@melodicdev/components 3.0.0 → 4.0.0
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/assets/melodic-components.js +4371 -2363
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +6220 -4461
- package/lib/components/data-display/calendar-view/calendar-view-month.template.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view-month.template.js +17 -0
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts +23 -3
- package/lib/components/data-display/calendar-view/calendar-view.component.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.component.js +76 -21
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +9 -0
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.utils.js +68 -19
- package/lib/components/data-display/data-grid/data-grid.component.d.ts +24 -0
- package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.component.js +104 -31
- package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.template.js +3 -0
- package/lib/components/data-display/table/table.component.d.ts +7 -0
- package/lib/components/data-display/table/table.component.d.ts.map +1 -1
- package/lib/components/data-display/table/table.component.js +20 -5
- package/lib/components/data-display/table/table.template.d.ts.map +1 -1
- package/lib/components/data-display/table/table.template.js +3 -0
- package/lib/components/data-display/table-core/index.d.ts +1 -0
- package/lib/components/data-display/table-core/index.d.ts.map +1 -1
- package/lib/components/data-display/table-core/index.js +1 -0
- package/lib/components/data-display/table-core/memo.d.ts +10 -0
- package/lib/components/data-display/table-core/memo.d.ts.map +1 -0
- package/lib/components/data-display/table-core/memo.js +20 -0
- package/lib/components/feedback/alert/alert.styles.d.ts.map +1 -1
- package/lib/components/feedback/alert/alert.styles.js +25 -0
- package/lib/components/feedback/progress/progress.styles.d.ts.map +1 -1
- package/lib/components/feedback/progress/progress.styles.js +8 -3
- package/lib/components/feedback/spinner/spinner.styles.d.ts.map +1 -1
- package/lib/components/feedback/spinner/spinner.styles.js +2 -11
- package/lib/components/feedback/toast/toast-container.template.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast-container.template.js +4 -0
- package/lib/components/feedback/toast/toast.component.d.ts +3 -2
- package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.component.js +10 -0
- package/lib/components/feedback/toast/toast.service.d.ts +26 -6
- package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.service.js +53 -18
- package/lib/components/feedback/toast/toast.template.js +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts +7 -0
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.js +39 -0
- package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.template.js +5 -1
- package/lib/components/forms/button-group/button-group.component.d.ts +3 -2
- package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.component.js +11 -1
- package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -0
- package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.component.js +5 -1
- package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.template.js +2 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts +21 -0
- package/lib/components/forms/date-picker/calendar.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.component.js +69 -2
- package/lib/components/forms/date-picker/calendar.template.d.ts.map +1 -1
- package/lib/components/forms/date-picker/calendar.template.js +6 -3
- package/lib/components/forms/date-picker/date-picker.component.d.ts +6 -0
- package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.component.js +41 -12
- package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
- package/lib/components/forms/file-upload/file-upload.component.js +15 -5
- package/lib/components/forms/form-field/form-field.component.d.ts +8 -0
- package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
- package/lib/components/forms/form-field/form-field.component.js +41 -6
- package/lib/components/forms/form-field/form-field.template.js +1 -1
- package/lib/components/forms/input/input.component.d.ts +26 -3
- package/lib/components/forms/input/input.component.d.ts.map +1 -1
- package/lib/components/forms/input/input.component.js +46 -6
- package/lib/components/forms/input/input.template.d.ts.map +1 -1
- package/lib/components/forms/input/input.template.js +9 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card-group.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card-group.component.js +34 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts +6 -0
- package/lib/components/forms/radio-card-group/radio-card.component.d.ts.map +1 -1
- package/lib/components/forms/radio-card-group/radio-card.component.js +7 -1
- package/lib/components/forms/radio-card-group/radio-card.template.js +1 -1
- package/lib/components/forms/select/select.component.d.ts +8 -0
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +75 -1
- package/lib/components/forms/select/select.template.d.ts.map +1 -1
- package/lib/components/forms/select/select.template.js +5 -1
- package/lib/components/forms/textarea/textarea.component.d.ts +10 -3
- package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.component.js +10 -5
- package/lib/components/forms/textarea/textarea.template.d.ts.map +1 -1
- package/lib/components/forms/textarea/textarea.template.js +2 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts +16 -0
- package/lib/components/forms/time-picker/time-picker.component.d.ts.map +1 -1
- package/lib/components/forms/time-picker/time-picker.component.js +43 -3
- package/lib/components/foundation/container/container.component.js +5 -5
- package/lib/components/foundation/container/container.styles.d.ts.map +1 -1
- package/lib/components/foundation/container/container.styles.js +10 -0
- package/lib/components/foundation/stack/stack.component.d.ts +6 -0
- package/lib/components/foundation/stack/stack.component.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.component.js +11 -5
- package/lib/components/foundation/stack/stack.styles.d.ts.map +1 -1
- package/lib/components/foundation/stack/stack.styles.js +14 -0
- package/lib/components/general/icon/icon.template.d.ts.map +1 -1
- package/lib/components/general/icon/icon.template.js +7 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.d.ts.map +1 -1
- package/lib/components/navigation/breadcrumb/breadcrumb-item.template.js +2 -1
- package/lib/components/navigation/functions/match-by-route.function.d.ts +16 -0
- package/lib/components/navigation/functions/match-by-route.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/match-by-route.function.js +34 -0
- package/lib/components/navigation/functions/route-link.function.d.ts +20 -0
- package/lib/components/navigation/functions/route-link.function.d.ts.map +1 -0
- package/lib/components/navigation/functions/route-link.function.js +34 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts +8 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.component.js +12 -2
- package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.styles.js +10 -0
- package/lib/components/navigation/pagination/pagination.template.js +2 -2
- package/lib/components/navigation/sidebar/sidebar-item.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar-item.template.js +5 -1
- package/lib/components/navigation/sidebar/sidebar.component.d.ts +12 -6
- package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.component.js +20 -12
- package/lib/components/navigation/sidebar/sidebar.template.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.template.js +5 -1
- package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.component.js +19 -1
- package/lib/components/navigation/steps/step.template.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.template.js +6 -0
- package/lib/components/navigation/steps/steps.component.d.ts +10 -0
- package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/steps.component.js +42 -9
- package/lib/components/navigation/steps/steps.template.js +9 -0
- package/lib/components/navigation/tabs/tab-panel.styles.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tab-panel.styles.js +7 -2
- package/lib/components/navigation/tabs/tabs.component.d.ts +10 -0
- package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tabs.component.js +36 -7
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts +19 -9
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog-ref.class.js +37 -5
- package/lib/components/overlays/dropdown/dropdown.component.d.ts +7 -0
- package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown.component.js +26 -11
- package/lib/components/overlays/popover/popover.component.d.ts +8 -0
- package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
- package/lib/components/overlays/popover/popover.component.js +17 -0
- package/lib/components/overlays/tooltip/tooltip.component.d.ts +6 -5
- package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.component.js +14 -10
- package/lib/components/sections/app-shell/app-shell.component.d.ts +13 -0
- package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.component.js +45 -1
- package/lib/components/sections/app-shell/app-shell.styles.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.styles.js +15 -0
- package/lib/components/sections/app-shell/app-shell.template.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.template.js +5 -0
- package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.template.js +6 -1
- package/lib/directives/tooltip.directive.d.ts.map +1 -1
- package/lib/directives/tooltip.directive.js +39 -6
- package/lib/theme/functions/apply-theme.function.d.ts +4 -1
- package/lib/theme/functions/apply-theme.function.d.ts.map +1 -1
- package/lib/theme/functions/apply-theme.function.js +20 -4
- package/lib/theme/functions/create-theme.function.js +0 -1
- package/lib/utils/accessibility/cross-root-aria.d.ts +40 -0
- package/lib/utils/accessibility/cross-root-aria.d.ts.map +1 -0
- package/lib/utils/accessibility/cross-root-aria.js +97 -0
- package/lib/utils/accessibility/index.d.ts +1 -0
- package/lib/utils/accessibility/index.d.ts.map +1 -1
- package/lib/utils/accessibility/index.js +1 -0
- package/lib/utils/directives/index.d.ts +1 -0
- package/lib/utils/directives/index.d.ts.map +1 -1
- package/lib/utils/directives/index.js +1 -0
- package/lib/utils/directives/watch-light-slots.d.ts +20 -0
- package/lib/utils/directives/watch-light-slots.d.ts.map +1 -0
- package/lib/utils/directives/watch-light-slots.js +36 -0
- package/package.json +2 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Injector, RouterService } from '@melodicdev/core';
|
|
2
|
+
/**
|
|
3
|
+
* Intercept an anchor click and route it through the router when possible.
|
|
4
|
+
*
|
|
5
|
+
* Navigation components rendered raw `<a href>` elements with no
|
|
6
|
+
* `preventDefault`, so clicking one triggered a full page load — while tabs and
|
|
7
|
+
* steps in the same app navigated client-side. That inconsistency reloads the
|
|
8
|
+
* whole SPA (losing state) on what looks like ordinary in-app navigation.
|
|
9
|
+
*
|
|
10
|
+
* Native behaviour is preserved where it is the right thing:
|
|
11
|
+
* - modifier / non-primary clicks (new tab, new window, download)
|
|
12
|
+
* - external links, explicit `target`, and non-http(s) schemes
|
|
13
|
+
* - apps with no router registered
|
|
14
|
+
*
|
|
15
|
+
* Returns true when the router handled it.
|
|
16
|
+
*/
|
|
17
|
+
export function routeAnchorClick(event, href, options = {}) {
|
|
18
|
+
if (event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (!href || options.external || (options.target && options.target !== '_self')) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
// Absolute URLs to another origin, mailto:, tel:, … stay native.
|
|
25
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(href) && !href.startsWith(window.location.origin)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (!Injector.has(RouterService)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
void Injector.get(RouterService).navigate(href);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
@@ -30,6 +30,14 @@ export declare class PaginationComponent implements IElementRef {
|
|
|
30
30
|
/** Number of sibling pages to show around current */
|
|
31
31
|
siblings: number;
|
|
32
32
|
get pages(): PaginationPage[];
|
|
33
|
+
/**
|
|
34
|
+
* The page actually being displayed, clamped into `[1, totalPages]`.
|
|
35
|
+
*
|
|
36
|
+
* `pages` already clamps, so a `page` outside the range (a filter that
|
|
37
|
+
* shrank the result set while the user was on page 9) rendered a list where
|
|
38
|
+
* nothing matched `page` — no active styling and no `aria-current` at all.
|
|
39
|
+
*/
|
|
40
|
+
get currentPage(): number;
|
|
33
41
|
get hasPrevious(): boolean;
|
|
34
42
|
get hasNext(): boolean;
|
|
35
43
|
goToPage: (page: number) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/pagination/pagination.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,qBAMa,mBAAoB,YAAW,WAAW;IAC/C,UAAU,EAAG,WAAW,CAAC;IAIhC,OAAc,aAAa;;;;MAIhB;IAEX,oCAAoC;IAC7B,IAAI,SAAK;IAEhB,4BAA4B;IACrB,UAAU,SAAK;IAEtB,qDAAqD;IAC9C,QAAQ,SAAK;IAEpB,IAAW,KAAK,IAAI,cAAc,EAAE,CA2CnC;IAED,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEM,QAAQ,GAAI,MAAM,MAAM,KAAG,IAAI,CAWpC;IAEK,QAAQ,QAAO,IAAI,CAExB;IAEK,IAAI,QAAO,IAAI,CAEpB;CACF"}
|
|
1
|
+
{"version":3,"file":"pagination.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/pagination/pagination.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAEpF;;;;;;;;;;GAUG;AACH,qBAMa,mBAAoB,YAAW,WAAW;IAC/C,UAAU,EAAG,WAAW,CAAC;IAIhC,OAAc,aAAa;;;;MAIhB;IAEX,oCAAoC;IAC7B,IAAI,SAAK;IAEhB,4BAA4B;IACrB,UAAU,SAAK;IAEtB,qDAAqD;IAC9C,QAAQ,SAAK;IAEpB,IAAW,KAAK,IAAI,cAAc,EAAE,CA2CnC;IAED;;;;;;OAMG;IACH,IAAW,WAAW,IAAI,MAAM,CAE/B;IAED,IAAW,WAAW,IAAI,OAAO,CAEhC;IAED,IAAW,OAAO,IAAI,OAAO,CAE5B;IAEM,QAAQ,GAAI,MAAM,MAAM,KAAG,IAAI,CAWpC;IAEK,QAAQ,QAAO,IAAI,CAExB;IAEK,IAAI,QAAO,IAAI,CAEpB;CACF"}
|
|
@@ -85,11 +85,21 @@ let PaginationComponent = class PaginationComponent {
|
|
|
85
85
|
{ type: 'page', value: total }
|
|
86
86
|
];
|
|
87
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* The page actually being displayed, clamped into `[1, totalPages]`.
|
|
90
|
+
*
|
|
91
|
+
* `pages` already clamps, so a `page` outside the range (a filter that
|
|
92
|
+
* shrank the result set while the user was on page 9) rendered a list where
|
|
93
|
+
* nothing matched `page` — no active styling and no `aria-current` at all.
|
|
94
|
+
*/
|
|
95
|
+
get currentPage() {
|
|
96
|
+
return Math.min(Math.max(1, Number(this.page) || 1), Math.max(1, this.totalPages));
|
|
97
|
+
}
|
|
88
98
|
get hasPrevious() {
|
|
89
|
-
return this.
|
|
99
|
+
return this.currentPage > 1;
|
|
90
100
|
}
|
|
91
101
|
get hasNext() {
|
|
92
|
-
return this.
|
|
102
|
+
return this.currentPage < this.totalPages;
|
|
93
103
|
}
|
|
94
104
|
};
|
|
95
105
|
PaginationComponent = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/pagination/pagination.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"pagination.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/pagination/pagination.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,iDA0H5B,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { css } from '@melodicdev/core';
|
|
2
2
|
export const paginationStyles = () => css `
|
|
3
3
|
:host {
|
|
4
|
+
/* ── Pagination: focus ── */
|
|
5
|
+
--ml-pagination-focus-width: 2px;
|
|
6
|
+
--ml-pagination-focus-color: var(--ml-color-primary);
|
|
7
|
+
--ml-pagination-focus-offset: 2px;
|
|
8
|
+
|
|
4
9
|
/* Layout */
|
|
5
10
|
--ml-pagination-gap: var(--ml-space-3);
|
|
6
11
|
--ml-pagination-pages-gap: var(--ml-space-1);
|
|
@@ -79,6 +84,11 @@ export const paginationStyles = () => css `
|
|
|
79
84
|
color: var(--ml-pagination-btn-hover-color);
|
|
80
85
|
}
|
|
81
86
|
|
|
87
|
+
.ml-pagination__btn:focus-visible {
|
|
88
|
+
outline: var(--ml-pagination-focus-width) solid var(--ml-pagination-focus-color);
|
|
89
|
+
outline-offset: var(--ml-pagination-focus-offset);
|
|
90
|
+
}
|
|
91
|
+
|
|
82
92
|
.ml-pagination__btn--nav {
|
|
83
93
|
font-weight: var(--ml-pagination-nav-font-weight);
|
|
84
94
|
}
|
|
@@ -26,10 +26,10 @@ export function paginationTemplate(c) {
|
|
|
26
26
|
class=${classMap({
|
|
27
27
|
'ml-pagination__btn': true,
|
|
28
28
|
'ml-pagination__btn--page': true,
|
|
29
|
-
'ml-pagination__btn--active': p.value ===
|
|
29
|
+
'ml-pagination__btn--active': p.value === c.currentPage
|
|
30
30
|
})}
|
|
31
31
|
aria-label=${`Page ${p.value}`}
|
|
32
|
-
aria-current=${p.value ===
|
|
32
|
+
aria-current=${p.value === c.currentPage ? 'page' : false}
|
|
33
33
|
@click=${() => c.goToPage(p.value)}
|
|
34
34
|
>
|
|
35
35
|
${p.value}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-item.template.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar/sidebar-item.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"sidebar-item.template.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar/sidebar-item.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,oBAAoB,6CAmF1D"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html, classMap, when } from '@melodicdev/core';
|
|
2
|
+
import { routeAnchorClick } from '../functions/route-link.function.js';
|
|
2
3
|
export function sidebarItemTemplate(c) {
|
|
3
4
|
const level = parseInt(c.level, 10) || 0;
|
|
4
5
|
const isCollapsed = c.collapsed;
|
|
@@ -46,7 +47,10 @@ export function sidebarItemTemplate(c) {
|
|
|
46
47
|
href=${c.href}
|
|
47
48
|
?target=${c.external ? '_blank' : null}
|
|
48
49
|
?rel=${c.external ? 'noopener noreferrer' : null}
|
|
49
|
-
@click=${
|
|
50
|
+
@click=${(event) => {
|
|
51
|
+
routeAnchorClick(event, c.href, { external: c.external });
|
|
52
|
+
c.handleClick(event);
|
|
53
|
+
}}
|
|
50
54
|
>
|
|
51
55
|
${content}
|
|
52
56
|
</a>
|
|
@@ -46,12 +46,18 @@ export declare class SidebarComponent implements IElementRef, OnCreate, OnDestro
|
|
|
46
46
|
private readonly _handleItemClick;
|
|
47
47
|
private readonly _handleMouseEnter;
|
|
48
48
|
private readonly _handleMouseLeave;
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Slot presence, kept in sync from the light DOM.
|
|
51
|
+
*
|
|
52
|
+
* These were live getters read inside `when()`, so nothing re-rendered when
|
|
53
|
+
* content was slotted after mount — an async-rendered user card or search
|
|
54
|
+
* box simply never appeared. `watchSlotPresence` cannot help here because
|
|
55
|
+
* the slots themselves are conditional.
|
|
56
|
+
*/
|
|
57
|
+
hasSearch: boolean;
|
|
58
|
+
hasFeature: boolean;
|
|
59
|
+
hasUser: boolean;
|
|
60
|
+
private _slotWatcherCleanup;
|
|
55
61
|
onCreate(): void;
|
|
56
62
|
onRender(): void;
|
|
57
63
|
onDestroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar/sidebar.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SA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BAAqB,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,KAAG,IAAI,CAEjE;IAEF,mCAAmC;IAC5B,kBAAkB,GAAI,MAAM,cAAc,KAAG,IAAI,CAQtD;IAEF,0BAA0B;IACnB,aAAa,GAAI,OAAO,aAAa,KAAG,IAAI,CAoCjD;IAEF;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAyCzB,kCAAkC;IAC3B,aAAa,cAAqB;IAEzC,uBAAuB;IACvB,OAAO,CAAC,YAAY;IAqBpB,8CAA8C;IAC9C,OAAO,CAAC,WAAW;IASnB,0CAA0C;IAC1C,OAAO,CAAC,YAAY;IASpB,0CAA0C;IAC1C,OAAO,CAAC,YAAY;IASpB,2DAA2D;IAC3D,OAAO,CAAC,gBAAgB;CAexB"}
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { MelodicComponent } from '@melodicdev/core';
|
|
8
8
|
import { sidebarTemplate } from './sidebar.template.js';
|
|
9
9
|
import { sidebarStyles } from './sidebar.styles.js';
|
|
10
|
+
import { watchLightSlots, hasLightSlot } from '../../../utils/directives/watch-light-slots.js';
|
|
10
11
|
/**
|
|
11
12
|
* ml-sidebar - App-level sidebar navigation component
|
|
12
13
|
*
|
|
@@ -53,6 +54,18 @@ let SidebarComponent = class SidebarComponent {
|
|
|
53
54
|
this._handleItemClick = this.onItemClick.bind(this);
|
|
54
55
|
this._handleMouseEnter = this.onMouseEnter.bind(this);
|
|
55
56
|
this._handleMouseLeave = this.onMouseLeave.bind(this);
|
|
57
|
+
/**
|
|
58
|
+
* Slot presence, kept in sync from the light DOM.
|
|
59
|
+
*
|
|
60
|
+
* These were live getters read inside `when()`, so nothing re-rendered when
|
|
61
|
+
* content was slotted after mount — an async-rendered user card or search
|
|
62
|
+
* box simply never appeared. `watchSlotPresence` cannot help here because
|
|
63
|
+
* the slots themselves are conditional.
|
|
64
|
+
*/
|
|
65
|
+
this.hasSearch = false;
|
|
66
|
+
this.hasFeature = false;
|
|
67
|
+
this.hasUser = false;
|
|
68
|
+
this._slotWatcherCleanup = null;
|
|
56
69
|
/** Handle slotted items change */
|
|
57
70
|
this.handleDefaultSlotChange = () => {
|
|
58
71
|
this.updateItemStates();
|
|
@@ -110,23 +123,16 @@ let SidebarComponent = class SidebarComponent {
|
|
|
110
123
|
/** Track expanded config items */
|
|
111
124
|
this.expandedItems = new Set();
|
|
112
125
|
}
|
|
113
|
-
/** Check if search slot has content */
|
|
114
|
-
get hasSearch() {
|
|
115
|
-
return this.elementRef?.querySelector('[slot="search"]') !== null;
|
|
116
|
-
}
|
|
117
|
-
/** Check if feature slot has content */
|
|
118
|
-
get hasFeature() {
|
|
119
|
-
return this.elementRef?.querySelector('[slot="feature"]') !== null;
|
|
120
|
-
}
|
|
121
|
-
/** Check if user slot has content */
|
|
122
|
-
get hasUser() {
|
|
123
|
-
return this.elementRef?.querySelector('[slot="user"]') !== null;
|
|
124
|
-
}
|
|
125
126
|
onCreate() {
|
|
126
127
|
// Set initial collapsed state based on variant
|
|
127
128
|
if (this.variant === 'slim') {
|
|
128
129
|
this.collapsed = true;
|
|
129
130
|
}
|
|
131
|
+
this._slotWatcherCleanup = watchLightSlots(this.elementRef, () => {
|
|
132
|
+
this.hasSearch = hasLightSlot(this.elementRef, 'search');
|
|
133
|
+
this.hasFeature = hasLightSlot(this.elementRef, 'feature');
|
|
134
|
+
this.hasUser = hasLightSlot(this.elementRef, 'user');
|
|
135
|
+
});
|
|
130
136
|
// Listen for item click events from children
|
|
131
137
|
this.elementRef.addEventListener('ml:sidebar-item-click', this._handleItemClick);
|
|
132
138
|
// Set up hover for slim variant
|
|
@@ -139,6 +145,8 @@ let SidebarComponent = class SidebarComponent {
|
|
|
139
145
|
this.updateItemStates();
|
|
140
146
|
}
|
|
141
147
|
onDestroy() {
|
|
148
|
+
this._slotWatcherCleanup?.();
|
|
149
|
+
this._slotWatcherCleanup = null;
|
|
142
150
|
this.elementRef.removeEventListener('ml:sidebar-item-click', this._handleItemClick);
|
|
143
151
|
this.elementRef.removeEventListener('mouseenter', this._handleMouseEnter);
|
|
144
152
|
this.elementRef.removeEventListener('mouseleave', this._handleMouseLeave);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar.template.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar/sidebar.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"sidebar.template.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/sidebar/sidebar.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAI/D,wBAAgB,eAAe,CAAC,CAAC,EAAE,gBAAgB,kBAkElD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { html, classMap, repeat, when } from '@melodicdev/core';
|
|
2
|
+
import { routeAnchorClick } from '../functions/route-link.function.js';
|
|
2
3
|
export function sidebarTemplate(c) {
|
|
3
4
|
const hasNavConfig = c.navigation.length > 0;
|
|
4
5
|
const hasFooterConfig = c.footerNavigation.length > 0;
|
|
@@ -125,7 +126,10 @@ function renderNavItem(c, item, level) {
|
|
|
125
126
|
href=${item.href}
|
|
126
127
|
?target=${item.external ? '_blank' : null}
|
|
127
128
|
?rel=${item.external ? 'noopener noreferrer' : null}
|
|
128
|
-
@click=${
|
|
129
|
+
@click=${(event) => {
|
|
130
|
+
routeAnchorClick(event, item.href ?? '', { external: item.external });
|
|
131
|
+
handleClick(event);
|
|
132
|
+
}}
|
|
129
133
|
>
|
|
130
134
|
${content}
|
|
131
135
|
</a>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/steps/step.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAK/G;;;;;;;;;;GAUG;AACH,
|
|
1
|
+
{"version":3,"file":"step.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/steps/step.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAK/G;;;;;;;;;;GAUG;AACH,qBAwBa,aAAc,YAAW,WAAW;IACzC,UAAU,EAAG,WAAW,CAAC;IAEhC,sBAAsB;IACf,KAAK,SAAM;IAElB,iBAAiB;IACV,KAAK,SAAM;IAElB,iCAAiC;IAC1B,WAAW,SAAM;IAExB,oCAAoC;IAC7B,IAAI,SAAM;IAEjB,0BAA0B;IACnB,IAAI,SAAM;IAEjB,wBAAwB;IACjB,QAAQ,UAAS;IAExB,sCAAsC;IAC/B,MAAM,EAAE,UAAU,CAAc;IAEvC,yCAAyC;IAClC,OAAO,EAAE,YAAY,CAAc;IAE1C,0CAA0C;IACnC,SAAS,EAAE,cAAc,CAAW;IAE3C,uCAAuC;IAChC,KAAK,EAAE,UAAU,CAAa;IAErC,6CAA6C;IACtC,WAAW,EAAE,gBAAgB,CAAgB;IAEpD,8DAA8D;IACvD,UAAU,SAAO;IAExB,0CAA0C;IACnC,KAAK,UAAS;IAErB,yCAAyC;IAClC,IAAI,UAAS;IAEpB,4CAA4C;IACrC,OAAO,UAAS;IAEvB,2BAA2B;IACpB,WAAW,QAAO,IAAI,CAU3B;CACF"}
|
|
@@ -68,7 +68,25 @@ StepComponent = __decorate([
|
|
|
68
68
|
selector: 'ml-step',
|
|
69
69
|
template: stepTemplate,
|
|
70
70
|
styles: stepStyles,
|
|
71
|
-
attributes: [
|
|
71
|
+
attributes: [
|
|
72
|
+
'value',
|
|
73
|
+
'label',
|
|
74
|
+
'description',
|
|
75
|
+
'icon',
|
|
76
|
+
// `href` drives routed steps and is documented as an attribute, but it
|
|
77
|
+
// was never observed — so `<ml-step href="/x">` never navigated.
|
|
78
|
+
'href',
|
|
79
|
+
'disabled',
|
|
80
|
+
'status',
|
|
81
|
+
'variant',
|
|
82
|
+
'connector',
|
|
83
|
+
'color',
|
|
84
|
+
'orientation',
|
|
85
|
+
'step-number',
|
|
86
|
+
'first',
|
|
87
|
+
'last',
|
|
88
|
+
'compact'
|
|
89
|
+
]
|
|
72
90
|
})
|
|
73
91
|
], StepComponent);
|
|
74
92
|
export { StepComponent };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step.template.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/steps/step.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,YAAY,CAAC,CAAC,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"step.template.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/steps/step.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,wBAAgB,YAAY,CAAC,CAAC,EAAE,aAAa,6CAiC5C"}
|
|
@@ -20,6 +20,12 @@ export function stepTemplate(c) {
|
|
|
20
20
|
aria-disabled=${c.disabled}
|
|
21
21
|
tabindex=${c.status === 'current' ? '0' : '-1'}
|
|
22
22
|
@click=${c.handleClick}
|
|
23
|
+
@keydown=${(e) => {
|
|
24
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
25
|
+
return;
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
c.handleClick();
|
|
28
|
+
}}
|
|
23
29
|
>
|
|
24
30
|
${when(isBar, () => renderBarStep(c))}
|
|
25
31
|
${when(!isBar && !isCompact, () => renderStandardStep(c))}
|
|
@@ -48,6 +48,16 @@ export declare class StepsComponent implements IElementRef, OnCreate, OnDestroy,
|
|
|
48
48
|
private _slottedSteps;
|
|
49
49
|
/** Navigation event listener for routed mode */
|
|
50
50
|
private readonly _handleNavigation;
|
|
51
|
+
/**
|
|
52
|
+
* Whether the NavigationEvent listener is currently attached.
|
|
53
|
+
*
|
|
54
|
+
* `routed` used to be read once, in onCreate, to decide whether to listen.
|
|
55
|
+
* Toggling it afterwards left the listener either missing (routed turned
|
|
56
|
+
* on) or leaked (turned off).
|
|
57
|
+
*/
|
|
58
|
+
private _routedListenerAttached;
|
|
59
|
+
/** Attach or detach the routed-mode listener to match `routed`. */
|
|
60
|
+
private syncRoutedListener;
|
|
51
61
|
onCreate(): void;
|
|
52
62
|
onRender(): void;
|
|
53
63
|
onDestroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"steps.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/steps/steps.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"steps.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/steps/steps.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,E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IAI9B,6CAA6C;IACtC,WAAW,IAAI,UAAU,EAAE;IAelC,wBAAwB;IACxB,OAAO,CAAC,cAAc;IAItB,yCAAyC;IACzC,OAAO,CAAC,uBAAuB;IAqB/B,8BAA8B;IAC9B,OAAO,CAAC,qBAAqB;IAuB7B,4EAA4E;IAC5E,OAAO,CAAC,SAAS;IAcjB,0CAA0C;IAC1C,OAAO,CAAC,aAAa;IAQrB,6CAA6C;IAC7C,OAAO,CAAC,YAAY;CAGpB"}
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Injector, MelodicComponent, RouterService } from '@melodicdev/core';
|
|
8
8
|
import { stepsTemplate } from './steps.template.js';
|
|
9
9
|
import { stepsStyles } from './steps.styles.js';
|
|
10
|
+
import { matchTabByRoute } from '../functions/match-by-route.function.js';
|
|
10
11
|
/**
|
|
11
12
|
* ml-steps - Multi-step progress/wizard component
|
|
12
13
|
*
|
|
@@ -55,6 +56,14 @@ let StepsComponent = class StepsComponent {
|
|
|
55
56
|
this._slottedSteps = [];
|
|
56
57
|
/** Navigation event listener for routed mode */
|
|
57
58
|
this._handleNavigation = this.onNavigation.bind(this);
|
|
59
|
+
/**
|
|
60
|
+
* Whether the NavigationEvent listener is currently attached.
|
|
61
|
+
*
|
|
62
|
+
* `routed` used to be read once, in onCreate, to decide whether to listen.
|
|
63
|
+
* Toggling it afterwards left the listener either missing (routed turned
|
|
64
|
+
* on) or leaked (turned off).
|
|
65
|
+
*/
|
|
66
|
+
this._routedListenerAttached = false;
|
|
58
67
|
/** Handle step slot changes */
|
|
59
68
|
this.handleStepSlotChange = (event) => {
|
|
60
69
|
const slot = event.target;
|
|
@@ -148,21 +157,40 @@ let StepsComponent = class StepsComponent {
|
|
|
148
157
|
}
|
|
149
158
|
};
|
|
150
159
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
this.
|
|
160
|
+
/** Attach or detach the routed-mode listener to match `routed`. */
|
|
161
|
+
syncRoutedListener() {
|
|
162
|
+
if (this.routed === this._routedListenerAttached) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
154
165
|
if (this.routed) {
|
|
155
166
|
window.addEventListener('NavigationEvent', this._handleNavigation);
|
|
167
|
+
this._routedListenerAttached = true;
|
|
156
168
|
this.syncWithRoute();
|
|
157
169
|
}
|
|
170
|
+
else {
|
|
171
|
+
window.removeEventListener('NavigationEvent', this._handleNavigation);
|
|
172
|
+
this._routedListenerAttached = false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
onCreate() {
|
|
176
|
+
// Listen for step click events from slotted ml-step elements
|
|
177
|
+
this.elementRef.addEventListener('ml:step-click', this.handleSlottedStepClick);
|
|
178
|
+
this.syncRoutedListener();
|
|
158
179
|
}
|
|
159
180
|
onRender() {
|
|
181
|
+
this.syncRoutedListener();
|
|
182
|
+
// Slotted <ml-step> elements are in the LIGHT dom, so this component's
|
|
183
|
+
// own re-render never touches them. Without this, a programmatic
|
|
184
|
+
// `active` / `variant` / `color` / `connector` / `orientation` /
|
|
185
|
+
// `compact` change moved the panel but left every step header stale.
|
|
186
|
+
this.updateSlottedStepStates();
|
|
160
187
|
this.updatePanelVisibility();
|
|
161
188
|
}
|
|
162
189
|
onDestroy() {
|
|
163
190
|
this.elementRef.removeEventListener('ml:step-click', this.handleSlottedStepClick);
|
|
164
|
-
if (this.
|
|
191
|
+
if (this._routedListenerAttached) {
|
|
165
192
|
window.removeEventListener('NavigationEvent', this._handleNavigation);
|
|
193
|
+
this._routedListenerAttached = false;
|
|
166
194
|
}
|
|
167
195
|
}
|
|
168
196
|
/** Apply the active step state and notify consumers. */
|
|
@@ -218,9 +246,12 @@ let StepsComponent = class StepsComponent {
|
|
|
218
246
|
/** Update attributes on slotted steps */
|
|
219
247
|
updateSlottedStepStates() {
|
|
220
248
|
const allSteps = this.getAllSteps();
|
|
249
|
+
// Status is a function of position relative to the active step, so
|
|
250
|
+
// resolve the active index ONCE instead of scanning the list twice per
|
|
251
|
+
// step (which made the sync O(n²)).
|
|
252
|
+
const activeIndex = allSteps.findIndex((step) => step.value === this.active);
|
|
221
253
|
this._slottedSteps.forEach((step, index) => {
|
|
222
|
-
const
|
|
223
|
-
const status = this.getStepStatus(value);
|
|
254
|
+
const status = index < activeIndex ? 'completed' : index === activeIndex ? 'current' : 'upcoming';
|
|
224
255
|
step.setAttribute('status', status);
|
|
225
256
|
step.setAttribute('variant', this.variant);
|
|
226
257
|
step.setAttribute('connector', this.connector);
|
|
@@ -241,7 +272,10 @@ let StepsComponent = class StepsComponent {
|
|
|
241
272
|
panels.forEach((panel) => {
|
|
242
273
|
const value = panel.getAttribute('value');
|
|
243
274
|
const isActive = value === this.active;
|
|
244
|
-
|
|
275
|
+
// `hidden`, not an inline `display` — an inline style beats every
|
|
276
|
+
// stylesheet rule, so a consumer could not style a panel (an entry
|
|
277
|
+
// animation, a different display mode) at all.
|
|
278
|
+
panel.hidden = !isActive;
|
|
245
279
|
// Name the panel after its step. ARIA id references cannot cross
|
|
246
280
|
// shadow-root boundaries, so the association is made by accessible
|
|
247
281
|
// name instead of aria-labelledby/aria-controls (see tabs.component).
|
|
@@ -266,8 +300,7 @@ let StepsComponent = class StepsComponent {
|
|
|
266
300
|
}
|
|
267
301
|
/** Sync active step with current route */
|
|
268
302
|
syncWithRoute() {
|
|
269
|
-
const
|
|
270
|
-
const matchingStep = this.getAllSteps().find((step) => step.href && path.startsWith(step.href));
|
|
303
|
+
const matchingStep = matchTabByRoute(this.getAllSteps(), window.location.pathname);
|
|
271
304
|
if (matchingStep) {
|
|
272
305
|
this.active = matchingStep.value;
|
|
273
306
|
this.updateSlottedStepStates();
|
|
@@ -64,6 +64,15 @@ function renderConfigStep(c, step, index) {
|
|
|
64
64
|
aria-disabled=${step.disabled || false}
|
|
65
65
|
tabindex=${status === 'current' ? '0' : '-1'}
|
|
66
66
|
@click=${() => c.handleStepClick(step.value, step.href)}
|
|
67
|
+
@keydown=${(e) => {
|
|
68
|
+
// A role="tab" div must activate on Enter/Space; arrows are
|
|
69
|
+
// handled by the tablist above. Without this the step was
|
|
70
|
+
// focusable and un-activatable by keyboard.
|
|
71
|
+
if (e.key !== 'Enter' && e.key !== ' ')
|
|
72
|
+
return;
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
c.handleStepClick(step.value, step.href);
|
|
75
|
+
}}
|
|
67
76
|
>
|
|
68
77
|
${when(isBar, () => renderBarStep(c, step))}
|
|
69
78
|
${when(!isBar && !isCompact, () => renderStandardStep(c, step, index, isFirst, isLast, status))}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-panel.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/tabs/tab-panel.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"tab-panel.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/tabs/tab-panel.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,iDAsB1B,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { css } from '@melodicdev/core';
|
|
2
2
|
export const tabPanelStyles = () => css `
|
|
3
3
|
:host {
|
|
4
|
+
/* ── Tab panel: focus ── */
|
|
5
|
+
--ml-tab-panel-focus-width: 2px;
|
|
6
|
+
--ml-tab-panel-focus-color: var(--ml-color-primary);
|
|
7
|
+
--ml-tab-panel-focus-offset: 2px;
|
|
8
|
+
|
|
4
9
|
display: block;
|
|
5
10
|
}
|
|
6
11
|
|
|
@@ -13,7 +18,7 @@ export const tabPanelStyles = () => css `
|
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
.ml-tab-panel:focus-visible {
|
|
16
|
-
outline:
|
|
17
|
-
outline-offset:
|
|
21
|
+
outline: var(--ml-tab-panel-focus-width) solid var(--ml-tab-panel-focus-color);
|
|
22
|
+
outline-offset: var(--ml-tab-panel-focus-offset);
|
|
18
23
|
}
|
|
19
24
|
`;
|
|
@@ -55,6 +55,16 @@ export declare class TabsComponent implements IElementRef, OnCreate, OnDestroy,
|
|
|
55
55
|
private _slottedTabs;
|
|
56
56
|
/** Navigation event listener for routed mode */
|
|
57
57
|
private readonly _handleNavigation;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the NavigationEvent listener is currently attached.
|
|
60
|
+
*
|
|
61
|
+
* `routed` used to be read once, in onCreate, to decide whether to listen.
|
|
62
|
+
* Toggling it afterwards left the listener either missing (routed turned
|
|
63
|
+
* on) or leaked (turned off).
|
|
64
|
+
*/
|
|
65
|
+
private _routedListenerAttached;
|
|
66
|
+
/** Attach or detach the routed-mode listener to match `routed`. */
|
|
67
|
+
private syncRoutedListener;
|
|
58
68
|
/** Listener for ml:tab-click from slotted ml-tab elements */
|
|
59
69
|
private readonly _handleTabClick;
|
|
60
70
|
onCreate(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/tabs/tabs.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs.component.d.ts","sourceRoot":"","sources":["../../../../src/components/navigation/tabs/tabs.component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK/E;;;;;;;;;;;;;;;;;;;;;;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6C;IAC7C,OAAO,CAAC,YAAY;CAGpB"}
|
|
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Injector, MelodicComponent, RouterService } from '@melodicdev/core';
|
|
8
8
|
import { tabsTemplate } from './tabs.template.js';
|
|
9
9
|
import { tabsStyles } from './tabs.styles.js';
|
|
10
|
+
import { matchTabByRoute } from '../functions/match-by-route.function.js';
|
|
10
11
|
/**
|
|
11
12
|
* ml-tabs - Tabbed interface component with optional router integration
|
|
12
13
|
*
|
|
@@ -61,6 +62,14 @@ let TabsComponent = class TabsComponent {
|
|
|
61
62
|
this._slottedTabs = [];
|
|
62
63
|
/** Navigation event listener for routed mode */
|
|
63
64
|
this._handleNavigation = this.onNavigation.bind(this);
|
|
65
|
+
/**
|
|
66
|
+
* Whether the NavigationEvent listener is currently attached.
|
|
67
|
+
*
|
|
68
|
+
* `routed` used to be read once, in onCreate, to decide whether to listen.
|
|
69
|
+
* Toggling it afterwards left the listener either missing (routed turned
|
|
70
|
+
* on) or leaked (turned off).
|
|
71
|
+
*/
|
|
72
|
+
this._routedListenerAttached = false;
|
|
64
73
|
/** Listener for ml:tab-click from slotted ml-tab elements */
|
|
65
74
|
this._handleTabClick = (event) => {
|
|
66
75
|
// ml:tab-click is internal tab→tabs coordination; consumers get ml:change.
|
|
@@ -139,21 +148,39 @@ let TabsComponent = class TabsComponent {
|
|
|
139
148
|
}
|
|
140
149
|
};
|
|
141
150
|
}
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
/** Attach or detach the routed-mode listener to match `routed`. */
|
|
152
|
+
syncRoutedListener() {
|
|
153
|
+
if (this.routed === this._routedListenerAttached) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
144
156
|
if (this.routed) {
|
|
145
157
|
window.addEventListener('NavigationEvent', this._handleNavigation);
|
|
158
|
+
this._routedListenerAttached = true;
|
|
146
159
|
this.syncWithRoute();
|
|
147
160
|
}
|
|
161
|
+
else {
|
|
162
|
+
window.removeEventListener('NavigationEvent', this._handleNavigation);
|
|
163
|
+
this._routedListenerAttached = false;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
onCreate() {
|
|
167
|
+
this.elementRef.addEventListener('ml:tab-click', this._handleTabClick);
|
|
168
|
+
this.syncRoutedListener();
|
|
148
169
|
}
|
|
149
170
|
onRender() {
|
|
150
|
-
|
|
171
|
+
this.syncRoutedListener();
|
|
172
|
+
// Slotted <ml-tab> elements live in the LIGHT dom, so a re-render of
|
|
173
|
+
// this component's own template does not touch them. Syncing only the
|
|
174
|
+
// panels meant a programmatic `value` write moved the panel but left
|
|
175
|
+
// the tab itself looking unselected.
|
|
176
|
+
this.updateTabStates();
|
|
151
177
|
this.updatePanelVisibility();
|
|
152
178
|
}
|
|
153
179
|
onDestroy() {
|
|
154
180
|
this.elementRef.removeEventListener('ml:tab-click', this._handleTabClick);
|
|
155
|
-
if (this.
|
|
181
|
+
if (this._routedListenerAttached) {
|
|
156
182
|
window.removeEventListener('NavigationEvent', this._handleNavigation);
|
|
183
|
+
this._routedListenerAttached = false;
|
|
157
184
|
}
|
|
158
185
|
}
|
|
159
186
|
/** Apply the active tab state and notify consumers. */
|
|
@@ -200,7 +227,10 @@ let TabsComponent = class TabsComponent {
|
|
|
200
227
|
panels.forEach((panel) => {
|
|
201
228
|
const value = panel.getAttribute('value');
|
|
202
229
|
const isActive = value === this.value;
|
|
203
|
-
|
|
230
|
+
// `hidden`, not an inline `display` — an inline style beats every
|
|
231
|
+
// stylesheet rule, so a consumer could not style a panel (an entry
|
|
232
|
+
// animation, a different display mode) at all.
|
|
233
|
+
panel.hidden = !isActive;
|
|
204
234
|
// Name the panel after its tab. ARIA id references cannot cross
|
|
205
235
|
// shadow-root boundaries (the tab's role="tab" element and the
|
|
206
236
|
// panel's role="tabpanel" element live in different shadow trees),
|
|
@@ -227,8 +257,7 @@ let TabsComponent = class TabsComponent {
|
|
|
227
257
|
}
|
|
228
258
|
/** Sync active tab with current route (for routed mode) */
|
|
229
259
|
syncWithRoute() {
|
|
230
|
-
const
|
|
231
|
-
const matchingTab = this.getAllTabs().find((tab) => tab.href && path.startsWith(tab.href));
|
|
260
|
+
const matchingTab = matchTabByRoute(this.getAllTabs(), window.location.pathname);
|
|
232
261
|
if (matchingTab) {
|
|
233
262
|
this.value = matchingTab.value;
|
|
234
263
|
this.updateTabStates();
|