cosey 0.6.29 → 0.6.31

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