@ixfx/components 0.14.7 → 0.15.1
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 +102 -3
- package/bundle/index.js +574 -247
- package/bundle/style.css +2 -82
- package/dist/{button-BYuf72aR.d.ts → button-N92DKoWb.d.ts} +7 -0
- package/dist/{button-B7mgqtxR.js → button-ikByJJPN.js} +29 -8
- package/dist/button.d.ts +1 -1
- package/dist/button.js +1 -1
- package/dist/{colour-picker-BCMU7W7R.js → colour-picker-DwAa6RDh.js} +73 -9
- package/dist/colour-picker.d.ts +1 -1
- package/dist/colour-picker.js +1 -1
- package/dist/form-BGZK3jZd.d.ts +54 -0
- package/dist/form-CY0nibZ5.js +418 -0
- package/dist/form.d.ts +1 -13
- package/dist/form.js +1 -1
- package/dist/{index-tq6f8007.d.ts → index-DN2BWctP.d.ts} +3 -0
- package/dist/index.d.ts +54 -6
- package/dist/index.js +138 -8
- package/dist/style.css +2 -82
- package/dist/{tab-list-CexFFg6O.d.ts → tab-list-Df371rqw.d.ts} +1 -0
- package/dist/tab-list-R_bGbDvO.js +766 -0
- package/dist/tabs.d.ts +1 -1
- package/dist/tabs.js +1 -673
- package/docs-user/button.md +1 -0
- package/docs-user/colour-picker.md +19 -0
- package/docs-user/form.md +97 -4
- package/docs-user/index.json +2 -2
- package/docs-user/multicol-list.md +1 -1
- package/docs-user/tabs.md +30 -0
- package/package.json +2 -1
- package/dist/form-CsXJX15p.js +0 -62
package/dist/tabs.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as TabListReorderDetail, i as TabListElement, n as TabListChangeEvent, o as TabListReorderEvent, r as TabListDragMode, t as TabListChangeDetail } from "./tab-list-
|
|
1
|
+
import { a as TabListReorderDetail, i as TabListElement, n as TabListChangeEvent, o as TabListReorderEvent, r as TabListDragMode, t as TabListChangeDetail } from "./tab-list-Df371rqw.js";
|
|
2
2
|
export { TabListChangeDetail, TabListChangeEvent, TabListDragMode, TabListElement, TabListReorderDetail, TabListReorderEvent };
|
package/dist/tabs.js
CHANGED
|
@@ -1,674 +1,2 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { n as safeCustomElement, t as __decorate } from "./decorate-VRK8rslU.js";
|
|
3
|
-
import { t as scrollFadeStyles } from "./scroll-fade-Xx28D7mH.js";
|
|
4
|
-
import { t as createDragGhost } from "./drag-ghost-DtSDvjri.js";
|
|
5
|
-
import { LitElement, css, html, nothing } from "lit";
|
|
6
|
-
import { property } from "lit/decorators.js";
|
|
7
|
-
//#region src/tabs/tab-list.ts
|
|
8
|
-
/** Pointer movement threshold (px) before a press becomes a drag. */
|
|
9
|
-
const DRAG_THRESHOLD_PX = 5;
|
|
10
|
-
let TabListElement = class TabListElement extends LitElement {
|
|
11
|
-
constructor(..._args) {
|
|
12
|
-
super(..._args);
|
|
13
|
-
this.orientation = `horizontal`;
|
|
14
|
-
this.flip = false;
|
|
15
|
-
this.scrollable = false;
|
|
16
|
-
this.hideLabels = false;
|
|
17
|
-
this.labelNogrow = false;
|
|
18
|
-
this.shrink = false;
|
|
19
|
-
this.dragMode = `off`;
|
|
20
|
-
this.#items = [];
|
|
21
|
-
this.#dragState = null;
|
|
22
|
-
this.#suppressNextClick = false;
|
|
23
|
-
this.#onSlotChange = () => {
|
|
24
|
-
this.updateComplete.then(() => {
|
|
25
|
-
this.#refreshItems();
|
|
26
|
-
this.#syncIndicatorColors();
|
|
27
|
-
this.#syncHideLabels();
|
|
28
|
-
this.#syncLabelNogrow();
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
this.#onToolbarSlotChange = () => {
|
|
32
|
-
const assigned = (this.shadowRoot?.querySelector(`slot[name="toolbar"]`))?.assignedElements() ?? [];
|
|
33
|
-
const has = assigned.length > 0;
|
|
34
|
-
this.toggleAttribute(`has-toolbar`, has);
|
|
35
|
-
const toolbarDiv = this.shadowRoot?.querySelector(`.list-toolbar`);
|
|
36
|
-
if (toolbarDiv) toolbarDiv.hidden = !has;
|
|
37
|
-
if (has) {
|
|
38
|
-
const toolbar = assigned[0];
|
|
39
|
-
if (toolbar?.tagName === `IXFX-TOOLBAR`) requestAnimationFrame(() => {
|
|
40
|
-
toolbar?._scheduleMeasure?.();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
this.#onKeyUp = (event) => {
|
|
45
|
-
const key = event.key;
|
|
46
|
-
if (this.#isVertical) {
|
|
47
|
-
if (key === `ArrowUp`) this.#selectPrevious();
|
|
48
|
-
else if (key === `ArrowDown`) this.#selectNext();
|
|
49
|
-
} else if (key === `ArrowRight`) this.#selectNext();
|
|
50
|
-
else if (key === `ArrowLeft`) this.#selectPrevious();
|
|
51
|
-
};
|
|
52
|
-
this.#onKeyDown = (event) => {
|
|
53
|
-
const state = this.#dragState;
|
|
54
|
-
if (event.key !== `Escape` || !state?.active) return;
|
|
55
|
-
event.preventDefault();
|
|
56
|
-
const pointerId = state.pointerId;
|
|
57
|
-
this.#abortDrag();
|
|
58
|
-
this.#endDrag(pointerId);
|
|
59
|
-
};
|
|
60
|
-
this.#onWheel = (event) => {
|
|
61
|
-
if (!this.scrollable) return;
|
|
62
|
-
const el = this.#containerEl;
|
|
63
|
-
if (!el) return;
|
|
64
|
-
if (!this.#isVertical) {
|
|
65
|
-
if (event.deltaY === 0 || el.scrollWidth <= el.clientWidth) return;
|
|
66
|
-
el.scrollLeft = el.scrollLeft + event.deltaY;
|
|
67
|
-
event.preventDefault();
|
|
68
|
-
} else {
|
|
69
|
-
if (event.deltaX === 0 || el.scrollHeight <= el.clientHeight) return;
|
|
70
|
-
el.scrollTop = el.scrollTop + event.deltaX;
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
this.#onSlotClick = (event) => {
|
|
75
|
-
if (this.#suppressNextClick) {
|
|
76
|
-
this.#suppressNextClick = false;
|
|
77
|
-
event.preventDefault();
|
|
78
|
-
event.stopPropagation();
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
this.focus();
|
|
82
|
-
const t = event.target.closest(`ixfx-tab-list-item`);
|
|
83
|
-
if (!t) return;
|
|
84
|
-
const previous = this.getSelectedElement();
|
|
85
|
-
this.selectElement(t);
|
|
86
|
-
const forId = t.getAttribute(`for`);
|
|
87
|
-
const previousId = previous?.id;
|
|
88
|
-
this.dispatchEvent(new CustomEvent(`change`, {
|
|
89
|
-
bubbles: true,
|
|
90
|
-
detail: {
|
|
91
|
-
previous: previousId,
|
|
92
|
-
selected: t.id,
|
|
93
|
-
for: forId ?? ``
|
|
94
|
-
}
|
|
95
|
-
}));
|
|
96
|
-
};
|
|
97
|
-
this.#onPointerDown = (event) => {
|
|
98
|
-
if (this.dragMode !== `reorder`) return;
|
|
99
|
-
if (event.button !== 0) return;
|
|
100
|
-
const target = this.#findDragTarget(event);
|
|
101
|
-
if (!target) return;
|
|
102
|
-
const fromIndex = this.#items.indexOf(target);
|
|
103
|
-
if (fromIndex < 0) return;
|
|
104
|
-
this.#dragState = {
|
|
105
|
-
pointerId: event.pointerId,
|
|
106
|
-
source: target,
|
|
107
|
-
fromIndex,
|
|
108
|
-
startX: event.clientX,
|
|
109
|
-
startY: event.clientY,
|
|
110
|
-
active: false,
|
|
111
|
-
ghost: null,
|
|
112
|
-
gapIndex: void 0
|
|
113
|
-
};
|
|
114
|
-
window.addEventListener(`pointermove`, this.#onPointerMove);
|
|
115
|
-
window.addEventListener(`pointerup`, this.#onPointerUp);
|
|
116
|
-
window.addEventListener(`pointercancel`, this.#onPointerCancel);
|
|
117
|
-
};
|
|
118
|
-
this.#pendingMove = null;
|
|
119
|
-
this.#moveRaf = null;
|
|
120
|
-
this.#onPointerMove = (event) => {
|
|
121
|
-
const state = this.#dragState;
|
|
122
|
-
if (!state || event.pointerId !== state.pointerId) return;
|
|
123
|
-
this.#pendingMove = event;
|
|
124
|
-
this.#moveRaf ??= requestAnimationFrame(this.#flushMove);
|
|
125
|
-
};
|
|
126
|
-
this.#flushMove = () => {
|
|
127
|
-
const event = this.#pendingMove;
|
|
128
|
-
this.#pendingMove = null;
|
|
129
|
-
this.#moveRaf = null;
|
|
130
|
-
const state = this.#dragState;
|
|
131
|
-
if (!state || !event) return;
|
|
132
|
-
const dx = event.clientX - state.startX;
|
|
133
|
-
const dy = event.clientY - state.startY;
|
|
134
|
-
const distance = Math.hypot(dx, dy);
|
|
135
|
-
if (!state.active) {
|
|
136
|
-
if (distance < DRAG_THRESHOLD_PX) return;
|
|
137
|
-
this.#beginDrag(event);
|
|
138
|
-
}
|
|
139
|
-
state.ghost?.move(event.clientX, event.clientY);
|
|
140
|
-
const gap = this.#computeGapIndex(event.clientX, event.clientY);
|
|
141
|
-
if (gap !== state.gapIndex) {
|
|
142
|
-
state.gapIndex = gap;
|
|
143
|
-
this.requestUpdate();
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
this.#onPointerUp = (event) => {
|
|
147
|
-
const state = this.#dragState;
|
|
148
|
-
if (!state || event.pointerId !== state.pointerId) return;
|
|
149
|
-
if (state.active) {
|
|
150
|
-
const gap = this.#computeGapIndex(event.clientX, event.clientY);
|
|
151
|
-
this.#commitDrag(state.source, state.fromIndex, gap);
|
|
152
|
-
}
|
|
153
|
-
this.#endDrag(event.pointerId);
|
|
154
|
-
};
|
|
155
|
-
this.#onPointerCancel = (event) => {
|
|
156
|
-
const state = this.#dragState;
|
|
157
|
-
if (!state || event.pointerId !== state.pointerId) return;
|
|
158
|
-
this.#abortDrag();
|
|
159
|
-
this.#endDrag(event.pointerId);
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
#items;
|
|
163
|
-
#dragState;
|
|
164
|
-
#suppressNextClick;
|
|
165
|
-
get #isVertical() {
|
|
166
|
-
return this.orientation === `vertical-stack` || this.orientation === `vertical-side`;
|
|
167
|
-
}
|
|
168
|
-
get #containerClass() {
|
|
169
|
-
return [
|
|
170
|
-
this.scrollable ? `${this.orientation} scrollable` : this.orientation,
|
|
171
|
-
this.scrollable ? this.#isVertical ? `scroll-fade-y` : `scroll-fade-x` : ``,
|
|
172
|
-
this.dragMode === `reorder` ? `reorder` : ``
|
|
173
|
-
].filter(Boolean).join(` `);
|
|
174
|
-
}
|
|
175
|
-
render() {
|
|
176
|
-
const caretStyle = this.#computeCaretStyle();
|
|
177
|
-
return html`
|
|
178
|
-
<div class="outer ${this.orientation}">
|
|
179
|
-
<div
|
|
180
|
-
tabindex=0
|
|
181
|
-
@keyup=${this.#onKeyUp}
|
|
182
|
-
@click=${this.#onSlotClick}
|
|
183
|
-
@pointerdown=${this.#onPointerDown}
|
|
184
|
-
@keydown=${this.#onKeyDown}
|
|
185
|
-
@wheel=${this.#onWheel}
|
|
186
|
-
id="container"
|
|
187
|
-
class=${this.#containerClass}
|
|
188
|
-
>
|
|
189
|
-
<slot @slotchange=${this.#onSlotChange}></slot>
|
|
190
|
-
${caretStyle ? html`<div class="drop-caret" style=${caretStyle}></div>` : nothing}
|
|
191
|
-
</div>
|
|
192
|
-
<div class="list-toolbar ${this.orientation}" part="list-toolbar">
|
|
193
|
-
<slot name="toolbar" @slotchange=${this.#onToolbarSlotChange}></slot>
|
|
194
|
-
</div>
|
|
195
|
-
</div>`;
|
|
196
|
-
}
|
|
197
|
-
#onSlotChange;
|
|
198
|
-
/**
|
|
199
|
-
* Re-read the assigned tab items. Some environments do not fire slotchange
|
|
200
|
-
* for a slot's initial assignment, so firstUpdated also calls this before
|
|
201
|
-
* syncing item attributes.
|
|
202
|
-
*/
|
|
203
|
-
#refreshItems() {
|
|
204
|
-
this.#items = (this.shadowRoot?.querySelector(`slot:not([name])`))?.assignedElements({ flatten: true }) ?? [];
|
|
205
|
-
}
|
|
206
|
-
#onToolbarSlotChange;
|
|
207
|
-
firstUpdated() {
|
|
208
|
-
this.updateComplete.then(() => {
|
|
209
|
-
this.#refreshItems();
|
|
210
|
-
this.#syncIndicatorColors();
|
|
211
|
-
this.#syncHideLabels();
|
|
212
|
-
this.#syncLabelNogrow();
|
|
213
|
-
this.#onToolbarSlotChange();
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
updated(changedProperties) {
|
|
217
|
-
super.updated(changedProperties);
|
|
218
|
-
this.classList.toggle(`scrollable`, this.scrollable);
|
|
219
|
-
if (changedProperties.has(`dragMode`)) this.toggleAttribute(`drag-mode`, this.dragMode !== `off`);
|
|
220
|
-
if (changedProperties.has(`hideLabels`)) this.#syncHideLabels();
|
|
221
|
-
if (changedProperties.has(`labelNogrow`)) this.#syncLabelNogrow();
|
|
222
|
-
}
|
|
223
|
-
#syncHideLabels() {
|
|
224
|
-
for (const item of this.#items) if (this.hideLabels) item.setAttribute(`hide-labels`, ``);
|
|
225
|
-
else item.removeAttribute(`hide-labels`);
|
|
226
|
-
}
|
|
227
|
-
#syncLabelNogrow() {
|
|
228
|
-
for (const item of this.#items) if (this.labelNogrow) item.setAttribute(`label-nogrow`, ``);
|
|
229
|
-
else item.removeAttribute(`label-nogrow`);
|
|
230
|
-
}
|
|
231
|
-
#syncIndicatorColors() {
|
|
232
|
-
for (const item of this.#items) {
|
|
233
|
-
item.style.setProperty(`--indicator-color-bottom`, `transparent`);
|
|
234
|
-
item.style.setProperty(`--indicator-color-top`, `transparent`);
|
|
235
|
-
item.style.setProperty(`--indicator-color-left`, `transparent`);
|
|
236
|
-
item.style.setProperty(`--indicator-color-right`, `transparent`);
|
|
237
|
-
if (item.hasAttribute(`selected`)) {
|
|
238
|
-
if (this.orientation === `horizontal` && !this.flip) item.style.setProperty(`--indicator-color-bottom`, `var(--accent)`);
|
|
239
|
-
else if (this.orientation === `horizontal` && this.flip) item.style.setProperty(`--indicator-color-top`, `var(--accent)`);
|
|
240
|
-
else if (this.#isVertical && !this.flip) item.style.setProperty(`--indicator-color-right`, `var(--accent)`);
|
|
241
|
-
else if (this.#isVertical && this.flip) item.style.setProperty(`--indicator-color-left`, `var(--accent)`);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
#onKeyUp;
|
|
246
|
-
#onKeyDown;
|
|
247
|
-
/**
|
|
248
|
-
* Translate vertical wheel deltas into horizontal scroll on a scrollable
|
|
249
|
-
* horizontal list (and vice-versa for vertical lists). Without this, the
|
|
250
|
-
* default browser behaviour only scrolls horizontally with Shift+wheel or a
|
|
251
|
-
* physical horizontal wheel — neither of which most users reach for on a
|
|
252
|
-
* VS Code-style tab strip.
|
|
253
|
-
*
|
|
254
|
-
* Only kicks in when the list is actually scrollable (overflow content
|
|
255
|
-
* present), and is a no-op when nothing is scrollable in that direction.
|
|
256
|
-
*/
|
|
257
|
-
#onWheel;
|
|
258
|
-
getSelectedElement() {
|
|
259
|
-
for (const el of this.#items) if (this.#isSelected(el)) return el;
|
|
260
|
-
const slot = this.shadowRoot?.querySelector(`slot`);
|
|
261
|
-
if (slot) {
|
|
262
|
-
const els = slot.assignedElements({ flatten: true });
|
|
263
|
-
for (const el of els) if (this.#isSelected(el)) return el;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
#isSelected(el) {
|
|
267
|
-
if (el.getAttribute(`selected`) === null) return false;
|
|
268
|
-
return el.hasAttribute(`selected`);
|
|
269
|
-
}
|
|
270
|
-
selectElement(el) {
|
|
271
|
-
const existing = this.getSelectedElement();
|
|
272
|
-
if (existing) {
|
|
273
|
-
existing.removeAttribute(`selected`);
|
|
274
|
-
existing.style.setProperty(`--indicator-color-bottom`, `transparent`);
|
|
275
|
-
existing.style.setProperty(`--indicator-color-top`, `transparent`);
|
|
276
|
-
existing.style.setProperty(`--indicator-color-left`, `transparent`);
|
|
277
|
-
existing.style.setProperty(`--indicator-color-right`, `transparent`);
|
|
278
|
-
}
|
|
279
|
-
el.setAttribute(`selected`, ``);
|
|
280
|
-
if (this.orientation === `horizontal` && !this.flip) el.style.setProperty(`--indicator-color-bottom`, `var(--accent)`);
|
|
281
|
-
else if (this.orientation === `horizontal` && this.flip) el.style.setProperty(`--indicator-color-top`, `var(--accent)`);
|
|
282
|
-
else if (this.#isVertical && !this.flip) el.style.setProperty(`--indicator-color-right`, `var(--accent)`);
|
|
283
|
-
else if (this.#isVertical && this.flip) el.style.setProperty(`--indicator-color-left`, `var(--accent)`);
|
|
284
|
-
}
|
|
285
|
-
#selectNext() {
|
|
286
|
-
let found = false;
|
|
287
|
-
for (const el of this.#items) if (this.#isSelected(el) && !found) found = true;
|
|
288
|
-
else if (found) {
|
|
289
|
-
this.selectElement(el);
|
|
290
|
-
break;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
#selectPrevious() {
|
|
294
|
-
let prev;
|
|
295
|
-
for (const el of this.#items) if (this.#isSelected(el) && prev) this.selectElement(prev);
|
|
296
|
-
else prev = el;
|
|
297
|
-
}
|
|
298
|
-
#onSlotClick;
|
|
299
|
-
/**
|
|
300
|
-
* Walk composedPath looking for the nearest ancestor tab-list-item, but bail
|
|
301
|
-
* if the path goes through a `.close-btn` or `.toolbar` (so close/toolbar
|
|
302
|
-
* buttons always win — same delegation pattern used by tooltip-controller).
|
|
303
|
-
*/
|
|
304
|
-
#findDragTarget(event) {
|
|
305
|
-
if (this.dragMode === `off`) return null;
|
|
306
|
-
const path = event.composedPath();
|
|
307
|
-
let item = null;
|
|
308
|
-
for (const node of path) {
|
|
309
|
-
if (!(node instanceof HTMLElement)) continue;
|
|
310
|
-
if (node.classList.contains(`close-btn`) || node.classList.contains(`toolbar`)) return null;
|
|
311
|
-
if (!item && node.tagName === `IXFX-TAB-LIST-ITEM`) item = node;
|
|
312
|
-
}
|
|
313
|
-
return item;
|
|
314
|
-
}
|
|
315
|
-
#onPointerDown;
|
|
316
|
-
#pendingMove;
|
|
317
|
-
#moveRaf;
|
|
318
|
-
#onPointerMove;
|
|
319
|
-
#cancelPendingMove() {
|
|
320
|
-
if (this.#moveRaf !== null) {
|
|
321
|
-
cancelAnimationFrame(this.#moveRaf);
|
|
322
|
-
this.#moveRaf = null;
|
|
323
|
-
}
|
|
324
|
-
this.#pendingMove = null;
|
|
325
|
-
}
|
|
326
|
-
#flushMove;
|
|
327
|
-
#onPointerUp;
|
|
328
|
-
#onPointerCancel;
|
|
329
|
-
#beginDrag(event) {
|
|
330
|
-
const state = this.#dragState;
|
|
331
|
-
if (!state || state.active) return;
|
|
332
|
-
try {
|
|
333
|
-
this.#containerEl?.setPointerCapture(event.pointerId);
|
|
334
|
-
} catch {}
|
|
335
|
-
state.active = true;
|
|
336
|
-
state.source.setAttribute(`drag-source`, ``);
|
|
337
|
-
state.ghost = this.#createGhost(state.source);
|
|
338
|
-
if (state.ghost) state.ghost.move(event.clientX, event.clientY);
|
|
339
|
-
}
|
|
340
|
-
#abortDrag() {
|
|
341
|
-
const state = this.#dragState;
|
|
342
|
-
if (!state) return;
|
|
343
|
-
state.source.removeAttribute(`drag-source`);
|
|
344
|
-
if (state.gapIndex !== void 0) {
|
|
345
|
-
state.gapIndex = void 0;
|
|
346
|
-
this.requestUpdate();
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
#endDrag(pointerId) {
|
|
350
|
-
const state = this.#dragState;
|
|
351
|
-
if (!state) return;
|
|
352
|
-
this.#cancelPendingMove();
|
|
353
|
-
state.ghost?.destroy();
|
|
354
|
-
state.ghost = null;
|
|
355
|
-
this.#dragState = null;
|
|
356
|
-
window.removeEventListener(`pointermove`, this.#onPointerMove);
|
|
357
|
-
window.removeEventListener(`pointerup`, this.#onPointerUp);
|
|
358
|
-
window.removeEventListener(`pointercancel`, this.#onPointerCancel);
|
|
359
|
-
try {
|
|
360
|
-
this.#containerEl?.releasePointerCapture(pointerId);
|
|
361
|
-
} catch {}
|
|
362
|
-
this.requestUpdate();
|
|
363
|
-
}
|
|
364
|
-
#commitDrag(source, fromIndex, gapIndex) {
|
|
365
|
-
source.removeAttribute(`drag-source`);
|
|
366
|
-
const siblings = this.#items.filter((el) => el !== source);
|
|
367
|
-
const target = gapIndex === void 0 ? siblings.length : Math.max(0, Math.min(gapIndex, siblings.length));
|
|
368
|
-
const parent = source.parentNode;
|
|
369
|
-
if (!parent) return;
|
|
370
|
-
const ref = siblings[target] ?? null;
|
|
371
|
-
parent.insertBefore(source, ref);
|
|
372
|
-
const toIndex = Array.prototype.indexOf.call(parent.children, source);
|
|
373
|
-
if (toIndex === fromIndex) return;
|
|
374
|
-
this.#items = (this.shadowRoot?.querySelector(`slot`))?.assignedElements({ flatten: true }) ?? [];
|
|
375
|
-
this.#syncIndicatorColors();
|
|
376
|
-
this.#suppressNextClick = true;
|
|
377
|
-
this.dispatchEvent(new CustomEvent(`reorder`, {
|
|
378
|
-
bubbles: true,
|
|
379
|
-
detail: {
|
|
380
|
-
id: source.id,
|
|
381
|
-
fromIndex,
|
|
382
|
-
toIndex
|
|
383
|
-
}
|
|
384
|
-
}));
|
|
385
|
-
}
|
|
386
|
-
#createGhost(source) {
|
|
387
|
-
const content = document.createElement(`span`);
|
|
388
|
-
content.style.display = `inline-flex`;
|
|
389
|
-
content.style.alignItems = `center`;
|
|
390
|
-
content.style.gap = `var(--space-xs, 4px)`;
|
|
391
|
-
content.style.minWidth = `0`;
|
|
392
|
-
const iconName = source.iconName;
|
|
393
|
-
if (iconName) {
|
|
394
|
-
const icon = document.createElement(`ixfx-icon`);
|
|
395
|
-
icon.name = iconName;
|
|
396
|
-
content.appendChild(icon);
|
|
397
|
-
}
|
|
398
|
-
const label = document.createElement(`span`);
|
|
399
|
-
label.textContent = (source.textContent ?? ``).trim();
|
|
400
|
-
label.style.overflow = `hidden`;
|
|
401
|
-
label.style.textOverflow = `ellipsis`;
|
|
402
|
-
label.style.whiteSpace = `nowrap`;
|
|
403
|
-
content.appendChild(label);
|
|
404
|
-
try {
|
|
405
|
-
return createDragGhost({
|
|
406
|
-
anchor: source,
|
|
407
|
-
content
|
|
408
|
-
});
|
|
409
|
-
} catch {
|
|
410
|
-
return null;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Compute the index of the gap nearest the pointer, ignoring the source item.
|
|
415
|
-
* Returns 0..#items.length-1; undefined if no siblings.
|
|
416
|
-
*
|
|
417
|
-
* Per the plan: drag-mode="reorder" has "no sense of breaking out", so the
|
|
418
|
-
* perpendicular axis is ignored — the pointer always resolves to some gap.
|
|
419
|
-
*/
|
|
420
|
-
#computeGapIndex(clientX, clientY) {
|
|
421
|
-
const state = this.#dragState;
|
|
422
|
-
if (!state) return void 0;
|
|
423
|
-
const siblings = this.#items.filter((el) => el !== state.source);
|
|
424
|
-
if (siblings.length === 0) return 0;
|
|
425
|
-
const useX = !this.#isVertical;
|
|
426
|
-
let bestGap = 0;
|
|
427
|
-
let bestDist = Infinity;
|
|
428
|
-
for (let i = 0; i < siblings.length; i++) {
|
|
429
|
-
const rect = siblings[i].getBoundingClientRect();
|
|
430
|
-
const start = useX ? rect.left : rect.top;
|
|
431
|
-
const end = useX ? rect.right : rect.bottom;
|
|
432
|
-
const mid = (start + end) / 2;
|
|
433
|
-
const pos = useX ? clientX : clientY;
|
|
434
|
-
const dStart = Math.abs(pos - start);
|
|
435
|
-
Math.abs(pos - mid);
|
|
436
|
-
const dEnd = Math.abs(pos - end);
|
|
437
|
-
if (pos < mid) {
|
|
438
|
-
if (dStart < bestDist) {
|
|
439
|
-
bestDist = dStart;
|
|
440
|
-
bestGap = i;
|
|
441
|
-
}
|
|
442
|
-
} else if (dEnd < bestDist) {
|
|
443
|
-
bestDist = dEnd;
|
|
444
|
-
bestGap = i + 1;
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
return bestGap;
|
|
448
|
-
}
|
|
449
|
-
#computeCaretStyle() {
|
|
450
|
-
const state = this.#dragState;
|
|
451
|
-
if (!state?.active || state.gapIndex === void 0) return void 0;
|
|
452
|
-
const siblings = this.#items.filter((el) => el !== state.source);
|
|
453
|
-
if (siblings.length === 0) return void 0;
|
|
454
|
-
const useX = !this.#isVertical;
|
|
455
|
-
const containerRect = this.#containerEl?.getBoundingClientRect();
|
|
456
|
-
if (!containerRect) return void 0;
|
|
457
|
-
const gap = Math.max(0, Math.min(state.gapIndex, siblings.length));
|
|
458
|
-
let rect = null;
|
|
459
|
-
if (gap < siblings.length) rect = siblings[gap].getBoundingClientRect();
|
|
460
|
-
else rect = siblings[siblings.length - 1].getBoundingClientRect();
|
|
461
|
-
if (useX) {
|
|
462
|
-
const x = (gap < siblings.length ? rect.left : rect.right) - containerRect.left;
|
|
463
|
-
const y = 0;
|
|
464
|
-
const h = containerRect.height;
|
|
465
|
-
const w = 2;
|
|
466
|
-
return `transform: translate(${x - w / 2}px, ${y}px); width: ${w}px; height: ${h}px;`;
|
|
467
|
-
} else {
|
|
468
|
-
const y = (gap < siblings.length ? rect.top : rect.bottom) - containerRect.top;
|
|
469
|
-
const x = 0;
|
|
470
|
-
const w = containerRect.width;
|
|
471
|
-
const h = 2;
|
|
472
|
-
return `transform: translate(${x}px, ${y - h / 2}px); width: ${w}px; height: ${h}px;`;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
get #containerEl() {
|
|
476
|
-
return this.shadowRoot?.getElementById(`container`) ?? null;
|
|
477
|
-
}
|
|
478
|
-
static {
|
|
479
|
-
this.styles = [
|
|
480
|
-
themeFallbacks,
|
|
481
|
-
scrollFadeStyles(`x`),
|
|
482
|
-
scrollFadeStyles(`y`),
|
|
483
|
-
css`
|
|
484
|
-
:host {
|
|
485
|
-
display: inline-block;
|
|
486
|
-
--activated-colour: var(--accent);
|
|
487
|
-
--colour: var(--surface-3-text);
|
|
488
|
-
--scroll-max-height: 200px;
|
|
489
|
-
--allow-overflow: hidden;
|
|
490
|
-
color: var(--colour);
|
|
491
|
-
border: var(--border, none);
|
|
492
|
-
border-color: var(--surface-5);
|
|
493
|
-
border-radius: var(--radius-l, 8px) var(--radius-l, 8px) 0 0;
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
:host(.scrollable) {
|
|
497
|
-
max-height: var(--scroll-max-height);
|
|
498
|
-
}
|
|
499
|
-
:host([hide-labels]) {
|
|
500
|
-
display: inline-flex;
|
|
501
|
-
width: auto;
|
|
502
|
-
}
|
|
503
|
-
text {
|
|
504
|
-
user-select:none;
|
|
505
|
-
}
|
|
506
|
-
.outer {
|
|
507
|
-
display: flex;
|
|
508
|
-
width: 100%;
|
|
509
|
-
height: 100%;
|
|
510
|
-
gap: var(--space-s);
|
|
511
|
-
align-items: stretch;
|
|
512
|
-
box-sizing: border-box;
|
|
513
|
-
}
|
|
514
|
-
.outer.horizontal {
|
|
515
|
-
flex-direction: row;
|
|
516
|
-
align-items: center;
|
|
517
|
-
}
|
|
518
|
-
.outer.vertical-stack,
|
|
519
|
-
.outer.vertical-side {
|
|
520
|
-
flex-direction: column;
|
|
521
|
-
}
|
|
522
|
-
.list-toolbar {
|
|
523
|
-
display: flex;
|
|
524
|
-
align-items: center;
|
|
525
|
-
gap: var(--space-xs);
|
|
526
|
-
flex: 0 0 auto;
|
|
527
|
-
width: max-content;
|
|
528
|
-
max-width: 50%;
|
|
529
|
-
overflow: visible;
|
|
530
|
-
}
|
|
531
|
-
.list-toolbar.horizontal ::slotted(*:not(ixfx-toolbar)) {
|
|
532
|
-
margin-left: auto;
|
|
533
|
-
}
|
|
534
|
-
.list-toolbar[hidden] {
|
|
535
|
-
display: none !important;
|
|
536
|
-
}
|
|
537
|
-
.list-toolbar[hidden] {
|
|
538
|
-
display: none !important;
|
|
539
|
-
}
|
|
540
|
-
::slotted(ixfx-toolbar) {
|
|
541
|
-
--toolbar-bg: transparent;
|
|
542
|
-
--toolbar-border: none;
|
|
543
|
-
--toolbar-padding: 0;
|
|
544
|
-
width: max-content;
|
|
545
|
-
max-width: 100%;
|
|
546
|
-
min-width: 150px;
|
|
547
|
-
flex-shrink: 0;
|
|
548
|
-
}
|
|
549
|
-
#container {
|
|
550
|
-
display:flex;
|
|
551
|
-
position: relative;
|
|
552
|
-
flex: 1 1 0%;
|
|
553
|
-
min-width: 0;
|
|
554
|
-
min-height: 0;
|
|
555
|
-
}
|
|
556
|
-
.outer.vertical-stack #container,
|
|
557
|
-
.outer.vertical-side #container {
|
|
558
|
-
flex: 1 1 auto;
|
|
559
|
-
height: 100%;
|
|
560
|
-
}
|
|
561
|
-
#container.horizontal {
|
|
562
|
-
flex-direction: row;
|
|
563
|
-
overflow: hidden;
|
|
564
|
-
}
|
|
565
|
-
#container.horizontal.scrollable {
|
|
566
|
-
overflow-x: scroll;
|
|
567
|
-
--allow-overflow: visible;
|
|
568
|
-
scrollbar-width: none;
|
|
569
|
-
}
|
|
570
|
-
#container.horizontal.scrollable::-webkit-scrollbar {
|
|
571
|
-
display: none;
|
|
572
|
-
}
|
|
573
|
-
#container.horizontal.scrollable ::slotted(ixfx-tab-list-item) {
|
|
574
|
-
flex-shrink: 0;
|
|
575
|
-
}
|
|
576
|
-
#container.vertical-stack {
|
|
577
|
-
flex-direction: column;
|
|
578
|
-
height: 100%;
|
|
579
|
-
}
|
|
580
|
-
#container.vertical-stack.flip {
|
|
581
|
-
flex-direction: column-reverse;
|
|
582
|
-
}
|
|
583
|
-
#container.vertical-stack.scrollable {
|
|
584
|
-
overflow-y: scroll;
|
|
585
|
-
max-height: var(--scroll-max-height);
|
|
586
|
-
--allow-overflow: visible;
|
|
587
|
-
scrollbar-width: none;
|
|
588
|
-
}
|
|
589
|
-
#container.vertical-stack.scrollable::-webkit-scrollbar {
|
|
590
|
-
display: none;
|
|
591
|
-
}
|
|
592
|
-
#container.vertical-side {
|
|
593
|
-
flex-direction: column;
|
|
594
|
-
height: 100%;
|
|
595
|
-
}
|
|
596
|
-
#container.vertical-side.flip {
|
|
597
|
-
flex-direction: column-reverse;
|
|
598
|
-
}
|
|
599
|
-
#container.vertical-side.scrollable {
|
|
600
|
-
overflow-y: scroll;
|
|
601
|
-
max-height: var(--scroll-max-height);
|
|
602
|
-
--allow-overflow: visible;
|
|
603
|
-
scrollbar-width: none;
|
|
604
|
-
}
|
|
605
|
-
#container.vertical-side.scrollable::-webkit-scrollbar {
|
|
606
|
-
display: none;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
::slotted(ixfx-tab-list-item) {
|
|
610
|
-
flex: 1 1 auto;
|
|
611
|
-
min-width: 0;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
:host([shrink]) ::slotted(ixfx-tab-list-item) {
|
|
615
|
-
flex: 0 0 auto;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
#container.vertical-side ::slotted(ixfx-tab-list-item) {
|
|
619
|
-
writing-mode: vertical-lr;
|
|
620
|
-
text-orientation: mixed;
|
|
621
|
-
}
|
|
622
|
-
#container.vertical-side.flip ::slotted(ixfx-tab-list-item) {
|
|
623
|
-
writing-mode: vertical-rl;
|
|
624
|
-
text-orientation: mixed;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
|
-
/* Drag affordances — opt-in via drag-mode="reorder" on the host (list). */
|
|
628
|
-
#container.reorder ::slotted(ixfx-tab-list-item) {
|
|
629
|
-
cursor: grab;
|
|
630
|
-
}
|
|
631
|
-
:host([drag-mode]) ::slotted(ixfx-tab-list-item[drag-source]) {
|
|
632
|
-
cursor: grabbing;
|
|
633
|
-
opacity: 0.4;
|
|
634
|
-
transition: opacity var(--transition, 0.15s ease-out);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
/* Insertion caret shown during an active drag. */
|
|
638
|
-
.drop-caret {
|
|
639
|
-
position: absolute;
|
|
640
|
-
background: var(--accent);
|
|
641
|
-
border-radius: 1px;
|
|
642
|
-
pointer-events: none;
|
|
643
|
-
z-index: 1;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
::slotted(.activated) {
|
|
647
|
-
--colour: var(--activated-colour);
|
|
648
|
-
}
|
|
649
|
-
`
|
|
650
|
-
];
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
__decorate([property({ type: String })], TabListElement.prototype, "orientation", void 0);
|
|
654
|
-
__decorate([property({ type: Boolean })], TabListElement.prototype, "flip", void 0);
|
|
655
|
-
__decorate([property({ type: Boolean })], TabListElement.prototype, "scrollable", void 0);
|
|
656
|
-
__decorate([property({
|
|
657
|
-
type: Boolean,
|
|
658
|
-
attribute: `hide-labels`
|
|
659
|
-
})], TabListElement.prototype, "hideLabels", void 0);
|
|
660
|
-
__decorate([property({
|
|
661
|
-
type: Boolean,
|
|
662
|
-
attribute: `label-nogrow`
|
|
663
|
-
})], TabListElement.prototype, "labelNogrow", void 0);
|
|
664
|
-
__decorate([property({
|
|
665
|
-
type: Boolean,
|
|
666
|
-
reflect: true
|
|
667
|
-
})], TabListElement.prototype, "shrink", void 0);
|
|
668
|
-
__decorate([property({
|
|
669
|
-
type: String,
|
|
670
|
-
attribute: `drag-mode`
|
|
671
|
-
})], TabListElement.prototype, "dragMode", void 0);
|
|
672
|
-
TabListElement = __decorate([safeCustomElement(`ixfx-tab-list`)], TabListElement);
|
|
673
|
-
//#endregion
|
|
1
|
+
import { t as TabListElement } from "./tab-list-R_bGbDvO.js";
|
|
674
2
|
export { TabListElement };
|
package/docs-user/button.md
CHANGED
|
@@ -27,6 +27,7 @@ Three related button components:
|
|
|
27
27
|
| `icon` | string | — | Registered icon name **or** raw `<svg>` string |
|
|
28
28
|
| `hide-icon` | boolean | `false` | Hides the icon even when `icon` is set |
|
|
29
29
|
| `hide-label` | boolean | `false` | Hides the text label (useful for icon-only buttons)|
|
|
30
|
+
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Inside a `<form>` (including `ixfx-form`), `submit` submits it (after validation) and `reset` resets it. The button is form-associated, so this works even though its inner `<button>` is in a shadow root |
|
|
30
31
|
| `subtle` | boolean | `false` | Renders the background at 40% opacity, raised to 70% on hover/focus |
|
|
31
32
|
|
|
32
33
|
### Slots
|