@v-c/select 1.2.6 → 1.2.8-rc.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.
@@ -12,7 +12,7 @@ import Polite from "./Polite.js";
12
12
  import { Fragment, computed, createVNode, defineComponent, isVNode, mergeDefaults, mergeProps, shallowRef, watch } from "vue";
13
13
  import { clsx, isNonNullable } from "@v-c/util";
14
14
  import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
15
- import omit from "@v-c/util/dist/omit";
15
+ import pickDefined from "@v-c/util/dist/pickDefined";
16
16
  import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
17
17
  //#region src/BaseSelect/index.tsx
18
18
  /**
@@ -266,9 +266,9 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
266
266
  function onPopupMouseEnter() {
267
267
  forceState.value = {};
268
268
  }
269
- useBaseSelectProvider(computed(() => {
269
+ const baseSelectContext = computed(() => {
270
270
  return {
271
- ...props,
271
+ ...pickDefined(props),
272
272
  notFoundContent: mergedNotFoundContent.value,
273
273
  open: mergedOpen.value,
274
274
  triggerOpen: mergedOpen.value,
@@ -277,7 +277,8 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
277
277
  lockOptions: lockOptions.value,
278
278
  rawOpen: rawOpen.value
279
279
  };
280
- }));
280
+ });
281
+ useBaseSelectProvider(baseSelectContext);
281
282
  const onClearMouseDown = () => {
282
283
  props?.onClear?.();
283
284
  containerRef.value?.focus?.();
@@ -323,7 +324,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
323
324
  [`${prefixCls}-customize-input`]: customizeInputElement,
324
325
  [`${prefixCls}-show-search`]: showSearch
325
326
  });
326
- let renderNode = createVNode(SelectInput, mergeProps(attrs, omit(props, omitKeys), {
327
+ let renderNode = createVNode(SelectInput, mergeProps(attrs, pickDefined(props, omitKeys), {
327
328
  "ref": containerRef,
328
329
  "prefixCls": prefixCls,
329
330
  "className": mergedClassName,
@@ -13,5 +13,5 @@ export interface RefOptionListProps {
13
13
  * Using virtual list of option display.
14
14
  * Will fallback to dom if use customize render.
15
15
  */
16
- declare const OptionList: import('vue').DefineComponent<{}, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
16
+ declare const OptionList: import('vue').DefineComponent<{}, () => import('vue/jsx-runtime').JSX.Element, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
17
17
  export default OptionList;
package/dist/Select.js CHANGED
@@ -12,7 +12,7 @@ import { convertChildrenToData } from "./utils/legacyUtil.js";
12
12
  import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, toRef, watch } from "vue";
13
13
  import { isNonNullable } from "@v-c/util";
14
14
  import useId from "@v-c/util/dist/hooks/useId";
15
- import omit from "@v-c/util/dist/omit";
15
+ import pickDefined from "@v-c/util/dist/pickDefined";
16
16
  import { filterEmpty } from "@v-c/util/dist/props-util";
17
17
  //#region src/Select.tsx
18
18
  var OMIT_DOM_PROPS = ["inputValue"];
