@v-c/cascader 1.0.0 → 1.0.2

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.
@@ -7,6 +7,7 @@ export interface RawOptionListProps {
7
7
  direction?: 'ltr' | 'rtl';
8
8
  open?: boolean;
9
9
  disabled?: boolean;
10
+ lockOptions?: boolean;
10
11
  }
11
12
  declare const RawOptionList: import('vue').DefineSetupFnComponent<RawOptionListProps, {}, {}, RawOptionListProps & {}, import('vue').PublicProps>;
12
13
  export default RawOptionList;
@@ -1,11 +1,10 @@
1
1
  import { useCascaderContext } from "../context.js";
2
2
  import { getFullPathKeys, isLeaf, scrollIntoParentView, toPathKey, toPathKeys, toPathValueStr } from "../utils/commonUtil.js";
3
3
  import { toPathOptions } from "../utils/treeUtil.js";
4
- import CacheContent_default from "./CacheContent.js";
5
4
  import Column_default, { FIX_LABEL } from "./Column.js";
6
5
  import useActive_default from "./useActive.js";
7
6
  import useKeyboard from "./useKeyboard.js";
8
- import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, ref, watch, watchEffect } from "vue";
7
+ import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, nextTick, onBeforeUpdate, ref, shallowRef, watch, watchEffect } from "vue";
9
8
  import { clsx } from "@v-c/util";
10
9
  var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
11
10
  const containerRef = ref(null);
@@ -57,10 +56,14 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
57
56
  context.value?.onSelect(valuePath);
58
57
  if (!props.multiple && (leaf || context.value?.changeOnSelect && (context.value?.expandTrigger === "hover" || fromKeyboard))) props.toggleOpen(false);
59
58
  };
60
- const mergedOptions = computed(() => {
59
+ const filteredOptions = computed(() => {
61
60
  if (props.searchValue) return context.value?.searchOptions || [];
62
61
  return context.value?.options || [];
63
62
  });
63
+ const mergedOptions = shallowRef(filteredOptions.value);
64
+ onBeforeUpdate(() => {
65
+ if (!!props.open && !props.lockOptions && mergedOptions.value !== filteredOptions.value) mergedOptions.value = filteredOptions.value;
66
+ });
64
67
  const optionColumns = computed(() => {
65
68
  const fieldNames = mergedFieldNames.value;
66
69
  if (!fieldNames) return [];
@@ -125,13 +128,13 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
125
128
  "activeValue": activeValue
126
129
  }), null);
127
130
  });
128
- return createVNode(CacheContent_default, { "open": props.open }, { default: () => [createVNode("div", {
131
+ return createVNode("div", {
129
132
  "class": clsx(`${mergedPrefixCls.value}-menus`, {
130
133
  [`${mergedPrefixCls.value}-menu-empty`]: isEmpty,
131
134
  [`${mergedPrefixCls.value}-rtl`]: rtl.value
132
135
  }),
133
136
  "ref": containerRef
134
- }, [columnNodes])] });
137
+ }, [columnNodes]);
135
138
  };
136
139
  }, {
137
140
  props: /* @__PURE__ */ mergeDefaults({
@@ -173,6 +176,11 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
173
176
  type: Boolean,
174
177
  required: false,
175
178
  default: void 0
179
+ },
180
+ lockOptions: {
181
+ type: Boolean,
182
+ required: false,
183
+ default: void 0
176
184
  }
177
185
  }, {
178
186
  prefixCls: "",
@@ -181,7 +189,8 @@ var List_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
181
189
  toggleOpen: () => {},
182
190
  open: false,
183
191
  direction: "ltr",
184
- disabled: false
192
+ disabled: false,
193
+ lockOptions: false
185
194
  }),
186
195
  name: "RawOptionList",
187
196
  inheritAttrs: false
@@ -8,9 +8,12 @@ var OptionList_default = /* @__PURE__ */ defineComponent((_, { expose }) => {
8
8
  onKeyDown: (event) => listRef.value?.onKeyDown(event),
9
9
  onKeyUp: (event) => listRef.value?.onKeyUp(event)
10
10
  });
11
- return () => createVNode(List_default, mergeProps(baseProps.value || {}, { "ref": (el) => {
12
- listRef.value = el;
13
- } }), null);
11
+ return () => createVNode(List_default, mergeProps(baseProps.value || {}, {
12
+ "lockOptions": baseProps.value?.lockOptions,
13
+ "ref": (el) => {
14
+ listRef.value = el;
15
+ }
16
+ }), null);
14
17
  }, {
15
18
  name: "OptionList",
16
19
  inheritAttrs: false
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/cascader",
3
3
  "type": "module",
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "description": "",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -10,7 +10,7 @@
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
12
  "import": "./dist/index.js",
13
- "require": "./dist/index.cjs"
13
+ "default": "./dist/index.js"
14
14
  },
15
15
  "./dist/*": "./dist/*",
16
16
  "./package.json": "./package.json"
@@ -24,9 +24,9 @@
24
24
  "vue": "^3.0.0"
25
25
  },
26
26
  "dependencies": {
27
- "@v-c/select": "^1.0.9",
28
- "@v-c/tree": "^1.0.0",
29
- "@v-c/util": "^1.0.9"
27
+ "@v-c/select": "^1.0.16",
28
+ "@v-c/tree": "^1.0.4",
29
+ "@v-c/util": "^1.0.17"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "vite build",