cosey 0.6.28 → 0.6.30

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.
@@ -1,24 +1,52 @@
1
- export interface HorizontalTreeProps<INode extends Record<PropertyKey, any> = any> {
2
- data?: INode[];
3
- props?: {
4
- children?: string;
5
- label?: string;
6
- disabled?: string | ((data: INode[], node: INode) => string);
7
- class?: string | ((data: INode[], node: INode) => string);
8
- };
9
- nodeKey?: string;
10
- mergeLast?: boolean;
11
- showCheckbox?: boolean;
12
- checkStrictly?: boolean;
13
- }
14
- export interface HorizontalTreeSlots<INode extends Record<PropertyKey, any> = any> {
15
- default?: (props: Record<string, never>) => any;
16
- node?: (node: INode) => any;
17
- }
18
- export interface HorizontalTreeEmits<INode extends Record<PropertyKey, any> = any> {
19
- (e: 'check-change', node: INode, checked: boolean): void;
1
+ import type { ExtractPropTypes, PropType, SlotsType, VNodeChild } from 'vue';
2
+ import { ExtraTreeNode } from '../../utils';
3
+ type INode = Record<PropertyKey, any>;
4
+ export declare const horizontalTreeProps: {
5
+ data: {
6
+ type: PropType<INode[]>;
7
+ };
8
+ props: {
9
+ type: PropType<{
10
+ children?: string;
11
+ label?: string;
12
+ disabled?: string | ((data: INode[], node: INode) => string);
13
+ class?: string | ((data: INode[], node: INode) => string);
14
+ }>;
15
+ };
16
+ nodeKey: {
17
+ type: StringConstructor;
18
+ };
19
+ nodeWidth: {
20
+ type: StringConstructor;
21
+ default: string;
22
+ };
23
+ mergeLast: {
24
+ type: BooleanConstructor;
25
+ default: boolean;
26
+ };
27
+ showCheckbox: {
28
+ type: BooleanConstructor;
29
+ };
30
+ checkStrictly: {
31
+ type: BooleanConstructor;
32
+ };
33
+ renderNode: {
34
+ type: PropType<(node: ExtraTreeNode<any>, defaultRender: () => VNodeChild) => VNodeChild>;
35
+ };
36
+ renderContent: {
37
+ type: PropType<(node: ExtraTreeNode<any>, defaultRender: () => VNodeChild) => VNodeChild>;
38
+ };
39
+ };
40
+ export type HorizontalTreeProps = ExtractPropTypes<typeof horizontalTreeProps>;
41
+ export interface HorizontalTreeSlots {
42
+ default: {};
20
43
  }
21
- export interface HorizontalTreeExpose<INode extends Record<PropertyKey, any> = any> {
44
+ export declare const horizontalTreeSlots: SlotsType<HorizontalTreeSlots>;
45
+ export declare const horizontalTreeEmits: {
46
+ 'check-change': (node: ExtraTreeNode<any>, checked: boolean) => boolean;
47
+ };
48
+ export type HorizontalTreeEmits = typeof horizontalTreeEmits;
49
+ export interface HorizontalTreeExpose {
22
50
  getCheckedNodes: () => INode[];
23
51
  setCheckedNodes: (nodes: INode[]) => void;
24
52
  getCheckedKeys: () => (string | number)[];
@@ -28,3 +56,4 @@ export interface HorizontalTreeExpose<INode extends Record<PropertyKey, any> = a
28
56
  getHalfCheckedKeys: () => (string | number)[];
29
57
  getNode: (key: string | number) => INode | undefined;
30
58
  }
59
+ export {};
@@ -1 +1,39 @@
1
+ import { isObject, isBoolean } from '../../utils/is.js';
1
2
 
3
+ const horizontalTreeProps = {
4
+ data: {
5
+ type: Array
6
+ },
7
+ props: {
8
+ type: Object
9
+ },
10
+ nodeKey: {
11
+ type: String
12
+ },
13
+ nodeWidth: {
14
+ type: String,
15
+ default: "120px"
16
+ },
17
+ mergeLast: {
18
+ type: Boolean,
19
+ default: true
20
+ },
21
+ showCheckbox: {
22
+ type: Boolean
23
+ },
24
+ checkStrictly: {
25
+ type: Boolean
26
+ },
27
+ renderNode: {
28
+ type: Function
29
+ },
30
+ renderContent: {
31
+ type: Function
32
+ }
33
+ };
34
+ const horizontalTreeSlots = Object;
35
+ const horizontalTreeEmits = {
36
+ "check-change": (node, checked) => isObject(node) && isBoolean(checked)
37
+ };
38
+
39
+ export { horizontalTreeEmits, horizontalTreeProps, horizontalTreeSlots };
@@ -0,0 +1,122 @@
1
+ import { ExtraTreeNode } from '../../utils';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
+ data: {
4
+ type: import("vue").PropType<{
5
+ [x: string]: any;
6
+ [x: number]: any;
7
+ [x: symbol]: any;
8
+ }[]>;
9
+ };
10
+ props: {
11
+ type: import("vue").PropType<{
12
+ children?: string;
13
+ label?: string;
14
+ disabled?: string | ((data: {
15
+ [x: string]: any;
16
+ [x: number]: any;
17
+ [x: symbol]: any;
18
+ }[], node: {
19
+ [x: string]: any;
20
+ [x: number]: any;
21
+ [x: symbol]: any;
22
+ }) => string);
23
+ class?: string | ((data: {
24
+ [x: string]: any;
25
+ [x: number]: any;
26
+ [x: symbol]: any;
27
+ }[], node: {
28
+ [x: string]: any;
29
+ [x: number]: any;
30
+ [x: symbol]: any;
31
+ }) => string);
32
+ }>;
33
+ };
34
+ nodeKey: {
35
+ type: StringConstructor;
36
+ };
37
+ nodeWidth: {
38
+ type: StringConstructor;
39
+ default: string;
40
+ };
41
+ mergeLast: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
45
+ showCheckbox: {
46
+ type: BooleanConstructor;
47
+ };
48
+ checkStrictly: {
49
+ type: BooleanConstructor;
50
+ };
51
+ renderNode: {
52
+ type: import("vue").PropType<(node: ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
53
+ };
54
+ renderContent: {
55
+ type: import("vue").PropType<(node: ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
56
+ };
57
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
58
+ 'check-change': (node: ExtraTreeNode<any>, checked: boolean) => boolean;
59
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
60
+ data: {
61
+ type: import("vue").PropType<{
62
+ [x: string]: any;
63
+ [x: number]: any;
64
+ [x: symbol]: any;
65
+ }[]>;
66
+ };
67
+ props: {
68
+ type: import("vue").PropType<{
69
+ children?: string;
70
+ label?: string;
71
+ disabled?: string | ((data: {
72
+ [x: string]: any;
73
+ [x: number]: any;
74
+ [x: symbol]: any;
75
+ }[], node: {
76
+ [x: string]: any;
77
+ [x: number]: any;
78
+ [x: symbol]: any;
79
+ }) => string);
80
+ class?: string | ((data: {
81
+ [x: string]: any;
82
+ [x: number]: any;
83
+ [x: symbol]: any;
84
+ }[], node: {
85
+ [x: string]: any;
86
+ [x: number]: any;
87
+ [x: symbol]: any;
88
+ }) => string);
89
+ }>;
90
+ };
91
+ nodeKey: {
92
+ type: StringConstructor;
93
+ };
94
+ nodeWidth: {
95
+ type: StringConstructor;
96
+ default: string;
97
+ };
98
+ mergeLast: {
99
+ type: BooleanConstructor;
100
+ default: boolean;
101
+ };
102
+ showCheckbox: {
103
+ type: BooleanConstructor;
104
+ };
105
+ checkStrictly: {
106
+ type: BooleanConstructor;
107
+ };
108
+ renderNode: {
109
+ type: import("vue").PropType<(node: ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
110
+ };
111
+ renderContent: {
112
+ type: import("vue").PropType<(node: ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
113
+ };
114
+ }>> & Readonly<{
115
+ "onCheck-change"?: ((node: any, checked: boolean) => any) | undefined;
116
+ }>, {
117
+ mergeLast: boolean;
118
+ checkStrictly: boolean;
119
+ showCheckbox: boolean;
120
+ nodeWidth: string;
121
+ }, import("vue").SlotsType<import("./horizontal-tree.api").HorizontalTreeSlots>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
122
+ export default _default;
@@ -0,0 +1,210 @@
1
+ import { defineComponent, computed, watch, createVNode, isVNode } from 'vue';
2
+ import { horizontalTreeEmits, horizontalTreeSlots, horizontalTreeProps } from './horizontal-tree.api.js';
3
+ import stdin_default$1 from './horizontal-tree.style.js';
4
+ import { ElCheckbox } from 'element-plus';
5
+ import { useTreeCheck } from '../../hooks/useTreeCheck.js';
6
+ import { mapTree, extraTreeToTable, walkTree } from '../../utils/tree.js';
7
+ import { useComponentConfig } from '../config-provider/config-provider.api.js';
8
+ import { useLocale } from '../../hooks/useLocale.js';
9
+ import { isString } from '../../utils/is.js';
10
+
11
+ function _isSlot(s) {
12
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
13
+ }
14
+ var stdin_default = defineComponent({
15
+ name: "CoHorizontalTree",
16
+ props: horizontalTreeProps,
17
+ slots: horizontalTreeSlots,
18
+ emits: horizontalTreeEmits,
19
+ setup(props, {
20
+ emit,
21
+ expose
22
+ }) {
23
+ const {
24
+ prefixCls
25
+ } = useComponentConfig("horizontal-tree", props);
26
+ const {
27
+ hashId
28
+ } = stdin_default$1(prefixCls);
29
+ const {
30
+ t
31
+ } = useLocale();
32
+ const propNames = computed(() => {
33
+ return Object.assign({
34
+ children: "children",
35
+ label: "label",
36
+ disabled: "disabled",
37
+ class: "class"
38
+ }, props.props);
39
+ });
40
+ const {
41
+ rootNode,
42
+ tree: checkableTree,
43
+ checkAllValue,
44
+ checkAllIndeterminate,
45
+ onCheckAllChange,
46
+ initialize,
47
+ setCheckedByNode
48
+ } = useTreeCheck({
49
+ mergeLast: props.mergeLast,
50
+ childrenKey: propNames.value.children,
51
+ checkStrictly: props.checkStrictly
52
+ });
53
+ const tree = computed(() => {
54
+ return mapTree(props.data || [], node => node);
55
+ });
56
+ watch(tree, () => {
57
+ initialize(tree.value);
58
+ }, {
59
+ immediate: true
60
+ });
61
+ const tableTree = computed(() => {
62
+ return extraTreeToTable(checkableTree.value, props.mergeLast);
63
+ });
64
+ const maxLevel = computed(() => Math.max(...tableTree.value.map(([item]) => item.reverseLevel)));
65
+ const getDisabled = node => {
66
+ return isString(propNames.value.disabled) ? node[propNames.value.disabled] : node[propNames.value.disabled(props.data, node)];
67
+ };
68
+ const getNodeClass = node => {
69
+ return isString(propNames.value.class) ? node[propNames.value.class] : node[propNames.value.class(props.data, node)];
70
+ };
71
+ const onCheckChange = (node, checked) => {
72
+ setCheckedByNode(node, checked);
73
+ emit("check-change", node.data, checked);
74
+ };
75
+ const getCheckedNodes = () => {
76
+ const nodes = [];
77
+ walkTree(checkableTree.value, "children", node => {
78
+ if (node.checkedStatus === "checked") {
79
+ nodes.push(node.data);
80
+ }
81
+ });
82
+ return nodes;
83
+ };
84
+ const setCheckedKeys = keys => {
85
+ const nodes = [];
86
+ walkTree(checkableTree.value, "children", node => {
87
+ const id = node.data[props.nodeKey];
88
+ if (keys.includes(id)) {
89
+ nodes.push(node);
90
+ }
91
+ });
92
+ setCheckedByNode(rootNode, false);
93
+ nodes.forEach(node => {
94
+ setCheckedByNode(node, true);
95
+ });
96
+ };
97
+ const getCheckedKeys = () => {
98
+ const keys = [];
99
+ walkTree(checkableTree.value, "children", node => {
100
+ if (node.checkedStatus === "checked") {
101
+ const key = node.data[props.nodeKey];
102
+ keys.push(key);
103
+ }
104
+ });
105
+ return keys;
106
+ };
107
+ const setCheckedNodes = nodes => {
108
+ const keys = nodes.map(node => node[props.nodeKey]);
109
+ setCheckedKeys(keys);
110
+ };
111
+ const setChecked = (key, checked) => {
112
+ walkTree(checkableTree.value, "children", node => {
113
+ if (node.data[props.nodeKey] === key) {
114
+ setCheckedByNode(node, checked);
115
+ return true;
116
+ }
117
+ });
118
+ };
119
+ const getHalfCheckedNodes = () => {
120
+ const nodes = [];
121
+ walkTree(checkableTree.value, "children", node => {
122
+ if (node.checkedStatus === "indeterminate") {
123
+ nodes.push(node.data);
124
+ }
125
+ });
126
+ return nodes;
127
+ };
128
+ const getHalfCheckedKeys = () => {
129
+ const nodes = getHalfCheckedNodes();
130
+ return nodes.map(node => node[props.nodeKey]);
131
+ };
132
+ const getNode = key => {
133
+ let _node;
134
+ walkTree(checkableTree.value, "children", node => {
135
+ if (node.data[props.nodeKey] === key) {
136
+ _node = node.data;
137
+ return true;
138
+ }
139
+ });
140
+ return _node;
141
+ };
142
+ expose({
143
+ getCheckedNodes,
144
+ setCheckedNodes,
145
+ setCheckedKeys,
146
+ getCheckedKeys,
147
+ setChecked,
148
+ getHalfCheckedNodes,
149
+ getHalfCheckedKeys,
150
+ getNode
151
+ });
152
+ function renderNode(node) {
153
+ let _slot;
154
+ function renderContent() {
155
+ return createVNode("span", {
156
+ "class": getNodeClass(node.data)
157
+ }, [node.data[propNames.value.label]]);
158
+ }
159
+ function renderMayCustomContent() {
160
+ return props.renderContent ? props.renderContent(node, renderContent) : renderContent();
161
+ }
162
+ return createVNode("div", {
163
+ "class": `${prefixCls.value}-node`
164
+ }, [props.showCheckbox ? createVNode(ElCheckbox, {
165
+ "disabled": getDisabled(node.data),
166
+ "modelValue": node.checkedStatus === "checked",
167
+ "indeterminate": node.checkedStatus === "indeterminate",
168
+ "onChange": value => onCheckChange(node, !!value)
169
+ }, _isSlot(_slot = renderMayCustomContent()) ? _slot : {
170
+ default: () => [_slot]
171
+ }) : renderMayCustomContent()]);
172
+ }
173
+ function renderMayCustomNode(node) {
174
+ return props.renderNode ? props.renderNode(node, () => renderNode(node)) : renderNode(node);
175
+ }
176
+ return () => {
177
+ let _slot2;
178
+ return createVNode("div", {
179
+ "class": [hashId.value, prefixCls.value],
180
+ "style": {
181
+ "--node-width": props.nodeWidth
182
+ }
183
+ }, [tableTree.value.length === 0 ? createVNode("div", {
184
+ "class": `${prefixCls.value}-empty`
185
+ }, [t("co.common.noData")]) : createVNode("table", null, [props.showCheckbox && !props.checkStrictly && createVNode("thead", null, [createVNode("tr", null, [createVNode("td", {
186
+ "colspan": maxLevel.value
187
+ }, [createVNode("div", {
188
+ "class": `${prefixCls.value}-node`
189
+ }, [createVNode(ElCheckbox, {
190
+ "modelValue": checkAllValue.value,
191
+ "indeterminate": checkAllIndeterminate.value,
192
+ "onChange": onCheckAllChange
193
+ }, _isSlot(_slot2 = t("co.common.checkAll")) ? _slot2 : {
194
+ default: () => [_slot2]
195
+ })])])])]), createVNode("tbody", null, [tableTree.value.map((row, i) => {
196
+ return createVNode("tr", {
197
+ "key": i
198
+ }, [row.map((node, j) => {
199
+ return createVNode("td", {
200
+ "key": j,
201
+ "colspan": node.reverseLevel === 1 ? maxLevel.value - node.level + 1 : 1,
202
+ "rowspan": node.leafCount
203
+ }, [node.reverseLevel !== 1 || !props.mergeLast ? renderMayCustomNode(node) : createVNode("div", null, [node.parent.children?.map(renderMayCustomNode)])]);
204
+ })]);
205
+ })])])]);
206
+ };
207
+ }
208
+ });
209
+
210
+ export { stdin_default as default };
@@ -27,7 +27,7 @@ var stdin_default = getSimpleStyleHook("CoHorizontalTree", (token) => {
27
27
  },
28
28
  [`${componentCls}-node`]: {
29
29
  display: "inline-flex",
30
- width: 120
30
+ width: "var(--node-width)"
31
31
  }
32
32
  }
33
33
  };
@@ -1,55 +1,206 @@
1
1
  export * from './horizontal-tree.api';
2
2
  declare const _HorizontalTree: {
3
- new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./horizontal-tree.api").HorizontalTreeProps<any>> & Readonly<{
3
+ new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
4
+ data: {
5
+ type: import("vue").PropType<{
6
+ [x: string]: any;
7
+ [x: number]: any;
8
+ [x: symbol]: any;
9
+ }[]>;
10
+ };
11
+ props: {
12
+ type: import("vue").PropType<{
13
+ children?: string;
14
+ label?: string;
15
+ disabled?: string | ((data: {
16
+ [x: string]: any;
17
+ [x: number]: any;
18
+ [x: symbol]: any;
19
+ }[], node: {
20
+ [x: string]: any;
21
+ [x: number]: any;
22
+ [x: symbol]: any;
23
+ }) => string);
24
+ class?: string | ((data: {
25
+ [x: string]: any;
26
+ [x: number]: any;
27
+ [x: symbol]: any;
28
+ }[], node: {
29
+ [x: string]: any;
30
+ [x: number]: any;
31
+ [x: symbol]: any;
32
+ }) => string);
33
+ }>;
34
+ };
35
+ nodeKey: {
36
+ type: StringConstructor;
37
+ };
38
+ nodeWidth: {
39
+ type: StringConstructor;
40
+ default: string;
41
+ };
42
+ mergeLast: {
43
+ type: BooleanConstructor;
44
+ default: boolean;
45
+ };
46
+ showCheckbox: {
47
+ type: BooleanConstructor;
48
+ };
49
+ checkStrictly: {
50
+ type: BooleanConstructor;
51
+ };
52
+ renderNode: {
53
+ type: import("vue").PropType<(node: import("../../utils").ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
54
+ };
55
+ renderContent: {
56
+ type: import("vue").PropType<(node: import("../../utils").ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
57
+ };
58
+ }>> & Readonly<{
4
59
  "onCheck-change"?: ((node: any, checked: boolean) => any) | undefined;
5
- }>, {
6
- getCheckedNodes: () => any[];
7
- setCheckedNodes: (nodes: any[]) => void;
8
- getCheckedKeys: () => (string | number)[];
9
- setCheckedKeys: (keys: (string | number)[]) => void;
10
- setChecked: (key: string | number, checked: boolean) => void;
11
- getHalfCheckedNodes: () => any[];
12
- getHalfCheckedKeys: () => (string | number)[];
13
- getNode: (key: string | number) => any;
14
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
15
- "check-change": (node: any, checked: boolean) => any;
16
- }, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
60
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
61
+ 'check-change': (node: import("../../utils").ExtraTreeNode<any>, checked: boolean) => boolean;
62
+ }, import("vue").PublicProps, {
63
+ mergeLast: boolean;
64
+ checkStrictly: boolean;
65
+ showCheckbox: boolean;
66
+ nodeWidth: string;
67
+ }, true, {}, import("vue").SlotsType<import("./horizontal-tree.api").HorizontalTreeSlots>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
17
68
  P: {};
18
69
  B: {};
19
70
  D: {};
20
71
  C: {};
21
72
  M: {};
22
73
  Defaults: {};
23
- }, Readonly<import("./horizontal-tree.api").HorizontalTreeProps<any>> & Readonly<{
74
+ }, Readonly<import("vue").ExtractPropTypes<{
75
+ data: {
76
+ type: import("vue").PropType<{
77
+ [x: string]: any;
78
+ [x: number]: any;
79
+ [x: symbol]: any;
80
+ }[]>;
81
+ };
82
+ props: {
83
+ type: import("vue").PropType<{
84
+ children?: string;
85
+ label?: string;
86
+ disabled?: string | ((data: {
87
+ [x: string]: any;
88
+ [x: number]: any;
89
+ [x: symbol]: any;
90
+ }[], node: {
91
+ [x: string]: any;
92
+ [x: number]: any;
93
+ [x: symbol]: any;
94
+ }) => string);
95
+ class?: string | ((data: {
96
+ [x: string]: any;
97
+ [x: number]: any;
98
+ [x: symbol]: any;
99
+ }[], node: {
100
+ [x: string]: any;
101
+ [x: number]: any;
102
+ [x: symbol]: any;
103
+ }) => string);
104
+ }>;
105
+ };
106
+ nodeKey: {
107
+ type: StringConstructor;
108
+ };
109
+ nodeWidth: {
110
+ type: StringConstructor;
111
+ default: string;
112
+ };
113
+ mergeLast: {
114
+ type: BooleanConstructor;
115
+ default: boolean;
116
+ };
117
+ showCheckbox: {
118
+ type: BooleanConstructor;
119
+ };
120
+ checkStrictly: {
121
+ type: BooleanConstructor;
122
+ };
123
+ renderNode: {
124
+ type: import("vue").PropType<(node: import("../../utils").ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
125
+ };
126
+ renderContent: {
127
+ type: import("vue").PropType<(node: import("../../utils").ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
128
+ };
129
+ }>> & Readonly<{
24
130
  "onCheck-change"?: ((node: any, checked: boolean) => any) | undefined;
25
- }>, {
26
- getCheckedNodes: () => any[];
27
- setCheckedNodes: (nodes: any[]) => void;
28
- getCheckedKeys: () => (string | number)[];
29
- setCheckedKeys: (keys: (string | number)[]) => void;
30
- setChecked: (key: string | number, checked: boolean) => void;
31
- getHalfCheckedNodes: () => any[];
32
- getHalfCheckedKeys: () => (string | number)[];
33
- getNode: (key: string | number) => any;
34
- }, {}, {}, {}, {}>;
131
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, {
132
+ mergeLast: boolean;
133
+ checkStrictly: boolean;
134
+ showCheckbox: boolean;
135
+ nodeWidth: string;
136
+ }>;
35
137
  __isFragment?: never;
36
138
  __isTeleport?: never;
37
139
  __isSuspense?: never;
38
- } & import("vue").ComponentOptionsBase<Readonly<import("./horizontal-tree.api").HorizontalTreeProps<any>> & Readonly<{
140
+ } & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
141
+ data: {
142
+ type: import("vue").PropType<{
143
+ [x: string]: any;
144
+ [x: number]: any;
145
+ [x: symbol]: any;
146
+ }[]>;
147
+ };
148
+ props: {
149
+ type: import("vue").PropType<{
150
+ children?: string;
151
+ label?: string;
152
+ disabled?: string | ((data: {
153
+ [x: string]: any;
154
+ [x: number]: any;
155
+ [x: symbol]: any;
156
+ }[], node: {
157
+ [x: string]: any;
158
+ [x: number]: any;
159
+ [x: symbol]: any;
160
+ }) => string);
161
+ class?: string | ((data: {
162
+ [x: string]: any;
163
+ [x: number]: any;
164
+ [x: symbol]: any;
165
+ }[], node: {
166
+ [x: string]: any;
167
+ [x: number]: any;
168
+ [x: symbol]: any;
169
+ }) => string);
170
+ }>;
171
+ };
172
+ nodeKey: {
173
+ type: StringConstructor;
174
+ };
175
+ nodeWidth: {
176
+ type: StringConstructor;
177
+ default: string;
178
+ };
179
+ mergeLast: {
180
+ type: BooleanConstructor;
181
+ default: boolean;
182
+ };
183
+ showCheckbox: {
184
+ type: BooleanConstructor;
185
+ };
186
+ checkStrictly: {
187
+ type: BooleanConstructor;
188
+ };
189
+ renderNode: {
190
+ type: import("vue").PropType<(node: import("../../utils").ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
191
+ };
192
+ renderContent: {
193
+ type: import("vue").PropType<(node: import("../../utils").ExtraTreeNode<any>, defaultRender: () => import("vue").VNodeChild) => import("vue").VNodeChild>;
194
+ };
195
+ }>> & Readonly<{
39
196
  "onCheck-change"?: ((node: any, checked: boolean) => any) | undefined;
40
- }>, {
41
- getCheckedNodes: () => any[];
42
- setCheckedNodes: (nodes: any[]) => void;
43
- getCheckedKeys: () => (string | number)[];
44
- setCheckedKeys: (keys: (string | number)[]) => void;
45
- setChecked: (key: string | number, checked: boolean) => void;
46
- getHalfCheckedNodes: () => any[];
47
- getHalfCheckedKeys: () => (string | number)[];
48
- getNode: (key: string | number) => any;
49
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
50
- "check-change": (node: any, checked: boolean) => any;
51
- }, string, {}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & (new () => {
52
- $slots: import("./horizontal-tree.api").HorizontalTreeSlots<any>;
53
- }) & import("vue").Plugin;
197
+ }>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
198
+ 'check-change': (node: import("../../utils").ExtraTreeNode<any>, checked: boolean) => boolean;
199
+ }, string, {
200
+ mergeLast: boolean;
201
+ checkStrictly: boolean;
202
+ showCheckbox: boolean;
203
+ nodeWidth: string;
204
+ }, {}, string, import("vue").SlotsType<import("./horizontal-tree.api").HorizontalTreeSlots>, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & import("vue").Plugin;
54
205
  export { _HorizontalTree as HorizontalTree };
55
206
  export default _HorizontalTree;
@@ -1,5 +1,6 @@
1
1
  import { withInstall } from '../utils.js';
2
- import stdin_default$1 from './horizontal-tree.vue.js';
2
+ import stdin_default$1 from './horizontal-tree.js';
3
+ export { horizontalTreeEmits, horizontalTreeProps, horizontalTreeSlots } from './horizontal-tree.api.js';
3
4
 
4
5
  const _HorizontalTree = withInstall(stdin_default$1);
5
6
  var stdin_default = _HorizontalTree;
@@ -78,6 +78,7 @@ export { defaultFormListProps, formListEmits, formListExposeKeys, formListProps,
78
78
  export { defaultMapSizeColNumber, formQueryContextSymbol, formQueryEmits, formQueryProps, formQuerySlots } from './form-query/form-query.api.js';
79
79
  export { highlightProps, highlightSlots } from './highlight/highlight.api.js';
80
80
  export { default as hljs } from 'highlight.js/lib/core';
81
+ export { horizontalTreeEmits, horizontalTreeProps, horizontalTreeSlots } from './horizontal-tree/horizontal-tree.api.js';
81
82
  export { addIconifyIcon, iconifyIconsSets } from './iconify-icon/iconify-icon.js';
82
83
  export { imageCardEmits, imageCardProps, imageCardSlots } from './image-card/image-card.api.js';
83
84
  export { defaultInputNumberRangeProps } from './input-number-range/input-number-range.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cosey",
3
- "version": "0.6.28",
3
+ "version": "0.6.30",
4
4
  "description": "基于 Vue3 + vite 的后台管理系统框架",
5
5
  "type": "module",
6
6
  "main": "index.js",
package/store/layout.js CHANGED
@@ -42,9 +42,6 @@ const useLayoutStore = defineStore(
42
42
  const menus = computed(() => {
43
43
  return getMenus([...getAllStaticRoutes(), ...userStore.dynamicRoutes]);
44
44
  });
45
- watch(menus, () => {
46
- console.log("watch menus", menus.value);
47
- });
48
45
  const menusMap = computed(() => getMenusMap(menus.value));
49
46
  const firstLevelMenus = menus;
50
47
  const firstLevelActive = ref("");
package/store/user.js CHANGED
@@ -74,8 +74,6 @@ const useUserStore = defineStore("cosey-user", () => {
74
74
  };
75
75
  const addDynamicRoutes = async () => {
76
76
  const filteredRoutes = filterRoutes(getAllDynamicRoutes());
77
- console.log("getAllDynamicRoutes", getAllDynamicRoutes());
78
- console.log("filteredRoutes", filteredRoutes);
79
77
  router.removeRoute(NOT_FOUND_ROUTE_NAME);
80
78
  filteredRoutes.forEach((route2) => {
81
79
  router.addRoute(route2);
@@ -1,24 +0,0 @@
1
- import { type HorizontalTreeProps, type HorizontalTreeSlots } from './horizontal-tree.api';
2
- type __VLS_Props = HorizontalTreeProps;
3
- type __VLS_Slots = HorizontalTreeSlots;
4
- declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {
5
- getCheckedNodes: () => any[];
6
- setCheckedNodes: (nodes: any[]) => void;
7
- getCheckedKeys: () => (string | number)[];
8
- setCheckedKeys: (keys: (string | number)[]) => void;
9
- setChecked: (key: string | number, checked: boolean) => void;
10
- getHalfCheckedNodes: () => any[];
11
- getHalfCheckedKeys: () => (string | number)[];
12
- getNode: (key: string | number) => any;
13
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
14
- "check-change": (node: any, checked: boolean) => any;
15
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
16
- "onCheck-change"?: ((node: any, checked: boolean) => any) | undefined;
17
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
- declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
19
- export default _default;
20
- type __VLS_WithSlots<T, S> = T & {
21
- new (): {
22
- $slots: S;
23
- };
24
- };
@@ -1,275 +0,0 @@
1
- import { defineComponent, computed, watch, resolveComponent, createElementBlock, openBlock, normalizeClass, unref, toDisplayString, createCommentVNode, createElementVNode, createVNode, withCtx, createTextVNode, Fragment, renderList, createBlock, renderSlot } from 'vue';
2
- import stdin_default$1 from './horizontal-tree.style.js';
3
- import { useTreeCheck } from '../../hooks/useTreeCheck.js';
4
- import { mapTree, extraTreeToTable, walkTree } from '../../utils/tree.js';
5
- import { useComponentConfig } from '../config-provider/config-provider.api.js';
6
- import { useLocale } from '../../hooks/useLocale.js';
7
- import { isString } from '../../utils/is.js';
8
-
9
- const _hoisted_1 = {
10
- key: 1
11
- };
12
- const _hoisted_2 = {
13
- key: 0
14
- };
15
- const _hoisted_3 = ["colspan"];
16
- const _hoisted_4 = ["colspan", "rowspan"];
17
- const _hoisted_5 = {
18
- key: 1
19
- };
20
- var stdin_default = /* @__PURE__ */defineComponent({
21
- ...{
22
- name: "CoHorizontalTree"
23
- },
24
- __name: "horizontal-tree",
25
- props: {
26
- data: {
27
- type: Array,
28
- required: false
29
- },
30
- props: {
31
- type: Object,
32
- required: false
33
- },
34
- nodeKey: {
35
- type: String,
36
- required: false
37
- },
38
- mergeLast: {
39
- type: Boolean,
40
- required: false
41
- },
42
- showCheckbox: {
43
- type: Boolean,
44
- required: false
45
- },
46
- checkStrictly: {
47
- type: Boolean,
48
- required: false
49
- }
50
- },
51
- emits: ["check-change"],
52
- setup(__props, {
53
- expose: __expose,
54
- emit: __emit
55
- }) {
56
- const props = __props;
57
- const emit = __emit;
58
- const {
59
- prefixCls
60
- } = useComponentConfig("horizontal-tree", props);
61
- const {
62
- hashId
63
- } = stdin_default$1(prefixCls);
64
- const {
65
- t
66
- } = useLocale();
67
- const propNames = computed(() => {
68
- return Object.assign({
69
- children: "children",
70
- label: "label",
71
- disabled: "disabled",
72
- class: "class"
73
- }, props.props);
74
- });
75
- const {
76
- rootNode,
77
- tree: checkableTree,
78
- checkAllValue,
79
- checkAllIndeterminate,
80
- onCheckAllChange,
81
- initialize,
82
- setCheckedByNode
83
- } = useTreeCheck({
84
- mergeLast: props.mergeLast,
85
- childrenKey: propNames.value.children,
86
- checkStrictly: props.checkStrictly
87
- });
88
- const tree = computed(() => {
89
- return mapTree(props.data || [], node => node);
90
- });
91
- watch(tree, () => {
92
- initialize(tree.value);
93
- }, {
94
- immediate: true
95
- });
96
- const tableTree = computed(() => {
97
- return extraTreeToTable(checkableTree.value, props.mergeLast);
98
- });
99
- const maxLevel = computed(() => Math.max(...tableTree.value.map(([item]) => item.reverseLevel)));
100
- const getDisabled = node => {
101
- return isString(propNames.value.disabled) ? node[propNames.value.disabled] : node[propNames.value.disabled(props.data, node)];
102
- };
103
- const getNodeClass = node => {
104
- return isString(propNames.value.class) ? node[propNames.value.class] : node[propNames.value.class(props.data, node)];
105
- };
106
- const onCheckChange = (node, checked) => {
107
- setCheckedByNode(node, checked);
108
- emit("check-change", node.data, checked);
109
- };
110
- const getCheckedNodes = () => {
111
- const nodes = [];
112
- walkTree(checkableTree.value, "children", node => {
113
- if (node.checkedStatus === "checked") {
114
- nodes.push(node.data);
115
- }
116
- });
117
- return nodes;
118
- };
119
- const setCheckedKeys = keys => {
120
- const nodes = [];
121
- walkTree(checkableTree.value, "children", node => {
122
- const id = node.data[props.nodeKey];
123
- if (keys.includes(id)) {
124
- nodes.push(node);
125
- }
126
- });
127
- setCheckedByNode(rootNode, false);
128
- nodes.forEach(node => {
129
- setCheckedByNode(node, true);
130
- });
131
- };
132
- const getCheckedKeys = () => {
133
- const keys = [];
134
- walkTree(checkableTree.value, "children", node => {
135
- if (node.checkedStatus === "checked") {
136
- const key = node.data[props.nodeKey];
137
- keys.push(key);
138
- }
139
- });
140
- return keys;
141
- };
142
- const setCheckedNodes = nodes => {
143
- const keys = nodes.map(node => node[props.nodeKey]);
144
- setCheckedKeys(keys);
145
- };
146
- const setChecked = (key, checked) => {
147
- walkTree(checkableTree.value, "children", node => {
148
- if (node.data[props.nodeKey] === key) {
149
- setCheckedByNode(node, checked);
150
- return true;
151
- }
152
- });
153
- };
154
- const getHalfCheckedNodes = () => {
155
- const nodes = [];
156
- walkTree(checkableTree.value, "children", node => {
157
- if (node.checkedStatus === "indeterminate") {
158
- nodes.push(node.data);
159
- }
160
- });
161
- return nodes;
162
- };
163
- const getHalfCheckedKeys = () => {
164
- const nodes = getHalfCheckedNodes();
165
- return nodes.map(node => node[props.nodeKey]);
166
- };
167
- const getNode = key => {
168
- let _node;
169
- walkTree(checkableTree.value, "children", node => {
170
- if (node.data[props.nodeKey] === key) {
171
- _node = node.data;
172
- return true;
173
- }
174
- });
175
- return _node;
176
- };
177
- __expose({
178
- getCheckedNodes,
179
- setCheckedNodes,
180
- setCheckedKeys,
181
- getCheckedKeys,
182
- setChecked,
183
- getHalfCheckedNodes,
184
- getHalfCheckedKeys,
185
- getNode
186
- });
187
- return (_ctx, _cache) => {
188
- const _component_el_checkbox = resolveComponent("el-checkbox");
189
- return openBlock(), createElementBlock("div", {
190
- class: normalizeClass([unref(hashId), unref(prefixCls)])
191
- }, [tableTree.value.length === 0 ? (openBlock(), createElementBlock("div", {
192
- key: 0,
193
- class: normalizeClass(`${unref(prefixCls)}-empty`)
194
- }, toDisplayString(unref(t)("co.common.noData")), 3
195
- /* TEXT, CLASS */)) : (openBlock(), createElementBlock("table", _hoisted_1, [_ctx.showCheckbox && !_ctx.checkStrictly ? (openBlock(), createElementBlock("thead", _hoisted_2, [createElementVNode("tr", null, [createElementVNode("td", {
196
- colspan: maxLevel.value
197
- }, [createElementVNode("div", {
198
- class: normalizeClass(`${unref(prefixCls)}-node`)
199
- }, [createVNode(_component_el_checkbox, {
200
- "model-value": unref(checkAllValue),
201
- indeterminate: unref(checkAllIndeterminate),
202
- onChange: unref(onCheckAllChange)
203
- }, {
204
- default: withCtx(() => [createTextVNode(toDisplayString(unref(t)("co.common.checkAll")), 1
205
- /* TEXT */)]),
206
- _: 1
207
- /* STABLE */
208
- }, 8, ["model-value", "indeterminate", "onChange"])], 2
209
- /* CLASS */)], 8, _hoisted_3)])])) : createCommentVNode("v-if", true), createElementVNode("tbody", null, [(openBlock(true), createElementBlock(Fragment, null, renderList(tableTree.value, (row, i) => {
210
- return openBlock(), createElementBlock("tr", {
211
- key: i
212
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(row, (node, j) => {
213
- return openBlock(), createElementBlock("td", {
214
- key: j,
215
- colspan: node.reverseLevel === 1 ? maxLevel.value - node.level + 1 : 1,
216
- rowspan: node.leafCount
217
- }, [node.reverseLevel !== 1 || !_ctx.mergeLast ? (openBlock(), createElementBlock("div", {
218
- key: 0,
219
- class: normalizeClass(`${unref(prefixCls)}-node`)
220
- }, [_ctx.showCheckbox ? (openBlock(), createBlock(_component_el_checkbox, {
221
- key: 0,
222
- disabled: getDisabled(node.data),
223
- "model-value": node.checkedStatus === "checked",
224
- indeterminate: node.checkedStatus === "indeterminate",
225
- onChange: value => onCheckChange(node, !!value)
226
- }, {
227
- default: withCtx(() => [createElementVNode("span", {
228
- class: normalizeClass(getNodeClass(node.data))
229
- }, [renderSlot(_ctx.$slots, "node", {}, () => [createTextVNode(toDisplayString(node.data[propNames.value.label]), 1
230
- /* TEXT */)])], 2
231
- /* CLASS */)]),
232
- _: 2
233
- /* DYNAMIC */
234
- }, 1032, ["disabled", "model-value", "indeterminate", "onChange"])) : (openBlock(), createElementBlock("span", {
235
- key: 1,
236
- class: normalizeClass(getNodeClass(node.data))
237
- }, [renderSlot(_ctx.$slots, "node", {}, () => [createTextVNode(toDisplayString(node.data[propNames.value.label]), 1
238
- /* TEXT */)])], 2
239
- /* CLASS */))], 2
240
- /* CLASS */)) : (openBlock(), createElementBlock("div", _hoisted_5, [(openBlock(true), createElementBlock(Fragment, null, renderList(node.parent.children, (_node, k) => {
241
- return openBlock(), createElementBlock("div", {
242
- key: k,
243
- class: normalizeClass(`${unref(prefixCls)}-node`)
244
- }, [_ctx.showCheckbox ? (openBlock(), createBlock(_component_el_checkbox, {
245
- key: 0,
246
- disabled: getDisabled(node.data),
247
- "model-value": _node.checkedStatus === "checked",
248
- indeterminate: _node.checkedStatus === "indeterminate",
249
- onChange: value => onCheckChange(_node, !!value)
250
- }, {
251
- default: withCtx(() => [renderSlot(_ctx.$slots, "node", {}, () => [createElementVNode("span", {
252
- class: normalizeClass(getNodeClass(_node.data))
253
- }, toDisplayString(_node.data[propNames.value.label]), 3
254
- /* TEXT, CLASS */)])]),
255
- _: 2
256
- /* DYNAMIC */
257
- }, 1032, ["disabled", "model-value", "indeterminate", "onChange"])) : renderSlot(_ctx.$slots, "node", {
258
- key: 1
259
- }, () => [createElementVNode("span", {
260
- class: normalizeClass(getNodeClass(_node.data))
261
- }, toDisplayString(_node.data[propNames.value.label]), 3
262
- /* TEXT, CLASS */)])], 2
263
- /* CLASS */);
264
- }), 128
265
- /* KEYED_FRAGMENT */))]))], 8, _hoisted_4);
266
- }), 128
267
- /* KEYED_FRAGMENT */))]);
268
- }), 128
269
- /* KEYED_FRAGMENT */))])]))], 2
270
- /* CLASS */);
271
- };
272
- }
273
- });
274
-
275
- export { stdin_default as default };