le-kit 0.3.0 → 0.3.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.
Files changed (47) hide show
  1. package/dist/cjs/{le-button_13.cjs.entry.js → le-bar_16.cjs.entry.js} +951 -5
  2. package/dist/cjs/le-kit.cjs.js +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/collection/components/le-bar/le-bar.js +65 -13
  5. package/dist/collection/components/le-bar/le-bar.js.map +1 -1
  6. package/dist/collection/components/le-component/le-component.js +1 -1
  7. package/dist/collection/components/le-component/le-component.js.map +1 -1
  8. package/dist/collection/components/le-navigation/le-navigation.js +3 -3
  9. package/dist/collection/components/le-navigation/le-navigation.js.map +1 -1
  10. package/dist/collection/components/le-select/le-select.js +3 -3
  11. package/dist/collection/components/le-select/le-select.js.map +1 -1
  12. package/dist/collection/dist/components/assets/custom-elements.json +1053 -1035
  13. package/dist/components/assets/custom-elements.json +1053 -1035
  14. package/dist/components/le-bar2.js +46 -13
  15. package/dist/components/le-bar2.js.map +1 -1
  16. package/dist/components/le-button2.js +4 -4
  17. package/dist/components/le-button2.js.map +1 -1
  18. package/dist/components/le-navigation.js +2 -2
  19. package/dist/components/le-navigation.js.map +1 -1
  20. package/dist/docs.json +33 -4
  21. package/dist/esm/{le-button_13.entry.js → le-bar_16.entry.js} +951 -8
  22. package/dist/esm/le-kit.js +1 -1
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/le-kit/dist/components/assets/custom-elements.json +1053 -1035
  25. package/dist/le-kit/le-kit.esm.js +1 -1
  26. package/dist/le-kit/p-dea78542.entry.js +2 -0
  27. package/dist/le-kit/p-dea78542.entry.js.map +1 -0
  28. package/dist/types/components/le-bar/le-bar.d.ts +6 -0
  29. package/dist/types/components.d.ts +14 -4
  30. package/package.json +1 -1
  31. package/dist/cjs/le-bar.cjs.entry.js +0 -428
  32. package/dist/cjs/le-icon.cjs.entry.js +0 -110
  33. package/dist/cjs/le-navigation.cjs.entry.js +0 -393
  34. package/dist/esm/le-bar.entry.js +0 -426
  35. package/dist/esm/le-bar.entry.js.map +0 -1
  36. package/dist/esm/le-icon.entry.js +0 -108
  37. package/dist/esm/le-icon.entry.js.map +0 -1
  38. package/dist/esm/le-navigation.entry.js +0 -391
  39. package/dist/esm/le-navigation.entry.js.map +0 -1
  40. package/dist/le-kit/p-2102a152.entry.js +0 -2
  41. package/dist/le-kit/p-2102a152.entry.js.map +0 -1
  42. package/dist/le-kit/p-4f11ea11.entry.js +0 -2
  43. package/dist/le-kit/p-4f11ea11.entry.js.map +0 -1
  44. package/dist/le-kit/p-53d9c363.entry.js +0 -2
  45. package/dist/le-kit/p-53d9c363.entry.js.map +0 -1
  46. package/dist/le-kit/p-94f774af.entry.js +0 -2
  47. package/dist/le-kit/p-94f774af.entry.js.map +0 -1
@@ -1,7 +1,460 @@
1
- import { r as registerInstance, d as createEvent, c as getElement, h, F as Fragment, H as Host, e as getAssetPath, f as getLeKitConfig } from './index-BqH-zsXr.js';
2
- import { c as classnames, o as observeModeChanges, g as generateId } from './utils-CdBk0DdF.js';
1
+ import { r as registerInstance, d as createEvent, c as getElement, h, H as Host, F as Fragment, e as getAssetPath, f as getLeKitConfig } from './index-BqH-zsXr.js';
2
+ import { g as generateId, c as classnames, o as observeModeChanges } from './utils-CdBk0DdF.js';
3
3
  import { leConfirm } from './index.js';
4
4
 
