@pixelium/web-vue 0.0.1-beta → 0.0.2-fix
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 +21 -10
- package/README.zh.md +21 -10
- package/dist/icon-pa.d.ts +490 -0
- package/dist/index.d.ts +1586 -10
- package/dist/pixelium-vue-icon-pa.cjs +1 -0
- package/dist/pixelium-vue-icon-pa.css +1 -0
- package/dist/pixelium-vue-icon-pa.js +10143 -0
- package/dist/pixelium-vue-icon-pa.umd.cjs +1 -0
- package/dist/pixelium-vue.cjs +12 -1
- package/dist/pixelium-vue.css +1 -1
- package/dist/pixelium-vue.js +5370 -1093
- package/dist/pixelium-vue.umd.cjs +12 -1
- package/es/aside/css.js +1 -1
- package/es/aside/index.js +60 -13
- package/es/auto-complete/css.js +2 -0
- package/es/auto-complete/draw.d.ts +2 -0
- package/es/auto-complete/draw.js +52 -0
- package/es/auto-complete/index.css +123 -0
- package/es/auto-complete/index.d.ts +35 -0
- package/es/auto-complete/index.js +402 -0
- package/es/auto-complete/type.d.ts +192 -0
- package/es/button/css.js +1 -1
- package/es/button/draw.d.ts +1 -2
- package/es/button/draw.js +105 -123
- package/es/button/index.css +24 -14
- package/es/button/index.js +70 -121
- package/es/button-group/css.js +1 -1
- package/es/button-group/index.d.ts +0 -1
- package/es/button-group/index.js +11 -37
- package/es/button-group/type.d.ts +1 -1
- package/es/col/css.js +1 -1
- package/es/col/index.d.ts +2 -2
- package/es/container/css.js +1 -1
- package/es/divider/css.js +1 -1
- package/es/empty/css.js +2 -0
- package/es/empty/index.css +19 -0
- package/es/empty/index.d.ts +17 -0
- package/es/empty/index.js +73 -0
- package/es/empty/type.d.ts +19 -0
- package/es/footer/css.js +1 -1
- package/es/grid/css.js +1 -1
- package/es/grid/index.js +5 -1
- package/es/grid-item/css.js +1 -1
- package/es/grid-item/index.d.ts +1 -1
- package/es/grid-item/index.js +7 -3
- package/es/header/css.js +1 -1
- package/es/icon/css.js +1 -1
- package/es/icon/index.css +0 -3
- package/es/icon/index.js +1 -1
- package/es/icons/css-pa.js +2 -0
- package/es/icons/icon-hn.js +1 -1
- package/es/icons/icon-pa.css +9 -0
- package/es/icons/icon-pa.d.ts +490 -0
- package/es/icons/icon-pa.js +17449 -0
- package/es/index.css +22 -8
- package/es/index.d.ts +18 -1
- package/es/index.js +63 -2
- package/es/input/css.js +2 -0
- package/es/input/draw.d.ts +2 -0
- package/es/input/draw.js +52 -0
- package/es/input/index.css +138 -0
- package/es/input/index.d.ts +50 -0
- package/es/input/index.js +432 -0
- package/es/input/type.d.ts +175 -0
- package/es/input-group/css.js +2 -0
- package/es/input-group/index.css +24 -0
- package/es/input-group/index.d.ts +17 -0
- package/es/input-group/index.js +40 -0
- package/es/input-group/type.d.ts +30 -0
- package/es/input-group-label/css.js +2 -0
- package/es/input-group-label/draw.d.ts +2 -0
- package/es/input-group-label/draw.js +52 -0
- package/es/input-group-label/index.css +50 -0
- package/es/input-group-label/index.d.ts +16 -0
- package/es/input-group-label/index.js +129 -0
- package/es/input-group-label/type.d.ts +30 -0
- package/es/input-number/css.js +2 -0
- package/es/input-number/draw.d.ts +2 -0
- package/es/input-number/draw.js +52 -0
- package/es/input-number/index.css +161 -0
- package/es/input-number/index.d.ts +47 -0
- package/es/input-number/index.js +543 -0
- package/es/input-number/type.d.ts +183 -0
- package/es/input-tag/css.js +2 -0
- package/es/input-tag/draw.d.ts +2 -0
- package/es/input-tag/draw.js +49 -0
- package/es/input-tag/index.css +133 -0
- package/es/input-tag/index.d.ts +73 -0
- package/es/input-tag/index.js +474 -0
- package/es/input-tag/type.d.ts +212 -0
- package/es/link/css.js +1 -1
- package/es/link/index.css +2 -5
- package/es/link/index.js +10 -6
- package/es/main/css.js +1 -1
- package/es/mask/css.js +2 -0
- package/es/mask/index.css +17 -0
- package/es/mask/index.d.ts +8 -0
- package/es/mask/index.js +117 -0
- package/es/mask/type.d.ts +27 -0
- package/es/message/css.js +1 -1
- package/es/message/index.css +26 -26
- package/es/message/index.d.ts +1 -1
- package/es/message/index.js +22 -50
- package/es/message-box/css.js +1 -1
- package/es/message-box/index.js +40 -30
- package/es/message-box/message-box-wrapped.d.ts +0 -1
- package/es/message-box/message-box-wrapped.js +2 -2
- package/es/message-box/message-box.d.ts +2 -1
- package/es/message-box/message-box.js +10 -8
- package/es/message-box/type.d.ts +14 -4
- package/es/option-list/css.js +2 -0
- package/es/option-list/index.css +57 -0
- package/es/option-list/index.d.ts +38 -0
- package/es/option-list/index.js +169 -0
- package/es/option-list/type.d.ts +16 -0
- package/es/popover/css.js +1 -0
- package/es/popover/index.d.ts +203 -0
- package/es/popover/index.js +240 -0
- package/es/popover/type.d.ts +100 -0
- package/es/popup-content/css.js +2 -0
- package/es/popup-content/draw.d.ts +6 -0
- package/es/popup-content/draw.js +151 -0
- package/es/popup-content/index.css +99 -0
- package/es/popup-content/index.d.ts +30 -0
- package/es/popup-content/index.js +1578 -0
- package/es/popup-content/type.d.ts +20 -0
- package/es/popup-trigger/css.js +1 -0
- package/es/popup-trigger/index.d.ts +22 -0
- package/es/popup-trigger/index.js +97 -0
- package/es/popup-trigger/type.d.ts +9 -0
- package/es/row/css.js +1 -1
- package/es/select/css.js +2 -0
- package/es/select/draw.d.ts +2 -0
- package/es/select/draw.js +52 -0
- package/es/select/index.css +152 -0
- package/es/select/index.d.ts +44 -0
- package/es/select/index.js +677 -0
- package/es/select/type.d.ts +252 -0
- package/es/share/const/event-bus-key.d.ts +4 -0
- package/es/share/const/event-bus-key.js +10 -0
- package/es/share/const/index.d.ts +4 -0
- package/es/share/const/index.js +11 -2
- package/es/share/const/provide-key.d.ts +3 -0
- package/es/share/const/provide-key.js +8 -0
- package/es/share/hook/use-click-outside-listener.d.ts +4 -0
- package/es/share/hook/use-click-outside-listener.js +44 -0
- package/es/share/hook/use-composition.d.ts +5 -0
- package/es/share/hook/use-composition.js +17 -0
- package/es/share/hook/use-controlled-mode.d.ts +6 -0
- package/es/share/hook/use-controlled-mode.js +25 -0
- package/es/share/hook/use-dark-mode.js +11 -3
- package/es/share/hook/use-index-of-children.d.ts +2 -1
- package/es/share/hook/use-index-of-children.js +25 -35
- package/es/share/hook/use-resize-observer.js +1 -1
- package/es/share/hook/use-textarea-height.d.ts +5 -0
- package/es/share/hook/use-textarea-height.js +116 -0
- package/es/share/hook/use-watch-global-css-var.d.ts +1 -0
- package/es/share/hook/use-watch-global-css-var.js +19 -0
- package/es/share/hook/use-z-index.d.ts +6 -0
- package/es/share/hook/use-z-index.js +32 -0
- package/es/share/type/index.d.ts +9 -1
- package/es/share/util/color.js +4 -2
- package/es/share/util/common.d.ts +5 -0
- package/es/share/util/common.js +71 -0
- package/es/share/util/event-bus.d.ts +1 -0
- package/es/share/util/event-bus.js +20 -0
- package/es/share/util/plot.d.ts +15 -2
- package/es/share/util/plot.js +200 -30
- package/es/share/util/render.d.ts +1 -0
- package/es/share/util/render.js +10 -2
- package/es/share/util/theme.js +23 -4
- package/es/space/css.js +1 -1
- package/es/space/index.css +5 -0
- package/es/space/index.js +2 -2
- package/es/spin/css.js +2 -0
- package/es/spin/index.css +66 -0
- package/es/spin/index.d.ts +24 -0
- package/es/spin/index.js +104 -0
- package/es/spin/type.d.ts +54 -0
- package/es/tag/css.js +2 -0
- package/es/tag/draw.d.ts +6 -0
- package/es/tag/draw.js +135 -0
- package/es/tag/index.css +372 -0
- package/es/tag/index.d.ts +23 -0
- package/es/tag/index.js +193 -0
- package/es/tag/type.d.ts +58 -0
- package/es/textarea/css.js +2 -0
- package/es/textarea/draw.d.ts +2 -0
- package/es/textarea/draw.js +13 -0
- package/es/textarea/index.css +108 -0
- package/es/textarea/index.d.ts +49 -0
- package/es/textarea/index.js +267 -0
- package/es/textarea/type.d.ts +169 -0
- package/es/tooltip/css.js +1 -0
- package/es/tooltip/index.d.ts +20 -0
- package/es/tooltip/index.js +228 -0
- package/es/tooltip/type.d.ts +77 -0
- package/package.json +17 -3
- package/es/icons/{css.js → css-hn.js} +1 -1
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import './css.js'
|
|
2
|
+
import { defineComponent, computed, ref, shallowRef, watch, onMounted, nextTick, useSlots, createVNode, Fragment } from "vue";
|
|
3
|
+
import { N } from "../aside/index.js";
|
|
4
|
+
import { _ as _sfc_main$2 } from "../popup-content/index.js";
|
|
5
|
+
import { _ as _sfc_main$1 } from "../popup-trigger/index.js";
|
|
6
|
+
import { i as inBrowser } from "../share/util/env.js";
|
|
7
|
+
const BORDER_RADIUS = 16;
|
|
8
|
+
const HOVER_CLOSE_DELAY = 300;
|
|
9
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
10
|
+
...{
|
|
11
|
+
name: "Popover"
|
|
12
|
+
},
|
|
13
|
+
__name: "index",
|
|
14
|
+
props: {
|
|
15
|
+
content: null,
|
|
16
|
+
visible: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
20
|
+
defaultVisible: {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: void 0
|
|
23
|
+
},
|
|
24
|
+
placement: {
|
|
25
|
+
default: "top"
|
|
26
|
+
},
|
|
27
|
+
trigger: {
|
|
28
|
+
default: "hover"
|
|
29
|
+
},
|
|
30
|
+
offset: {
|
|
31
|
+
default: 8
|
|
32
|
+
},
|
|
33
|
+
variant: {
|
|
34
|
+
default: "light"
|
|
35
|
+
},
|
|
36
|
+
arrow: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: true
|
|
39
|
+
},
|
|
40
|
+
disabled: {
|
|
41
|
+
type: Boolean
|
|
42
|
+
},
|
|
43
|
+
zIndex: null,
|
|
44
|
+
root: {
|
|
45
|
+
default: "body"
|
|
46
|
+
},
|
|
47
|
+
widthEqual: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
contentStyle: null
|
|
52
|
+
},
|
|
53
|
+
emits: ["update:visible", "close", "open"],
|
|
54
|
+
setup(__props, {
|
|
55
|
+
expose: __expose,
|
|
56
|
+
emit: __emit
|
|
57
|
+
}) {
|
|
58
|
+
const props = __props;
|
|
59
|
+
const controlledMode = computed(() => {
|
|
60
|
+
return props.visible !== void 0;
|
|
61
|
+
});
|
|
62
|
+
const preDisplay = controlledMode.value ? props.visible : props.defaultVisible;
|
|
63
|
+
const display = ref(N(preDisplay) ? false : preDisplay);
|
|
64
|
+
const contentRef = shallowRef();
|
|
65
|
+
const triggerRef = shallowRef();
|
|
66
|
+
const emits = __emit;
|
|
67
|
+
const currentTrigger = shallowRef(null);
|
|
68
|
+
let closeDelayPromiseReject;
|
|
69
|
+
async function openHandler(node, e) {
|
|
70
|
+
if (closeDelayPromiseReject) {
|
|
71
|
+
closeDelayPromiseReject();
|
|
72
|
+
closeDelayPromiseReject = void 0;
|
|
73
|
+
}
|
|
74
|
+
await openHandlerImpl(node);
|
|
75
|
+
emits("open", e);
|
|
76
|
+
}
|
|
77
|
+
async function openHandlerImpl(node, controlled = false) {
|
|
78
|
+
if (inBrowser()) {
|
|
79
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
80
|
+
if (node.el instanceof HTMLElement) {
|
|
81
|
+
currentTrigger.value = node;
|
|
82
|
+
} else {
|
|
83
|
+
currentTrigger.value = null;
|
|
84
|
+
}
|
|
85
|
+
if (currentTrigger.value && currentTrigger.value.el instanceof HTMLElement) {
|
|
86
|
+
resizeObserver == null ? void 0 : resizeObserver.observe(currentTrigger.value.el);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (controlledMode.value && !controlled) {
|
|
90
|
+
emits("update:visible", true);
|
|
91
|
+
await nextTick(() => {
|
|
92
|
+
});
|
|
93
|
+
display.value = !!props.visible;
|
|
94
|
+
} else {
|
|
95
|
+
display.value = true;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async function closeHandler(e) {
|
|
99
|
+
if (props.trigger === "click") {
|
|
100
|
+
const clickContent = contentRef.value && contentRef.value.content && contentRef.value.content.contains(e.target);
|
|
101
|
+
if (clickContent || !display.value) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
} else {
|
|
105
|
+
if (closeDelayPromiseReject) {
|
|
106
|
+
closeDelayPromiseReject();
|
|
107
|
+
closeDelayPromiseReject = void 0;
|
|
108
|
+
}
|
|
109
|
+
const {
|
|
110
|
+
resolve,
|
|
111
|
+
reject,
|
|
112
|
+
promise
|
|
113
|
+
} = Promise.withResolvers();
|
|
114
|
+
closeDelayPromiseReject = reject;
|
|
115
|
+
setTimeout(() => {
|
|
116
|
+
resolve();
|
|
117
|
+
}, HOVER_CLOSE_DELAY);
|
|
118
|
+
try {
|
|
119
|
+
await promise;
|
|
120
|
+
} catch {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (controlledMode.value) {
|
|
125
|
+
emits("update:visible", false);
|
|
126
|
+
await nextTick(() => {
|
|
127
|
+
});
|
|
128
|
+
display.value = !!props.visible;
|
|
129
|
+
} else {
|
|
130
|
+
display.value = false;
|
|
131
|
+
}
|
|
132
|
+
emits("close", e);
|
|
133
|
+
}
|
|
134
|
+
const contentMouseenterHandler = () => {
|
|
135
|
+
if (props.trigger === "click") {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (closeDelayPromiseReject) {
|
|
139
|
+
closeDelayPromiseReject();
|
|
140
|
+
closeDelayPromiseReject = void 0;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const contentMouseleaveHandler = (e) => {
|
|
144
|
+
if (props.trigger === "click") {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
closeHandler(e);
|
|
148
|
+
};
|
|
149
|
+
const preprocessCurrentTrigger = () => {
|
|
150
|
+
if (!inBrowser()) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (!currentTrigger.value && triggerRef.value && triggerRef.value.firstVNode) {
|
|
154
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
155
|
+
currentTrigger.value = triggerRef.value.firstVNode;
|
|
156
|
+
if (currentTrigger.value.el instanceof HTMLElement) {
|
|
157
|
+
resizeObserver == null ? void 0 : resizeObserver.observe(currentTrigger.value.el);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
const processVisible = (value) => {
|
|
162
|
+
if (value) {
|
|
163
|
+
preprocessCurrentTrigger();
|
|
164
|
+
if (currentTrigger.value) {
|
|
165
|
+
openHandlerImpl(currentTrigger.value, true);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
display.value = false;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
watch(() => props.visible, () => {
|
|
172
|
+
processVisible(!!props.visible);
|
|
173
|
+
});
|
|
174
|
+
const resizeObserver = inBrowser() ? new ResizeObserver(() => {
|
|
175
|
+
updateRenderState();
|
|
176
|
+
}) : null;
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
nextTick(() => {
|
|
179
|
+
if (display.value) {
|
|
180
|
+
updateRenderState();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
const updateRenderState = () => {
|
|
185
|
+
var _a;
|
|
186
|
+
preprocessCurrentTrigger();
|
|
187
|
+
if (inBrowser()) {
|
|
188
|
+
(_a = contentRef.value) == null ? void 0 : _a.updateRenderState();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
__expose({
|
|
192
|
+
triggerContent: contentRef,
|
|
193
|
+
updateRenderState
|
|
194
|
+
});
|
|
195
|
+
const slots = useSlots();
|
|
196
|
+
const checkCurrentTrigger = (_) => {
|
|
197
|
+
var _a;
|
|
198
|
+
if (!inBrowser()) {
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
return ((_a = currentTrigger.value) == null ? void 0 : _a.el) instanceof HTMLElement;
|
|
202
|
+
};
|
|
203
|
+
return () => {
|
|
204
|
+
var _a;
|
|
205
|
+
return createVNode(Fragment, null, [createVNode(_sfc_main$1, {
|
|
206
|
+
"trigger": props.trigger,
|
|
207
|
+
"disabled": props.disabled,
|
|
208
|
+
"onClose": closeHandler,
|
|
209
|
+
"onOpen": openHandler,
|
|
210
|
+
"ref": (node) => triggerRef.value = node
|
|
211
|
+
}, {
|
|
212
|
+
default: () => {
|
|
213
|
+
var _a2;
|
|
214
|
+
return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
|
|
215
|
+
}
|
|
216
|
+
}), createVNode(_sfc_main$2, {
|
|
217
|
+
"visible": display.value,
|
|
218
|
+
"content": props.content,
|
|
219
|
+
"zIndex": props.zIndex,
|
|
220
|
+
"variant": props.variant,
|
|
221
|
+
"placement": props.placement,
|
|
222
|
+
"arrow": props.arrow,
|
|
223
|
+
"offset": props.offset,
|
|
224
|
+
"borderRadius": BORDER_RADIUS,
|
|
225
|
+
"root": props.root,
|
|
226
|
+
"widthEqual": props.widthEqual,
|
|
227
|
+
"target": checkCurrentTrigger((_a = currentTrigger.value) == null ? void 0 : _a.el) ? currentTrigger.value.el : null,
|
|
228
|
+
"onContentMouseenter": contentMouseenterHandler,
|
|
229
|
+
"onContentMouseleave": contentMouseleaveHandler,
|
|
230
|
+
"contentStyle": props.contentStyle,
|
|
231
|
+
"ref": (node) => contentRef.value = node
|
|
232
|
+
}, {
|
|
233
|
+
content: slots.content
|
|
234
|
+
})]);
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
export {
|
|
239
|
+
_sfc_main as _
|
|
240
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
export type PopoverProps = {
|
|
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} [disabled]
|
|
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
|
+
export type PopoverEvents = {
|
|
70
|
+
/**
|
|
71
|
+
* @event update:visible
|
|
72
|
+
* @param {boolean} value
|
|
73
|
+
* @version 0.0.2
|
|
74
|
+
*/
|
|
75
|
+
'update:visible': [value: boolean];
|
|
76
|
+
/**
|
|
77
|
+
* @event close
|
|
78
|
+
* @param {MouseEvent} e
|
|
79
|
+
* @version 0.0.2
|
|
80
|
+
*/
|
|
81
|
+
close: [e: MouseEvent];
|
|
82
|
+
/**
|
|
83
|
+
* @event open
|
|
84
|
+
* @param {MouseEvent} e
|
|
85
|
+
* @version 0.0.2
|
|
86
|
+
*/
|
|
87
|
+
open: [e: MouseEvent];
|
|
88
|
+
};
|
|
89
|
+
export type PopoverSlots = {
|
|
90
|
+
/**
|
|
91
|
+
* @slot default
|
|
92
|
+
* @version 0.0.0-beta
|
|
93
|
+
*/
|
|
94
|
+
default: {};
|
|
95
|
+
/**
|
|
96
|
+
* @slot content
|
|
97
|
+
* @version 0.0.0-beta
|
|
98
|
+
*/
|
|
99
|
+
content: {};
|
|
100
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RgbaColor } from '../share/type';
|
|
2
|
+
import type { PopupContentProps } from './type';
|
|
3
|
+
export declare function getBorderColor(variant: PopupContentProps['variant']): RgbaColor;
|
|
4
|
+
export declare function getBackgroundColor(variant: PopupContentProps['variant']): RgbaColor;
|
|
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
|
+
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;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { g as getGlobalThemeColor, r as rgbaColor2string } from "../share/util/color.js";
|
|
2
|
+
import { d as drawCircle } from "../share/util/plot.js";
|
|
3
|
+
function getBorderColor(variant) {
|
|
4
|
+
return variant === "light" ? getGlobalThemeColor("neutral", 10) : getGlobalThemeColor("neutral", 9);
|
|
5
|
+
}
|
|
6
|
+
function getBackgroundColor(variant) {
|
|
7
|
+
return variant === "light" ? getGlobalThemeColor("neutral", 1) : getGlobalThemeColor("neutral", 10);
|
|
8
|
+
}
|
|
9
|
+
const drawBorder = (ctx, width, height, center, borderRadius, rad, borderColor, pixelSize, offsetX, offsetY, offsetTop, offsetLeft) => {
|
|
10
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
11
|
+
for (let i = 0; i < 4; i++) {
|
|
12
|
+
if (borderRadius[i] > pixelSize) {
|
|
13
|
+
drawCircle(
|
|
14
|
+
ctx,
|
|
15
|
+
center[i][0] + offsetLeft,
|
|
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
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const drawArrow = (ctx, width, height, borderColor, backgroundColor, pixelSize, placement, popupSide, arrowXOffset, arrowYOffset) => {
|
|
58
|
+
switch (placement) {
|
|
59
|
+
case "right": {
|
|
60
|
+
const y = arrowYOffset - pixelSize / 2;
|
|
61
|
+
const vertex = [
|
|
62
|
+
0,
|
|
63
|
+
popupSide === "start" ? Math.floor(y) : popupSide === "end" ? Math.ceil(y) : Math.round(y)
|
|
64
|
+
];
|
|
65
|
+
for (let i = 0; i < 4; i++) {
|
|
66
|
+
const factor = i > 1 ? i - 1 : i;
|
|
67
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
68
|
+
const top = Math.max(0, vertex[1] - factor * pixelSize);
|
|
69
|
+
const bottom = Math.min(height, vertex[1] + factor * pixelSize);
|
|
70
|
+
const x = vertex[0] + i * pixelSize;
|
|
71
|
+
ctx.fillRect(x, top, pixelSize, pixelSize);
|
|
72
|
+
ctx.fillRect(x, bottom, pixelSize, pixelSize);
|
|
73
|
+
ctx.fillStyle = rgbaColor2string(backgroundColor);
|
|
74
|
+
if (bottom - top - pixelSize > 0) {
|
|
75
|
+
ctx.fillRect(x, top + pixelSize, pixelSize, bottom - top - pixelSize);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case "left": {
|
|
81
|
+
const y = arrowYOffset - pixelSize / 2;
|
|
82
|
+
const vertex = [
|
|
83
|
+
Math.round(width - pixelSize),
|
|
84
|
+
popupSide === "start" ? Math.floor(y) : popupSide === "end" ? Math.ceil(y) : Math.round(y)
|
|
85
|
+
];
|
|
86
|
+
for (let i = 0; i < 4; i++) {
|
|
87
|
+
const factor = i > 1 ? i - 1 : i;
|
|
88
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
89
|
+
const top = Math.max(0, vertex[1] - factor * pixelSize);
|
|
90
|
+
const bottom = Math.min(height - pixelSize, vertex[1] + factor * pixelSize);
|
|
91
|
+
const x = vertex[0] - i * pixelSize;
|
|
92
|
+
ctx.fillRect(x, top, pixelSize, pixelSize);
|
|
93
|
+
ctx.fillRect(x, bottom, pixelSize, pixelSize);
|
|
94
|
+
ctx.fillStyle = rgbaColor2string(backgroundColor);
|
|
95
|
+
if (bottom - top - pixelSize > 0) {
|
|
96
|
+
ctx.fillRect(x, top + pixelSize, pixelSize, bottom - top - pixelSize);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "bottom": {
|
|
102
|
+
const x = arrowXOffset - pixelSize / 2;
|
|
103
|
+
const vertex = [
|
|
104
|
+
popupSide === "start" ? Math.floor(x) : popupSide === "end" ? Math.ceil(x) : Math.round(x),
|
|
105
|
+
0
|
|
106
|
+
];
|
|
107
|
+
for (let i = 0; i < 4; i++) {
|
|
108
|
+
const factor = i > 1 ? i - 1 : i;
|
|
109
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
110
|
+
const left = Math.max(0, vertex[0] - factor * pixelSize);
|
|
111
|
+
const right = Math.min(vertex[0] + factor * pixelSize, width - pixelSize);
|
|
112
|
+
const y = vertex[1] + i * pixelSize;
|
|
113
|
+
ctx.fillRect(left, y, pixelSize, pixelSize);
|
|
114
|
+
ctx.fillRect(right, y, pixelSize, pixelSize);
|
|
115
|
+
ctx.fillStyle = rgbaColor2string(backgroundColor);
|
|
116
|
+
if (right - left - pixelSize > 0) {
|
|
117
|
+
ctx.fillRect(left + pixelSize, y, right - left - pixelSize, pixelSize);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
case "top":
|
|
123
|
+
default: {
|
|
124
|
+
const x = arrowXOffset - pixelSize / 2;
|
|
125
|
+
const vertex = [
|
|
126
|
+
popupSide === "start" ? Math.floor(x) : popupSide === "end" ? Math.ceil(x) : Math.round(x),
|
|
127
|
+
Math.round(height - pixelSize)
|
|
128
|
+
];
|
|
129
|
+
for (let i = 0; i < 4; i++) {
|
|
130
|
+
const factor = i > 1 ? i - 1 : i;
|
|
131
|
+
ctx.fillStyle = rgbaColor2string(borderColor);
|
|
132
|
+
const left = Math.max(0, vertex[0] - factor * pixelSize);
|
|
133
|
+
const right = Math.min(vertex[0] + factor * pixelSize, width - pixelSize);
|
|
134
|
+
const y = vertex[1] - i * pixelSize;
|
|
135
|
+
ctx.fillRect(left, y, pixelSize, pixelSize);
|
|
136
|
+
ctx.fillRect(right, y, pixelSize, pixelSize);
|
|
137
|
+
ctx.fillStyle = rgbaColor2string(backgroundColor);
|
|
138
|
+
if (right - left - pixelSize > 0) {
|
|
139
|
+
ctx.fillRect(left + pixelSize, y, right - left - pixelSize, pixelSize);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
export {
|
|
147
|
+
getBackgroundColor as a,
|
|
148
|
+
drawArrow as b,
|
|
149
|
+
drawBorder as d,
|
|
150
|
+
getBorderColor as g
|
|
151
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
.px-popup-content {
|
|
2
|
+
padding: var(--px-interval-1) var(--px-interval-2);
|
|
3
|
+
display: inline-block;
|
|
4
|
+
--text-color: var(--px-neutral-10);
|
|
5
|
+
--min-size: var(--px-interval-9);
|
|
6
|
+
color: var(--text-color);
|
|
7
|
+
border-color: transparent;
|
|
8
|
+
border-width: var(--px-bit);
|
|
9
|
+
border-style: solid;
|
|
10
|
+
background-color: transparent;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
position: absolute;
|
|
13
|
+
white-space: pre-line;
|
|
14
|
+
min-height: var(--min-size);
|
|
15
|
+
min-width: var(--min-size);
|
|
16
|
+
transition: transform 0.25s, opacity 0.25s;
|
|
17
|
+
}
|
|
18
|
+
.px-popup-content-fade__top-enter-to,
|
|
19
|
+
.px-popup-content-fade__top-leave-from {
|
|
20
|
+
opacity: 1;
|
|
21
|
+
transform: translateY(0);
|
|
22
|
+
}
|
|
23
|
+
.px-popup-content-fade__top-enter-from,
|
|
24
|
+
.px-popup-content-fade__top-leave-to {
|
|
25
|
+
opacity: 0;
|
|
26
|
+
transform: translateY(-20px);
|
|
27
|
+
}
|
|
28
|
+
.px-popup-content-fade__bottom-enter-to,
|
|
29
|
+
.px-popup-content-fade__bottom-leave-from {
|
|
30
|
+
opacity: 1;
|
|
31
|
+
transform: translateY(0);
|
|
32
|
+
}
|
|
33
|
+
.px-popup-content-fade__bottom-enter-from,
|
|
34
|
+
.px-popup-content-fade__bottom-leave-to {
|
|
35
|
+
opacity: 0;
|
|
36
|
+
transform: translateY(20px);
|
|
37
|
+
}
|
|
38
|
+
.px-popup-content-fade__left-enter-to,
|
|
39
|
+
.px-popup-content-fade__left-leave-from {
|
|
40
|
+
opacity: 1;
|
|
41
|
+
transform: translateY(0);
|
|
42
|
+
}
|
|
43
|
+
.px-popup-content-fade__left-enter-from,
|
|
44
|
+
.px-popup-content-fade__left-leave-to {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transform: translateX(-20px);
|
|
47
|
+
}
|
|
48
|
+
.px-popup-content-fade__right-enter-to,
|
|
49
|
+
.px-popup-content-fade__right-leave-from {
|
|
50
|
+
opacity: 1;
|
|
51
|
+
transform: translateX(0);
|
|
52
|
+
}
|
|
53
|
+
.px-popup-content-fade__right-enter-from,
|
|
54
|
+
.px-popup-content-fade__right-leave-to {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
transform: translateX(20px);
|
|
57
|
+
}
|
|
58
|
+
.px-popup-content__dark {
|
|
59
|
+
--text-color: var(--px-neutral-1);
|
|
60
|
+
}
|
|
61
|
+
.px-popup-content__top.px-popup-content__arrow {
|
|
62
|
+
min-height: calc(var(--px-bit) * 3 + var(--min-size));
|
|
63
|
+
padding-bottom: calc(var(--px-interval-1) + var(--px-bit) * 3);
|
|
64
|
+
}
|
|
65
|
+
.px-popup-content__top.px-popup-content__arrow .px-popup-content-arrow {
|
|
66
|
+
bottom: calc(-1 * var(--px-bit));
|
|
67
|
+
}
|
|
68
|
+
.px-popup-content__bottom.px-popup-content__arrow {
|
|
69
|
+
min-height: calc(var(--px-bit) * 12);
|
|
70
|
+
padding-top: calc(var(--px-interval-1) + var(--px-bit) * 3);
|
|
71
|
+
}
|
|
72
|
+
.px-popup-content__bottom.px-popup-content__arrow .px-popup-content-arrow {
|
|
73
|
+
top: calc(-1 * var(--px-bit));
|
|
74
|
+
}
|
|
75
|
+
.px-popup-content__left.px-popup-content__arrow {
|
|
76
|
+
min-width: calc(var(--px-bit) * 12);
|
|
77
|
+
padding-right: calc(var(--px-interval-2) + var(--px-bit) * 3);
|
|
78
|
+
}
|
|
79
|
+
.px-popup-content__left.px-popup-content__arrow .px-popup-content-arrow {
|
|
80
|
+
right: calc(-1 * var(--px-bit));
|
|
81
|
+
}
|
|
82
|
+
.px-popup-content__right.px-popup-content__arrow {
|
|
83
|
+
min-width: calc(var(--px-bit) * 12);
|
|
84
|
+
padding-left: calc(var(--px-interval-2) + var(--px-bit) * 3);
|
|
85
|
+
}
|
|
86
|
+
.px-popup-content__right.px-popup-content__arrow .px-popup-content-arrow {
|
|
87
|
+
left: calc(-1 * var(--px-bit));
|
|
88
|
+
}
|
|
89
|
+
.px-popup-content-arrow {
|
|
90
|
+
position: absolute;
|
|
91
|
+
}
|
|
92
|
+
.px-popup-content-canvas {
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: 50%;
|
|
95
|
+
left: 50%;
|
|
96
|
+
transform: translate(-50%, -50%);
|
|
97
|
+
z-index: -1;
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PopupContentProps } from './type';
|
|
2
|
+
declare var __VLS_11: {};
|
|
3
|
+
type __VLS_Slots = {} & {
|
|
4
|
+
content?: (props: typeof __VLS_11) => any;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_component: import("vue").DefineComponent<PopupContentProps, {
|
|
7
|
+
updateRenderState: () => void;
|
|
8
|
+
content: import("vue").ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
9
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
contentMouseenter: (e: MouseEvent) => any;
|
|
11
|
+
contentMouseleave: (e: MouseEvent) => any;
|
|
12
|
+
}, string, import("vue").PublicProps, Readonly<PopupContentProps> & Readonly<{
|
|
13
|
+
onContentMouseenter?: ((e: MouseEvent) => any) | undefined;
|
|
14
|
+
onContentMouseleave?: ((e: MouseEvent) => any) | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
variant: "dark" | "light";
|
|
17
|
+
placement: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
|
|
18
|
+
root: HTMLElement | string;
|
|
19
|
+
offset: number;
|
|
20
|
+
visible: boolean | null;
|
|
21
|
+
arrow: boolean;
|
|
22
|
+
widthEqual: boolean;
|
|
23
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
27
|
+
new (): {
|
|
28
|
+
$slots: S;
|
|
29
|
+
};
|
|
30
|
+
};
|