@v-c/select 1.2.8-rc.0 → 1.3.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/dist/BaseSelect/index.d.ts +2 -4
- package/dist/BaseSelect/index.js +6 -4
- package/dist/SelectInput/index.d.ts +1 -0
- package/dist/SelectInput/index.js +6 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/useAllowClear.d.ts +4 -5
- package/dist/hooks/useAllowClear.js +4 -7
- package/package.json +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AlignType, BuildInPlacements } from '@v-c/trigger';
|
|
2
|
+
import { AllowClearConfig } from '@v-c/util';
|
|
2
3
|
import { VueNode } from '@v-c/util/dist/type';
|
|
3
4
|
import { ScrollConfig, ScrollTo } from '@v-c/virtual-list';
|
|
4
5
|
import { CSSProperties, StyleValue } from 'vue';
|
|
@@ -93,10 +94,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps {
|
|
|
93
94
|
maxTagCount?: number | 'responsive';
|
|
94
95
|
maxTagPlaceholder?: VueNode | ((omittedValues: DisplayValueType[]) => any);
|
|
95
96
|
tokenSeparators?: string[] | ((input: string) => string[]);
|
|
96
|
-
allowClear?: boolean |
|
|
97
|
-
clearIcon?: VueNode;
|
|
98
|
-
label?: string;
|
|
99
|
-
};
|
|
97
|
+
allowClear?: boolean | AllowClearConfig;
|
|
100
98
|
prefix?: VueNode;
|
|
101
99
|
/** @deprecated Please use `suffix` instead. */
|
|
102
100
|
suffixIcon?: RenderNode;
|
package/dist/BaseSelect/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useBaseSelectProvider } from "../hooks/useBaseProps.js";
|
|
2
2
|
import { getSeparatedContent, isValidCount } from "../utils/valueUtil.js";
|
|
3
|
-
import { useAllowClear } from "../hooks/useAllowClear.js";
|
|
3
|
+
import { useAllowClear as useAllowClear$1 } from "../hooks/useAllowClear.js";
|
|
4
4
|
import useComponents from "../hooks/useComponents.js";
|
|
5
5
|
import useLock from "../hooks/useLock.js";
|
|
6
6
|
import useOpen, { macroTask } from "../hooks/useOpen.js";
|
|
@@ -232,7 +232,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
232
232
|
keyLockRef.value = false;
|
|
233
233
|
};
|
|
234
234
|
const getSelectElements = () => [getDOM(containerRef), triggerRef.value?.getPopupElement?.()];
|
|
235
|
-
useSelectTriggerControl(getSelectElements,
|
|
235
|
+
useSelectTriggerControl(getSelectElements, rawOpen, triggerOpen, computed(() => !!mergedComponents.value.root));
|
|
236
236
|
const internalMouseDownRef = shallowRef(false);
|
|
237
237
|
const onInternalFocus = (event) => {
|
|
238
238
|
focused.value = true;
|
|
@@ -242,7 +242,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
244
|
const onRootBlur = () => {
|
|
245
|
-
if (
|
|
245
|
+
if (rawOpen.value && !internalMouseDownRef.value) triggerOpen(false, { cancelFun: () => isInside(getSelectElements(), document.activeElement) });
|
|
246
246
|
};
|
|
247
247
|
const onInternalBlur = (event) => {
|
|
248
248
|
focused.value = false;
|
|
@@ -288,12 +288,13 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
288
288
|
});
|
|
289
289
|
onInternalSearch("", false, false);
|
|
290
290
|
};
|
|
291
|
-
const allowClearConfig = useAllowClear(computed(() => props.prefixCls), displayValues, computed(() => props.allowClear ?? false), computed(() => props.clearIcon), computed(() => disabled.value ?? false), mergedSearchValue, mode);
|
|
291
|
+
const allowClearConfig = useAllowClear$1(computed(() => props.prefixCls), displayValues, computed(() => props.allowClear ?? false), computed(() => props.clearIcon), computed(() => disabled.value ?? false), mergedSearchValue, mode);
|
|
292
292
|
return () => {
|
|
293
293
|
const { OptionList, prefixCls, className, loading, showSearch, prefix, placeholder, activeValue, animation, transitionName, popupStyle, popupClassName, direction, popupMatchSelectWidth, popupRender, popupAlign, placement, builtinPlacements, getPopupContainer, emptyOptions } = props;
|
|
294
294
|
const mergedAllowClear = allowClearConfig.value.allowClear;
|
|
295
295
|
const clearNode = allowClearConfig.value.clearIcon;
|
|
296
296
|
const clearLabel = allowClearConfig.value.label;
|
|
297
|
+
const clearTabIndex = allowClearConfig.value.tabIndex;
|
|
297
298
|
const customizeInputElement = mode.value === "combobox" && typeof getInputElement.value === "function" && getInputElement.value() || null;
|
|
298
299
|
let onTriggerVisibleChange = null;
|
|
299
300
|
if (mergedComponents.value?.root) onTriggerVisibleChange = (newOpen) => {
|
|
@@ -333,6 +334,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
333
334
|
"suffix": mergedSuffixIcon,
|
|
334
335
|
"clearIcon": clearNode,
|
|
335
336
|
"clearLabel": clearLabel,
|
|
337
|
+
"clearTabIndex": clearTabIndex,
|
|
336
338
|
"multiple": multiple.value,
|
|
337
339
|
"mode": mode.value,
|
|
338
340
|
"displayValues": displayValues.value,
|
|
@@ -163,6 +163,7 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
|
|
|
163
163
|
isVueRenderable(clearIcon.value) && createVNode("button", {
|
|
164
164
|
"type": "button",
|
|
165
165
|
"aria-label": clearLabel.value,
|
|
166
|
+
"tabindex": props.clearTabIndex,
|
|
166
167
|
"class": clsx(`${prefixCls.value}-clear`, classNamesConfig.value?.clear),
|
|
167
168
|
"style": stylesConfig.value?.clear,
|
|
168
169
|
"onMousedown": (e) => {
|
|
@@ -225,6 +226,11 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
|
|
|
225
226
|
required: false,
|
|
226
227
|
default: void 0
|
|
227
228
|
},
|
|
229
|
+
clearTabIndex: {
|
|
230
|
+
type: Number,
|
|
231
|
+
required: false,
|
|
232
|
+
default: void 0
|
|
233
|
+
},
|
|
228
234
|
removeIcon: {
|
|
229
235
|
type: [
|
|
230
236
|
Object,
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { useAllowClear } from './useAllowClear';
|
|
2
|
-
export type { AllowClearConfig } from './useAllowClear';
|
|
3
2
|
export { default as useBaseProps, useBaseSelectProvider } from './useBaseProps';
|
|
4
3
|
export type { BaseSelectContextProps } from './useBaseProps';
|
|
5
4
|
export { default as useCache } from './useCache';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { AllowClearConfig } from '@v-c/util';
|
|
1
2
|
import { Ref } from 'vue';
|
|
2
3
|
import { DisplayValueType, Mode } from '../interface.ts';
|
|
3
|
-
|
|
4
|
+
interface ClearInfo extends AllowClearConfig {
|
|
4
5
|
allowClear: boolean;
|
|
5
6
|
clearIcon: any;
|
|
6
7
|
label: string;
|
|
7
8
|
}
|
|
8
|
-
export declare function useAllowClear(_prefixCls: Ref<string>, displayValues: Ref<DisplayValueType[]>, allowClear?: Ref<boolean |
|
|
9
|
-
|
|
10
|
-
label?: string;
|
|
11
|
-
}>, clearIcon?: Ref<any>, disabled?: Ref<boolean>, mergedSearchValue?: Ref<string | undefined>, mode?: Ref<Mode | undefined>): import('vue').ComputedRef<AllowClearConfig>;
|
|
9
|
+
export declare function useAllowClear(_prefixCls: Ref<string>, displayValues: Ref<DisplayValueType[]>, allowClear?: Ref<boolean | AllowClearConfig | undefined>, clearIcon?: Ref<any>, disabled?: Ref<boolean>, mergedSearchValue?: Ref<string | undefined>, mode?: Ref<Mode | undefined>): import('vue').ComputedRef<ClearInfo>;
|
|
10
|
+
export {};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
|
-
import { isVueRenderable } from "@v-c/util";
|
|
2
|
+
import { isVueRenderable, useAllowClear as useAllowClear$1 } from "@v-c/util";
|
|
3
3
|
//#region src/hooks/useAllowClear.tsx
|
|
4
4
|
function useAllowClear(_prefixCls, displayValues, allowClear, clearIcon, disabled, mergedSearchValue, mode) {
|
|
5
|
-
const allowClearConfig =
|
|
6
|
-
if (typeof allowClear?.value === "boolean") return { allowClear: allowClear.value };
|
|
7
|
-
if (allowClear?.value && typeof allowClear.value === "object") return allowClear.value;
|
|
8
|
-
return { allowClear: false };
|
|
9
|
-
});
|
|
5
|
+
const allowClearConfig = useAllowClear$1(() => allowClear?.value);
|
|
10
6
|
return computed(() => {
|
|
11
|
-
const mergedAllowClear = !disabled?.value && allowClearConfig.value
|
|
7
|
+
const mergedAllowClear = !disabled?.value && !allowClearConfig.value.disabled && (displayValues.value.length || mergedSearchValue?.value) && !(mode?.value === "combobox" && mergedSearchValue?.value === "");
|
|
12
8
|
return {
|
|
9
|
+
...allowClearConfig.value,
|
|
13
10
|
allowClear: !!mergedAllowClear,
|
|
14
11
|
clearIcon: mergedAllowClear ? isVueRenderable(allowClearConfig.value.clearIcon) ? allowClearConfig.value.clearIcon : isVueRenderable(clearIcon?.value) ? clearIcon?.value : "×" : null,
|
|
15
12
|
label: mergedAllowClear ? allowClearConfig.value.label ?? "Clear" : ""
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/select",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@v-c/overflow": "^1.1.2",
|
|
38
|
-
"@v-c/trigger": "^1.1.
|
|
39
|
-
"@v-c/virtual-list": "^1.1.
|
|
40
|
-
"@v-c/util": "^1.
|
|
38
|
+
"@v-c/trigger": "^1.1.6",
|
|
39
|
+
"@v-c/virtual-list": "^1.1.4",
|
|
40
|
+
"@v-c/util": "^1.4.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "vite build",
|