@v-c/select 1.1.4 → 1.2.1

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.
@@ -94,6 +94,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps {
94
94
  tokenSeparators?: string[] | ((input: string) => string[]);
95
95
  allowClear?: boolean | {
96
96
  clearIcon?: VueNode;
97
+ label?: string;
97
98
  };
98
99
  prefix?: VueNode;
99
100
  /** @deprecated Please use `suffix` instead. */
@@ -292,6 +292,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
292
292
  const { OptionList, prefixCls, className, loading, showSearch, prefix, placeholder, activeValue, animation, transitionName, popupStyle, popupClassName, direction, popupMatchSelectWidth, popupRender, popupAlign, placement, builtinPlacements, getPopupContainer, emptyOptions } = props;
293
293
  const mergedAllowClear = allowClearConfig.value.allowClear;
294
294
  const clearNode = allowClearConfig.value.clearIcon;
295
+ const clearLabel = allowClearConfig.value.label;
295
296
  const customizeInputElement = mode.value === "combobox" && typeof getInputElement.value === "function" && getInputElement.value() || null;
296
297
  let onTriggerVisibleChange = null;
297
298
  if (mergedComponents.value?.root) onTriggerVisibleChange = (newOpen) => {
@@ -330,6 +331,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
330
331
  "prefix": prefix,
331
332
  "suffix": mergedSuffixIcon,
332
333
  "clearIcon": clearNode,
334
+ "clearLabel": clearLabel,
333
335
  "multiple": multiple.value,
334
336
  "mode": mode.value,
335
337
  "displayValues": displayValues.value,
@@ -423,15 +425,6 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
423
425
  default: void 0
424
426
  },
425
427
  placeholder: {
426
- type: [
427
- Object,
428
- Function,
429
- String,
430
- Number,
431
- null,
432
- Boolean,
433
- Array
434
- ],
435
428
  required: false,
436
429
  default: void 0
437
430
  },
@@ -451,15 +444,6 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
451
444
  default: void 0
452
445
  },
453
446
  notFoundContent: {
454
- type: [
455
- Object,
456
- Function,
457
- String,
458
- Number,
459
- null,
460
- Boolean,
461
- Array
462
- ],
463
447
  required: false,
464
448
  default: void 0
465
449
  },
@@ -534,16 +518,9 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
534
518
  default: void 0
535
519
  },
536
520
  maxTagPlaceholder: {
537
- type: [
538
- Object,
539
- Function,
540
- String,
541
- Number,
542
- null,
543
- Boolean,
544
- Array
545
- ],
521
+ type: Function,
546
522
  required: false,
523
+ skipCheck: true,
547
524
  default: void 0
548
525
  },
549
526
  tokenSeparators: {
@@ -557,68 +534,29 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
557
534
  default: void 0
558
535
  },
559
536
  prefix: {
560
- type: [
561
- Object,
562
- Function,
563
- String,
564
- Number,
565
- null,
566
- Boolean,
567
- Array
568
- ],
569
537
  required: false,
570
538
  default: void 0
571
539
  },
572
540
  suffixIcon: {
573
- type: [
574
- Object,
575
- Function,
576
- String,
577
- Number,
578
- null,
579
- Boolean,
580
- Array
581
- ],
541
+ type: Function,
582
542
  required: false,
543
+ skipCheck: true,
583
544
  default: void 0
584
545
  },
585
546
  suffix: {
586
- type: [
587
- Object,
588
- Function,
589
- String,
590
- Number,
591
- null,
592
- Boolean,
593
- Array
594
- ],
547
+ type: Function,
595
548
  required: false,
549
+ skipCheck: true,
596
550
  default: void 0
597
551
  },
598
552
  clearIcon: {
599
- type: [
600
- Object,
601
- Function,
602
- String,
603
- Number,
604
- null,
605
- Boolean,
606
- Array
607
- ],
608
553
  required: false,
609
554
  default: void 0
610
555
  },
611
556
  removeIcon: {
612
- type: [
613
- Object,
614
- Function,
615
- String,
616
- Number,
617
- null,
618
- Boolean,
619
- Array
620
- ],
557
+ type: Function,
621
558
  required: false,
559
+ skipCheck: true,
622
560
  default: void 0
623
561
  },
624
562
  animation: {
@@ -652,7 +590,6 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
652
590
  default: void 0
653
591
  },
654
592
  popupAlign: {
655
- type: Object,
656
593
  required: false,
657
594
  default: void 0
658
595
  },
@@ -662,7 +599,6 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
662
599
  default: void 0
663
600
  },
664
601
  builtinPlacements: {
665
- type: Object,
666
602
  required: false,
667
603
  default: void 0
668
604
  },
