@ixfx/components 0.13.0 → 0.13.2
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/bundle/index.d.ts +217 -73
- package/bundle/index.d.ts.map +1 -1
- package/bundle/index.js +375 -13
- package/bundle/index.js.map +1 -1
- package/dist/{button-BYuf72aR.d.ts → button-CTL45aBl.d.ts} +2 -2
- package/dist/{button-BYuf72aR.d.ts.map → button-CTL45aBl.d.ts.map} +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/crumbs.d.ts +2 -2
- package/dist/{data-grid-BJ6XXvRc.d.ts → data-grid-Ck1Qx2H1.d.ts} +4 -4
- package/dist/{data-grid-BJ6XXvRc.d.ts.map → data-grid-Ck1Qx2H1.d.ts.map} +1 -1
- package/dist/data-grid.d.ts +2 -2
- package/dist/{detail-list-B0waVNeS.d.ts → detail-list-C1xzr1z7.d.ts} +4 -4
- package/dist/{detail-list-B0waVNeS.d.ts.map → detail-list-C1xzr1z7.d.ts.map} +1 -1
- package/dist/detail-list.d.ts +3 -3
- package/dist/editable-label-rzXkjf1H.d.ts.map +1 -1
- package/dist/editable-label.js +2 -2
- package/dist/editable-label.js.map +1 -1
- package/dist/{flat-list-eYItri8-.d.ts → flat-list-Ohxqsy0g.d.ts} +63 -5
- package/dist/flat-list-Ohxqsy0g.d.ts.map +1 -0
- package/dist/flat-list.d.ts +2 -2
- package/dist/flat-list.js +172 -9
- package/dist/flat-list.js.map +1 -1
- package/dist/{grid-list-_gI9ckcT.d.ts → grid-list-pefLORIr.d.ts} +4 -4
- package/dist/{grid-list-_gI9ckcT.d.ts.map → grid-list-pefLORIr.d.ts.map} +1 -1
- package/dist/grid-list.d.ts +2 -2
- package/dist/incr-search.d.ts +1 -1
- package/dist/{index-BvxHQUME.d.ts → index-CxZ61DO1.d.ts} +3 -3
- package/dist/{index-BvxHQUME.d.ts.map → index-CxZ61DO1.d.ts.map} +1 -1
- package/dist/{index-CW2QL33o.d.ts → index-Dq30pOnn.d.ts} +2 -2
- package/dist/{index-CW2QL33o.d.ts.map → index-Dq30pOnn.d.ts.map} +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/{list-native-drag-controller-CllsHLxw.d.ts → list-native-drag-controller-ChIi3eK5.d.ts} +2 -2
- package/dist/{list-native-drag-controller-CllsHLxw.d.ts.map → list-native-drag-controller-ChIi3eK5.d.ts.map} +1 -1
- package/dist/menu.d.ts +1 -1
- package/dist/miller.d.ts +3 -3
- package/dist/{tree-component-DukLqesg.d.ts → tree-component-Cj8V3uar.d.ts} +2 -2
- package/dist/{tree-component-DukLqesg.d.ts.map → tree-component-Cj8V3uar.d.ts.map} +1 -1
- package/dist/tree.d.ts +4 -4
- package/dist/{types-D-kYF16b.d.ts → types-DQ7KOUIj.d.ts} +6 -1
- package/dist/types-DQ7KOUIj.d.ts.map +1 -0
- package/dist/{vertical-list-DheZSEmB.d.ts → vertical-list-CqBc-t8w.d.ts} +86 -4
- package/dist/vertical-list-CqBc-t8w.d.ts.map +1 -0
- package/dist/vertical-list.d.ts +3 -3
- package/dist/vertical-list.js +202 -2
- package/dist/vertical-list.js.map +1 -1
- package/docs-user/flat-list.md +45 -3
- package/docs-user/index.json +2 -2
- package/docs-user/vertical-list.md +59 -3
- package/package.json +1 -1
- package/dist/flat-list-eYItri8-.d.ts.map +0 -1
- package/dist/types-D-kYF16b.d.ts.map +0 -1
- package/dist/vertical-list-DheZSEmB.d.ts.map +0 -1
package/dist/vertical-list.js
CHANGED
|
@@ -7,6 +7,7 @@ import { r as ListDragSelectController, t as ListSelectionController } from "./l
|
|
|
7
7
|
import { n as animateListItemIn, r as animateListItemOut } from "./list-item-animation-BUoEKi5s.js";
|
|
8
8
|
import { t as scrollFadeStyles } from "./scroll-fade-BrNUIYnm.js";
|
|
9
9
|
import { n as appearanceColor, t as appearanceAbsent } from "./item-appearance-BjcMyauw.js";
|
|
10
|
+
import "./editable-label.js";
|
|
10
11
|
import { LitElement, css, html, render } from "lit";
|
|
11
12
|
import { property } from "lit/decorators.js";
|
|
12
13
|
import { createCommandRegistry } from "@clinth/ui-commands";
|
|
@@ -43,6 +44,7 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
43
44
|
this.keyProperty = ``;
|
|
44
45
|
this.virtualize = false;
|
|
45
46
|
this.itemHeight = 0;
|
|
47
|
+
this.itemsDroppable = false;
|
|
46
48
|
this.#customWrappers = /* @__PURE__ */ new Map();
|
|
47
49
|
this.#wrappedElements = /* @__PURE__ */ new Set();
|
|
48
50
|
this.#itemData = /* @__PURE__ */ new WeakMap();
|
|
@@ -162,7 +164,16 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
162
164
|
this.tickled.handlePointerLeave(e);
|
|
163
165
|
};
|
|
164
166
|
this._onKeyDown = (e) => {
|
|
165
|
-
if (this.search.isOpen) return;
|
|
167
|
+
if (this.search.isOpen || this.#isEditEvent(e)) return;
|
|
168
|
+
if (e.key === `ContextMenu` || e.shiftKey && e.key === `F10`) {
|
|
169
|
+
const id = this.tickled.tickledId;
|
|
170
|
+
if (id) {
|
|
171
|
+
e.preventDefault();
|
|
172
|
+
const rect = id.getBoundingClientRect();
|
|
173
|
+
this.#requestContextMenu(id, rect.left, rect.bottom);
|
|
174
|
+
}
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
166
177
|
if ((e.ctrlKey || e.metaKey) && e.key === `a`) {
|
|
167
178
|
if (this.selection.canSelectAll()) {
|
|
168
179
|
e.preventDefault();
|
|
@@ -216,6 +227,7 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
216
227
|
}
|
|
217
228
|
};
|
|
218
229
|
this._onClick = (e) => {
|
|
230
|
+
if (this.#isEditEvent(e)) return;
|
|
219
231
|
if (this.#dragSelect.isDragging || this.#nativeDrag.isDragging || this.#postDragSuppressTimer !== 0) return;
|
|
220
232
|
const item = this._findListItem(e.composedPath());
|
|
221
233
|
if (!item) return;
|
|
@@ -223,9 +235,60 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
223
235
|
this.selection.handleClick(item, e);
|
|
224
236
|
};
|
|
225
237
|
this._onDblClick = (e) => {
|
|
238
|
+
if (this.#isEditEvent(e)) return;
|
|
226
239
|
const item = this._findListItem(e.composedPath());
|
|
227
240
|
if (item) this._activateItem(item);
|
|
228
241
|
};
|
|
242
|
+
this._onDragOver = (e) => {
|
|
243
|
+
const dt = e.dataTransfer;
|
|
244
|
+
if (!this.itemsDroppable || !dt || this.#isEditEvent(e)) return;
|
|
245
|
+
const item = this._findListItem(e.composedPath());
|
|
246
|
+
if (this.canDrop && !this.canDrop(item, dt)) {
|
|
247
|
+
this.#clearDropTarget();
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (this.#dragOver && this.#dragOver.item !== item) this.#clearDropTarget();
|
|
251
|
+
this.#dragOver = { item };
|
|
252
|
+
if (!!this._dispatchCancelable(`list-drag-over`, {
|
|
253
|
+
key: item ? keyForElement(item) : void 0,
|
|
254
|
+
item,
|
|
255
|
+
dataTransfer: dt
|
|
256
|
+
})) {
|
|
257
|
+
this.#highlightDropTarget(void 0, false);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
e.preventDefault();
|
|
261
|
+
if (dt.dropEffect === `none`) dt.dropEffect = `copy`;
|
|
262
|
+
this.#highlightDropTarget(item, true);
|
|
263
|
+
};
|
|
264
|
+
this._onDragLeave = (e) => {
|
|
265
|
+
const next = e.relatedTarget;
|
|
266
|
+
if (next instanceof Node && this.contains(next)) return;
|
|
267
|
+
this.#clearDropTarget();
|
|
268
|
+
};
|
|
269
|
+
this._onDrop = (e) => {
|
|
270
|
+
const dt = e.dataTransfer;
|
|
271
|
+
if (!this.itemsDroppable || !dt || this.#isEditEvent(e)) return;
|
|
272
|
+
const item = this._findListItem(e.composedPath());
|
|
273
|
+
if (this.canDrop && !this.canDrop(item, dt)) {
|
|
274
|
+
this.#clearDropTarget();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
e.preventDefault();
|
|
278
|
+
this.#dragOver = void 0;
|
|
279
|
+
this.#highlightDropTarget(void 0, false);
|
|
280
|
+
this._dispatch(`list-drop`, {
|
|
281
|
+
key: item ? keyForElement(item) : void 0,
|
|
282
|
+
item,
|
|
283
|
+
dataTransfer: dt
|
|
284
|
+
});
|
|
285
|
+
};
|
|
286
|
+
this._onContextMenu = (e) => {
|
|
287
|
+
if (this.#isEditEvent(e)) return;
|
|
288
|
+
const item = this._findListItem(e.composedPath());
|
|
289
|
+
if (!item) return;
|
|
290
|
+
if (!this.#requestContextMenu(item, e.clientX, e.clientY)) e.preventDefault();
|
|
291
|
+
};
|
|
229
292
|
}
|
|
230
293
|
#customWrappers;
|
|
231
294
|
#wrappedElements;
|
|
@@ -352,6 +415,10 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
352
415
|
this.addEventListener(`keydown`, this._onKeyDown);
|
|
353
416
|
this.addEventListener(`click`, this._onClick);
|
|
354
417
|
this.addEventListener(`dblclick`, this._onDblClick);
|
|
418
|
+
this.addEventListener(`dragover`, this._onDragOver);
|
|
419
|
+
this.addEventListener(`dragleave`, this._onDragLeave);
|
|
420
|
+
this.addEventListener(`drop`, this._onDrop);
|
|
421
|
+
this.addEventListener(`contextmenu`, this._onContextMenu);
|
|
355
422
|
for (const el of this.querySelectorAll(ITEM_SELECTOR)) this.#animatedItems.add(el);
|
|
356
423
|
this.#itemObserver ??= new MutationObserver((records) => this.#onItemsMutated(records));
|
|
357
424
|
this.#itemObserver.observe(this, { childList: true });
|
|
@@ -366,6 +433,12 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
366
433
|
this.removeEventListener(`keydown`, this._onKeyDown);
|
|
367
434
|
this.removeEventListener(`click`, this._onClick);
|
|
368
435
|
this.removeEventListener(`dblclick`, this._onDblClick);
|
|
436
|
+
this.removeEventListener(`dragover`, this._onDragOver);
|
|
437
|
+
this.removeEventListener(`dragleave`, this._onDragLeave);
|
|
438
|
+
this.removeEventListener(`drop`, this._onDrop);
|
|
439
|
+
this.removeEventListener(`contextmenu`, this._onContextMenu);
|
|
440
|
+
this.#clearDropTarget();
|
|
441
|
+
this.#edit = void 0;
|
|
369
442
|
this.#itemObserver?.disconnect();
|
|
370
443
|
this.#resizeObserver?.disconnect();
|
|
371
444
|
this.#resizeObserver = void 0;
|
|
@@ -1052,7 +1125,7 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
1052
1125
|
}
|
|
1053
1126
|
/** Per-attach state the attached sweep can't cover (it only sees the window). */
|
|
1054
1127
|
#applyRowState(el) {
|
|
1055
|
-
if (el instanceof HTMLElement) el.draggable = this.itemsDraggable && this._isCheckable(el);
|
|
1128
|
+
if (el instanceof HTMLElement) el.draggable = this.itemsDraggable && this._isCheckable(el) && !el.hasAttribute(`data-editing`);
|
|
1056
1129
|
el.removeAttribute(`data-marquee`);
|
|
1057
1130
|
el.removeAttribute(`data-drag-origin`);
|
|
1058
1131
|
}
|
|
@@ -1262,6 +1335,114 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
1262
1335
|
if (this.interactionMode !== `manual`) this.selection.replace(item);
|
|
1263
1336
|
this._dispatch(`list-activate`, { item });
|
|
1264
1337
|
}
|
|
1338
|
+
/** The row (or `undefined` for empty space) the last `list-drag-over` was fired for. */
|
|
1339
|
+
#dragOver;
|
|
1340
|
+
/** Tell the consumer the drag left its last target and drop the highlight. */
|
|
1341
|
+
#clearDropTarget() {
|
|
1342
|
+
const last = this.#dragOver;
|
|
1343
|
+
this.#dragOver = void 0;
|
|
1344
|
+
this.#highlightDropTarget(void 0, false);
|
|
1345
|
+
if (last) this._dispatch(`list-drag-leave`, { key: last.item ? keyForElement(last.item) : void 0 });
|
|
1346
|
+
}
|
|
1347
|
+
/** Mark one row (or, for empty space, the host) as the drop target. */
|
|
1348
|
+
#highlightDropTarget(item, active) {
|
|
1349
|
+
for (const el of this.querySelectorAll(`[data-drop-target]`)) el.removeAttribute(`data-drop-target`);
|
|
1350
|
+
this.toggleAttribute(`data-drop-target`, active && item === void 0);
|
|
1351
|
+
if (active && item) item.setAttribute(`data-drop-target`, ``);
|
|
1352
|
+
}
|
|
1353
|
+
/**
|
|
1354
|
+
* Select the row if it is not already, then fire `list-context-menu`.
|
|
1355
|
+
* Returns false when a listener cancelled it (the native menu is then suppressed).
|
|
1356
|
+
*/
|
|
1357
|
+
#requestContextMenu(item, x, y) {
|
|
1358
|
+
if (!this.selection.selected.has(item) && this.interactionMode !== `manual` && this._isCheckable(item)) this.selection.replace(item);
|
|
1359
|
+
return this._dispatchCancelable(`list-context-menu`, {
|
|
1360
|
+
key: keyForElement(item),
|
|
1361
|
+
item,
|
|
1362
|
+
x,
|
|
1363
|
+
y,
|
|
1364
|
+
selectedKeys: this.selection.selectedKeys
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
#edit;
|
|
1368
|
+
/** The key of the row being edited, if any. */
|
|
1369
|
+
get editingKey() {
|
|
1370
|
+
return this.#edit?.key;
|
|
1371
|
+
}
|
|
1372
|
+
#isEditEvent(e) {
|
|
1373
|
+
return this.#edit !== void 0 && e.composedPath().includes(this.#edit.label);
|
|
1374
|
+
}
|
|
1375
|
+
/**
|
|
1376
|
+
* Edit a row's label in place with an `ixfx-editable-label`. The editor
|
|
1377
|
+
* replaces the row's `[data-edit-label]` element (else the whole row) and
|
|
1378
|
+
* the original content returns when editing ends. Fires `list-edit-commit`
|
|
1379
|
+
* `{ key, value }` when the text changed, otherwise `list-edit-cancel`
|
|
1380
|
+
* `{ key }` (Escape, an unchanged value, or one the label rejects). The list
|
|
1381
|
+
* never rewrites the label itself — update your data in response.
|
|
1382
|
+
*
|
|
1383
|
+
* Returns false when `editValidator` is not set, or the row is unknown or
|
|
1384
|
+
* not currently rendered.
|
|
1385
|
+
*/
|
|
1386
|
+
beginEdit(key) {
|
|
1387
|
+
this.#finishEdit();
|
|
1388
|
+
const validate = this.editValidator;
|
|
1389
|
+
if (!validate) return false;
|
|
1390
|
+
const row = this.#itemForKey(key);
|
|
1391
|
+
if (!(row instanceof HTMLElement) || row.parentNode !== this) return false;
|
|
1392
|
+
const container = row.querySelector(`[data-edit-label]`) ?? row;
|
|
1393
|
+
const value = container.getAttribute(`data-edit-value`) ?? container.textContent?.trim() ?? ``;
|
|
1394
|
+
const label = document.createElement(`ixfx-editable-label`);
|
|
1395
|
+
label.mode = `label`;
|
|
1396
|
+
label.value = value;
|
|
1397
|
+
label.validator = (text) => validate(text, key);
|
|
1398
|
+
label.style.cssText = `flex:1;min-width:0;--label-align:left;--label-padding:0 var(--space-xs,3px)`;
|
|
1399
|
+
const edit = {
|
|
1400
|
+
key,
|
|
1401
|
+
row,
|
|
1402
|
+
container,
|
|
1403
|
+
saved: [...container.childNodes],
|
|
1404
|
+
label,
|
|
1405
|
+
committed: void 0,
|
|
1406
|
+
refocus: false
|
|
1407
|
+
};
|
|
1408
|
+
this.#edit = edit;
|
|
1409
|
+
label.addEventListener(`change`, (e) => {
|
|
1410
|
+
e.stopPropagation();
|
|
1411
|
+
edit.committed = e.detail.value;
|
|
1412
|
+
});
|
|
1413
|
+
label.addEventListener(`input`, (e) => e.stopPropagation());
|
|
1414
|
+
label.addEventListener(`keydown`, (e) => {
|
|
1415
|
+
edit.refocus = e.key === `Enter` || e.key === `Escape`;
|
|
1416
|
+
});
|
|
1417
|
+
for (const type of [`pointerdown`, `dragstart`]) label.addEventListener(type, (e) => e.stopPropagation());
|
|
1418
|
+
label.addEventListener(`focusout`, () => this.#finishEdit());
|
|
1419
|
+
container.replaceChildren(label);
|
|
1420
|
+
row.setAttribute(`data-editing`, ``);
|
|
1421
|
+
row.draggable = false;
|
|
1422
|
+
row.scrollIntoView({
|
|
1423
|
+
block: `nearest`,
|
|
1424
|
+
inline: `nearest`
|
|
1425
|
+
});
|
|
1426
|
+
label.updateComplete.then(() => {
|
|
1427
|
+
if (this.#edit === edit) label.shadowRoot?.querySelector(`.content`)?.click();
|
|
1428
|
+
});
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
/** Restore the row's content and report how the edit ended. */
|
|
1432
|
+
#finishEdit() {
|
|
1433
|
+
const edit = this.#edit;
|
|
1434
|
+
if (!edit) return;
|
|
1435
|
+
this.#edit = void 0;
|
|
1436
|
+
if (edit.container.isConnected) edit.container.replaceChildren(...edit.saved);
|
|
1437
|
+
edit.row.removeAttribute(`data-editing`);
|
|
1438
|
+
this.#applyRowState(edit.row);
|
|
1439
|
+
if (edit.refocus) this.focus();
|
|
1440
|
+
if (edit.committed === void 0) this._dispatch(`list-edit-cancel`, { key: edit.key });
|
|
1441
|
+
else this._dispatch(`list-edit-commit`, {
|
|
1442
|
+
key: edit.key,
|
|
1443
|
+
value: edit.committed
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1265
1446
|
static {
|
|
1266
1447
|
this.styles = [
|
|
1267
1448
|
themeFallbacks,
|
|
@@ -1422,6 +1603,18 @@ let VerticalListElement = class VerticalListElement extends LitElement {
|
|
|
1422
1603
|
opacity: 0.6;
|
|
1423
1604
|
}
|
|
1424
1605
|
|
|
1606
|
+
/* Native drop target: the row under a drag, or the whole list over empty space. */
|
|
1607
|
+
::slotted([data-drop-target]) {
|
|
1608
|
+
background: var(--list-drop-target-bg, color-mix(in srgb, var(--accent) 25%, transparent));
|
|
1609
|
+
outline: 2px solid var(--list-drop-target-outline, var(--accent));
|
|
1610
|
+
outline-offset: -2px;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
:host([data-drop-target]) {
|
|
1614
|
+
outline: 2px solid var(--list-drop-target-outline, var(--accent));
|
|
1615
|
+
outline-offset: -2px;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1425
1618
|
/* checked mode: checkbox (injected into li) communicates selection — suppress bg highlight */
|
|
1426
1619
|
:host([interaction-mode="checked"]) ::slotted([data-selected]) {
|
|
1427
1620
|
background: transparent;
|
|
@@ -1494,6 +1687,13 @@ __decorate([property({
|
|
|
1494
1687
|
type: Number,
|
|
1495
1688
|
attribute: `item-height`
|
|
1496
1689
|
})], VerticalListElement.prototype, "itemHeight", void 0);
|
|
1690
|
+
__decorate([property({
|
|
1691
|
+
type: Boolean,
|
|
1692
|
+
attribute: `items-droppable`,
|
|
1693
|
+
reflect: true
|
|
1694
|
+
})], VerticalListElement.prototype, "itemsDroppable", void 0);
|
|
1695
|
+
__decorate([property({ attribute: false })], VerticalListElement.prototype, "editValidator", void 0);
|
|
1696
|
+
__decorate([property({ attribute: false })], VerticalListElement.prototype, "canDrop", void 0);
|
|
1497
1697
|
VerticalListElement = __decorate([safeCustomElement(`ixfx-vertical-list`)], VerticalListElement);
|
|
1498
1698
|
//#endregion
|
|
1499
1699
|
export { VerticalListElement };
|