@v-c/select 1.1.4 → 1.2.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.
@@ -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,
@@ -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;
@@ -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[];
@@ -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,7 +98,7 @@ 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
  };
@@ -152,14 +153,17 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
152
153
  "class": clsx(`${prefixCls.value}-suffix`, { [`${prefixCls.value}-suffix-loading`]: loading.value }, classNamesConfig.value?.suffix),
153
154
  "style": stylesConfig.value?.suffix
154
155
  }, { default: () => [suffix.value] }),
155
- clearIcon.value && createVNode(Affix, {
156
+ clearIcon.value && createVNode("button", {
157
+ "type": "button",
158
+ "aria-label": clearLabel.value,
156
159
  "class": clsx(`${prefixCls.value}-clear`, classNamesConfig.value?.clear),
157
160
  "style": stylesConfig.value?.clear,
158
161
  "onMousedown": (e) => {
162
+ e.preventDefault();
159
163
  e._select_lazy = true;
160
- onClearMouseDown.value?.(e);
161
- }
162
- }, { default: () => [clearIcon.value] }),
164
+ },
165
+ "onClick": (e) => onClearMouseDown.value?.(e)
166
+ }, [clearIcon.value]),
163
167
  slots.default?.()
164
168
  ]);
165
169
  };
@@ -208,6 +212,11 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
208
212
  required: false,
209
213
  default: void 0
210
214
  },
215
+ clearLabel: {
216
+ type: String,
217
+ required: false,
218
+ default: void 0
219
+ },
211
220
  removeIcon: {
212
221
  type: [
213
222
  Object,
@@ -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.0",
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/trigger": "^1.1.0",
38
+ "@v-c/virtual-list": "^1.1.0",
39
+ "@v-c/util": "^1.1.0",
40
+ "@v-c/overflow": "^1.1.1"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "vite build",