5
+ const leBarCss = () => `:host{display:block;--le-bar-gap:var(--le-spacing-2);--le-bar-padding:var(--le-spacing-2);--le-bar-min-height:2.5rem;--le-bar-background:transparent;--le-bar-border-color:var(--le-color-border);--le-bar-border-radius:var(--le-radius-md);--le-bar-button-size:2rem;--le-bar-button-color:var(--le-color-text-primary);--le-bar-button-hover-bg:var(--le-color-gray-100);--le-bar-button-border-radius:var(--le-radius-sm);--le-bar-arrow-size:1.5rem;--le-bar-popover-min-width:200px;--le-bar-popover-gap:var(--le-spacing-1)}.bar-container{display:flex;align-items:center;gap:var(--le-bar-gap);min-height:var(--le-bar-min-height);background:var(--le-bar-background);border-radius:var(--le-bar-border-radius);padding:var(--le-bar-padding)}.bar-container.align-start{justify-content:flex-start}.bar-container.align-end .bar-items{justify-content:flex-end}.bar-container.align-center .bar-items{justify-content:center}.bar-container.align-stretch .bar-items{justify-content:space-evenly}.bar-items{display:flex;flex-wrap:wrap;align-items:center;gap:var(--le-bar-gap);overflow:hidden;min-width:0;flex:1 1 0%;position:relative}.bar-items[style*="height"]{overflow:hidden}.bar-items.is-scrollable{flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x mandatory;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.bar-items.is-scrollable::-webkit-scrollbar{display:none}.bar-items.is-scrollable ::slotted(*){scroll-snap-align:start;flex-shrink:0}.bar-items.is-wrapping{flex-wrap:wrap;overflow:visible;height:auto !important}.bar-controls{display:flex;align-items:center;gap:var(--le-spacing-1);flex-shrink:0}.bar-controls-start{order:-1}.bar-controls-end{order:1}.bar-more-button,.bar-hamburger-button,.bar-all-menu-button{display:inline-flex;align-items:center;justify-content:center;width:var(--le-bar-button-size);height:var(--le-bar-button-size);padding:0;border:none;background:transparent;color:var(--le-bar-button-color);border-radius:var(--le-bar-button-border-radius);cursor:pointer;transition:background-color 0.15s ease}.bar-more-button:hover,.bar-hamburger-button:hover,.bar-all-menu-button:hover{background:var(--le-bar-button-hover-bg)}.bar-more-button:focus-visible,.bar-hamburger-button:focus-visible,.bar-all-menu-button:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.bar-arrow{display:inline-flex;align-items:center;justify-content:center;width:var(--le-bar-arrow-size);height:var(--le-bar-arrow-size);padding:0;border:none;background:transparent;color:var(--le-bar-button-color);border-radius:var(--le-bar-button-border-radius);cursor:pointer;transition:background-color 0.15s ease, opacity 0.15s ease}.bar-arrow:hover:not(:disabled){background:var(--le-bar-button-hover-bg)}.bar-arrow:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.bar-arrow:disabled,.bar-arrow.disabled{opacity:0.3;cursor:not-allowed}.arrow-icon-start{transform:rotate(90deg)}.arrow-icon-end{transform:rotate(-90deg)}.bar-overflow-trigger,.bar-all-menu-trigger{display:inline-flex}.bar-popover-content{display:flex;flex-direction:column;gap:var(--le-bar-popover-gap);min-width:var(--le-bar-popover-min-width);padding:var(--le-spacing-2)}.bar-popover-item{cursor:pointer}.bar-popover-item:hover{background:var(--le-bar-button-hover-bg);border-radius:var(--le-bar-button-border-radius)}:host(.hamburger-active) .bar-items{visibility:hidden;pointer-events:none}`;
6
+
7
+ const LeBar = class {
8
+ constructor(hostRef) {
9
+ registerInstance(this, hostRef);
10
+ this.leBarOverflowChange = createEvent(this, "leBarOverflowChange");
11
+ }
12
+ get el() { return getElement(this); }
13
+ /**
14
+ * Overflow behavior when items don't fit on one row.
15
+ * - `more`: Overflow items appear in a "more" dropdown
16
+ * - `scroll`: Items scroll horizontally with optional arrows
17
+ * - `hamburger`: All items go into a hamburger menu if any overflow
18
+ * - `wrap`: Items wrap to additional rows
19
+ */
20
+ overflow = 'more';
21
+ /**
22
+ * Alignment of items within the bar (maps to justify-content).
23
+ */
24
+ alignItems = 'start';
25
+ /**
26
+ * Show scroll arrows when overflow is "scroll".
27
+ */
28
+ arrows = false;
29
+ /**
30
+ * Disable the internal overflow popover.
31
+ * When true, the bar still detects overflow and hides items,
32
+ * but doesn't render its own popover. Use this when providing
33
+ * custom overflow handling via the leBarOverflowChange event.
34
+ */
35
+ disablePopover = false;
36
+ /**
37
+ * Minimum number of visible items required when using "more" overflow mode.
38
+ * If fewer items would be visible, the bar falls back to hamburger mode.
39
+ * Only applies when overflow is "more".
40
+ */
41
+ minVisibleItems = 0;
42
+ /**
43
+ * Show an "all items" menu button.
44
+ * - `false`: Don't show
45
+ * - `true` or `'end'`: Show at end
46
+ * - `'start'`: Show at start
47
+ */
48
+ showAllMenu = false;
49
+ /**
50
+ * Emitted when overflow state changes.
51
+ */
52
+ leBarOverflowChange;
53
+ /** Whether the hamburger/more popover is open */
54
+ popoverOpen = false;
55
+ /** Whether hamburger mode is active (for hamburger overflow) */
56
+ hamburgerActive = false;
57
+ /** IDs of items that are overflowing */
58
+ overflowingIds = new Set();
59
+ /** Whether we can scroll left */
60
+ canScrollStart = false;
61
+ /** Whether we can scroll right */
62
+ canScrollEnd = false;
63
+ /** Whether the all-menu popover is open */
64
+ allMenuOpen = false;
65
+ /** Current height of the items container (for overflow handling) */
66
+ containerHeight = null;
67
+ itemsContainerEl;
68
+ moreButtonEl;
69
+ resizeObserver;
70
+ mutationObserver;
71
+ instanceId = generateId('le-bar');
72
+ // Map to track item elements and their IDs
73
+ itemMap = new Map();
74
+ // Prevent multiple recalculations in the same frame
75
+ pendingRecalc = null;
76
+ handleOverflowChange() {
77
+ this.resetOverflowState();
78
+ this.scheduleOverflowRecalc();
79
+ }
80
+ handleSlotChange() {
81
+ this.scheduleOverflowRecalc();
82
+ }
83
+ connectedCallback() {
84
+ this.setupObservers();
85
+ }
86
+ componentDidLoad() {
87
+ this.scheduleOverflowRecalc();
88
+ }
89
+ componentDidRender() {
90
+ // Recalculate after render in case children changed
91
+ this.scheduleOverflowRecalc();
92
+ }
93
+ disconnectedCallback() {
94
+ this.resizeObserver?.disconnect();
95
+ this.mutationObserver?.disconnect();
96
+ }
97
+ /**
98
+ * Force recalculation of overflow state.
99
+ */
100
+ async recalculate() {
101
+ this.computeOverflow();
102
+ }
103
+ setupObservers() {
104
+ // ResizeObserver for container size changes
105
+ if (typeof ResizeObserver !== 'undefined') {
106
+ this.resizeObserver = new ResizeObserver(() => {
107
+ this.computeOverflow();
108
+ this.updateScrollState();
109
+ });
110
+ }
111
+ // MutationObserver for child changes
112
+ this.mutationObserver = new MutationObserver(() => {
113
+ this.scheduleOverflowRecalc();
114
+ });
115
+ this.mutationObserver.observe(this.el, {
116
+ childList: true,
117
+ subtree: false,
118
+ });
119
+ }
120
+ observeContainer(el) {
121
+ if (!this.resizeObserver)
122
+ return;
123
+ this.resizeObserver.disconnect();
124
+ if (el)
125
+ this.resizeObserver.observe(el);
126
+ }
127
+ scheduleOverflowRecalc() {
128
+ // Debounce recalculations to prevent infinite loops
129
+ if (this.pendingRecalc !== null) {
130
+ cancelAnimationFrame(this.pendingRecalc);
131
+ }
132
+ this.pendingRecalc = requestAnimationFrame(() => {
133
+ this.pendingRecalc = null;
134
+ this.computeOverflow();
135
+ });
136
+ }
137
+ resetOverflowState() {
138
+ this.hamburgerActive = false;
139
+ this.overflowingIds = new Set();
140
+ this.containerHeight = null;
141
+ this.popoverOpen = false;
142
+ }
143
+ getSlottedItems() {
144
+ // Get direct children from the light DOM (excluding named slot elements)
145
+ return Array.from(this.el.children).filter((el) => el instanceof HTMLElement && !el.hasAttribute('slot'));
146
+ }
147
+ getItemId(el, index) {
148
+ return el.id || el.dataset.barId || `${this.instanceId}-item-${index}`;
149
+ }
150
+ computeOverflow() {
151
+ if (this.overflow === 'wrap' || this.overflow === 'scroll') {
152
+ // No overflow handling needed for wrap/scroll modes
153
+ this.resetOverflowState();
154
+ this.updateScrollState();
155
+ return;
156
+ }
157
+ const container = this.itemsContainerEl;
158
+ if (!container)
159
+ return;
160
+ const items = this.getSlottedItems();
161
+ if (items.length === 0) {
162
+ this.resetOverflowState();
163
+ return;
164
+ }
165
+ // Build item map
166
+ this.itemMap.clear();
167
+ items.forEach((item, index) => {
168
+ const id = this.getItemId(item, index);
169
+ this.itemMap.set(id, item);
170
+ });
171
+ // Get the position of items to determine which are on the first row
172
+ const itemRects = items.map((item, index) => ({
173
+ item,
174
+ id: this.getItemId(item, index),
175
+ rect: item.getBoundingClientRect(),
176
+ }));
177
+ if (itemRects.length === 0) {
178
+ return;
179
+ }
180
+ // Find the first row's top position (accounting for vertical alignment)
181
+ const containerRect = container.getBoundingClientRect();
182
+ const topValues = itemRects.map(i => i.rect.top - containerRect.top);
183
+ const minTop = Math.min(...topValues);
184
+ // Items are on the first row if their top is close to minTop
185
+ // Allow some tolerance for alignment differences
186
+ const tolerance = 15;
187
+ const firstRowItems = itemRects.filter(i => i.rect.top - containerRect.top <= minTop + tolerance);
188
+ const overflowItems = itemRects.filter(i => i.rect.top - containerRect.top > minTop + tolerance);
189
+ // Calculate the height of the first row
190
+ const firstRowBottom = firstRowItems.length > 0
191
+ ? Math.max(...firstRowItems.map(i => i.rect.bottom - containerRect.top))
192
+ : 0;
193
+ if (this.overflow === 'hamburger') {
194
+ // In hamburger mode, if ANY item overflows, all go into the menu
195
+ const shouldHamburger = overflowItems.length > 0;
196
+ if (shouldHamburger !== this.hamburgerActive) {
197
+ this.hamburgerActive = shouldHamburger;
198
+ this.emitOverflowChange();
199
+ }
200
+ // Set height to show only first row (or hide all if hamburger is active)
201
+ if (shouldHamburger && firstRowBottom > 0) {
202
+ this.containerHeight = firstRowBottom;
203
+ }
204
+ else {
205
+ this.containerHeight = null;
206
+ }
207
+ }
208
+ else {
209
+ // 'more' mode
210
+ let newOverflowingIds = new Set(overflowItems.map(i => i.id));
211
+ // Check if we need to make room for the "more" button
212
+ if (newOverflowingIds.size > 0 && this.moreButtonEl) {
213
+ const moreRect = this.moreButtonEl.getBoundingClientRect();
214
+ const moreTop = moreRect.top - containerRect.top;
215
+ // If "more" button is not on the first row, we need to hide one more item
216
+ if (moreTop > minTop + tolerance) {
217
+ // Find the last visible item and move it to overflow
218
+ const lastVisible = firstRowItems[firstRowItems.length - 1];
219
+ if (lastVisible) {
220
+ newOverflowingIds.add(lastVisible.id);
221
+ }
222
+ }
223
+ }
224
+ // Check if we should fallback to hamburger mode
225
+ // This happens when minVisibleItems is set and fewer items would be visible
226
+ const visibleCount = items.length - newOverflowingIds.size;
227
+ const shouldFallbackToHamburger = this.minVisibleItems > 0 &&
228
+ newOverflowingIds.size > 0 &&
229
+ visibleCount < this.minVisibleItems;
230
+ if (shouldFallbackToHamburger) {
231
+ // Switch to hamburger mode - all items go into the menu
232
+ if (!this.hamburgerActive) {
233
+ this.hamburgerActive = true;
234
+ this.overflowingIds = new Set();
235
+ this.emitOverflowChange();
236
+ }
237
+ // Set height to show only first row
238
+ if (firstRowBottom > 0) {
239
+ this.containerHeight = firstRowBottom;
240
+ }
241
+ else {
242
+ this.containerHeight = null;
243
+ }
244
+ return;
245
+ }
246
+ // Not falling back to hamburger - ensure hamburgerActive is false
247
+ if (this.hamburgerActive) {
248
+ this.hamburgerActive = false;
249
+ }
250
+ // Check if overflow state changed
251
+ const hasChanged = (newOverflowingIds?.size ?? 0) !== (this.overflowingIds?.size ?? 0) ||
252
+ ![...newOverflowingIds].every(id => this.overflowingIds?.has(id));
253
+ if (hasChanged) {
254
+ this.overflowingIds = newOverflowingIds;
255
+ this.emitOverflowChange();
256
+ }
257
+ // Set container height to show only first row
258
+ if ((newOverflowingIds?.size ?? 0) > 0 && firstRowBottom > 0) {
259
+ this.containerHeight = firstRowBottom;
260
+ }
261
+ else {
262
+ this.containerHeight = null;
263
+ }
264
+ }
265
+ }
266
+ emitOverflowChange() {
267
+ this.leBarOverflowChange.emit({
268
+ overflowingIds: [...(this.overflowingIds ?? [])],
269
+ hamburgerActive: this.hamburgerActive,
270
+ });
271
+ }
272
+ updateScrollState() {
273
+ if (this.overflow !== 'scroll' || !this.itemsContainerEl) {
274
+ this.canScrollStart = false;
275
+ this.canScrollEnd = false;
276
+ return;
277
+ }
278
+ const el = this.itemsContainerEl;
279
+ this.canScrollStart = el.scrollLeft > 0;
280
+ this.canScrollEnd = el.scrollLeft < el.scrollWidth - el.clientWidth - 1;
281
+ }
282
+ handleScroll = () => {
283
+ this.updateScrollState();
284
+ };
285
+ scrollToStart = () => {
286
+ if (!this.itemsContainerEl)
287
+ return;
288
+ const items = this.getSlottedItems();
289
+ const container = this.itemsContainerEl;
290
+ // Find the scroll position of the previous item
291
+ const currentScroll = container.scrollLeft;
292
+ let targetScroll = 0;
293
+ for (let i = items.length - 1; i >= 0; i--) {
294
+ const item = items[i];
295
+ // Calculate item's left edge relative to container's scroll position
296
+ const itemLeft = item.offsetLeft - container.offsetLeft;
297
+ // If this item starts before current scroll position, scroll to it
298
+ if (itemLeft < currentScroll - 1) {
299
+ targetScroll = itemLeft;
300
+ break;
301
+ }
302
+ }
303
+ container.scrollTo({ left: targetScroll, behavior: 'smooth' });
304
+ // Update scroll state after animation
305
+ setTimeout(() => this.updateScrollState(), 300);
306
+ };
307
+ scrollToEnd = () => {
308
+ if (!this.itemsContainerEl)
309
+ return;
310
+ const container = this.itemsContainerEl;
311
+ const items = this.getSlottedItems();
312
+ if (items.length === 0)
313
+ return;
314
+ const containerWidth = container.clientWidth;
315
+ const currentScroll = container.scrollLeft;
316
+ let targetScroll = container.scrollWidth - containerWidth;
317
+ for (const item of items) {
318
+ // Calculate item's right edge relative to container
319
+ const itemLeft = item.offsetLeft - container.offsetLeft;
320
+ // If this is the next item to scroll to from left to right then scroll to it
321
+ if (itemLeft > currentScroll + 1) {
322
+ targetScroll = itemLeft;
323
+ break;
324
+ }
325
+ }
326
+ container.scrollTo({ left: Math.max(0, targetScroll), behavior: 'smooth' });
327
+ // Update scroll state after animation
328
+ setTimeout(() => this.updateScrollState(), 300);
329
+ };
330
+ togglePopover = () => {
331
+ this.popoverOpen = !this.popoverOpen;
332
+ };
333
+ closePopover = () => {
334
+ this.popoverOpen = false;
335
+ };
336
+ toggleAllMenu = () => {
337
+ this.allMenuOpen = !this.allMenuOpen;
338
+ };
339
+ closeAllMenu = () => {
340
+ this.allMenuOpen = false;
341
+ };
342
+ handleItemClick = (_e, id) => {
343
+ // Close popover when an item inside is clicked
344
+ const originalItem = this.itemMap.get(id);
345
+ if (originalItem) {
346
+ // Clone the click to the original item
347
+ const cloneEvent = new MouseEvent('click', {
348
+ bubbles: true,
349
+ cancelable: true,
350
+ view: window,
351
+ });
352
+ originalItem.dispatchEvent(cloneEvent);
353
+ }
354
+ this.closePopover();
355
+ this.closeAllMenu();
356
+ };
357
+ renderMoreButton() {
358
+ const hasSlottedMore = this.el.querySelector('[slot="more"]');
359
+ return (h("button", { class: "bar-more-button", part: "more-button", ref: el => (this.moreButtonEl = el), onClick: this.togglePopover, "aria-expanded": String(this.popoverOpen), "aria-haspopup": "true" }, hasSlottedMore ? h("slot", { name: "more" }) : h("le-icon", { name: "ellipsis-horizontal" })));
360
+ }
361
+ renderHamburgerButton() {
362
+ const hasSlottedHamburger = this.el.querySelector('[slot="hamburger"]');
363
+ return (h("button", { class: "bar-hamburger-button", part: "hamburger-button", onClick: this.togglePopover, "aria-expanded": String(this.popoverOpen), "aria-haspopup": "true" }, hasSlottedHamburger ? h("slot", { name: "hamburger" }) : h("le-icon", { name: "hamburger" })));
364
+ }
365
+ renderScrollArrows() {
366
+ if (!this.arrows || this.overflow !== 'scroll')
367
+ return null;
368
+ const hasSlottedStartArrow = this.el.querySelector('[slot="start-arrow"]');
369
+ const hasSlottedEndArrow = this.el.querySelector('[slot="end-arrow"]');
370
+ return [
371
+ h("button", { class: classnames('bar-arrow', 'bar-arrow-start', {
372
+ disabled: !this.canScrollStart,
373
+ }), part: "arrow-start", onClick: this.scrollToStart, disabled: !this.canScrollStart, "aria-label": "Scroll to start" }, hasSlottedStartArrow ? (h("slot", { name: "start-arrow" })) : (h("le-icon", { name: "chevron-down", class: "arrow-icon-start" }))),
374
+ h("button", { class: classnames('bar-arrow', 'bar-arrow-end', {
375
+ disabled: !this.canScrollEnd,
376
+ }), part: "arrow-end", onClick: this.scrollToEnd, disabled: !this.canScrollEnd, "aria-label": "Scroll to end" }, hasSlottedEndArrow ? (h("slot", { name: "end-arrow" })) : (h("le-icon", { name: "chevron-down", class: "arrow-icon-end" }))),
377
+ ];
378
+ }
379
+ renderAllMenuButton() {
380
+ if (!this.showAllMenu)
381
+ return null;
382
+ const hasSlottedAllMenu = this.el.querySelector('[slot="all-menu"]');
383
+ return (h("button", { class: "bar-all-menu-button", part: "all-menu-button", onClick: this.toggleAllMenu, "aria-expanded": String(this.allMenuOpen), "aria-haspopup": "true" }, hasSlottedAllMenu ? h("slot", { name: "all-menu" }) : h("le-icon", { name: "hamburger" })));
384
+ }
385
+ renderPopoverContent(itemsToShow) {
386
+ return (h("div", { class: "bar-popover-content", part: "popover-content" }, itemsToShow.map(({ id, item }) => (h("div", { class: "bar-popover-item", key: id, onClick: (e) => this.handleItemClick(e, id), innerHTML: item.outerHTML })))));
387
+ }
388
+ renderOverflowPopover() {
389
+ if (this.overflow !== 'more' && this.overflow !== 'hamburger')
390
+ return null;
391
+ const items = this.getSlottedItems();
392
+ let itemsToShow = [];
393
+ if (this.overflow === 'hamburger' && this.hamburgerActive) {
394
+ // Show all items in hamburger mode
395
+ itemsToShow = items.map((item, index) => ({
396
+ id: this.getItemId(item, index),
397
+ item,
398
+ }));
399
+ }
400
+ else if (this.overflow === 'more' && (this.overflowingIds?.size ?? 0) > 0) {
401
+ // Show only overflowing items
402
+ itemsToShow = items
403
+ .map((item, index) => ({
404
+ id: this.getItemId(item, index),
405
+ item,
406
+ }))
407
+ .filter(({ id }) => this.overflowingIds?.has(id));
408
+ }
409
+ if (itemsToShow.length === 0)
410
+ return null;
411
+ return (h("le-popover", { mode: "default", open: this.popoverOpen, position: "bottom", align: "end", showClose: false, closeOnClickOutside: true, closeOnEscape: true, onLePopoverClose: this.closePopover }, h("div", { slot: "trigger", class: "bar-overflow-trigger" }, this.overflow === 'hamburger' ? this.renderHamburgerButton() : this.renderMoreButton()), this.renderPopoverContent(itemsToShow)));
412
+ }
413
+ renderAllMenuPopover() {
414
+ if (!this.showAllMenu)
415
+ return null;
416
+ const items = this.getSlottedItems();
417
+ const itemsToShow = items.map((item, index) => ({
418
+ id: this.getItemId(item, index),
419
+ item,
420
+ }));
421
+ const position = this.showAllMenu === 'start' ? 'start' : 'end';
422
+ return (h("le-popover", { mode: "default", open: this.allMenuOpen, position: "bottom", align: position, showClose: false, closeOnClickOutside: true, closeOnEscape: true, onLePopoverClose: this.closeAllMenu }, h("div", { slot: "trigger", class: "bar-all-menu-trigger" }, this.renderAllMenuButton()), this.renderPopoverContent(itemsToShow)));
423
+ }
424
+ render() {
425
+ const showOverflowButton = !this.disablePopover &&
426
+ ((this.overflow === 'more' && (this.overflowingIds?.size ?? 0) > 0) ||
427
+ (this.overflow === 'hamburger' && this.hamburgerActive));
428
+ const containerStyle = {};
429
+ if (this.containerHeight !== null &&
430
+ (this.overflow === 'more' || this.overflow === 'hamburger')) {
431
+ containerStyle.height = `${this.containerHeight}px`;
432
+ }
433
+ const showAllMenuAtStart = this.showAllMenu === 'start';
434
+ const showAllMenuAtEnd = this.showAllMenu === true || this.showAllMenu === 'end';
435
+ return (h(Host, { key: '56d04e4504ed7ce1d8e78a825c71c71c074d0b62', class: classnames({
436
+ 'overflow-more': this.overflow === 'more',
437
+ 'overflow-scroll': this.overflow === 'scroll',
438
+ 'overflow-hamburger': this.overflow === 'hamburger',
439
+ 'overflow-wrap': this.overflow === 'wrap',
440
+ 'hamburger-active': this.hamburgerActive,
441
+ 'has-overflow': (this.overflowingIds?.size ?? 0) > 0 || this.hamburgerActive,
442
+ }) }, h("div", { key: '4e7aeb4c84a9964e19012c3d05827fa8406988b0', class: classnames('bar-container', {
443
+ [`align-${this.alignItems}`]: true,
444
+ }), part: "container" }, this.overflow === 'scroll' && this.arrows && (h("div", { key: '2e3ae04c00e88e5055216dbc5b6d53574c450470', class: "bar-controls bar-controls-start" }, this.renderScrollArrows()?.[0])), showAllMenuAtStart && (h("div", { key: '9628c8dc2b15d9358baad63b19c75fd933eeb19a', class: "bar-controls bar-controls-start" }, this.renderAllMenuPopover())), h("div", { key: 'd1feb9603d0ff4247852aadb62cb920a5f5a1921', class: classnames('bar-items', {
445
+ 'is-scrollable': this.overflow === 'scroll',
446
+ 'is-wrapping': this.overflow === 'wrap',
447
+ }), style: containerStyle, ref: el => {
448
+ this.itemsContainerEl = el;
449
+ this.observeContainer(el);
450
+ }, onScroll: this.overflow === 'scroll' ? this.handleScroll : undefined }, h("slot", { key: '338698e038b9df4c7b163017ceb0675b834160e4' })), showOverflowButton && (h("div", { key: 'd619fcda1b0c28247af60899f73cc076b0517787', class: "bar-controls bar-controls-end" }, this.renderOverflowPopover())), showAllMenuAtEnd && (h("div", { key: 'fd9fef90194aabb8d48e77c8f7615daa5d7297ac', class: "bar-controls bar-controls-end" }, this.renderAllMenuPopover())), this.overflow === 'scroll' && this.arrows && (h("div", { key: 'bcffb914e2788767c3765351a3eeae771f3e115f', class: "bar-controls bar-controls-end" }, this.renderScrollArrows()?.[1])))));
451
+ }
452
+ static get watchers() { return {
453
+ "overflow": ["handleOverflowChange"]
454
+ }; }
455
+ };
456
+ LeBar.style = leBarCss();
457
+
5
458
  const leButtonCss = () => `:host{display:inline-block;--le-button-border-radius:var(--le-radius-md);--le-button-padding-x:var(--le-spacing-3);--le-button-padding-y:var(--le-spacing-1);--le-button-padding:var(--le-button-padding-y) var(--le-button-padding-x);--le-button-small-padding:0.25rem;--le-button-font-size:var(--le-font-size-md);--le-button-font-weight:var(--le-font-weight-medium);--le-button-transition:var(--le-transition-fast);--le-transition-easing:ease-in-out;--le-button-icon-aspect-ratio:1;--le-button-color:var(--le-color-primary-contrast);--_btn-bg:var(--le-color-primary);--_btn-bg-hover:var(--le-color-primary-dark);--_btn-bg-system:var(--le-color-black);--_btn-color:var(--le-button-color);--_btn-border-color:var(--le-color-primary)}:host([full-width]){display:block;width:100%}.le-button-container{display:inline-flex;flex-direction:row;align-items:center;justify-content:center;gap:var(--le-spacing-3);width:100%;padding:var(--le-button-padding);border:1px solid var(--_btn-border-color);border-radius:var(--le-button-border-radius);background:var(--_btn-bg);color:var(--_btn-color);font-family:var(--le-font-family-base);font-size:var(--le-button-font-size);font-weight:var(--le-button-font-weight);line-height:var(--le-line-height-tight);text-decoration:none;cursor:pointer;transition:background-color var(--le-button-transition) var(--le-transition-easing),
6
459
  border-color var(--le-button-transition) var(--le-transition-easing),
7
460
  box-shadow var(--le-button-transition) var(--le-transition-easing),
@@ -435,7 +888,7 @@ const LeComponent = class {
435
888
  const enumMatch = type.match(/^'[^']+'/);
436
889
  if (enumMatch) {
437
890
  const options = type.split('|').map(opt => opt.trim().replace(/'/g, ''));
438
- return (h("div", { class: "property-field" }, h("label", { htmlFor: `prop-${attr.name}` }, attr.name, attr.description && h("span", { class: "property-hint" }, attr.description)), h("le-select", { options: [...options.map(opt => ({ label: opt, value: opt }))], "full-width": true, value: value ?? attr.default?.replace(/'/g, ''), placeholder: attr.default?.replace(/'/g, ''), onLeChange: (e) => this.handlePropertyChange(attr.name, e.detail.value, type) })));
891
+ return (h("div", { class: "property-field" }, h("label", { htmlFor: `prop-${attr.name}` }, attr.name, attr.description && h("span", { class: "property-hint" }, attr.description)), h("le-select", { options: [...options.map(opt => ({ label: opt, value: opt }))], "full-width": true, value: value ?? attr.default?.replace(/'/g, ''), placeholder: attr.default?.replace(/'/g, ''), onChange: (e) => this.handlePropertyChange(attr.name, e.detail.value, type) })));
439
892
  }
440
893
  // Boolean type
441
894
  if (type === 'boolean') {
@@ -1121,6 +1574,496 @@ const LeHeader = class {
1121
1574
  };
1122
1575
  LeHeader.style = leHeaderCss();
1123
1576
 
1577
+ const leIconCss = () => `:host{display:inline-block;width:var(--le-icon-size, var(--le-size-4));height:var(--le-icon-size, var(--le-size-4));color:var(--le-icon-color, var(--le-color-text-primary))}:host svg{display:block;fill:currentColor}`;
1578
+
1579
+ const iconCache = {};
1580
+ const requestCache = {};
1581
+ async function fetchIcon({ name }) {
1582
+ if (iconCache[name]) {
1583
+ return iconCache[name];
1584
+ }
1585
+ if (!requestCache[name]) {
1586
+ console.log(`Fetching icon "${name}"`, getAssetPath(`./assets/icons/${name}.json`));
1587
+ requestCache[name] = fetch(getAssetPath(`./assets/icons/${name}.json`))
1588
+ .then(resp => resp.json())
1589
+ .catch(() => {
1590
+ console.error(`"${name}" is not a valid name`);
1591
+ return '';
1592
+ });
1593
+ }
1594
+ const path = await requestCache[name];
1595
+ iconCache[name] = path;
1596
+ return path;
1597
+ }
1598
+ const LeIcon = class {
1599
+ constructor(hostRef) {
1600
+ registerInstance(this, hostRef);
1601
+ }
1602
+ get el() { return getElement(this); }
1603
+ /**
1604
+ * Name of the icon to display. Corresponds to a JSON file in the assets folder.
1605
+ * For example, "search" will load the "search.json" file.
1606
+ */
1607
+ name = null;
1608
+ /**
1609
+ * Size of the icon in pixels. Default is 16.
1610
+ */
1611
+ size = 16;
1612
+ iconData = null;
1613
+ visible = false;
1614
+ async loadIconData() {
1615
+ const { name, visible } = this;
1616
+ if (!name || !visible) {
1617
+ return;
1618
+ }
1619
+ this.iconData = await fetchIcon({ name });
1620
+ }
1621
+ intersectionObserver;
1622
+ connectedCallback() {
1623
+ this.waitUntilVisible(() => {
1624
+ this.visible = true;
1625
+ this.loadIconData();
1626
+ });
1627
+ }
1628
+ disconnectedCallback() {
1629
+ if (this.intersectionObserver) {
1630
+ this.intersectionObserver.disconnect();
1631
+ this.intersectionObserver = null;
1632
+ }
1633
+ }
1634
+ async componentWillLoad() {
1635
+ this.loadIconData();
1636
+ }
1637
+ waitUntilVisible(callback) {
1638
+ if (typeof window === 'undefined' ||
1639
+ !window.IntersectionObserver) {
1640
+ callback();
1641
+ return;
1642
+ }
1643
+ this.intersectionObserver = new IntersectionObserver(entries => {
1644
+ entries.forEach(entry => {
1645
+ if (entry.isIntersecting) {
1646
+ this.intersectionObserver.disconnect();
1647
+ this.intersectionObserver = null;
1648
+ callback();
1649
+ }
1650
+ });
1651
+ }, { rootMargin: '50px' });
1652
+ this.intersectionObserver.observe(this.el);
1653
+ }
1654
+ /**
1655
+ * Renders the SVG content out of a JSON data in a format:
1656
+ * { "viewBox": "...", children: [{ "tag": "g", ""children": [ ... ], ...attrs }, ...] }
1657
+ *
1658
+ * @returns JSX.Element | null
1659
+ */
1660
+ renderSVGContent(children) {
1661
+ if (!children || children.length === 0) {
1662
+ return null;
1663
+ }
1664
+ const createElement = node => {
1665
+ const { tag, children, ...attrs } = node;
1666
+ return h(tag, attrs, children ? children.map(createElement) : null);
1667
+ };
1668
+ const svgElements = children.map(createElement);
1669
+ return svgElements;
1670
+ }
1671
+ render() {
1672
+ return (h("svg", { key: 'ef551908a289cd765ae88ded83b99057d510e142', xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", height: this.size || 16, width: this.size || 16, viewBox: this.iconData?.viewBox || `0 0 ${this.size || 16} ${this.size || 16}` }, this.renderSVGContent(this.iconData?.children)));
1673
+ }
1674
+ static get assetsDirs() { return ["assets/icons"]; }
1675
+ static get watchers() { return {
1676
+ "name": ["loadIconData"]
1677
+ }; }
1678
+ };
1679
+ LeIcon.style = leIconCss();
1680
+
1681
+ const leNavigationCss = () => `:host{display:block;--le-nav-radius:var(--le-radius-md);--le-nav-gap:var(--le-spacing-2);--le-nav-item-padding-x:var(--le-spacing-1);--le-nav-item-padding-y:var(--le-spacing-2);--le-nav-item-gap:var(--le-spacing-2);--le-nav-color:var(--le-color-text-primary);--le-nav-muted:var(--le-color-text-secondary);--le-nav-hover-bg:var(--le-color-gray-100);--le-nav-selected-bg:var(--le-color-primary);--le-nav-selected-color:var(--le-color-primary-contrast)}:host([orientation='horizontal']:not([wrap])){flex:1 1 0%;min-width:0}.nav-vertical{display:flex;flex-direction:column;gap:var(--le-nav-gap)}.nav-search{width:100%}.nav-search-input{--le-input-radius:var(--le-radius-md)}.nav-empty{padding:var(--le-spacing-2);color:var(--le-nav-muted);font-size:var(--le-font-size-sm)}.nav-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--le-spacing-1)}.nav-row{display:flex;align-items:stretch;gap:var(--le-spacing-1);border-radius:var(--le-nav-radius)}.nav-row:hover{background:var(--le-nav-hover-bg)}.nav-toggle,.nav-toggle-spacer{box-sizing:border-box;width:var(--le-spacing-4);min-width:var(--le-spacing-4);display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:var(--le-nav-radius);color:inherit}.nav-toggle{background:transparent;cursor:pointer;opacity:0.4}.nav-toggle:hover:not(:disabled){opacity:1}.nav-toggle:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px;opacity:1}.nav-chevron{display:inline-block;transition:transform var(--le-transition-fast)}.nav-chevron svg{display:block;width:var(--le-spacing-4);height:var(--le-spacing-4)}.nav-node>div>button>.nav-chevron{transform:rotate(-90deg)}.nav-node.open>div>button>.nav-chevron{transform:rotate(0deg)}.nav-item{flex:1;display:inline-flex;align-items:center;gap:var(--le-nav-item-gap);padding:var(--le-nav-item-padding-y) var(--le-nav-item-padding-x) var(--le-nav-item-padding-y) 0;border-radius:var(--le-nav-radius);border:1px solid transparent;background:transparent;text-decoration:none;color:var(--le-nav-color);font-family:var(--le-font-family-base);font-size:var(--le-font-size-md);line-height:var(--le-line-height-tight);cursor:pointer}.nav-item:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.nav-node.selected>.nav-row{background:var(--le-nav-selected-bg);color:var(--le-nav-selected-color)}.nav-node.selected>.nav-row>.nav-item{color:inherit}.nav-node.disabled>.nav-row>.nav-item{opacity:0.5;cursor:not-allowed}.nav-text{display:flex;flex-direction:column;min-width:0}.nav-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.nav-description{color:color-mix(in srgb, var(--le-nav-muted) 90%, transparent);font-size:var(--le-font-size-sm);line-height:var(--le-line-height-tight)}.nav-icon{display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}.nav-icon-end{margin-left:auto}.nav-children{margin-top:var(--le-spacing-1)}.nav-horizontal-wrapper{display:flex;align-items:center;gap:var(--le-spacing-2)}.nav-bar{flex:1 1 0%;min-width:0;--le-bar-gap:var(--le-spacing-2)}.nav-bar.align-end{--le-bar-justify:flex-end}.nav-bar.align-center{--le-bar-justify:center}.nav-bar.align-space-between{--le-bar-justify:space-between}.h-item{display:flex;align-items:center}.h-link{display:inline-flex;align-items:center;gap:var(--le-spacing-2);padding:var(--le-spacing-2) var(--le-spacing-3);border-radius:var(--le-nav-radius);border:1px solid transparent;background:transparent;text-decoration:none;color:var(--le-nav-color);font-family:var(--le-font-family-base);font-size:var(--le-font-size-md);cursor:pointer}.h-link:hover{background:var(--le-nav-hover-bg)}.h-link:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.h-link.disabled,.h-trigger.disabled{opacity:0.5;pointer-events:none}.h-link.selected,.h-trigger.selected{background:var(--le-nav-selected-bg);color:var(--le-nav-selected-color)}.h-label{white-space:nowrap}.h-trigger{display:inline-flex;align-items:center;gap:var(--le-spacing-1);border-radius:var(--le-nav-radius)}.h-submenu-toggle{width:var(--le-spacing-3);height:var(--le-spacing-3);display:inline-flex;align-items:center;justify-content:center;border:1px solid transparent;border-radius:var(--le-nav-radius);background:transparent;color:currentColor;cursor:pointer}.h-submenu-toggle:hover{background:var(--le-nav-hover-bg)}.overflow-trigger{display:inline-flex;align-items:center;justify-content:center;gap:var(--le-spacing-2);padding:var(--le-spacing-2) var(--le-spacing-3);border-radius:var(--le-nav-radius);border:1px solid transparent;background:transparent;color:var(--le-nav-color);cursor:pointer;font-family:var(--le-font-family-base);font-size:var(--le-font-size-md)}.overflow-trigger:hover{background:var(--le-nav-hover-bg)}.overflow-trigger:focus-visible{outline:2px solid var(--le-color-focus);outline-offset:2px}.nav-overflow-trigger{display:flex;align-items:center}le-popover::part(content){padding:var(--le-spacing-1)}`;
1682
+
1683
+ const LeNavigation = class {
1684
+ constructor(hostRef) {
1685
+ registerInstance(this, hostRef);
1686
+ this.leNavItemSelect = createEvent(this, "leNavItemSelect");
1687
+ this.leNavItemToggle = createEvent(this, "leNavItemToggle");
1688
+ }
1689
+ get el() { return getElement(this); }
1690
+ /**
1691
+ * Navigation items.
1692
+ * Can be passed as an array or JSON string (same pattern as le-select).
1693
+ */
1694
+ items = [];
1695
+ /**
1696
+ * Layout orientation.
1697
+ */
1698
+ orientation = 'horizontal';
1699
+ /**
1700
+ * Horizontal wrapping behavior.
1701
+ * If false, overflow behavior depends on `overflowMode`.
1702
+ */
1703
+ wrap = false;
1704
+ /**
1705
+ * Overflow behavior for horizontal, non-wrapping menus.
1706
+ * - more: moves overflow items into a "More" popover
1707
+ * - hamburger: turns the whole nav into a hamburger popover
1708
+ */
1709
+ overflowMode = 'more';
1710
+ /**
1711
+ * Minimum number of visible top-level items required to use the "More" overflow.
1712
+ * If fewer would be visible, the navigation falls back to hamburger.
1713
+ */
1714
+ minVisibleItemsForMore = 2;
1715
+ /**
1716
+ * Alignment of the menu items within the navigation bar.
1717
+ */
1718
+ align = 'start';
1719
+ /**
1720
+ * Active url for automatic selection.
1721
+ */
1722
+ activeUrl = '';
1723
+ /**
1724
+ * Enables a search input for the vertical navigation.
1725
+ */
1726
+ searchable = false;
1727
+ /**
1728
+ * Placeholder text for the search input.
1729
+ */
1730
+ searchPlaceholder = 'Search...';
1731
+ /**
1732
+ * Text shown when no items match the filter.
1733
+ */
1734
+ emptyText = 'No results found';
1735
+ /**
1736
+ * Whether submenu popovers should include a filter input.
1737
+ */
1738
+ submenuSearchable = false;
1739
+ /**
1740
+ * Fired when a navigation item is activated.
1741
+ *
1742
+ * This event is cancelable. Call `event.preventDefault()` to prevent
1743
+ * default browser navigation and implement custom routing.
1744
+ */
1745
+ leNavItemSelect;
1746
+ /**
1747
+ * Fired when a tree branch is toggled.
1748
+ */
1749
+ leNavItemToggle;
1750
+ searchQuery = '';
1751
+ openState = {};
1752
+ /** IDs of items currently in overflow (from le-bar) */
1753
+ overflowIds = [];
1754
+ /** Whether hamburger mode is active (from le-bar) */
1755
+ hamburgerActive = false;
1756
+ submenuQueries = {};
1757
+ /** Whether the overflow popover is open */
1758
+ overflowPopoverOpen = false;
1759
+ popoverRefs = new Map();
1760
+ instanceId = generateId('le-nav');
1761
+ partFromOptionPart(base, part) {
1762
+ const raw = (part ?? '').trim();
1763
+ if (!raw)
1764
+ return base;
1765
+ const tokens = raw
1766
+ .split(/\s+/)
1767
+ .map(t => t.replace(/[^a-zA-Z0-9_-]/g, ''))
1768
+ .filter(Boolean);
1769
+ if (tokens.length === 0)
1770
+ return base;
1771
+ return [base, ...tokens.map(t => `${base}-${t}`)].join(' ');
1772
+ }
1773
+ handleLayoutInputsChange() {
1774
+ // Reset overflow state when layout inputs change
1775
+ this.overflowIds = [];
1776
+ this.hamburgerActive = false;
1777
+ }
1778
+ disconnectedCallback() {
1779
+ // Cleanup if needed
1780
+ }
1781
+ get parsedItems() {
1782
+ if (typeof this.items === 'string') {
1783
+ try {
1784
+ return JSON.parse(this.items);
1785
+ }
1786
+ catch {
1787
+ return [];
1788
+ }
1789
+ }
1790
+ return this.items;
1791
+ }
1792
+ getItemId(item, path) {
1793
+ return item.id ?? `${this.instanceId}:${path}`;
1794
+ }
1795
+ getChildItems(item) {
1796
+ return Array.isArray(item.children) ? item.children : [];
1797
+ }
1798
+ isOpen(item, id) {
1799
+ const fromState = this.openState[id];
1800
+ if (typeof fromState === 'boolean')
1801
+ return fromState;
1802
+ return !!item.open;
1803
+ }
1804
+ setOpen(id, open) {
1805
+ if (this.openState[id] === open)
1806
+ return;
1807
+ this.openState = {
1808
+ ...this.openState,
1809
+ [id]: open,
1810
+ };
1811
+ }
1812
+ matchesQuery(option, query) {
1813
+ if (!query)
1814
+ return true;
1815
+ const q = query.toLowerCase();
1816
+ return (option.label.toLowerCase().includes(q) ||
1817
+ (option.description?.toLowerCase().includes(q) ?? false));
1818
+ }
1819
+ filterTree(items, query, pathPrefix, autoOpen) {
1820
+ if (!query)
1821
+ return items;
1822
+ const result = [];
1823
+ items.forEach((item, index) => {
1824
+ const path = pathPrefix ? `${pathPrefix}.${index}` : String(index);
1825
+ const id = this.getItemId(item, path);
1826
+ const children = this.getChildItems(item);
1827
+ const filteredChildren = this.filterTree(children, query, path, autoOpen);
1828
+ const selfMatch = this.matchesQuery(item, query);
1829
+ const childMatch = filteredChildren.length > 0;
1830
+ if (selfMatch || childMatch) {
1831
+ if (childMatch) {
1832
+ autoOpen.add(id);
1833
+ }
1834
+ if (childMatch && filteredChildren !== children) {
1835
+ result.push({
1836
+ ...item,
1837
+ children: filteredChildren,
1838
+ });
1839
+ }
1840
+ else {
1841
+ result.push(item);
1842
+ }
1843
+ }
1844
+ });
1845
+ return result;
1846
+ }
1847
+ handleItemSelect = (e, item, id) => {
1848
+ if (item.disabled) {
1849
+ e.preventDefault();
1850
+ e.stopPropagation();
1851
+ return;
1852
+ }
1853
+ const emitted = this.leNavItemSelect.emit({
1854
+ item,
1855
+ id,
1856
+ href: item.href,
1857
+ originalEvent: e,
1858
+ });
1859
+ if (emitted.defaultPrevented) {
1860
+ e.preventDefault();
1861
+ }
1862
+ };
1863
+ handleToggle = (e, item, id) => {
1864
+ e.preventDefault();
1865
+ e.stopPropagation();
1866
+ if (item.disabled)
1867
+ return;
1868
+ const next = !this.isOpen(item, id);
1869
+ this.setOpen(id, next);
1870
+ this.leNavItemToggle.emit({
1871
+ item,
1872
+ id,
1873
+ open: next,
1874
+ originalEvent: e,
1875
+ });
1876
+ };
1877
+ handleSearchInput = (e) => {
1878
+ const target = e.target;
1879
+ this.searchQuery = target.value;
1880
+ };
1881
+ handleSubmenuSearchInput = (submenuId, e) => {
1882
+ const target = e.target;
1883
+ const value = target.value;
1884
+ if (this.submenuQueries[submenuId] === value)
1885
+ return;
1886
+ this.submenuQueries = {
1887
+ ...this.submenuQueries,
1888
+ [submenuId]: value,
1889
+ };
1890
+ // Position may change as items filter.
1891
+ requestAnimationFrame(() => this.popoverRefs.get(submenuId)?.updatePosition());
1892
+ };
1893
+ handleBarOverflowChange = (e) => {
1894
+ this.overflowIds = e.detail.overflowingIds || [];
1895
+ this.hamburgerActive = e.detail.hamburgerActive || false;
1896
+ };
1897
+ openOverflowPopover = () => {
1898
+ this.overflowPopoverOpen = true;
1899
+ };
1900
+ closeOverflowPopover = () => {
1901
+ this.overflowPopoverOpen = false;
1902
+ };
1903
+ renderVerticalList(items, { depth, pathPrefix, autoOpenIds, searchable, searchQuery, searchPlaceholder, emptyText, submenuId, closePopover, }) {
1904
+ const query = searchQuery ?? '';
1905
+ const openFromSearch = autoOpenIds ?? new Set();
1906
+ const filtered = query ? this.filterTree(items, query, pathPrefix, openFromSearch) : items;
1907
+ return (h("div", { class: classnames('nav-vertical', { 'is-submenu': !!submenuId }) }, searchable && (h("div", { class: "nav-search" }, h("le-string-input", { mode: "default", class: "nav-search-input", placeholder: searchPlaceholder ?? 'Search...', value: query, onInput: (e) => submenuId ? this.handleSubmenuSearchInput(submenuId, e) : this.handleSearchInput(e) }))), filtered.length === 0 ? (h("div", { class: "nav-empty" }, emptyText ?? this.emptyText)) : (h("ul", { class: "nav-list", role: "tree" }, filtered.map((item, index) => {
1908
+ const path = pathPrefix ? `${pathPrefix}.${index}` : String(index);
1909
+ const id = this.getItemId(item, path);
1910
+ const children = this.getChildItems(item);
1911
+ const hasChildren = children.length > 0;
1912
+ const open = hasChildren && (this.isOpen(item, id) || openFromSearch.has(id));
1913
+ const paddingLeft = `calc(var(--le-nav-item-padding-x) + ${depth} * var(--le-spacing-4))`;
1914
+ const TagType = item.href && !item.disabled ? 'a' : 'button';
1915
+ const attrs = TagType === 'a'
1916
+ ? { href: item.href, role: 'treeitem' }
1917
+ : { type: 'button', role: 'treeitem' };
1918
+ const itemPart = this.partFromOptionPart('item', item.part);
1919
+ return (h("li", { class: classnames('nav-node', {
1920
+ 'disabled': item.disabled,
1921
+ 'selected': item.selected || (this.activeUrl && item.href === this.activeUrl),
1922
+ open,
1923
+ 'has-children': hasChildren,
1924
+ }), key: id, role: "none" }, h("div", { class: "nav-row", style: { paddingLeft } }, hasChildren ? (h("button", { type: "button", class: "nav-toggle", "aria-label": open ? 'Collapse' : 'Expand', "aria-expanded": open ? 'true' : 'false', onClick: (e) => this.handleToggle(e, item, id), disabled: item.disabled }, h("le-icon", { name: "chevron-down", class: "nav-chevron", "aria-hidden": "true" }))) : (h("span", { class: "nav-toggle-spacer", "aria-hidden": "true" })), h(TagType, { class: "nav-item", part: itemPart, ...attrs, "aria-disabled": item.disabled ? 'true' : undefined, onClick: (e) => {
1925
+ // For buttons, also toggle if this is a purely structural node.
1926
+ this.handleItemSelect(e, item, id);
1927
+ if (!item.href && hasChildren && !item.disabled) {
1928
+ this.handleToggle(e, item, id);
1929
+ return;
1930
+ }
1931
+ if (!item.disabled && closePopover) {
1932
+ closePopover();
1933
+ }
1934
+ } }, item.iconStart && (h("span", { class: "nav-icon", "aria-hidden": "true" }, item.iconStart)), h("span", { class: "nav-text" }, h("span", { class: "nav-label" }, item.label), item.description && (h("span", { class: "nav-description" }, item.description))), item.iconEnd && (h("span", { class: "nav-icon nav-icon-end", "aria-hidden": "true" }, item.iconEnd)))), hasChildren && (h("le-collapse", { class: "nav-children", closed: !open, noFading: true, role: "group" }, this.renderVerticalList(children, {
1935
+ depth: depth + 1,
1936
+ pathPrefix: path,
1937
+ autoOpenIds: openFromSearch,
1938
+ submenuId,
1939
+ closePopover,
1940
+ })))));
1941
+ })))));
1942
+ }
1943
+ renderHorizontalItem(item, index) {
1944
+ const id = this.getItemId(item, String(index));
1945
+ const children = this.getChildItems(item);
1946
+ const hasChildren = children.length > 0;
1947
+ if (!hasChildren) {
1948
+ const TagType = item.href && !item.disabled ? 'a' : 'button';
1949
+ const attrs = TagType === 'a'
1950
+ ? { href: item.href, role: 'menuitem' }
1951
+ : { type: 'button', role: 'menuitem' };
1952
+ const itemPart = this.partFromOptionPart('item', item.part);
1953
+ return (h("div", { class: "h-item", "data-bar-id": id }, h(TagType, { class: classnames('h-link', {
1954
+ disabled: item.disabled,
1955
+ selected: item.selected || (this.activeUrl && item.href === this.activeUrl),
1956
+ }), part: itemPart, ...attrs, "aria-disabled": item.disabled ? 'true' : undefined, onClick: (e) => this.handleItemSelect(e, item, id) }, item.iconStart && (h("span", { class: "nav-icon", "aria-hidden": "true" }, item.iconStart)), h("span", { class: "h-label" }, item.label), item.iconEnd && (h("span", { class: "nav-icon nav-icon-end", "aria-hidden": "true" }, item.iconEnd)))));
1957
+ }
1958
+ const submenuId = id;
1959
+ const itemPart = this.partFromOptionPart('item', item.part);
1960
+ return (h("div", { class: "h-item", "data-bar-id": id }, h("le-popover", { ref: el => {
1961
+ if (el)
1962
+ this.popoverRefs.set(submenuId, el);
1963
+ }, mode: "default", showClose: false, closeOnClickOutside: true, closeOnEscape: true, position: "bottom", align: "start", minWidth: "240px" }, h("div", { slot: "trigger", class: classnames('h-trigger', {
1964
+ disabled: item.disabled,
1965
+ selected: item.selected || (this.activeUrl && item.href === this.activeUrl),
1966
+ }), part: itemPart, role: "menuitem", "aria-disabled": item.disabled ? 'true' : undefined, onClick: (e) => {
1967
+ // Don’t let le-popover auto-toggle from its internal wrapper.
1968
+ e.stopPropagation();
1969
+ if (item.disabled)
1970
+ return;
1971
+ if (item.href) {
1972
+ this.handleItemSelect(e, item, id);
1973
+ this.popoverRefs.get(submenuId)?.hide();
1974
+ }
1975
+ else {
1976
+ this.popoverRefs.get(submenuId)?.toggle();
1977
+ }
1978
+ } }, item.href ? (h("a", { class: "h-link", href: item.href, onClick: (e) => {
1979
+ e.stopPropagation();
1980
+ this.handleItemSelect(e, item, id);
1981
+ } }, item.iconStart && (h("span", { class: "nav-icon", "aria-hidden": "true" }, item.iconStart)), h("span", { class: "h-label" }, item.label), h("span", { class: "nav-chevron", "aria-hidden": "true" }, h("le-icon", { name: "chevron-down" })))) : (h("button", { type: "button", class: "h-link", onClick: (e) => {
1982
+ e.stopPropagation();
1983
+ if (item.disabled)
1984
+ return;
1985
+ this.popoverRefs.get(submenuId)?.toggle();
1986
+ } }, item.iconStart && (h("span", { class: "nav-icon", "aria-hidden": "true" }, item.iconStart)), h("span", { class: "h-label" }, item.label), h("span", { class: "nav-chevron", "aria-hidden": "true" }, h("le-icon", { name: "chevron-down" }))))), h("div", { class: "popover-menu" }, this.renderVerticalList(children, {
1987
+ depth: 0,
1988
+ pathPrefix: String(index),
1989
+ searchable: this.submenuSearchable,
1990
+ searchQuery: this.submenuQueries[submenuId] ?? '',
1991
+ searchPlaceholder: this.searchPlaceholder,
1992
+ emptyText: this.emptyText,
1993
+ submenuId,
1994
+ closePopover: () => this.popoverRefs.get(submenuId)?.hide(),
1995
+ })))));
1996
+ }
1997
+ getOverflowMode() {
1998
+ if (this.wrap)
1999
+ return 'wrap';
2000
+ return this.overflowMode;
2001
+ }
2002
+ getBarAlignment() {
2003
+ // Map le-navigation align to le-bar alignItems
2004
+ // 'space-between' doesn't map directly, use 'stretch' as closest
2005
+ if (this.align === 'space-between')
2006
+ return 'stretch';
2007
+ return this.align;
2008
+ }
2009
+ renderOverflowPopover() {
2010
+ const items = this.parsedItems;
2011
+ const overflowSet = new Set(this.overflowIds || []);
2012
+ // Determine which items to show in the popover
2013
+ let itemsToShow;
2014
+ if (this.hamburgerActive) {
2015
+ // In hamburger mode, show all items
2016
+ itemsToShow = items;
2017
+ }
2018
+ else {
2019
+ // In "more" mode, show only overflow items
2020
+ itemsToShow = items.filter((item, index) => {
2021
+ const id = this.getItemId(item, String(index));
2022
+ return overflowSet.has(id);
2023
+ });
2024
+ }
2025
+ if (itemsToShow.length === 0)
2026
+ return null;
2027
+ const isHamburger = this.hamburgerActive;
2028
+ return (h("le-popover", { mode: "default", open: this.overflowPopoverOpen, showClose: false, closeOnClickOutside: true, closeOnEscape: true, position: "bottom", align: "end", minWidth: "260px", onLePopoverClose: this.closeOverflowPopover }, h("button", { slot: "trigger", type: "button", class: "overflow-trigger", part: isHamburger ? 'hamburger-trigger' : 'more-trigger', "aria-label": isHamburger ? 'Open menu' : 'More', onClick: this.openOverflowPopover }, h("slot", { name: isHamburger ? 'hamburger-trigger' : 'more-trigger' }, h("le-icon", { name: isHamburger ? 'hamburger' : 'ellipsis-horizontal' }))), h("div", { class: "popover-menu" }, this.renderVerticalList(itemsToShow, {
2029
+ depth: 0,
2030
+ pathPrefix: '',
2031
+ closePopover: this.closeOverflowPopover,
2032
+ }))));
2033
+ }
2034
+ renderHorizontal() {
2035
+ const items = this.parsedItems;
2036
+ const overflowMode = this.getOverflowMode();
2037
+ const showOverflowButton = (this.overflowIds?.length ?? 0) > 0 || this.hamburgerActive;
2038
+ return (h("div", { class: "nav-horizontal-wrapper" }, h("le-bar", { class: classnames('nav-bar', {
2039
+ 'align-end': this.align === 'end',
2040
+ 'align-center': this.align === 'center',
2041
+ 'align-space-between': this.align === 'space-between',
2042
+ }), overflow: overflowMode, alignItems: this.getBarAlignment(), disablePopover: true, minVisibleItems: this.minVisibleItemsForMore, onLeBarOverflowChange: this.handleBarOverflowChange }, items.map((item, index) => this.renderHorizontalItem(item, index))), showOverflowButton && this.renderOverflowPopover()));
2043
+ }
2044
+ render() {
2045
+ const items = this.parsedItems;
2046
+ if (this.orientation === 'horizontal') {
2047
+ return (h(Host, null, h("le-component", { component: "le-navigation" }, this.renderHorizontal())));
2048
+ }
2049
+ return (h(Host, null, h("le-component", { component: "le-navigation" }, this.renderVerticalList(items, {
2050
+ depth: 0,
2051
+ pathPrefix: '',
2052
+ searchable: this.searchable,
2053
+ searchQuery: this.searchQuery,
2054
+ searchPlaceholder: this.searchPlaceholder,
2055
+ emptyText: this.emptyText,
2056
+ }))));
2057
+ }
2058
+ static get watchers() { return {
2059
+ "items": ["handleLayoutInputsChange"],
2060
+ "orientation": ["handleLayoutInputsChange"],
2061
+ "wrap": ["handleLayoutInputsChange"],
2062
+ "overflowMode": ["handleLayoutInputsChange"]
2063
+ }; }
2064
+ };
2065
+ LeNavigation.style = leNavigationCss();
2066
+
1124
2067
  const lePopoverCss = () => `/* ============================================
1125
2068
  le-popover.css
1126
2069
  Popover using native HTML Popover API
@@ -2072,7 +3015,7 @@ const leSelectCss = () => `:host{display:inline-block;min-width:150px;--le-selec
2072
3015
  const LeSelect = class {
2073
3016
  constructor(hostRef) {
2074
3017
  registerInstance(this, hostRef);
2075
- this.leChange = createEvent(this, "leChange");
3018
+ this.leChange = createEvent(this, "change");
2076
3019
  this.leOpen = createEvent(this, "leOpen");
2077
3020
  this.leClose = createEvent(this, "leClose");
2078
3021
  }
@@ -2234,13 +3177,13 @@ const LeSelect = class {
2234
3177
  }
2235
3178
  render() {
2236
3179
  const hasValue = this.selectedOption !== undefined;
2237
- return (h("le-component", { key: '1659550d258d0d647cefa5715cc9cbcf5ac3b6c7', component: "le-select" }, h("le-dropdown-base", { key: '4210afe927afaf35adeb25794d684d8bf6265604', ref: el => (this.dropdownEl = el), options: this.parsedOptions, value: this.value, disabled: this.disabled, filterFn: this.searchable ? this.filterOption : undefined, filterQuery: this.searchQuery, onLeOptionSelect: this.handleOptionSelect, onLeDropdownOpen: this.handleDropdownOpen, onLeDropdownClose: this.handleDropdownClose, fullWidth: this.fullWidth }, h("le-button", { key: '204b62bae909fb979f84f79ab64a7405f44df0a7', variant: this.variant && this.variant !== 'default' ? this.variant : 'outlined', slot: "trigger", align: "space-between", class: {
3180
+ return (h("le-component", { key: '1d67b699f3638ef75a15fecdbba80a531ea90681', component: "le-select" }, h("le-dropdown-base", { key: '9a52d99cdf1f0f0c1b9de6e10f5a694b580469ab', ref: el => (this.dropdownEl = el), options: this.parsedOptions, value: this.value, disabled: this.disabled, filterFn: this.searchable ? this.filterOption : undefined, filterQuery: this.searchQuery, onLeOptionSelect: this.handleOptionSelect, onLeDropdownOpen: this.handleDropdownOpen, onLeDropdownClose: this.handleDropdownClose, fullWidth: this.fullWidth }, h("le-button", { key: '20c02507679ed44cca089e15801ac8f57cbe3938', variant: this.variant && this.variant !== 'default' ? this.variant : 'outlined', slot: "trigger", align: "space-between", class: {
2238
3181
  'select-trigger': true,
2239
3182
  'has-value': hasValue,
2240
3183
  'is-open': this.open,
2241
3184
  }, mode: "default", size: this.size, disabled: this.disabled, "aria-haspopup": "listbox", "aria-expanded": this.open ? 'true' : 'false', onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeyDown, fullWidth: this.fullWidth, iconStart: hasValue && this.selectedOption?.iconStart
2242
3185
  ? this.renderIcon(this.selectedOption.iconStart)
2243
- : null, iconEnd: h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { d: "M4 6l4 4 4-4" })) }, h("span", { key: 'abb56957a4ddf6b39c3554b26e46c0ad51e022be', class: "trigger-label" }, hasValue ? this.selectedOption.label : this.placeholder)), this.searchable && this.open && (h("div", { key: '25d58fdfddc45f7fde1a41defdbd50dbddd70ea5', class: "multiselect-search", slot: "header" }, h("le-string-input", { key: '81b290d28bed6190b9ec165897ec2e7d758575bf', mode: "default", inputRef: el => (this.inputEl = el), class: "search-input", placeholder: "Search...", value: this.searchQuery, onInput: this.handleSearchInput })))), this.name && h("input", { key: '70e413d81035cdd61bfdaeae27ba3ced0a25f544', type: "hidden", name: this.name, value: this.value?.toString() ?? '' })));
3186
+ : null, iconEnd: h("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", "stroke-width": "2" }, h("path", { d: "M4 6l4 4 4-4" })) }, h("span", { key: '5eea76015ea63775315e5bf46e7b99c65cd5bc22', class: "trigger-label" }, hasValue ? this.selectedOption.label : this.placeholder)), this.searchable && this.open && (h("div", { key: 'c3cb84ae7d333ee84d40639fae5ebea7ba4eda36', class: "multiselect-search", slot: "header" }, h("le-string-input", { key: '1e887755cb1ec376f49d4bda1e86d5bb0709fbce', mode: "default", inputRef: el => (this.inputEl = el), class: "search-input", placeholder: "Search...", value: this.searchQuery, onInput: this.handleSearchInput })))), this.name && h("input", { key: '1cbcbe00822aeda2ccfecedef506f0de01c1b010', type: "hidden", name: this.name, value: this.value?.toString() ?? '' })));
2244
3187
  }
2245
3188
  static get watchers() { return {
2246
3189
  "value": ["handleValueChange"],
@@ -2731,5 +3674,5 @@ const LeStringInput = class {
2731
3674
  };
2732
3675
  LeStringInput.style = leStringInputCss();
2733
3676
 
2734
- export { LeButton as le_button, LeCheckbox as le_checkbox, LeCollapse as le_collapse, LeComponent as le_component, LeCurrentHeading as le_current_heading, LeDropdownBase as le_dropdown_base, LeHeader as le_header, LePopover as le_popover, LePopup as le_popup, LeScrollProgress as le_scroll_progress, LeSelect as le_select, LeSlot as le_slot, LeStringInput as le_string_input };
2735
- //# sourceMappingURL=le-button.le-checkbox.le-collapse.le-component.le-current-heading.le-dropdown-base.le-header.le-popover.le-popup.le-scroll-progress.le-select.le-slot.le-string-input.entry.js.map
3677
+ export { LeBar as le_bar, LeButton as le_button, LeCheckbox as le_checkbox, LeCollapse as le_collapse, LeComponent as le_component, LeCurrentHeading as le_current_heading, LeDropdownBase as le_dropdown_base, LeHeader as le_header, LeIcon as le_icon, LeNavigation as le_navigation, LePopover as le_popover, LePopup as le_popup, LeScrollProgress as le_scroll_progress, LeSelect as le_select, LeSlot as le_slot, LeStringInput as le_string_input };
3678
+ //# sourceMappingURL=le-bar.le-button.le-checkbox.le-collapse.le-component.le-current-heading.le-dropdown-base.le-header.le-icon.le-navigation.le-popover.le-popup.le-scroll-progress.le-select.le-slot.le-string-input.entry.js.map