@v-c/select 1.3.1 → 1.3.3

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.
@@ -10,7 +10,7 @@ import SelectInput from "../SelectInput/index.js";
10
10
  import SelectTrigger from "../SelectTrigger.js";
11
11
  import Polite from "./Polite.js";
12
12
  import { Fragment, computed, createVNode, defineComponent, isVNode, mergeDefaults, mergeProps, shallowRef, watch } from "vue";
13
- import { clsx, isNonNullable } from "@v-c/util";
13
+ import { clsx, isNonNullable, isVueRenderable } from "@v-c/util";
14
14
  import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
15
15
  import pickDefined from "@v-c/util/dist/pickDefined";
16
16
  import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
@@ -115,7 +115,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
115
115
  const mergedNotFoundContent = computed(() => {
116
116
  return props.notFoundContent ?? "Not Found";
117
117
  });
118
- const emptyListContent = computed(() => !props?.notFoundContent && props.emptyOptions);
118
+ const emptyListContent = computed(() => !isVueRenderable(props?.notFoundContent) && props.emptyOptions);
119
119
  const [rawOpen, mergedOpen, triggerOpen, lockOptions] = useOpen(props?.defaultOpen || false, open, (openVal) => {
120
120
  props.onPopupVisibleChange?.(openVal);
121
121
  }, (nextOpen) => {
@@ -1,10 +1,11 @@
1
1
  import useBaseProps from "./hooks/useBaseProps.js";
2
2
  import { useSelectContext } from "./SelectContext.js";
3
3
  import TransBtn from "./TransBtn.js";
4
+ import { getNextActiveIndex } from "./utils/keyUtil.js";
4
5
  import { isPlatformMac } from "./utils/platformUtil.js";
5
6
  import { isValidCount } from "./utils/valueUtil.js";
6
7
  import { Fragment, computed, createVNode, defineComponent, mergeProps, shallowRef, watch } from "vue";
7
- import { clsx } from "@v-c/util";
8
+ import { clsx, isVueRenderable } from "@v-c/util";
8
9
  import KeyCode from "@v-c/util/dist/KeyCode";
9
10
  import pickAttrs from "@v-c/util/dist/pickAttrs";
10
11
  import List from "@v-c/virtual-list";
@@ -133,7 +134,7 @@ var OptionList = /* @__PURE__ */ defineComponent({
133
134
  else if (which === KeyCode.P) offset = -1;
134
135
  }
135
136
  if (offset !== 0) {
136
- const nextActiveIndex = getEnabledActiveIndex(activeIndex.value + offset, offset);
137
+ const nextActiveIndex = getEnabledActiveIndex(getNextActiveIndex(activeIndex.value, offset), offset);
137
138
  scrollIntoView(nextActiveIndex);
138
139
  setActive(nextActiveIndex, true);
139
140
  }
@@ -293,8 +294,8 @@ var OptionList = /* @__PURE__ */ defineComponent({
293
294
  [`${optionPrefixCls}-selected`]: selected
294
295
  });
295
296
  const mergedLabel = getLabel(item);
296
- const iconVisible = !menuItemSelectedIcon || typeof menuItemSelectedIcon === "function" || selected;
297
- const content = typeof mergedLabel === "number" ? mergedLabel : mergedLabel || value;
297
+ const iconVisible = !isVueRenderable(menuItemSelectedIcon) || typeof menuItemSelectedIcon === "function" || selected;
298
+ const content = isVueRenderable(mergedLabel) ? mergedLabel : value;
298
299
  let optionTitle = isTitleType(content) ? content.toString() : void 0;
299
300
  if (title !== void 0) optionTitle = title;
300
301
  return createVNode("div", mergeProps(pickAttrs(passedProps), !virtual ? getItemAriaProps(item, itemIndex) : {}, {
@@ -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 ?? contextAutoComplete ?? "new-password",
83
+ "autocomplete": autoComplete ?? contextAutoComplete ?? "off",
84
84
  "class": inputCls,
85
85
  disabled,
86
86
  "value": value || "",
@@ -48,8 +48,8 @@ function useOpen(defaultOpen, propOpen, onOpen, postOpen) {
48
48
  const nextOpenVal = typeof nextOpen === "boolean" ? nextOpen : !mergedOpen.value;
49
49
  lock.value = !nextOpenVal;
50
50
  function triggerUpdate() {
51
- if (id === taskIdRef.value && !cancelFun?.()) {
52
- triggerEvent(nextOpenVal);
51
+ if (id === taskIdRef.value) {
52
+ if (!cancelFun?.()) triggerEvent(nextOpenVal);
53
53
  lock.value = false;
54
54
  }
55
55
  }
@@ -1,2 +1,3 @@
1
+ export declare function getNextActiveIndex(activeIndex: number, offset: number): number;
1
2
  /** keyCode Judgment function */
2
3
  export declare function isValidateOpenKey(currentKeyCode: number): boolean;
@@ -1,5 +1,8 @@
1
1
  import KeyCode from "@v-c/util/dist/KeyCode";
2
2
  //#region src/utils/keyUtil.ts
3
+ function getNextActiveIndex(activeIndex, offset) {
4
+ return activeIndex === -1 && offset < 0 ? -1 : activeIndex + offset;
5
+ }
3
6
  /** keyCode Judgment function */
4
7
  function isValidateOpenKey(currentKeyCode) {
5
8
  return !!currentKeyCode && ![
@@ -34,4 +37,4 @@ function isValidateOpenKey(currentKeyCode) {
34
37
  ].includes(currentKeyCode);
35
38
  }
36
39
  //#endregion
37
- export { isValidateOpenKey };
40
+ export { getNextActiveIndex, isValidateOpenKey };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/select",
3
3
  "type": "module",
4
- "version": "1.3.1",
4
+ "version": "1.3.3",
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/overflow": "^1.1.3",
38
37
  "@v-c/trigger": "^1.1.7",
39
38
  "@v-c/util": "^1.4.2",
40
- "@v-c/virtual-list": "^1.1.6"
39
+ "@v-c/virtual-list": "^1.1.8",
40
+ "@v-c/overflow": "^1.1.3"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "vite build",