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