cnhis-design-vue 3.1.23-beta.12 → 3.1.23-beta.14

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.
@@ -18,13 +18,13 @@ function useCanvasEvent(canvas, propItems, emits) {
18
18
  width,
19
19
  height,
20
20
  stroke: "transparent",
21
- strokeWidth: 1,
22
21
  fill: "transparent",
23
22
  lockMovementX: true,
24
23
  lockMovementY: true,
25
24
  transparentCorners: false,
26
25
  hasControls: false,
27
- ...selectionStyle
26
+ ...selectionStyle,
27
+ strokeWidth: 0
28
28
  });
29
29
  canvas.value.add(rect);
30
30
  return rect;
@@ -77,12 +77,15 @@ function useCanvasEvent(canvas, propItems, emits) {
77
77
  if (button == 1) {
78
78
  const _key = obj.key.replace("All", "");
79
79
  const key = pointer.x <= originX ? _key + "Title" : _key;
80
+ obj.sendToBack();
80
81
  select(key);
81
82
  emits("select", key);
82
83
  }
83
84
  });
84
85
  } else {
85
86
  obj.on("mousedown", () => {
87
+ resetStrokeWidth();
88
+ setActiveObj(obj);
86
89
  emits("select", obj.key);
87
90
  });
88
91
  setTimeout(() => {
@@ -95,18 +98,19 @@ function useCanvasEvent(canvas, propItems, emits) {
95
98
  }
96
99
  function addSelectionListener() {
97
100
  canvas.value.on("selection:cleared", selectionCB);
98
- canvas.value.on("selection:updated", selectionCB);
99
101
  function selectionCB(event) {
100
102
  const { deselected = [] } = event;
101
103
  deselected.forEach((obj) => {
104
+ obj.set("strokeWidth", 0);
102
105
  obj.key.endsWith("All") && obj.sendToBack();
103
106
  });
104
107
  }
105
108
  }
106
109
  function select(key) {
107
110
  canvas.value.discardActiveObject().renderAll();
111
+ resetStrokeWidth();
108
112
  const obj = selections == null ? void 0 : selections.find((obj2) => obj2.key === key);
109
- obj == null ? void 0 : obj.bringToFront();
113
+ setActiveObj(obj);
110
114
  obj && canvas.value.setActiveObject(obj);
111
115
  }
112
116
  function init() {
@@ -115,6 +119,16 @@ function useCanvasEvent(canvas, propItems, emits) {
115
119
  selections = initSelection();
116
120
  addSelectionListener();
117
121
  }
122
+ function resetStrokeWidth() {
123
+ selections.forEach((obj) => {
124
+ obj.set("strokeWidth", 0);
125
+ obj.key.endsWith("All") && obj.sendToBack();
126
+ });
127
+ }
128
+ function setActiveObj(obj) {
129
+ var _a;
130
+ obj == null ? void 0 : obj.bringToFront().set("strokeWidth", (_a = selectionStyle.strokeWidth) != null ? _a : 2);
131
+ }
118
132
  init();
119
133
  return { select };
120
134
  }
@@ -1,5 +1,5 @@
1
1
  import { defineComponent, computed, ref, inject, watch, createVNode } from 'vue';
2
- import { isEqual, isString, isEmpty } from 'lodash-es';
2
+ import { isEqual, isString, isEmpty, isFunction, omit } from 'lodash-es';
3
3
  import '../../../index2.js';
4
4
  import { InjectAsyncQueue } from '../../constants/index2.js';
5
5
  import { useCommonInjection } from '../../hooks/useCommonInjection2.js';
@@ -46,6 +46,7 @@ const script = defineComponent({
46
46
  get: () => props.value,
47
47
  set: (v) => emit("update:value", v)
48
48
  });
49
+ const showRef = ref(false);
49
50
  const optionsRef = ref([]);
50
51
  const {
51
52
  field,
@@ -59,7 +60,7 @@ const script = defineComponent({
59
60
  var _a, _b;
60
61
  return (_b = (_a = props.wordbook) == null ? void 0 : _a.value_key) != null ? _b : "value";
61
62
  });
62
- computed(() => {
63
+ const depth = computed(() => {
63
64
  var _a;
64
65
  return ((_a = props.wordbook) == null ? void 0 : _a.level_num) || Infinity;
65
66
  });
@@ -71,24 +72,16 @@ const script = defineComponent({
71
72
  try {
72
73
  if (node && !node.__keyword && node.isLeaf) {
73
74
  valueRef.value = createOptionValue(node);
74
- return;
75
- }
76
- const result = await asyncQueue.addAsync(createParams(props.wordbook, props.autograph, field.value, node, fieldKey.value));
77
- if (!node) {
78
- optionsRef.value = result.map((option) => {
79
- option.__keyword = !!keyword;
80
- option.isLeaf = !!keyword;
81
- return option;
82
- });
83
- return;
75
+ showRef.value = false;
76
+ return Promise.reject();
84
77
  }
85
78
  if (node == null ? void 0 : node.__keyword) {
86
79
  if (!isString(node.id_link))
87
- return;
80
+ return Promise.reject();
88
81
  const linkList = parseLinkFromString2List(node.id_link);
89
82
  const primaryKeyOptions = await fetchPrimaryKeyValue(linkList);
90
83
  if (!primaryKeyOptions)
91
- return;
84
+ return Promise.reject();
92
85
  const {
93
86
  lastOption,
94
87
  options
@@ -98,14 +91,25 @@ const script = defineComponent({
98
91
  valueRef.value = sortOptionWithIdList(primaryKeyOptions, linkList);
99
92
  } else {
100
93
  optionsRef.value = options;
94
+ return lastOption;
101
95
  }
102
96
  } else {
103
- node.children = result.map((option) => {
104
- return {
105
- ...option,
106
- parent: node
107
- };
108
- });
97
+ const result = await asyncQueue.addAsync(createParams(props.wordbook, props.autograph, field.value, node, fieldKey.value));
98
+ if (!node) {
99
+ optionsRef.value = result.map((option) => {
100
+ option.__keyword = !!keyword;
101
+ option.isLeaf = !!keyword;
102
+ return option;
103
+ });
104
+ } else {
105
+ node.children = result.map((option) => {
106
+ return {
107
+ ...option,
108
+ parent: node,
109
+ isLeaf: getNodeDepth(node) + 1 >= depth.value
110
+ };
111
+ });
112
+ }
109
113
  }
110
114
  } catch (e) {
111
115
  isString(e) && formRenderLog(e);
@@ -119,9 +123,15 @@ const script = defineComponent({
119
123
  let lastOption = options[0];
120
124
  const resultOption = idList.reduce((res, id, index) => {
121
125
  const option = getTargetOption(options, id);
122
- if (index === 0)
126
+ if (index === 0) {
127
+ lastOption = option;
123
128
  return [option];
129
+ }
124
130
  lastOption = option;
131
+ Object.assign(option, {
132
+ parent: res[0],
133
+ isLeaf: index + 1 >= depth.value
134
+ });
125
135
  res[0].children = [option];
126
136
  return res;
127
137
  }, []);
@@ -133,21 +143,34 @@ const script = defineComponent({
133
143
  return options2.find((o) => o[valueKey.value] === value);
134
144
  }
135
145
  }
146
+ function getNodeDepth(node2) {
147
+ let result = 1;
148
+ let parent = node2.parent;
149
+ while (parent) {
150
+ result++;
151
+ parent = parent.parent;
152
+ }
153
+ return result;
154
+ }
136
155
  function parseLinkFromString2List(linkString) {
137
156
  return linkString.split("_").filter((s) => s);
138
157
  }
139
158
  function createParams(wordbook, autograph, field2, node2, key2) {
140
- const params = {
141
- autograph,
142
- wordbookId: wordbook.id,
143
- wordbookType: wordbook.type,
144
- fieldKeys: wordbook.search_key ? JSON.stringify(wordbook.search_key) : void 0,
145
- conObj: JSON.stringify(createConfigObject(wordbook), node2),
146
- primaryKey: wordbook.primary_key,
147
- levelKey: wordbook.level_key,
148
- keyword,
149
- page: 1
159
+ const paramsAdaptorMap = {
160
+ autograph: () => autograph,
161
+ wordbookId: "id",
162
+ wordbookType: "type",
163
+ fieldKeys: () => wordbook.search_key ? JSON.stringify(wordbook.search_key) : void 0,
164
+ conObj: () => JSON.stringify(createConfigObject(wordbook, node2)),
165
+ primaryKey: "primary_key",
166
+ levelKey: "level_key",
167
+ keyword: () => keyword,
168
+ page: () => 1
150
169
  };
170
+ const params = Object.entries(paramsAdaptorMap).reduce((res, [k, v]) => {
171
+ res[k] = isString(v) ? wordbook[v] : isFunction(v) ? v() : void 0;
172
+ return res;
173
+ }, {});
151
174
  return {
152
175
  ...getSearchRequestInfo(),
153
176
  params,
@@ -169,21 +192,21 @@ const script = defineComponent({
169
192
  if (!getSearchRequestInfo().primaryKeyUrl)
170
193
  return [];
171
194
  try {
172
- const params = createParams(props.wordbook, props.autograph, primaryKeys, fieldKey.value);
173
- return await asyncQueue.addAsync(params);
195
+ return await asyncQueue.addAsync(createParams(props.wordbook, props.autograph, primaryKeys, fieldKey.value));
174
196
  } catch (e) {
175
197
  isString(e) && formRenderLog(e);
176
198
  }
177
199
  function createParams(wordbook, autograph, primaryKeys2, key2) {
178
200
  const requestInfo = getSearchRequestInfo();
201
+ const params = {
202
+ autograph,
203
+ tableId: wordbook.id,
204
+ primaryKeyValue: primaryKeys2.join(","),
205
+ page: 1
206
+ };
179
207
  return {
180
208
  key: key2,
181
- params: {
182
- autograph,
183
- tableId: wordbook.id,
184
- primaryKeyValue: primaryKeys2.join(","),
185
- page: 1
186
- },
209
+ params,
187
210
  ...requestInfo,
188
211
  url: requestInfo.primaryKeyUrl
189
212
  };
@@ -193,8 +216,8 @@ const script = defineComponent({
193
216
  const result = [];
194
217
  let current = node;
195
218
  while (current) {
196
- result.unshift(node);
197
- current = node.parent;
219
+ result.unshift(omit(current, ["parent", "isLeaf", "__keyword", "children"]));
220
+ current = current.parent;
198
221
  }
199
222
  return result;
200
223
  }
@@ -219,6 +242,8 @@ const script = defineComponent({
219
242
  return () => createVNode(SearchCascader, {
220
243
  "value": valueRef.value,
221
244
  "onUpdate:value": ($event) => valueRef.value = $event,
245
+ "show": showRef.value,
246
+ "onUpdate:show": ($event) => showRef.value = $event,
222
247
  "options": optionsRef.value,
223
248
  "key": key.value,
224
249
  "labelKey": labelKey.value,
@@ -3,6 +3,10 @@ declare const SearchCascader: SFCWithInstall<import("vue").DefineComponent<{
3
3
  value: {
4
4
  type: import("vue").PropType<string | import("../../../es/shared/types").AnyObject[]>;
5
5
  };
6
+ show: {
7
+ type: BooleanConstructor;
8
+ default: boolean;
9
+ };
6
10
  clearable: {
7
11
  type: BooleanConstructor;
8
12
  default: boolean;
@@ -42,6 +46,10 @@ declare const SearchCascader: SFCWithInstall<import("vue").DefineComponent<{
42
46
  value: {
43
47
  type: import("vue").PropType<string | import("../../../es/shared/types").AnyObject[]>;
44
48
  };
49
+ show: {
50
+ type: BooleanConstructor;
51
+ default: boolean;
52
+ };
45
53
  clearable: {
46
54
  type: BooleanConstructor;
47
55
  default: boolean;
@@ -79,15 +87,16 @@ declare const SearchCascader: SFCWithInstall<import("vue").DefineComponent<{
79
87
  }>> & {
80
88
  onFocus?: ((...args: any[]) => any) | undefined;
81
89
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
90
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
82
91
  }>>;
83
- emits: (event: "update:value" | "focus", ...args: any[]) => void;
92
+ emits: (event: "update:value" | "update:show" | "focus", ...args: any[]) => void;
84
93
  emitValue: (value: string | import("../../../es/shared/types").AnyObject[]) => void;
85
94
  onClear: () => void;
86
95
  cssVariable: {
87
96
  '--menu-width': number;
88
97
  };
89
98
  uuid: string;
90
- show: import("vue").Ref<boolean>;
99
+ show: import("vue").WritableComputedRef<boolean>;
91
100
  patternContent: import("vue").Ref<string>;
92
101
  displayValue: import("vue").WritableComputedRef<string>;
93
102
  onFocus: (focusEvt: Event) => void;
@@ -143,10 +152,14 @@ declare const SearchCascader: SFCWithInstall<import("vue").DefineComponent<{
143
152
  childKey: string;
144
153
  labelKey: string;
145
154
  }>;
146
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "focus")[], "focus" | "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
155
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "update:show" | "focus")[], "focus" | "update:value" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
147
156
  value: {
148
157
  type: import("vue").PropType<string | import("../../../es/shared/types").AnyObject[]>;
149
158
  };
159
+ show: {
160
+ type: BooleanConstructor;
161
+ default: boolean;
162
+ };
150
163
  clearable: {
151
164
  type: BooleanConstructor;
152
165
  default: boolean;
@@ -184,7 +197,9 @@ declare const SearchCascader: SFCWithInstall<import("vue").DefineComponent<{
184
197
  }>> & {
185
198
  onFocus?: ((...args: any[]) => any) | undefined;
186
199
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
200
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
187
201
  }, {
202
+ show: boolean;
188
203
  options: import("../../../es/shared/types").AnyObject[];
189
204
  placeholder: string;
190
205
  valueKey: string;
@@ -1,7 +1,7 @@
1
- import { defineComponent, ref, computed, provide, nextTick, openBlock, createBlock, unref, normalizeStyle, withCtx, createVNode, isRef, createElementVNode, renderSlot } from 'vue';
1
+ import { defineComponent, computed, ref, provide, nextTick, openBlock, createBlock, unref, isRef, normalizeStyle, withCtx, createVNode, createElementVNode, renderSlot } from 'vue';
2
2
  import { uuidGenerator } from '../../../shared/utils/index2.js';
3
3
  import { onClickOutside, useDebounceFn } from '@vueuse/core';
4
- import { isString, isArray, isFunction } from 'lodash-es';
4
+ import { isString, isArray, isFunction, isObject } from 'lodash-es';
5
5
  import { NPopover, NInput } from 'naive-ui';
6
6
  import { InjectionSearchCascaderLoadingNode } from './constants/index2.js';
7
7
  import { useCssVariable } from './hooks/useCssVariable2.js';
@@ -13,6 +13,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
13
13
  __name: "SearchCascader",
14
14
  props: {
15
15
  value: { type: [String, Array] },
16
+ show: { type: Boolean, default: false },
16
17
  clearable: { type: Boolean, default: false },
17
18
  childKey: { type: String, default: "children" },
18
19
  placeholder: { type: String, default: "\u8BF7\u9009\u62E9" },
@@ -23,7 +24,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
23
24
  valueKey: { type: String, default: "value" },
24
25
  beforeSetValue: { type: Function }
25
26
  },
26
- emits: ["update:value", "focus"],
27
+ emits: ["update:value", "focus", "update:show"],
27
28
  setup(__props, { emit: emits }) {
28
29
  const props = __props;
29
30
  function emitValue(value) {
@@ -37,7 +38,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
37
38
  }
38
39
  const cssVariable = useCssVariable();
39
40
  const uuid = uuidGenerator();
40
- const show = ref(false);
41
+ const show = computed({
42
+ get() {
43
+ return props.show;
44
+ },
45
+ set(value) {
46
+ emits("update:show", value);
47
+ }
48
+ });
41
49
  const patternContent = ref("");
42
50
  const displayValue = computed({
43
51
  get() {
@@ -110,8 +118,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
110
118
  var _a;
111
119
  try {
112
120
  loadingNode.value = node;
113
- await (isFunction(props.search) && props.search(node, keyword));
114
- currentNode.value = node;
121
+ const result = await (isFunction(props.search) && props.search(node, keyword));
122
+ currentNode.value = isObject(result) ? result : node;
115
123
  } finally {
116
124
  loadingNode.value = null;
117
125
  await nextTick();
@@ -122,8 +130,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
122
130
  return openBlock(), createBlock(unref(NPopover), {
123
131
  class: "search-cascader",
124
132
  trigger: "manual",
125
- show: show.value,
126
- "onUpdate:show": _cache[1] || (_cache[1] = ($event) => show.value = $event),
133
+ show: unref(show),
134
+ "onUpdate:show": _cache[1] || (_cache[1] = ($event) => isRef(show) ? show.value = $event : null),
127
135
  "show-arrow": false,
128
136
  placement: "bottom-start",
129
137
  style: normalizeStyle(unref(cssVariable)),
@@ -133,7 +141,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
133
141
  }, {
134
142
  trigger: withCtx(() => [
135
143
  createVNode(unref(NInput), {
136
- placeholder: show.value ? __props.editPlaceholder : __props.placeholder,
144
+ placeholder: unref(show) ? __props.editPlaceholder : __props.placeholder,
137
145
  clearable: __props.clearable,
138
146
  onClear,
139
147
  value: unref(displayValue),
@@ -5,6 +5,10 @@ declare const _default: import("vue").DefineComponent<{
5
5
  value: {
6
6
  type: PropType<ValueType>;
7
7
  };
8
+ show: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
8
12
  clearable: {
9
13
  type: BooleanConstructor;
10
14
  default: boolean;
@@ -44,6 +48,10 @@ declare const _default: import("vue").DefineComponent<{
44
48
  value: {
45
49
  type: PropType<ValueType>;
46
50
  };
51
+ show: {
52
+ type: BooleanConstructor;
53
+ default: boolean;
54
+ };
47
55
  clearable: {
48
56
  type: BooleanConstructor;
49
57
  default: boolean;
@@ -81,15 +89,16 @@ declare const _default: import("vue").DefineComponent<{
81
89
  }>> & {
82
90
  onFocus?: ((...args: any[]) => any) | undefined;
83
91
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
92
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
84
93
  }>>;
85
- emits: (event: "update:value" | "focus", ...args: any[]) => void;
94
+ emits: (event: "update:value" | "update:show" | "focus", ...args: any[]) => void;
86
95
  emitValue: (value: ValueType) => void;
87
96
  onClear: () => void;
88
97
  cssVariable: {
89
98
  '--menu-width': number;
90
99
  };
91
100
  uuid: string;
92
- show: import("vue").Ref<boolean>;
101
+ show: import("vue").WritableComputedRef<boolean>;
93
102
  patternContent: import("vue").Ref<string>;
94
103
  displayValue: import("vue").WritableComputedRef<string>;
95
104
  onFocus: (focusEvt: Event) => void;
@@ -145,10 +154,14 @@ declare const _default: import("vue").DefineComponent<{
145
154
  childKey: string;
146
155
  labelKey: string;
147
156
  }>;
148
- }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "focus")[], "focus" | "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
157
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("update:value" | "update:show" | "focus")[], "focus" | "update:value" | "update:show", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
149
158
  value: {
150
159
  type: PropType<ValueType>;
151
160
  };
161
+ show: {
162
+ type: BooleanConstructor;
163
+ default: boolean;
164
+ };
152
165
  clearable: {
153
166
  type: BooleanConstructor;
154
167
  default: boolean;
@@ -186,7 +199,9 @@ declare const _default: import("vue").DefineComponent<{
186
199
  }>> & {
187
200
  onFocus?: ((...args: any[]) => any) | undefined;
188
201
  "onUpdate:value"?: ((...args: any[]) => any) | undefined;
202
+ "onUpdate:show"?: ((...args: any[]) => any) | undefined;
189
203
  }, {
204
+ show: boolean;
190
205
  options: AnyObject[];
191
206
  placeholder: string;
192
207
  valueKey: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
- "version": "3.1.23-beta.12",
3
+ "version": "3.1.23-beta.14",
4
4
  "license": "ISC",
5
5
  "module": "./es/components/index.js",
6
6
  "main": "./es/components/index.js",
@@ -66,5 +66,5 @@
66
66
  "iOS 7",
67
67
  "last 3 iOS versions"
68
68
  ],
69
- "gitHead": "f819538beb54e1a0cac4986b22568eadb3331662"
69
+ "gitHead": "112bf14c5aaabbb89b6c5d96e1d89bbbd4158e19"
70
70
  }