@threadlabs/looma 0.1.20 → 0.1.22
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/{chunk-RLSUA6N5.js → chunk-NIPNHZ5W.js} +29 -29
- package/dist/cjs/ui-tree.cjs.entry.js +48 -15
- package/dist/collection/components/ui-tree/ui-tree.js +48 -15
- package/dist/components/ui-tree.js +1 -1
- package/dist/esm/ui-tree.entry.js +48 -15
- package/dist/index.cjs +44 -15
- package/dist/index.js +1 -1
- package/dist/looma/looma.esm.js +1 -1
- package/dist/looma/p-e3f99a24.entry.js +1 -0
- package/dist/types/components/ui-tree/ui-tree.d.ts +3 -0
- package/dist/{ui-affordance-scope.entry-TEYCR7NX.js → ui-affordance-scope.entry-L533MECG.js} +1 -1
- package/dist/{ui-avatar-group.entry-Z2JCVPMM.js → ui-avatar-group.entry-BWS7E2CM.js} +1 -1
- package/dist/{ui-avatar.entry-CDDUQV4B.js → ui-avatar.entry-3INAY3XP.js} +1 -1
- package/dist/{ui-badge.entry-ELFAXPKR.js → ui-badge.entry-2WOBVOYP.js} +1 -1
- package/dist/{ui-button.entry-S5GEJ55S.js → ui-button.entry-VCGSEONK.js} +1 -1
- package/dist/{ui-checkbox.entry-NFXU5LDX.js → ui-checkbox.entry-2PTBHSCQ.js} +1 -1
- package/dist/{ui-context-menu.entry-W5F6LBEC.js → ui-context-menu.entry-AYDDCIZS.js} +1 -1
- package/dist/{ui-dialog.entry-G2K37IUH.js → ui-dialog.entry-I2XI3ZTZ.js} +1 -1
- package/dist/{ui-disclosure.entry-JO3XAMCC.js → ui-disclosure.entry-5LY2BT7B.js} +1 -1
- package/dist/{ui-floating-action-button.entry-EXXENSSO.js → ui-floating-action-button.entry-EJAMR5AM.js} +1 -1
- package/dist/{ui-form-field.entry-L62S6Z62.js → ui-form-field.entry-SJ6NNFXB.js} +1 -1
- package/dist/{ui-icon-button.entry-D7I7BV27.js → ui-icon-button.entry-7SD2LVXE.js} +1 -1
- package/dist/{ui-input.entry-YDFDXMZE.js → ui-input.entry-7MM7GEQW.js} +1 -1
- package/dist/{ui-menu-item.entry-QH7UGDFX.js → ui-menu-item.entry-V3HIMR75.js} +1 -1
- package/dist/{ui-menu.entry-YIQOPJOS.js → ui-menu.entry-R4WK5QSX.js} +1 -1
- package/dist/{ui-popover.entry-XN2IOEYH.js → ui-popover.entry-ZRJRTXA7.js} +1 -1
- package/dist/{ui-radio-group.entry-C7ESTJSS.js → ui-radio-group.entry-S6RXHFSN.js} +1 -1
- package/dist/{ui-radio.entry-AKVI5OUS.js → ui-radio.entry-B73QZK2M.js} +1 -1
- package/dist/{ui-search-result-row.entry-3BY6GUCL.js → ui-search-result-row.entry-DR2Y5S7P.js} +1 -1
- package/dist/{ui-search-shell.entry-2Z3GUR2I.js → ui-search-shell.entry-ST5IKJBC.js} +1 -1
- package/dist/{ui-select.entry-2YQLACCA.js → ui-select.entry-7GPRFV67.js} +1 -1
- package/dist/{ui-switch.entry-N5HDUJIW.js → ui-switch.entry-XQ5IRJRH.js} +1 -1
- package/dist/{ui-tabs.entry-FVOVVZOQ.js → ui-tabs.entry-HPW5L5CY.js} +1 -1
- package/dist/{ui-textarea.entry-ZFGGCBLG.js → ui-textarea.entry-W2PSRYVS.js} +1 -1
- package/dist/{ui-toast-region.entry-AA2DEUUZ.js → ui-toast-region.entry-FJUHFXKZ.js} +1 -1
- package/dist/{ui-tooltip.entry-WN4PYNTZ.js → ui-tooltip.entry-G5WHQW7K.js} +1 -1
- package/dist/{ui-top-bar.entry-ZYYXC7OA.js → ui-top-bar.entry-3NCHFC4Y.js} +1 -1
- package/dist/{ui-tree-item.entry-HWCNTX6N.js → ui-tree-item.entry-45RR3CMP.js} +1 -1
- package/dist/{ui-tree.entry-6NPGKN5P.js → ui-tree.entry-SZW4Q5PY.js} +45 -16
- package/editor/{chunk-3QMBK3XZ.js → chunk-64GLF274.js} +12 -2
- package/editor/{chunk-OXFYYLUC.js → chunk-QCOYOVQL.js} +83 -15
- package/editor/extensions/index.d.ts +7 -2
- package/editor/extensions/index.js +5 -1
- package/editor/index.d.ts +1 -1
- package/editor/index.js +6 -2
- package/editor/ui.js +1 -1
- package/editor.css +49 -0
- package/package.json +1 -1
- package/dist/looma/p-979b8ab1.entry.js +0 -1
|
@@ -6,35 +6,35 @@ var __glob = (map) => (path) => {
|
|
|
6
6
|
|
|
7
7
|
// import("./**/*.entry.js") in dist/esm/index-CEeiinfk.js
|
|
8
8
|
var globImport_entry_js = __glob({
|
|
9
|
-
"./ui-affordance-scope.entry.js": () => import("./ui-affordance-scope.entry-
|
|
10
|
-
"./ui-avatar-group.entry.js": () => import("./ui-avatar-group.entry-
|
|
11
|
-
"./ui-avatar.entry.js": () => import("./ui-avatar.entry-
|
|
12
|
-
"./ui-badge.entry.js": () => import("./ui-badge.entry-
|
|
13
|
-
"./ui-button.entry.js": () => import("./ui-button.entry-
|
|
14
|
-
"./ui-checkbox.entry.js": () => import("./ui-checkbox.entry-
|
|
15
|
-
"./ui-context-menu.entry.js": () => import("./ui-context-menu.entry-
|
|
16
|
-
"./ui-dialog.entry.js": () => import("./ui-dialog.entry-
|
|
17
|
-
"./ui-disclosure.entry.js": () => import("./ui-disclosure.entry-
|
|
18
|
-
"./ui-floating-action-button.entry.js": () => import("./ui-floating-action-button.entry-
|
|
19
|
-
"./ui-form-field.entry.js": () => import("./ui-form-field.entry-
|
|
20
|
-
"./ui-icon-button.entry.js": () => import("./ui-icon-button.entry-
|
|
21
|
-
"./ui-input.entry.js": () => import("./ui-input.entry-
|
|
22
|
-
"./ui-menu-item.entry.js": () => import("./ui-menu-item.entry-
|
|
23
|
-
"./ui-menu.entry.js": () => import("./ui-menu.entry-
|
|
24
|
-
"./ui-popover.entry.js": () => import("./ui-popover.entry-
|
|
25
|
-
"./ui-radio-group.entry.js": () => import("./ui-radio-group.entry-
|
|
26
|
-
"./ui-radio.entry.js": () => import("./ui-radio.entry-
|
|
27
|
-
"./ui-search-result-row.entry.js": () => import("./ui-search-result-row.entry-
|
|
28
|
-
"./ui-search-shell.entry.js": () => import("./ui-search-shell.entry-
|
|
29
|
-
"./ui-select.entry.js": () => import("./ui-select.entry-
|
|
30
|
-
"./ui-switch.entry.js": () => import("./ui-switch.entry-
|
|
31
|
-
"./ui-tabs.entry.js": () => import("./ui-tabs.entry-
|
|
32
|
-
"./ui-textarea.entry.js": () => import("./ui-textarea.entry-
|
|
33
|
-
"./ui-toast-region.entry.js": () => import("./ui-toast-region.entry-
|
|
34
|
-
"./ui-tooltip.entry.js": () => import("./ui-tooltip.entry-
|
|
35
|
-
"./ui-top-bar.entry.js": () => import("./ui-top-bar.entry-
|
|
36
|
-
"./ui-tree-item.entry.js": () => import("./ui-tree-item.entry-
|
|
37
|
-
"./ui-tree.entry.js": () => import("./ui-tree.entry-
|
|
9
|
+
"./ui-affordance-scope.entry.js": () => import("./ui-affordance-scope.entry-L533MECG.js"),
|
|
10
|
+
"./ui-avatar-group.entry.js": () => import("./ui-avatar-group.entry-BWS7E2CM.js"),
|
|
11
|
+
"./ui-avatar.entry.js": () => import("./ui-avatar.entry-3INAY3XP.js"),
|
|
12
|
+
"./ui-badge.entry.js": () => import("./ui-badge.entry-2WOBVOYP.js"),
|
|
13
|
+
"./ui-button.entry.js": () => import("./ui-button.entry-VCGSEONK.js"),
|
|
14
|
+
"./ui-checkbox.entry.js": () => import("./ui-checkbox.entry-2PTBHSCQ.js"),
|
|
15
|
+
"./ui-context-menu.entry.js": () => import("./ui-context-menu.entry-AYDDCIZS.js"),
|
|
16
|
+
"./ui-dialog.entry.js": () => import("./ui-dialog.entry-I2XI3ZTZ.js"),
|
|
17
|
+
"./ui-disclosure.entry.js": () => import("./ui-disclosure.entry-5LY2BT7B.js"),
|
|
18
|
+
"./ui-floating-action-button.entry.js": () => import("./ui-floating-action-button.entry-EJAMR5AM.js"),
|
|
19
|
+
"./ui-form-field.entry.js": () => import("./ui-form-field.entry-SJ6NNFXB.js"),
|
|
20
|
+
"./ui-icon-button.entry.js": () => import("./ui-icon-button.entry-7SD2LVXE.js"),
|
|
21
|
+
"./ui-input.entry.js": () => import("./ui-input.entry-7MM7GEQW.js"),
|
|
22
|
+
"./ui-menu-item.entry.js": () => import("./ui-menu-item.entry-V3HIMR75.js"),
|
|
23
|
+
"./ui-menu.entry.js": () => import("./ui-menu.entry-R4WK5QSX.js"),
|
|
24
|
+
"./ui-popover.entry.js": () => import("./ui-popover.entry-ZRJRTXA7.js"),
|
|
25
|
+
"./ui-radio-group.entry.js": () => import("./ui-radio-group.entry-S6RXHFSN.js"),
|
|
26
|
+
"./ui-radio.entry.js": () => import("./ui-radio.entry-B73QZK2M.js"),
|
|
27
|
+
"./ui-search-result-row.entry.js": () => import("./ui-search-result-row.entry-DR2Y5S7P.js"),
|
|
28
|
+
"./ui-search-shell.entry.js": () => import("./ui-search-shell.entry-ST5IKJBC.js"),
|
|
29
|
+
"./ui-select.entry.js": () => import("./ui-select.entry-7GPRFV67.js"),
|
|
30
|
+
"./ui-switch.entry.js": () => import("./ui-switch.entry-XQ5IRJRH.js"),
|
|
31
|
+
"./ui-tabs.entry.js": () => import("./ui-tabs.entry-HPW5L5CY.js"),
|
|
32
|
+
"./ui-textarea.entry.js": () => import("./ui-textarea.entry-W2PSRYVS.js"),
|
|
33
|
+
"./ui-toast-region.entry.js": () => import("./ui-toast-region.entry-FJUHFXKZ.js"),
|
|
34
|
+
"./ui-tooltip.entry.js": () => import("./ui-tooltip.entry-G5WHQW7K.js"),
|
|
35
|
+
"./ui-top-bar.entry.js": () => import("./ui-top-bar.entry-3NCHFC4Y.js"),
|
|
36
|
+
"./ui-tree-item.entry.js": () => import("./ui-tree-item.entry-45RR3CMP.js"),
|
|
37
|
+
"./ui-tree.entry.js": () => import("./ui-tree.entry-SZW4Q5PY.js")
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// dist/esm/index-CEeiinfk.js
|
|
@@ -71,6 +71,8 @@ const UITree = class {
|
|
|
71
71
|
componentDidLoad() {
|
|
72
72
|
this.hoverIntent = createHoverIntent(this.hoverExpandDelay, this.expandTarget);
|
|
73
73
|
this.host.addEventListener('dragstart', this.onDragStart);
|
|
74
|
+
this.host.addEventListener('drag', this.onDrag);
|
|
75
|
+
this.host.addEventListener('dragenter', this.onDragOver);
|
|
74
76
|
this.host.addEventListener('dragover', this.onDragOver);
|
|
75
77
|
this.host.addEventListener('dragleave', this.onDragLeave);
|
|
76
78
|
this.host.addEventListener('drop', this.onDrop);
|
|
@@ -80,6 +82,8 @@ const UITree = class {
|
|
|
80
82
|
disconnectedCallback() {
|
|
81
83
|
this.hoverIntent?.destroy();
|
|
82
84
|
this.host.removeEventListener('dragstart', this.onDragStart);
|
|
85
|
+
this.host.removeEventListener('drag', this.onDrag);
|
|
86
|
+
this.host.removeEventListener('dragenter', this.onDragOver);
|
|
83
87
|
this.host.removeEventListener('dragover', this.onDragOver);
|
|
84
88
|
this.host.removeEventListener('dragleave', this.onDragLeave);
|
|
85
89
|
this.host.removeEventListener('drop', this.onDrop);
|
|
@@ -106,6 +110,16 @@ const UITree = class {
|
|
|
106
110
|
}
|
|
107
111
|
return null;
|
|
108
112
|
}
|
|
113
|
+
isWithinTree(node) {
|
|
114
|
+
let element = node instanceof HTMLElement ? node : null;
|
|
115
|
+
while (element) {
|
|
116
|
+
if (element === this.host || this.host.contains(element))
|
|
117
|
+
return true;
|
|
118
|
+
const root = element.getRootNode();
|
|
119
|
+
element = root instanceof ShadowRoot ? root.host : element.parentElement;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
109
123
|
acceptsChildren(item) {
|
|
110
124
|
return Boolean(item.container ?? item.hasAttribute('container'))
|
|
111
125
|
&& !Boolean(item.disabled ?? item.hasAttribute('disabled'));
|
|
@@ -176,27 +190,25 @@ const UITree = class {
|
|
|
176
190
|
}
|
|
177
191
|
setElementDragImage(event.dataTransfer, row);
|
|
178
192
|
};
|
|
179
|
-
|
|
193
|
+
updateTarget(target, clientY, dataTransfer) {
|
|
180
194
|
if (!this.source)
|
|
181
|
-
return;
|
|
182
|
-
const target = this.itemFromEvent(event);
|
|
195
|
+
return false;
|
|
183
196
|
if (!target || target === this.source) {
|
|
184
197
|
this.clearTarget();
|
|
185
|
-
return;
|
|
198
|
+
return false;
|
|
186
199
|
}
|
|
187
200
|
const row = this.rowFor(target);
|
|
188
201
|
if (!row)
|
|
189
|
-
return;
|
|
190
|
-
const position = classifyDropPosition(row.getBoundingClientRect(),
|
|
202
|
+
return false;
|
|
203
|
+
const position = classifyDropPosition(row.getBoundingClientRect(), clientY, this.acceptsChildren(target));
|
|
191
204
|
if (!this.permitsDrop(this.source, target, position)) {
|
|
192
|
-
if (
|
|
193
|
-
|
|
205
|
+
if (dataTransfer)
|
|
206
|
+
dataTransfer.dropEffect = 'none';
|
|
194
207
|
this.clearTarget();
|
|
195
|
-
return;
|
|
208
|
+
return false;
|
|
196
209
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
event.dataTransfer.dropEffect = 'move';
|
|
210
|
+
if (dataTransfer)
|
|
211
|
+
dataTransfer.dropEffect = 'move';
|
|
200
212
|
if (this.target !== target || this.position !== position) {
|
|
201
213
|
this.clearTarget();
|
|
202
214
|
this.target = target;
|
|
@@ -209,10 +221,31 @@ const UITree = class {
|
|
|
209
221
|
else {
|
|
210
222
|
this.hoverIntent?.cancel();
|
|
211
223
|
}
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
onDrag = (event) => {
|
|
227
|
+
if (!this.source || (event.clientX === 0 && event.clientY === 0))
|
|
228
|
+
return;
|
|
229
|
+
const target = this.itemAtPoint(event.clientX, event.clientY);
|
|
230
|
+
// Native dragenter does not fire when a nested source moves onto an
|
|
231
|
+
// ancestor row: the pointer was already inside that ancestor's host. The
|
|
232
|
+
// source drag event still carries the live pointer coordinates, so use it
|
|
233
|
+
// to keep ancestor/outdent feedback current.
|
|
234
|
+
if (target)
|
|
235
|
+
this.updateTarget(target, event.clientY, event.dataTransfer);
|
|
236
|
+
};
|
|
237
|
+
onDragOver = (event) => {
|
|
238
|
+
if (!this.source)
|
|
239
|
+
return;
|
|
240
|
+
const target = this.itemFromEvent(event);
|
|
241
|
+
if (this.updateTarget(target, event.clientY, event.dataTransfer)) {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
}
|
|
212
244
|
};
|
|
213
245
|
onDragLeave = (event) => {
|
|
214
|
-
|
|
215
|
-
|
|
246
|
+
if (this.isWithinTree(event.relatedTarget))
|
|
247
|
+
return;
|
|
248
|
+
if (this.itemAtPoint(event.clientX, event.clientY))
|
|
216
249
|
return;
|
|
217
250
|
this.clearTarget();
|
|
218
251
|
};
|
|
@@ -275,7 +308,7 @@ const UITree = class {
|
|
|
275
308
|
next.focus();
|
|
276
309
|
};
|
|
277
310
|
render() {
|
|
278
|
-
return (index.h(index.Host, { key: '
|
|
311
|
+
return (index.h(index.Host, { key: '7da064127eb199f5e2cfc59489a07204c9dac2f2', role: "tree", "aria-label": this.label || 'Tree' }, index.h("slot", { key: '31a98a6774ab35e565dab65f1dd8202494432b32' })));
|
|
279
312
|
}
|
|
280
313
|
};
|
|
281
314
|
UITree.style = uiTreeCss();
|
|
@@ -12,6 +12,8 @@ export class UITree {
|
|
|
12
12
|
componentDidLoad() {
|
|
13
13
|
this.hoverIntent = createHoverIntent(this.hoverExpandDelay, this.expandTarget);
|
|
14
14
|
this.host.addEventListener('dragstart', this.onDragStart);
|
|
15
|
+
this.host.addEventListener('drag', this.onDrag);
|
|
16
|
+
this.host.addEventListener('dragenter', this.onDragOver);
|
|
15
17
|
this.host.addEventListener('dragover', this.onDragOver);
|
|
16
18
|
this.host.addEventListener('dragleave', this.onDragLeave);
|
|
17
19
|
this.host.addEventListener('drop', this.onDrop);
|
|
@@ -21,6 +23,8 @@ export class UITree {
|
|
|
21
23
|
disconnectedCallback() {
|
|
22
24
|
this.hoverIntent?.destroy();
|
|
23
25
|
this.host.removeEventListener('dragstart', this.onDragStart);
|
|
26
|
+
this.host.removeEventListener('drag', this.onDrag);
|
|
27
|
+
this.host.removeEventListener('dragenter', this.onDragOver);
|
|
24
28
|
this.host.removeEventListener('dragover', this.onDragOver);
|
|
25
29
|
this.host.removeEventListener('dragleave', this.onDragLeave);
|
|
26
30
|
this.host.removeEventListener('drop', this.onDrop);
|
|
@@ -47,6 +51,16 @@ export class UITree {
|
|
|
47
51
|
}
|
|
48
52
|
return null;
|
|
49
53
|
}
|
|
54
|
+
isWithinTree(node) {
|
|
55
|
+
let element = node instanceof HTMLElement ? node : null;
|
|
56
|
+
while (element) {
|
|
57
|
+
if (element === this.host || this.host.contains(element))
|
|
58
|
+
return true;
|
|
59
|
+
const root = element.getRootNode();
|
|
60
|
+
element = root instanceof ShadowRoot ? root.host : element.parentElement;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
50
64
|
acceptsChildren(item) {
|
|
51
65
|
return Boolean(item.container ?? item.hasAttribute('container'))
|
|
52
66
|
&& !Boolean(item.disabled ?? item.hasAttribute('disabled'));
|
|
@@ -117,27 +131,25 @@ export class UITree {
|
|
|
117
131
|
}
|
|
118
132
|
setElementDragImage(event.dataTransfer, row);
|
|
119
133
|
};
|
|
120
|
-
|
|
134
|
+
updateTarget(target, clientY, dataTransfer) {
|
|
121
135
|
if (!this.source)
|
|
122
|
-
return;
|
|
123
|
-
const target = this.itemFromEvent(event);
|
|
136
|
+
return false;
|
|
124
137
|
if (!target || target === this.source) {
|
|
125
138
|
this.clearTarget();
|
|
126
|
-
return;
|
|
139
|
+
return false;
|
|
127
140
|
}
|
|
128
141
|
const row = this.rowFor(target);
|
|
129
142
|
if (!row)
|
|
130
|
-
return;
|
|
131
|
-
const position = classifyDropPosition(row.getBoundingClientRect(),
|
|
143
|
+
return false;
|
|
144
|
+
const position = classifyDropPosition(row.getBoundingClientRect(), clientY, this.acceptsChildren(target));
|
|
132
145
|
if (!this.permitsDrop(this.source, target, position)) {
|
|
133
|
-
if (
|
|
134
|
-
|
|
146
|
+
if (dataTransfer)
|
|
147
|
+
dataTransfer.dropEffect = 'none';
|
|
135
148
|
this.clearTarget();
|
|
136
|
-
return;
|
|
149
|
+
return false;
|
|
137
150
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
event.dataTransfer.dropEffect = 'move';
|
|
151
|
+
if (dataTransfer)
|
|
152
|
+
dataTransfer.dropEffect = 'move';
|
|
141
153
|
if (this.target !== target || this.position !== position) {
|
|
142
154
|
this.clearTarget();
|
|
143
155
|
this.target = target;
|
|
@@ -150,10 +162,31 @@ export class UITree {
|
|
|
150
162
|
else {
|
|
151
163
|
this.hoverIntent?.cancel();
|
|
152
164
|
}
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
onDrag = (event) => {
|
|
168
|
+
if (!this.source || (event.clientX === 0 && event.clientY === 0))
|
|
169
|
+
return;
|
|
170
|
+
const target = this.itemAtPoint(event.clientX, event.clientY);
|
|
171
|
+
// Native dragenter does not fire when a nested source moves onto an
|
|
172
|
+
// ancestor row: the pointer was already inside that ancestor's host. The
|
|
173
|
+
// source drag event still carries the live pointer coordinates, so use it
|
|
174
|
+
// to keep ancestor/outdent feedback current.
|
|
175
|
+
if (target)
|
|
176
|
+
this.updateTarget(target, event.clientY, event.dataTransfer);
|
|
177
|
+
};
|
|
178
|
+
onDragOver = (event) => {
|
|
179
|
+
if (!this.source)
|
|
180
|
+
return;
|
|
181
|
+
const target = this.itemFromEvent(event);
|
|
182
|
+
if (this.updateTarget(target, event.clientY, event.dataTransfer)) {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
}
|
|
153
185
|
};
|
|
154
186
|
onDragLeave = (event) => {
|
|
155
|
-
|
|
156
|
-
|
|
187
|
+
if (this.isWithinTree(event.relatedTarget))
|
|
188
|
+
return;
|
|
189
|
+
if (this.itemAtPoint(event.clientX, event.clientY))
|
|
157
190
|
return;
|
|
158
191
|
this.clearTarget();
|
|
159
192
|
};
|
|
@@ -216,7 +249,7 @@ export class UITree {
|
|
|
216
249
|
next.focus();
|
|
217
250
|
};
|
|
218
251
|
render() {
|
|
219
|
-
return (h(Host, { key: '
|
|
252
|
+
return (h(Host, { key: '7da064127eb199f5e2cfc59489a07204c9dac2f2', role: "tree", "aria-label": this.label || 'Tree' }, h("slot", { key: '31a98a6774ab35e565dab65f1dd8202494432b32' })));
|
|
220
253
|
}
|
|
221
254
|
static get is() { return "ui-tree"; }
|
|
222
255
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as t,H as e,h as i,c as s,t as r}from"./p-CIA4RyEp.js";import{d as n}from"./p-JwSoedEO.js";function o(t,e,i){const s=t.height>0?Math.min(1,Math.max(0,(e-t.top)/t.height)):.5;return i?s<.25?"before":s>.75?"after":"inside":s<.5?"before":"after"}const
|
|
1
|
+
import{p as t,H as e,h as i,c as s,t as r}from"./p-CIA4RyEp.js";import{d as n}from"./p-JwSoedEO.js";function o(t,e,i){const s=t.height>0?Math.min(1,Math.max(0,(e-t.top)/t.height)):.5;return i?s<.25?"before":s>.75?"after":"inside":s<.5?"before":"after"}const h=t(class extends e{constructor(t){super(),!1!==t&&this.__registerHost(),this.__attachShadow()}get host(){return this}label="Tree";hoverExpandDelay=700;source=null;target=null;position=null;hoverIntent=null;componentDidLoad(){this.hoverIntent=function(t,e){let i,s;function r(){i&&clearTimeout(i),i=void 0,s=void 0}return{schedule(n){s===n&&i||(r(),s=n,i=setTimeout((()=>{i=void 0;const t=s;s=void 0,t&&e(t)}),Math.max(0,t)))},cancel:r,destroy:r}}(this.hoverExpandDelay,this.expandTarget),this.host.addEventListener("dragstart",this.onDragStart),this.host.addEventListener("drag",this.onDrag),this.host.addEventListener("dragenter",this.onDragOver),this.host.addEventListener("dragover",this.onDragOver),this.host.addEventListener("dragleave",this.onDragLeave),this.host.addEventListener("drop",this.onDrop),this.host.addEventListener("dragend",this.onDragEnd),this.host.addEventListener("keydown",this.onKeyDown)}disconnectedCallback(){this.hoverIntent?.destroy(),this.host.removeEventListener("dragstart",this.onDragStart),this.host.removeEventListener("drag",this.onDrag),this.host.removeEventListener("dragenter",this.onDragOver),this.host.removeEventListener("dragover",this.onDragOver),this.host.removeEventListener("dragleave",this.onDragLeave),this.host.removeEventListener("drop",this.onDrop),this.host.removeEventListener("dragend",this.onDragEnd),this.host.removeEventListener("keydown",this.onKeyDown)}itemFromEvent(t){return t.composedPath().find((t=>t instanceof e&&"ui-tree-item"===t.localName))??null}itemId(t){return t.itemId||t.getAttribute("item-id")||""}rowFor(t){return t.shadowRoot?.querySelector('[part="row"]')??null}itemAtPoint(t,e){let i=this.host.ownerDocument.elementFromPoint(t,e);for(;i;){if("ui-tree-item"===i.localName&&this.host.contains(i))return i;const t=i.getRootNode();i=t instanceof ShadowRoot?t.host:i.parentElement}return null}isWithinTree(t){let i=t instanceof e?t:null;for(;i;){if(i===this.host||this.host.contains(i))return!0;const t=i.getRootNode();i=t instanceof ShadowRoot?t.host:i.parentElement}return!1}acceptsChildren(t){return!!(t.container??t.hasAttribute("container"))&&!(t.disabled??t.hasAttribute("disabled"))}itemMetadata(t){return{type:t.getAttribute("data-drag-type")||t.getAttribute("drag-type")||"item",scope:t.getAttribute("data-drop-scope")||t.getAttribute("drop-scope")||"",accepts:(t.getAttribute("data-accepts")||t.getAttribute("accepts")||"").split(",").map((t=>t.trim())).filter(Boolean)}}permitsDrop(t,e,i){if(t.contains(e))return!1;const s=this.itemMetadata(t),r=this.itemMetadata(e);return"inside"===i?this.acceptsChildren(e)&&(0===r.accepts.length||r.accepts.includes(s.type)):s.type===r.type}clearTarget(){this.target?.removeAttribute("data-drop-position"),this.target=null,this.position=null,this.hoverIntent?.cancel()}finishDrag(){this.source?.removeAttribute("data-dragging"),this.source=null,this.clearTarget()}expandTarget=t=>{const e=Array.from(this.host.querySelectorAll("ui-tree-item")).find((e=>this.itemId(e)===t));e&&"false"===e.getAttribute("aria-expanded")&&e.dispatchEvent(new CustomEvent("ui-tree-auto-expand"))};onDragStart=t=>{const i=this.itemFromEvent(t);if(!i||!(i.sortable??i.hasAttribute("sortable"))||(i.disabled??i.hasAttribute("disabled")))return;if(!t.composedPath().some((t=>t instanceof e&&"drag-handle"===t.getAttribute("part"))))return void t.preventDefault();const s=this.itemId(i),r=this.rowFor(i);s&&r?(this.source=i,i.setAttribute("data-dragging","true"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",s)),function(t,e){if(!t||"function"!=typeof t.setDragImage)return;const{height:i}=e.getBoundingClientRect();t.setDragImage(e,16,Math.max(0,i/2))}(t.dataTransfer,r)):t.preventDefault()};updateTarget(t,e,i){if(!this.source)return!1;if(!t||t===this.source)return this.clearTarget(),!1;const s=this.rowFor(t);if(!s)return!1;const r=o(s.getBoundingClientRect(),e,this.acceptsChildren(t));return this.permitsDrop(this.source,t,r)?(i&&(i.dropEffect="move"),this.target===t&&this.position===r||(this.clearTarget(),this.target=t,this.position=r,t.setAttribute("data-drop-position",r)),"inside"===r&&"false"===t.getAttribute("aria-expanded")?this.hoverIntent?.schedule(this.itemId(t)):this.hoverIntent?.cancel(),!0):(i&&(i.dropEffect="none"),this.clearTarget(),!1)}onDrag=t=>{if(!this.source||0===t.clientX&&0===t.clientY)return;const e=this.itemAtPoint(t.clientX,t.clientY);e&&this.updateTarget(e,t.clientY,t.dataTransfer)};onDragOver=t=>{if(!this.source)return;const e=this.itemFromEvent(t);this.updateTarget(e,t.clientY,t.dataTransfer)&&t.preventDefault()};onDragLeave=t=>{this.isWithinTree(t.relatedTarget)||this.itemAtPoint(t.clientX,t.clientY)||this.clearTarget()};dispatchReorder(t,e,i){const s=this.itemId(t),r=this.itemId(e);if(!s||!r)return;const o=this.itemMetadata(t),h=this.itemMetadata(e);n(this.host,"reorder",{sourceId:s,targetId:r,position:i,sourceType:o.type,targetType:h.type,sourceScope:o.scope,targetScope:h.scope,trigger:"pointer"})}onDrop=t=>{this.source&&this.target&&this.position&&(t.preventDefault(),this.dispatchReorder(this.source,this.target,this.position),this.finishDrag())};onDragEnd=t=>{if(this.source){const e=this.itemAtPoint(t.clientX,t.clientY);if(e&&e!==this.source){const i=this.rowFor(e);if(i){const s=o(i.getBoundingClientRect(),t.clientY,this.acceptsChildren(e));this.permitsDrop(this.source,e,s)&&this.dispatchReorder(this.source,e,s)}}}this.finishDrag()};visibleItems(){return Array.from(this.host.querySelectorAll("ui-tree-item")).filter((t=>t.getClientRects().length>0&&!t.hasAttribute("disabled")))}onKeyDown=t=>{const e=this.itemFromEvent(t);if(!e)return;const i=this.visibleItems(),s=i.indexOf(e);if(s<0)return;const r="ArrowDown"===t.key?i[s+1]:"ArrowUp"===t.key?i[s-1]:null;r&&(t.preventDefault(),r.focus())};render(){return i(s,{key:"7da064127eb199f5e2cfc59489a07204c9dac2f2",role:"tree","aria-label":this.label||"Tree"},i("slot",{key:"31a98a6774ab35e565dab65f1dd8202494432b32"}))}static get style(){return":host{--ui-tree-indent:16px;display:block;min-inline-size:0;padding-inline-start:var(--ui-tree-gutter, 22px)}::slotted(ui-tree-item){--ui-tree-indent:inherit}"}},[769,"ui-tree",{label:[1],hoverExpandDelay:[2,"hover-expand-delay"]}]),a=h,d=function(){"undefined"!=typeof customElements&&["ui-tree"].forEach((t=>{"ui-tree"===t&&(customElements.get(r(t))||customElements.define(r(t),h))}))};export{a as UiTree,d as defineCustomElement}
|
|
@@ -69,6 +69,8 @@ const UITree = class {
|
|
|
69
69
|
componentDidLoad() {
|
|
70
70
|
this.hoverIntent = createHoverIntent(this.hoverExpandDelay, this.expandTarget);
|
|
71
71
|
this.host.addEventListener('dragstart', this.onDragStart);
|
|
72
|
+
this.host.addEventListener('drag', this.onDrag);
|
|
73
|
+
this.host.addEventListener('dragenter', this.onDragOver);
|
|
72
74
|
this.host.addEventListener('dragover', this.onDragOver);
|
|
73
75
|
this.host.addEventListener('dragleave', this.onDragLeave);
|
|
74
76
|
this.host.addEventListener('drop', this.onDrop);
|
|
@@ -78,6 +80,8 @@ const UITree = class {
|
|
|
78
80
|
disconnectedCallback() {
|
|
79
81
|
this.hoverIntent?.destroy();
|
|
80
82
|
this.host.removeEventListener('dragstart', this.onDragStart);
|
|
83
|
+
this.host.removeEventListener('drag', this.onDrag);
|
|
84
|
+
this.host.removeEventListener('dragenter', this.onDragOver);
|
|
81
85
|
this.host.removeEventListener('dragover', this.onDragOver);
|
|
82
86
|
this.host.removeEventListener('dragleave', this.onDragLeave);
|
|
83
87
|
this.host.removeEventListener('drop', this.onDrop);
|
|
@@ -104,6 +108,16 @@ const UITree = class {
|
|
|
104
108
|
}
|
|
105
109
|
return null;
|
|
106
110
|
}
|
|
111
|
+
isWithinTree(node) {
|
|
112
|
+
let element = node instanceof HTMLElement ? node : null;
|
|
113
|
+
while (element) {
|
|
114
|
+
if (element === this.host || this.host.contains(element))
|
|
115
|
+
return true;
|
|
116
|
+
const root = element.getRootNode();
|
|
117
|
+
element = root instanceof ShadowRoot ? root.host : element.parentElement;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
107
121
|
acceptsChildren(item) {
|
|
108
122
|
return Boolean(item.container ?? item.hasAttribute('container'))
|
|
109
123
|
&& !Boolean(item.disabled ?? item.hasAttribute('disabled'));
|
|
@@ -174,27 +188,25 @@ const UITree = class {
|
|
|
174
188
|
}
|
|
175
189
|
setElementDragImage(event.dataTransfer, row);
|
|
176
190
|
};
|
|
177
|
-
|
|
191
|
+
updateTarget(target, clientY, dataTransfer) {
|
|
178
192
|
if (!this.source)
|
|
179
|
-
return;
|
|
180
|
-
const target = this.itemFromEvent(event);
|
|
193
|
+
return false;
|
|
181
194
|
if (!target || target === this.source) {
|
|
182
195
|
this.clearTarget();
|
|
183
|
-
return;
|
|
196
|
+
return false;
|
|
184
197
|
}
|
|
185
198
|
const row = this.rowFor(target);
|
|
186
199
|
if (!row)
|
|
187
|
-
return;
|
|
188
|
-
const position = classifyDropPosition(row.getBoundingClientRect(),
|
|
200
|
+
return false;
|
|
201
|
+
const position = classifyDropPosition(row.getBoundingClientRect(), clientY, this.acceptsChildren(target));
|
|
189
202
|
if (!this.permitsDrop(this.source, target, position)) {
|
|
190
|
-
if (
|
|
191
|
-
|
|
203
|
+
if (dataTransfer)
|
|
204
|
+
dataTransfer.dropEffect = 'none';
|
|
192
205
|
this.clearTarget();
|
|
193
|
-
return;
|
|
206
|
+
return false;
|
|
194
207
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
event.dataTransfer.dropEffect = 'move';
|
|
208
|
+
if (dataTransfer)
|
|
209
|
+
dataTransfer.dropEffect = 'move';
|
|
198
210
|
if (this.target !== target || this.position !== position) {
|
|
199
211
|
this.clearTarget();
|
|
200
212
|
this.target = target;
|
|
@@ -207,10 +219,31 @@ const UITree = class {
|
|
|
207
219
|
else {
|
|
208
220
|
this.hoverIntent?.cancel();
|
|
209
221
|
}
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
onDrag = (event) => {
|
|
225
|
+
if (!this.source || (event.clientX === 0 && event.clientY === 0))
|
|
226
|
+
return;
|
|
227
|
+
const target = this.itemAtPoint(event.clientX, event.clientY);
|
|
228
|
+
// Native dragenter does not fire when a nested source moves onto an
|
|
229
|
+
// ancestor row: the pointer was already inside that ancestor's host. The
|
|
230
|
+
// source drag event still carries the live pointer coordinates, so use it
|
|
231
|
+
// to keep ancestor/outdent feedback current.
|
|
232
|
+
if (target)
|
|
233
|
+
this.updateTarget(target, event.clientY, event.dataTransfer);
|
|
234
|
+
};
|
|
235
|
+
onDragOver = (event) => {
|
|
236
|
+
if (!this.source)
|
|
237
|
+
return;
|
|
238
|
+
const target = this.itemFromEvent(event);
|
|
239
|
+
if (this.updateTarget(target, event.clientY, event.dataTransfer)) {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
}
|
|
210
242
|
};
|
|
211
243
|
onDragLeave = (event) => {
|
|
212
|
-
|
|
213
|
-
|
|
244
|
+
if (this.isWithinTree(event.relatedTarget))
|
|
245
|
+
return;
|
|
246
|
+
if (this.itemAtPoint(event.clientX, event.clientY))
|
|
214
247
|
return;
|
|
215
248
|
this.clearTarget();
|
|
216
249
|
};
|
|
@@ -273,7 +306,7 @@ const UITree = class {
|
|
|
273
306
|
next.focus();
|
|
274
307
|
};
|
|
275
308
|
render() {
|
|
276
|
-
return (h(Host, { key: '
|
|
309
|
+
return (h(Host, { key: '7da064127eb199f5e2cfc59489a07204c9dac2f2', role: "tree", "aria-label": this.label || 'Tree' }, h("slot", { key: '31a98a6774ab35e565dab65f1dd8202494432b32' })));
|
|
277
310
|
}
|
|
278
311
|
};
|
|
279
312
|
UITree.style = uiTreeCss();
|
package/dist/index.cjs
CHANGED
|
@@ -3423,6 +3423,8 @@ var init_ui_tree_entry = __esm({
|
|
|
3423
3423
|
componentDidLoad() {
|
|
3424
3424
|
this.hoverIntent = createHoverIntent(this.hoverExpandDelay, this.expandTarget);
|
|
3425
3425
|
this.host.addEventListener("dragstart", this.onDragStart);
|
|
3426
|
+
this.host.addEventListener("drag", this.onDrag);
|
|
3427
|
+
this.host.addEventListener("dragenter", this.onDragOver);
|
|
3426
3428
|
this.host.addEventListener("dragover", this.onDragOver);
|
|
3427
3429
|
this.host.addEventListener("dragleave", this.onDragLeave);
|
|
3428
3430
|
this.host.addEventListener("drop", this.onDrop);
|
|
@@ -3432,6 +3434,8 @@ var init_ui_tree_entry = __esm({
|
|
|
3432
3434
|
disconnectedCallback() {
|
|
3433
3435
|
this.hoverIntent?.destroy();
|
|
3434
3436
|
this.host.removeEventListener("dragstart", this.onDragStart);
|
|
3437
|
+
this.host.removeEventListener("drag", this.onDrag);
|
|
3438
|
+
this.host.removeEventListener("dragenter", this.onDragOver);
|
|
3435
3439
|
this.host.removeEventListener("dragover", this.onDragOver);
|
|
3436
3440
|
this.host.removeEventListener("dragleave", this.onDragLeave);
|
|
3437
3441
|
this.host.removeEventListener("drop", this.onDrop);
|
|
@@ -3458,6 +3462,16 @@ var init_ui_tree_entry = __esm({
|
|
|
3458
3462
|
}
|
|
3459
3463
|
return null;
|
|
3460
3464
|
}
|
|
3465
|
+
isWithinTree(node) {
|
|
3466
|
+
let element = node instanceof HTMLElement ? node : null;
|
|
3467
|
+
while (element) {
|
|
3468
|
+
if (element === this.host || this.host.contains(element))
|
|
3469
|
+
return true;
|
|
3470
|
+
const root = element.getRootNode();
|
|
3471
|
+
element = root instanceof ShadowRoot ? root.host : element.parentElement;
|
|
3472
|
+
}
|
|
3473
|
+
return false;
|
|
3474
|
+
}
|
|
3461
3475
|
acceptsChildren(item) {
|
|
3462
3476
|
return Boolean(item.container ?? item.hasAttribute("container")) && !Boolean(item.disabled ?? item.hasAttribute("disabled"));
|
|
3463
3477
|
}
|
|
@@ -3518,27 +3532,25 @@ var init_ui_tree_entry = __esm({
|
|
|
3518
3532
|
}
|
|
3519
3533
|
setElementDragImage(event.dataTransfer, row);
|
|
3520
3534
|
};
|
|
3521
|
-
|
|
3535
|
+
updateTarget(target, clientY, dataTransfer) {
|
|
3522
3536
|
if (!this.source)
|
|
3523
|
-
return;
|
|
3524
|
-
const target = this.itemFromEvent(event);
|
|
3537
|
+
return false;
|
|
3525
3538
|
if (!target || target === this.source) {
|
|
3526
3539
|
this.clearTarget();
|
|
3527
|
-
return;
|
|
3540
|
+
return false;
|
|
3528
3541
|
}
|
|
3529
3542
|
const row = this.rowFor(target);
|
|
3530
3543
|
if (!row)
|
|
3531
|
-
return;
|
|
3532
|
-
const position = classifyDropPosition(row.getBoundingClientRect(),
|
|
3544
|
+
return false;
|
|
3545
|
+
const position = classifyDropPosition(row.getBoundingClientRect(), clientY, this.acceptsChildren(target));
|
|
3533
3546
|
if (!this.permitsDrop(this.source, target, position)) {
|
|
3534
|
-
if (
|
|
3535
|
-
|
|
3547
|
+
if (dataTransfer)
|
|
3548
|
+
dataTransfer.dropEffect = "none";
|
|
3536
3549
|
this.clearTarget();
|
|
3537
|
-
return;
|
|
3550
|
+
return false;
|
|
3538
3551
|
}
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
event.dataTransfer.dropEffect = "move";
|
|
3552
|
+
if (dataTransfer)
|
|
3553
|
+
dataTransfer.dropEffect = "move";
|
|
3542
3554
|
if (this.target !== target || this.position !== position) {
|
|
3543
3555
|
this.clearTarget();
|
|
3544
3556
|
this.target = target;
|
|
@@ -3550,10 +3562,27 @@ var init_ui_tree_entry = __esm({
|
|
|
3550
3562
|
} else {
|
|
3551
3563
|
this.hoverIntent?.cancel();
|
|
3552
3564
|
}
|
|
3565
|
+
return true;
|
|
3566
|
+
}
|
|
3567
|
+
onDrag = (event) => {
|
|
3568
|
+
if (!this.source || event.clientX === 0 && event.clientY === 0)
|
|
3569
|
+
return;
|
|
3570
|
+
const target = this.itemAtPoint(event.clientX, event.clientY);
|
|
3571
|
+
if (target)
|
|
3572
|
+
this.updateTarget(target, event.clientY, event.dataTransfer);
|
|
3573
|
+
};
|
|
3574
|
+
onDragOver = (event) => {
|
|
3575
|
+
if (!this.source)
|
|
3576
|
+
return;
|
|
3577
|
+
const target = this.itemFromEvent(event);
|
|
3578
|
+
if (this.updateTarget(target, event.clientY, event.dataTransfer)) {
|
|
3579
|
+
event.preventDefault();
|
|
3580
|
+
}
|
|
3553
3581
|
};
|
|
3554
3582
|
onDragLeave = (event) => {
|
|
3555
|
-
|
|
3556
|
-
|
|
3583
|
+
if (this.isWithinTree(event.relatedTarget))
|
|
3584
|
+
return;
|
|
3585
|
+
if (this.itemAtPoint(event.clientX, event.clientY))
|
|
3557
3586
|
return;
|
|
3558
3587
|
this.clearTarget();
|
|
3559
3588
|
};
|
|
@@ -3615,7 +3644,7 @@ var init_ui_tree_entry = __esm({
|
|
|
3615
3644
|
next.focus();
|
|
3616
3645
|
};
|
|
3617
3646
|
render() {
|
|
3618
|
-
return h(Host, { key: "
|
|
3647
|
+
return h(Host, { key: "7da064127eb199f5e2cfc59489a07204c9dac2f2", role: "tree", "aria-label": this.label || "Tree" }, h("slot", { key: "31a98a6774ab35e565dab65f1dd8202494432b32" }));
|
|
3619
3648
|
}
|
|
3620
3649
|
};
|
|
3621
3650
|
UITree.style = uiTreeCss();
|
package/dist/index.js
CHANGED
package/dist/looma/looma.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{p as e,b as a}from"./p-CEeiinfk.js";export{s as setNonce}from"./p-CEeiinfk.js";import{g as n}from"./p-DQuL1Twl.js";(()=>{const a=import.meta.url,n={};return""!==a&&(n.resourcesUrl=new URL(".",a).href),e(n)})().then((async e=>(await n(),a([["p-063f5a89",[[769,"ui-context-menu",{open:[4],defaultOpen:[4,"default-open"],for:[1],internalOpen:[32],focusTrigger:[32]},null,{open:[{syncFromProp:0}],for:[{syncTarget:0}],internalOpen:[{syncOverlay:0}]}]]],["p-2e6f791e",[[769,"ui-affordance-scope",{nearRadius:[514,"near-radius"]},null,{nearRadius:[{connectCoordinator:0}]}]]],["p-1681b218",[[513,"ui-avatar",{src:[1],alt:[1],name:[1],fallback:[1],hasImage:[32]},null,{src:[{watchSrc:0}]}]]],["p-5ba9d496",[[769,"ui-avatar-group",{max:[2],label:[1],overflowCount:[32]},null,{max:[{syncOverflow:0}]}]]],["p-0584a051",[[769,"ui-badge",{variant:[1],tone:[1]}]]],["p-34417499",[[769,"ui-button",{variant:[1],size:[1],disabled:[4]},null,{variant:[{syncToButton:0}],size:[{syncToButton:0}],disabled:[{syncToButton:0}]}]]],["p-0f45c5f0",[[769,"ui-checkbox",{checked:[4],defaultChecked:[4,"default-checked"],disabled:[4],indeterminate:[4],required:[4],value:[1],internalChecked:[32]},null,{checked:[{syncFromProp:0}],internalChecked:[{syncToInput:0}],indeterminate:[{syncToInput:0}],disabled:[{syncToInput:0}],required:[{syncToInput:0}]}]]],["p-11083743",[[769,"ui-dialog",{open:[4],defaultOpen:[4,"default-open"],modal:[4],dismissible:[4],label:[1],internalOpen:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{syncOpen:0}]}]]],["p-a9f46811",[[769,"ui-disclosure",{open:[4],defaultOpen:[4,"default-open"],disabled:[4],internalOpen:[32],contentId:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{syncState:0}]}]]],["p-051f578c",[[769,"ui-floating-action-button",{disabled:[516],mobileOnly:[516,"mobile-only"],label:[1]}]]],["p-5d4713a6",[[769,"ui-form-field",{invalid:[4],disabled:[4],required:[4]}]]],["p-0198bb21",[[769,"ui-icon-button",{disabled:[516],label:[1],size:[513],variant:[513],anticipatory:[516]}]]],["p-624ba086",[[769,"ui-input",{value:[1],defaultValue:[1,"default-value"],disabled:[4],invalid:[4],readOnly:[4,"readonly"],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToInput:0}],defaultValue:[{syncToInput:0}],disabled:[{syncToInput:0}],invalid:[{syncToInput:0}],readOnly:[{syncToInput:0}]}]]],["p-ed5abf6d",[[769,"ui-menu-item",{disabled:[516],value:[1]}]]],["p-caa8fc7b",[[769,"ui-popover",{open:[4],defaultOpen:[4,"default-open"],for:[1],placement:[1],internalOpen:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{onOpenChange:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}]}]]],["p-8d5adb17",[[769,"ui-radio",{checked:[4],defaultChecked:[4,"default-checked"],disabled:[4],name:[1],required:[4],value:[1]},null,{checked:[{syncToInput:0}],disabled:[{syncToInput:0}],name:[{syncToInput:0}],required:[{syncToInput:0}],value:[{syncToInput:0}]}]]],["p-7e94d90d",[[769,"ui-radio-group",{value:[1],name:[1],orientation:[1],disabled:[4],required:[4],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToRadios:0}],name:[{syncToRadios:0}],orientation:[{syncToRadios:0}],disabled:[{syncToRadios:0}]}]]],["p-2ed7e241",[[769,"ui-search-result-row",{disabled:[516],selected:[516],hasLeading:[32],hasMeta:[32],hasExcerpt:[32],hasTrailing:[32]}]]],["p-d273b857",[[769,"ui-search-shell",{hasStatus:[32],hasFooter:[32]}]]],["p-a5127c7d",[[769,"ui-select",{value:[1],defaultValue:[1,"default-value"],disabled:[4],invalid:[4],required:[4],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToSelect:0}],defaultValue:[{syncToSelect:0}],disabled:[{syncToSelect:0}],invalid:[{syncToSelect:0}],required:[{syncToSelect:0}]}]]],["p-b7aa4488",[[769,"ui-switch",{checked:[4],defaultChecked:[4,"default-checked"],disabled:[4],required:[4],value:[1],internalChecked:[32]},null,{checked:[{syncFromProp:0}]}]]],["p-078f9fb8",[[769,"ui-tabs",{value:[1],defaultValue:[1,"default-value"],orientation:[1],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncState:0}],orientation:[{syncState:0}]}]]],["p-4b422d40",[[769,"ui-textarea",{value:[1],defaultValue:[1,"default-value"],disabled:[4],invalid:[4],readOnly:[4,"readonly"],rows:[2],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToTextarea:0}],defaultValue:[{syncToTextarea:0}],disabled:[{syncToTextarea:0}],invalid:[{syncToTextarea:0}],readOnly:[{syncToTextarea:0}],rows:[{syncToTextarea:0}]}]]],["p-54c41576",[[769,"ui-toast-region",{open:[4],internalOpen:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{syncSurface:0}]}]]],["p-9194a99d",[[769,"ui-tooltip",{for:[1],open:[4],defaultOpen:[4,"default-open"],placement:[1],showDelay:[2,"show-delay"],hideDelay:[2,"hide-delay"],internalOpen:[32]},null,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncOverlay:0}]}]]],["p-a33522a2",[[769,"ui-top-bar",{hasLeading:[32],hasSearch:[32],hasActions:[32]}]]],["p-
|
|
1
|
+
import{p as e,b as a}from"./p-CEeiinfk.js";export{s as setNonce}from"./p-CEeiinfk.js";import{g as n}from"./p-DQuL1Twl.js";(()=>{const a=import.meta.url,n={};return""!==a&&(n.resourcesUrl=new URL(".",a).href),e(n)})().then((async e=>(await n(),a([["p-063f5a89",[[769,"ui-context-menu",{open:[4],defaultOpen:[4,"default-open"],for:[1],internalOpen:[32],focusTrigger:[32]},null,{open:[{syncFromProp:0}],for:[{syncTarget:0}],internalOpen:[{syncOverlay:0}]}]]],["p-2e6f791e",[[769,"ui-affordance-scope",{nearRadius:[514,"near-radius"]},null,{nearRadius:[{connectCoordinator:0}]}]]],["p-1681b218",[[513,"ui-avatar",{src:[1],alt:[1],name:[1],fallback:[1],hasImage:[32]},null,{src:[{watchSrc:0}]}]]],["p-5ba9d496",[[769,"ui-avatar-group",{max:[2],label:[1],overflowCount:[32]},null,{max:[{syncOverflow:0}]}]]],["p-0584a051",[[769,"ui-badge",{variant:[1],tone:[1]}]]],["p-34417499",[[769,"ui-button",{variant:[1],size:[1],disabled:[4]},null,{variant:[{syncToButton:0}],size:[{syncToButton:0}],disabled:[{syncToButton:0}]}]]],["p-0f45c5f0",[[769,"ui-checkbox",{checked:[4],defaultChecked:[4,"default-checked"],disabled:[4],indeterminate:[4],required:[4],value:[1],internalChecked:[32]},null,{checked:[{syncFromProp:0}],internalChecked:[{syncToInput:0}],indeterminate:[{syncToInput:0}],disabled:[{syncToInput:0}],required:[{syncToInput:0}]}]]],["p-11083743",[[769,"ui-dialog",{open:[4],defaultOpen:[4,"default-open"],modal:[4],dismissible:[4],label:[1],internalOpen:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{syncOpen:0}]}]]],["p-a9f46811",[[769,"ui-disclosure",{open:[4],defaultOpen:[4,"default-open"],disabled:[4],internalOpen:[32],contentId:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{syncState:0}]}]]],["p-051f578c",[[769,"ui-floating-action-button",{disabled:[516],mobileOnly:[516,"mobile-only"],label:[1]}]]],["p-5d4713a6",[[769,"ui-form-field",{invalid:[4],disabled:[4],required:[4]}]]],["p-0198bb21",[[769,"ui-icon-button",{disabled:[516],label:[1],size:[513],variant:[513],anticipatory:[516]}]]],["p-624ba086",[[769,"ui-input",{value:[1],defaultValue:[1,"default-value"],disabled:[4],invalid:[4],readOnly:[4,"readonly"],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToInput:0}],defaultValue:[{syncToInput:0}],disabled:[{syncToInput:0}],invalid:[{syncToInput:0}],readOnly:[{syncToInput:0}]}]]],["p-ed5abf6d",[[769,"ui-menu-item",{disabled:[516],value:[1]}]]],["p-caa8fc7b",[[769,"ui-popover",{open:[4],defaultOpen:[4,"default-open"],for:[1],placement:[1],internalOpen:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{onOpenChange:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}]}]]],["p-8d5adb17",[[769,"ui-radio",{checked:[4],defaultChecked:[4,"default-checked"],disabled:[4],name:[1],required:[4],value:[1]},null,{checked:[{syncToInput:0}],disabled:[{syncToInput:0}],name:[{syncToInput:0}],required:[{syncToInput:0}],value:[{syncToInput:0}]}]]],["p-7e94d90d",[[769,"ui-radio-group",{value:[1],name:[1],orientation:[1],disabled:[4],required:[4],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToRadios:0}],name:[{syncToRadios:0}],orientation:[{syncToRadios:0}],disabled:[{syncToRadios:0}]}]]],["p-2ed7e241",[[769,"ui-search-result-row",{disabled:[516],selected:[516],hasLeading:[32],hasMeta:[32],hasExcerpt:[32],hasTrailing:[32]}]]],["p-d273b857",[[769,"ui-search-shell",{hasStatus:[32],hasFooter:[32]}]]],["p-a5127c7d",[[769,"ui-select",{value:[1],defaultValue:[1,"default-value"],disabled:[4],invalid:[4],required:[4],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToSelect:0}],defaultValue:[{syncToSelect:0}],disabled:[{syncToSelect:0}],invalid:[{syncToSelect:0}],required:[{syncToSelect:0}]}]]],["p-b7aa4488",[[769,"ui-switch",{checked:[4],defaultChecked:[4,"default-checked"],disabled:[4],required:[4],value:[1],internalChecked:[32]},null,{checked:[{syncFromProp:0}]}]]],["p-078f9fb8",[[769,"ui-tabs",{value:[1],defaultValue:[1,"default-value"],orientation:[1],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncState:0}],orientation:[{syncState:0}]}]]],["p-4b422d40",[[769,"ui-textarea",{value:[1],defaultValue:[1,"default-value"],disabled:[4],invalid:[4],readOnly:[4,"readonly"],rows:[2],internalValue:[32]},null,{value:[{syncFromProp:0}],internalValue:[{syncToTextarea:0}],defaultValue:[{syncToTextarea:0}],disabled:[{syncToTextarea:0}],invalid:[{syncToTextarea:0}],readOnly:[{syncToTextarea:0}],rows:[{syncToTextarea:0}]}]]],["p-54c41576",[[769,"ui-toast-region",{open:[4],internalOpen:[32]},null,{open:[{syncFromProp:0}],internalOpen:[{syncSurface:0}]}]]],["p-9194a99d",[[769,"ui-tooltip",{for:[1],open:[4],defaultOpen:[4,"default-open"],placement:[1],showDelay:[2,"show-delay"],hideDelay:[2,"hide-delay"],internalOpen:[32]},null,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncOverlay:0}]}]]],["p-a33522a2",[[769,"ui-top-bar",{hasLeading:[32],hasSearch:[32],hasActions:[32]}]]],["p-e3f99a24",[[769,"ui-tree",{label:[1],hoverExpandDelay:[2,"hover-expand-delay"]}]]],["p-54722713",[[769,"ui-tree-item",{itemId:[1,"item-id"],label:[1],depth:[2],container:[4],sortable:[4],dragType:[1,"drag-type"],dropScope:[1,"drop-scope"],accepts:[1],expanded:[4],defaultExpanded:[4,"default-expanded"],selected:[4],disabled:[4],internalExpanded:[32]},null,{expanded:[{syncExpandedFromProp:0}]}]]],["p-1674cda4",[[769,"ui-menu",{open:[4],defaultOpen:[4,"default-open"],for:[1],placement:[1],internalOpen:[32]},null,{open:[{syncFromProp:0}],for:[{resetSurface:0}],placement:[{resetSurface:0}],internalOpen:[{syncSurface:0}]}]]]],e))));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,g as i,h as e,H as s}from"./p-CEeiinfk.js";import{d as r}from"./p-JwSoedEO.js";function n(t,i,e){const s=t.height>0?Math.min(1,Math.max(0,(i-t.top)/t.height)):.5;return e?s<.25?"before":s>.75?"after":"inside":s<.5?"before":"after"}const o=class{constructor(i){t(this,i)}get host(){return i(this)}label="Tree";hoverExpandDelay=700;source=null;target=null;position=null;hoverIntent=null;componentDidLoad(){this.hoverIntent=function(t,i){let e,s;function r(){e&&clearTimeout(e),e=void 0,s=void 0}return{schedule(n){s===n&&e||(r(),s=n,e=setTimeout((()=>{e=void 0;const t=s;s=void 0,t&&i(t)}),Math.max(0,t)))},cancel:r,destroy:r}}(this.hoverExpandDelay,this.expandTarget),this.host.addEventListener("dragstart",this.onDragStart),this.host.addEventListener("drag",this.onDrag),this.host.addEventListener("dragenter",this.onDragOver),this.host.addEventListener("dragover",this.onDragOver),this.host.addEventListener("dragleave",this.onDragLeave),this.host.addEventListener("drop",this.onDrop),this.host.addEventListener("dragend",this.onDragEnd),this.host.addEventListener("keydown",this.onKeyDown)}disconnectedCallback(){this.hoverIntent?.destroy(),this.host.removeEventListener("dragstart",this.onDragStart),this.host.removeEventListener("drag",this.onDrag),this.host.removeEventListener("dragenter",this.onDragOver),this.host.removeEventListener("dragover",this.onDragOver),this.host.removeEventListener("dragleave",this.onDragLeave),this.host.removeEventListener("drop",this.onDrop),this.host.removeEventListener("dragend",this.onDragEnd),this.host.removeEventListener("keydown",this.onKeyDown)}itemFromEvent(t){return t.composedPath().find((t=>t instanceof HTMLElement&&"ui-tree-item"===t.localName))??null}itemId(t){return t.itemId||t.getAttribute("item-id")||""}rowFor(t){return t.shadowRoot?.querySelector('[part="row"]')??null}itemAtPoint(t,i){let e=this.host.ownerDocument.elementFromPoint(t,i);for(;e;){if("ui-tree-item"===e.localName&&this.host.contains(e))return e;const t=e.getRootNode();e=t instanceof ShadowRoot?t.host:e.parentElement}return null}isWithinTree(t){let i=t instanceof HTMLElement?t:null;for(;i;){if(i===this.host||this.host.contains(i))return!0;const t=i.getRootNode();i=t instanceof ShadowRoot?t.host:i.parentElement}return!1}acceptsChildren(t){return Boolean(t.container??t.hasAttribute("container"))&&!Boolean(t.disabled??t.hasAttribute("disabled"))}itemMetadata(t){return{type:t.getAttribute("data-drag-type")||t.getAttribute("drag-type")||"item",scope:t.getAttribute("data-drop-scope")||t.getAttribute("drop-scope")||"",accepts:(t.getAttribute("data-accepts")||t.getAttribute("accepts")||"").split(",").map((t=>t.trim())).filter(Boolean)}}permitsDrop(t,i,e){if(t.contains(i))return!1;const s=this.itemMetadata(t),r=this.itemMetadata(i);return"inside"===e?this.acceptsChildren(i)&&(0===r.accepts.length||r.accepts.includes(s.type)):s.type===r.type}clearTarget(){this.target?.removeAttribute("data-drop-position"),this.target=null,this.position=null,this.hoverIntent?.cancel()}finishDrag(){this.source?.removeAttribute("data-dragging"),this.source=null,this.clearTarget()}expandTarget=t=>{const i=Array.from(this.host.querySelectorAll("ui-tree-item")).find((i=>this.itemId(i)===t));i&&"false"===i.getAttribute("aria-expanded")&&i.dispatchEvent(new CustomEvent("ui-tree-auto-expand"))};onDragStart=t=>{const i=this.itemFromEvent(t);if(!i||!Boolean(i.sortable??i.hasAttribute("sortable"))||Boolean(i.disabled??i.hasAttribute("disabled")))return;if(!t.composedPath().some((t=>t instanceof HTMLElement&&"drag-handle"===t.getAttribute("part"))))return void t.preventDefault();const e=this.itemId(i),s=this.rowFor(i);e&&s?(this.source=i,i.setAttribute("data-dragging","true"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e)),function(t,i){if(!t||"function"!=typeof t.setDragImage)return;const{height:e}=i.getBoundingClientRect();t.setDragImage(i,16,Math.max(0,e/2))}(t.dataTransfer,s)):t.preventDefault()};updateTarget(t,i,e){if(!this.source)return!1;if(!t||t===this.source)return this.clearTarget(),!1;const s=this.rowFor(t);if(!s)return!1;const r=n(s.getBoundingClientRect(),i,this.acceptsChildren(t));return this.permitsDrop(this.source,t,r)?(e&&(e.dropEffect="move"),this.target===t&&this.position===r||(this.clearTarget(),this.target=t,this.position=r,t.setAttribute("data-drop-position",r)),"inside"===r&&"false"===t.getAttribute("aria-expanded")?this.hoverIntent?.schedule(this.itemId(t)):this.hoverIntent?.cancel(),!0):(e&&(e.dropEffect="none"),this.clearTarget(),!1)}onDrag=t=>{if(!this.source||0===t.clientX&&0===t.clientY)return;const i=this.itemAtPoint(t.clientX,t.clientY);i&&this.updateTarget(i,t.clientY,t.dataTransfer)};onDragOver=t=>{if(!this.source)return;const i=this.itemFromEvent(t);this.updateTarget(i,t.clientY,t.dataTransfer)&&t.preventDefault()};onDragLeave=t=>{this.isWithinTree(t.relatedTarget)||this.itemAtPoint(t.clientX,t.clientY)||this.clearTarget()};dispatchReorder(t,i,e){const s=this.itemId(t),n=this.itemId(i);if(!s||!n)return;const o=this.itemMetadata(t),h=this.itemMetadata(i);r(this.host,"reorder",{sourceId:s,targetId:n,position:e,sourceType:o.type,targetType:h.type,sourceScope:o.scope,targetScope:h.scope,trigger:"pointer"})}onDrop=t=>{this.source&&this.target&&this.position&&(t.preventDefault(),this.dispatchReorder(this.source,this.target,this.position),this.finishDrag())};onDragEnd=t=>{if(this.source){const i=this.itemAtPoint(t.clientX,t.clientY);if(i&&i!==this.source){const e=this.rowFor(i);if(e){const s=n(e.getBoundingClientRect(),t.clientY,this.acceptsChildren(i));this.permitsDrop(this.source,i,s)&&this.dispatchReorder(this.source,i,s)}}}this.finishDrag()};visibleItems(){return Array.from(this.host.querySelectorAll("ui-tree-item")).filter((t=>t.getClientRects().length>0&&!t.hasAttribute("disabled")))}onKeyDown=t=>{const i=this.itemFromEvent(t);if(!i)return;const e=this.visibleItems(),s=e.indexOf(i);if(s<0)return;const r="ArrowDown"===t.key?e[s+1]:"ArrowUp"===t.key?e[s-1]:null;r&&(t.preventDefault(),r.focus())};render(){return e(s,{key:"7da064127eb199f5e2cfc59489a07204c9dac2f2",role:"tree","aria-label":this.label||"Tree"},e("slot",{key:"31a98a6774ab35e565dab65f1dd8202494432b32"}))}};o.style=":host{--ui-tree-indent:16px;display:block;min-inline-size:0;padding-inline-start:var(--ui-tree-gutter, 22px)}::slotted(ui-tree-item){--ui-tree-indent:inherit}";export{o as ui_tree}
|
|
@@ -12,6 +12,7 @@ export declare class UITree {
|
|
|
12
12
|
private itemId;
|
|
13
13
|
private rowFor;
|
|
14
14
|
private itemAtPoint;
|
|
15
|
+
private isWithinTree;
|
|
15
16
|
private acceptsChildren;
|
|
16
17
|
private itemMetadata;
|
|
17
18
|
private permitsDrop;
|
|
@@ -19,6 +20,8 @@ export declare class UITree {
|
|
|
19
20
|
private finishDrag;
|
|
20
21
|
private expandTarget;
|
|
21
22
|
private onDragStart;
|
|
23
|
+
private updateTarget;
|
|
24
|
+
private onDrag;
|
|
22
25
|
private onDragOver;
|
|
23
26
|
private onDragLeave;
|
|
24
27
|
private dispatchReorder;
|