@varlet/ui 3.13.1 → 3.14.0
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 +0 -10
- package/es/action-sheet/style/index.mjs +1 -1
- package/es/field-decorator/fieldDecorator.css +1 -1
- package/es/index.bundle.mjs +1 -1
- package/es/index.mjs +1 -1
- package/es/locale/en-US.mjs +3 -1
- package/es/locale/fa-IR.mjs +3 -1
- package/es/locale/ja-JP.mjs +3 -1
- package/es/locale/zh-CN.mjs +3 -1
- package/es/locale/zh-TW.mjs +3 -1
- package/es/option/Option.mjs +31 -2
- package/es/select/Select.mjs +258 -45
- package/es/select/SelectFilter.mjs +61 -0
- package/es/select/props.mjs +4 -0
- package/es/select/select.css +1 -1
- package/es/select/useOptionsMutationObserver.mjs +73 -0
- package/es/select/useSelectFilterSize.mjs +27 -0
- package/es/themes/dark/fieldDecorator.mjs +1 -1
- package/es/themes/dark/select.mjs +4 -1
- package/es/themes/md3-dark/fieldDecorator.mjs +1 -1
- package/es/themes/md3-dark/select.mjs +4 -1
- package/es/themes/md3-light/fieldDecorator.mjs +1 -1
- package/es/themes/md3-light/select.mjs +4 -1
- package/es/varlet.css +1 -1
- package/es/varlet.esm.js +7925 -7607
- package/highlight/web-types.en-US.json +23 -1
- package/highlight/web-types.zh-CN.json +23 -1
- package/lib/varlet.cjs.js +2236 -1832
- package/lib/varlet.css +1 -1
- package/package.json +7 -7
- package/types/index.d.ts +2 -2
- package/types/select.d.ts +5 -0
- package/types/styleVars.d.ts +3 -0
- package/umd/varlet.js +8 -8
package/es/select/Select.mjs
CHANGED
|
@@ -1,3 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __async = (__this, __arguments, generator) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
var fulfilled = (value) => {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
var rejected = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.throw(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
37
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
1
40
|
import { computed, defineComponent, nextTick, ref, watch } from "vue";
|
|
2
41
|
import { assert, call, doubleRaf, isArray, isEmpty, isFunction, preventDefault } from "@varlet/shared";
|
|
3
42
|
import { useEventListener } from "@varlet/use";
|
|
@@ -6,19 +45,25 @@ import VarFieldDecorator from "../field-decorator/index.mjs";
|
|
|
6
45
|
import VarFormDetails from "../form-details/index.mjs";
|
|
7
46
|
import { useForm } from "../form/provide.mjs";
|
|
8
47
|
import VarIcon from "../icon/index.mjs";
|
|
48
|
+
import { t } from "../locale/index.mjs";
|
|
49
|
+
import { injectLocaleProvider } from "../locale-provider/provide.mjs";
|
|
9
50
|
import VarMenu from "../menu/index.mjs";
|
|
10
51
|
import VarOption from "../option/index.mjs";
|
|
11
52
|
import { createNamespace, MaybeVNode, useValidation } from "../utils/components.mjs";
|
|
12
53
|
import { focusChildElementByKey, toPxNum } from "../utils/elements.mjs";
|
|
13
54
|
import { props } from "./props.mjs";
|
|
14
55
|
import { useOptions } from "./provide.mjs";
|
|
56
|
+
import VarSelectFilter from "./SelectFilter.mjs";
|
|
57
|
+
import { useOptionsMutationObserver } from "./useOptionsMutationObserver.mjs";
|
|
15
58
|
import { useSelectController } from "./useSelectController.mjs";
|
|
59
|
+
import { useSelectFilterSize } from "./useSelectFilterSize.mjs";
|
|
16
60
|
const { name, n, classes } = createNamespace("select");
|
|
17
|
-
import { renderSlot as _renderSlot, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createVNode as _createVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, withCtx as _withCtx, createBlock as _createBlock, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode,
|
|
61
|
+
import { renderSlot as _renderSlot, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveComponent as _resolveComponent, createVNode as _createVNode, withModifiers as _withModifiers, normalizeClass as _normalizeClass, withCtx as _withCtx, createBlock as _createBlock, normalizeStyle as _normalizeStyle, createCommentVNode as _createCommentVNode, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, createSlots as _createSlots } from "vue";
|
|
18
62
|
const _hoisted_1 = ["tabindex"];
|
|
19
63
|
function __render__(_ctx, _cache) {
|
|
20
64
|
const _component_maybe_v_node = _resolveComponent("maybe-v-node");
|
|
21
65
|
const _component_var_chip = _resolveComponent("var-chip");
|
|
66
|
+
const _component_var_select_filter = _resolveComponent("var-select-filter");
|
|
22
67
|
const _component_var_icon = _resolveComponent("var-icon");
|
|
23
68
|
const _component_var_field_decorator = _resolveComponent("var-field-decorator");
|
|
24
69
|
const _component_var_option = _resolveComponent("var-option");
|
|
@@ -27,19 +72,20 @@ function __render__(_ctx, _cache) {
|
|
|
27
72
|
return _openBlock(), _createElementBlock("div", {
|
|
28
73
|
ref: "root",
|
|
29
74
|
class: _normalizeClass(_ctx.n()),
|
|
30
|
-
tabindex: _ctx.tabindex
|
|
31
|
-
onFocus: _cache[
|
|
32
|
-
onBlur: _cache[
|
|
75
|
+
tabindex: _ctx.tabindex,
|
|
76
|
+
onFocus: _cache[6] || (_cache[6] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
|
|
77
|
+
onBlur: _cache[7] || (_cache[7] = (...args) => _ctx.handleRootBlur && _ctx.handleRootBlur(...args))
|
|
33
78
|
}, [
|
|
34
79
|
_createVNode(_component_var_menu, {
|
|
80
|
+
ref: "menuRef",
|
|
35
81
|
show: _ctx.showMenu,
|
|
36
|
-
"onUpdate:show": _cache[
|
|
82
|
+
"onUpdate:show": _cache[4] || (_cache[4] = ($event) => _ctx.showMenu = $event),
|
|
37
83
|
"var-select-cover": "",
|
|
38
84
|
"same-width": "",
|
|
39
85
|
"close-on-click-reference": "",
|
|
40
86
|
"close-on-key-escape": false,
|
|
41
87
|
class: _normalizeClass(_ctx.n("menu")),
|
|
42
|
-
"popover-class": _ctx.variant === "standard" && _ctx.hint ? _ctx.n("--standard-menu-margin") : void 0,
|
|
88
|
+
"popover-class": _ctx.variant === "standard" && _ctx.hint && !_ctx.filterable ? _ctx.n("--standard-menu-margin") : void 0,
|
|
43
89
|
"offset-y": _ctx.offsetY,
|
|
44
90
|
disabled: _ctx.formReadonly || _ctx.readonly || _ctx.formDisabled || _ctx.disabled,
|
|
45
91
|
placement: _ctx.placement,
|
|
@@ -54,9 +100,20 @@ function __render__(_ctx, _cache) {
|
|
|
54
100
|
class: _normalizeClass(_ctx.classes(_ctx.n("scroller"), _ctx.n("$-elevation--3")))
|
|
55
101
|
},
|
|
56
102
|
[
|
|
103
|
+
_ctx.showEmpty ? _renderSlot(_ctx.$slots, "empty", { key: 0 }, () => [
|
|
104
|
+
_createElementVNode(
|
|
105
|
+
"div",
|
|
106
|
+
{
|
|
107
|
+
class: _normalizeClass(_ctx.n("empty"))
|
|
108
|
+
},
|
|
109
|
+
_toDisplayString((_ctx.pt ? _ctx.pt : _ctx.t)("selectEmptyText")),
|
|
110
|
+
3
|
|
111
|
+
/* TEXT, CLASS */
|
|
112
|
+
)
|
|
113
|
+
]) : _createCommentVNode("v-if", true),
|
|
57
114
|
_ctx.options.length ? (_openBlock(true), _createElementBlock(
|
|
58
115
|
_Fragment,
|
|
59
|
-
{ key:
|
|
116
|
+
{ key: 1 },
|
|
60
117
|
_renderList(_ctx.options, (option) => {
|
|
61
118
|
return _openBlock(), _createBlock(_component_var_option, {
|
|
62
119
|
key: option[_ctx.valueKey],
|
|
@@ -80,7 +137,7 @@ function __render__(_ctx, _cache) {
|
|
|
80
137
|
_createVNode(
|
|
81
138
|
_component_var_field_decorator,
|
|
82
139
|
_normalizeProps(_guardReactiveProps({
|
|
83
|
-
value: _ctx.modelValue,
|
|
140
|
+
value: _ctx.pattern || _ctx.modelValue,
|
|
84
141
|
size: _ctx.size,
|
|
85
142
|
variant: _ctx.variant,
|
|
86
143
|
placeholder: _ctx.placeholder,
|
|
@@ -92,16 +149,14 @@ function __render__(_ctx, _cache) {
|
|
|
92
149
|
isFocusing: _ctx.isFocusing,
|
|
93
150
|
isError: !!_ctx.errorMessage,
|
|
94
151
|
formDisabled: _ctx.formDisabled,
|
|
152
|
+
composing: _ctx.isComposing,
|
|
95
153
|
disabled: _ctx.disabled,
|
|
96
|
-
clearable: _ctx.clearable,
|
|
154
|
+
clearable: _ctx.clearable ? !_ctx.filterable || !_ctx.pattern : false,
|
|
97
155
|
cursor: _ctx.cursor,
|
|
98
156
|
onClick: _ctx.handleClick,
|
|
99
157
|
onClear: _ctx.handleClear
|
|
100
158
|
})),
|
|
101
159
|
_createSlots({
|
|
102
|
-
"clear-icon": _withCtx(({ clear }) => [
|
|
103
|
-
_renderSlot(_ctx.$slots, "clear-icon", { clear })
|
|
104
|
-
]),
|
|
105
160
|
"append-icon": _withCtx(() => [
|
|
106
161
|
_renderSlot(_ctx.$slots, "arrow-icon", {
|
|
107
162
|
focus: _ctx.isFocusing,
|
|
@@ -130,10 +185,10 @@ function __render__(_ctx, _cache) {
|
|
|
130
185
|
_createElementVNode(
|
|
131
186
|
"div",
|
|
132
187
|
{
|
|
133
|
-
class: _normalizeClass(_ctx.n("label"))
|
|
188
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("label"), [_ctx.filterable && _ctx.showMenu, _ctx.n("--label-focusing")]))
|
|
134
189
|
},
|
|
135
190
|
[
|
|
136
|
-
|
|
191
|
+
_ctx.isShowSelected() ? _renderSlot(_ctx.$slots, "selected", { key: 0 }, () => [
|
|
137
192
|
_ctx.multiple ? (_openBlock(), _createElementBlock(
|
|
138
193
|
_Fragment,
|
|
139
194
|
{ key: 0 },
|
|
@@ -169,7 +224,20 @@ function __render__(_ctx, _cache) {
|
|
|
169
224
|
}),
|
|
170
225
|
128
|
|
171
226
|
/* KEYED_FRAGMENT */
|
|
172
|
-
))
|
|
227
|
+
)),
|
|
228
|
+
_ctx.isShowMultipleFilter() ? (_openBlock(), _createBlock(_component_var_select_filter, {
|
|
229
|
+
key: 0,
|
|
230
|
+
ref: "filterRef",
|
|
231
|
+
modelValue: _ctx.pattern,
|
|
232
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.pattern = $event),
|
|
233
|
+
style: _normalizeStyle(_ctx.filterStyle),
|
|
234
|
+
multiple: _ctx.multiple,
|
|
235
|
+
onFocus: _ctx.handleFocus,
|
|
236
|
+
onBlur: _ctx.handleRootBlur,
|
|
237
|
+
onInput: _ctx.handleInput,
|
|
238
|
+
onCompositionstart: _ctx.handleCompositionStart,
|
|
239
|
+
onCompositionend: _ctx.handleCompositionEnd
|
|
240
|
+
}, null, 8, ["modelValue", "style", "multiple", "onFocus", "onBlur", "onInput", "onCompositionstart", "onCompositionend"])) : _createCommentVNode("v-if", true)
|
|
173
241
|
],
|
|
174
242
|
2
|
|
175
243
|
/* CLASS */
|
|
@@ -201,7 +269,20 @@ function __render__(_ctx, _cache) {
|
|
|
201
269
|
}),
|
|
202
270
|
128
|
|
203
271
|
/* KEYED_FRAGMENT */
|
|
204
|
-
))
|
|
272
|
+
)),
|
|
273
|
+
_ctx.isShowMultipleFilter() ? (_openBlock(), _createBlock(_component_var_select_filter, {
|
|
274
|
+
key: 0,
|
|
275
|
+
ref: "filterRef",
|
|
276
|
+
modelValue: _ctx.pattern,
|
|
277
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.pattern = $event),
|
|
278
|
+
style: _normalizeStyle(__spreadProps(__spreadValues({}, _ctx.filterStyle), { paddingLeft: _ctx.labels.length ? "4px" : 0 })),
|
|
279
|
+
multiple: _ctx.multiple,
|
|
280
|
+
onFocus: _ctx.handleFocus,
|
|
281
|
+
onBlur: _ctx.handleRootBlur,
|
|
282
|
+
onInput: _ctx.handleInput,
|
|
283
|
+
onCompositionstart: _ctx.handleCompositionStart,
|
|
284
|
+
onCompositionend: _ctx.handleCompositionEnd
|
|
285
|
+
}, null, 8, ["modelValue", "style", "multiple", "onFocus", "onBlur", "onInput", "onCompositionstart", "onCompositionend"])) : _createCommentVNode("v-if", true)
|
|
205
286
|
],
|
|
206
287
|
2
|
|
207
288
|
/* CLASS */
|
|
@@ -218,18 +299,39 @@ function __render__(_ctx, _cache) {
|
|
|
218
299
|
2
|
|
219
300
|
/* CLASS */
|
|
220
301
|
),
|
|
221
|
-
_ctx.enableCustomPlaceholder ? (_openBlock(), _createElementBlock(
|
|
302
|
+
_ctx.enableCustomPlaceholder && !_ctx.pattern ? (_openBlock(), _createElementBlock(
|
|
222
303
|
"span",
|
|
223
304
|
{
|
|
224
305
|
key: 0,
|
|
225
306
|
class: _normalizeClass(_ctx.classes(_ctx.n("placeholder"), _ctx.n("$--ellipsis"))),
|
|
226
|
-
style: _normalizeStyle({
|
|
227
|
-
color: _ctx.placeholderColor
|
|
228
|
-
})
|
|
307
|
+
style: _normalizeStyle({ color: _ctx.placeholderColor })
|
|
229
308
|
},
|
|
230
309
|
_toDisplayString(_ctx.placeholder),
|
|
231
310
|
7
|
|
232
311
|
/* TEXT, CLASS, STYLE */
|
|
312
|
+
)) : _createCommentVNode("v-if", true),
|
|
313
|
+
_ctx.isShowSingleFilter() ? (_openBlock(), _createBlock(_component_var_select_filter, {
|
|
314
|
+
key: 1,
|
|
315
|
+
ref: "filterRef",
|
|
316
|
+
modelValue: _ctx.pattern,
|
|
317
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.pattern = $event),
|
|
318
|
+
style: _normalizeStyle(_ctx.filterStyle),
|
|
319
|
+
onFocus: _ctx.handleFocus,
|
|
320
|
+
onBlur: _ctx.handleRootBlur,
|
|
321
|
+
onInput: _ctx.handleInput,
|
|
322
|
+
onCompositionstart: _ctx.handleCompositionStart,
|
|
323
|
+
onCompositionend: _ctx.handleCompositionEnd
|
|
324
|
+
}, null, 8, ["modelValue", "style", "onFocus", "onBlur", "onInput", "onCompositionstart", "onCompositionend"])) : _createCommentVNode("v-if", true),
|
|
325
|
+
_ctx.filterable ? (_openBlock(), _createElementBlock(
|
|
326
|
+
"span",
|
|
327
|
+
{
|
|
328
|
+
key: 2,
|
|
329
|
+
ref: "calculatorRef",
|
|
330
|
+
class: _normalizeClass(_ctx.n("filter-calculator"))
|
|
331
|
+
},
|
|
332
|
+
_toDisplayString(_ctx.pattern),
|
|
333
|
+
3
|
|
334
|
+
/* TEXT, CLASS */
|
|
233
335
|
)) : _createCommentVNode("v-if", true)
|
|
234
336
|
],
|
|
235
337
|
6
|
|
@@ -245,6 +347,13 @@ function __render__(_ctx, _cache) {
|
|
|
245
347
|
_renderSlot(_ctx.$slots, "prepend-icon")
|
|
246
348
|
]),
|
|
247
349
|
key: "0"
|
|
350
|
+
} : void 0,
|
|
351
|
+
!_ctx.pattern ? {
|
|
352
|
+
name: "clear-icon",
|
|
353
|
+
fn: _withCtx(({ clear }) => [
|
|
354
|
+
_renderSlot(_ctx.$slots, "clear-icon", { clear })
|
|
355
|
+
]),
|
|
356
|
+
key: "1"
|
|
248
357
|
} : void 0
|
|
249
358
|
]),
|
|
250
359
|
1040
|
|
@@ -256,7 +365,7 @@ function __render__(_ctx, _cache) {
|
|
|
256
365
|
}, 8, ["show", "class", "popover-class", "offset-y", "disabled", "placement", "onClickOutside"]),
|
|
257
366
|
_createVNode(_component_var_form_details, {
|
|
258
367
|
"error-message": _ctx.errorMessage,
|
|
259
|
-
onClick: _cache[
|
|
368
|
+
onClick: _cache[5] || (_cache[5] = _withModifiers(() => {
|
|
260
369
|
}, ["stop"]))
|
|
261
370
|
}, null, 8, ["error-message"])
|
|
262
371
|
], 42, _hoisted_1);
|
|
@@ -270,18 +379,23 @@ const __sfc__ = defineComponent({
|
|
|
270
379
|
VarOption,
|
|
271
380
|
VarFieldDecorator,
|
|
272
381
|
VarFormDetails,
|
|
382
|
+
VarSelectFilter,
|
|
273
383
|
MaybeVNode
|
|
274
384
|
},
|
|
275
385
|
props,
|
|
276
386
|
setup(props2) {
|
|
387
|
+
var _a;
|
|
277
388
|
const isFocusing = ref(false);
|
|
278
389
|
const showMenu = ref(false);
|
|
279
390
|
const root = ref(null);
|
|
391
|
+
const filterRef = ref(null);
|
|
392
|
+
const pattern = ref("");
|
|
393
|
+
const isComposing = ref(false);
|
|
394
|
+
const filterable = computed(() => props2.filterable);
|
|
280
395
|
const multiple = computed(() => props2.multiple);
|
|
281
396
|
const focusColor = computed(() => props2.focusColor);
|
|
282
397
|
const isEmptyModelValue = computed(() => isEmpty(props2.modelValue));
|
|
283
398
|
const cursor = computed(() => props2.disabled || props2.readonly ? "" : "pointer");
|
|
284
|
-
const offsetY = ref(0);
|
|
285
399
|
const { bindForm, form } = useForm();
|
|
286
400
|
const { length, options, bindOptions } = useOptions();
|
|
287
401
|
const { label, labels, computeLabel, getSelectedValue } = useSelectController({
|
|
@@ -297,8 +411,21 @@ const __sfc__ = defineComponent({
|
|
|
297
411
|
// expose
|
|
298
412
|
resetValidation
|
|
299
413
|
} = useValidation();
|
|
414
|
+
const readonly = computed(() => (form == null ? void 0 : form.readonly.value) || props2.readonly);
|
|
415
|
+
const disabled = computed(() => (form == null ? void 0 : form.disabled.value) || props2.disabled);
|
|
300
416
|
const menuEl = ref(null);
|
|
301
|
-
const
|
|
417
|
+
const menuRef = ref(null);
|
|
418
|
+
const placement = computed(() => props2.variant === "standard" && !props2.filterable ? "cover-top" : "bottom");
|
|
419
|
+
const { t: pt } = injectLocaleProvider();
|
|
420
|
+
const _offsetY = ref(0);
|
|
421
|
+
const offsetY = computed({
|
|
422
|
+
get() {
|
|
423
|
+
return _offsetY.value + (placement.value === "bottom" ? 2 : 0);
|
|
424
|
+
},
|
|
425
|
+
set(v2) {
|
|
426
|
+
_offsetY.value = v2;
|
|
427
|
+
}
|
|
428
|
+
});
|
|
302
429
|
const placeholderColor = computed(() => {
|
|
303
430
|
const { hint, blurColor, focusColor: focusColor2 } = props2;
|
|
304
431
|
if (hint) {
|
|
@@ -313,8 +440,23 @@ const __sfc__ = defineComponent({
|
|
|
313
440
|
return blurColor || "var(--field-decorator-placeholder-color, var(--field-decorator-blur-color))";
|
|
314
441
|
});
|
|
315
442
|
const enableCustomPlaceholder = computed(() => !props2.hint && isEmpty(props2.modelValue));
|
|
443
|
+
const tabindex = computed(() => {
|
|
444
|
+
var _a2;
|
|
445
|
+
if (disabled.value) {
|
|
446
|
+
return void 0;
|
|
447
|
+
}
|
|
448
|
+
if (filterable.value && isFocusing.value) {
|
|
449
|
+
return "-1";
|
|
450
|
+
}
|
|
451
|
+
return (_a2 = props2.tabindex) != null ? _a2 : "0";
|
|
452
|
+
});
|
|
453
|
+
const { calculatorRef, filterStyle } = useSelectFilterSize(pattern);
|
|
316
454
|
const selectProvider = {
|
|
455
|
+
pattern: computed(() => pattern.value),
|
|
456
|
+
showMenu: computed(() => showMenu.value),
|
|
317
457
|
multiple,
|
|
458
|
+
filterable,
|
|
459
|
+
filter: (_a = props2.filter) != null ? _a : (pattern2, option) => String(option[props2.labelKey]).toLocaleLowerCase().includes(pattern2.toLocaleLowerCase()),
|
|
318
460
|
focusColor,
|
|
319
461
|
computeLabel,
|
|
320
462
|
onSelect,
|
|
@@ -322,6 +464,13 @@ const __sfc__ = defineComponent({
|
|
|
322
464
|
validate,
|
|
323
465
|
resetValidation
|
|
324
466
|
};
|
|
467
|
+
const { showEmpty } = useOptionsMutationObserver(menuEl, showMenu, {
|
|
468
|
+
onAfterUpdate: () => {
|
|
469
|
+
var _a2;
|
|
470
|
+
return (_a2 = menuRef.value) == null ? void 0 : _a2.resize();
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
let focusTransferToFilter = false;
|
|
325
474
|
watch(
|
|
326
475
|
() => props2.multiple,
|
|
327
476
|
() => {
|
|
@@ -336,9 +485,24 @@ const __sfc__ = defineComponent({
|
|
|
336
485
|
useEventListener(() => window, "keydown", handleKeydown);
|
|
337
486
|
useEventListener(() => window, "keyup", handleKeyup);
|
|
338
487
|
call(bindForm, selectProvider);
|
|
488
|
+
function isShowSingleFilter() {
|
|
489
|
+
return filterable.value && !readonly.value && !disabled.value && !multiple.value;
|
|
490
|
+
}
|
|
491
|
+
function isShowMultipleFilter() {
|
|
492
|
+
return filterable.value && !readonly.value && !disabled.value && multiple.value;
|
|
493
|
+
}
|
|
494
|
+
function isShowSelected() {
|
|
495
|
+
if (isEmptyModelValue.value && !multiple.value) {
|
|
496
|
+
return false;
|
|
497
|
+
}
|
|
498
|
+
if (!multiple.value && (pattern.value || isComposing.value)) {
|
|
499
|
+
return false;
|
|
500
|
+
}
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
339
503
|
function handleKeydown(event) {
|
|
340
|
-
|
|
341
|
-
if (
|
|
504
|
+
var _a2;
|
|
505
|
+
if (disabled.value || readonly.value || !isFocusing.value) {
|
|
342
506
|
return;
|
|
343
507
|
}
|
|
344
508
|
const { key } = event;
|
|
@@ -361,6 +525,7 @@ const __sfc__ = defineComponent({
|
|
|
361
525
|
if (key === "Enter" && !showMenu.value) {
|
|
362
526
|
preventDefault(event);
|
|
363
527
|
showMenu.value = true;
|
|
528
|
+
(_a2 = filterRef.value) == null ? void 0 : _a2.focus();
|
|
364
529
|
return;
|
|
365
530
|
}
|
|
366
531
|
if ((key === "ArrowDown" || key === "ArrowUp") && showMenu.value) {
|
|
@@ -369,8 +534,7 @@ const __sfc__ = defineComponent({
|
|
|
369
534
|
}
|
|
370
535
|
}
|
|
371
536
|
function handleKeyup(event) {
|
|
372
|
-
|
|
373
|
-
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly || showMenu.value || !isFocusing.value) {
|
|
537
|
+
if (disabled.value || readonly.value || showMenu.value || !isFocusing.value) {
|
|
374
538
|
return;
|
|
375
539
|
}
|
|
376
540
|
const { key } = event;
|
|
@@ -386,29 +550,46 @@ const __sfc__ = defineComponent({
|
|
|
386
550
|
});
|
|
387
551
|
}
|
|
388
552
|
function handleFocus() {
|
|
389
|
-
|
|
390
|
-
|
|
553
|
+
var _a2;
|
|
554
|
+
const { disabled: disabled2, readonly: readonly2, onFocus } = props2;
|
|
555
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (focusTransferToFilter) {
|
|
559
|
+
focusTransferToFilter = false;
|
|
391
560
|
return;
|
|
392
561
|
}
|
|
393
562
|
offsetY.value = toPxNum(props2.offsetY);
|
|
394
563
|
focus();
|
|
564
|
+
if (isShowMultipleFilter() || isShowSingleFilter()) {
|
|
565
|
+
focusTransferToFilter = true;
|
|
566
|
+
(_a2 = filterRef.value) == null ? void 0 : _a2.focus();
|
|
567
|
+
}
|
|
395
568
|
call(onFocus);
|
|
396
569
|
validateWithTrigger("onFocus");
|
|
397
570
|
}
|
|
398
571
|
function handleBlur() {
|
|
399
|
-
const { disabled, readonly, onBlur } = props2;
|
|
400
|
-
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) ||
|
|
572
|
+
const { disabled: disabled2, readonly: readonly2, onBlur } = props2;
|
|
573
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
|
|
401
574
|
return;
|
|
402
575
|
}
|
|
403
576
|
blur();
|
|
404
577
|
call(onBlur);
|
|
405
578
|
validateWithTrigger("onBlur");
|
|
579
|
+
pattern.value = "";
|
|
406
580
|
}
|
|
407
581
|
function handleRootBlur() {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
582
|
+
return __async(this, null, function* () {
|
|
583
|
+
if (focusTransferToFilter) {
|
|
584
|
+
yield nextTick();
|
|
585
|
+
focusTransferToFilter = false;
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
if (showMenu.value) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
handleBlur();
|
|
592
|
+
});
|
|
412
593
|
}
|
|
413
594
|
function handleClickOutside() {
|
|
414
595
|
if (!isFocusing.value) {
|
|
@@ -417,24 +598,29 @@ const __sfc__ = defineComponent({
|
|
|
417
598
|
handleBlur();
|
|
418
599
|
}
|
|
419
600
|
function onSelect(option) {
|
|
420
|
-
const { disabled, readonly, multiple: multiple2, onChange } = props2;
|
|
421
|
-
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) ||
|
|
601
|
+
const { disabled: disabled2, readonly: readonly2, multiple: multiple2, onChange } = props2;
|
|
602
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
|
|
422
603
|
return;
|
|
423
604
|
}
|
|
424
605
|
const selectedValue = getSelectedValue(option);
|
|
425
606
|
call(props2["onUpdate:modelValue"], selectedValue);
|
|
426
607
|
call(onChange, selectedValue);
|
|
427
608
|
validateWithTrigger("onChange");
|
|
609
|
+
nextTick(() => {
|
|
610
|
+
var _a2;
|
|
611
|
+
return (_a2 = filterRef.value) == null ? void 0 : _a2.focus();
|
|
612
|
+
});
|
|
428
613
|
if (!multiple2) {
|
|
429
614
|
root.value.focus();
|
|
430
615
|
doubleRaf().then(() => {
|
|
431
616
|
showMenu.value = false;
|
|
617
|
+
pattern.value = "";
|
|
432
618
|
});
|
|
433
619
|
}
|
|
434
620
|
}
|
|
435
621
|
function handleClear() {
|
|
436
|
-
const { disabled, readonly, multiple: multiple2, clearable, onClear, onChange } = props2;
|
|
437
|
-
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) ||
|
|
622
|
+
const { disabled: disabled2, readonly: readonly2, multiple: multiple2, clearable, onClear, onChange } = props2;
|
|
623
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2 || !clearable) {
|
|
438
624
|
return;
|
|
439
625
|
}
|
|
440
626
|
const changedModelValue = multiple2 ? [] : void 0;
|
|
@@ -445,23 +631,23 @@ const __sfc__ = defineComponent({
|
|
|
445
631
|
validateWithTrigger("onChange");
|
|
446
632
|
}
|
|
447
633
|
function handleClick(e) {
|
|
448
|
-
const { disabled, onClick } = props2;
|
|
449
|
-
if ((form == null ? void 0 : form.disabled.value) ||
|
|
634
|
+
const { disabled: disabled2, onClick } = props2;
|
|
635
|
+
if ((form == null ? void 0 : form.disabled.value) || disabled2) {
|
|
450
636
|
return;
|
|
451
637
|
}
|
|
452
638
|
call(onClick, e);
|
|
453
639
|
validateWithTrigger("onClick");
|
|
454
640
|
}
|
|
455
641
|
function handleClose(text) {
|
|
456
|
-
const { disabled, readonly, modelValue, onClose, onChange } = props2;
|
|
457
|
-
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) ||
|
|
642
|
+
const { disabled: disabled2, readonly: readonly2, modelValue, onClose, onChange } = props2;
|
|
643
|
+
if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
|
|
458
644
|
return;
|
|
459
645
|
}
|
|
460
646
|
const option = options.find(({ label: label2 }) => label2.value === text);
|
|
461
647
|
const changedModelValue = modelValue.filter(
|
|
462
648
|
(value) => {
|
|
463
|
-
var
|
|
464
|
-
return value !== ((
|
|
649
|
+
var _a2;
|
|
650
|
+
return value !== ((_a2 = option.value.value) != null ? _a2 : option.label.value);
|
|
465
651
|
}
|
|
466
652
|
);
|
|
467
653
|
call(props2["onUpdate:modelValue"], changedModelValue);
|
|
@@ -470,6 +656,15 @@ const __sfc__ = defineComponent({
|
|
|
470
656
|
call(onChange, changedModelValue);
|
|
471
657
|
validateWithTrigger("onChange");
|
|
472
658
|
}
|
|
659
|
+
function handleInput() {
|
|
660
|
+
showMenu.value = true;
|
|
661
|
+
}
|
|
662
|
+
function handleCompositionStart() {
|
|
663
|
+
isComposing.value = true;
|
|
664
|
+
}
|
|
665
|
+
function handleCompositionEnd() {
|
|
666
|
+
isComposing.value = false;
|
|
667
|
+
}
|
|
473
668
|
function focus() {
|
|
474
669
|
offsetY.value = toPxNum(props2.offsetY);
|
|
475
670
|
isFocusing.value = true;
|
|
@@ -487,6 +682,14 @@ const __sfc__ = defineComponent({
|
|
|
487
682
|
}
|
|
488
683
|
return {
|
|
489
684
|
root,
|
|
685
|
+
filterRef,
|
|
686
|
+
calculatorRef,
|
|
687
|
+
isComposing,
|
|
688
|
+
filterStyle,
|
|
689
|
+
pattern,
|
|
690
|
+
tabindex,
|
|
691
|
+
readonly,
|
|
692
|
+
disabled,
|
|
490
693
|
offsetY,
|
|
491
694
|
isFocusing,
|
|
492
695
|
showMenu,
|
|
@@ -497,13 +700,20 @@ const __sfc__ = defineComponent({
|
|
|
497
700
|
labels,
|
|
498
701
|
isEmptyModelValue,
|
|
499
702
|
menuEl,
|
|
703
|
+
menuRef,
|
|
500
704
|
placement,
|
|
501
705
|
cursor,
|
|
502
706
|
placeholderColor,
|
|
503
707
|
enableCustomPlaceholder,
|
|
708
|
+
showEmpty,
|
|
709
|
+
t,
|
|
710
|
+
pt,
|
|
504
711
|
isFunction,
|
|
505
712
|
n,
|
|
506
713
|
classes,
|
|
714
|
+
isShowSelected,
|
|
715
|
+
isShowSingleFilter,
|
|
716
|
+
isShowMultipleFilter,
|
|
507
717
|
handleFocus,
|
|
508
718
|
handleBlur,
|
|
509
719
|
handleClickOutside,
|
|
@@ -511,6 +721,9 @@ const __sfc__ = defineComponent({
|
|
|
511
721
|
handleClick,
|
|
512
722
|
handleClose,
|
|
513
723
|
handleRootBlur,
|
|
724
|
+
handleInput,
|
|
725
|
+
handleCompositionStart,
|
|
726
|
+
handleCompositionEnd,
|
|
514
727
|
reset,
|
|
515
728
|
validate,
|
|
516
729
|
resetValidation,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { computed, defineComponent, ref } from "vue";
|
|
2
|
+
import { call } from "@varlet/shared";
|
|
3
|
+
import { createNamespace, defineListenerProp } from "../utils/components.mjs";
|
|
4
|
+
const { n, classes } = createNamespace("select");
|
|
5
|
+
import { vModelText as _vModelText, normalizeClass as _normalizeClass, withDirectives as _withDirectives, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
|
|
6
|
+
function __render__(_ctx, _cache) {
|
|
7
|
+
return _withDirectives((_openBlock(), _createElementBlock(
|
|
8
|
+
"input",
|
|
9
|
+
{
|
|
10
|
+
ref: "filterInputRef",
|
|
11
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
|
|
12
|
+
type: "text",
|
|
13
|
+
class: _normalizeClass(_ctx.classes(_ctx.n("filter"), [_ctx.multiple, _ctx.n("filter--multiple")]))
|
|
14
|
+
},
|
|
15
|
+
null,
|
|
16
|
+
2
|
|
17
|
+
/* CLASS */
|
|
18
|
+
)), [
|
|
19
|
+
[_vModelText, _ctx.value]
|
|
20
|
+
]);
|
|
21
|
+
}
|
|
22
|
+
const __sfc__ = defineComponent({
|
|
23
|
+
name: "VarSelectFilter",
|
|
24
|
+
props: {
|
|
25
|
+
modelValue: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: ""
|
|
28
|
+
},
|
|
29
|
+
multiple: Boolean,
|
|
30
|
+
"onUpdate:modelValue": defineListenerProp()
|
|
31
|
+
},
|
|
32
|
+
setup(props) {
|
|
33
|
+
const filterInputRef = ref();
|
|
34
|
+
const value = computed({
|
|
35
|
+
get: () => props.modelValue,
|
|
36
|
+
set: (val) => call(props["onUpdate:modelValue"], val)
|
|
37
|
+
});
|
|
38
|
+
const focus = () => {
|
|
39
|
+
var _a;
|
|
40
|
+
(_a = filterInputRef.value) == null ? void 0 : _a.focus();
|
|
41
|
+
};
|
|
42
|
+
const blur = () => {
|
|
43
|
+
var _a;
|
|
44
|
+
(_a = filterInputRef.value) == null ? void 0 : _a.blur();
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
n,
|
|
48
|
+
classes,
|
|
49
|
+
value,
|
|
50
|
+
filterInputRef,
|
|
51
|
+
// expose
|
|
52
|
+
focus,
|
|
53
|
+
blur
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
__sfc__.render = __render__;
|
|
58
|
+
var stdin_default = __sfc__;
|
|
59
|
+
export {
|
|
60
|
+
stdin_default as default
|
|
61
|
+
};
|
package/es/select/props.mjs
CHANGED
|
@@ -54,6 +54,10 @@ const props = __spreadValues({
|
|
|
54
54
|
},
|
|
55
55
|
rules: [Array, Function, Object],
|
|
56
56
|
tabindex: String,
|
|
57
|
+
filterable: Boolean,
|
|
58
|
+
filter: {
|
|
59
|
+
type: Function
|
|
60
|
+
},
|
|
57
61
|
onFocus: defineListenerProp(),
|
|
58
62
|
onBlur: defineListenerProp(),
|
|
59
63
|
onClose: defineListenerProp(),
|
package/es/select/select.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root { --select-scroller-background: var(--color-surface-container-high); --select-scroller-padding: 6px 0; --select-scroller-max-height: 278px; --select-scroller-border-radius: 2px; --select-chips-margin: -5px 0 0 0; --select-chips-padding: 2px 0; --select-chip-margin: 5px 5px 0 0; --select-chip-background-color: #e0e0e0; --select-arrow-size: 20px; --select-standard-menu-margin: calc(var(--field-decorator-placeholder-size) * 0.75 + 12px) 0 0 0; --select-label-font-size: 16px;}.var-select { text-align: left; outline: none;}.var-select__menu[var-select-cover] { width: 100%; background: transparent; display: block;}.var-select__chip[var-select-cover] { margin: var(--select-chip-margin); background-color: var(--select-chip-background-color);}.var-select__chips { padding: var(--select-chips-padding); margin: var(--select-chips-margin);}.var-select__scroller { max-height: var(--select-scroller-max-height); background: var(--select-scroller-background); padding: var(--select-scroller-padding); overflow-y: auto; transition: background-color 0.25s; border-radius: var(--select-scroller-border-radius);}.var-
|
|
1
|
+
:root { --select-scroller-background: var(--color-surface-container-high); --select-scroller-padding: 6px 0; --select-scroller-max-height: 278px; --select-scroller-border-radius: 2px; --select-chips-margin: -5px 0 0 0; --select-chips-padding: 2px 0; --select-chip-margin: 5px 5px 0 0; --select-chip-background-color: #e0e0e0; --select-arrow-size: 20px; --select-standard-menu-margin: calc(var(--field-decorator-placeholder-size) * 0.75 + 12px) 0 0 0; --select-label-font-size: 16px; --select-empty-text-color: rgba(0, 0, 0, 0.6); --select-empty-height: 38px; --select-empty-font-size: 14px;}.var-select { text-align: left; outline: none;}.var-select__menu[var-select-cover] { width: 100%; background: transparent; display: block;}.var-select__chip[var-select-cover] { margin: var(--select-chip-margin); background-color: var(--select-chip-background-color);}.var-select__chips { padding: var(--select-chips-padding); margin: var(--select-chips-margin);}.var-select__scroller { max-height: var(--select-scroller-max-height); background: var(--select-scroller-background); padding: var(--select-scroller-padding); overflow-y: auto; transition: background-color 0.25s; border-radius: var(--select-scroller-border-radius);}.var-select__select { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 24px; outline: none; border: none; font-size: inherit; color: var(--field-decorator-text-color); word-break: break-all; overflow: hidden; transition: color 0.25s;}.var-select__values { display: flex; flex-wrap: wrap; align-items: center;}.var-select__chips { display: flex; flex-wrap: wrap; align-items: center;}.var-select__filter { flex: 1; position: absolute; left: 0; top: 0; height: 100%; border: none; outline: none; padding: 0; background-color: transparent; font-size: var(--field-decorator-placeholder-size); line-height: inherit; color: var(--field-decorator-text-color);}.var-select__filter--multiple { position: unset;}.var-select__chips .var-select__filter { padding-left: 0; margin-top: 4px;}.var-select__filter-calculator { position: absolute; left: 0; top: 0; max-width: 100%; visibility: hidden; white-space: pre; overflow: hidden; pointer-events: none;}.var-select__label { display: flex; align-items: center; font-size: var(--select-label-font-size);}.var-select__placeholder { max-width: 100%; position: absolute; top: 50%; left: 0; transform: translateY(-50%); font-size: var(--field-decorator-placeholder-size); line-height: 1.5em; color: var(--field-decorator-blur-color); pointer-events: none; cursor: inherit;}.var-select__empty { color: var(--select-empty-text-color); text-align: center; height: var(--select-empty-height); font-size: var(--select-empty-font-size); display: flex; align-items: center; justify-content: center;}.var-select__arrow[var-select-cover] { flex-shrink: 0; font-size: var(--select-arrow-size); margin-left: 6px;}.var-select--standard-menu-margin { margin: var(--select-standard-menu-margin) !important;}.var-select--disabled { color: var(--field-decorator-disabled-color); cursor: not-allowed;}.var-select--error { color: var(--field-decorator-error-color);}.var-select--arrow-rotate { transform: rotate(180deg);}.var-select--label-focusing { color: var(--field-decorator-blur-color);}
|