UNPKG

@zhsz/cool-design-dv

Version:

120 lines (119 loc) 4.53 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); const vue = require("vue"); require("./style.css"); const index$1 = require("../dv-box/index.js"); const index$2 = require("../dv-content/index.js"); const index = require("../../symbols/index.js"); const resizeEvent = require("../../utils/resize-event.js"); const useBorder = require("../../hooks/useBorder.js"); const useConfig = require("../../hooks/useConfig.js"); const _hoisted_1 = ["width", "height"]; const _hoisted_2 = ["fill", "points"]; const _hoisted_3 = ["fill"]; const __default__ = vue.defineComponent({ name: "DvBorder9" }); const _sfc_main = /* @__PURE__ */ vue.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 = vue.getCurrentInstance()) == null ? void 0 : _a.proxy; const emits = __emit; const $attrs = vue.useAttrs(); const props = __props; const page = vue.inject(index.dvPageSymbols, null); const border = vue.ref(["left-top", "right-top", "left-bottom", "right-bottom"]); const fill = vue.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.useBorder( emits, ((_c = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.value) == null ? void 0 : _c.color) ?? useConfig.baseConfig.color, props, page ); const svgStyle = vue.computed(() => { return { ...styles.value, "box-shadow": `inset 0 0 30px 3px ${dark.value}`, "border-radius": "15px" }; }); const boxStyles = vue.computed(() => { return { backgroundColor: fill.value }; }); vue.onMounted(() => { resize(instance == null ? void 0 : instance.$el); resizeEvent.addResizeListener(instance == null ? void 0 : instance.$el, () => resize(instance == null ? void 0 : instance.$el)); }); vue.onBeforeUnmount(() => { resizeEvent.removeResizeListener(instance == null ? void 0 : instance.$el, () => resize(instance == null ? void 0 : instance.$el)); }); return (_ctx, _cache) => { return vue.openBlock(), vue.createBlock(vue.unref(index$1.default), vue.mergeProps({ class: ["my-dv-border-9", vue.unref(classes)], "default-width": "400px", "default-height": "300px", padding: "0" }, { ...vue.unref($attrs), ...props }, { style: boxStyles.value }), { default: vue.withCtx(() => [ (vue.openBlock(), vue.createElementBlock("svg", { class: "my-dv-border__svg", width: vue.unref(width), height: vue.unref(height), style: vue.normalizeStyle(svgStyle.value) }, [ vue.createElementVNode("polygon", { fill: fill.value, points: ` 4, 0 ${vue.unref(width) - 4}, 0 ${vue.unref(width)}, 4 ${vue.unref(width)}, ${vue.unref(height) - 4} ${vue.unref(width) - 4}, ${vue.unref(height)} 4, ${vue.unref(height)} 0, ${vue.unref(height) - 4} 0, 4 ` }, null, 8, _hoisted_2) ], 12, _hoisted_1)), (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(border.value, (item) => { return vue.openBlock(), vue.createElementBlock("svg", { width: "150px", height: "150px", key: item, class: vue.normalizeClass(`my-dv-border-9__${item} my-dv-border-9__item`) }, [ vue.createElementVNode("polygon", { fill: vue.unref(light), points: "40, 0 5, 0 0, 5 0, 16 3, 19 3, 7 7, 3 35, 3" }, null, 8, _hoisted_3) ], 2); }), 128)), vue.createVNode(vue.unref(index$2.default), { padding: vue.unref($attrs).padding }, { default: vue.withCtx(() => [ vue.renderSlot(_ctx.$slots, "default") ]), _: 3 }, 8, ["padding"]) ]), _: 3 }, 16, ["class", "style"]); }; } }); exports.default = _sfc_main;