@varlet/ui 3.3.10 → 3.3.12-alpha.1722841613989
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/es/action-sheet/style/index.mjs +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/menu/usePopover.mjs +80 -71
- package/es/picker/Picker.mjs +10 -6
- package/es/picker/props.mjs +1 -0
- package/es/snackbar/style/index.mjs +1 -1
- package/es/varlet.esm.js +3497 -3465
- package/highlight/web-types.en-US.json +14 -5
- package/highlight/web-types.zh-CN.json +13 -4
- package/lib/varlet.cjs.js +91 -77
- package/package.json +7 -7
- package/types/menu.d.ts +1 -1
- package/types/menuSelect.d.ts +1 -1
- package/types/picker.d.ts +2 -0
- package/types/tooltip.d.ts +1 -1
- package/umd/varlet.js +6 -6
package/es/index.bundle.mjs
CHANGED
|
@@ -265,7 +265,7 @@ import './tooltip/style/index.mjs'
|
|
|
265
265
|
import './uploader/style/index.mjs'
|
|
266
266
|
import './watermark/style/index.mjs'
|
|
267
267
|
|
|
268
|
-
const version = '3.3.
|
|
268
|
+
const version = '3.3.12-alpha.1722841613989'
|
|
269
269
|
|
|
270
270
|
function install(app) {
|
|
271
271
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/index.mjs
CHANGED
|
@@ -176,7 +176,7 @@ export * from './tooltip/index.mjs'
|
|
|
176
176
|
export * from './uploader/index.mjs'
|
|
177
177
|
export * from './watermark/index.mjs'
|
|
178
178
|
|
|
179
|
-
const version = '3.3.
|
|
179
|
+
const version = '3.3.12-alpha.1722841613989'
|
|
180
180
|
|
|
181
181
|
function install(app) {
|
|
182
182
|
ActionSheet.install && app.use(ActionSheet)
|
package/es/menu/usePopover.mjs
CHANGED
|
@@ -67,7 +67,27 @@ function usePopover(options) {
|
|
|
67
67
|
let popoverInstance = null;
|
|
68
68
|
let enterPopover = false;
|
|
69
69
|
let enterHost = false;
|
|
70
|
-
|
|
70
|
+
useEventListener(() => window, "keydown", handleKeydown);
|
|
71
|
+
useClickOutside(getReference, "click", handleClickOutside);
|
|
72
|
+
onWindowResize(resize);
|
|
73
|
+
watch(() => [options.offsetX, options.offsetY, options.placement, options.strategy], resize);
|
|
74
|
+
watch(() => options.disabled, close);
|
|
75
|
+
watch(
|
|
76
|
+
() => show.value,
|
|
77
|
+
(newValue) => {
|
|
78
|
+
if (newValue) {
|
|
79
|
+
resize();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
onMounted(() => {
|
|
84
|
+
var _a;
|
|
85
|
+
popoverInstance = createPopper((_a = getReference()) != null ? _a : host.value, popover.value, getPopperOptions());
|
|
86
|
+
});
|
|
87
|
+
onUnmounted(() => {
|
|
88
|
+
popoverInstance.destroy();
|
|
89
|
+
});
|
|
90
|
+
function computeHostSize() {
|
|
71
91
|
if (!host.value) {
|
|
72
92
|
return;
|
|
73
93
|
}
|
|
@@ -76,8 +96,8 @@ function usePopover(options) {
|
|
|
76
96
|
width: toPxNum(width),
|
|
77
97
|
height: toPxNum(height)
|
|
78
98
|
};
|
|
79
|
-
}
|
|
80
|
-
|
|
99
|
+
}
|
|
100
|
+
function getTransformOrigin() {
|
|
81
101
|
switch (options.placement) {
|
|
82
102
|
case "top":
|
|
83
103
|
case "cover-bottom":
|
|
@@ -108,64 +128,71 @@ function usePopover(options) {
|
|
|
108
128
|
case "cover-left":
|
|
109
129
|
return "left";
|
|
110
130
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
131
|
+
}
|
|
132
|
+
function handleHostMouseenter() {
|
|
113
133
|
if (options.trigger !== "hover") {
|
|
114
134
|
return;
|
|
115
135
|
}
|
|
116
136
|
enterHost = true;
|
|
117
137
|
open();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
138
|
+
}
|
|
139
|
+
function handleHostMouseleave() {
|
|
140
|
+
return __async(this, null, function* () {
|
|
141
|
+
if (options.trigger !== "hover") {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
enterHost = false;
|
|
145
|
+
yield doubleRaf();
|
|
146
|
+
if (enterPopover) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
close();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function handlePopoverMouseenter() {
|
|
131
153
|
if (options.trigger !== "hover") {
|
|
132
154
|
return;
|
|
133
155
|
}
|
|
134
156
|
enterPopover = true;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
}
|
|
158
|
+
function handlePopoverMouseleave() {
|
|
159
|
+
return __async(this, null, function* () {
|
|
160
|
+
if (options.trigger !== "hover") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
enterPopover = false;
|
|
164
|
+
yield doubleRaf();
|
|
165
|
+
if (enterHost) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
close();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function handleHostClick() {
|
|
172
|
+
if (options.trigger !== "click") {
|
|
143
173
|
return;
|
|
144
174
|
}
|
|
145
|
-
close();
|
|
146
|
-
});
|
|
147
|
-
const handleHostClick = () => {
|
|
148
175
|
if (options.closeOnClickReference && show.value) {
|
|
149
176
|
close();
|
|
150
|
-
|
|
151
|
-
open();
|
|
177
|
+
return;
|
|
152
178
|
}
|
|
153
|
-
|
|
154
|
-
|
|
179
|
+
open();
|
|
180
|
+
}
|
|
181
|
+
function handlePopoverClose() {
|
|
155
182
|
close();
|
|
156
|
-
}
|
|
157
|
-
|
|
183
|
+
}
|
|
184
|
+
function handleClickOutside(e) {
|
|
158
185
|
if (options.trigger !== "click") {
|
|
159
186
|
return;
|
|
160
187
|
}
|
|
161
188
|
handlePopoverClose();
|
|
162
189
|
call(options.onClickOutside, e);
|
|
163
|
-
}
|
|
164
|
-
|
|
190
|
+
}
|
|
191
|
+
function handleClosed() {
|
|
165
192
|
resize();
|
|
166
193
|
call(options.onClosed);
|
|
167
|
-
}
|
|
168
|
-
|
|
194
|
+
}
|
|
195
|
+
function getPosition() {
|
|
169
196
|
const { offsetX, offsetY, placement } = options;
|
|
170
197
|
computeHostSize();
|
|
171
198
|
const offset2 = {
|
|
@@ -254,8 +281,8 @@ function usePopover(options) {
|
|
|
254
281
|
distance: offset2.x
|
|
255
282
|
};
|
|
256
283
|
}
|
|
257
|
-
}
|
|
258
|
-
|
|
284
|
+
}
|
|
285
|
+
function getPopperOptions() {
|
|
259
286
|
const { placement, skidding, distance } = getPosition();
|
|
260
287
|
const modifiers = [
|
|
261
288
|
__spreadProps(__spreadValues({}, flip), {
|
|
@@ -287,49 +314,31 @@ function usePopover(options) {
|
|
|
287
314
|
modifiers,
|
|
288
315
|
strategy: options.strategy
|
|
289
316
|
};
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
317
|
+
}
|
|
318
|
+
function getReference() {
|
|
319
|
+
return options.reference ? host.value.querySelector(options.reference) : host.value;
|
|
320
|
+
}
|
|
321
|
+
function handleKeydown(event) {
|
|
293
322
|
const { closeOnKeyEscape = false } = options;
|
|
294
323
|
if (event.key === "Escape" && closeOnKeyEscape && show.value) {
|
|
295
324
|
preventDefault(event);
|
|
296
325
|
close();
|
|
297
326
|
}
|
|
298
|
-
}
|
|
299
|
-
|
|
327
|
+
}
|
|
328
|
+
function resize() {
|
|
300
329
|
popoverInstance.setOptions(getPopperOptions());
|
|
301
|
-
}
|
|
302
|
-
|
|
330
|
+
}
|
|
331
|
+
function open() {
|
|
303
332
|
if (options.disabled) {
|
|
304
333
|
return;
|
|
305
334
|
}
|
|
306
335
|
show.value = true;
|
|
307
336
|
call(options["onUpdate:show"], true);
|
|
308
|
-
}
|
|
309
|
-
|
|
337
|
+
}
|
|
338
|
+
function close() {
|
|
310
339
|
show.value = false;
|
|
311
340
|
call(options["onUpdate:show"], false);
|
|
312
|
-
}
|
|
313
|
-
useEventListener(() => window, "keydown", handleKeydown);
|
|
314
|
-
useClickOutside(getReference, "click", handleClickOutside);
|
|
315
|
-
onWindowResize(resize);
|
|
316
|
-
watch(() => [options.offsetX, options.offsetY, options.placement, options.strategy], resize);
|
|
317
|
-
watch(() => options.disabled, close);
|
|
318
|
-
watch(
|
|
319
|
-
() => show.value,
|
|
320
|
-
(newValue) => {
|
|
321
|
-
if (newValue) {
|
|
322
|
-
resize();
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
);
|
|
326
|
-
onMounted(() => {
|
|
327
|
-
var _a;
|
|
328
|
-
popoverInstance = createPopper((_a = getReference()) != null ? _a : host.value, popover.value, getPopperOptions());
|
|
329
|
-
});
|
|
330
|
-
onUnmounted(() => {
|
|
331
|
-
popoverInstance.destroy();
|
|
332
|
-
});
|
|
341
|
+
}
|
|
333
342
|
return {
|
|
334
343
|
show,
|
|
335
344
|
popover,
|
package/es/picker/Picker.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import VarPopup from "../popup/index.mjs";
|
|
|
3
3
|
import { defineComponent, watch, ref, computed, Transition } from "vue";
|
|
4
4
|
import { props } from "./props.mjs";
|
|
5
5
|
import { useTouch, useVModel } from "@varlet/use";
|
|
6
|
-
import { clamp, clampArrayRange, call } from "@varlet/shared";
|
|
6
|
+
import { clamp, clampArrayRange, call, toNumber } from "@varlet/shared";
|
|
7
7
|
import { toPxNum, getTranslateY } from "../utils/elements.mjs";
|
|
8
8
|
import { t } from "../locale/index.mjs";
|
|
9
9
|
import { createNamespace } from "../utils/components.mjs";
|
|
@@ -229,6 +229,7 @@ const __sfc__ = defineComponent({
|
|
|
229
229
|
setup(props2) {
|
|
230
230
|
const modelValue = useVModel(props2, "modelValue");
|
|
231
231
|
const scrollColumns = ref([]);
|
|
232
|
+
const visibleColumnsCount = computed(() => toNumber(props2.columnsCount));
|
|
232
233
|
const optionHeight = computed(() => toPxNum(props2.optionHeight));
|
|
233
234
|
const optionCount = computed(() => toPxNum(props2.optionCount));
|
|
234
235
|
const center = computed(() => optionCount.value * optionHeight.value / 2 - optionHeight.value / 2);
|
|
@@ -255,7 +256,8 @@ const __sfc__ = defineComponent({
|
|
|
255
256
|
prevIndexes = [...indexes];
|
|
256
257
|
}
|
|
257
258
|
function normalizeNormalMode(columns) {
|
|
258
|
-
|
|
259
|
+
const visibleColumns = props2.columnsCount != null ? columns.slice(0, visibleColumnsCount.value) : columns;
|
|
260
|
+
return visibleColumns.map((column, idx) => {
|
|
259
261
|
const scrollColumn = {
|
|
260
262
|
id: sid++,
|
|
261
263
|
prevY: 0,
|
|
@@ -281,9 +283,9 @@ const __sfc__ = defineComponent({
|
|
|
281
283
|
createChildren(scrollColumns2, column);
|
|
282
284
|
return scrollColumns2;
|
|
283
285
|
}
|
|
284
|
-
function createChildren(scrollColumns2, children, syncModelValue = true) {
|
|
286
|
+
function createChildren(scrollColumns2, children, syncModelValue = true, depth = 1) {
|
|
285
287
|
var _a;
|
|
286
|
-
if (children.length) {
|
|
288
|
+
if (children.length && (props2.columnsCount == null || depth <= visibleColumnsCount.value)) {
|
|
287
289
|
const scrollColumn = {
|
|
288
290
|
id: sid++,
|
|
289
291
|
prevY: 0,
|
|
@@ -307,7 +309,8 @@ const __sfc__ = defineComponent({
|
|
|
307
309
|
createChildren(
|
|
308
310
|
scrollColumns2,
|
|
309
311
|
(_a = scrollColumn.column[scrollColumn.index][getOptionKey("children")]) != null ? _a : [],
|
|
310
|
-
syncModelValue
|
|
312
|
+
syncModelValue,
|
|
313
|
+
depth + 1
|
|
311
314
|
);
|
|
312
315
|
}
|
|
313
316
|
}
|
|
@@ -317,7 +320,8 @@ const __sfc__ = defineComponent({
|
|
|
317
320
|
createChildren(
|
|
318
321
|
scrollColumns.value,
|
|
319
322
|
(_a = scrollColumn.column[scrollColumn.index][getOptionKey("children")]) != null ? _a : [],
|
|
320
|
-
false
|
|
323
|
+
false,
|
|
324
|
+
scrollColumns.value.length + 1
|
|
321
325
|
);
|
|
322
326
|
}
|
|
323
327
|
function initScrollColumns() {
|
package/es/picker/props.mjs
CHANGED