UNPKG

@zhsz/cool-design-dv

Version:

122 lines (121 loc) 4.32 kB
import { defineComponent, getCurrentInstance, useAttrs, inject, computed, useSlots, onMounted, onBeforeUnmount, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, createElementVNode, normalizeStyle, renderSlot } from "vue"; import "./style.css"; import Box from "../dv-box/index.mjs"; import { dvPageSymbols } from "../../symbols/index.mjs"; import { addResizeListener, removeResizeListener } from "../../utils/resize-event.mjs"; import { useAdorn } from "../../hooks/useAdorn.mjs"; import { baseConfig } from "../../hooks/useConfig.mjs"; const _hoisted_1 = ["height"]; const _hoisted_2 = ["stroke", "points"]; const _hoisted_3 = ["stroke", "points"]; const _hoisted_4 = ["height"]; const _hoisted_5 = ["stroke", "points"]; const _hoisted_6 = ["stroke", "points"]; const __default__ = defineComponent({ name: "DvAdorn7" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { duration: { type: Number, default: 3 }, reverse: Boolean, opacity: { type: Number, default: 1 } }, emits: ["resize"], setup(__props, { emit: __emit }) { var _a, _b, _c; const props = __props; const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy; const emits = __emit; const $attrs = useAttrs(); const page = inject(dvPageSymbols, null); const { resize, classes, styles, width, height, dark, light } = useAdorn( emits, ((_c = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.value) == null ? void 0 : _c.color) ?? baseConfig.color, props, page ); const svgStyle = computed(() => { return { ...styles.value, "line-height": `${height.value}px` }; }); const $slots = useSlots(); const spanStyle = computed(() => { if ($slots == null ? void 0 : $slots.default) { return void 0; } return { width: `${width.value - 21 - 21 - 20}px` }; }); 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-adorn-7", unref(classes)], style: svgStyle.value, "default-width": "300px", "default-height": "20px" }, unref($attrs)), { default: withCtx(() => [ (openBlock(), createElementBlock("svg", { width: "21px", height: `${unref(height)}px` }, [ createElementVNode("polyline", { "stroke-width": "4", fill: "transparent", stroke: unref(dark), points: `10, 0 19, ${unref(height) / 2} 10, ${unref(height)}` }, null, 8, _hoisted_2), createElementVNode("polyline", { "stroke-width": "2", fill: "transparent", stroke: unref(light), points: `2, 0 11, ${unref(height) / 2} 2, ${unref(height)}` }, null, 8, _hoisted_3) ], 8, _hoisted_1)), createElementVNode("span", { style: normalizeStyle(spanStyle.value) }, [ renderSlot(_ctx.$slots, "default") ], 4), (openBlock(), createElementBlock("svg", { width: "21px", height: `${unref(height)}px` }, [ createElementVNode("polyline", { "stroke-width": "4", fill: "transparent", stroke: unref(dark), points: `11, 0 2, ${unref(height) / 2} 11, ${unref(height)}` }, null, 8, _hoisted_5), createElementVNode("polyline", { "stroke-width": "2", fill: "transparent", stroke: unref(light), points: `19, 0 10, ${unref(height) / 2} 19, ${unref(height)}` }, null, 8, _hoisted_6) ], 8, _hoisted_4)) ]), _: 3 }, 16, ["class", "style"]); }; } }); export { _sfc_main as default };