@pixelium/web-vue 0.0.2-fix → 0.0.3-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/README.zh.md +6 -3
- package/dist/font.css +1 -1
- package/dist/index.d.ts +1602 -248
- package/dist/normalize.css +2 -0
- package/dist/pixelium-vue-icon-hn.cjs +1 -1
- package/dist/pixelium-vue-icon-hn.css +2 -1
- package/dist/pixelium-vue-icon-hn.js +8533 -8154
- package/dist/pixelium-vue-icon-hn.umd.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.cjs +1 -1
- package/dist/pixelium-vue-icon-pa.css +2 -1
- package/dist/pixelium-vue-icon-pa.js +10625 -10143
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -1
- package/dist/pixelium-vue.cjs +2 -2
- package/dist/pixelium-vue.css +2 -1
- package/dist/pixelium-vue.js +7407 -5854
- package/dist/pixelium-vue.umd.cjs +2 -2
- package/es/aside/index.css +1 -0
- package/es/aside/index.js +46 -151
- package/es/auto-complete/draw.d.ts +1 -1
- package/es/auto-complete/draw.js +26 -51
- package/es/auto-complete/index.css +92 -32
- package/es/auto-complete/index.d.ts +12 -15
- package/es/auto-complete/index.js +338 -400
- package/es/auto-complete/type.d.ts +25 -13
- package/es/avatar/css.js +2 -0
- package/es/avatar/draw.d.ts +2 -0
- package/es/avatar/draw.js +11 -0
- package/es/avatar/index.css +49 -0
- package/es/avatar/index.d.ts +15 -0
- package/es/avatar/index.js +110 -0
- package/es/avatar/type.d.ts +34 -0
- package/es/button/draw.d.ts +4 -4
- package/es/button/draw.js +213 -297
- package/es/button/index.css +40 -30
- package/es/button/index.d.ts +0 -4
- package/es/button/index.js +230 -256
- package/es/button/type.d.ts +3 -3
- package/es/button-group/index.css +0 -3
- package/es/button-group/index.d.ts +1 -2
- package/es/button-group/index.js +59 -31
- package/es/button-group/type.d.ts +21 -4
- package/es/checkbox/css.js +2 -0
- package/es/checkbox/draw.d.ts +4 -0
- package/es/checkbox/draw.js +46 -0
- package/es/checkbox/index.css +85 -0
- package/es/checkbox/index.d.ts +31 -0
- package/es/checkbox/index.js +206 -0
- package/es/checkbox/type.d.ts +88 -0
- package/es/checkbox-group/css.js +2 -0
- package/es/checkbox-group/index.css +20 -0
- package/es/checkbox-group/index.d.ts +23 -0
- package/es/checkbox-group/index.js +84 -0
- package/es/checkbox-group/type.d.ts +78 -0
- package/es/col/index.d.ts +2 -2
- package/es/col/index.js +43 -58
- package/es/container/index.css +1 -0
- package/es/container/index.js +18 -31
- package/es/divider/index.js +39 -53
- package/es/empty/index.css +4 -4
- package/es/empty/index.js +16 -71
- package/es/entry.js +102 -0
- package/es/footer/index.css +1 -0
- package/es/footer/index.js +31 -40
- package/es/form/css.js +1 -0
- package/es/form/index.d.ts +27 -0
- package/es/form/index.js +125 -0
- package/es/form/type.d.ts +238 -0
- package/es/form/use-form.d.ts +4 -0
- package/es/form/use-form.js +48 -0
- package/es/form-item/css.js +2 -0
- package/es/form-item/index.css +77 -0
- package/es/form-item/index.d.ts +37 -0
- package/es/form-item/index.js +318 -0
- package/es/form-item/type.d.ts +96 -0
- package/es/grid/index.js +56 -75
- package/es/grid-item/css.js +0 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +85 -121
- package/es/header/index.css +1 -0
- package/es/header/index.js +31 -40
- package/es/icon/index.js +44 -55
- package/es/icons/css-hn.js +0 -1
- package/es/icons/css-pa.js +0 -1
- package/es/icons/icon-hn.js +10337 -15986
- package/es/icons/icon-pa.js +12573 -17447
- package/es/image/css.js +2 -0
- package/es/image/index.css +69 -0
- package/es/image/index.d.ts +35 -0
- package/es/image/index.js +199 -0
- package/es/image/type.d.ts +126 -0
- package/es/index.css +1 -515
- package/es/index.d.ts +22 -2
- package/es/index.js +144 -123
- package/es/input/draw.d.ts +1 -1
- package/es/input/draw.js +26 -51
- package/es/input/index.css +85 -33
- package/es/input/index.d.ts +9 -16
- package/es/input/index.js +319 -423
- package/es/input/type.d.ts +3 -3
- package/es/input-group/index.css +0 -1
- package/es/input-group/index.d.ts +2 -2
- package/es/input-group/index.js +66 -37
- package/es/input-group/type.d.ts +16 -4
- package/es/input-group-label/draw.d.ts +1 -1
- package/es/input-group-label/draw.js +26 -51
- package/es/input-group-label/index.css +33 -22
- package/es/input-group-label/index.d.ts +1 -4
- package/es/input-group-label/index.js +104 -127
- package/es/input-group-label/type.d.ts +3 -3
- package/es/input-number/draw.d.ts +1 -1
- package/es/input-number/draw.js +26 -51
- package/es/input-number/index.css +90 -35
- package/es/input-number/index.d.ts +9 -16
- package/es/input-number/index.js +428 -536
- package/es/input-number/type.d.ts +3 -3
- package/es/input-tag/draw.d.ts +1 -1
- package/es/input-tag/draw.js +26 -48
- package/es/input-tag/index.css +100 -33
- package/es/input-tag/index.d.ts +7 -13
- package/es/input-tag/index.js +442 -467
- package/es/input-tag/type.d.ts +24 -13
- package/es/link/index.js +75 -106
- package/es/main/index.css +4 -0
- package/es/main/index.d.ts +4 -1
- package/es/main/index.js +15 -15
- package/es/main/type.d.ts +7 -0
- package/es/mask/index.js +94 -115
- package/es/message/index.css +1 -1
- package/es/message/index.js +168 -346
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +98 -114
- package/es/message-box/message-box-wrapped.js +33 -46
- package/es/message-box/message-box.js +79 -111
- package/es/option-list/index.css +13 -13
- package/es/option-list/index.d.ts +4 -31
- package/es/option-list/index.js +99 -167
- package/es/option-list/type.d.ts +5 -1
- package/es/pixelate/pixel.d.ts +5 -0
- package/es/pixelate/pixel.js +70 -0
- package/es/pixelate/pixelate.worker.d.ts +1 -0
- package/es/popover/index.d.ts +13 -99
- package/es/popover/index.js +75 -238
- package/es/popover/type.d.ts +7 -2
- package/es/popup/css.js +1 -0
- package/es/popup/index.d.ts +210 -0
- package/es/popup/index.js +203 -0
- package/es/popup/type.d.ts +105 -0
- package/es/popup-content/draw.d.ts +2 -2
- package/es/popup-content/draw.js +98 -143
- package/es/popup-content/index.css +11 -11
- package/es/popup-content/index.d.ts +1 -0
- package/es/popup-content/index.js +253 -1576
- package/es/popup-content/type.d.ts +1 -0
- package/es/popup-trigger/index.d.ts +8 -2
- package/es/popup-trigger/index.js +122 -95
- package/es/popup-trigger/type.d.ts +4 -1
- package/es/popup-wrapper/css.js +2 -0
- package/es/popup-wrapper/index.css +14 -0
- package/es/popup-wrapper/index.d.ts +18 -0
- package/es/popup-wrapper/index.js +67 -0
- package/es/popup-wrapper/type.d.ts +9 -0
- package/es/radio/css.js +1 -0
- package/es/radio/draw.d.ts +4 -0
- package/es/radio/draw.js +47 -0
- package/es/radio/index.d.ts +30 -0
- package/es/radio/index.js +190 -0
- package/es/radio/style.css +73 -0
- package/es/radio/type.d.ts +76 -0
- package/es/radio-group/css.js +2 -0
- package/es/radio-group/index.css +20 -0
- package/es/radio-group/index.d.ts +23 -0
- package/es/radio-group/index.js +77 -0
- package/es/radio-group/type.d.ts +77 -0
- package/es/row/index.js +56 -70
- package/es/select/draw.d.ts +1 -1
- package/es/select/draw.js +26 -51
- package/es/select/index.css +118 -36
- package/es/select/index.d.ts +14 -16
- package/es/select/index.js +625 -675
- package/es/select/type.d.ts +60 -25
- package/es/share/const/event-bus-key.js +1 -6
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +22 -24
- package/es/share/const/provide-key.d.ts +5 -0
- package/es/share/const/provide-key.js +6 -5
- package/es/share/const/style.d.ts +6 -0
- package/es/share/const/style.js +7 -0
- package/es/share/hook/use-cancelable-delay.d.ts +1 -0
- package/es/share/hook/use-cancelable-delay.js +42 -0
- package/es/share/hook/use-click-outside-listener.d.ts +1 -1
- package/es/share/hook/use-click-outside-listener.js +28 -41
- package/es/share/hook/use-composition.js +17 -15
- package/es/share/hook/use-controlled-mode.d.ts +3 -3
- package/es/share/hook/use-controlled-mode.js +20 -23
- package/es/share/hook/use-dark-mode.js +51 -65
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +47 -45
- package/es/share/hook/use-lazy-load.d.ts +10 -0
- package/es/share/hook/use-lazy-load.js +133 -0
- package/es/share/hook/use-props-detect.d.ts +2 -0
- package/es/share/hook/use-resize-observer.d.ts +1 -2
- package/es/share/hook/use-resize-observer.js +28 -20
- package/es/share/hook/use-screen-width.js +27 -36
- package/es/share/hook/use-smooth-transition.d.ts +2 -0
- package/es/share/hook/use-smooth-transition.js +65 -0
- package/es/share/hook/use-textarea-height.js +86 -92
- package/es/share/hook/use-theme-mode.js +41 -42
- package/es/share/hook/use-transition-end.d.ts +2 -0
- package/es/share/hook/use-transition-end.js +12 -0
- package/es/share/hook/use-watch-global-css-var.js +12 -16
- package/es/share/hook/use-window-resize-listener.d.ts +1 -0
- package/es/share/hook/use-window-resize-listener.js +15 -0
- package/es/share/hook/use-z-index.js +30 -27
- package/es/share/style/index.css +5 -0
- package/es/share/type/index.d.ts +18 -3
- package/es/share/util/color.d.ts +5 -3
- package/es/share/util/color.js +156 -149
- package/es/share/util/common.d.ts +7 -2
- package/es/share/util/common.js +127 -65
- package/es/share/util/console.d.ts +3 -3
- package/es/share/util/console.js +10 -7
- package/es/share/util/dom.d.ts +19 -0
- package/es/share/util/dom.js +88 -0
- package/es/share/util/env.d.ts +1 -0
- package/es/share/util/env.js +5 -4
- package/es/share/util/event-bus.js +3 -20
- package/es/share/util/lru-cache.js +29 -33
- package/es/share/util/pixel.d.ts +4 -0
- package/es/share/util/plot.d.ts +8 -3
- package/es/share/util/plot.js +457 -229
- package/es/share/util/reactivity.d.ts +8 -0
- package/es/share/util/reactivity.js +23 -0
- package/es/share/util/render.js +31 -41
- package/es/share/util/theme.d.ts +3 -0
- package/es/share/util/theme.js +77 -57
- package/es/slider/css.js +2 -0
- package/es/slider/draw.d.ts +25 -0
- package/es/slider/draw.js +113 -0
- package/es/slider/index.css +119 -0
- package/es/slider/index.d.ts +66 -0
- package/es/slider/index.js +503 -0
- package/es/slider/type.d.ts +162 -0
- package/es/slider/util.d.ts +37 -0
- package/es/slider/util.js +130 -0
- package/es/space/index.css +24 -29
- package/es/space/index.js +73 -97
- package/es/spin/index.css +18 -17
- package/es/spin/index.js +72 -102
- package/es/spin/type.d.ts +11 -5
- package/es/switch/css.js +2 -0
- package/es/switch/draw.d.ts +2 -0
- package/es/switch/draw.js +18 -0
- package/es/switch/index.css +121 -0
- package/es/switch/index.d.ts +42 -0
- package/es/switch/index.js +259 -0
- package/es/switch/type.d.ts +133 -0
- package/es/tag/draw.d.ts +2 -2
- package/es/tag/draw.js +80 -127
- package/es/tag/index.css +38 -22
- package/es/tag/index.d.ts +2 -2
- package/es/tag/index.js +121 -190
- package/es/tag/type.d.ts +3 -3
- package/es/text-outline/css.js +2 -0
- package/es/text-outline/index.css +4 -0
- package/es/text-outline/index.d.ts +17 -0
- package/es/text-outline/index.js +33 -0
- package/es/text-outline/type.d.ts +23 -0
- package/es/textarea/draw.js +9 -11
- package/es/textarea/index.css +37 -23
- package/es/textarea/index.d.ts +8 -14
- package/es/textarea/index.js +274 -262
- package/es/tooltip/index.d.ts +100 -4
- package/es/tooltip/index.js +70 -226
- package/es/tooltip/type.d.ts +7 -2
- package/es/vendor.js +504 -0
- package/es/virtual-list/css.js +2 -0
- package/es/virtual-list/index.css +25 -0
- package/es/virtual-list/index.d.ts +11 -0
- package/es/virtual-list/index.js +313 -0
- package/es/virtual-list/type.d.ts +26 -0
- package/package.json +10 -16
- package/es/grid-item/index.css +0 -0
- /package/es/message-box/{message-box.css → index.css} +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import './css.js'
|
|
2
|
+
import { F as m, L as qe, _ as E } from "../vendor.js";
|
|
3
|
+
import { r as GET_ELEMENT_RENDERED } from "../share/const/index.js";
|
|
4
|
+
import { t as inBrowser } from "../share/util/env.js";
|
|
5
|
+
import { n as calcPixelSize } from "../share/util/plot.js";
|
|
6
|
+
import { n as logWarn } from "../share/util/console.js";
|
|
7
|
+
import { t as popup_content_default } from "../popup-content/index.js";
|
|
8
|
+
import { r as checkMouseInsideElementFromEvent } from "../share/util/dom.js";
|
|
9
|
+
import { t as popup_trigger_default } from "../popup-trigger/index.js";
|
|
10
|
+
import { t as useCancelableDelay } from "../share/hook/use-cancelable-delay.js";
|
|
11
|
+
import { Fragment, computed, createVNode, defineComponent, nextTick, onMounted, ref, shallowRef, useSlots, watch } from "vue";
|
|
12
|
+
var popup_default = /* @__PURE__ */ defineComponent({
|
|
13
|
+
name: "Popup",
|
|
14
|
+
__name: "index",
|
|
15
|
+
props: {
|
|
16
|
+
content: null,
|
|
17
|
+
visible: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: void 0
|
|
20
|
+
},
|
|
21
|
+
defaultVisible: {
|
|
22
|
+
type: Boolean,
|
|
23
|
+
default: void 0
|
|
24
|
+
},
|
|
25
|
+
placement: { default: "top" },
|
|
26
|
+
trigger: { default: "hover" },
|
|
27
|
+
offset: { default: 8 },
|
|
28
|
+
variant: { default: "light" },
|
|
29
|
+
arrow: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true
|
|
32
|
+
},
|
|
33
|
+
disabled: { type: Boolean },
|
|
34
|
+
zIndex: null,
|
|
35
|
+
root: { default: "body" },
|
|
36
|
+
widthEqual: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: false
|
|
39
|
+
},
|
|
40
|
+
contentStyle: null,
|
|
41
|
+
destroyOnHide: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
default: false
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
emits: [
|
|
47
|
+
"update:visible",
|
|
48
|
+
"close",
|
|
49
|
+
"open"
|
|
50
|
+
],
|
|
51
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
52
|
+
const props = __props;
|
|
53
|
+
const controlledMode = computed(() => {
|
|
54
|
+
return props.visible !== void 0;
|
|
55
|
+
});
|
|
56
|
+
const preDisplay = controlledMode.value ? props.visible : props.defaultVisible;
|
|
57
|
+
const display = ref(E(preDisplay) ? false : preDisplay);
|
|
58
|
+
const contentRef = shallowRef();
|
|
59
|
+
const triggerRef = shallowRef();
|
|
60
|
+
const emits = __emit;
|
|
61
|
+
const currentTrigger = shallowRef(null);
|
|
62
|
+
const [wait, cancel] = useCancelableDelay();
|
|
63
|
+
const getElFromVNode = (node) => {
|
|
64
|
+
if (inBrowser()) {
|
|
65
|
+
let triggerEl = null;
|
|
66
|
+
if (node.el instanceof HTMLElement || node.el instanceof SVGElement) triggerEl = node.el;
|
|
67
|
+
else {
|
|
68
|
+
var _node$component;
|
|
69
|
+
const getElFunc = (_node$component = node.component) === null || _node$component === void 0 || (_node$component = _node$component.exposed) === null || _node$component === void 0 ? void 0 : _node$component[GET_ELEMENT_RENDERED];
|
|
70
|
+
if (m(getElFunc)) {
|
|
71
|
+
const el = getElFunc();
|
|
72
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) triggerEl = el;
|
|
73
|
+
}
|
|
74
|
+
if (triggerEl === null) logWarn(`Please ensure that the root node of the default slot passed to Tooltip, Popover, and similar components can be rendered as a DOM element, or expose a getElementRender function on the component to retrieve the DOM element for balloon attachment.`);
|
|
75
|
+
}
|
|
76
|
+
return triggerEl;
|
|
77
|
+
} else return null;
|
|
78
|
+
};
|
|
79
|
+
async function openHandler(node, e) {
|
|
80
|
+
cancel();
|
|
81
|
+
currentTrigger.value = getElFromVNode(node);
|
|
82
|
+
await openHandlerImpl(currentTrigger.value);
|
|
83
|
+
emits("open", e);
|
|
84
|
+
}
|
|
85
|
+
async function openHandlerImpl(node, controlled = false) {
|
|
86
|
+
if (node) resizeObserver === null || resizeObserver === void 0 || resizeObserver.observe(node);
|
|
87
|
+
if (controlledMode.value && !controlled) {
|
|
88
|
+
emits("update:visible", true);
|
|
89
|
+
await nextTick(() => {});
|
|
90
|
+
display.value = !!props.visible;
|
|
91
|
+
} else display.value = true;
|
|
92
|
+
}
|
|
93
|
+
async function closeHandler(e) {
|
|
94
|
+
if (e.type === "mouseup" || e.type === "touchend") {
|
|
95
|
+
const contentEl = contentRef.value && contentRef.value.content;
|
|
96
|
+
if (contentEl && checkMouseInsideElementFromEvent(contentEl, e)) return;
|
|
97
|
+
}
|
|
98
|
+
if (props.trigger === "click") {
|
|
99
|
+
if (contentRef.value && contentRef.value.content && contentRef.value.content.contains(e.target) || !display.value) return;
|
|
100
|
+
} else if (!await wait()) return;
|
|
101
|
+
if (controlledMode.value) {
|
|
102
|
+
emits("update:visible", false);
|
|
103
|
+
await nextTick(() => {});
|
|
104
|
+
display.value = !!props.visible;
|
|
105
|
+
} else display.value = false;
|
|
106
|
+
emits("close", e);
|
|
107
|
+
}
|
|
108
|
+
const contentMouseenterHandler = () => {
|
|
109
|
+
if (props.trigger === "click") return;
|
|
110
|
+
cancel();
|
|
111
|
+
};
|
|
112
|
+
const dragging = ref(false);
|
|
113
|
+
const contentMouseleaveHandler = (e) => {
|
|
114
|
+
if (props.trigger === "click") return;
|
|
115
|
+
if (dragging.value) return;
|
|
116
|
+
closeHandler(e);
|
|
117
|
+
};
|
|
118
|
+
const preprocessCurrentTrigger = () => {
|
|
119
|
+
if (!inBrowser()) return;
|
|
120
|
+
if (!currentTrigger.value && triggerRef.value && triggerRef.value.firstVNode) {
|
|
121
|
+
resizeObserver === null || resizeObserver === void 0 || resizeObserver.disconnect();
|
|
122
|
+
currentTrigger.value = getElFromVNode(triggerRef.value.firstVNode);
|
|
123
|
+
if (currentTrigger.value instanceof HTMLElement) resizeObserver === null || resizeObserver === void 0 || resizeObserver.observe(currentTrigger.value);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const processVisible = (value) => {
|
|
127
|
+
if (value) {
|
|
128
|
+
preprocessCurrentTrigger();
|
|
129
|
+
if (currentTrigger.value) openHandlerImpl(currentTrigger.value, true);
|
|
130
|
+
} else display.value = false;
|
|
131
|
+
};
|
|
132
|
+
watch(() => props.visible, () => {
|
|
133
|
+
processVisible(!!props.visible);
|
|
134
|
+
});
|
|
135
|
+
const resizeObserver = inBrowser() ? new ResizeObserver(() => {
|
|
136
|
+
updateRenderState();
|
|
137
|
+
}) : null;
|
|
138
|
+
onMounted(() => {
|
|
139
|
+
nextTick(() => {
|
|
140
|
+
if (display.value) updateRenderState();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
const updateRenderState = () => {
|
|
144
|
+
preprocessCurrentTrigger();
|
|
145
|
+
if (inBrowser()) {
|
|
146
|
+
var _contentRef$value;
|
|
147
|
+
(_contentRef$value = contentRef.value) === null || _contentRef$value === void 0 || _contentRef$value.updateRenderState();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
__expose({
|
|
151
|
+
triggerContent: contentRef,
|
|
152
|
+
updateRenderState
|
|
153
|
+
});
|
|
154
|
+
const slots = useSlots();
|
|
155
|
+
const checkCurrentTrigger = (_) => {
|
|
156
|
+
if (!inBrowser()) return false;
|
|
157
|
+
return currentTrigger.value instanceof HTMLElement;
|
|
158
|
+
};
|
|
159
|
+
const dragHandler = qe(() => {
|
|
160
|
+
updateRenderState();
|
|
161
|
+
}, 20);
|
|
162
|
+
const dragStartHandler = () => {
|
|
163
|
+
dragging.value = true;
|
|
164
|
+
};
|
|
165
|
+
const dragEndHandler = () => {
|
|
166
|
+
dragging.value = false;
|
|
167
|
+
};
|
|
168
|
+
return () => {
|
|
169
|
+
const pixelSize = calcPixelSize();
|
|
170
|
+
return createVNode(Fragment, null, [createVNode(popup_trigger_default, {
|
|
171
|
+
"trigger": props.trigger,
|
|
172
|
+
"disabled": props.disabled,
|
|
173
|
+
"onClose": closeHandler,
|
|
174
|
+
"onOpen": openHandler,
|
|
175
|
+
"onDrag": dragHandler,
|
|
176
|
+
"onDragStart": dragStartHandler,
|
|
177
|
+
"onDragEnd": dragEndHandler,
|
|
178
|
+
"ref": (node) => triggerRef.value = node
|
|
179
|
+
}, { default: () => {
|
|
180
|
+
var _slots$default;
|
|
181
|
+
return [(_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
182
|
+
} }), createVNode(popup_content_default, {
|
|
183
|
+
"visible": display.value,
|
|
184
|
+
"content": props.content,
|
|
185
|
+
"zIndex": props.zIndex,
|
|
186
|
+
"variant": props.variant,
|
|
187
|
+
"placement": props.placement,
|
|
188
|
+
"arrow": props.arrow,
|
|
189
|
+
"offset": props.offset,
|
|
190
|
+
"borderRadius": pixelSize * 4,
|
|
191
|
+
"root": props.root,
|
|
192
|
+
"widthEqual": props.widthEqual,
|
|
193
|
+
"target": checkCurrentTrigger(currentTrigger.value) ? currentTrigger.value : null,
|
|
194
|
+
"onContentMouseenter": contentMouseenterHandler,
|
|
195
|
+
"onContentMouseleave": contentMouseleaveHandler,
|
|
196
|
+
"contentStyle": props.contentStyle,
|
|
197
|
+
"destroyOnHide": props.destroyOnHide,
|
|
198
|
+
"ref": (node) => contentRef.value = node
|
|
199
|
+
}, { content: slots.content })]);
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
export { popup_default as t };
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
export type PopupProps = {
|
|
3
|
+
/**
|
|
4
|
+
* @property {string} [content]
|
|
5
|
+
* @version 0.0.2
|
|
6
|
+
*/
|
|
7
|
+
content?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @property {boolean | null} [visible]
|
|
10
|
+
* @version 0.0.2
|
|
11
|
+
*/
|
|
12
|
+
visible?: boolean | null;
|
|
13
|
+
/**
|
|
14
|
+
* @property {boolean | null} [defaultVisible]
|
|
15
|
+
* @version 0.0.2
|
|
16
|
+
*/
|
|
17
|
+
defaultVisible?: boolean | null;
|
|
18
|
+
/**
|
|
19
|
+
* @property {'top' | 'right' | 'bottom' | 'left' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end'} [placement='top']
|
|
20
|
+
* @version 0.0.2
|
|
21
|
+
*/
|
|
22
|
+
placement?: 'top' | 'right' | 'bottom' | 'left' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end';
|
|
23
|
+
/**
|
|
24
|
+
* @property {'hover' | 'click'} [trigger='hover']
|
|
25
|
+
* @version 0.0.2
|
|
26
|
+
*/
|
|
27
|
+
trigger?: 'hover' | 'click';
|
|
28
|
+
/**
|
|
29
|
+
* @property {number} [offset=8]
|
|
30
|
+
* @version 0.0.2
|
|
31
|
+
*/
|
|
32
|
+
offset?: number;
|
|
33
|
+
/**
|
|
34
|
+
* @property {'dark' | 'light'} [variant='light']
|
|
35
|
+
* @version 0.0.2
|
|
36
|
+
*/
|
|
37
|
+
variant?: 'dark' | 'light';
|
|
38
|
+
/**
|
|
39
|
+
* @property {boolean} [arrow=true]
|
|
40
|
+
* @version 0.0.2
|
|
41
|
+
*/
|
|
42
|
+
arrow?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* @property {boolean} [disabled=false]
|
|
45
|
+
* @version 0.0.2
|
|
46
|
+
*/
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* @property {number} [zIndex]
|
|
50
|
+
* @version 0.0.2
|
|
51
|
+
*/
|
|
52
|
+
zIndex?: number;
|
|
53
|
+
/**
|
|
54
|
+
* @property { HTMLElement | string} [root='body']
|
|
55
|
+
* @version 0.0.2
|
|
56
|
+
*/
|
|
57
|
+
root?: HTMLElement | string;
|
|
58
|
+
/**
|
|
59
|
+
* @property {boolean} [widthEqual=false]
|
|
60
|
+
* @version 0.0.2
|
|
61
|
+
*/
|
|
62
|
+
widthEqual?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* @property {CSSProperties} [contentStyle]
|
|
65
|
+
* @version 0.0.2
|
|
66
|
+
*/
|
|
67
|
+
contentStyle?: CSSProperties;
|
|
68
|
+
/**
|
|
69
|
+
* @property {boolean} [destroyOnHide=false]
|
|
70
|
+
* @version 0.0.3
|
|
71
|
+
*/
|
|
72
|
+
destroyOnHide?: boolean;
|
|
73
|
+
};
|
|
74
|
+
export type PopupEvents = {
|
|
75
|
+
/**
|
|
76
|
+
* @event update:visible
|
|
77
|
+
* @param {boolean} value
|
|
78
|
+
* @version 0.0.2
|
|
79
|
+
*/
|
|
80
|
+
'update:visible': [value: boolean];
|
|
81
|
+
/**
|
|
82
|
+
* @event close
|
|
83
|
+
* @param {MouseEvent} e
|
|
84
|
+
* @version 0.0.2
|
|
85
|
+
*/
|
|
86
|
+
close: [e: MouseEvent | TouchEvent];
|
|
87
|
+
/**
|
|
88
|
+
* @event open
|
|
89
|
+
* @param {MouseEvent} e
|
|
90
|
+
* @version 0.0.2
|
|
91
|
+
*/
|
|
92
|
+
open: [e: MouseEvent];
|
|
93
|
+
};
|
|
94
|
+
export type PopupSlots = {
|
|
95
|
+
/**
|
|
96
|
+
* @slot default
|
|
97
|
+
* @version 0.0.0-beta
|
|
98
|
+
*/
|
|
99
|
+
default: {};
|
|
100
|
+
/**
|
|
101
|
+
* @slot content
|
|
102
|
+
* @version 0.0.0-beta
|
|
103
|
+
*/
|
|
104
|
+
content: {};
|
|
105
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RgbaColor } from '../share/type';
|
|
2
2
|
import type { PopupContentProps } from './type';
|
|
3
|
-
export declare function getBorderColor(variant: PopupContentProps['variant']): RgbaColor;
|
|
4
|
-
export declare function getBackgroundColor(variant: PopupContentProps['variant']): RgbaColor;
|
|
3
|
+
export declare function getBorderColor(variant: PopupContentProps['variant']): RgbaColor | null;
|
|
4
|
+
export declare function getBackgroundColor(variant: PopupContentProps['variant']): RgbaColor | null;
|
|
5
5
|
export declare const drawBorder: (ctx: CanvasRenderingContext2D, width: number, height: number, center: [number, number][], borderRadius: number[], rad: [number, number][], borderColor: RgbaColor, pixelSize: number, offsetX: number, offsetY: number, offsetTop: number, offsetLeft: number) => void;
|
|
6
6
|
export declare const drawArrow: (ctx: CanvasRenderingContext2D, width: number, height: number, borderColor: RgbaColor, backgroundColor: RgbaColor, pixelSize: number, placement: "top" | "left" | "right" | "bottom", popupSide: "start" | "end" | "middle", arrowXOffset: number, arrowYOffset: number) => void;
|
package/es/popup-content/draw.js
CHANGED
|
@@ -1,151 +1,106 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { a as drawCircle } from "../share/util/plot.js";
|
|
2
|
+
import { a as rgbaColor2string, n as getGlobalThemeColor } from "../share/util/color.js";
|
|
3
3
|
function getBorderColor(variant) {
|
|
4
|
-
|
|
4
|
+
return variant === "light" ? getGlobalThemeColor("neutral", 10) : getGlobalThemeColor("neutral", 9);
|
|
5
5
|
}
|
|
6
6
|
function getBackgroundColor(variant) {
|
|
7
|
-
|
|
7
|
+
return variant === "light" ? getGlobalThemeColor("neutral", 1) : getGlobalThemeColor("neutral", 10);
|
|
8
8
|
}
|
|
9
9
|
const drawBorder = (ctx, width, height, center, borderRadius, rad, borderColor, pixelSize, offsetX, offsetY, offsetTop, offsetLeft) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
center[i][1] + offsetTop,
|
|
17
|
-
borderRadius[i],
|
|
18
|
-
rad[i][0],
|
|
19
|
-
rad[i][1],
|
|
20
|
-
pixelSize
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
if (center[1][0] + pixelSize > center[0][0]) {
|
|
25
|
-
ctx.fillRect(
|
|
26
|
-
center[0][0] + offsetLeft,
|
|
27
|
-
offsetTop,
|
|
28
|
-
center[1][0] - center[0][0] + pixelSize,
|
|
29
|
-
pixelSize
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
if (center[2][1] + pixelSize > center[1][1]) {
|
|
33
|
-
ctx.fillRect(
|
|
34
|
-
width - offsetX - pixelSize + offsetLeft,
|
|
35
|
-
center[1][1] + offsetTop,
|
|
36
|
-
pixelSize,
|
|
37
|
-
center[2][1] - center[1][1] + pixelSize
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
if (center[3][0] < center[2][0] + pixelSize) {
|
|
41
|
-
ctx.fillRect(
|
|
42
|
-
center[3][0] + offsetLeft,
|
|
43
|
-
height - offsetY - pixelSize + offsetTop,
|
|
44
|
-
center[2][0] - center[3][0] + pixelSize,
|
|
45
|
-
pixelSize
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
if (center[3][1] + pixelSize > center[0][1]) {
|
|
49
|
-
ctx.fillRect(
|
|
50
|
-
offsetLeft,
|
|
51
|
-
center[0][1] + offsetTop,
|
|
52
|
-
pixelSize,
|
|
53
|
-
center[3][1] - center[0][1] + pixelSize
|
|
54
|
-
);
|
|
55
|
-
}
|
|
10
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
11
|
+
for (let i = 0; i < 4; i++) if (borderRadius[i] > pixelSize) drawCircle(ctx, center[i][0] + offsetLeft, center[i][1] + offsetTop, borderRadius[i], rad[i][0], rad[i][1], pixelSize);
|
|
12
|
+
if (center[1][0] + pixelSize > center[0][0]) ctx.fillRect(center[0][0] + offsetLeft, offsetTop, center[1][0] - center[0][0] + pixelSize, pixelSize);
|
|
13
|
+
if (center[2][1] + pixelSize > center[1][1]) ctx.fillRect(width - offsetX - pixelSize + offsetLeft, center[1][1] + offsetTop, pixelSize, center[2][1] - center[1][1] + pixelSize);
|
|
14
|
+
if (center[3][0] < center[2][0] + pixelSize) ctx.fillRect(center[3][0] + offsetLeft, height - offsetY - pixelSize + offsetTop, center[2][0] - center[3][0] + pixelSize, pixelSize);
|
|
15
|
+
if (center[3][1] + pixelSize > center[0][1]) ctx.fillRect(offsetLeft, center[0][1] + offsetTop, pixelSize, center[3][1] - center[0][1] + pixelSize);
|
|
56
16
|
};
|
|
57
17
|
const drawArrow = (ctx, width, height, borderColor, backgroundColor, pixelSize, placement, popupSide, arrowXOffset, arrowYOffset) => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
};
|
|
146
|
-
export {
|
|
147
|
-
getBackgroundColor as a,
|
|
148
|
-
drawArrow as b,
|
|
149
|
-
drawBorder as d,
|
|
150
|
-
getBorderColor as g
|
|
18
|
+
const factors = [
|
|
19
|
+
0,
|
|
20
|
+
1,
|
|
21
|
+
1
|
|
22
|
+
];
|
|
23
|
+
const borderColorStr = rgbaColor2string(borderColor);
|
|
24
|
+
const bgColorStr = rgbaColor2string(backgroundColor);
|
|
25
|
+
const adjust = (coord) => popupSide === "start" ? Math.floor(coord) : popupSide === "end" ? Math.ceil(coord) : Math.round(coord);
|
|
26
|
+
switch (placement) {
|
|
27
|
+
case "right": {
|
|
28
|
+
const vertexY = adjust(arrowYOffset - pixelSize / 2);
|
|
29
|
+
const startX = 0;
|
|
30
|
+
for (let i = 0; i < 3; i++) {
|
|
31
|
+
const spread = factors[i] * pixelSize;
|
|
32
|
+
const top = Math.max(0, vertexY - spread);
|
|
33
|
+
const bottom = Math.min(height, vertexY + spread);
|
|
34
|
+
const x = startX + i * pixelSize;
|
|
35
|
+
ctx.fillStyle = i == 2 ? bgColorStr : borderColorStr;
|
|
36
|
+
ctx.fillRect(x, top, pixelSize, pixelSize);
|
|
37
|
+
ctx.fillRect(x, bottom, pixelSize, pixelSize);
|
|
38
|
+
const bgHeight = bottom - top - pixelSize;
|
|
39
|
+
if (bgHeight > 0) {
|
|
40
|
+
ctx.fillStyle = bgColorStr;
|
|
41
|
+
ctx.fillRect(x, top + pixelSize, pixelSize, bgHeight);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "left": {
|
|
47
|
+
const vertexY = adjust(arrowYOffset - pixelSize / 2);
|
|
48
|
+
const startX = Math.round(width - pixelSize);
|
|
49
|
+
for (let i = 0; i < 3; i++) {
|
|
50
|
+
const spread = factors[i] * pixelSize;
|
|
51
|
+
const top = Math.max(0, vertexY - spread);
|
|
52
|
+
const bottom = Math.min(height - pixelSize, vertexY + spread);
|
|
53
|
+
const x = startX - i * pixelSize;
|
|
54
|
+
ctx.fillStyle = i == 2 ? bgColorStr : borderColorStr;
|
|
55
|
+
ctx.fillRect(x, top, pixelSize, pixelSize);
|
|
56
|
+
ctx.fillRect(x, bottom, pixelSize, pixelSize);
|
|
57
|
+
const bgHeight = bottom - top - pixelSize;
|
|
58
|
+
if (bgHeight > 0) {
|
|
59
|
+
ctx.fillStyle = bgColorStr;
|
|
60
|
+
ctx.fillRect(x, top + pixelSize, pixelSize, bgHeight);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
case "bottom": {
|
|
66
|
+
const vertexX = adjust(arrowXOffset - pixelSize / 2);
|
|
67
|
+
const startY = 0;
|
|
68
|
+
for (let i = 0; i < 3; i++) {
|
|
69
|
+
const spread = factors[i] * pixelSize;
|
|
70
|
+
const left = Math.max(0, vertexX - spread);
|
|
71
|
+
const right = Math.min(vertexX + spread, width - pixelSize);
|
|
72
|
+
const y = startY + i * pixelSize;
|
|
73
|
+
ctx.fillStyle = i == 2 ? bgColorStr : borderColorStr;
|
|
74
|
+
ctx.fillRect(left, y, pixelSize, pixelSize);
|
|
75
|
+
ctx.fillRect(right, y, pixelSize, pixelSize);
|
|
76
|
+
const bgWidth = right - left - pixelSize;
|
|
77
|
+
if (bgWidth > 0) {
|
|
78
|
+
ctx.fillStyle = bgColorStr;
|
|
79
|
+
ctx.fillRect(left + pixelSize, y, bgWidth, pixelSize);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
case "top":
|
|
85
|
+
default: {
|
|
86
|
+
const vertexX = adjust(arrowXOffset - pixelSize / 2);
|
|
87
|
+
const startY = Math.round(height - pixelSize);
|
|
88
|
+
for (let i = 0; i < 3; i++) {
|
|
89
|
+
const spread = factors[i] * pixelSize;
|
|
90
|
+
const left = Math.max(0, vertexX - spread);
|
|
91
|
+
const right = Math.min(vertexX + spread, width - pixelSize);
|
|
92
|
+
const y = startY - i * pixelSize;
|
|
93
|
+
ctx.fillStyle = i == 2 ? bgColorStr : borderColorStr;
|
|
94
|
+
ctx.fillRect(left, y, pixelSize, pixelSize);
|
|
95
|
+
ctx.fillRect(right, y, pixelSize, pixelSize);
|
|
96
|
+
const bgWidth = right - left - pixelSize;
|
|
97
|
+
if (bgWidth > 0) {
|
|
98
|
+
ctx.fillStyle = bgColorStr;
|
|
99
|
+
ctx.fillRect(left + pixelSize, y, bgWidth, pixelSize);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
151
105
|
};
|
|
106
|
+
export { getBorderColor as i, drawBorder as n, getBackgroundColor as r, drawArrow as t };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
.px-popup-content {
|
|
2
|
-
padding: var(--px-interval-1) var(--px-interval-2);
|
|
3
|
-
display: inline-block;
|
|
4
2
|
--text-color: var(--px-neutral-10);
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
padding: 4px 8px;
|
|
4
|
+
display: inline-block;
|
|
7
5
|
border-color: transparent;
|
|
8
6
|
border-width: var(--px-bit);
|
|
9
7
|
border-style: solid;
|
|
10
8
|
background-color: transparent;
|
|
11
9
|
box-sizing: border-box;
|
|
12
10
|
position: absolute;
|
|
11
|
+
color: var(--text-color);
|
|
13
12
|
white-space: pre-line;
|
|
14
|
-
min-height: var(--
|
|
15
|
-
min-width:
|
|
13
|
+
min-height: calc(28px + 2 * var(--px-bit));
|
|
14
|
+
min-width: 36px;
|
|
15
|
+
width: max-content;
|
|
16
16
|
transition: transform 0.25s, opacity 0.25s;
|
|
17
17
|
}
|
|
18
18
|
.px-popup-content-fade__top-enter-to,
|
|
@@ -59,29 +59,29 @@
|
|
|
59
59
|
--text-color: var(--px-neutral-1);
|
|
60
60
|
}
|
|
61
61
|
.px-popup-content__top.px-popup-content__arrow {
|
|
62
|
-
min-height: calc(var(--px-bit) *
|
|
63
|
-
padding-bottom: calc(
|
|
62
|
+
min-height: calc(var(--px-bit) * 12);
|
|
63
|
+
padding-bottom: calc(4px + var(--px-bit) * 2);
|
|
64
64
|
}
|
|
65
65
|
.px-popup-content__top.px-popup-content__arrow .px-popup-content-arrow {
|
|
66
66
|
bottom: calc(-1 * var(--px-bit));
|
|
67
67
|
}
|
|
68
68
|
.px-popup-content__bottom.px-popup-content__arrow {
|
|
69
69
|
min-height: calc(var(--px-bit) * 12);
|
|
70
|
-
padding-top: calc(
|
|
70
|
+
padding-top: calc(4px + var(--px-bit) * 2);
|
|
71
71
|
}
|
|
72
72
|
.px-popup-content__bottom.px-popup-content__arrow .px-popup-content-arrow {
|
|
73
73
|
top: calc(-1 * var(--px-bit));
|
|
74
74
|
}
|
|
75
75
|
.px-popup-content__left.px-popup-content__arrow {
|
|
76
76
|
min-width: calc(var(--px-bit) * 12);
|
|
77
|
-
padding-right: calc(
|
|
77
|
+
padding-right: calc(8px + var(--px-bit) * 2);
|
|
78
78
|
}
|
|
79
79
|
.px-popup-content__left.px-popup-content__arrow .px-popup-content-arrow {
|
|
80
80
|
right: calc(-1 * var(--px-bit));
|
|
81
81
|
}
|
|
82
82
|
.px-popup-content__right.px-popup-content__arrow {
|
|
83
83
|
min-width: calc(var(--px-bit) * 12);
|
|
84
|
-
padding-left: calc(
|
|
84
|
+
padding-left: calc(8px + var(--px-bit) * 2);
|
|
85
85
|
}
|
|
86
86
|
.px-popup-content__right.px-popup-content__arrow .px-popup-content-arrow {
|
|
87
87
|
left: calc(-1 * var(--px-bit));
|
|
@@ -20,6 +20,7 @@ declare const __VLS_component: import("vue").DefineComponent<PopupContentProps,
|
|
|
20
20
|
visible: boolean | null;
|
|
21
21
|
arrow: boolean;
|
|
22
22
|
widthEqual: boolean;
|
|
23
|
+
destroyOnHide: boolean;
|
|
23
24
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
25
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
25
26
|
export default _default;
|