cnhis-design-vue 3.1.23-beta.2 → 3.1.23-beta.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.
- package/README.md +123 -123
- package/es/components/big-table/src/components/edit-form/useCommon.d.ts +4 -0
- package/es/components/bpmn-workflow/src/BpmnWorkflow.d.ts +0 -0
- package/es/components/bpmn-workflow/types/BpmnViewer.d.ts +1 -0
- package/es/components/bpmn-workflow/types/ModelingModule.d.ts +1 -0
- package/es/components/bpmn-workflow/types/MoveCanvasModule.d.ts +1 -0
- package/es/components/fabric-chart/src/utils/index.d.ts +6823 -0
- package/es/components/form-render/src/utils/schema2.js +1 -4
- package/es/components/iho-table/index.d.ts +100 -270
- package/es/components/iho-table/src/IhoTable.vue.d.ts +100 -270
- package/es/components/iho-table/src/hooks/tapHooks/index.d.ts +2 -2
- package/es/components/iho-table/src/plugins/index.js +1 -1
- package/es/components/iho-table/src/plugins/index2.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/index.d.ts +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/index.js +1 -1
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/inputRendererPlugin.d.ts +1 -0
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/{inputRendererPlugins.js → inputRendererPlugin.js} +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/index.js +1 -1
- package/es/components/index.css +1 -1
- package/es/components/search-cascader/index.d.ts +133 -0
- package/es/components/search-cascader/index.js +1 -0
- package/es/components/search-cascader/index2.js +10 -0
- package/es/components/search-cascader/src/SearchCascader.js +183 -0
- package/es/components/search-cascader/src/SearchCascader.vue.d.ts +135 -0
- package/es/components/search-cascader/src/components/SearchMenu.d.ts +36 -0
- package/es/components/search-cascader/src/components/SearchMenu.js +125 -0
- package/es/components/search-cascader/src/components/index.d.ts +1 -0
- package/es/components/search-cascader/src/components/index.js +1 -0
- package/es/components/search-cascader/src/constants/index.d.ts +3 -0
- package/es/components/search-cascader/src/constants/index.js +1 -0
- package/es/components/search-cascader/src/constants/index2.js +3 -0
- package/es/components/search-cascader/src/hooks/index.d.ts +1 -0
- package/es/components/search-cascader/src/hooks/index.js +1 -0
- package/es/components/search-cascader/src/hooks/useCssVariable.d.ts +3 -0
- package/es/components/search-cascader/src/hooks/useCssVariable.js +1 -0
- package/es/components/search-cascader/src/hooks/useCssVariable2.js +7 -0
- package/es/components/search-cascader/src/utils/index.d.ts +2 -0
- package/es/components/search-cascader/src/utils/index.js +1 -0
- package/es/components/search-cascader/src/utils/index2.js +11 -0
- package/es/components/search-cascader/style/index.css +1 -0
- package/es/shared/utils/index.d.ts +1 -1
- package/es/shared/utils/index2.js +14 -5
- package/es/shared/utils/tapable/index.d.ts +139 -0
- package/package.json +2 -2
- package/es/components/iho-table/src/plugins/rendererPlugins/editableWidgets/inputRendererPlugins.d.ts +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, provide, nextTick, openBlock, createBlock, unref, normalizeStyle, withCtx, createVNode, isRef, createElementVNode, renderSlot } from 'vue';
|
|
2
|
+
import { uuidGenerator } from '../../../shared/utils/index2.js';
|
|
3
|
+
import { onClickOutside, useDebounceFn } from '@vueuse/core';
|
|
4
|
+
import { isString, isArray, isFunction } from 'lodash-es';
|
|
5
|
+
import { NPopover, NInput } from 'naive-ui';
|
|
6
|
+
import { InjectionSearchCascaderLoadingNode } from './constants/index2.js';
|
|
7
|
+
import { useCssVariable } from './hooks/useCssVariable2.js';
|
|
8
|
+
import { getParentNodeList } from './utils/index2.js';
|
|
9
|
+
import { SearchMenu } from './components/SearchMenu.js';
|
|
10
|
+
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.js';
|
|
11
|
+
|
|
12
|
+
const _hoisted_1 = ["id"];
|
|
13
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
14
|
+
__name: "SearchCascader",
|
|
15
|
+
props: {
|
|
16
|
+
value: { type: [String, Array] },
|
|
17
|
+
clearable: { type: Boolean, default: false },
|
|
18
|
+
childKey: { type: String, default: "children" },
|
|
19
|
+
placeholder: { type: String, default: "\u8BF7\u9009\u62E9" },
|
|
20
|
+
fetchOptions: { type: Function },
|
|
21
|
+
beforeSetValue: { type: Function }
|
|
22
|
+
},
|
|
23
|
+
emits: ["update:value"],
|
|
24
|
+
setup(__props, { expose, emit: emits }) {
|
|
25
|
+
const props = __props;
|
|
26
|
+
function onClear() {
|
|
27
|
+
emits("update:value", []);
|
|
28
|
+
}
|
|
29
|
+
const cssVariable = useCssVariable();
|
|
30
|
+
const optionsRef = ref([{}]);
|
|
31
|
+
const uuid = uuidGenerator();
|
|
32
|
+
const show = ref(false);
|
|
33
|
+
const patternContent = ref("");
|
|
34
|
+
const displayValue = computed({
|
|
35
|
+
get() {
|
|
36
|
+
if (show.value)
|
|
37
|
+
return patternContent.value;
|
|
38
|
+
if (isString(props.value))
|
|
39
|
+
return props.value;
|
|
40
|
+
if (isArray(props.value))
|
|
41
|
+
return arrayOptionsToString(props.value);
|
|
42
|
+
return "";
|
|
43
|
+
function arrayOptionsToString(optionList) {
|
|
44
|
+
return optionList.reduce((res, item, idx) => {
|
|
45
|
+
if (idx === 0)
|
|
46
|
+
return item.label;
|
|
47
|
+
return res + " / " + item.label;
|
|
48
|
+
}, "");
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
set(value) {
|
|
52
|
+
patternContent.value = value;
|
|
53
|
+
search(void 0, value);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
function openMenu() {
|
|
57
|
+
if (show.value)
|
|
58
|
+
return;
|
|
59
|
+
optionsRef.value = [];
|
|
60
|
+
show.value = true;
|
|
61
|
+
patternContent.value = "";
|
|
62
|
+
search();
|
|
63
|
+
}
|
|
64
|
+
async function closeMenu() {
|
|
65
|
+
var _a;
|
|
66
|
+
show.value = false;
|
|
67
|
+
(_a = inputRef.value) == null ? void 0 : _a.blur();
|
|
68
|
+
}
|
|
69
|
+
const inputRef = ref();
|
|
70
|
+
onClickOutside(inputRef, (evt) => {
|
|
71
|
+
var _a;
|
|
72
|
+
if (!show.value)
|
|
73
|
+
return;
|
|
74
|
+
if (!evt.target)
|
|
75
|
+
return closeMenu();
|
|
76
|
+
if (isInPopper(evt.target)) {
|
|
77
|
+
(_a = inputRef.value) == null ? void 0 : _a.focus();
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
closeMenu();
|
|
81
|
+
function isInPopper(targetEle) {
|
|
82
|
+
let result = false;
|
|
83
|
+
let current = targetEle;
|
|
84
|
+
while (current) {
|
|
85
|
+
if (current.id === uuid) {
|
|
86
|
+
result = true;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
current = current.parentElement;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const popoverRef = ref();
|
|
95
|
+
const currentNode = ref();
|
|
96
|
+
const loadingNode = ref(null);
|
|
97
|
+
provide(InjectionSearchCascaderLoadingNode, loadingNode);
|
|
98
|
+
const search = useDebounceFn(async (node, keyword) => {
|
|
99
|
+
var _a;
|
|
100
|
+
if (!isFunction(props.fetchOptions)) {
|
|
101
|
+
emits("update:value", node ? [node] : []);
|
|
102
|
+
return closeMenu();
|
|
103
|
+
}
|
|
104
|
+
loadingNode.value = node;
|
|
105
|
+
try {
|
|
106
|
+
const options = await props.fetchOptions(node, keyword);
|
|
107
|
+
if (!isValidOption(options)) {
|
|
108
|
+
if (!node)
|
|
109
|
+
return;
|
|
110
|
+
node.isLeaf = true;
|
|
111
|
+
emits("update:value", getParentNodeList(node));
|
|
112
|
+
return closeMenu();
|
|
113
|
+
}
|
|
114
|
+
if (node) {
|
|
115
|
+
node[props.childKey] = options.map((option) => enrichOption(option, node));
|
|
116
|
+
} else {
|
|
117
|
+
optionsRef.value = options;
|
|
118
|
+
}
|
|
119
|
+
currentNode.value = node;
|
|
120
|
+
} finally {
|
|
121
|
+
loadingNode.value = null;
|
|
122
|
+
await nextTick();
|
|
123
|
+
(_a = popoverRef.value) == null ? void 0 : _a.syncPosition();
|
|
124
|
+
}
|
|
125
|
+
function enrichOption(option, parent) {
|
|
126
|
+
return { ...option, parent };
|
|
127
|
+
}
|
|
128
|
+
function isValidOption(options) {
|
|
129
|
+
return isArray(options) && !!options.length;
|
|
130
|
+
}
|
|
131
|
+
}, 400);
|
|
132
|
+
expose({
|
|
133
|
+
setOptions(options) {
|
|
134
|
+
optionsRef.value = options;
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return (_ctx, _cache) => {
|
|
138
|
+
return openBlock(), createBlock(unref(NPopover), {
|
|
139
|
+
class: "search-cascader",
|
|
140
|
+
trigger: "manual",
|
|
141
|
+
show: show.value,
|
|
142
|
+
"onUpdate:show": _cache[1] || (_cache[1] = ($event) => show.value = $event),
|
|
143
|
+
"show-arrow": false,
|
|
144
|
+
placement: "bottom-start",
|
|
145
|
+
style: normalizeStyle(unref(cssVariable)),
|
|
146
|
+
width: optionsRef.value.length ? void 0 : "trigger",
|
|
147
|
+
ref_key: "popoverRef",
|
|
148
|
+
ref: popoverRef
|
|
149
|
+
}, {
|
|
150
|
+
trigger: withCtx(() => [
|
|
151
|
+
createVNode(unref(NInput), {
|
|
152
|
+
placeholder: __props.placeholder,
|
|
153
|
+
clearable: __props.clearable,
|
|
154
|
+
onClear,
|
|
155
|
+
value: unref(displayValue),
|
|
156
|
+
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => isRef(displayValue) ? displayValue.value = $event : null),
|
|
157
|
+
ref_key: "inputRef",
|
|
158
|
+
ref: inputRef,
|
|
159
|
+
onFocus: openMenu
|
|
160
|
+
}, null, 8, ["placeholder", "clearable", "value"])
|
|
161
|
+
]),
|
|
162
|
+
default: withCtx(() => [
|
|
163
|
+
createElementVNode("section", { id: unref(uuid) }, [
|
|
164
|
+
createVNode(unref(SearchMenu), {
|
|
165
|
+
options: optionsRef.value,
|
|
166
|
+
onNodeClick: unref(search),
|
|
167
|
+
"current-node": currentNode.value
|
|
168
|
+
}, {
|
|
169
|
+
empty: withCtx(() => [
|
|
170
|
+
renderSlot(_ctx.$slots, "empty")
|
|
171
|
+
]),
|
|
172
|
+
_: 3
|
|
173
|
+
}, 8, ["options", "onNodeClick", "current-node"])
|
|
174
|
+
], 8, _hoisted_1)
|
|
175
|
+
]),
|
|
176
|
+
_: 3
|
|
177
|
+
}, 8, ["show", "style", "width"]);
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
var script = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "SearchCascader.vue"]]);
|
|
182
|
+
|
|
183
|
+
export { script as default };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { AnyObject, Func, Nullable } from '../../../../es/shared/types';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
declare type ValueType = string | AnyObject[];
|
|
4
|
+
declare const _default: import("vue").DefineComponent<{
|
|
5
|
+
value: {
|
|
6
|
+
type: PropType<ValueType>;
|
|
7
|
+
};
|
|
8
|
+
clearable: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
default: boolean;
|
|
11
|
+
};
|
|
12
|
+
childKey: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
default: string;
|
|
15
|
+
};
|
|
16
|
+
placeholder: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
fetchOptions: {
|
|
21
|
+
type: PropType<Func<any[], any>>;
|
|
22
|
+
};
|
|
23
|
+
beforeSetValue: {
|
|
24
|
+
type: PropType<(value: ValueType) => void | ValueType | Promise<ValueType>>;
|
|
25
|
+
};
|
|
26
|
+
}, {
|
|
27
|
+
props: Readonly<import("@vue/shared").LooseRequired<Readonly<import("vue").ExtractPropTypes<{
|
|
28
|
+
value: {
|
|
29
|
+
type: PropType<ValueType>;
|
|
30
|
+
};
|
|
31
|
+
clearable: {
|
|
32
|
+
type: BooleanConstructor;
|
|
33
|
+
default: boolean;
|
|
34
|
+
};
|
|
35
|
+
childKey: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
placeholder: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
};
|
|
43
|
+
fetchOptions: {
|
|
44
|
+
type: PropType<Func<any[], any>>;
|
|
45
|
+
};
|
|
46
|
+
beforeSetValue: {
|
|
47
|
+
type: PropType<(value: ValueType) => void | ValueType | Promise<ValueType>>;
|
|
48
|
+
};
|
|
49
|
+
}>> & {
|
|
50
|
+
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
51
|
+
}>>;
|
|
52
|
+
emits: (event: "update:value", ...args: any[]) => void;
|
|
53
|
+
emitValue: (value: unknown) => void;
|
|
54
|
+
onClear: () => void;
|
|
55
|
+
cssVariable: {
|
|
56
|
+
'--menu-width': number;
|
|
57
|
+
};
|
|
58
|
+
optionsRef: import("vue").Ref<AnyObject[]>;
|
|
59
|
+
uuid: string;
|
|
60
|
+
show: import("vue").Ref<boolean>;
|
|
61
|
+
patternContent: import("vue").Ref<string>;
|
|
62
|
+
displayValue: import("vue").WritableComputedRef<string>;
|
|
63
|
+
openMenu: () => void;
|
|
64
|
+
closeMenu: () => Promise<void>;
|
|
65
|
+
inputRef: import("vue").Ref<any>;
|
|
66
|
+
popoverRef: import("vue").Ref<any>;
|
|
67
|
+
currentNode: import("vue").Ref<AnyObject | undefined>;
|
|
68
|
+
loadingNode: import("vue").Ref<Nullable<AnyObject>>;
|
|
69
|
+
search: (node?: AnyObject, keyword?: string) => Promise<void>;
|
|
70
|
+
NInput: any;
|
|
71
|
+
NPopover: any;
|
|
72
|
+
SearchMenu: import("vue").DefineComponent<{
|
|
73
|
+
childKey: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: string;
|
|
76
|
+
};
|
|
77
|
+
options: {
|
|
78
|
+
type: PropType<AnyObject[]>;
|
|
79
|
+
default: () => never[];
|
|
80
|
+
};
|
|
81
|
+
onNodeClick: {
|
|
82
|
+
type: PropType<Func<any[], any>>;
|
|
83
|
+
};
|
|
84
|
+
currentNode: {
|
|
85
|
+
type: PropType<AnyObject>;
|
|
86
|
+
};
|
|
87
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
88
|
+
childKey: {
|
|
89
|
+
type: StringConstructor;
|
|
90
|
+
default: string;
|
|
91
|
+
};
|
|
92
|
+
options: {
|
|
93
|
+
type: PropType<AnyObject[]>;
|
|
94
|
+
default: () => never[];
|
|
95
|
+
};
|
|
96
|
+
onNodeClick: {
|
|
97
|
+
type: PropType<Func<any[], any>>;
|
|
98
|
+
};
|
|
99
|
+
currentNode: {
|
|
100
|
+
type: PropType<AnyObject>;
|
|
101
|
+
};
|
|
102
|
+
}>>, {
|
|
103
|
+
options: AnyObject[];
|
|
104
|
+
childKey: string;
|
|
105
|
+
}>;
|
|
106
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:value"[], "update:value", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
107
|
+
value: {
|
|
108
|
+
type: PropType<ValueType>;
|
|
109
|
+
};
|
|
110
|
+
clearable: {
|
|
111
|
+
type: BooleanConstructor;
|
|
112
|
+
default: boolean;
|
|
113
|
+
};
|
|
114
|
+
childKey: {
|
|
115
|
+
type: StringConstructor;
|
|
116
|
+
default: string;
|
|
117
|
+
};
|
|
118
|
+
placeholder: {
|
|
119
|
+
type: StringConstructor;
|
|
120
|
+
default: string;
|
|
121
|
+
};
|
|
122
|
+
fetchOptions: {
|
|
123
|
+
type: PropType<Func<any[], any>>;
|
|
124
|
+
};
|
|
125
|
+
beforeSetValue: {
|
|
126
|
+
type: PropType<(value: ValueType) => void | ValueType | Promise<ValueType>>;
|
|
127
|
+
};
|
|
128
|
+
}>> & {
|
|
129
|
+
"onUpdate:value"?: ((...args: any[]) => any) | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
placeholder: string;
|
|
132
|
+
clearable: boolean;
|
|
133
|
+
childKey: string;
|
|
134
|
+
}>;
|
|
135
|
+
export default _default;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AnyObject, Func } from '../../../../../es/shared/types';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
export declare const SearchMenu: import("vue").DefineComponent<{
|
|
4
|
+
childKey: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
options: {
|
|
9
|
+
type: PropType<AnyObject[]>;
|
|
10
|
+
default: () => never[];
|
|
11
|
+
};
|
|
12
|
+
onNodeClick: {
|
|
13
|
+
type: PropType<Func<any[], any>>;
|
|
14
|
+
};
|
|
15
|
+
currentNode: {
|
|
16
|
+
type: PropType<AnyObject>;
|
|
17
|
+
};
|
|
18
|
+
}, () => JSX.Element, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
|
+
childKey: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
options: {
|
|
24
|
+
type: PropType<AnyObject[]>;
|
|
25
|
+
default: () => never[];
|
|
26
|
+
};
|
|
27
|
+
onNodeClick: {
|
|
28
|
+
type: PropType<Func<any[], any>>;
|
|
29
|
+
};
|
|
30
|
+
currentNode: {
|
|
31
|
+
type: PropType<AnyObject>;
|
|
32
|
+
};
|
|
33
|
+
}>>, {
|
|
34
|
+
options: AnyObject[];
|
|
35
|
+
childKey: string;
|
|
36
|
+
}>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { defineComponent, computed, inject, createVNode, ref, createTextVNode } from 'vue';
|
|
2
|
+
import { traverse } from '../../../../shared/utils/index2.js';
|
|
3
|
+
import { Reload, ChevronForward } from '@vicons/ionicons5';
|
|
4
|
+
import { useVirtualList } from '@vueuse/core';
|
|
5
|
+
import { isArray, isFunction } from 'lodash-es';
|
|
6
|
+
import { InjectionSearchCascaderLoadingNode } from '../constants/index2.js';
|
|
7
|
+
|
|
8
|
+
const SearchMenuList = defineComponent({
|
|
9
|
+
props: {
|
|
10
|
+
options: {
|
|
11
|
+
type: Array,
|
|
12
|
+
default: () => []
|
|
13
|
+
},
|
|
14
|
+
activeNodes: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => []
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
emits: ["nodeClick"],
|
|
20
|
+
setup(props, {
|
|
21
|
+
emit
|
|
22
|
+
}) {
|
|
23
|
+
const optionsRef = computed(() => props.options);
|
|
24
|
+
const {
|
|
25
|
+
list,
|
|
26
|
+
containerProps,
|
|
27
|
+
wrapperProps
|
|
28
|
+
} = useVirtualList(optionsRef, {
|
|
29
|
+
itemHeight: 32,
|
|
30
|
+
overscan: 5
|
|
31
|
+
});
|
|
32
|
+
const loadingNode = inject(InjectionSearchCascaderLoadingNode);
|
|
33
|
+
return () => {
|
|
34
|
+
return createVNode("div", {
|
|
35
|
+
"class": "search-cascader__optionWrapper",
|
|
36
|
+
"ref": containerProps.ref,
|
|
37
|
+
"style": containerProps.style,
|
|
38
|
+
"onScroll": containerProps.onScroll
|
|
39
|
+
}, [createVNode("div", {
|
|
40
|
+
"style": wrapperProps.value.style
|
|
41
|
+
}, [list.value.map((item) => {
|
|
42
|
+
var _a;
|
|
43
|
+
return createVNode("div", {
|
|
44
|
+
"class": ["search-cascader__option", {
|
|
45
|
+
"search-cascader__option--active": (_a = props.activeNodes) == null ? void 0 : _a.includes(item.data)
|
|
46
|
+
}],
|
|
47
|
+
"onClick": () => emit("nodeClick", item.data),
|
|
48
|
+
"title": item.data.label
|
|
49
|
+
}, [createVNode("div", {
|
|
50
|
+
"class": "search-cascader__optionText"
|
|
51
|
+
}, [item.data.label]), loadingNode.value === item.data ? createVNode(Reload, {
|
|
52
|
+
"class": "rotate"
|
|
53
|
+
}, null) : item.data.isLeaf ? null : createVNode(ChevronForward, null, null)]);
|
|
54
|
+
})])]);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const SearchMenu = defineComponent({
|
|
59
|
+
props: {
|
|
60
|
+
childKey: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: "children"
|
|
63
|
+
},
|
|
64
|
+
options: {
|
|
65
|
+
type: Array,
|
|
66
|
+
default: () => []
|
|
67
|
+
},
|
|
68
|
+
onNodeClick: {
|
|
69
|
+
type: Function
|
|
70
|
+
},
|
|
71
|
+
currentNode: {
|
|
72
|
+
type: Object
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
setup(props, {
|
|
76
|
+
slots
|
|
77
|
+
}) {
|
|
78
|
+
const activeNodes = ref([]);
|
|
79
|
+
function renderList(options) {
|
|
80
|
+
return createVNode(SearchMenuList, {
|
|
81
|
+
"activeNodes": activeNodes.value,
|
|
82
|
+
"onNodeClick": props.onNodeClick,
|
|
83
|
+
"options": options
|
|
84
|
+
}, null);
|
|
85
|
+
}
|
|
86
|
+
function renderEmpty() {
|
|
87
|
+
return createVNode("section", {
|
|
88
|
+
"class": "search-cascader__emptyWrapper"
|
|
89
|
+
}, [isFunction(slots.empty) ? slots.empty() : createVNode("section", null, [createTextVNode("empty")])]);
|
|
90
|
+
}
|
|
91
|
+
function isNodeExpand(node) {
|
|
92
|
+
let result = false;
|
|
93
|
+
traverse(node, (n, stop) => {
|
|
94
|
+
if (n !== props.currentNode)
|
|
95
|
+
return;
|
|
96
|
+
result = true;
|
|
97
|
+
stop();
|
|
98
|
+
}, ["children"]);
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
function getRenderNodeList() {
|
|
102
|
+
if (!isArray(props.options) || !props.currentNode)
|
|
103
|
+
return [];
|
|
104
|
+
const result = [props.options];
|
|
105
|
+
let _options = props.options;
|
|
106
|
+
activeNodes.value.length = 0;
|
|
107
|
+
while (isArray(_options)) {
|
|
108
|
+
const expandNode = _options.find(isNodeExpand);
|
|
109
|
+
if (!expandNode)
|
|
110
|
+
break;
|
|
111
|
+
activeNodes.value.push(expandNode);
|
|
112
|
+
_options = expandNode[props.childKey];
|
|
113
|
+
result.push(_options);
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
return () => {
|
|
118
|
+
return createVNode("section", {
|
|
119
|
+
"class": "search-cascader__menuWrapper"
|
|
120
|
+
}, [!isArray(props.options) || !props.options.length ? renderEmpty() : !props.currentNode ? renderList(props.options) : getRenderNodeList().map(renderList)]);
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export { SearchMenu };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SearchMenu';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SearchMenu } from './SearchMenu.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InjectionSearchCascaderLoadingNode } from './index2.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useCssVariable';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCssVariable } from './useCssVariable2.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useCssVariable } from './useCssVariable2.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getParentNodeList } from './index2.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.search-cascader__menuWrapper{display:flex;flex-wrap:nowrap;margin:-8px -14px}.search-cascader__option{align-items:center;border-radius:4px;box-sizing:border-box;display:flex;height:32px;justify-content:space-between;padding:0 8px 0 16px;width:100%}.search-cascader__option--active{background:#f8f8f8}.search-cascader__option:hover{background:#f5f5f5;cursor:pointer}.search-cascader__optionWrapper{background:#fff;height:256px;overflow-x:auto;width:calc(var(--menu-width)*1px)}.search-cascader__optionWrapper:not(:last-of-type){border:solid #e5e5e5;border-width:0 1px 0 0}.search-cascader__optionText{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:calc(100% - 20px)}.search-cascader__option svg{color:#bfbfbf;flex-shrink:0;font-size:12px;width:20px}.search-cascader__option svg.rotate{animation:rotate 1s linear infinite}.search-cascader__emptyWrapper{align-items:center;background:#fff;box-sizing:border-box;display:flex;height:200px;justify-content:center;padding:16px;width:100%}@keyframes rotate{0%{transform:rotate(0)}to{transform:rotate(1turn)}}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyObject, ArrayAble } from '../../../es/shared/types';
|
|
2
2
|
import { App, Component } from 'vue';
|
|
3
|
-
export declare function traverse<T extends ArrayAble<AnyObject>>(target: T, handler: (item: T extends Array<infer P> ? P : T) => void, keys?: ArrayAble<string>): void;
|
|
3
|
+
export declare function traverse<T extends ArrayAble<AnyObject>>(target: T, handler: (item: T extends Array<infer P> ? P : T, stop: () => void) => void, keys?: ArrayAble<string>): void;
|
|
4
4
|
export declare function safeComponentRegister(app: App, component: Component, cName?: string | undefined, scheduler?: () => void): void;
|
|
5
5
|
export declare function generateTimeFormat(format: string): string | undefined;
|
|
6
6
|
export declare function arrayed<T>(maybeArray: T): T extends Array<any> ? T : [T];
|
|
@@ -2,12 +2,21 @@ import { useMemoize } from '@vueuse/core';
|
|
|
2
2
|
import { isArray, isString } from 'lodash-es';
|
|
3
3
|
|
|
4
4
|
function traverse(target, handler, keys = "children") {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function stop() {
|
|
6
|
+
throw "silence break traverse";
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
arrayed(target).forEach((item) => {
|
|
10
|
+
handler(item, stop);
|
|
11
|
+
arrayed(keys).forEach((key) => {
|
|
12
|
+
isArray(item[key]) && traverse(item[key], handler);
|
|
13
|
+
});
|
|
9
14
|
});
|
|
10
|
-
})
|
|
15
|
+
} catch (err) {
|
|
16
|
+
if (err === "silence break traverse")
|
|
17
|
+
return;
|
|
18
|
+
throw err;
|
|
19
|
+
}
|
|
11
20
|
}
|
|
12
21
|
function safeComponentRegister(app, component, cName = component.name, scheduler) {
|
|
13
22
|
if (!cName)
|