@@ -634,12 +634,13 @@ var Select = /* @__PURE__ */ defineComponent({
634
634
  const setInternalValue = (val) => {
635
635
  internalValue.value = val;
636
636
  };
637
- const [mergedValues, getMixedOption] = useCache(computed(() => {
637
+ const rawLabeledValues = computed(() => {
638
638
  const newInternalValue = multiple.value && internalValue.value === null ? [] : internalValue.value;
639
639
  const values = convert2LabelValues(newInternalValue);
640
640
  if (props.mode === "combobox" && isComboNoValue(values[0]?.value)) return [];
641
641
  return values;
642
- }), valueOptions);
642
+ });
643
+ const [mergedValues, getMixedOption] = useCache(rawLabeledValues, valueOptions);
643
644
  const displayValues = computed(() => {
644
645
  if (!props.mode && mergedValues.value.length === 1) {
645
646
  const firstValue = mergedValues.value[0];
@@ -665,7 +666,7 @@ var Select = /* @__PURE__ */ defineComponent({
665
666
  [mergedFieldNames.value.label]: mergedLabel
666
667
  };
667
668
  });
668
- const filteredOptions = useFilterOptions(computed(() => {
669
+ const filledTagOptions = computed(() => {
669
670
  if (props.mode !== "tags") return mergedOptions.value;
670
671
  const cloneOptions = [...mergedOptions.value];
671
672
  const existOptions = (val) => valueOptions.value.has(val);
@@ -674,7 +675,8 @@ var Select = /* @__PURE__ */ defineComponent({
674
675
  if (!existOptions(val)) cloneOptions.push(createTagOption(val, item.label));
675
676
  });
676
677
  return cloneOptions;
677
- }), mergedFieldNames, mergedSearchValue, mergedFilterOption, normalizedOptionFilterProps);
678
+ });
679
+ const filteredOptions = useFilterOptions(filledTagOptions, mergedFieldNames, mergedSearchValue, mergedFilterOption, normalizedOptionFilterProps);
678
680
  const filledSearchOptions = computed(() => {
679
681
  const hasItemMatchingSearch = (item) => {
680
682
  if (normalizedOptionFilterProps.value.length) return normalizedOptionFilterProps.value.some((prop) => item?.[prop] === mergedSearchValue.value);
@@ -794,7 +796,7 @@ var Select = /* @__PURE__ */ defineComponent({
794
796
  triggerSelect(newRawValue, true);
795
797
  });
796
798
  };
797
- useSelectProvider(computed(() => {
799
+ const selectContext = computed(() => {
798
800
  const realVirtual = props.virtual !== false && props.popupMatchSelectWidth !== false;
799
801
  return {
800
802
  ...parsedOptions.value,
@@ -815,11 +817,13 @@ var Select = /* @__PURE__ */ defineComponent({
815
817
  classNames: props.classNames,
816
818
  styles: props.styles
817
819
  };
818
- }));
820
+ });
821
+ useSelectProvider(selectContext);
819
822
  let lastChildrenKey = "";
820
823
  return () => {
821
824
  if (!props.options || props.options.length === 0) {
822
- const newChildrenOptions = convertChildrenToData(filterEmpty(slots?.default?.() ?? []));
825
+ const children = filterEmpty(slots?.default?.() ?? []);
826
+ const newChildrenOptions = convertChildrenToData(children);
823
827
  const newKey = newChildrenOptions.map((o) => `${o.value}`).join(",");
824
828
  if (lastChildrenKey !== newKey) {
825
829
  lastChildrenKey = newKey;
@@ -827,7 +831,7 @@ var Select = /* @__PURE__ */ defineComponent({
827
831
  }
828
832
  }
829
833
  const restAttrs = { ...attrs };
830
- const restProps = omit(props, omitKeyList);
834
+ const restProps = pickDefined(props, omitKeyList);
831
835
  const { prefixCls, mode, classNames, styles, maxCount, placeholder, direction, popupMatchSelectWidth } = props;
832
836
  return createVNode(BaseSelect, mergeProps(restAttrs, restProps, {
833
837
  "placeholder": placeholder,
@@ -98,10 +98,13 @@ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
98
98
  "aria-controls": `${id}_list`,
99
99
  "aria-activedescendant": open ? activeDescendantId : void 0
100
100
  };
101
- if (isVNode(InputComponent)) return createVNode(InputComponent, {
102
- placeholder: props.placeholder || placeholder,
103
- ...sharedInputProps
104
- });
101
+ if (isVNode(InputComponent)) {
102
+ const mergedProps = {
103
+ placeholder: props.placeholder || placeholder,
104
+ ...sharedInputProps
105
+ };
106
+ return createVNode(InputComponent, mergedProps);
107
+ }
105
108
  return createVNode(InputComponent, sharedInputProps, null);
106
109
  };
107
110
  }, {
@@ -6,8 +6,9 @@ import SelectContent from "./Content/index.js";
6
6
  import { cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
7
7
  import { clsx, isVueRenderable } from "@v-c/util";
8
8
  import KeyCode, { KeyCodeStr } from "@v-c/util/dist/KeyCode";
9
- import omit from "@v-c/util/dist/omit";
9
+ import pickDefined from "@v-c/util/dist/pickDefined";
10
10
  import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
11
+ import omit from "@v-c/util/dist/omit";
11
12
  //#region src/SelectInput/index.tsx
12
13
  var DEFAULT_OMIT_PROPS = [
13
14
  "value",
@@ -106,10 +107,11 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
106
107
  const onClearKeydown = (event) => {
107
108
  if (event.key === KeyCodeStr.Enter || event.key === KeyCodeStr.Space) event.stopPropagation();
108
109
  };
109
- useSelectInputProvider(computed(() => ({
110
- ...props,
110
+ const contextValue = computed(() => ({
111
+ ...pickDefined(props),
111
112
  onInputKeyDown: onInternalInputKeyDown
112
- })));
113
+ }));
114
+ useSelectInputProvider(contextValue);
113
115
  return () => {
114
116
  const RootComponent = components.value?.root;
115
117
  const domProps = omit({
@@ -130,7 +132,7 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
130
132
  });
131
133
  return createVNode(RootComponent, mergeProps(mergedProps, { "ref": rootRef }), null);
132
134
  }
133
- return createVNode("div", mergeProps(omit(domProps, [
135
+ const divProps = omit(domProps, [
134
136
  "onFocus",
135
137
  "onBlur",
136
138
  "onFocusin",
@@ -138,7 +140,8 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
138
140
  "onKeydown",
139
141
  "onKeyup",
140
142
  "onMousedown"
141
- ]), {
143
+ ]);
144
+ return createVNode("div", mergeProps(divProps, {
142
145
  "ref": rootRef,
143
146
  "class": className.value,
144
147
  "style": style.value,
@@ -11,7 +11,7 @@ function useAllowClear(_prefixCls, displayValues, allowClear, clearIcon, disable
11
11
  const mergedAllowClear = !disabled?.value && allowClearConfig.value?.allowClear !== false && (displayValues.value.length || mergedSearchValue?.value) && !(mode?.value === "combobox" && mergedSearchValue?.value === "");
12
12
  return {
13
13
  allowClear: !!mergedAllowClear,
14
- clearIcon: mergedAllowClear ? isVueRenderable(allowClearConfig.value.clearIcon) ? allowClearConfig.value.clearIcon : isVueRenderable(clearIcon?.value) ? clearIcon.value : "×" : null,
14
+ clearIcon: mergedAllowClear ? isVueRenderable(allowClearConfig.value.clearIcon) ? allowClearConfig.value.clearIcon : isVueRenderable(clearIcon?.value) ? clearIcon?.value : "×" : null,
15
15
  label: mergedAllowClear ? allowClearConfig.value.label ?? "Clear" : ""
16
16
  };
17
17
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/select",
3
3
  "type": "module",
4
- "version": "1.2.6",
4
+ "version": "1.2.8-rc.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.1",
39
- "@v-c/virtual-list": "^1.1.1",
40
- "@v-c/util": "^1.2.0"
38
+ "@v-c/trigger": "^1.1.5",
39
+ "@v-c/virtual-list": "^1.1.2",
40
+ "@v-c/util": "^1.3.2-rc.0"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "vite build",