@zhsz/cool-design-dv
Version:
180 lines (179 loc) • 6.99 kB
JavaScript
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 = ["fill"];
const _hoisted_4 = ["fill", "cx"];
const _hoisted_5 = ["fill", "cx", "cy"];
const _hoisted_6 = ["fill", "cy"];
const _hoisted_7 = ["stroke", "points"];
const _hoisted_8 = ["stroke", "points"];
const _hoisted_9 = ["stroke", "points"];
const _hoisted_10 = ["stroke", "points"];
const _hoisted_11 = ["stroke"];
const _hoisted_12 = ["stroke"];
const _hoisted_13 = ["stroke", "points"];
const _hoisted_14 = ["stroke", "points"];
const _hoisted_15 = ["stroke", "points"];
const _hoisted_16 = ["stroke", "points"];
const _hoisted_17 = ["stroke", "points"];
const _hoisted_18 = ["stroke", "points"];
const __default__ = defineComponent({
name: "DvBorder5"
});
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-5", 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: `
9, 7 ${unref(width) - 9}, 7 ${unref(width) - 9}, ${unref(height) - 7} 9, ${unref(height) - 7}
`
}, null, 8, _hoisted_2),
createElementVNode("circle", {
fill: unref(light),
cx: "5",
cy: "5",
r: "2"
}, null, 8, _hoisted_3),
createElementVNode("circle", {
fill: unref(light),
cx: unref(width) - 5,
cy: "5",
r: "2"
}, null, 8, _hoisted_4),
createElementVNode("circle", {
fill: unref(light),
cx: unref(width) - 5,
cy: unref(height) - 5,
r: "2"
}, null, 8, _hoisted_5),
createElementVNode("circle", {
fill: unref(light),
cx: "5",
cy: unref(height) - 5,
r: "2"
}, null, 8, _hoisted_6),
createElementVNode("polyline", {
stroke: unref(dark),
points: `10, 4 ${unref(width) - 10}, 4`
}, null, 8, _hoisted_7),
createElementVNode("polyline", {
stroke: unref(dark),
points: `10, ${unref(height) - 4} ${unref(width) - 10}, ${unref(height) - 4}`
}, null, 8, _hoisted_8),
createElementVNode("polyline", {
stroke: unref(dark),
points: `5, 70 5, ${unref(height) - 70}`
}, null, 8, _hoisted_9),
createElementVNode("polyline", {
stroke: unref(dark),
points: `${unref(width) - 5}, 70 ${unref(width) - 5}, ${unref(height) - 70}`
}, null, 8, _hoisted_10),
createElementVNode("polyline", {
stroke: unref(dark),
points: `3, 10, 3, 50`
}, null, 8, _hoisted_11),
createElementVNode("polyline", {
stroke: unref(dark),
points: `7, 30 7, 80`
}, null, 8, _hoisted_12),
createElementVNode("polyline", {
stroke: unref(dark),
points: `${unref(width) - 3}, 10 ${unref(width) - 3}, 50`
}, null, 8, _hoisted_13),
createElementVNode("polyline", {
stroke: unref(dark),
points: `${unref(width) - 7}, 30 ${unref(width) - 7}, 80`
}, null, 8, _hoisted_14),
createElementVNode("polyline", {
stroke: unref(dark),
points: `3, ${unref(height) - 10} 3, ${unref(height) - 50}`
}, null, 8, _hoisted_15),
createElementVNode("polyline", {
stroke: unref(dark),
points: `7, ${unref(height) - 30} 7, ${unref(height) - 80}`
}, null, 8, _hoisted_16),
createElementVNode("polyline", {
stroke: unref(dark),
points: `${unref(width) - 3}, ${unref(height) - 10} ${unref(width) - 3}, ${unref(height) - 50}`
}, null, 8, _hoisted_17),
createElementVNode("polyline", {
stroke: unref(dark),
points: `${unref(width) - 7}, ${unref(height) - 30} ${unref(width) - 7}, ${unref(height) - 80}`
}, null, 8, _hoisted_18)
], 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
};