@onereach/ui-components 3.0.2-beta.2473.0 → 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.
@@ -1,3 +1,5 @@
1
+ import { PropType } from 'vue-demi';
2
+ import { ITreeNode } from './types';
1
3
  declare const _default: import("vue").ComponentOptions<import("vue").default, import("@vue/composition-api").ShallowUnwrapRef<{
2
4
  rootClasses: string[];
3
5
  }> & import("@vue/composition-api").Data, {}, {
@@ -6,6 +8,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
6
8
  'padding-left': string;
7
9
  };
8
10
  }, {
11
+ node: {
12
+ type: PropType<ITreeNode>;
13
+ default: undefined;
14
+ };
9
15
  nodeKey: {
10
16
  type: StringConstructor;
11
17
  default: string;
@@ -23,6 +29,10 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
23
29
  default: number;
24
30
  };
25
31
  }, import("@vue/composition-api").ExtractPropTypes<{
32
+ node: {
33
+ type: PropType<ITreeNode>;
34
+ default: undefined;
35
+ };
26
36
  nodeKey: {
27
37
  type: StringConstructor;
28
38
  default: string;
@@ -40,6 +50,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
40
50
  default: number;
41
51
  };
42
52
  }>> & Omit<import("vue").VueConstructor<import("vue").default>, never> & (new (...args: any[]) => import("@vue/composition-api").ComponentRenderProxy<{
53
+ node: ITreeNode;
43
54
  nodeKey: string;
44
55
  isExpanded: boolean;
45
56
  isLeaf: boolean;
@@ -54,6 +65,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
54
65
  'padding-left': string;
55
66
  };
56
67
  }, {}, {}, {}, string[], {
68
+ node: ITreeNode;
57
69
  nodeKey: string;
58
70
  isExpanded: boolean;
59
71
  isLeaf: boolean;
@@ -61,6 +73,7 @@ declare const _default: import("vue").ComponentOptions<import("vue").default, im
61
73
  } & {} & {
62
74
  [x: `on${Capitalize<string>}`]: ((...args: any[]) => any) | undefined;
63
75
  }, {
76
+ node: ITreeNode;
64
77
  nodeKey: string;
65
78
  isExpanded: boolean;
66
79
  isLeaf: boolean;
@@ -1,6 +1,7 @@
1
- import { defineComponent, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createBlock, createCommentVNode, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, Fragment, renderList, mergeProps, withCtx } from 'vue';
1
+ export { s as OrTreeV3 } from '../../OrTree.vue_vue_type_script_lang-d25db1c4.js';
2
+ import 'vue';
2
3
  import '../../OrIconButton-b3e4997b.js';
3
- import { s as script$2 } from '../../OrIconButton.vue_vue_type_script_lang-de03b47c.js';
4
+ import '../../OrIconButton.vue_vue_type_script_lang-de03b47c.js';
4
5
  import '../../OrIcon-a670d8e9.js';
5
6
  import '../../OrIcon.vue_vue_type_script_lang-859d76fb.js';
6
7
  import '../../OrTooltip.vue_vue_type_script_lang-ce2158d0.js';
@@ -13,164 +14,3 @@ import '../../OrOverlay.vue_vue_type_script_lang-c298c8cd.js';
13
14
  import '../../OrTeleport.vue3.vue_vue_type_script_lang-4dc70cf1.js';
14
15
  import '../../useElevation-e8a2ce89.js';
15
16
  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 };