@ixfx/components 0.5.16 → 0.5.18
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 +52 -3
- package/bundle/index.d.ts.map +1 -1
- package/bundle/index.js +438 -160
- package/bundle/index.js.map +1 -1
- package/dist/ac-text.d.ts +1 -1
- package/dist/colour-picker.d.ts +1 -1
- package/dist/crumb-navigation-DTwJ8468.js +1123 -0
- package/dist/crumb-navigation-DTwJ8468.js.map +1 -0
- package/dist/crumbs.d.ts +4 -3
- package/dist/crumbs.d.ts.map +1 -1
- package/dist/crumbs.js +1 -1101
- package/dist/{icon-DpA9x2Ve.d.ts → icon-BUwP1CZ1.d.ts} +2 -2
- package/dist/icon-BUwP1CZ1.d.ts.map +1 -0
- package/dist/icons.d.ts +2 -2
- package/dist/{index-D_ftz_IT.d.ts → index-BKAlRgbq.d.ts} +2 -2
- package/dist/{index-D_ftz_IT.d.ts.map → index-BKAlRgbq.d.ts.map} +1 -1
- package/dist/{index-CoqtMSd9.d.ts → index-BUB5SICW.d.ts} +2 -2
- package/dist/{index-CoqtMSd9.d.ts.map → index-BUB5SICW.d.ts.map} +1 -1
- package/dist/{index-DfEkTGvT.d.ts → index-DkhBGHgF.d.ts} +3 -3
- package/dist/{index-DfEkTGvT.d.ts.map → index-DkhBGHgF.d.ts.map} +1 -1
- package/dist/{index-BtGFYfaK.d.ts → index-RqMh1i-O.d.ts} +2 -2
- package/dist/{index-BtGFYfaK.d.ts.map → index-RqMh1i-O.d.ts.map} +1 -1
- package/dist/index.d.ts +55 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +259 -5
- package/dist/index.js.map +1 -1
- package/dist/{labelled-input-base-DiTme1JO.d.ts → labelled-input-base-Dp_9KP0G.d.ts} +2 -2
- package/dist/{labelled-input-base-DiTme1JO.d.ts.map → labelled-input-base-Dp_9KP0G.d.ts.map} +1 -1
- package/dist/labelled-radial-input.d.ts +2 -2
- package/dist/labelled-radial-input.d.ts.map +1 -1
- package/dist/labelled-range-input.d.ts +1 -1
- package/dist/{menu-B8gE2MSo.js → menu-CdwSe_XN.js} +2 -2
- package/dist/{menu-B8gE2MSo.js.map → menu-CdwSe_XN.js.map} +1 -1
- package/dist/{menu-item-DSyf9f_L.d.ts → menu-item-BG5w7fi4.d.ts} +4 -2
- package/dist/menu-item-BG5w7fi4.d.ts.map +1 -0
- package/dist/{menu-item-BYRvfyXK.js → menu-item-CrmUwIoJ.js} +7 -2
- package/dist/menu-item-CrmUwIoJ.js.map +1 -0
- package/dist/menu.d.ts +2 -2
- package/dist/menu.js +2 -2
- package/dist/panel.d.ts +1 -1
- package/dist/{tab-list-ih-0I0NE.d.ts → tab-list-CLqlPnX-.d.ts} +2 -2
- package/dist/{tab-list-ih-0I0NE.d.ts.map → tab-list-CLqlPnX-.d.ts.map} +1 -1
- package/dist/tabs.d.ts +1 -1
- package/docs-user/README.md +1 -0
- package/docs-user/crumbs.md +15 -1
- package/docs-user/select-horiz.md +114 -0
- package/package.json +1 -1
- package/dist/crumbs.js.map +0 -1
- package/dist/icon-DpA9x2Ve.d.ts.map +0 -1
- package/dist/menu-item-BYRvfyXK.js.map +0 -1
- package/dist/menu-item-DSyf9f_L.d.ts.map +0 -1
|
@@ -0,0 +1,1123 @@
|
|
|
1
|
+
import { n as tickledStyles, r as TickledController, t as tickledItemStyles } from "./tickled-styles-fNDdqf6l.js";
|
|
2
|
+
import { t as themeFallbacks } from "./fallbacks-DPgPEqo8.js";
|
|
3
|
+
import { n as safeCustomElement, t as __decorate } from "./decorate-VRK8rslU.js";
|
|
4
|
+
import "./interaction-D6efrBLo.js";
|
|
5
|
+
import "./menu-item-CrmUwIoJ.js";
|
|
6
|
+
import { t as collectDataResult } from "./data-provider-35TyWclX.js";
|
|
7
|
+
import "./narrowed-text.js";
|
|
8
|
+
import { LitElement, css, html, nothing, unsafeCSS } from "lit";
|
|
9
|
+
import { property, state } from "lit/decorators.js";
|
|
10
|
+
//#region src/styles/scroll-fade.ts
|
|
11
|
+
/**
|
|
12
|
+
* Zero-JS scroll edge fade.
|
|
13
|
+
*
|
|
14
|
+
* A CSS alpha mask driven by a scroll-linked animation (`scroll-timeline`),
|
|
15
|
+
* rather than a JS scroll/resize listener - so it can never go stale after
|
|
16
|
+
* a resize (widening a scroller so content fully fits clears the fade
|
|
17
|
+
* immediately, with no JS involved), and it fades the whole element
|
|
18
|
+
* including its children, not just a background layer that an opaque
|
|
19
|
+
* item background would hide.
|
|
20
|
+
*
|
|
21
|
+
* Apply the returned `.scroll-fade-x` / `.scroll-fade-y` class to
|
|
22
|
+
* whichever element actually has `overflow` scrolling on that axis.
|
|
23
|
+
*
|
|
24
|
+
* CSS variables:
|
|
25
|
+
* - `--scroll-fade-width` (default `30px`): how far the fade extends from each edge.
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { scrollFadeStyles } from '../styles/scroll-fade.js';
|
|
29
|
+
*
|
|
30
|
+
* static styles = [scrollFadeStyles(`x`), css`...`];
|
|
31
|
+
* ```
|
|
32
|
+
* ```html
|
|
33
|
+
* <div class="scroll-fade-x" style="overflow-x: scroll">...</div>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
function scrollFadeStyles(axis) {
|
|
37
|
+
const className = `scroll-fade-${axis}`;
|
|
38
|
+
const start = `--${className}-start`;
|
|
39
|
+
const end = `--${className}-end`;
|
|
40
|
+
const timeline = `--${className}-timeline`;
|
|
41
|
+
const keyframesName = `${className}-fade`;
|
|
42
|
+
const gradientDirection = axis === `x` ? `to right` : `to bottom`;
|
|
43
|
+
return css`
|
|
44
|
+
@property ${unsafeCSS(start)} {
|
|
45
|
+
syntax: '<length>';
|
|
46
|
+
inherits: false;
|
|
47
|
+
initial-value: 0px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@property ${unsafeCSS(end)} {
|
|
51
|
+
syntax: '<length>';
|
|
52
|
+
inherits: false;
|
|
53
|
+
initial-value: 0px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@keyframes ${unsafeCSS(keyframesName)} {
|
|
57
|
+
0% { ${unsafeCSS(start)}: 0px; }
|
|
58
|
+
10%, 100% { ${unsafeCSS(start)}: var(--scroll-fade-width, 30px); }
|
|
59
|
+
0%, 90% { ${unsafeCSS(end)}: var(--scroll-fade-width, 30px); }
|
|
60
|
+
100% { ${unsafeCSS(end)}: 0px; }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.${unsafeCSS(className)} {
|
|
64
|
+
scroll-timeline: ${unsafeCSS(timeline)} ${unsafeCSS(axis)};
|
|
65
|
+
animation: ${unsafeCSS(keyframesName)};
|
|
66
|
+
animation-timeline: ${unsafeCSS(timeline)};
|
|
67
|
+
mask-image: linear-gradient(${unsafeCSS(gradientDirection)},
|
|
68
|
+
transparent,
|
|
69
|
+
black var(${unsafeCSS(start)}, 0px) calc(100% - var(${unsafeCSS(end)}, 0px)),
|
|
70
|
+
transparent
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/crumbs/crumb-navigation.ts
|
|
77
|
+
let CrumbNavigationElement = class CrumbNavigationElement extends LitElement {
|
|
78
|
+
constructor(..._args) {
|
|
79
|
+
super(..._args);
|
|
80
|
+
this._selectedNodes = /* @__PURE__ */ new Set();
|
|
81
|
+
this.exclusivity = `none`;
|
|
82
|
+
this.selectionFilter = `leaf`;
|
|
83
|
+
this._openIdx = -1;
|
|
84
|
+
this._isFocused = false;
|
|
85
|
+
this._menuOpen = false;
|
|
86
|
+
this._focusOnNarrowedText = false;
|
|
87
|
+
this.inputMode = ``;
|
|
88
|
+
this.noTruncate = false;
|
|
89
|
+
this.showSuggestions = false;
|
|
90
|
+
this.leadingCaret = false;
|
|
91
|
+
this.caretEmbedded = true;
|
|
92
|
+
this.hideRoot = false;
|
|
93
|
+
this.#previousSelectionKey = ``;
|
|
94
|
+
this.#menuOpenedByKeyboard = false;
|
|
95
|
+
this.#currentOpenTrigger = null;
|
|
96
|
+
this.tickled = new TickledController(this, {
|
|
97
|
+
getItems: () => this.#getTickledItems(),
|
|
98
|
+
onTickle: (index) => {
|
|
99
|
+
if (index !== void 0) this.#onTickled(index);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
this.#onFocus = () => {
|
|
103
|
+
this._isFocused = true;
|
|
104
|
+
};
|
|
105
|
+
this.#onBlur = () => {
|
|
106
|
+
this._isFocused = false;
|
|
107
|
+
};
|
|
108
|
+
this.#onHostClick = () => {
|
|
109
|
+
this.#getHostContainer()?.focus();
|
|
110
|
+
};
|
|
111
|
+
this.#onMenuTriggerClose = () => {
|
|
112
|
+
document.removeEventListener(`keydown`, this.#onMenuKeyNav, { capture: true });
|
|
113
|
+
this.#currentOpenTrigger = null;
|
|
114
|
+
this.#menuOpenedByKeyboard = false;
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
this.#getHostContainer()?.focus();
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
this.#onMenuKeyNav = (e) => {
|
|
120
|
+
if (!this.#currentOpenTrigger?.querySelector(`ixfx-menu-container`) || !this.#currentOpenTrigger?.isOpen) return;
|
|
121
|
+
switch (e.key) {
|
|
122
|
+
case `ArrowLeft`:
|
|
123
|
+
case `ArrowRight`: {
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
this.#currentOpenTrigger.closeMenu();
|
|
127
|
+
const r = this.root;
|
|
128
|
+
const sel = this.selectedNode;
|
|
129
|
+
if (!r || !sel) break;
|
|
130
|
+
const totalItems = this.#getTickledItems().length;
|
|
131
|
+
const currentTickled = this.tickled.tickledId ?? -1;
|
|
132
|
+
if (e.key === `ArrowLeft`) {
|
|
133
|
+
if (currentTickled > 0) this.tickled.handleKeyboardNavigation(`previous`);
|
|
134
|
+
} else if (currentTickled < totalItems - 1) this.tickled.handleKeyboardNavigation(`next`);
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
this.#onKeyDown = (e) => {
|
|
140
|
+
const r = this.root;
|
|
141
|
+
const sel = this.selectedNode;
|
|
142
|
+
if (!r || !sel) return;
|
|
143
|
+
const totalItems = this.#getTickledItems().length;
|
|
144
|
+
const currentTickled = this.tickled.tickledId ?? -1;
|
|
145
|
+
switch (e.key) {
|
|
146
|
+
case `ArrowRight`:
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
if (currentTickled < totalItems - 1) this.tickled.handleKeyboardNavigation(`next`);
|
|
149
|
+
else if (currentTickled === totalItems - 1 && this.#canFocusSuggestions()) this.#shiftFocusToNarrowedText();
|
|
150
|
+
break;
|
|
151
|
+
case `ArrowLeft`:
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
if (currentTickled > 0) this.tickled.handleKeyboardNavigation(`previous`);
|
|
154
|
+
break;
|
|
155
|
+
case `ArrowDown`:
|
|
156
|
+
case `ArrowUp`:
|
|
157
|
+
if (this.tickled.tickledId !== void 0) {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
if (this.#currentOpenTrigger?.isOpen) {
|
|
160
|
+
const popover = this.#currentOpenTrigger.querySelector(`ixfx-menu-container`)?.shadowRoot?.querySelector(`.popover`);
|
|
161
|
+
if (popover) popover.dispatchEvent(new KeyboardEvent(`keydown`, {
|
|
162
|
+
key: e.key,
|
|
163
|
+
bubbles: true
|
|
164
|
+
}));
|
|
165
|
+
} else this.#handleOpenCaretMenu();
|
|
166
|
+
}
|
|
167
|
+
break;
|
|
168
|
+
case `Enter`:
|
|
169
|
+
case ` `:
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
this.#activateTickled();
|
|
172
|
+
break;
|
|
173
|
+
case `Escape`:
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
this._menuOpen = false;
|
|
176
|
+
this.tickled.clearTickled();
|
|
177
|
+
this.blur();
|
|
178
|
+
break;
|
|
179
|
+
case `Tab`:
|
|
180
|
+
if (e.shiftKey) break;
|
|
181
|
+
if (currentTickled === totalItems - 1 && this.#canFocusSuggestions()) {
|
|
182
|
+
e.preventDefault();
|
|
183
|
+
this.#shiftFocusToNarrowedText();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
this.#onNarrowedTextBlur = () => {
|
|
188
|
+
this._focusOnNarrowedText = false;
|
|
189
|
+
this.#shiftFocusToPath();
|
|
190
|
+
};
|
|
191
|
+
this.#onNarrowedTextShiftTab = () => {
|
|
192
|
+
this._focusOnNarrowedText = false;
|
|
193
|
+
this.#shiftFocusToPath();
|
|
194
|
+
};
|
|
195
|
+
this.#isWheelScrolling = false;
|
|
196
|
+
this.#onWheel = (e) => {
|
|
197
|
+
const wheelEvent = e;
|
|
198
|
+
if (wheelEvent.deltaX !== 0 || wheelEvent.deltaY !== 0) {
|
|
199
|
+
e.preventDefault();
|
|
200
|
+
if (!this.#isWheelScrolling) {
|
|
201
|
+
this.#isWheelScrolling = true;
|
|
202
|
+
this.tickled.clearTickled();
|
|
203
|
+
}
|
|
204
|
+
const hostContainer = this.#getHostContainer();
|
|
205
|
+
if (hostContainer) hostContainer.scrollLeft += wheelEvent.deltaX + wheelEvent.deltaY;
|
|
206
|
+
clearTimeout(this.#wheelScrollTimeout);
|
|
207
|
+
this.#wheelScrollTimeout = setTimeout(() => {
|
|
208
|
+
this.#isWheelScrolling = false;
|
|
209
|
+
}, 150);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
this.#currentLeadingSiblings = void 0;
|
|
213
|
+
}
|
|
214
|
+
get selectedNodes() {
|
|
215
|
+
return this._selectedNodes;
|
|
216
|
+
}
|
|
217
|
+
#pendingNode;
|
|
218
|
+
#pendingController;
|
|
219
|
+
#modelUnsubscribe;
|
|
220
|
+
#previousSelectionKey;
|
|
221
|
+
#menuOpenedByKeyboard;
|
|
222
|
+
#currentOpenTrigger;
|
|
223
|
+
#getTickledItems() {
|
|
224
|
+
const r = this.root;
|
|
225
|
+
const sel = this.selectedNode;
|
|
226
|
+
if (!r || !sel) return [];
|
|
227
|
+
const pathNodes = this.#findPath(r, sel) ?? [r];
|
|
228
|
+
const items = [];
|
|
229
|
+
if (this.caretEmbedded) {
|
|
230
|
+
pathNodes.forEach((_node, i) => {
|
|
231
|
+
items.push({
|
|
232
|
+
id: i,
|
|
233
|
+
enabled: true
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
if (this.#canFocusSuggestions()) items.push({
|
|
237
|
+
id: pathNodes.length,
|
|
238
|
+
enabled: true
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
let segmentId = 0;
|
|
242
|
+
pathNodes.forEach((node, i) => {
|
|
243
|
+
const isLast = i === pathNodes.length - 1;
|
|
244
|
+
const hasChildren = node.item.isLeaf !== true && (node.children === void 0 || node.children.length > 0);
|
|
245
|
+
const showLeadingCaret = this.leadingCaret && (i > 0 || this.hideRoot) && hasChildren;
|
|
246
|
+
const showTrailingCaret = !this.leadingCaret && hasChildren || this.leadingCaret && isLast && hasChildren;
|
|
247
|
+
if (showLeadingCaret) items.push({
|
|
248
|
+
id: segmentId++,
|
|
249
|
+
enabled: true
|
|
250
|
+
});
|
|
251
|
+
items.push({
|
|
252
|
+
id: segmentId++,
|
|
253
|
+
enabled: true
|
|
254
|
+
});
|
|
255
|
+
if (showTrailingCaret) items.push({
|
|
256
|
+
id: segmentId++,
|
|
257
|
+
enabled: true
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return items;
|
|
262
|
+
}
|
|
263
|
+
#onTickled(index) {
|
|
264
|
+
if (this.tickled.inputMode === `keyboard`) this.#scrollTickledIntoView(index);
|
|
265
|
+
}
|
|
266
|
+
#scrollTickledIntoView(index) {
|
|
267
|
+
const r = this.root;
|
|
268
|
+
const sel = this.selectedNode;
|
|
269
|
+
if (!r || !sel) return;
|
|
270
|
+
const pathNodes = this.#findPath(r, sel) ?? [r];
|
|
271
|
+
let el = null;
|
|
272
|
+
if (this.caretEmbedded && this.#canFocusSuggestions() && index === pathNodes.length) el = this.shadowRoot?.querySelector(`ixfx-narrowed-text`) ?? null;
|
|
273
|
+
else el = this.shadowRoot?.querySelectorAll(`.crumb-segment`)[index] ?? null;
|
|
274
|
+
el?.scrollIntoView({
|
|
275
|
+
inline: `nearest`,
|
|
276
|
+
block: `nearest`,
|
|
277
|
+
behavior: `smooth`
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
#hasChildOptions() {
|
|
281
|
+
const s = this.selectedNode;
|
|
282
|
+
if (s === void 0) return false;
|
|
283
|
+
const isPending = this.#pendingNode === s;
|
|
284
|
+
return (s.children ?? []).length > 0 || isPending;
|
|
285
|
+
}
|
|
286
|
+
/** True when the suggestions (narrowed-text) sub-part is renderable and focusable. */
|
|
287
|
+
#canFocusSuggestions() {
|
|
288
|
+
return this.showSuggestions && this.#hasChildOptions();
|
|
289
|
+
}
|
|
290
|
+
#onFocus;
|
|
291
|
+
#onBlur;
|
|
292
|
+
#getHostContainer() {
|
|
293
|
+
return this.shadowRoot?.querySelector(`.host-container`) ?? null;
|
|
294
|
+
}
|
|
295
|
+
#onHostClick;
|
|
296
|
+
#handleOpenCaretMenu() {
|
|
297
|
+
const currentTickled = this.tickled.tickledId;
|
|
298
|
+
if (currentTickled === void 0) return;
|
|
299
|
+
const r = this.root;
|
|
300
|
+
const sel = this.selectedNode;
|
|
301
|
+
if (!r || !sel) return;
|
|
302
|
+
const pathNodes = this.#findPath(r, sel) ?? [r];
|
|
303
|
+
if (this.caretEmbedded && this.#canFocusSuggestions() && currentTickled === pathNodes.length) {
|
|
304
|
+
this.#shiftFocusToNarrowedText();
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const trigger = (this.shadowRoot?.querySelectorAll(`.crumb-segment`))?.[currentTickled]?.querySelector(`.caret ixfx-menu-trigger`);
|
|
308
|
+
if (trigger) {
|
|
309
|
+
this.#menuOpenedByKeyboard = true;
|
|
310
|
+
this.#currentOpenTrigger = trigger;
|
|
311
|
+
document.addEventListener(`keydown`, this.#onMenuKeyNav, { capture: true });
|
|
312
|
+
trigger.openMenu();
|
|
313
|
+
this.#propagateInputModeToMenu();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
#propagateInputModeToMenu() {
|
|
317
|
+
const inputMode = this.tickled.inputMode;
|
|
318
|
+
requestAnimationFrame(() => {
|
|
319
|
+
const container = this.#currentOpenTrigger?.querySelector(`ixfx-menu-container`);
|
|
320
|
+
if (container) container.setAttribute(`data-input-mode`, inputMode);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
#onMenuTriggerClose;
|
|
324
|
+
#onMenuKeyNav;
|
|
325
|
+
#onKeyDown;
|
|
326
|
+
/** Activates the currently tickled item, as if it had been clicked. */
|
|
327
|
+
#activateTickled() {
|
|
328
|
+
const currentTickled = this.tickled.tickledId;
|
|
329
|
+
if (currentTickled === void 0) return;
|
|
330
|
+
const r = this.root;
|
|
331
|
+
const sel = this.selectedNode;
|
|
332
|
+
if (!r || !sel) return;
|
|
333
|
+
const pathNodes = this.#findPath(r, sel) ?? [r];
|
|
334
|
+
if (this.caretEmbedded && this.#canFocusSuggestions() && currentTickled === pathNodes.length) {
|
|
335
|
+
this.#shiftFocusToNarrowedText();
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
(this.shadowRoot?.querySelector(`.crumb-segment[data-segment-id="${currentTickled}"]`))?.click();
|
|
339
|
+
}
|
|
340
|
+
#shiftFocusToNarrowedText() {
|
|
341
|
+
const narrowedText = this.shadowRoot?.querySelector(`ixfx-narrowed-text`);
|
|
342
|
+
if (narrowedText) {
|
|
343
|
+
this._menuOpen = false;
|
|
344
|
+
this._focusOnNarrowedText = true;
|
|
345
|
+
narrowedText.focus();
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
#shiftFocusToPath() {
|
|
349
|
+
this._focusOnNarrowedText = false;
|
|
350
|
+
const hostContainer = this.#getHostContainer();
|
|
351
|
+
if (hostContainer) hostContainer.focus();
|
|
352
|
+
}
|
|
353
|
+
#onNarrowedTextBlur;
|
|
354
|
+
#onNarrowedTextShiftTab;
|
|
355
|
+
select(node) {
|
|
356
|
+
this.#setSelected(node);
|
|
357
|
+
}
|
|
358
|
+
deselect(_node) {}
|
|
359
|
+
clearSelection() {
|
|
360
|
+
if (this.root) this.#setSelected(this.root);
|
|
361
|
+
}
|
|
362
|
+
/** Not implemented on crumb-navigation. */
|
|
363
|
+
selectAll() {}
|
|
364
|
+
/** Not implemented on crumb-navigation. */
|
|
365
|
+
deselectAll() {}
|
|
366
|
+
getNodes() {
|
|
367
|
+
if (!this.root) return [];
|
|
368
|
+
const result = [];
|
|
369
|
+
const visit = (node, depth) => {
|
|
370
|
+
result.push({
|
|
371
|
+
node,
|
|
372
|
+
depth
|
|
373
|
+
});
|
|
374
|
+
if (node.children) for (const child of node.children) visit(child, depth + 1);
|
|
375
|
+
};
|
|
376
|
+
for (const child of this.root.children ?? []) visit(child, 0);
|
|
377
|
+
return result;
|
|
378
|
+
}
|
|
379
|
+
updated(changedProps) {
|
|
380
|
+
if (changedProps.has(`model`)) {
|
|
381
|
+
this.#modelUnsubscribe?.();
|
|
382
|
+
this.#modelUnsubscribe = void 0;
|
|
383
|
+
const model = this.model;
|
|
384
|
+
if (model) {
|
|
385
|
+
this.root = model.root;
|
|
386
|
+
this.#modelUnsubscribe = model._subscribe((event) => {
|
|
387
|
+
if (event.type === `root`) {
|
|
388
|
+
this.root = event.root;
|
|
389
|
+
this.requestUpdate();
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
this.#runLayoutUpdate(changedProps);
|
|
395
|
+
}
|
|
396
|
+
connectedCallback() {
|
|
397
|
+
super.connectedCallback();
|
|
398
|
+
this.addEventListener(`click`, this.#onHostClick);
|
|
399
|
+
this.addEventListener(`wheel`, this.#onWheel, { passive: false });
|
|
400
|
+
}
|
|
401
|
+
disconnectedCallback() {
|
|
402
|
+
super.disconnectedCallback();
|
|
403
|
+
this.removeEventListener(`click`, this.#onHostClick);
|
|
404
|
+
this.removeEventListener(`wheel`, this.#onWheel);
|
|
405
|
+
this.#modelUnsubscribe?.();
|
|
406
|
+
this.#modelUnsubscribe = void 0;
|
|
407
|
+
document.removeEventListener(`keydown`, this.#onMenuKeyNav, { capture: true });
|
|
408
|
+
this.#currentOpenTrigger = null;
|
|
409
|
+
}
|
|
410
|
+
firstUpdated() {
|
|
411
|
+
const hostContainer = this.#getHostContainer();
|
|
412
|
+
if (hostContainer) hostContainer.scrollLeft = hostContainer.scrollWidth - hostContainer.clientWidth;
|
|
413
|
+
}
|
|
414
|
+
#isWheelScrolling;
|
|
415
|
+
#onWheel;
|
|
416
|
+
#wheelScrollTimeout;
|
|
417
|
+
#runLayoutUpdate(_changedProperties) {
|
|
418
|
+
if (!this.shadowRoot) return;
|
|
419
|
+
const hsiElement = this.shadowRoot.querySelector(`.horiz-select-items`);
|
|
420
|
+
if (!hsiElement) return;
|
|
421
|
+
const ulElement = hsiElement.querySelector(`ul`);
|
|
422
|
+
if (!ulElement) return;
|
|
423
|
+
const menuTrigger = this.shadowRoot.querySelector(`ixfx-menu-trigger`);
|
|
424
|
+
if (!menuTrigger) return;
|
|
425
|
+
if (ulElement.getBoundingClientRect().width > hsiElement.getBoundingClientRect().width) menuTrigger.style.display = `inline-flex`;
|
|
426
|
+
else menuTrigger.style.display = `none`;
|
|
427
|
+
for (const li of ulElement.querySelectorAll(`li`)) if ((li.getAttribute(`data-key`) ?? ``) === this.#previousSelectionKey) {
|
|
428
|
+
this.#scrollToValue(li);
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
#scrollToValue(li) {
|
|
433
|
+
let l = li.offsetLeft;
|
|
434
|
+
const ul = li.parentElement;
|
|
435
|
+
if (!ul) return;
|
|
436
|
+
l -= ul.offsetLeft;
|
|
437
|
+
const horizSelectItems = ul.parentElement;
|
|
438
|
+
if (!horizSelectItems) return;
|
|
439
|
+
horizSelectItems.scroll({
|
|
440
|
+
left: l,
|
|
441
|
+
top: 0,
|
|
442
|
+
behavior: `smooth`
|
|
443
|
+
});
|
|
444
|
+
const horizSelect = horizSelectItems.parentElement;
|
|
445
|
+
if (!horizSelect) return;
|
|
446
|
+
horizSelect.style.minWidth = `${li.getBoundingClientRect().width}px`;
|
|
447
|
+
}
|
|
448
|
+
#abortPending() {
|
|
449
|
+
if (this.#pendingController) {
|
|
450
|
+
this.#pendingController.abort();
|
|
451
|
+
this.#pendingController = void 0;
|
|
452
|
+
this.#pendingNode = void 0;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
#findPath(node, target, acc = []) {
|
|
456
|
+
const path = [...acc, node];
|
|
457
|
+
if (node === target) return path;
|
|
458
|
+
if (!node.children) return void 0;
|
|
459
|
+
for (const child of node.children) {
|
|
460
|
+
const result = this.#findPath(child, target, path);
|
|
461
|
+
if (result) return result;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
#scrollSegmentIntoView(depth) {
|
|
465
|
+
if (!this.shadowRoot) return;
|
|
466
|
+
this.shadowRoot.querySelectorAll(`.crumb-segment`)[depth]?.scrollIntoView({
|
|
467
|
+
block: `nearest`,
|
|
468
|
+
inline: `start`
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
#setSelected(node) {
|
|
472
|
+
const previous = this.selectedNode;
|
|
473
|
+
if (previous) this.#previousSelectionKey = previous.item?.key ?? ``;
|
|
474
|
+
else this.#previousSelectionKey = ``;
|
|
475
|
+
const previousSet = previous ? /* @__PURE__ */ new Set([previous]) : /* @__PURE__ */ new Set();
|
|
476
|
+
this.selectedNode = node;
|
|
477
|
+
this._selectedNodes = /* @__PURE__ */ new Set([node]);
|
|
478
|
+
if (this.root) {
|
|
479
|
+
const path = this.#findPath(this.root, node);
|
|
480
|
+
if (path) {
|
|
481
|
+
const depth = this.hideRoot && path.length > 1 ? path.length - 2 : path.length - 1;
|
|
482
|
+
requestAnimationFrame(() => {
|
|
483
|
+
this.#scrollSegmentIntoView(depth);
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
this.dispatchEvent(new CustomEvent(`select`, {
|
|
488
|
+
detail: {
|
|
489
|
+
selected: /* @__PURE__ */ new Set([node]),
|
|
490
|
+
previous: previousSet
|
|
491
|
+
},
|
|
492
|
+
bubbles: true,
|
|
493
|
+
composed: true
|
|
494
|
+
}));
|
|
495
|
+
}
|
|
496
|
+
#onLabelClick(node, depth) {
|
|
497
|
+
this._openIdx = -1;
|
|
498
|
+
this.#setSelected(node);
|
|
499
|
+
this.#scrollSegmentIntoView(depth);
|
|
500
|
+
this.dispatchEvent(new CustomEvent(`item-click`, {
|
|
501
|
+
detail: {
|
|
502
|
+
node,
|
|
503
|
+
depth
|
|
504
|
+
},
|
|
505
|
+
bubbles: true,
|
|
506
|
+
composed: true
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
#onCaretClick(node, depth, e) {
|
|
510
|
+
e.preventDefault();
|
|
511
|
+
e.stopPropagation();
|
|
512
|
+
if (this._openIdx === depth) {
|
|
513
|
+
this._openIdx = -1;
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
this._openIdx = depth;
|
|
517
|
+
if (node.children === void 0 && this.#pendingNode !== node) {
|
|
518
|
+
this.#abortPending();
|
|
519
|
+
this.#pendingNode = node;
|
|
520
|
+
const controller = new AbortController();
|
|
521
|
+
this.#pendingController = controller;
|
|
522
|
+
if (this.loadChildren) this.#invokeLoadChildren(node, depth, controller).catch(() => {});
|
|
523
|
+
}
|
|
524
|
+
this.requestUpdate();
|
|
525
|
+
}
|
|
526
|
+
async #invokeLoadChildren(node, depth, controller) {
|
|
527
|
+
try {
|
|
528
|
+
const children = [...await collectDataResult(this.loadChildren({
|
|
529
|
+
node,
|
|
530
|
+
depth
|
|
531
|
+
}, controller.signal), controller.signal)];
|
|
532
|
+
if (controller.signal.aborted) return;
|
|
533
|
+
node.children = children;
|
|
534
|
+
this.#pendingNode = void 0;
|
|
535
|
+
this.#pendingController = void 0;
|
|
536
|
+
this.dispatchEvent(new CustomEvent(`expand`, {
|
|
537
|
+
detail: {
|
|
538
|
+
node,
|
|
539
|
+
depth
|
|
540
|
+
},
|
|
541
|
+
bubbles: true,
|
|
542
|
+
composed: true
|
|
543
|
+
}));
|
|
544
|
+
this.requestUpdate();
|
|
545
|
+
} catch {
|
|
546
|
+
if (controller.signal.aborted) return;
|
|
547
|
+
node.children = [];
|
|
548
|
+
this.#pendingNode = void 0;
|
|
549
|
+
this.#pendingController = void 0;
|
|
550
|
+
this.requestUpdate();
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
#onSegmentMenuCommand(e, node, depth) {
|
|
554
|
+
const key = e.detail.command;
|
|
555
|
+
if (this.leadingCaret) {
|
|
556
|
+
const child = node.children?.find((c) => c.item.key === key);
|
|
557
|
+
if (child) {
|
|
558
|
+
this.#onChildClick(child, depth + 1);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (this.#currentLeadingSiblings) {
|
|
562
|
+
const sibling = this.#currentLeadingSiblings.find((c) => c.item.key === key);
|
|
563
|
+
if (sibling) this.#onChildClick(sibling, depth);
|
|
564
|
+
this.#currentLeadingSiblings = void 0;
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
const child = node.children?.find((c) => c.item.key === key);
|
|
569
|
+
if (child) this.#onChildClick(child, depth + 1);
|
|
570
|
+
}
|
|
571
|
+
#currentLeadingSiblings;
|
|
572
|
+
#getSiblingMenuItems(pathNodes, index) {
|
|
573
|
+
if (index === 0) {
|
|
574
|
+
if (!this.hideRoot || !this.root) return [];
|
|
575
|
+
const siblings = [...this.root.children ?? []].sort((a, b) => (a.item.label ?? ``).localeCompare(b.item.label ?? ``));
|
|
576
|
+
this.#currentLeadingSiblings = siblings;
|
|
577
|
+
return siblings.map((sibling) => html`
|
|
578
|
+
<ixfx-menu-item
|
|
579
|
+
label="${sibling.item.label}"
|
|
580
|
+
command="${sibling.item.key}"
|
|
581
|
+
icon-name="${sibling.item.icon ?? nothing}"
|
|
582
|
+
@click=${() => {
|
|
583
|
+
this.#onChildClick(sibling, index);
|
|
584
|
+
}}
|
|
585
|
+
></ixfx-menu-item>
|
|
586
|
+
`);
|
|
587
|
+
}
|
|
588
|
+
const siblings = [...pathNodes[index - 1].children ?? []].sort((a, b) => (a.item.label ?? ``).localeCompare(b.item.label ?? ``));
|
|
589
|
+
this.#currentLeadingSiblings = siblings;
|
|
590
|
+
return siblings.map((sibling) => html`
|
|
591
|
+
<ixfx-menu-item
|
|
592
|
+
label="${sibling.item.label}"
|
|
593
|
+
command="${sibling.item.key}"
|
|
594
|
+
icon-name="${sibling.item.icon ?? nothing}"
|
|
595
|
+
@click=${() => {
|
|
596
|
+
this.#onChildClick(sibling, index);
|
|
597
|
+
}}
|
|
598
|
+
></ixfx-menu-item>
|
|
599
|
+
`);
|
|
600
|
+
}
|
|
601
|
+
#onChildClick(node, depth) {
|
|
602
|
+
this._openIdx = -1;
|
|
603
|
+
this.#setSelected(node);
|
|
604
|
+
this.dispatchEvent(new CustomEvent(`item-click`, {
|
|
605
|
+
detail: {
|
|
606
|
+
node,
|
|
607
|
+
depth
|
|
608
|
+
},
|
|
609
|
+
bubbles: true,
|
|
610
|
+
composed: true
|
|
611
|
+
}));
|
|
612
|
+
}
|
|
613
|
+
/** Navigate to a node by key path. Returns false if any key is not found in already-loaded children. */
|
|
614
|
+
navigateTo(keys) {
|
|
615
|
+
if (!this.root?.children) return false;
|
|
616
|
+
let current = this.root;
|
|
617
|
+
for (const key of keys) {
|
|
618
|
+
const found = current?.children?.find((n) => n.item.key === key);
|
|
619
|
+
if (!found) return false;
|
|
620
|
+
current = found;
|
|
621
|
+
}
|
|
622
|
+
if (current && current !== this.root) this.#setSelected(current);
|
|
623
|
+
return true;
|
|
624
|
+
}
|
|
625
|
+
/** Navigate to the first node matching the predicate. Returns false if not found. */
|
|
626
|
+
navigateToNode(predicate) {
|
|
627
|
+
if (!this.root) return false;
|
|
628
|
+
const keyPath = this.#findNodePath(this.root.children ?? [], predicate);
|
|
629
|
+
if (!keyPath) return false;
|
|
630
|
+
return this.navigateTo(keyPath);
|
|
631
|
+
}
|
|
632
|
+
#findNodePath(nodes, predicate, prefix = []) {
|
|
633
|
+
for (const node of nodes) {
|
|
634
|
+
const path = [...prefix, node.item.key];
|
|
635
|
+
if (predicate(node)) return path;
|
|
636
|
+
if (node.children?.length) {
|
|
637
|
+
const result = this.#findNodePath(node.children, predicate, path);
|
|
638
|
+
if (result) return result;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
#onMenuCommand(e) {
|
|
643
|
+
const node = this.selectedNode;
|
|
644
|
+
if (!node?.children) return;
|
|
645
|
+
const key = e.detail.command;
|
|
646
|
+
const child = node.children.find((c) => c.item.key === key);
|
|
647
|
+
if (child) {
|
|
648
|
+
const depth = this.root ? this.#findPath(this.root, node)?.length ?? 1 : 1;
|
|
649
|
+
this.#onChildClick(child, depth);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
render() {
|
|
653
|
+
const r = this.root;
|
|
654
|
+
const sel = this.selectedNode;
|
|
655
|
+
if (!r || !sel) return html``;
|
|
656
|
+
this.inputMode = this.tickled.inputMode;
|
|
657
|
+
let pathNodes = this.#findPath(r, sel) ?? [r];
|
|
658
|
+
if (this.hideRoot && pathNodes.length > 1) pathNodes = pathNodes.slice(1);
|
|
659
|
+
this.#hasChildOptions();
|
|
660
|
+
const parts = [];
|
|
661
|
+
let segmentId = 0;
|
|
662
|
+
pathNodes.forEach((node, i) => {
|
|
663
|
+
const isLast = i === pathNodes.length - 1;
|
|
664
|
+
const isPending = this.#pendingNode === node;
|
|
665
|
+
const isOpen = this._openIdx === i;
|
|
666
|
+
const hasChildren = node.item.isLeaf !== true && (node.children === void 0 || node.children.length > 0);
|
|
667
|
+
const isTickled = this.tickled.isTickled(i);
|
|
668
|
+
const showLeadingCaret = this.leadingCaret && (i > 0 || this.hideRoot) && hasChildren;
|
|
669
|
+
const showTrailingCaret = !this.leadingCaret && hasChildren || this.leadingCaret && isLast && hasChildren;
|
|
670
|
+
const siblingMenuItems = showLeadingCaret ? this.#getSiblingMenuItems(pathNodes, i) : [];
|
|
671
|
+
const childMenuItems = (node.children ?? []).map((c) => html`
|
|
672
|
+
<ixfx-menu-item
|
|
673
|
+
label="${c.item.label}"
|
|
674
|
+
command="${c.item.key}"
|
|
675
|
+
icon-name="${c.item.icon ?? nothing}"
|
|
676
|
+
></ixfx-menu-item>
|
|
677
|
+
`);
|
|
678
|
+
if (this.caretEmbedded) {
|
|
679
|
+
const canTruncate = !this.noTruncate && !isLast && !isTickled;
|
|
680
|
+
parts.push(html`
|
|
681
|
+
<div class="item crumb-segment ${isTickled ? `tickled` : ``} ${canTruncate ? `truncatable` : ``} ${this.leadingCaret ? `leading-caret` : ``} ${isLast ? `last-label` : ``}" data-segment-id="${i}" data-path-index="${i}"
|
|
682
|
+
@click=${(e) => {
|
|
683
|
+
if (e.target.closest(`.caret`)) return;
|
|
684
|
+
this.#onLabelClick(node, i);
|
|
685
|
+
}}
|
|
686
|
+
>
|
|
687
|
+
${showLeadingCaret ? html`
|
|
688
|
+
<span class="caret ${isOpen ? `open` : ``} ${isPending ? `pending` : ``}">
|
|
689
|
+
${isPending ? html`<span class="loading-spinner"></span>` : html`
|
|
690
|
+
<ixfx-menu-trigger mode="trigger" label="›" .tabStop=${false} @menu-command=${(e) => this.#onSegmentMenuCommand(e, node, i)}>
|
|
691
|
+
<ixfx-menu-container slot="menu">
|
|
692
|
+
${siblingMenuItems}
|
|
693
|
+
</ixfx-menu-container>
|
|
694
|
+
</ixfx-menu-trigger>
|
|
695
|
+
`}
|
|
696
|
+
</span>
|
|
697
|
+
` : nothing}
|
|
698
|
+
<span class="label">${node.item.label}</span>
|
|
699
|
+
${showTrailingCaret ? html`
|
|
700
|
+
<span class="caret ${isOpen ? `open` : ``} ${isPending ? `pending` : ``}">
|
|
701
|
+
${isPending ? html`<span class="loading-spinner"></span>` : html`
|
|
702
|
+
<ixfx-menu-trigger mode="trigger" label="›" .tabStop=${false} placement="right-start" @menu-command=${(e) => this.#onSegmentMenuCommand(e, node, i)}>
|
|
703
|
+
<ixfx-menu-container slot="menu">
|
|
704
|
+
${childMenuItems}
|
|
705
|
+
</ixfx-menu-container>
|
|
706
|
+
</ixfx-menu-trigger>
|
|
707
|
+
`}
|
|
708
|
+
</span>
|
|
709
|
+
` : nothing}
|
|
710
|
+
</div>
|
|
711
|
+
`);
|
|
712
|
+
} else {
|
|
713
|
+
const leadingCaretTickled = showLeadingCaret ? this.tickled.isTickled(segmentId) : false;
|
|
714
|
+
if (showLeadingCaret) {
|
|
715
|
+
parts.push(html`
|
|
716
|
+
<div class="item crumb-segment ${leadingCaretTickled ? `tickled` : ``}" data-segment-id="${segmentId}" data-path-index="${i}"
|
|
717
|
+
@click=${(e) => {
|
|
718
|
+
const trigger = e.target.closest(`.crumb-segment`)?.querySelector(`ixfx-menu-trigger`);
|
|
719
|
+
if (trigger) trigger.openMenu();
|
|
720
|
+
}}
|
|
721
|
+
>
|
|
722
|
+
<span class="caret ${isOpen ? `open` : ``} ${isPending ? `pending` : ``}">
|
|
723
|
+
${isPending ? html`<span class="loading-spinner"></span>` : html`
|
|
724
|
+
<ixfx-menu-trigger mode="trigger" label="›" .tabStop=${false} placement="right-start" @menu-command=${(e) => this.#onSegmentMenuCommand(e, node, i)}>
|
|
725
|
+
<ixfx-menu-container slot="menu">
|
|
726
|
+
${siblingMenuItems}
|
|
727
|
+
</ixfx-menu-container>
|
|
728
|
+
</ixfx-menu-trigger>
|
|
729
|
+
`}
|
|
730
|
+
</span>
|
|
731
|
+
</div>
|
|
732
|
+
`);
|
|
733
|
+
segmentId++;
|
|
734
|
+
}
|
|
735
|
+
const labelTickled = this.tickled.isTickled(segmentId);
|
|
736
|
+
const canTruncate = !this.noTruncate && !isLast && !labelTickled;
|
|
737
|
+
parts.push(html`
|
|
738
|
+
<div class="item crumb-segment ${labelTickled ? `tickled` : ``} ${canTruncate ? `truncatable` : ``} ${isLast ? `last-label` : ``}" data-segment-id="${segmentId}" data-path-index="${i}"
|
|
739
|
+
@click=${(e) => {
|
|
740
|
+
if (e.target.closest(`.caret`)) return;
|
|
741
|
+
this.#onLabelClick(node, i);
|
|
742
|
+
}}
|
|
743
|
+
>
|
|
744
|
+
<span class="label">${node.item.label}</span>
|
|
745
|
+
</div>
|
|
746
|
+
`);
|
|
747
|
+
segmentId++;
|
|
748
|
+
if (showTrailingCaret) {
|
|
749
|
+
const trailingCaretTickled = this.tickled.isTickled(segmentId);
|
|
750
|
+
parts.push(html`
|
|
751
|
+
<div class="item crumb-segment ${trailingCaretTickled ? `tickled` : ``}" data-segment-id="${segmentId}" data-path-index="${i}"
|
|
752
|
+
@click=${(e) => {
|
|
753
|
+
const trigger = e.target.closest(`.crumb-segment`)?.querySelector(`ixfx-menu-trigger`);
|
|
754
|
+
if (trigger) trigger.openMenu();
|
|
755
|
+
}}
|
|
756
|
+
>
|
|
757
|
+
<span class="caret ${isOpen ? `open` : ``} ${isPending ? `pending` : ``}">
|
|
758
|
+
${isPending ? html`<span class="loading-spinner"></span>` : html`
|
|
759
|
+
<ixfx-menu-trigger mode="trigger" label="›" .tabStop=${false} @menu-command=${(e) => this.#onSegmentMenuCommand(e, node, i)}>
|
|
760
|
+
<ixfx-menu-container slot="menu">
|
|
761
|
+
${childMenuItems}
|
|
762
|
+
</ixfx-menu-container>
|
|
763
|
+
</ixfx-menu-trigger>
|
|
764
|
+
`}
|
|
765
|
+
</span>
|
|
766
|
+
</div>
|
|
767
|
+
`);
|
|
768
|
+
segmentId++;
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
});
|
|
772
|
+
return html`
|
|
773
|
+
<div
|
|
774
|
+
class="host-container scroll-fade-x"
|
|
775
|
+
tabindex="0"
|
|
776
|
+
@focus=${this.#onFocus}
|
|
777
|
+
@blur=${this.#onBlur}
|
|
778
|
+
@keydown=${this.#onKeyDown}
|
|
779
|
+
@click=${this.#onHostClick}
|
|
780
|
+
@menu-trigger-close=${this.#onMenuTriggerClose}
|
|
781
|
+
@mouseout=${(e) => this.tickled.handlePointerLeave(e)}
|
|
782
|
+
>
|
|
783
|
+
<div class="parts"
|
|
784
|
+
@mouseover=${(e) => {
|
|
785
|
+
if (this.#isWheelScrolling) return;
|
|
786
|
+
const target = e.target;
|
|
787
|
+
if (!(target instanceof HTMLElement)) return;
|
|
788
|
+
const segment = target.closest(`.crumb-segment`);
|
|
789
|
+
if (!segment) return;
|
|
790
|
+
const segmentId = parseInt(segment.dataset.segmentId ?? ``, 10);
|
|
791
|
+
if (Number.isNaN(segmentId)) return;
|
|
792
|
+
const pathIndex = parseInt(segment.dataset.pathIndex ?? ``, 10);
|
|
793
|
+
const node = pathNodes[pathIndex];
|
|
794
|
+
if (!node) return;
|
|
795
|
+
this.tickled.handlePointerEnter(segmentId);
|
|
796
|
+
this.dispatchEvent(new CustomEvent(`tickle`, {
|
|
797
|
+
detail: {
|
|
798
|
+
node,
|
|
799
|
+
depth: pathIndex
|
|
800
|
+
},
|
|
801
|
+
bubbles: true,
|
|
802
|
+
composed: true
|
|
803
|
+
}));
|
|
804
|
+
}}
|
|
805
|
+
>${parts}<div class="trailing"></div></div>
|
|
806
|
+
${this.showSuggestions ? this.#renderChildOptions() : nothing}
|
|
807
|
+
</div>
|
|
808
|
+
`;
|
|
809
|
+
}
|
|
810
|
+
#renderChildOptions() {
|
|
811
|
+
const s = this.selectedNode;
|
|
812
|
+
if (s === void 0) return nothing;
|
|
813
|
+
const isPending = this.#pendingNode === s;
|
|
814
|
+
const children = s.children ?? [];
|
|
815
|
+
if (children.length === 0 && !isPending) return nothing;
|
|
816
|
+
if (isPending) return html`
|
|
817
|
+
<div class="horiz-select">
|
|
818
|
+
<div class="horiz-select-items">
|
|
819
|
+
<span class="loading-spinner"></span>
|
|
820
|
+
</div>
|
|
821
|
+
</div>
|
|
822
|
+
`;
|
|
823
|
+
return html`
|
|
824
|
+
<ixfx-narrowed-text
|
|
825
|
+
class="horiz-select"
|
|
826
|
+
selection-mode="single"
|
|
827
|
+
orientation="horizontal"
|
|
828
|
+
nowrap
|
|
829
|
+
width=${this.#getChildOptionsWidth()}
|
|
830
|
+
@change=${this.#onNarrowedTextChange}
|
|
831
|
+
@narrowed-text-blur=${this.#onNarrowedTextBlur}
|
|
832
|
+
@narrowed-text-shift-tab=${this.#onNarrowedTextShiftTab}
|
|
833
|
+
>
|
|
834
|
+
${children.map((c) => html`
|
|
835
|
+
<span data-value="${c.item.key}" data-label="${c.item.label}"></span>
|
|
836
|
+
`)}
|
|
837
|
+
</ixfx-narrowed-text>
|
|
838
|
+
`;
|
|
839
|
+
}
|
|
840
|
+
#onNarrowedTextChange(e) {
|
|
841
|
+
e.stopPropagation();
|
|
842
|
+
const detail = e.detail;
|
|
843
|
+
const node = this.selectedNode;
|
|
844
|
+
if (!node?.children) return;
|
|
845
|
+
const child = node.children.find((c) => c.item.key === detail.item.value);
|
|
846
|
+
if (child) {
|
|
847
|
+
const depth = this.root ? this.#findPath(this.root, node)?.length ?? 1 : 1;
|
|
848
|
+
this.#onChildClick(child, depth);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
#getChildOptionsWidth() {
|
|
852
|
+
return `var(--child-options-width, 50ch)`;
|
|
853
|
+
}
|
|
854
|
+
static {
|
|
855
|
+
this.styles = [
|
|
856
|
+
themeFallbacks,
|
|
857
|
+
tickledStyles,
|
|
858
|
+
tickledItemStyles,
|
|
859
|
+
scrollFadeStyles(`x`),
|
|
860
|
+
css`
|
|
861
|
+
:host {
|
|
862
|
+
--crumb-item-bg: var(--item-bg, transparent);
|
|
863
|
+
--crumb-item-bg-tickled: var(--item-bg-tickled);
|
|
864
|
+
--crumb-item-text-tickled: var(--item-text-tickled);
|
|
865
|
+
--crumb-item-border: var(--item-border);
|
|
866
|
+
--crumb-item-border-tickled: var(--item-border-tickled);
|
|
867
|
+
--crumb-item-padding: var(--space-s, 2px);
|
|
868
|
+
--crumb-item-border-radius: var(--item-border-radius);
|
|
869
|
+
--crumb-item-gap: var(--item-gap, var(--space-xs));
|
|
870
|
+
--crumb-separator: var(--surface-muted-text);
|
|
871
|
+
--crumb-truncate-min-width: 10ch;
|
|
872
|
+
display: flex;
|
|
873
|
+
width: 100%;
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
/* Outline goes on :host, not .host-container: .host-container carries the
|
|
877
|
+
* scroll-fade mask-image, and CSS masks clip everything painted outside
|
|
878
|
+
* the masked box - including an outline, which paints outside the border edge. */
|
|
879
|
+
:host(:focus-within) {
|
|
880
|
+
outline: 2px solid var(--accent);
|
|
881
|
+
outline-offset: 2px;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
/* Edge fade (shows/hides based on scroll position) comes from the
|
|
885
|
+
* shared .scroll-fade-x class - see ../styles/scroll-fade.ts */
|
|
886
|
+
.host-container {
|
|
887
|
+
display: flex;
|
|
888
|
+
width: 100%;
|
|
889
|
+
outline: none;
|
|
890
|
+
overflow: scroll;
|
|
891
|
+
scroll-snap-type: x mandatory;
|
|
892
|
+
scrollbar-width: none;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
.parts {
|
|
896
|
+
display: flex;
|
|
897
|
+
gap: var(--space-s);
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
.trailing {
|
|
901
|
+
flex: 1;
|
|
902
|
+
min-width: 1em;
|
|
903
|
+
cursor: pointer;
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
.crumb-segment {
|
|
907
|
+
display: flex;
|
|
908
|
+
align-items: center;
|
|
909
|
+
flex-shrink: 0;
|
|
910
|
+
background: var(--crumb-item-bg);
|
|
911
|
+
border: var(--crumb-item-border);
|
|
912
|
+
border-radius: var(--crumb-item-border-radius);
|
|
913
|
+
padding:0;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
.crumb-segment.leading-caret {
|
|
917
|
+
flex-direction: row;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
.crumb-segment.tickled {
|
|
921
|
+
background: var(--crumb-item-bg-tickled);
|
|
922
|
+
border-color: var(--crumb-item-border-tickled);
|
|
923
|
+
color: var(--crumb-item-text-tickled);
|
|
924
|
+
flex-shrink: 0;
|
|
925
|
+
min-width: auto;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
.crumb-segment.truncatable {
|
|
929
|
+
flex-shrink: 1;
|
|
930
|
+
min-width: min(var(--crumb-truncate-min-width), auto);
|
|
931
|
+
overflow: hidden;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
.crumb-segment.truncatable .label {
|
|
935
|
+
overflow: hidden;
|
|
936
|
+
text-overflow: ellipsis;
|
|
937
|
+
white-space: nowrap;
|
|
938
|
+
min-width: 0;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
.label {
|
|
942
|
+
padding: var(--crumb-item-padding);
|
|
943
|
+
cursor: pointer;
|
|
944
|
+
white-space: nowrap;
|
|
945
|
+
color: inherit;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
.crumb-segment.last-label .label {
|
|
949
|
+
color: var(--crumb-last-label-color, inherit);
|
|
950
|
+
font-style: var(--crumb-last-label-font-style, inherit);
|
|
951
|
+
font-weight: var(--crumb-last-label-font-weight, inherit);
|
|
952
|
+
text-decoration: var(--crumb-last-label-text-decoration, inherit);
|
|
953
|
+
text-underline-offset: var(--crumb-last-label-text-underline-offset, auto);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
.crumb-segment.tickled .label {
|
|
957
|
+
color: var(--crumb-item-text-tickled);
|
|
958
|
+
overflow: visible;
|
|
959
|
+
text-overflow: clip;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.crumb-segment ixfx-menu-trigger {
|
|
963
|
+
--ixfx-button-padding: var(--space-s, 2px);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
.caret {
|
|
967
|
+
position: relative;
|
|
968
|
+
cursor: pointer;
|
|
969
|
+
color: var(--crumb-separator);
|
|
970
|
+
display: inline-flex;
|
|
971
|
+
align-items: center;
|
|
972
|
+
justify-content: center;
|
|
973
|
+
transition: all 0.2s ease-in-out;
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
.caret.open {
|
|
977
|
+
background: color-mix(in srgb, var(--surface-5) 40%, transparent);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
.caret.pending {
|
|
981
|
+
display: inline-flex;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
.caret > ixfx-menu-trigger {
|
|
985
|
+
display: inline-flex;
|
|
986
|
+
margin: 0;
|
|
987
|
+
--_trigger-hover-bg: transparent;
|
|
988
|
+
--_trigger-hover-opacity: 0.6;
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
.caret > ixfx-menu-trigger::part(base) {
|
|
992
|
+
background: none;
|
|
993
|
+
border: none;
|
|
994
|
+
color: inherit;
|
|
995
|
+
cursor: pointer;
|
|
996
|
+
font-size: inherit;
|
|
997
|
+
line-height: 1;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
.caret > ixfx-menu-trigger::part(base):hover {
|
|
1001
|
+
background: none;
|
|
1002
|
+
opacity: 0.6;
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
.separator {
|
|
1006
|
+
margin-left: var(--crumb-item-gap);
|
|
1007
|
+
margin-right: var(--crumb-item-gap);
|
|
1008
|
+
color: var(--crumb-separator);
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
.separator-trigger {
|
|
1012
|
+
display: inline-flex;
|
|
1013
|
+
margin-left: var(--crumb-item-gap);
|
|
1014
|
+
margin-right: var(--crumb-item-gap);
|
|
1015
|
+
--_trigger-hover-bg: transparent;
|
|
1016
|
+
--_trigger-hover-opacity: 0.6;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
.separator-trigger::part(base) {
|
|
1020
|
+
background: none;
|
|
1021
|
+
border: none;
|
|
1022
|
+
color: var(--crumb-separator);
|
|
1023
|
+
padding: 0;
|
|
1024
|
+
cursor: pointer;
|
|
1025
|
+
font-size: inherit;
|
|
1026
|
+
line-height: 1;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.separator-trigger::part(base):hover {
|
|
1030
|
+
background: none;
|
|
1031
|
+
opacity: 0.6;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
.separator-trigger.tickled::part(base) {
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
ixfx-menu-trigger {
|
|
1038
|
+
display: none;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
.horiz-select > ixfx-menu-trigger {
|
|
1042
|
+
display: inline-flex;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.horiz-select {
|
|
1046
|
+
display: flex;
|
|
1047
|
+
min-width: 5ch;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
.loading-spinner {
|
|
1051
|
+
display: inline-block;
|
|
1052
|
+
width: 12px;
|
|
1053
|
+
height: 12px;
|
|
1054
|
+
border: 2px solid var(--surface-5);
|
|
1055
|
+
border-top-color: var(--accent);
|
|
1056
|
+
border-radius: 50%;
|
|
1057
|
+
animation: crumb-spin 0.7s linear infinite;
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
@keyframes crumb-spin {
|
|
1061
|
+
to { transform: rotate(360deg); }
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
::slotted(*), option {
|
|
1065
|
+
user-select: none;
|
|
1066
|
+
scroll-snap-align: start;
|
|
1067
|
+
}
|
|
1068
|
+
`
|
|
1069
|
+
];
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
__decorate([property({ type: Object })], CrumbNavigationElement.prototype, "root", void 0);
|
|
1073
|
+
__decorate([property({ attribute: false })], CrumbNavigationElement.prototype, "model", void 0);
|
|
1074
|
+
__decorate([property({ type: Object })], CrumbNavigationElement.prototype, "selectedNode", void 0);
|
|
1075
|
+
__decorate([state()], CrumbNavigationElement.prototype, "_selectedNodes", void 0);
|
|
1076
|
+
__decorate([property({ attribute: false })], CrumbNavigationElement.prototype, "loadChildren", void 0);
|
|
1077
|
+
__decorate([property({ attribute: false })], CrumbNavigationElement.prototype, "filterPredicate", void 0);
|
|
1078
|
+
__decorate([property({
|
|
1079
|
+
reflect: true,
|
|
1080
|
+
attribute: `exclusivity`
|
|
1081
|
+
})], CrumbNavigationElement.prototype, "exclusivity", void 0);
|
|
1082
|
+
__decorate([property({
|
|
1083
|
+
reflect: true,
|
|
1084
|
+
attribute: `selection-filter`
|
|
1085
|
+
})], CrumbNavigationElement.prototype, "selectionFilter", void 0);
|
|
1086
|
+
__decorate([state()], CrumbNavigationElement.prototype, "_openIdx", void 0);
|
|
1087
|
+
__decorate([state()], CrumbNavigationElement.prototype, "_isFocused", void 0);
|
|
1088
|
+
__decorate([state()], CrumbNavigationElement.prototype, "_menuOpen", void 0);
|
|
1089
|
+
__decorate([state()], CrumbNavigationElement.prototype, "_focusOnNarrowedText", void 0);
|
|
1090
|
+
__decorate([property({
|
|
1091
|
+
reflect: true,
|
|
1092
|
+
attribute: `input-mode`
|
|
1093
|
+
})], CrumbNavigationElement.prototype, "inputMode", void 0);
|
|
1094
|
+
__decorate([property({
|
|
1095
|
+
type: Boolean,
|
|
1096
|
+
reflect: true,
|
|
1097
|
+
attribute: `no-truncate`
|
|
1098
|
+
})], CrumbNavigationElement.prototype, "noTruncate", void 0);
|
|
1099
|
+
__decorate([property({
|
|
1100
|
+
type: Boolean,
|
|
1101
|
+
reflect: true,
|
|
1102
|
+
attribute: `show-suggestions`
|
|
1103
|
+
})], CrumbNavigationElement.prototype, "showSuggestions", void 0);
|
|
1104
|
+
__decorate([property({
|
|
1105
|
+
type: Boolean,
|
|
1106
|
+
reflect: true,
|
|
1107
|
+
attribute: `leading-caret`
|
|
1108
|
+
})], CrumbNavigationElement.prototype, "leadingCaret", void 0);
|
|
1109
|
+
__decorate([property({
|
|
1110
|
+
type: Boolean,
|
|
1111
|
+
reflect: true,
|
|
1112
|
+
attribute: `caret-embedded`
|
|
1113
|
+
})], CrumbNavigationElement.prototype, "caretEmbedded", void 0);
|
|
1114
|
+
__decorate([property({
|
|
1115
|
+
type: Boolean,
|
|
1116
|
+
reflect: true,
|
|
1117
|
+
attribute: `hide-root`
|
|
1118
|
+
})], CrumbNavigationElement.prototype, "hideRoot", void 0);
|
|
1119
|
+
CrumbNavigationElement = __decorate([safeCustomElement(`ixfx-crumb-navigation`)], CrumbNavigationElement);
|
|
1120
|
+
//#endregion
|
|
1121
|
+
export { scrollFadeStyles as n, CrumbNavigationElement as t };
|
|
1122
|
+
|
|
1123
|
+
//# sourceMappingURL=crumb-navigation-DTwJ8468.js.map
|