@threadlabs/looma 0.1.18 → 0.1.20
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-DTQVRGVL.js → chunk-RLSUA6N5.js} +29 -29
- package/dist/cjs/ui-tree-item.cjs.entry.js +2 -2
- package/dist/cjs/ui-tree.cjs.entry.js +44 -18
- package/dist/collection/components/ui-tree/ui-tree.js +44 -18
- package/dist/collection/components/ui-tree-item/ui-tree-item.css +2 -2
- package/dist/collection/components/ui-tree-item/ui-tree-item.js +1 -1
- package/dist/components/ui-tree-item.js +1 -1
- package/dist/components/ui-tree.js +1 -1
- package/dist/esm/ui-tree-item.entry.js +2 -2
- package/dist/esm/ui-tree.entry.js +44 -18
- package/dist/index.cjs +46 -20
- package/dist/index.js +1 -1
- package/dist/looma/looma.esm.js +1 -1
- package/dist/looma/{p-d01960c2.entry.js → p-54722713.entry.js} +1 -1
- package/dist/looma/p-979b8ab1.entry.js +1 -0
- package/dist/types/components/ui-tree/ui-tree.d.ts +2 -0
- package/dist/{ui-affordance-scope.entry-2W7ZKAGK.js → ui-affordance-scope.entry-TEYCR7NX.js} +1 -1
- package/dist/{ui-avatar-group.entry-SE5JG2FT.js → ui-avatar-group.entry-Z2JCVPMM.js} +1 -1
- package/dist/{ui-avatar.entry-46JDI25A.js → ui-avatar.entry-CDDUQV4B.js} +1 -1
- package/dist/{ui-badge.entry-U7G3MEC5.js → ui-badge.entry-ELFAXPKR.js} +1 -1
- package/dist/{ui-button.entry-DELD6KMH.js → ui-button.entry-S5GEJ55S.js} +1 -1
- package/dist/{ui-checkbox.entry-ZUG2P642.js → ui-checkbox.entry-NFXU5LDX.js} +1 -1
- package/dist/{ui-context-menu.entry-L4HTK3PV.js → ui-context-menu.entry-W5F6LBEC.js} +1 -1
- package/dist/{ui-dialog.entry-TQPYD2YI.js → ui-dialog.entry-G2K37IUH.js} +1 -1
- package/dist/{ui-disclosure.entry-23TII4YU.js → ui-disclosure.entry-JO3XAMCC.js} +1 -1
- package/dist/{ui-floating-action-button.entry-FOQYAFJI.js → ui-floating-action-button.entry-EXXENSSO.js} +1 -1
- package/dist/{ui-form-field.entry-SCPG4STY.js → ui-form-field.entry-L62S6Z62.js} +1 -1
- package/dist/{ui-icon-button.entry-U45ZVAC3.js → ui-icon-button.entry-D7I7BV27.js} +1 -1
- package/dist/{ui-input.entry-3AIA3G4C.js → ui-input.entry-YDFDXMZE.js} +1 -1
- package/dist/{ui-menu-item.entry-3QO5TG2J.js → ui-menu-item.entry-QH7UGDFX.js} +1 -1
- package/dist/{ui-menu.entry-JACWGDDG.js → ui-menu.entry-YIQOPJOS.js} +1 -1
- package/dist/{ui-popover.entry-2XP4H3S2.js → ui-popover.entry-XN2IOEYH.js} +1 -1
- package/dist/{ui-radio-group.entry-73IKFMDK.js → ui-radio-group.entry-C7ESTJSS.js} +1 -1
- package/dist/{ui-radio.entry-INJVXUKE.js → ui-radio.entry-AKVI5OUS.js} +1 -1
- package/dist/{ui-search-result-row.entry-4J732TDC.js → ui-search-result-row.entry-3BY6GUCL.js} +1 -1
- package/dist/{ui-search-shell.entry-3C2WRVE2.js → ui-search-shell.entry-2Z3GUR2I.js} +1 -1
- package/dist/{ui-select.entry-3ZLDGAKX.js → ui-select.entry-2YQLACCA.js} +1 -1
- package/dist/{ui-switch.entry-5MJRLR2P.js → ui-switch.entry-N5HDUJIW.js} +1 -1
- package/dist/{ui-tabs.entry-F5H7OPBO.js → ui-tabs.entry-FVOVVZOQ.js} +1 -1
- package/dist/{ui-textarea.entry-BNJ375JB.js → ui-textarea.entry-ZFGGCBLG.js} +1 -1
- package/dist/{ui-toast-region.entry-ZUIPJ2JH.js → ui-toast-region.entry-AA2DEUUZ.js} +1 -1
- package/dist/{ui-tooltip.entry-DZ4RMF35.js → ui-tooltip.entry-WN4PYNTZ.js} +1 -1
- package/dist/{ui-top-bar.entry-VKRXIUU6.js → ui-top-bar.entry-ZYYXC7OA.js} +1 -1
- package/dist/{ui-tree-item.entry-NFUQ45OL.js → ui-tree-item.entry-HWCNTX6N.js} +3 -3
- package/dist/{ui-tree.entry-H4CWDYI6.js → ui-tree.entry-6NPGKN5P.js} +45 -19
- package/package.json +1 -1
- package/dist/looma/p-95368dee.entry.js +0 -1
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
getElement,
|
|
8
8
|
h,
|
|
9
9
|
registerInstance
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RLSUA6N5.js";
|
|
11
11
|
|
|
12
12
|
// dist/esm/ui-tree-item.entry.js
|
|
13
13
|
var Bold = [
|
|
@@ -285,7 +285,7 @@ function loomaIconMarkup(name, className = "looma-icon") {
|
|
|
285
285
|
"</svg>"
|
|
286
286
|
].join("");
|
|
287
287
|
}
|
|
288
|
-
var uiTreeItemCss = () => `:host{--ui-tree-indent:16px;--ui-tree-row-min-height:32px;--ui-tree-drop-color:var(--ui-accent-solid);position:relative;display:block;min-inline-size:0;margin-inline-start:calc(var(--ui-tree-item-depth, 0) * var(--ui-tree-indent))}.row{position:relative;display:grid;grid-template-columns:20px auto minmax(0, 1fr) auto;align-items:center;min-block-size:var(--ui-tree-row-min-height);min-inline-size:0;font-size:var(--ui-tree-font-size, var(--ui-font-size-ui, 0.9375rem));border-radius:var(--ui-radius-md);color:var(--ui-text-secondary);transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease), opacity var(--ui-motion-fast) var(--ui-motion-ease), box-shadow var(--ui-motion-fast) var(--ui-motion-ease), min-block-size var(--ui-motion-base) var(--ui-motion-ease)}.row:hover,:host([data-selected]) .row,.row:focus-within{color:var(--ui-text-primary);background:var(--ui-surface-muted)}:host([data-disabled]) .row{opacity:0.55}:host([data-dragging]) .row{opacity:0.42}:host(:focus){outline:none}:host(:focus-visible) .row{box-shadow:0 0 0 2px var(--ui-focus-ring)}:host([data-drop-position='inside']) .row{background:var(--ui-accent-subtle);box-shadow:inset 0 0 0 1px var(--ui-tree-drop-color)}.disclosure,.disclosure-spacer{grid-column:1;grid-row:1;inline-size:20px;block-size:28px}.disclosure{display:grid;place-items:center;padding:0;color:var(--ui-text-muted);background:transparent;border:0;border-radius:var(--ui-radius-sm);cursor:pointer}.disclosure:hover{color:var(--ui-text-primary);background:var(--ui-surface-elevated)}.disclosure-icon{display:block;inline-size:14px;block-size:14px;transform:rotate(-90deg);transition:transform var(--ui-motion-fast) var(--ui-motion-ease)}.disclosure-icon--expanded{transform:rotate(0deg)}.disclosure-icon :is(svg),.drag-handle :is(svg){display:block;inline-size:100%;block-size:100%}.leading{display:none}.leading:has(*){display:inline-grid;place-items:center;grid-column:2;grid-row:1;inline-size:16px;block-size:16px;margin-inline-start:var(--ui-space-1)}.label{grid-column:3;grid-row:1;min-inline-size:0;padding:var(--ui-space-1) var(--ui-space-2)}.actions{grid-column:4;grid-row:1;display:inline-flex;align-items:center;min-inline-size:0}.drag-handle{position:absolute;z-index:2;inset-block-start:50%;inset-inline-start:-22px;inline-size:20px;block-size:32px;display:grid;place-items:center;padding:7px 3px;color:var(--ui-text-muted);background:var(--ui-surface-elevated);border:1px solid transparent;border-radius:var(--ui-radius-sm);cursor:grab;opacity:0;pointer-events:none;transform:translateY(-50%);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease)}.row:hover .drag-handle,.drag-handle:focus-visible,:host([data-dragging]) .drag-handle{opacity:1;pointer-events:auto}.drag-handle:active{cursor:grabbing}.drop-indicator{position:absolute;z-index:3;inset-inline:1px;display:none;block-size:2px;border-radius:999px;background:var(--ui-tree-drop-color);pointer-events:none}.drop-indicator::before,.drop-indicator::after{content:'';position:absolute;inset-block-start:50%;inline-size:7px;block-size:7px;border:2px solid var(--ui-tree-drop-color);border-radius:999px;background:var(--ui-surface-elevated);transform:translateY(-50%)}.drop-indicator::before{inset-inline-start:-1px}.drop-indicator::after{inset-inline-end:-1px}:host([data-drop-position='before']) .drop-indicator{display:block;inset-block-start:-1px}:host([data-drop-position='after']) .drop-indicator{display:block;inset-block-end:-1px}.children[hidden]{display:none}:host-context(html[data-ui-input-modality='touch']){--ui-tree-row-min-height:44px}:host-context(html[data-ui-input-modality='touch']) .drag-handle{display:none}@media (prefers-reduced-motion: reduce){.row,.disclosure-icon,.drag-handle{transition:none}}`;
|
|
288
|
+
var uiTreeItemCss = () => `:host{--ui-tree-indent:16px;--ui-tree-row-min-height:32px;--ui-tree-drop-color:var(--ui-accent-solid);position:relative;display:block;min-inline-size:0;margin-inline-start:calc(var(--ui-tree-item-depth, 0) * var(--ui-tree-indent))}.row{position:relative;display:grid;grid-template-columns:20px auto minmax(0, 1fr) auto;align-items:center;min-block-size:var(--ui-tree-row-min-height);min-inline-size:0;font-size:var(--ui-tree-font-size, var(--ui-font-size-ui, 0.9375rem));border-radius:var(--ui-radius-md);color:var(--ui-text-secondary);transition:background-color var(--ui-motion-fast) var(--ui-motion-ease), color var(--ui-motion-fast) var(--ui-motion-ease), opacity var(--ui-motion-fast) var(--ui-motion-ease), box-shadow var(--ui-motion-fast) var(--ui-motion-ease), min-block-size var(--ui-motion-base) var(--ui-motion-ease)}.row:hover,:host([data-selected]) .row,.row:focus-within{color:var(--ui-text-primary);background:var(--ui-surface-muted)}:host([data-disabled]) .row{opacity:0.55}:host([data-dragging]) .row{opacity:0.42}:host(:focus){outline:none}:host(:focus-visible) .row{box-shadow:0 0 0 2px var(--ui-focus-ring)}:host([data-drop-position='inside']) .row{background:var(--ui-accent-subtle);box-shadow:inset 0 0 0 1px var(--ui-tree-drop-color)}.disclosure,.disclosure-spacer{grid-column:1;grid-row:1;inline-size:20px;block-size:28px}.disclosure{display:grid;place-items:center;padding:0;color:var(--ui-text-muted);background:transparent;border:0;border-radius:var(--ui-radius-sm);cursor:pointer}.disclosure:hover{color:var(--ui-text-primary);background:var(--ui-surface-elevated)}.disclosure-icon{display:block;inline-size:14px;block-size:14px;transform:rotate(-90deg);transition:transform var(--ui-motion-fast) var(--ui-motion-ease)}.disclosure-icon--expanded{transform:rotate(0deg)}.disclosure-icon :is(svg),.drag-handle :is(svg){display:block;inline-size:100%;block-size:100%}.leading{display:none}.leading:has(*){display:inline-grid;place-items:center;grid-column:2;grid-row:1;inline-size:16px;block-size:16px;margin-inline-start:var(--ui-space-1)}.label{grid-column:3;grid-row:1;min-inline-size:0;padding:var(--ui-space-1) var(--ui-space-2)}.actions{grid-column:4;grid-row:1;display:inline-flex;align-items:center;min-inline-size:0}.drag-handle{position:absolute;z-index:2;inset-block-start:50%;inset-inline-start:-22px;inline-size:20px;block-size:32px;display:grid;place-items:center;padding:7px 3px;color:var(--ui-text-muted);background:var(--ui-surface-elevated);border:1px solid transparent;border-radius:var(--ui-radius-sm);cursor:grab;opacity:0;pointer-events:none;transform:translateY(-50%);transition:opacity var(--ui-motion-fast) var(--ui-motion-ease)}.row:hover .drag-handle,.drag-handle:focus-visible,:host([data-dragging]) .drag-handle{opacity:1;pointer-events:auto}.drag-handle:active{cursor:grabbing}.drop-indicator{position:absolute;z-index:3;inset-inline:1px;display:none;block-size:2px;border-radius:999px;background:var(--ui-tree-drop-color);pointer-events:none}.drop-indicator::before,.drop-indicator::after{content:'';position:absolute;inset-block-start:50%;inline-size:7px;block-size:7px;border:2px solid var(--ui-tree-drop-color);border-radius:999px;background:var(--ui-surface-elevated);transform:translateY(-50%)}.drop-indicator::before{inset-inline-start:-1px}.drop-indicator::after{inset-inline-end:-1px}:host([data-drop-position='before']) .row-drop-indicator{display:block;inset-block-start:-1px}:host([data-drop-position='after']) .subtree-drop-indicator{display:block;inset-block-end:-1px}.children[hidden]{display:none}:host-context(html[data-ui-input-modality='touch']){--ui-tree-row-min-height:44px}:host-context(html[data-ui-input-modality='touch']) .drag-handle{display:none}@media (prefers-reduced-motion: reduce){.row,.disclosure-icon,.drag-handle{transition:none}}`;
|
|
289
289
|
var UITreeItem = class {
|
|
290
290
|
constructor(hostRef) {
|
|
291
291
|
registerInstance(this, hostRef);
|
|
@@ -363,7 +363,7 @@ var UITreeItem = class {
|
|
|
363
363
|
return h(Host, { key: "ea8ed538aa3883c87257a25614a066965364693f", role: "treeitem", "aria-level": String(level), "aria-expanded": this.container ? String(this.internalExpanded) : void 0, "aria-selected": String(this.selected), "aria-disabled": this.disabled ? "true" : void 0, "data-container": this.container ? "" : void 0, "data-selected": this.selected ? "" : void 0, "data-disabled": this.disabled ? "" : void 0, "data-drag-type": this.dragType || "item", "data-drop-scope": this.dropScope || void 0, "data-accepts": this.accepts || void 0, tabIndex: this.disabled ? -1 : 0, style: {
|
|
364
364
|
"--ui-tree-item-depth": String(level - 1),
|
|
365
365
|
"margin-inline-start": level > 1 ? "var(--ui-tree-indent, 16px)" : "0px"
|
|
366
|
-
} }, h("div", { key: "740b93aa47e65d8a1cb899d4b9c966d9ad1d456f", class: "row", part: "row", onClick: this.onRowClick }, this.sortable && !this.disabled ? h("button", { class: "drag-handle", part: "drag-handle", type: "button", draggable: true, "aria-label": dragLabel, title: dragLabel }, h("span", { innerHTML: loomaIconMarkup("grip-vertical") })) : null, this.container ? h("button", { class: "disclosure", part: "disclosure", type: "button", "aria-label": disclosureLabel, "aria-expanded": String(this.internalExpanded), disabled: this.disabled, onClick: this.onDisclosureClick, onKeyDown: this.onDisclosureKeydown }, h("span", { class: { "disclosure-icon": true, "disclosure-icon--expanded": this.internalExpanded }, innerHTML: loomaIconMarkup("chevron-down") })) : h("span", { class: "disclosure-spacer", "aria-hidden": "true" }), h("span", { key: "37e1b7f1cdddf623734becef465ffde83d8b86f2", class: "leading", part: "leading" }, h("slot", { key: "0ab3a60c98628f009918d0d720772154912d2709", name: "leading" })), h("span", { key: "defdd343f25a0f4354110e981f3889e1d09c27ee", class: "label", part: "label" }, h("slot", { key: "bde46ccacc1a620348062fc300503c4f1736316b" })), h("span", { key: "caff9ada38c41be90aeb6e331f4c54a51f31d26c", class: "actions", part: "actions" }, h("slot", { key: "e11704d6871445c91eaa29c99302d8b751be69d3", name: "actions" })), h("span", { key: "
|
|
366
|
+
} }, h("div", { key: "740b93aa47e65d8a1cb899d4b9c966d9ad1d456f", class: "row", part: "row", onClick: this.onRowClick }, this.sortable && !this.disabled ? h("button", { class: "drag-handle", part: "drag-handle", type: "button", draggable: true, "aria-label": dragLabel, title: dragLabel }, h("span", { innerHTML: loomaIconMarkup("grip-vertical") })) : null, this.container ? h("button", { class: "disclosure", part: "disclosure", type: "button", "aria-label": disclosureLabel, "aria-expanded": String(this.internalExpanded), disabled: this.disabled, onClick: this.onDisclosureClick, onKeyDown: this.onDisclosureKeydown }, h("span", { class: { "disclosure-icon": true, "disclosure-icon--expanded": this.internalExpanded }, innerHTML: loomaIconMarkup("chevron-down") })) : h("span", { class: "disclosure-spacer", "aria-hidden": "true" }), h("span", { key: "37e1b7f1cdddf623734becef465ffde83d8b86f2", class: "leading", part: "leading" }, h("slot", { key: "0ab3a60c98628f009918d0d720772154912d2709", name: "leading" })), h("span", { key: "defdd343f25a0f4354110e981f3889e1d09c27ee", class: "label", part: "label" }, h("slot", { key: "bde46ccacc1a620348062fc300503c4f1736316b" })), h("span", { key: "caff9ada38c41be90aeb6e331f4c54a51f31d26c", class: "actions", part: "actions" }, h("slot", { key: "e11704d6871445c91eaa29c99302d8b751be69d3", name: "actions" })), h("span", { key: "9efc0e95588f1dd4527dade2b7ff9f2774462c2e", class: "drop-indicator row-drop-indicator", part: "drop-indicator", "aria-hidden": "true" })), this.container ? h("div", { class: "children", part: "children", role: "group", hidden: !this.internalExpanded }, h("slot", { name: "children" })) : null, h("span", { key: "8893ec2c4082bb8af942ef563055a2910d0d4201", class: "drop-indicator subtree-drop-indicator", part: "drop-indicator", "aria-hidden": "true" }));
|
|
367
367
|
}
|
|
368
368
|
static get watchers() {
|
|
369
369
|
return {
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getElement,
|
|
7
7
|
h,
|
|
8
8
|
registerInstance
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RLSUA6N5.js";
|
|
10
10
|
|
|
11
11
|
// dist/esm/ui-tree.entry.js
|
|
12
12
|
function classifyDropPosition(rect, clientY, acceptsChildren) {
|
|
@@ -93,6 +93,17 @@ var UITree = class {
|
|
|
93
93
|
rowFor(item) {
|
|
94
94
|
return item.shadowRoot?.querySelector('[part="row"]') ?? null;
|
|
95
95
|
}
|
|
96
|
+
itemAtPoint(clientX, clientY) {
|
|
97
|
+
let element = this.host.ownerDocument.elementFromPoint(clientX, clientY);
|
|
98
|
+
while (element) {
|
|
99
|
+
if (element.localName === "ui-tree-item" && this.host.contains(element)) {
|
|
100
|
+
return element;
|
|
101
|
+
}
|
|
102
|
+
const root = element.getRootNode();
|
|
103
|
+
element = root instanceof ShadowRoot ? root.host : element.parentElement;
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
96
107
|
acceptsChildren(item) {
|
|
97
108
|
return Boolean(item.container ?? item.hasAttribute("container")) && !Boolean(item.disabled ?? item.hasAttribute("disabled"));
|
|
98
109
|
}
|
|
@@ -192,29 +203,44 @@ var UITree = class {
|
|
|
192
203
|
return;
|
|
193
204
|
this.clearTarget();
|
|
194
205
|
};
|
|
206
|
+
dispatchReorder(source, target, position) {
|
|
207
|
+
const sourceId = this.itemId(source);
|
|
208
|
+
const targetId = this.itemId(target);
|
|
209
|
+
if (!sourceId || !targetId)
|
|
210
|
+
return;
|
|
211
|
+
const sourceMeta = this.itemMetadata(source);
|
|
212
|
+
const targetMeta = this.itemMetadata(target);
|
|
213
|
+
dispatchDetail(this.host, "reorder", {
|
|
214
|
+
sourceId,
|
|
215
|
+
targetId,
|
|
216
|
+
position,
|
|
217
|
+
sourceType: sourceMeta.type,
|
|
218
|
+
targetType: targetMeta.type,
|
|
219
|
+
sourceScope: sourceMeta.scope,
|
|
220
|
+
targetScope: targetMeta.scope,
|
|
221
|
+
trigger: "pointer"
|
|
222
|
+
});
|
|
223
|
+
}
|
|
195
224
|
onDrop = (event) => {
|
|
196
225
|
if (!this.source || !this.target || !this.position)
|
|
197
226
|
return;
|
|
198
227
|
event.preventDefault();
|
|
199
|
-
|
|
200
|
-
const targetId = this.itemId(this.target);
|
|
201
|
-
if (sourceId && targetId) {
|
|
202
|
-
const sourceMeta = this.itemMetadata(this.source);
|
|
203
|
-
const targetMeta = this.itemMetadata(this.target);
|
|
204
|
-
dispatchDetail(this.host, "reorder", {
|
|
205
|
-
sourceId,
|
|
206
|
-
targetId,
|
|
207
|
-
position: this.position,
|
|
208
|
-
sourceType: sourceMeta.type,
|
|
209
|
-
targetType: targetMeta.type,
|
|
210
|
-
sourceScope: sourceMeta.scope,
|
|
211
|
-
targetScope: targetMeta.scope,
|
|
212
|
-
trigger: "pointer"
|
|
213
|
-
});
|
|
214
|
-
}
|
|
228
|
+
this.dispatchReorder(this.source, this.target, this.position);
|
|
215
229
|
this.finishDrag();
|
|
216
230
|
};
|
|
217
|
-
onDragEnd = () => {
|
|
231
|
+
onDragEnd = (event) => {
|
|
232
|
+
if (this.source) {
|
|
233
|
+
const target = this.itemAtPoint(event.clientX, event.clientY);
|
|
234
|
+
if (target && target !== this.source) {
|
|
235
|
+
const row = this.rowFor(target);
|
|
236
|
+
if (row) {
|
|
237
|
+
const position = classifyDropPosition(row.getBoundingClientRect(), event.clientY, this.acceptsChildren(target));
|
|
238
|
+
if (this.permitsDrop(this.source, target, position)) {
|
|
239
|
+
this.dispatchReorder(this.source, target, position);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
218
244
|
this.finishDrag();
|
|
219
245
|
};
|
|
220
246
|
visibleItems() {
|
|
@@ -235,7 +261,7 @@ var UITree = class {
|
|
|
235
261
|
next.focus();
|
|
236
262
|
};
|
|
237
263
|
render() {
|
|
238
|
-
return h(Host, { key: "
|
|
264
|
+
return h(Host, { key: "9668f6170cec944d7b993bf0f98637d8908f5962", role: "tree", "aria-label": this.label || "Tree" }, h("slot", { key: "93140b9a53ca3cddfdc1206e952ca713559dbc2f" }));
|
|
239
265
|
}
|
|
240
266
|
};
|
|
241
267
|
UITree.style = uiTreeCss();
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,g as e,h as i,H as s}from"./p-CEeiinfk.js";import{d as r}from"./p-JwSoedEO.js";const n=class{constructor(e){t(this,e)}get host(){return e(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("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("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}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,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 e=this.itemFromEvent(t);if(!e||!Boolean(e.sortable??e.hasAttribute("sortable"))||Boolean(e.disabled??e.hasAttribute("disabled")))return;if(!t.composedPath().some((t=>t instanceof HTMLElement&&"drag-handle"===t.getAttribute("part"))))return void t.preventDefault();const i=this.itemId(e),s=this.rowFor(e);i&&s?(this.source=e,e.setAttribute("data-dragging","true"),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",i)),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,s)):t.preventDefault()};onDragOver=t=>{if(!this.source)return;const e=this.itemFromEvent(t);if(!e||e===this.source)return void this.clearTarget();const i=this.rowFor(e);if(!i)return;const s=function(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"}(i.getBoundingClientRect(),t.clientY,this.acceptsChildren(e));if(!this.permitsDrop(this.source,e,s))return t.dataTransfer&&(t.dataTransfer.dropEffect="none"),void this.clearTarget();t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this.target===e&&this.position===s||(this.clearTarget(),this.target=e,this.position=s,e.setAttribute("data-drop-position",s)),"inside"===s&&"false"===e.getAttribute("aria-expanded")?this.hoverIntent?.schedule(this.itemId(e)):this.hoverIntent?.cancel()};onDragLeave=t=>{const e=t.relatedTarget;e instanceof Node&&this.host.contains(e)||this.clearTarget()};onDrop=t=>{if(!this.source||!this.target||!this.position)return;t.preventDefault();const e=this.itemId(this.source),i=this.itemId(this.target);if(e&&i){const t=this.itemMetadata(this.source),s=this.itemMetadata(this.target);r(this.host,"reorder",{sourceId:e,targetId:i,position:this.position,sourceType:t.type,targetType:s.type,sourceScope:t.scope,targetScope:s.scope,trigger:"pointer"})}this.finishDrag()};onDragEnd=()=>{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:"5761d2840d2694340a4b937d46522f15f81973ac",role:"tree","aria-label":this.label||"Tree"},i("slot",{key:"08e5a7b489eed4f4eae9de6462104fd12defd336"}))}};n.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{n as ui_tree}
|