@varlet/ui 3.13.1 → 3.14.0-alpha.1772307023035

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.
@@ -1,24 +1,68 @@
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
- import { assert, call, doubleRaf, isArray, isEmpty, isFunction, preventDefault } from "@varlet/shared";
41
+ import { assert, call, doubleRaf, getStyle, isArray, isEmpty, isFunction, preventDefault } from "@varlet/shared";
3
42
  import { useEventListener } from "@varlet/use";
4
43
  import VarChip from "../chip/index.mjs";
5
44
  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";
15
57
  import { useSelectController } from "./useSelectController.mjs";
58
+ import { useSelectFilterSize } from "./useSelectFilterSize.mjs";
16
59
  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, normalizeStyle as _normalizeStyle, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, createSlots as _createSlots } from "vue";
60
+ 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
61
  const _hoisted_1 = ["tabindex"];
19
62
  function __render__(_ctx, _cache) {
20
63
  const _component_maybe_v_node = _resolveComponent("maybe-v-node");
21
64
  const _component_var_chip = _resolveComponent("var-chip");
65
+ const _component_var_select_filter = _resolveComponent("var-select-filter");
22
66
  const _component_var_icon = _resolveComponent("var-icon");
23
67
  const _component_var_field_decorator = _resolveComponent("var-field-decorator");
24
68
  const _component_var_option = _resolveComponent("var-option");
@@ -27,19 +71,20 @@ function __render__(_ctx, _cache) {
27
71
  return _openBlock(), _createElementBlock("div", {
28
72
  ref: "root",
29
73
  class: _normalizeClass(_ctx.n()),
30
- tabindex: _ctx.tabindex == null ? _ctx.disabled || _ctx.formDisabled ? void 0 : "0" : _ctx.tabindex,
31
- onFocus: _cache[3] || (_cache[3] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
32
- onBlur: _cache[4] || (_cache[4] = (...args) => _ctx.handleRootBlur && _ctx.handleRootBlur(...args))
74
+ tabindex: _ctx.tabindex,
75
+ onFocus: _cache[6] || (_cache[6] = (...args) => _ctx.handleFocus && _ctx.handleFocus(...args)),
76
+ onBlur: _cache[7] || (_cache[7] = (...args) => _ctx.handleRootBlur && _ctx.handleRootBlur(...args))
33
77
  }, [
34
78
  _createVNode(_component_var_menu, {
79
+ ref: "menuRef",
35
80
  show: _ctx.showMenu,
36
- "onUpdate:show": _cache[1] || (_cache[1] = ($event) => _ctx.showMenu = $event),
81
+ "onUpdate:show": _cache[4] || (_cache[4] = ($event) => _ctx.showMenu = $event),
37
82
  "var-select-cover": "",
38
83
  "same-width": "",
39
84
  "close-on-click-reference": "",
40
85
  "close-on-key-escape": false,
41
86
  class: _normalizeClass(_ctx.n("menu")),
42
- "popover-class": _ctx.variant === "standard" && _ctx.hint ? _ctx.n("--standard-menu-margin") : void 0,
87
+ "popover-class": _ctx.variant === "standard" && _ctx.hint && !_ctx.filterable ? _ctx.n("--standard-menu-margin") : void 0,
43
88
  "offset-y": _ctx.offsetY,
44
89
  disabled: _ctx.formReadonly || _ctx.readonly || _ctx.formDisabled || _ctx.disabled,
45
90
  placement: _ctx.placement,
@@ -54,9 +99,20 @@ function __render__(_ctx, _cache) {
54
99
  class: _normalizeClass(_ctx.classes(_ctx.n("scroller"), _ctx.n("$-elevation--3")))
55
100
  },
56
101
  [
102
+ _ctx.showEmpty ? _renderSlot(_ctx.$slots, "empty", { key: 0 }, () => [
103
+ _createElementVNode(
104
+ "div",
105
+ {
106
+ class: _normalizeClass(_ctx.n("empty"))
107
+ },
108
+ _toDisplayString((_ctx.pt ? _ctx.pt : _ctx.t)("selectEmptyText")),
109
+ 3
110
+ /* TEXT, CLASS */
111
+ )
112
+ ]) : _createCommentVNode("v-if", true),
57
113
  _ctx.options.length ? (_openBlock(true), _createElementBlock(
58
114
  _Fragment,
59
- { key: 0 },
115
+ { key: 1 },
60
116
  _renderList(_ctx.options, (option) => {
61
117
  return _openBlock(), _createBlock(_component_var_option, {
62
118
  key: option[_ctx.valueKey],
@@ -80,7 +136,7 @@ function __render__(_ctx, _cache) {
80
136
  _createVNode(
81
137
  _component_var_field_decorator,
82
138
  _normalizeProps(_guardReactiveProps({
83
- value: _ctx.modelValue,
139
+ value: _ctx.pattern || _ctx.modelValue,
84
140
  size: _ctx.size,
85
141
  variant: _ctx.variant,
86
142
  placeholder: _ctx.placeholder,
@@ -92,16 +148,14 @@ function __render__(_ctx, _cache) {
92
148
  isFocusing: _ctx.isFocusing,
93
149
  isError: !!_ctx.errorMessage,
94
150
  formDisabled: _ctx.formDisabled,
151
+ composing: _ctx.isComposing,
95
152
  disabled: _ctx.disabled,
96
- clearable: _ctx.clearable,
153
+ clearable: _ctx.clearable ? !_ctx.filterable || !_ctx.pattern : false,
97
154
  cursor: _ctx.cursor,
98
155
  onClick: _ctx.handleClick,
99
156
  onClear: _ctx.handleClear
100
157
  })),
101
158
  _createSlots({
102
- "clear-icon": _withCtx(({ clear }) => [
103
- _renderSlot(_ctx.$slots, "clear-icon", { clear })
104
- ]),
105
159
  "append-icon": _withCtx(() => [
106
160
  _renderSlot(_ctx.$slots, "arrow-icon", {
107
161
  focus: _ctx.isFocusing,
@@ -130,10 +184,10 @@ function __render__(_ctx, _cache) {
130
184
  _createElementVNode(
131
185
  "div",
132
186
  {
133
- class: _normalizeClass(_ctx.n("label"))
187
+ class: _normalizeClass(_ctx.classes(_ctx.n("label"), [_ctx.filterable && _ctx.showMenu, _ctx.n("--label-focusing")]))
134
188
  },
135
189
  [
136
- !_ctx.isEmptyModelValue ? _renderSlot(_ctx.$slots, "selected", { key: 0 }, () => [
190
+ _ctx.isShowSelected() ? _renderSlot(_ctx.$slots, "selected", { key: 0 }, () => [
137
191
  _ctx.multiple ? (_openBlock(), _createElementBlock(
138
192
  _Fragment,
139
193
  { key: 0 },
@@ -169,7 +223,20 @@ function __render__(_ctx, _cache) {
169
223
  }),
170
224
  128
171
225
  /* KEYED_FRAGMENT */
172
- ))
226
+ )),
227
+ _ctx.isShowMultipleFilter() ? (_openBlock(), _createBlock(_component_var_select_filter, {
228
+ key: 0,
229
+ ref: "filterRef",
230
+ modelValue: _ctx.pattern,
231
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.pattern = $event),
232
+ style: _normalizeStyle(_ctx.filterStyle),
233
+ multiple: _ctx.multiple,
234
+ onFocus: _ctx.handleFocus,
235
+ onBlur: _ctx.handleRootBlur,
236
+ onInput: _ctx.handleInput,
237
+ onCompositionstart: _ctx.handleCompositionStart,
238
+ onCompositionend: _ctx.handleCompositionEnd
239
+ }, null, 8, ["modelValue", "style", "multiple", "onFocus", "onBlur", "onInput", "onCompositionstart", "onCompositionend"])) : _createCommentVNode("v-if", true)
173
240
  ],
174
241
  2
175
242
  /* CLASS */
@@ -201,7 +268,20 @@ function __render__(_ctx, _cache) {
201
268
  }),
202
269
  128
203
270
  /* KEYED_FRAGMENT */
204
- ))
271
+ )),
272
+ _ctx.isShowMultipleFilter() ? (_openBlock(), _createBlock(_component_var_select_filter, {
273
+ key: 0,
274
+ ref: "filterRef",
275
+ modelValue: _ctx.pattern,
276
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.pattern = $event),
277
+ style: _normalizeStyle(__spreadProps(__spreadValues({}, _ctx.filterStyle), { paddingLeft: _ctx.labels.length ? "4px" : 0 })),
278
+ multiple: _ctx.multiple,
279
+ onFocus: _ctx.handleFocus,
280
+ onBlur: _ctx.handleRootBlur,
281
+ onInput: _ctx.handleInput,
282
+ onCompositionstart: _ctx.handleCompositionStart,
283
+ onCompositionend: _ctx.handleCompositionEnd
284
+ }, null, 8, ["modelValue", "style", "multiple", "onFocus", "onBlur", "onInput", "onCompositionstart", "onCompositionend"])) : _createCommentVNode("v-if", true)
205
285
  ],
206
286
  2
207
287
  /* CLASS */
@@ -218,18 +298,39 @@ function __render__(_ctx, _cache) {
218
298
  2
219
299
  /* CLASS */
220
300
  ),
221
- _ctx.enableCustomPlaceholder ? (_openBlock(), _createElementBlock(
301
+ _ctx.enableCustomPlaceholder && !_ctx.pattern ? (_openBlock(), _createElementBlock(
222
302
  "span",
223
303
  {
224
304
  key: 0,
225
305
  class: _normalizeClass(_ctx.classes(_ctx.n("placeholder"), _ctx.n("$--ellipsis"))),
226
- style: _normalizeStyle({
227
- color: _ctx.placeholderColor
228
- })
306
+ style: _normalizeStyle({ color: _ctx.placeholderColor })
229
307
  },
230
308
  _toDisplayString(_ctx.placeholder),
231
309
  7
232
310
  /* TEXT, CLASS, STYLE */
311
+ )) : _createCommentVNode("v-if", true),
312
+ _ctx.isShowSingleFilter() ? (_openBlock(), _createBlock(_component_var_select_filter, {
313
+ key: 1,
314
+ ref: "filterRef",
315
+ modelValue: _ctx.pattern,
316
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.pattern = $event),
317
+ style: _normalizeStyle(_ctx.filterStyle),
318
+ onFocus: _ctx.handleFocus,
319
+ onBlur: _ctx.handleRootBlur,
320
+ onInput: _ctx.handleInput,
321
+ onCompositionstart: _ctx.handleCompositionStart,
322
+ onCompositionend: _ctx.handleCompositionEnd
323
+ }, null, 8, ["modelValue", "style", "onFocus", "onBlur", "onInput", "onCompositionstart", "onCompositionend"])) : _createCommentVNode("v-if", true),
324
+ _ctx.filterable ? (_openBlock(), _createElementBlock(
325
+ "span",
326
+ {
327
+ key: 2,
328
+ ref: "calculatorRef",
329
+ class: _normalizeClass(_ctx.n("filter-calculator"))
330
+ },
331
+ _toDisplayString(_ctx.pattern),
332
+ 3
333
+ /* TEXT, CLASS */
233
334
  )) : _createCommentVNode("v-if", true)
234
335
  ],
235
336
  6
@@ -245,6 +346,13 @@ function __render__(_ctx, _cache) {
245
346
  _renderSlot(_ctx.$slots, "prepend-icon")
246
347
  ]),
247
348
  key: "0"
349
+ } : void 0,
350
+ !_ctx.pattern ? {
351
+ name: "clear-icon",
352
+ fn: _withCtx(({ clear }) => [
353
+ _renderSlot(_ctx.$slots, "clear-icon", { clear })
354
+ ]),
355
+ key: "1"
248
356
  } : void 0
249
357
  ]),
250
358
  1040
@@ -256,7 +364,7 @@ function __render__(_ctx, _cache) {
256
364
  }, 8, ["show", "class", "popover-class", "offset-y", "disabled", "placement", "onClickOutside"]),
257
365
  _createVNode(_component_var_form_details, {
258
366
  "error-message": _ctx.errorMessage,
259
- onClick: _cache[2] || (_cache[2] = _withModifiers(() => {
367
+ onClick: _cache[5] || (_cache[5] = _withModifiers(() => {
260
368
  }, ["stop"]))
261
369
  }, null, 8, ["error-message"])
262
370
  ], 42, _hoisted_1);
@@ -270,18 +378,23 @@ const __sfc__ = defineComponent({
270
378
  VarOption,
271
379
  VarFieldDecorator,
272
380
  VarFormDetails,
381
+ VarSelectFilter,
273
382
  MaybeVNode
274
383
  },
275
384
  props,
276
385
  setup(props2) {
386
+ var _a;
277
387
  const isFocusing = ref(false);
278
388
  const showMenu = ref(false);
279
389
  const root = ref(null);
390
+ const filterRef = ref(null);
391
+ const pattern = ref("");
392
+ const isComposing = ref(false);
393
+ const filterable = computed(() => props2.filterable);
280
394
  const multiple = computed(() => props2.multiple);
281
395
  const focusColor = computed(() => props2.focusColor);
282
396
  const isEmptyModelValue = computed(() => isEmpty(props2.modelValue));
283
397
  const cursor = computed(() => props2.disabled || props2.readonly ? "" : "pointer");
284
- const offsetY = ref(0);
285
398
  const { bindForm, form } = useForm();
286
399
  const { length, options, bindOptions } = useOptions();
287
400
  const { label, labels, computeLabel, getSelectedValue } = useSelectController({
@@ -297,8 +410,22 @@ const __sfc__ = defineComponent({
297
410
  // expose
298
411
  resetValidation
299
412
  } = useValidation();
413
+ const readonly = computed(() => (form == null ? void 0 : form.readonly.value) || props2.readonly);
414
+ const disabled = computed(() => (form == null ? void 0 : form.disabled.value) || props2.disabled);
300
415
  const menuEl = ref(null);
301
- const placement = computed(() => props2.variant === "outlined" ? "bottom" : "cover-top");
416
+ const menuRef = ref(null);
417
+ const placement = computed(() => props2.variant === "standard" && !props2.filterable ? "cover-top" : "bottom");
418
+ const showEmpty = ref(false);
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,
@@ -332,13 +474,58 @@ const __sfc__ = defineComponent({
332
474
  );
333
475
  }
334
476
  );
477
+ watch(
478
+ () => pattern.value,
479
+ () => __async(this, null, function* () {
480
+ var _a2;
481
+ if (!showMenu.value) {
482
+ return;
483
+ }
484
+ yield nextTick();
485
+ (_a2 = menuRef.value) == null ? void 0 : _a2.resize();
486
+ updateShowEmpty();
487
+ })
488
+ );
489
+ watch(
490
+ () => showMenu.value,
491
+ () => {
492
+ if (!showMenu.value) {
493
+ return;
494
+ }
495
+ updateShowEmpty();
496
+ },
497
+ { immediate: true }
498
+ );
335
499
  bindOptions(selectProvider);
336
500
  useEventListener(() => window, "keydown", handleKeydown);
337
501
  useEventListener(() => window, "keyup", handleKeyup);
338
502
  call(bindForm, selectProvider);
503
+ function updateShowEmpty() {
504
+ var _a2;
505
+ const options2 = (_a2 = menuEl.value) == null ? void 0 : _a2.querySelectorAll(".var-option");
506
+ if (!options2) {
507
+ return;
508
+ }
509
+ showEmpty.value = options2.length === 0 || Array.from(options2).every((option) => getStyle(option).display === "none");
510
+ }
511
+ function isShowSingleFilter() {
512
+ return filterable.value && !readonly.value && !disabled.value && !multiple.value;
513
+ }
514
+ function isShowMultipleFilter() {
515
+ return filterable.value && !readonly.value && !disabled.value && multiple.value;
516
+ }
517
+ function isShowSelected() {
518
+ if (isEmptyModelValue.value && !multiple.value) {
519
+ return false;
520
+ }
521
+ if (!multiple.value && (pattern.value || isComposing.value)) {
522
+ return false;
523
+ }
524
+ return true;
525
+ }
339
526
  function handleKeydown(event) {
340
- const { disabled, readonly } = props2;
341
- if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly || !isFocusing.value) {
527
+ var _a2;
528
+ if (disabled.value || readonly.value || !isFocusing.value) {
342
529
  return;
343
530
  }
344
531
  const { key } = event;
@@ -361,6 +548,7 @@ const __sfc__ = defineComponent({
361
548
  if (key === "Enter" && !showMenu.value) {
362
549
  preventDefault(event);
363
550
  showMenu.value = true;
551
+ (_a2 = filterRef.value) == null ? void 0 : _a2.focus();
364
552
  return;
365
553
  }
366
554
  if ((key === "ArrowDown" || key === "ArrowUp") && showMenu.value) {
@@ -369,8 +557,7 @@ const __sfc__ = defineComponent({
369
557
  }
370
558
  }
371
559
  function handleKeyup(event) {
372
- const { disabled, readonly } = props2;
373
- if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly || showMenu.value || !isFocusing.value) {
560
+ if (disabled.value || readonly.value || showMenu.value || !isFocusing.value) {
374
561
  return;
375
562
  }
376
563
  const { key } = event;
@@ -386,18 +573,20 @@ const __sfc__ = defineComponent({
386
573
  });
387
574
  }
388
575
  function handleFocus() {
389
- const { disabled, readonly, onFocus } = props2;
390
- if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly) {
576
+ var _a2;
577
+ const { disabled: disabled2, readonly: readonly2, onFocus } = props2;
578
+ if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
391
579
  return;
392
580
  }
393
581
  offsetY.value = toPxNum(props2.offsetY);
394
582
  focus();
583
+ (_a2 = filterRef.value) == null ? void 0 : _a2.focus();
395
584
  call(onFocus);
396
585
  validateWithTrigger("onFocus");
397
586
  }
398
587
  function handleBlur() {
399
- const { disabled, readonly, onBlur } = props2;
400
- if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled || readonly) {
588
+ const { disabled: disabled2, readonly: readonly2, onBlur } = props2;
589
+ if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
401
590
  return;
402
591
  }
403
592
  blur();
@@ -417,24 +606,29 @@ const __sfc__ = defineComponent({
417
606
  handleBlur();
418
607
  }
419
608
  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) || disabled || readonly) {
609
+ const { disabled: disabled2, readonly: readonly2, multiple: multiple2, onChange } = props2;
610
+ if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
422
611
  return;
423
612
  }
424
613
  const selectedValue = getSelectedValue(option);
425
614
  call(props2["onUpdate:modelValue"], selectedValue);
426
615
  call(onChange, selectedValue);
427
616
  validateWithTrigger("onChange");
617
+ nextTick(() => {
618
+ var _a2;
619
+ return (_a2 = filterRef.value) == null ? void 0 : _a2.focus();
620
+ });
428
621
  if (!multiple2) {
429
622
  root.value.focus();
430
623
  doubleRaf().then(() => {
431
624
  showMenu.value = false;
625
+ pattern.value = "";
432
626
  });
433
627
  }
434
628
  }
435
629
  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) || disabled || readonly || !clearable) {
630
+ const { disabled: disabled2, readonly: readonly2, multiple: multiple2, clearable, onClear, onChange } = props2;
631
+ if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2 || !clearable) {
438
632
  return;
439
633
  }
440
634
  const changedModelValue = multiple2 ? [] : void 0;
@@ -445,23 +639,23 @@ const __sfc__ = defineComponent({
445
639
  validateWithTrigger("onChange");
446
640
  }
447
641
  function handleClick(e) {
448
- const { disabled, onClick } = props2;
449
- if ((form == null ? void 0 : form.disabled.value) || disabled) {
642
+ const { disabled: disabled2, onClick } = props2;
643
+ if ((form == null ? void 0 : form.disabled.value) || disabled2) {
450
644
  return;
451
645
  }
452
646
  call(onClick, e);
453
647
  validateWithTrigger("onClick");
454
648
  }
455
649
  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) || disabled || readonly) {
650
+ const { disabled: disabled2, readonly: readonly2, modelValue, onClose, onChange } = props2;
651
+ if ((form == null ? void 0 : form.disabled.value) || (form == null ? void 0 : form.readonly.value) || disabled2 || readonly2) {
458
652
  return;
459
653
  }
460
654
  const option = options.find(({ label: label2 }) => label2.value === text);
461
655
  const changedModelValue = modelValue.filter(
462
656
  (value) => {
463
- var _a;
464
- return value !== ((_a = option.value.value) != null ? _a : option.label.value);
657
+ var _a2;
658
+ return value !== ((_a2 = option.value.value) != null ? _a2 : option.label.value);
465
659
  }
466
660
  );
467
661
  call(props2["onUpdate:modelValue"], changedModelValue);
@@ -470,6 +664,15 @@ const __sfc__ = defineComponent({
470
664
  call(onChange, changedModelValue);
471
665
  validateWithTrigger("onChange");
472
666
  }
667
+ function handleInput() {
668
+ showMenu.value = true;
669
+ }
670
+ function handleCompositionStart() {
671
+ isComposing.value = true;
672
+ }
673
+ function handleCompositionEnd() {
674
+ isComposing.value = false;
675
+ }
473
676
  function focus() {
474
677
  offsetY.value = toPxNum(props2.offsetY);
475
678
  isFocusing.value = true;
@@ -487,6 +690,14 @@ const __sfc__ = defineComponent({
487
690
  }
488
691
  return {
489
692
  root,
693
+ filterRef,
694
+ calculatorRef,
695
+ isComposing,
696
+ filterStyle,
697
+ pattern,
698
+ tabindex,
699
+ readonly,
700
+ disabled,
490
701
  offsetY,
491
702
  isFocusing,
492
703
  showMenu,
@@ -497,13 +708,20 @@ const __sfc__ = defineComponent({
497
708
  labels,
498
709
  isEmptyModelValue,
499
710
  menuEl,
711
+ menuRef,
500
712
  placement,
501
713
  cursor,
502
714
  placeholderColor,
503
715
  enableCustomPlaceholder,
716
+ showEmpty,
717
+ t,
718
+ pt,
504
719
  isFunction,
505
720
  n,
506
721
  classes,
722
+ isShowSelected,
723
+ isShowSingleFilter,
724
+ isShowMultipleFilter,
507
725
  handleFocus,
508
726
  handleBlur,
509
727
  handleClickOutside,
@@ -511,6 +729,9 @@ const __sfc__ = defineComponent({
511
729
  handleClick,
512
730
  handleClose,
513
731
  handleRootBlur,
732
+ handleInput,
733
+ handleCompositionStart,
734
+ handleCompositionEnd,
514
735
  reset,
515
736
  validate,
516
737
  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
+ };
@@ -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(),
@@ -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-select__wrap { position: relative; display: flex; flex-direction: column; width: 100%;}.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__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__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);}
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);}