@m3e/tabs 1.0.0-rc.1 → 1.0.0-rc.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.
@@ -1,87 +0,0 @@
1
- import { CSSResultGroup, LitElement, PropertyValues } from "lit";
2
- declare const M3eTabElement_base: import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor<import("@m3e/core").SelectedMixin> & import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor<import("@m3e/core").HtmlForMixin> & import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor & import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor<import("@m3e/core").DisabledMixin> & import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor<import("@m3e/core").AttachInternalsMixin> & typeof LitElement;
3
- /**
4
- * @summary
5
- * An interactive element that, when activated, presents an associated tab panel.
6
- *
7
- * @description
8
- * The `m3e-tab` component is an interactive control used within a tabbed interface to activate and
9
- * reveal an associated tab panel. It supports accessible labeling, optional iconography, and selection
10
- * state styling consistent with Material 3 guidance. Tabs may be disabled, selected, or linked to a
11
- * specific panel via the `for` attribute, enabling declarative control and semantic clarity.
12
- *
13
- * @example
14
- * The following example illustrates using the `m3e-tabs`, `m3e-tab`, and `m3e-tab-panel` components to present
15
- * secondary tabs.
16
- * ```html
17
- * <m3e-tabs>
18
- * <m3e-tab selected for="videos"><m3e-icon slot="icon" name="videocam"></m3e-icon>Video</m3e-tab>
19
- * <m3e-tab for="photos"><m3e-icon slot="icon" name="photo"></m3e-icon>Photos</m3e-tab>
20
- * <m3e-tab for="audio"><m3e-icon slot="icon" name="music_note"></m3e-icon>Audio</m3e-tab>
21
- * <m3e-tab-panel id="videos">Videos</m3e-tab-panel>
22
- * <m3e-tab-panel id="photos">Photos</m3e-tab-panel>
23
- * <m3e-tab-panel id="audio">Audio</m3e-tab-panel>
24
- * </m3e-tabs>
25
- * ```
26
- *
27
- * @tag m3e-tab
28
- *
29
- * @slot - Renders the label of the tab.
30
- * @slot icon - Renders an icon before the tab's label.
31
- *
32
- * @attr disabled - Whether the element is disabled.
33
- * @attr for - The query selector used to specify the element related to this element.
34
- * @attr selected - Whether the element is selected.
35
- *
36
- * @cssprop --m3e-tab-font-size - Font size for tab label.
37
- * @cssprop --m3e-tab-font-weight - Font weight for tab label.
38
- * @cssprop --m3e-tab-line-height - Line height for tab label.
39
- * @cssprop --m3e-tab-tracking - Letter spacing for tab label.
40
- * @cssprop --m3e-tab-padding-start - Padding on the inline start of the tab.
41
- * @cssprop --m3e-tab-padding-end - Padding on the inline end of the tab.
42
- * @cssprop --m3e-tab-focus-ring-shape - Border radius for the focus ring.
43
- * @cssprop --m3e-tab-selected-color - Text color for selected tab.
44
- * @cssprop --m3e-tab-selected-container-hover-color - Hover state-layer color for selected tab.
45
- * @cssprop --m3e-tab-selected-container-focus-color - Focus state-layer color for selected tab.
46
- * @cssprop --m3e-tab-selected-ripple-color - Ripple color for selected tab.
47
- * @cssprop --m3e-tab-unselected-color - Text color for unselected tab.
48
- * @cssprop --m3e-tab-unselected-container-hover-color - Hover state-layer color for unselected tab.
49
- * @cssprop --m3e-tab-unselected-container-focus-color - Focus state-layer color for unselected tab.
50
- * @cssprop --m3e-tab-unselected-ripple-color - Ripple color for unselected tab.
51
- * @cssprop --m3e-tab-disabled-color - Text color for disabled tab.
52
- * @cssprop --m3e-tab-disabled-opacity - Text opacity for disabled tab.
53
- * @cssprop --m3e-tab-spacing - Column gap between icon and label.
54
- * @cssprop --m3e-tab-icon-size - Font size for slotted icon.
55
- */
56
- export declare class M3eTabElement extends M3eTabElement_base {
57
- #private;
58
- /** The styles of the element. */
59
- static styles: CSSResultGroup;
60
- /** @private */ private static __nextId;
61
- /** @private */ private readonly _focusRing?;
62
- /** @private */ private readonly _stateLayer?;
63
- /** @private */ private readonly _ripple?;
64
- /** @internal A reference to the element that wraps the label of the tab. */
65
- readonly label: HTMLElement;
66
- /** @inheritdoc */
67
- attach(control: HTMLElement): void;
68
- /** @inheritdoc */
69
- detach(): void;
70
- /** @inheritdoc */
71
- connectedCallback(): void;
72
- /** @inheritdoc */
73
- disconnectedCallback(): void;
74
- /** @inheritdoc */
75
- protected firstUpdated(_changedProperties: PropertyValues<this>): void;
76
- /** @inheritdoc */
77
- protected update(changedProperties: PropertyValues<this>): void;
78
- /** @inheritdoc */
79
- protected render(): unknown;
80
- }
81
- declare global {
82
- interface HTMLElementTagNameMap {
83
- "m3e-tab": M3eTabElement;
84
- }
85
- }
86
- export {};
87
- //# sourceMappingURL=TabElement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabElement.d.ts","sourceRoot":"","sources":["../../src/TabElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;;AAmB5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBACa,aAAc,SAAQ,kBAElC;;IACC,iCAAiC;IACjC,OAAgB,MAAM,EAAE,cAAc,CAkFpC;IAEF,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAK;IAE5C,eAAe,CAAuB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAsB;IACxF,eAAe,CAAwB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAuB;IAC3F,eAAe,CAAmB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAmB;IAG9E,4EAA4E;IAC3D,QAAQ,CAAC,KAAK,EAAG,WAAW,CAAC;IAE9C,kBAAkB;IACT,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAO3C,kBAAkB;IACT,MAAM,IAAI,IAAI;IAQvB,kBAAkB;IACT,iBAAiB,IAAI,IAAI;IAKlC,kBAAkB;IACT,oBAAoB,IAAI,IAAI;IAKrC,kBAAkB;cACC,YAAY,CAAC,kBAAkB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAK/E,kBAAkB;cACC,MAAM,CAAC,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAQxE,kBAAkB;cACC,MAAM,IAAI,OAAO;CA6BrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,SAAS,EAAE,aAAa,CAAC;KAC1B;CACF"}
@@ -1,3 +0,0 @@
1
- /** Specifies the possible positions of a tab header. */
2
- export type TabHeaderPosition = "before" | "after";
3
- //# sourceMappingURL=TabHeaderPosition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabHeaderPosition.d.ts","sourceRoot":"","sources":["../../src/TabHeaderPosition.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG,OAAO,CAAC"}
@@ -1,46 +0,0 @@
1
- import { CSSResultGroup, LitElement } from "lit";
2
- declare const M3eTabPanelElement_base: import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor & typeof LitElement;
3
- /**
4
- * @summary
5
- * A panel presented for a tab.
6
- *
7
- * @description
8
- * The `m3e-tab-panel` component represents the content region associated with a selected tab.
9
- * It is conditionally rendered based on tab selection and provides a structured surface for
10
- * displaying contextual information, media, or interactive elements. Panels are linked to their
11
- * corresponding tabs via the `for` attribute on `m3e-tab`, enabling declarative control and
12
- * accessible navigation consistent with Material 3 guidance.
13
- *
14
- * @example
15
- * The following example illustrates using the `m3e-tabs`, `m3e-tab`, and `m3e-tab-panel` components to present
16
- * secondary tabs.
17
- * ```html
18
- * <m3e-tabs>
19
- * <m3e-tab selected for="videos"><m3e-icon slot="icon" name="videocam"></m3e-icon>Video</m3e-tab>
20
- * <m3e-tab for="photos"><m3e-icon slot="icon" name="photo"></m3e-icon>Photos</m3e-tab>
21
- * <m3e-tab for="audio"><m3e-icon slot="icon" name="music_note"></m3e-icon>Audio</m3e-tab>
22
- * <m3e-tab-panel id="videos">Videos</m3e-tab-panel>
23
- * <m3e-tab-panel id="photos">Photos</m3e-tab-panel>
24
- * <m3e-tab-panel id="audio">Audio</m3e-tab-panel>
25
- * </m3e-tabs>
26
- * ```
27
- *
28
- * @tag m3e-tab-panel
29
- *
30
- * @slot - Renders the content of the panel.
31
- */
32
- export declare class M3eTabPanelElement extends M3eTabPanelElement_base {
33
- /** The styles of the element. */
34
- static styles: CSSResultGroup;
35
- /** @inheritdoc */
36
- connectedCallback(): void;
37
- /** @inheritdoc */
38
- protected render(): unknown;
39
- }
40
- declare global {
41
- interface HTMLElementTagNameMap {
42
- "m3e-tab-panel": M3eTabPanelElement;
43
- }
44
- }
45
- export {};
46
- //# sourceMappingURL=TabPanelElement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabPanelElement.d.ts","sourceRoot":"","sources":["../../src/TabPanelElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAQ,UAAU,EAAE,MAAM,KAAK,CAAC;;AAK5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBACa,kBAAmB,SAAQ,uBAA4B;IAClE,iCAAiC;IACjC,OAAgB,MAAM,EAAE,cAAc,CAOpC;IAEF,kBAAkB;IACT,iBAAiB,IAAI,IAAI;IAKlC,kBAAkB;cACC,MAAM,IAAI,OAAO;CAGrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,eAAe,EAAE,kBAAkB,CAAC;KACrC;CACF"}
@@ -1,3 +0,0 @@
1
- /** Specifies the possible appearance variants of a tab. */
2
- export type TabVariant = "primary" | "secondary";
3
- //# sourceMappingURL=TabVariant.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabVariant.d.ts","sourceRoot":"","sources":["../../src/TabVariant.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC"}
@@ -1,117 +0,0 @@
1
- import { CSSResultGroup, LitElement, PropertyValues } from "lit";
2
- import { SelectionManager, selectionManager } from "@m3e/core/a11y";
3
- import { TabVariant } from "./TabVariant";
4
- import { M3eTabElement } from "./TabElement";
5
- import { TabHeaderPosition } from "./TabHeaderPosition";
6
- declare const M3eTabsElement_base: import("node_modules/@m3e/core/dist/src/shared/mixins/Constructor").Constructor<import("@m3e/core").AttachInternalsMixin> & typeof LitElement;
7
- /**
8
- * @summary
9
- * Organizes content into separate views where only one view can be visible at a time.
10
- *
11
- * @description
12
- * The `m3e-tabs` component provides a structured navigation surface for organizing content into distinct views,
13
- * where only one view is visible at a time. It supports scrollable tab headers with optional pagination,
14
- * accessible labeling for navigation controls, and configurable header positioning to suit various layout
15
- * contexts. Two visual variants are available: `primary`, which emphasizes active indicators and shape styling
16
- * for prominent navigation, and `secondary`, which offers a more subtle presentation with reduced indicator
17
- * thickness. Stretch behavior allows tabs to expand and align rhythmically within their container, consistent
18
- * with Material 3 guidance.
19
- *
20
- * @example
21
- * The following example illustrates using the `m3e-tabs`, `m3e-tab`, and `m3e-tab-panel` components to present
22
- * secondary tabs.
23
- * ```html
24
- * <m3e-tabs>
25
- * <m3e-tab selected for="videos"><m3e-icon slot="icon" name="videocam"></m3e-icon>Video</m3e-tab>
26
- * <m3e-tab for="photos"><m3e-icon slot="icon" name="photo"></m3e-icon>Photos</m3e-tab>
27
- * <m3e-tab for="audio"><m3e-icon slot="icon" name="music_note"></m3e-icon>Audio</m3e-tab>
28
- * <m3e-tab-panel id="videos">Videos</m3e-tab-panel>
29
- * <m3e-tab-panel id="photos">Photos</m3e-tab-panel>
30
- * <m3e-tab-panel id="audio">Audio</m3e-tab-panel>
31
- * </m3e-tabs>
32
- * ```
33
- *
34
- * @tag m3e-tabs
35
- *
36
- * @slot - Renders the tabs.
37
- * @slot panel - Renders the panels of the tabs.
38
- * @slot next-icon - Renders the icon to present for the next button used to paginate.
39
- * @slot prev-icon - Renders the icon to present for the previous button used to paginate.
40
- *
41
- * @attr disable-pagination - Whether scroll buttons are disabled.
42
- * @attr header-position - The position of the tab headers.
43
- * @attr next-page-label - The accessible label given to the button used to move to the previous page.
44
- * @attr previous-page-label - The accessible label given to the button used to move to the next page.
45
- * @attr stretch - Whether tabs are stretched to fill the header.
46
- * @attr variant - The appearance variant of the tabs.
47
- *
48
- * @fires change - Emitted when the selected tab changes.
49
- *
50
- * @cssprop --m3e-tabs-paginator-button-icon-size - Overrides the icon size for paginator buttons.
51
- * @cssprop --m3e-tabs-active-indicator-color - Color of the active tab indicator.
52
- * @cssprop --m3e-tabs-primary-before-active-indicator-shape - Border radius for active indicator when header is before and variant is primary.
53
- * @cssprop --m3e-tabs-primary-after-active-indicator-shape - Border radius for active indicator when header is after and variant is primary.
54
- * @cssprop --m3e-tabs-primary-active-indicator-inset - Inset for primary variant's active indicator.
55
- * @cssprop --m3e-tabs-primary-active-indicator-thickness - Thickness for primary variant's active indicator.
56
- * @cssprop --m3e-tabs-secondary-active-indicator-thickness - Thickness for secondary variant's active indicator.
57
- */
58
- export declare class M3eTabsElement extends M3eTabsElement_base {
59
- #private;
60
- /** The styles of the element. */
61
- static styles: CSSResultGroup;
62
- /** @private */ private readonly _tablist;
63
- /** @private */ _selectedIndex: number | null;
64
- /** @internal */
65
- readonly [selectionManager]: SelectionManager<M3eTabElement>;
66
- constructor();
67
- /**
68
- * Whether scroll buttons are disabled.
69
- * @default false
70
- */
71
- disablePagination: boolean;
72
- /**
73
- * The position of the tab headers.
74
- * @default "before"
75
- */
76
- headerPosition: TabHeaderPosition;
77
- /**
78
- * The appearance variant of the tabs.
79
- * @default "secondary"
80
- */
81
- variant: TabVariant;
82
- /**
83
- * Whether tabs are stretched to fill the header.
84
- * @default false
85
- */
86
- stretch: boolean;
87
- /**
88
- * The accessible label given to the button used to move to the previous page.
89
- * @default "Previous page"
90
- */
91
- previousPageLabel: string;
92
- /**
93
- * The accessible label given to the button used to move to the next page.
94
- * @default "Next page"
95
- */
96
- nextPageLabel: string;
97
- /** The tabs. */
98
- get tabs(): readonly M3eTabElement[];
99
- /** The selected tab. */
100
- get selectedTab(): M3eTabElement | null;
101
- /** The zero-based index of the selected tab. */
102
- get selectedIndex(): number;
103
- set selectedIndex(value: number);
104
- /** @inheritdoc */
105
- connectedCallback(): void;
106
- /** @inheritdoc */
107
- protected updated(_changedProperties: PropertyValues<this>): void;
108
- /** @inheritdoc */
109
- protected render(): unknown;
110
- }
111
- declare global {
112
- interface HTMLElementTagNameMap {
113
- "m3e-tabs": M3eTabsElement;
114
- }
115
- }
116
- export {};
117
- //# sourceMappingURL=TabsElement.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabsElement.d.ts","sourceRoot":"","sources":["../../src/TabsElement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAQ,UAAU,EAAW,cAAc,EAAa,MAAM,KAAK,CAAC;AAIhG,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;;AAIxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,qBACa,cAAe,SAAQ,mBAA2B;;IAC7D,iCAAiC;IACjC,OAAgB,MAAM,EAAE,cAAc,CA0GpC;IAEF,eAAe,CAAoB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAe;IAC3E,eAAe,CAAU,cAAc,EAAE,MAAM,GAAG,IAAI,CAAQ;IAE9D,gBAAgB;IAChB,QAAQ,CAAC,CAAC,gBAAgB,CAAC,kCAGb;;IAad;;;OAGG;IAC2D,iBAAiB,UAAS;IAExF;;;OAGG;IACwD,cAAc,EAAE,iBAAiB,CAAY;IAExG;;;OAGG;IAC0B,OAAO,EAAE,UAAU,CAAe;IAE/D;;;OAGG;IACyC,OAAO,UAAS;IAE5D;;;OAGG;IAC6C,iBAAiB,SAAmB;IAEpF;;;OAGG;IACyC,aAAa,SAAe;IAExE,gBAAgB;IAChB,IAAI,IAAI,IAAI,SAAS,aAAa,EAAE,CAEnC;IAED,wBAAwB;IACxB,IAAI,WAAW,IAAI,aAAa,GAAG,IAAI,CAEtC;IAED,gDAAgD;IAChD,IAAI,aAAa,IAAI,MAAM,CAE1B;IACD,IAAI,aAAa,CAAC,KAAK,EAAE,MAAM,EAS9B;IAED,kBAAkB;IACT,iBAAiB,IAAI,IAAI;IAKlC,kBAAkB;cACC,OAAO,CAAC,kBAAkB,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,IAAI;IAQ1E,kBAAkB;cACC,MAAM,IAAI,OAAO;CA2GrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,cAAc,CAAC;KAC5B;CACF"}
@@ -1,6 +0,0 @@
1
- export * from "./TabElement";
2
- export * from "./TabHeaderPosition";
3
- export * from "./TabPanelElement";
4
- export * from "./TabVariant";
5
- export * from "./TabsElement";
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
package/eslint.config.mjs DELETED
@@ -1,13 +0,0 @@
1
- import eslint from "@eslint/js";
2
- import tseslint from "typescript-eslint";
3
- import { fileURLToPath } from "url";
4
- import { dirname } from "path";
5
-
6
- export default tseslint.config(eslint.configs.recommended, tseslint.configs.recommended, {
7
- languageOptions: {
8
- parserOptions: {
9
- project: true,
10
- tsconfigRootDir: dirname(fileURLToPath(import.meta.url)),
11
- },
12
- },
13
- });
package/rollup.config.js DELETED
@@ -1,32 +0,0 @@
1
- import resolve from "@rollup/plugin-node-resolve";
2
- import terser from "@rollup/plugin-terser";
3
- import typescript from "@rollup/plugin-typescript";
4
-
5
- const banner = `/**
6
- * @license MIT
7
- * Copyright (c) 2025 matraic
8
- * See LICENSE file in the project root for full license text.
9
- */`;
10
-
11
- export default [
12
- {
13
- input: "src/index.ts",
14
- output: [
15
- {
16
- file: "dist/index.js",
17
- format: "esm",
18
- sourcemap: true,
19
- banner: banner,
20
- },
21
- {
22
- file: "dist/index.min.js",
23
- format: "esm",
24
- sourcemap: true,
25
- banner: banner,
26
- plugins: [terser({ mangle: true })],
27
- },
28
- ],
29
- external: ["@m3e/core", "@m3e/core/a11y", "@m3e/slide-group", "lit"],
30
- plugins: [resolve(), typescript()],
31
- },
32
- ];
package/src/TabElement.ts DELETED
@@ -1,252 +0,0 @@
1
- import { css, CSSResultGroup, html, LitElement, PropertyValues } from "lit";
2
- import { customElement, query } from "lit/decorators.js";
3
-
4
- import {
5
- AttachInternals,
6
- DesignToken,
7
- Disabled,
8
- Focusable,
9
- HtmlFor,
10
- KeyboardClick,
11
- M3eFocusRingElement,
12
- M3eRippleElement,
13
- M3eStateLayerElement,
14
- Role,
15
- Selected,
16
- } from "@m3e/core";
17
-
18
- import { addAriaReferencedId, removeAriaReferencedId, selectionManager } from "@m3e/core/a11y";
19
-
20
- /**
21
- * @summary
22
- * An interactive element that, when activated, presents an associated tab panel.
23
- *
24
- * @description
25
- * The `m3e-tab` component is an interactive control used within a tabbed interface to activate and
26
- * reveal an associated tab panel. It supports accessible labeling, optional iconography, and selection
27
- * state styling consistent with Material 3 guidance. Tabs may be disabled, selected, or linked to a
28
- * specific panel via the `for` attribute, enabling declarative control and semantic clarity.
29
- *
30
- * @example
31
- * The following example illustrates using the `m3e-tabs`, `m3e-tab`, and `m3e-tab-panel` components to present
32
- * secondary tabs.
33
- * ```html
34
- * <m3e-tabs>
35
- * <m3e-tab selected for="videos"><m3e-icon slot="icon" name="videocam"></m3e-icon>Video</m3e-tab>
36
- * <m3e-tab for="photos"><m3e-icon slot="icon" name="photo"></m3e-icon>Photos</m3e-tab>
37
- * <m3e-tab for="audio"><m3e-icon slot="icon" name="music_note"></m3e-icon>Audio</m3e-tab>
38
- * <m3e-tab-panel id="videos">Videos</m3e-tab-panel>
39
- * <m3e-tab-panel id="photos">Photos</m3e-tab-panel>
40
- * <m3e-tab-panel id="audio">Audio</m3e-tab-panel>
41
- * </m3e-tabs>
42
- * ```
43
- *
44
- * @tag m3e-tab
45
- *
46
- * @slot - Renders the label of the tab.
47
- * @slot icon - Renders an icon before the tab's label.
48
- *
49
- * @attr disabled - Whether the element is disabled.
50
- * @attr for - The query selector used to specify the element related to this element.
51
- * @attr selected - Whether the element is selected.
52
- *
53
- * @cssprop --m3e-tab-font-size - Font size for tab label.
54
- * @cssprop --m3e-tab-font-weight - Font weight for tab label.
55
- * @cssprop --m3e-tab-line-height - Line height for tab label.
56
- * @cssprop --m3e-tab-tracking - Letter spacing for tab label.
57
- * @cssprop --m3e-tab-padding-start - Padding on the inline start of the tab.
58
- * @cssprop --m3e-tab-padding-end - Padding on the inline end of the tab.
59
- * @cssprop --m3e-tab-focus-ring-shape - Border radius for the focus ring.
60
- * @cssprop --m3e-tab-selected-color - Text color for selected tab.
61
- * @cssprop --m3e-tab-selected-container-hover-color - Hover state-layer color for selected tab.
62
- * @cssprop --m3e-tab-selected-container-focus-color - Focus state-layer color for selected tab.
63
- * @cssprop --m3e-tab-selected-ripple-color - Ripple color for selected tab.
64
- * @cssprop --m3e-tab-unselected-color - Text color for unselected tab.
65
- * @cssprop --m3e-tab-unselected-container-hover-color - Hover state-layer color for unselected tab.
66
- * @cssprop --m3e-tab-unselected-container-focus-color - Focus state-layer color for unselected tab.
67
- * @cssprop --m3e-tab-unselected-ripple-color - Ripple color for unselected tab.
68
- * @cssprop --m3e-tab-disabled-color - Text color for disabled tab.
69
- * @cssprop --m3e-tab-disabled-opacity - Text opacity for disabled tab.
70
- * @cssprop --m3e-tab-spacing - Column gap between icon and label.
71
- * @cssprop --m3e-tab-icon-size - Font size for slotted icon.
72
- */
73
- @customElement("m3e-tab")
74
- export class M3eTabElement extends Selected(
75
- HtmlFor(KeyboardClick(Focusable(Disabled(AttachInternals(Role(LitElement, "tab"), true)))))
76
- ) {
77
- /** The styles of the element. */
78
- static override styles: CSSResultGroup = css`
79
- :host {
80
- display: inline-block;
81
- outline: none;
82
- user-select: none;
83
- height: calc(var(--_tab-height) + ${DesignToken.density.calc(-3)});
84
- font-size: var(--m3e-tab-font-size, ${DesignToken.typescale.standard.title.small.fontSize});
85
- font-weight: var(--m3e-tab-font-weight, ${DesignToken.typescale.standard.title.small.fontWeight});
86
- line-height: var(--m3e-tab-line-height, ${DesignToken.typescale.standard.title.small.lineHeight});
87
- letter-spacing: var(--m3e-tab-tracking, ${DesignToken.typescale.standard.title.small.tracking});
88
- flex-grow: var(--_tab-grow);
89
- }
90
- :host(:not(:disabled)) {
91
- cursor: pointer;
92
- }
93
- .base {
94
- box-sizing: border-box;
95
- vertical-align: middle;
96
- display: inline-flex;
97
- align-items: center;
98
- justify-content: center;
99
- position: relative;
100
- width: 100%;
101
- height: 100%;
102
- padding-inline-start: var(--m3e-tab-padding-start, 1.5rem);
103
- padding-inline-end: var(--m3e-tab-padding-end, 1.5rem);
104
- }
105
- .touch {
106
- position: absolute;
107
- height: 3rem;
108
- left: 0;
109
- right: 0;
110
- }
111
- .focus-ring {
112
- border-radius: var(--m3e-tab-focus-ring-shape, ${DesignToken.shape.corner.large});
113
- }
114
- :host([selected]:focus-within) .focus-ring {
115
- top: var(--_tab-focus-ring-top-offset, 0);
116
- bottom: var(--_tab-focus-ring-bottom-offset, 0);
117
- }
118
- :host([selected]:not(:disabled)) .base {
119
- color: var(--m3e-tab-selected-color, ${DesignToken.color.primary});
120
- --m3e-state-layer-hover-color: var(--m3e-tab-selected-container-hover-color, ${DesignToken.color.primary});
121
- --m3e-state-layer-focus-color: var(--m3e-tab-selected-container-focus-color, ${DesignToken.color.primary});
122
- --m3e-ripple-color: var(--m3e-tab-selected-ripple-color, ${DesignToken.color.primary});
123
- }
124
- :host(:not([selected]):not(:disabled)) .base {
125
- color: var(--m3e-tab-unselected-color, ${DesignToken.color.onSurface});
126
- --m3e-state-layer-hover-color: var(--m3e-tab-unselected-container-hover-color, ${DesignToken.color.onSurface});
127
- --m3e-state-layer-focus-color: var(--m3e-tab-unselected-container-focus-color, ${DesignToken.color.onSurface});
128
- --m3e-ripple-color: var(--m3e-tab-unselected-ripple-color, ${DesignToken.color.onSurface});
129
- }
130
- :host(:disabled) .base {
131
- color: color-mix(
132
- in srgb,
133
- var(--m3e-tab-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-tab-disabled-opacity, 38%),
134
- transparent
135
- );
136
- }
137
- .wrapper {
138
- display: inline-flex;
139
- align-items: center;
140
- white-space: nowrap;
141
- flex-direction: var(--_tab-direction);
142
- justify-content: center;
143
- column-gap: var(--m3e-tab-spacing, 0.5rem);
144
- }
145
- ::slotted([slot="icon"]) {
146
- width: 1em;
147
- font-size: var(--m3e-tab-icon-size, 1.5rem) !important;
148
- }
149
- @media (forced-colors: active) {
150
- :host([selected]:not(:disabled)) .base {
151
- color: ButtonText;
152
- }
153
- :host(:not([selected]):not(:disabled)) .base {
154
- color: ButtonText;
155
- }
156
- :host(:disabled) .base {
157
- color: GrayText;
158
- }
159
- }
160
- `;
161
-
162
- /** @private */ private static __nextId = 0;
163
-
164
- /** @private */ @query(".focus-ring") private readonly _focusRing?: M3eFocusRingElement;
165
- /** @private */ @query(".state-layer") private readonly _stateLayer?: M3eStateLayerElement;
166
- /** @private */ @query(".ripple") private readonly _ripple?: M3eRippleElement;
167
- /** @private */ readonly #clickHandler = (e: Event) => this.#handleClick(e);
168
-
169
- /** @internal A reference to the element that wraps the label of the tab. */
170
- @query(".label") readonly label!: HTMLElement;
171
-
172
- /** @inheritdoc */
173
- override attach(control: HTMLElement): void {
174
- super.attach(control);
175
-
176
- control.id = control.id || `m3e-tab-panel-${M3eTabElement.__nextId++}`;
177
- addAriaReferencedId(this, "aria-controls", control.id);
178
- }
179
-
180
- /** @inheritdoc */
181
- override detach(): void {
182
- if (this.control && this.control.id) {
183
- removeAriaReferencedId(this, "aria-controls", this.control.id);
184
- }
185
-
186
- super.detach();
187
- }
188
-
189
- /** @inheritdoc */
190
- override connectedCallback(): void {
191
- super.connectedCallback();
192
- this.addEventListener("click", this.#clickHandler);
193
- }
194
-
195
- /** @inheritdoc */
196
- override disconnectedCallback(): void {
197
- super.disconnectedCallback();
198
- this.removeEventListener("click", this.#clickHandler);
199
- }
200
-
201
- /** @inheritdoc */
202
- protected override firstUpdated(_changedProperties: PropertyValues<this>): void {
203
- super.firstUpdated(_changedProperties);
204
- [this._focusRing, this._stateLayer, this._ripple].forEach((x) => x?.attach(this));
205
- }
206
-
207
- /** @inheritdoc */
208
- protected override update(changedProperties: PropertyValues<this>): void {
209
- super.update(changedProperties);
210
-
211
- if (changedProperties.has("selected")) {
212
- this.closest("m3e-tabs")?.[selectionManager].notifySelectionChange(this);
213
- }
214
- }
215
-
216
- /** @inheritdoc */
217
- protected override render(): unknown {
218
- return html`<div class="base">
219
- <m3e-state-layer class="state-layer" ?disabled="${this.disabled}"></m3e-state-layer>
220
- <m3e-focus-ring class="focus-ring" inward ?disabled="${this.disabled}"></m3e-focus-ring>
221
- <m3e-ripple class="ripple" ?disabled="${this.disabled}"></m3e-ripple>
222
- <div class="touch" aria-hidden="true"></div>
223
- <div class="wrapper">
224
- <slot name="icon" aria-hidden="true"></slot><span class="label"><slot></slot></span>
225
- </div>
226
- </div>`;
227
- }
228
-
229
- /** @private */
230
- #handleClick(e: Event): void {
231
- if (this.disabled) {
232
- e.preventDefault();
233
- e.stopImmediatePropagation();
234
- }
235
-
236
- if (e.defaultPrevented || this.selected) return;
237
-
238
- this.selected = true;
239
- if (this.dispatchEvent(new Event("input", { bubbles: true, composed: true, cancelable: true }))) {
240
- this.closest("m3e-tabs")?.[selectionManager].notifySelectionChange(this);
241
- this.dispatchEvent(new Event("change", { bubbles: true }));
242
- } else {
243
- this.selected = false;
244
- }
245
- }
246
- }
247
-
248
- declare global {
249
- interface HTMLElementTagNameMap {
250
- "m3e-tab": M3eTabElement;
251
- }
252
- }
@@ -1,2 +0,0 @@
1
- /** Specifies the possible positions of a tab header. */
2
- export type TabHeaderPosition = "before" | "after";
@@ -1,63 +0,0 @@
1
- import { css, CSSResultGroup, html, LitElement } from "lit";
2
- import { customElement } from "lit/decorators.js";
3
-
4
- import { DesignToken, Role } from "@m3e/core";
5
-
6
- /**
7
- * @summary
8
- * A panel presented for a tab.
9
- *
10
- * @description
11
- * The `m3e-tab-panel` component represents the content region associated with a selected tab.
12
- * It is conditionally rendered based on tab selection and provides a structured surface for
13
- * displaying contextual information, media, or interactive elements. Panels are linked to their
14
- * corresponding tabs via the `for` attribute on `m3e-tab`, enabling declarative control and
15
- * accessible navigation consistent with Material 3 guidance.
16
- *
17
- * @example
18
- * The following example illustrates using the `m3e-tabs`, `m3e-tab`, and `m3e-tab-panel` components to present
19
- * secondary tabs.
20
- * ```html
21
- * <m3e-tabs>
22
- * <m3e-tab selected for="videos"><m3e-icon slot="icon" name="videocam"></m3e-icon>Video</m3e-tab>
23
- * <m3e-tab for="photos"><m3e-icon slot="icon" name="photo"></m3e-icon>Photos</m3e-tab>
24
- * <m3e-tab for="audio"><m3e-icon slot="icon" name="music_note"></m3e-icon>Audio</m3e-tab>
25
- * <m3e-tab-panel id="videos">Videos</m3e-tab-panel>
26
- * <m3e-tab-panel id="photos">Photos</m3e-tab-panel>
27
- * <m3e-tab-panel id="audio">Audio</m3e-tab-panel>
28
- * </m3e-tabs>
29
- * ```
30
- *
31
- * @tag m3e-tab-panel
32
- *
33
- * @slot - Renders the content of the panel.
34
- */
35
- @customElement("m3e-tab-panel")
36
- export class M3eTabPanelElement extends Role(LitElement, "tabpanel") {
37
- /** The styles of the element. */
38
- static override styles: CSSResultGroup = css`
39
- :host {
40
- display: block;
41
- overflow-y: auto;
42
- scrollbar-width: ${DesignToken.scrollbar.width};
43
- scrollbar-color: ${DesignToken.scrollbar.color};
44
- }
45
- `;
46
-
47
- /** @inheritdoc */
48
- override connectedCallback(): void {
49
- super.connectedCallback();
50
- this.slot = "panel";
51
- }
52
-
53
- /** @inheritdoc */
54
- protected override render(): unknown {
55
- return html`<slot></slot>`;
56
- }
57
- }
58
-
59
- declare global {
60
- interface HTMLElementTagNameMap {
61
- "m3e-tab-panel": M3eTabPanelElement;
62
- }
63
- }
package/src/TabVariant.ts DELETED
@@ -1,2 +0,0 @@
1
- /** Specifies the possible appearance variants of a tab. */
2
- export type TabVariant = "primary" | "secondary";