@onereach/ui-components 3.0.1 → 3.0.2-beta.2473.0
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/dist/bundled/v2/components/or-tree-v3/OrTree.vue.d.ts +47 -0
- package/dist/bundled/v2/components/or-tree-v3/TreeNode.vue.d.ts +69 -0
- package/dist/bundled/v2/components/or-tree-v3/index.d.ts +2 -0
- package/dist/bundled/v2/components/or-tree-v3/index.js +236 -0
- package/dist/bundled/v2/components/or-tree-v3/styles.d.ts +1 -0
- package/dist/bundled/v2/components/or-tree-v3/types.d.ts +10 -0
- package/dist/bundled/v2/components/or-tree-v3/utils.d.ts +5 -0
- package/dist/bundled/v2/index.js +1 -1
- package/dist/bundled/v3/components/or-tree-v3/OrTree.vue.d.ts +47 -0
- package/dist/bundled/v3/components/or-tree-v3/TreeNode.vue.d.ts +69 -0
- package/dist/bundled/v3/components/or-tree-v3/index.d.ts +2 -0
- package/dist/bundled/v3/components/or-tree-v3/index.js +176 -0
- package/dist/bundled/v3/components/or-tree-v3/styles.d.ts +1 -0
- package/dist/bundled/v3/components/or-tree-v3/types.d.ts +10 -0
- package/dist/bundled/v3/components/or-tree-v3/utils.d.ts +5 -0
- package/dist/bundled/v3/index.js +1 -1
- package/dist/esm/v2/components/or-tree-v3/OrTree.vue.d.ts +47 -0
- package/dist/esm/v2/components/or-tree-v3/TreeNode.vue.d.ts +69 -0
- package/dist/esm/v2/components/or-tree-v3/index.d.ts +2 -0
- package/dist/esm/v2/components/or-tree-v3/index.js +232 -0
- package/dist/esm/v2/components/or-tree-v3/styles.d.ts +1 -0
- package/dist/esm/v2/components/or-tree-v3/types.d.ts +10 -0
- package/dist/esm/v2/components/or-tree-v3/utils.d.ts +5 -0
- package/dist/esm/v3/components/or-tree-v3/OrTree.vue.d.ts +47 -0
- package/dist/esm/v3/components/or-tree-v3/TreeNode.vue.d.ts +69 -0
- package/dist/esm/v3/components/or-tree-v3/index.d.ts +2 -0
- package/dist/esm/v3/components/or-tree-v3/index.js +174 -0
- package/dist/esm/v3/components/or-tree-v3/styles.d.ts +1 -0
- package/dist/esm/v3/components/or-tree-v3/types.d.ts +10 -0
- package/dist/esm/v3/components/or-tree-v3/utils.d.ts +5 -0
- package/package.json +3 -4
- package/src/components/or-tree-v3/OrTree.stories3.ts +104 -0
- package/src/components/or-tree-v3/OrTree.vue +80 -0
- package/src/components/or-tree-v3/TreeNode.vue +67 -0
- package/src/components/or-tree-v3/index.ts +2 -0
- package/src/components/or-tree-v3/styles.ts +13 -0
- package/src/components/or-tree-v3/types.ts +12 -0
- package/src/components/or-tree-v3/utils.ts +31 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { PropType } from 'vue-demi';
|
|
2
|
+
import { ITreeNode, ITreeNodeMetadata } from './types';
|
|
3
|
+
declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<import("@vue/composition-api").Data> & {
|
|
4
|
+
flatTree: ITreeNode[];
|
|
5
|
+
nodeMetadataByKey: Record<string, ITreeNodeMetadata>;
|
|
6
|
+
}, {
|
|
7
|
+
onTriggerExpand(key: string): void;
|
|
8
|
+
isNodeExpanded(key: string): boolean;
|
|
9
|
+
}, {
|
|
10
|
+
visibleItems(): ITreeNode[];
|
|
11
|
+
}, {
|
|
12
|
+
initialData: {
|
|
13
|
+
type: PropType<ITreeNode[]>;
|
|
14
|
+
default: () => never[];
|
|
15
|
+
};
|
|
16
|
+
identifierKey: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
}, import("@vue/composition-api").ExtractPropTypes<{
|
|
21
|
+
initialData: {
|
|
22
|
+
type: PropType<ITreeNode[]>;
|
|
23
|
+
default: () => never[];
|
|
24
|
+
};
|
|
25
|
+
identifierKey: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
}>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
|
|
30
|
+
initialData: ITreeNode[];
|
|
31
|
+
identifierKey: string;
|
|
32
|
+
} & {}, import("@vue/composition-api").ShallowUnwrapRef<import("@vue/composition-api").Data>, {
|
|
33
|
+
flatTree: ITreeNode[];
|
|
34
|
+
nodeMetadataByKey: Record<string, ITreeNodeMetadata>;
|
|
35
|
+
}, {
|
|
36
|
+
visibleItems(): ITreeNode[];
|
|
37
|
+
}, {
|
|
38
|
+
onTriggerExpand(key: string): void;
|
|
39
|
+
isNodeExpanded(key: string): boolean;
|
|
40
|
+
}, {}, {}, {}, {
|
|
41
|
+
initialData: ITreeNode[];
|
|
42
|
+
identifierKey: string;
|
|
43
|
+
} & {}, {
|
|
44
|
+
initialData: ITreeNode[];
|
|
45
|
+
identifierKey: string;
|
|
46
|
+
}, true>);
|
|
47
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
2
|
+
rootClasses: string[];
|
|
3
|
+
}> & import("@vue/composition-api").Data, {}, {
|
|
4
|
+
expandIcon(): "keyboard_arrow_down" | "arrow_right";
|
|
5
|
+
styleCSS(): {
|
|
6
|
+
'padding-left': string;
|
|
7
|
+
};
|
|
8
|
+
}, {
|
|
9
|
+
nodeKey: {
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
default: string;
|
|
12
|
+
};
|
|
13
|
+
isExpanded: {
|
|
14
|
+
type: BooleanConstructor;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
|
+
isLeaf: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: boolean;
|
|
20
|
+
};
|
|
21
|
+
level: {
|
|
22
|
+
type: NumberConstructor;
|
|
23
|
+
default: number;
|
|
24
|
+
};
|
|
25
|
+
}, import("@vue/composition-api").ExtractPropTypes<{
|
|
26
|
+
nodeKey: {
|
|
27
|
+
type: StringConstructor;
|
|
28
|
+
default: string;
|
|
29
|
+
};
|
|
30
|
+
isExpanded: {
|
|
31
|
+
type: BooleanConstructor;
|
|
32
|
+
default: boolean;
|
|
33
|
+
};
|
|
34
|
+
isLeaf: {
|
|
35
|
+
type: BooleanConstructor;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
38
|
+
level: {
|
|
39
|
+
type: NumberConstructor;
|
|
40
|
+
default: number;
|
|
41
|
+
};
|
|
42
|
+
}>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
|
|
43
|
+
nodeKey: string;
|
|
44
|
+
isExpanded: boolean;
|
|
45
|
+
isLeaf: boolean;
|
|
46
|
+
level: number;
|
|
47
|
+
} & {} & {
|
|
48
|
+
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
49
|
+
}, import("@vue/composition-api").ShallowUnwrapRef<{
|
|
50
|
+
rootClasses: string[];
|
|
51
|
+
}>, import("@vue/composition-api").Data, {
|
|
52
|
+
expandIcon(): "keyboard_arrow_down" | "arrow_right";
|
|
53
|
+
styleCSS(): {
|
|
54
|
+
'padding-left': string;
|
|
55
|
+
};
|
|
56
|
+
}, {}, {}, {}, string[], {
|
|
57
|
+
nodeKey: string;
|
|
58
|
+
isExpanded: boolean;
|
|
59
|
+
isLeaf: boolean;
|
|
60
|
+
level: number;
|
|
61
|
+
} & {} & {
|
|
62
|
+
[x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
nodeKey: string;
|
|
65
|
+
isExpanded: boolean;
|
|
66
|
+
isLeaf: boolean;
|
|
67
|
+
level: number;
|
|
68
|
+
}, true>);
|
|
69
|
+
export default _default;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createBlock, createCommentVNode, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, Fragment, renderList, mergeProps, withCtx } from 'vue';
|
|
2
|
+
import '../../OrIconButton-b3e4997b.js';
|
|
3
|
+
import { s as script$2 } from '../../OrIconButton.vue_vue_type_script_lang-de03b47c.js';
|
|
4
|
+
import '../../OrIcon-a670d8e9.js';
|
|
5
|
+
import '../../OrIcon.vue_vue_type_script_lang-859d76fb.js';
|
|
6
|
+
import '../../OrTooltip.vue_vue_type_script_lang-ce2158d0.js';
|
|
7
|
+
import '@vueuse/core';
|
|
8
|
+
import '../../OrPopover-f09c1ad2.js';
|
|
9
|
+
import '../../OrPopover.vue_vue_type_script_lang-1caf28d1.js';
|
|
10
|
+
import '../../floating-ui.dom.esm-83eba816.js';
|
|
11
|
+
import '../../OrBottomSheet.vue_vue_type_script_lang-e3ef075b.js';
|
|
12
|
+
import '../../OrOverlay.vue_vue_type_script_lang-c298c8cd.js';
|
|
13
|
+
import '../../OrTeleport.vue3.vue_vue_type_script_lang-4dc70cf1.js';
|
|
14
|
+
import '../../useElevation-e8a2ce89.js';
|
|
15
|
+
import '../../useResponsive-9d397e2a.js';
|
|
16
|
+
|
|
17
|
+
const getFlatTree = tree => {
|
|
18
|
+
const flatTree = [];
|
|
19
|
+
const nodeMetadataByKey = {};
|
|
20
|
+
const goDeeper = (treeNode, level, parentNodeKey) => {
|
|
21
|
+
flatTree.push(treeNode);
|
|
22
|
+
nodeMetadataByKey[treeNode.key] = {
|
|
23
|
+
level,
|
|
24
|
+
isExpanded: false,
|
|
25
|
+
parentNodeKey
|
|
26
|
+
};
|
|
27
|
+
if (treeNode.children) {
|
|
28
|
+
for (const child of treeNode.children) {
|
|
29
|
+
goDeeper(child, level + 1, treeNode.key);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
for (const node of tree) {
|
|
34
|
+
goDeeper(node, 0, '');
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
flatTree,
|
|
38
|
+
nodeMetadataByKey
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const TreeNodeRoot = ['flex', 'items-center', 'gap-sm', 'pt-6', 'my-sm',
|
|
43
|
+
// Theme
|
|
44
|
+
'text-on-background', 'dark:text-on-background-dark', 'hover:bg-primary-opacity-0-08', 'dark:hover:bg-primary-opacity-0-08-dark'];
|
|
45
|
+
|
|
46
|
+
var script$1 = defineComponent({
|
|
47
|
+
components: {
|
|
48
|
+
OrIconButton: script$2
|
|
49
|
+
},
|
|
50
|
+
props: {
|
|
51
|
+
nodeKey: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: ''
|
|
54
|
+
},
|
|
55
|
+
isExpanded: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false
|
|
58
|
+
},
|
|
59
|
+
isLeaf: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
63
|
+
level: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 0
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
emits: ['trigger-expand'],
|
|
69
|
+
setup() {
|
|
70
|
+
return {
|
|
71
|
+
rootClasses: TreeNodeRoot
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
computed: {
|
|
75
|
+
expandIcon() {
|
|
76
|
+
return this.isExpanded ? 'keyboard_arrow_down' : 'arrow_right';
|
|
77
|
+
},
|
|
78
|
+
styleCSS() {
|
|
79
|
+
return {
|
|
80
|
+
// 24px -- gap-sm + tooltip width
|
|
81
|
+
'padding-left': this.isLeaf && this.level === 0 ? '24px' : `${this.level * 10}px`
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
function render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
88
|
+
const _component_or_icon_button = resolveComponent("or-icon-button");
|
|
89
|
+
return openBlock(), createElementBlock("div", {
|
|
90
|
+
class: normalizeClass(["tree-node", _ctx.rootClasses]),
|
|
91
|
+
style: normalizeStyle(_ctx.styleCSS)
|
|
92
|
+
}, [!_ctx.isLeaf ? (openBlock(), createBlock(_component_or_icon_button, {
|
|
93
|
+
key: 0,
|
|
94
|
+
icon: _ctx.expandIcon,
|
|
95
|
+
onClick: _cache[0] || (_cache[0] = $event => _ctx.$emit('trigger-expand', _ctx.nodeKey))
|
|
96
|
+
}, null, 8 /* PROPS */, ["icon"])) : createCommentVNode("v-if", true), renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(_ctx.$props)), () => [createTextVNode(toDisplayString(_ctx.nodeKey), 1 /* TEXT */)])], 6 /* CLASS, STYLE */);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
script$1.render = render$1;
|
|
100
|
+
script$1.__file = "src/components/or-tree-v3/TreeNode.vue";
|
|
101
|
+
|
|
102
|
+
var script = defineComponent({
|
|
103
|
+
components: {
|
|
104
|
+
TreeNode: script$1
|
|
105
|
+
},
|
|
106
|
+
props: {
|
|
107
|
+
initialData: {
|
|
108
|
+
type: Array,
|
|
109
|
+
default: () => []
|
|
110
|
+
},
|
|
111
|
+
identifierKey: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: 'key'
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
data() {
|
|
117
|
+
return {
|
|
118
|
+
flatTree: [],
|
|
119
|
+
nodeMetadataByKey: {}
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
computed: {
|
|
123
|
+
visibleItems() {
|
|
124
|
+
return this.flatTree.filter(treeNode => {
|
|
125
|
+
return this.isNodeExpanded(treeNode.key);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
mounted() {
|
|
130
|
+
const {
|
|
131
|
+
nodeMetadataByKey,
|
|
132
|
+
flatTree
|
|
133
|
+
} = getFlatTree(this.initialData);
|
|
134
|
+
this.flatTree = flatTree;
|
|
135
|
+
this.nodeMetadataByKey = nodeMetadataByKey;
|
|
136
|
+
},
|
|
137
|
+
methods: {
|
|
138
|
+
onTriggerExpand(key) {
|
|
139
|
+
this.nodeMetadataByKey[key].isExpanded = !this.nodeMetadataByKey[key].isExpanded;
|
|
140
|
+
},
|
|
141
|
+
isNodeExpanded(key) {
|
|
142
|
+
const {
|
|
143
|
+
parentNodeKey,
|
|
144
|
+
level
|
|
145
|
+
} = this.nodeMetadataByKey[key];
|
|
146
|
+
const parentMetadata = this.nodeMetadataByKey[parentNodeKey];
|
|
147
|
+
if (level === 0) return true;
|
|
148
|
+
if (!parentMetadata.isExpanded) return false;
|
|
149
|
+
return this.isNodeExpanded(parentNodeKey);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
155
|
+
const _component_tree_node = resolveComponent("tree-node");
|
|
156
|
+
return openBlock(), createElementBlock("div", {
|
|
157
|
+
class: "or-tree",
|
|
158
|
+
onDrop: _cache[0] || (_cache[0] = (...args) => _ctx.onDrop && _ctx.onDrop(...args))
|
|
159
|
+
}, [(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.visibleItems, node => {
|
|
160
|
+
return openBlock(), createBlock(_component_tree_node, mergeProps(node, {
|
|
161
|
+
key: node[_ctx.identifierKey],
|
|
162
|
+
"node-key": node[_ctx.identifierKey],
|
|
163
|
+
"is-expanded": _ctx.nodeMetadataByKey[node.key].isExpanded,
|
|
164
|
+
level: _ctx.nodeMetadataByKey[node.key].level,
|
|
165
|
+
onTriggerExpand: _ctx.onTriggerExpand
|
|
166
|
+
}), {
|
|
167
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
168
|
+
_: 2 /* DYNAMIC */
|
|
169
|
+
}, 1040 /* FULL_PROPS, DYNAMIC_SLOTS */, ["node-key", "is-expanded", "level", "onTriggerExpand"]);
|
|
170
|
+
}), 128 /* KEYED_FRAGMENT */))], 32 /* HYDRATE_EVENTS */);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
script.render = render;
|
|
174
|
+
script.__file = "src/components/or-tree-v3/OrTree.vue";
|
|
175
|
+
|
|
176
|
+
export { script as OrTreeV3 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TreeNodeRoot: string[];
|