@@ -196,6 +196,7 @@ var OptionList = /* @__PURE__ */ defineComponent({
196
196
  renderItem(activeIndex.value),
197
197
  renderItem(activeIndex.value + 1)
198
198
  ]), createVNode(List, mergeProps({
199
+ "prefixCls": `${baseProps.value?.prefixCls}-dropdown-list`,
199
200
  "itemKey": "key",
200
201
  "ref": (el) => {
201
202
  listRef.value = el;
package/dist/Select.js CHANGED
@@ -172,16 +172,9 @@ var Select = /* @__PURE__ */ defineComponent({
172
172
  default: void 0
173
173
  },
174
174
  menuItemSelectedIcon: {
175
- type: [
176
- Object,
177
- Function,
178
- String,
179
- Number,
180
- null,
181
- Boolean,
182
- Array
183
- ],
175
+ type: Function,
184
176
  required: false,
177
+ skipCheck: true,
185
178
  default: void 0
186
179
  },
187
180
  mode: {
@@ -243,15 +236,6 @@ var Select = /* @__PURE__ */ defineComponent({
243
236
  default: void 0
244
237
  },
245
238
  placeholder: {
246
- type: [
247
- Object,
248
- Function,
249
- String,
250
- Number,
251
- null,
252
- Boolean,
253
- Array
254
- ],
255
239
  required: false,
256
240
  default: void 0
257
241
  },
@@ -266,15 +250,6 @@ var Select = /* @__PURE__ */ defineComponent({
266
250
  default: void 0
267
251
  },
268
252
  notFoundContent: {
269
- type: [
270
- Object,
271
- Function,
272
- String,
273
- Number,
274
- null,
275
- Boolean,
276
- Array
277
- ],
278
253
  required: false,
279
254
  default: void 0
280
255
  },
@@ -344,16 +319,9 @@ var Select = /* @__PURE__ */ defineComponent({
344
319
  default: void 0
345
320
  },
346
321
  maxTagPlaceholder: {
347
- type: [
348
- Object,
349
- Function,
350
- String,
351
- Number,
352
- null,
353
- Boolean,
354
- Array
355
- ],
322
+ type: Function,
356
323
  required: false,
324
+ skipCheck: true,
357
325
  default: void 0
358
326
  },
359
327
  tokenSeparators: {
@@ -367,68 +335,29 @@ var Select = /* @__PURE__ */ defineComponent({
367
335
  default: void 0
368
336
  },
369
337
  prefix: {
370
- type: [
371
- Object,
372
- Function,
373
- String,
374
- Number,
375
- null,
376
- Boolean,
377
- Array
378
- ],
379
338
  required: false,
380
339
  default: void 0
381
340
  },
382
341
  suffixIcon: {
383
- type: [
384
- Object,
385
- Function,
386
- String,
387
- Number,
388
- null,
389
- Boolean,
390
- Array
391
- ],
342
+ type: Function,
392
343
  required: false,
344
+ skipCheck: true,
393
345
  default: void 0
394
346
  },
395
347
  suffix: {
396
- type: [
397
- Object,
398
- Function,
399
- String,
400
- Number,
401
- null,
402
- Boolean,
403
- Array
404
- ],
348
+ type: Function,
405
349
  required: false,
350
+ skipCheck: true,
406
351
  default: void 0
407
352
  },
408
353
  clearIcon: {
409
- type: [
410
- Object,
411
- Function,
412
- String,
413
- Number,
414
- null,
415
- Boolean,
416
- Array
417
- ],
418
354
  required: false,
419
355
  default: void 0
420
356
  },
421
357
  removeIcon: {
422
- type: [
423
- Object,
424
- Function,
425
- String,
426
- Number,
427
- null,
428
- Boolean,
429
- Array
430
- ],
358
+ type: Function,
431
359
  required: false,
360
+ skipCheck: true,
432
361
  default: void 0
433
362
  },
434
363
  animation: {
@@ -462,7 +391,6 @@ var Select = /* @__PURE__ */ defineComponent({
462
391
  default: void 0
463
392
  },
464
393
  popupAlign: {
465
- type: Object,
466
394
  required: false,
467
395
  default: void 0
468
396
  },
@@ -472,7 +400,6 @@ var Select = /* @__PURE__ */ defineComponent({
472
400
  default: void 0
473
401
  },
474
402
  builtinPlacements: {
475
- type: Object,
476
403
  required: false,
477
404
  default: void 0
478
405
  },
@@ -14,7 +14,7 @@ var Placeholder = /* @__PURE__ */ defineComponent((props) => {
14
14
  return createVNode("div", {
15
15
  "class": clsx(`${prefixCls}-placeholder`, classNames?.placeholder),
16
16
  "style": {
17
- visibility: show ? "visible" : "hidden",
17
+ ...show ? {} : { visibility: "hidden" },
18
18
  ...styles?.placeholder
19
19
  }
20
20
  }, [placeholder]);
@@ -64,13 +64,13 @@ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
64
64
  }, { immediate: true });
65
65
  return () => {
66
66
  const { style, autoComplete, className, value, readOnly } = props;
67
- const { prefixCls, mode, autoFocus, placeholder } = selectInputContext.value ?? {};
67
+ const { prefixCls, autoFocus, placeholder } = selectInputContext.value ?? {};
68
68
  const { input: InputComponent = "input" } = selectInputContext.value?.components ?? {};
69
69
  const { styles, id, classNames, open, activeDescendantId, role, disabled } = baseProps.value ?? {};
70
70
  const inputCls = clsx(`${prefixCls}-input`, classNames?.input, className);
71
71
  const sharedInputProps = {
72
72
  id,
73
- "type": mode === "combobox" ? "text" : "search",
73
+ "type": "text",
74
74
  readOnly,
75
75
  ...attrs,
76
76
  "ref": inputRef,
@@ -80,7 +80,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
80
80
  "--select-input-width": widthCssVar.value
81
81
  },
82
82
  autoFocus,
83
- "autocomplete": autoComplete || "off",
83
+ "autocomplete": autoComplete || "new-password",
84
84
  "class": inputCls,
85
85
  disabled,
86
86
  "value": value || "",
@@ -12,6 +12,7 @@ export interface SelectInputProps {
12
12
  prefix?: VueNode;
13
13
  suffix?: VueNode;
14
14
  clearIcon?: VueNode;
15
+ clearLabel?: string;
15
16
  removeIcon?: RenderNode;
16
17
  multiple?: boolean;
17
18
  displayValues: DisplayValueType[];
@@ -5,7 +5,7 @@ import { useSelectInputProvider } from "./context.js";
5
5
  import SelectContent from "./Content/index.js";
6
6
  import { cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
7
7
  import { clsx } from "@v-c/util";
8
- import KeyCode from "@v-c/util/dist/KeyCode";
8
+ import KeyCode, { KeyCodeStr } from "@v-c/util/dist/KeyCode";
9
9
  import omit from "@v-c/util/dist/omit";
10
10
  import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
11
11
  //#region src/SelectInput/index.tsx
@@ -50,6 +50,7 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
50
50
  const prefix = computed(() => props.prefix);
51
51
  const suffix = computed(() => props.suffix);
52
52
  const clearIcon = computed(() => props.clearIcon);
53
+ const clearLabel = computed(() => props.clearLabel);
53
54
  const multiple = computed(() => props.multiple);
54
55
  const mode = computed(() => props.mode);
55
56
  const onClearMouseDown = computed(() => props.onClearMouseDown);
@@ -97,10 +98,13 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
97
98
  if (!event._select_lazy) {
98
99
  inputRef.value?.input?.focus();
99
100
  if (!shouldPreventClose) toggleOpen.value?.();
100
- } else if (triggerOpen.value) toggleOpen.value?.(false);
101
+ } else if (triggerOpen.value && !multiple.value) toggleOpen.value?.(false);
101
102
  }
102
103
  props?.onMouseDown?.(event);
103
104
  };
105
+ const onClearKeydown = (event) => {
106
+ if (event.key === KeyCodeStr.Enter || event.key === KeyCodeStr.Space) event.stopPropagation();
107
+ };
104
108
  useSelectInputProvider(computed(() => ({
105
109
  ...props,
106
110
  onInputKeyDown: onInternalInputKeyDown
@@ -152,14 +156,18 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
152
156
  "class": clsx(`${prefixCls.value}-suffix`, { [`${prefixCls.value}-suffix-loading`]: loading.value }, classNamesConfig.value?.suffix),
153
157
  "style": stylesConfig.value?.suffix
154
158
  }, { default: () => [suffix.value] }),
155
- clearIcon.value && createVNode(Affix, {
159
+ clearIcon.value && createVNode("button", {
160
+ "type": "button",
161
+ "aria-label": clearLabel.value,
156
162
  "class": clsx(`${prefixCls.value}-clear`, classNamesConfig.value?.clear),
157
163
  "style": stylesConfig.value?.clear,
158
164
  "onMousedown": (e) => {
165
+ e.preventDefault();
159
166
  e._select_lazy = true;
160
- onClearMouseDown.value?.(e);
161
- }
162
- }, { default: () => [clearIcon.value] }),
167
+ },
168
+ "onKeydown": onClearKeydown,
169
+ "onClick": (e) => onClearMouseDown.value?.(e)
170
+ }, [clearIcon.value]),
163
171
  slots.default?.()
164
172
  ]);
165
173
  };
@@ -170,55 +178,26 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
170
178
  required: true
171
179
  },
172
180
  prefix: {
173
- type: [
174
- Object,
175
- Function,
176
- String,
177
- Number,
178
- null,
179
- Boolean,
180
- Array
181
- ],
182
181
  required: false,
183
182
  default: void 0
184
183
  },
185
184
  suffix: {
186
- type: [
187
- Object,
188
- Function,
189
- String,
190
- Number,
191
- null,
192
- Boolean,
193
- Array
194
- ],
195
185
  required: false,
196
186
  default: void 0
197
187
  },
198
188
  clearIcon: {
199
- type: [
200
- Object,
201
- Function,
202
- String,
203
- Number,
204
- null,
205
- Boolean,
206
- Array
207
- ],
189
+ required: false,
190
+ default: void 0
191
+ },
192
+ clearLabel: {
193
+ type: String,
208
194
  required: false,
209
195
  default: void 0
210
196
  },
211
197
  removeIcon: {
212
- type: [
213
- Object,
214
- Function,
215
- String,
216
- Number,
217
- null,
218
- Boolean,
219
- Array
220
- ],
198
+ type: Function,
221
199
  required: false,
200
+ skipCheck: true,
222
201
  default: void 0
223
202
  },
224
203
  multiple: {
@@ -231,15 +210,6 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
231
210
  required: true
232
211
  },
233
212
  placeholder: {
234
- type: [
235
- Object,
236
- Function,
237
- String,
238
- Number,
239
- null,
240
- Boolean,
241
- Array
242
- ],
243
213
  required: false,
244
214
  default: void 0
245
215
  },
@@ -114,7 +114,6 @@ var SelectTrigger = /* @__PURE__ */ defineComponent((props, { slots, attrs, expo
114
114
  default: void 0
115
115
  },
116
116
  builtinPlacements: {
117
- type: Object,
118
117
  required: false,
119
118
  default: void 0
120
119
  },
@@ -149,7 +148,6 @@ var SelectTrigger = /* @__PURE__ */ defineComponent((props, { slots, attrs, expo
149
148
  default: void 0
150
149
  },
151
150
  popupAlign: {
152
- type: Object,
153
151
  required: false,
154
152
  default: void 0
155
153
  },
package/dist/TransBtn.js CHANGED
@@ -43,16 +43,9 @@ var TransBtn = /* @__PURE__ */ defineComponent((props, { slots }) => {
43
43
  default: void 0
44
44
  },
45
45
  customizeIcon: {
46
- type: [
47
- Object,
48
- Function,
49
- String,
50
- Number,
51
- null,
52
- Boolean,
53
- Array
54
- ],
46
+ type: Function,
55
47
  required: false,
48
+ skipCheck: true,
56
49
  default: void 0
57
50
  },
58
51
  customizeIconProps: {
@@ -3,7 +3,9 @@ import { DisplayValueType, Mode } from '../interface.ts';
3
3
  export interface AllowClearConfig {
4
4
  allowClear: boolean;
5
5
  clearIcon: any;
6
+ label: string;
6
7
  }
7
8
  export declare function useAllowClear(_prefixCls: Ref<string>, displayValues: Ref<DisplayValueType[]>, allowClear?: Ref<boolean | {
8
9
  clearIcon?: any;
10
+ label?: string;
9
11
  }>, clearIcon?: Ref<any>, disabled?: Ref<boolean>, mergedSearchValue?: Ref<string | undefined>, mode?: Ref<Mode | undefined>): import('vue').ComputedRef<AllowClearConfig>;
@@ -10,7 +10,8 @@ function useAllowClear(_prefixCls, displayValues, allowClear, clearIcon, disable
10
10
  const mergedAllowClear = !disabled?.value && allowClearConfig.value?.allowClear !== false && (displayValues.value.length || mergedSearchValue?.value) && !(mode?.value === "combobox" && mergedSearchValue?.value === "");
11
11
  return {
12
12
  allowClear: !!mergedAllowClear,
13
- clearIcon: mergedAllowClear ? allowClearConfig.value.clearIcon || clearIcon?.value || "×" : null
13
+ clearIcon: mergedAllowClear ? allowClearConfig.value.clearIcon || clearIcon?.value || "×" : null,
14
+ label: mergedAllowClear ? allowClearConfig.value.label ?? "Clear" : ""
14
15
  };
15
16
  });
16
17
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/select",
3
3
  "type": "module",
4
- "version": "1.1.4",
4
+ "version": "1.2.1",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -34,10 +34,10 @@
34
34
  "vue": "^3.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@v-c/trigger": "^1.0.17",
38
- "@v-c/overflow": "^1.1.0",
39
- "@v-c/virtual-list": "^1.0.9",
40
- "@v-c/util": "^1.0.19"
37
+ "@v-c/overflow": "^1.1.1",
38
+ "@v-c/util": "^1.1.0",
39
+ "@v-c/virtual-list": "^1.1.1",
40
+ "@v-c/trigger": "^1.1.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "vite build",