UNPKG

@zhsz/cool-design-dv

Version:

136 lines (135 loc) 5.4 kB
import { defineComponent, getCurrentInstance, useAttrs, inject, computed, onMounted, onBeforeUnmount, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, normalizeStyle, createElementVNode, createVNode, renderSlot } from "vue"; import "./style.css"; import Box from "../dv-box/index.mjs"; import BoxContent from "../dv-content/index.mjs"; import { dvPageSymbols } from "../../symbols/index.mjs"; import { addResizeListener, removeResizeListener } from "../../utils/resize-event.mjs"; import { useBorder } from "../../hooks/useBorder.mjs"; import { baseConfig } from "../../hooks/useConfig.mjs"; const _hoisted_1 = ["width", "height"]; const _hoisted_2 = ["fill", "points"]; const _hoisted_3 = ["stroke", "points"]; const _hoisted_4 = ["stroke", "points"]; const _hoisted_5 = ["stroke", "points"]; const _hoisted_6 = ["stroke", "points"]; const _hoisted_7 = ["stroke", "points"]; const _hoisted_8 = ["stroke", "points"]; const __default__ = defineComponent({ name: "DvBorder4" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { fill: { type: String, default() { return "transparent"; } }, reverse: Boolean, opacity: { type: Number, default: 1 } }, emits: ["resize"], setup(__props, { emit: __emit }) { var _a, _b, _c; const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy; const emits = __emit; const $attrs = useAttrs(); const props = __props; const page = inject(dvPageSymbols, null); const fill = computed(() => { var _a2, _b2; return props.fill || ((_b2 = (_a2 = page == null ? void 0 : page.settings) == null ? void 0 : _a2.value) == null ? void 0 : _b2.fill); }); const { resize, classes, styles, width, height, dark, light } = useBorder( emits, ((_c = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.value) == null ? void 0 : _c.color) ?? baseConfig.color, props, page ); onMounted(() => { resize(instance == null ? void 0 : instance.$el); addResizeListener(instance == null ? void 0 : instance.$el, () => resize(instance == null ? void 0 : instance.$el)); }); onBeforeUnmount(() => { removeResizeListener(instance == null ? void 0 : instance.$el, () => resize(instance == null ? void 0 : instance.$el)); }); return (_ctx, _cache) => { return openBlock(), createBlock(unref(Box), mergeProps({ class: ["my-dv-border-4", unref(classes)], "default-width": "400px", "default-height": "300px", padding: "0" }, { ...unref($attrs), ...props }), { default: withCtx(() => [ (openBlock(), createElementBlock("svg", { class: "my-dv-border__svg", width: unref(width), height: unref(height), style: normalizeStyle(unref(styles)) }, [ createElementVNode("polygon", { fill: fill.value, points: ` 10, 22 ${unref(width) - 22}, 22 ${unref(width) - 22}, ${unref(height) - 86} ${unref(width) - 84}, ${unref(height) - 24} 10, ${unref(height) - 24} ` }, null, 8, _hoisted_2), createElementVNode("polyline", { class: "dv-bb5-line-1", fill: "transparent", stroke: unref(light), points: `8, 5 ${unref(width) - 5}, 5 ${unref(width) - 5}, ${unref(height) - 100} ${unref(width) - 100}, ${unref(height) - 5} 8, ${unref(height) - 5} 8, 5` }, null, 8, _hoisted_3), createElementVNode("polyline", { class: "dv-bb5-line-2", fill: "transparent", stroke: unref(dark), points: `3, 5 ${unref(width) - 20}, 5 ${unref(width) - 20}, ${unref(height) - 60} ${unref(width) - 74}, ${unref(height) - 5} 3, ${unref(height) - 5} 3, 5` }, null, 8, _hoisted_4), createElementVNode("polyline", { class: "dv-bb5-line-3", "stroke-width": "5", stroke: unref(dark), points: `50, 13 ${unref(width) - 35}, 13` }, null, 8, _hoisted_5), createElementVNode("polyline", { class: "dv-bb5-line-4", "stroke-width": "2", stroke: unref(dark), points: `15, 20 ${unref(width) - 35}, 20` }, null, 8, _hoisted_6), createElementVNode("polyline", { class: "dv-bb5-line-5", "stroke-width": "2", stroke: unref(dark), points: `15, ${unref(height) - 20} ${unref(width) - 110}, ${unref(height) - 20}` }, null, 8, _hoisted_7), createElementVNode("polyline", { class: "dv-bb5-line-6", "stroke-width": "5", stroke: unref(dark), points: `15, ${unref(height) - 13} ${unref(width) - 110}, ${unref(height) - 13}` }, null, 8, _hoisted_8) ], 12, _hoisted_1)), createVNode(unref(BoxContent), { padding: unref($attrs).padding }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 8, ["padding"]) ]), _: 3 }, 16, ["class"]); }; } }); export { _sfc_main as default };