@moni-labs/moni-ui 0.2.0 → 0.3.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/README.md +52 -194
- package/custom-elements.json +1636 -350
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +6 -0
- package/dist/components/_base/field-styles.d.ts +51 -16
- package/dist/components/_base/field-styles.d.ts.map +1 -1
- package/dist/components/_base/field-styles.js +164 -36
- package/dist/components/_base/index.d.ts +25 -0
- package/dist/components/_base/index.d.ts.map +1 -1
- package/dist/components/_base/index.js +25 -0
- package/dist/components/_base/interaction-styles.d.ts +39 -12
- package/dist/components/_base/interaction-styles.d.ts.map +1 -1
- package/dist/components/_base/interaction-styles.js +85 -33
- package/dist/components/_base/moni-element.d.ts +43 -8
- package/dist/components/_base/moni-element.d.ts.map +1 -1
- package/dist/components/_base/moni-element.js +43 -8
- package/dist/components/_base/shared-styles.d.ts +41 -17
- package/dist/components/_base/shared-styles.d.ts.map +1 -1
- package/dist/components/_base/shared-styles.js +113 -21
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -0
- package/dist/components/loading-shapes.d.ts +6 -0
- package/dist/components/loading-shapes.d.ts.map +1 -1
- package/dist/components/loading-shapes.js +6 -0
- package/dist/components/moni-app-bar.d.ts +128 -33
- package/dist/components/moni-app-bar.d.ts.map +1 -1
- package/dist/components/moni-app-bar.js +121 -26
- package/dist/components/moni-badge.d.ts +122 -14
- package/dist/components/moni-badge.d.ts.map +1 -1
- package/dist/components/moni-badge.js +122 -14
- package/dist/components/moni-bottom-sheet.d.ts +120 -15
- package/dist/components/moni-bottom-sheet.d.ts.map +1 -1
- package/dist/components/moni-bottom-sheet.js +116 -12
- package/dist/components/moni-button-group.d.ts +53 -27
- package/dist/components/moni-button-group.d.ts.map +1 -1
- package/dist/components/moni-button-group.js +49 -23
- package/dist/components/moni-button-segment.d.ts +28 -8
- package/dist/components/moni-button-segment.d.ts.map +1 -1
- package/dist/components/moni-button-segment.js +27 -7
- package/dist/components/moni-button.d.ts +51 -32
- package/dist/components/moni-button.d.ts.map +1 -1
- package/dist/components/moni-button.js +50 -31
- package/dist/components/moni-card.d.ts +91 -31
- package/dist/components/moni-card.d.ts.map +1 -1
- package/dist/components/moni-card.js +86 -26
- package/dist/components/moni-carousel.d.ts +67 -17
- package/dist/components/moni-carousel.d.ts.map +1 -1
- package/dist/components/moni-carousel.js +59 -16
- package/dist/components/moni-checkbox.d.ts +122 -17
- package/dist/components/moni-checkbox.d.ts.map +1 -1
- package/dist/components/moni-checkbox.js +118 -14
- package/dist/components/moni-chip.d.ts +56 -30
- package/dist/components/moni-chip.d.ts.map +1 -1
- package/dist/components/moni-chip.js +51 -25
- package/dist/components/moni-color-field.d.ts +44 -6
- package/dist/components/moni-color-field.d.ts.map +1 -1
- package/dist/components/moni-color-field.js +43 -5
- package/dist/components/moni-context-menu.d.ts +44 -22
- package/dist/components/moni-context-menu.d.ts.map +1 -1
- package/dist/components/moni-context-menu.js +43 -21
- package/dist/components/moni-dialog.d.ts +107 -15
- package/dist/components/moni-dialog.d.ts.map +1 -1
- package/dist/components/moni-dialog.js +105 -14
- package/dist/components/moni-divider.d.ts +50 -15
- package/dist/components/moni-divider.d.ts.map +1 -1
- package/dist/components/moni-divider.js +49 -14
- package/dist/components/moni-expansion.d.ts +44 -8
- package/dist/components/moni-expansion.d.ts.map +1 -1
- package/dist/components/moni-expansion.js +43 -7
- package/dist/components/moni-fab-menu.d.ts +39 -20
- package/dist/components/moni-fab-menu.d.ts.map +1 -1
- package/dist/components/moni-fab-menu.js +38 -19
- package/dist/components/moni-fab.d.ts +49 -23
- package/dist/components/moni-fab.d.ts.map +1 -1
- package/dist/components/moni-fab.js +46 -20
- package/dist/components/moni-file-field.d.ts +54 -14
- package/dist/components/moni-file-field.d.ts.map +1 -1
- package/dist/components/moni-file-field.js +53 -13
- package/dist/components/moni-icon.d.ts +78 -11
- package/dist/components/moni-icon.d.ts.map +1 -1
- package/dist/components/moni-icon.js +77 -10
- package/dist/components/moni-list-item.d.ts +61 -30
- package/dist/components/moni-list-item.d.ts.map +1 -1
- package/dist/components/moni-list-item.js +55 -24
- package/dist/components/moni-list.d.ts +37 -13
- package/dist/components/moni-list.d.ts.map +1 -1
- package/dist/components/moni-list.js +36 -12
- package/dist/components/moni-loading-indicator.d.ts +38 -11
- package/dist/components/moni-loading-indicator.d.ts.map +1 -1
- package/dist/components/moni-loading-indicator.js +37 -10
- package/dist/components/moni-menu-item.d.ts +31 -8
- package/dist/components/moni-menu-item.d.ts.map +1 -1
- package/dist/components/moni-menu-item.js +30 -7
- package/dist/components/moni-menu.d.ts +58 -33
- package/dist/components/moni-menu.d.ts.map +1 -1
- package/dist/components/moni-menu.js +51 -26
- package/dist/components/moni-morph-modal.d.ts +7 -1
- package/dist/components/moni-morph-modal.d.ts.map +1 -1
- package/dist/components/moni-morph-modal.js +46 -24
- package/dist/components/moni-nav-item.d.ts +50 -10
- package/dist/components/moni-nav-item.d.ts.map +1 -1
- package/dist/components/moni-nav-item.js +48 -8
- package/dist/components/moni-nav.d.ts +57 -22
- package/dist/components/moni-nav.d.ts.map +1 -1
- package/dist/components/moni-nav.js +53 -18
- package/dist/components/moni-progress.d.ts +108 -20
- package/dist/components/moni-progress.d.ts.map +1 -1
- package/dist/components/moni-progress.js +104 -16
- package/dist/components/moni-radio.d.ts +106 -14
- package/dist/components/moni-radio.d.ts.map +1 -1
- package/dist/components/moni-radio.js +104 -13
- package/dist/components/moni-ripple.d.ts +121 -10
- package/dist/components/moni-ripple.d.ts.map +1 -1
- package/dist/components/moni-ripple.js +120 -9
- package/dist/components/moni-segmented-button.d.ts +31 -11
- package/dist/components/moni-segmented-button.d.ts.map +1 -1
- package/dist/components/moni-segmented-button.js +30 -10
- package/dist/components/moni-select-option.d.ts +43 -9
- package/dist/components/moni-select-option.d.ts.map +1 -1
- package/dist/components/moni-select-option.js +41 -7
- package/dist/components/moni-select.d.ts +59 -2
- package/dist/components/moni-select.d.ts.map +1 -1
- package/dist/components/moni-select.js +58 -1
- package/dist/components/moni-shape.d.ts +1 -1
- package/dist/components/moni-side-sheet.d.ts +56 -19
- package/dist/components/moni-side-sheet.d.ts.map +1 -1
- package/dist/components/moni-side-sheet.js +53 -16
- package/dist/components/moni-slider.d.ts +56 -25
- package/dist/components/moni-slider.d.ts.map +1 -1
- package/dist/components/moni-slider.js +55 -24
- package/dist/components/moni-snackbar.d.ts +86 -17
- package/dist/components/moni-snackbar.d.ts.map +1 -1
- package/dist/components/moni-snackbar.js +85 -16
- package/dist/components/moni-split-button.d.ts +38 -9
- package/dist/components/moni-split-button.d.ts.map +1 -1
- package/dist/components/moni-split-button.js +37 -8
- package/dist/components/moni-step.d.ts +42 -9
- package/dist/components/moni-step.d.ts.map +1 -1
- package/dist/components/moni-step.js +41 -8
- package/dist/components/moni-stepper.d.ts +43 -6
- package/dist/components/moni-stepper.d.ts.map +1 -1
- package/dist/components/moni-stepper.js +42 -5
- package/dist/components/moni-switch.d.ts +103 -16
- package/dist/components/moni-switch.d.ts.map +1 -1
- package/dist/components/moni-switch.js +99 -13
- package/dist/components/moni-tab.d.ts +35 -8
- package/dist/components/moni-tab.d.ts.map +1 -1
- package/dist/components/moni-tab.js +34 -7
- package/dist/components/moni-tabs.d.ts +51 -13
- package/dist/components/moni-tabs.d.ts.map +1 -1
- package/dist/components/moni-tabs.js +48 -10
- package/dist/components/moni-text-field.d.ts +55 -10
- package/dist/components/moni-text-field.d.ts.map +1 -1
- package/dist/components/moni-text-field.js +54 -9
- package/dist/components/moni-textarea.d.ts +51 -21
- package/dist/components/moni-textarea.d.ts.map +1 -1
- package/dist/components/moni-textarea.js +48 -18
- package/dist/components/moni-time-picker.d.ts +41 -11
- package/dist/components/moni-time-picker.d.ts.map +1 -1
- package/dist/components/moni-time-picker.js +40 -10
- package/dist/components/moni-toolbar.d.ts +43 -15
- package/dist/components/moni-toolbar.d.ts.map +1 -1
- package/dist/components/moni-toolbar.js +42 -14
- package/dist/components/moni-tooltip.d.ts +55 -25
- package/dist/components/moni-tooltip.d.ts.map +1 -1
- package/dist/components/moni-tooltip.js +54 -24
- package/dist/components/moni-typography.d.ts +43 -18
- package/dist/components/moni-typography.d.ts.map +1 -1
- package/dist/components/moni-typography.js +42 -17
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -2
- package/dist/styles/tailwind.css +67 -0
- package/dist/styles/tokens.css +111 -99
- package/dist/utils/color.d.ts +181 -2
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +182 -4
- package/dist/utils/theme.svelte.d.ts +305 -2
- package/dist/utils/theme.svelte.d.ts.map +1 -1
- package/dist/utils/theme.svelte.js +331 -2
- package/dist/web-components.d.ts +28 -0
- package/dist/web-components.d.ts.map +1 -1
- package/dist/web-components.js +29 -2
- package/package.json +1 -1
- package/src/actions/index.ts +7 -0
- package/src/components/_base/field-styles.ts +165 -37
- package/src/components/_base/index.ts +27 -0
- package/src/components/_base/interaction-styles.ts +86 -33
- package/src/components/_base/moni-element.ts +44 -8
- package/src/components/_base/shared-styles.ts +114 -21
- package/src/components/index.ts +7 -0
- package/src/components/loading-shapes.ts +7 -0
- package/src/components/moni-app-bar.ts +127 -26
- package/src/components/moni-badge.ts +128 -14
- package/src/components/moni-bottom-sheet.ts +125 -13
- package/src/components/moni-button-group.ts +50 -23
- package/src/components/moni-button-segment.ts +28 -7
- package/src/components/moni-button.ts +51 -31
- package/src/components/moni-card.ts +90 -26
- package/src/components/moni-carousel.ts +67 -16
- package/src/components/moni-checkbox.ts +125 -14
- package/src/components/moni-chip.ts +52 -25
- package/src/components/moni-color-field.ts +44 -5
- package/src/components/moni-context-menu.ts +44 -21
- package/src/components/moni-dialog.ts +111 -14
- package/src/components/moni-divider.ts +50 -14
- package/src/components/moni-expansion.ts +44 -7
- package/src/components/moni-fab-menu.ts +39 -19
- package/src/components/moni-fab.ts +47 -20
- package/src/components/moni-file-field.ts +54 -13
- package/src/components/moni-icon.ts +80 -10
- package/src/components/moni-list-item.ts +56 -24
- package/src/components/moni-list.ts +37 -12
- package/src/components/moni-loading-indicator.ts +38 -10
- package/src/components/moni-menu-item.ts +31 -7
- package/src/components/moni-menu.ts +52 -26
- package/src/components/moni-morph-modal.ts +58 -24
- package/src/components/moni-nav-item.ts +49 -8
- package/src/components/moni-nav.ts +54 -18
- package/src/components/moni-progress.ts +109 -16
- package/src/components/moni-radio.ts +111 -13
- package/src/components/moni-ripple.ts +126 -9
- package/src/components/moni-segmented-button.ts +31 -10
- package/src/components/moni-select-option.ts +42 -7
- package/src/components/moni-select.ts +79 -1
- package/src/components/moni-side-sheet.ts +54 -16
- package/src/components/moni-slider.ts +56 -24
- package/src/components/moni-snackbar.ts +90 -16
- package/src/components/moni-split-button.ts +38 -8
- package/src/components/moni-step.ts +42 -8
- package/src/components/moni-stepper.ts +43 -5
- package/src/components/moni-switch.ts +106 -13
- package/src/components/moni-tab.ts +35 -7
- package/src/components/moni-tabs.ts +49 -10
- package/src/components/moni-text-field.ts +55 -9
- package/src/components/moni-textarea.ts +49 -18
- package/src/components/moni-time-picker.ts +41 -10
- package/src/components/moni-toolbar.ts +43 -14
- package/src/components/moni-tooltip.ts +55 -24
- package/src/components/moni-typography.ts +43 -17
- package/src/index.ts +67 -3
- package/src/styles/tailwind.css +67 -0
- package/src/styles/tokens.css +111 -99
- package/src/types/svelte-runes.d.ts +64 -2
- package/src/utils/color.ts +286 -5
- package/src/utils/theme.svelte.ts +411 -2
- package/src/web-components.ts +31 -2
- package/dist/assets/shapes/arch.svg +0 -1
- package/dist/assets/shapes/arrow.svg +0 -1
- package/dist/assets/shapes/boom.svg +0 -1
- package/dist/assets/shapes/burst.svg +0 -1
- package/dist/assets/shapes/circle.svg +0 -1
- package/dist/assets/shapes/clamshell.svg +0 -1
- package/dist/assets/shapes/diamond.svg +0 -1
- package/dist/assets/shapes/fan.svg +0 -1
- package/dist/assets/shapes/flower.svg +0 -1
- package/dist/assets/shapes/gem.svg +0 -1
- package/dist/assets/shapes/ghost-ish.svg +0 -1
- package/dist/assets/shapes/heart.svg +0 -1
- package/dist/assets/shapes/leaf-clover4.svg +0 -1
- package/dist/assets/shapes/leaf-clover8.svg +0 -1
- package/dist/assets/shapes/loading-indicator.svg +0 -1
- package/dist/assets/shapes/oval.svg +0 -1
- package/dist/assets/shapes/pentagon.svg +0 -1
- package/dist/assets/shapes/pill.svg +0 -1
- package/dist/assets/shapes/pixel-circle.svg +0 -1
- package/dist/assets/shapes/pixel-triangle.svg +0 -1
- package/dist/assets/shapes/puffy-diamond.svg +0 -1
- package/dist/assets/shapes/puffy.svg +0 -1
- package/dist/assets/shapes/semicircle.svg +0 -1
- package/dist/assets/shapes/sided-cookie12.svg +0 -1
- package/dist/assets/shapes/sided-cookie4.svg +0 -1
- package/dist/assets/shapes/sided-cookie6.svg +0 -1
- package/dist/assets/shapes/sided-cookie7.svg +0 -1
- package/dist/assets/shapes/sided-cookie9.svg +0 -1
- package/dist/assets/shapes/slanted.svg +0 -1
- package/dist/assets/shapes/soft-boom.svg +0 -1
- package/dist/assets/shapes/soft-burst.svg +0 -1
- package/dist/assets/shapes/square.svg +0 -1
- package/dist/assets/shapes/sunny.svg +0 -1
- package/dist/assets/shapes/triangle.svg +0 -1
- package/dist/assets/shapes/very-sunny.svg +0 -1
- package/dist/assets/shapes/wavy-circle.svg +0 -1
- package/dist/assets/shapes/wavy.svg +0 -1
- package/src/assets/shapes/arch.svg +0 -1
- package/src/assets/shapes/arrow.svg +0 -1
- package/src/assets/shapes/boom.svg +0 -1
- package/src/assets/shapes/burst.svg +0 -1
- package/src/assets/shapes/circle.svg +0 -1
- package/src/assets/shapes/clamshell.svg +0 -1
- package/src/assets/shapes/diamond.svg +0 -1
- package/src/assets/shapes/fan.svg +0 -1
- package/src/assets/shapes/flower.svg +0 -1
- package/src/assets/shapes/gem.svg +0 -1
- package/src/assets/shapes/ghost-ish.svg +0 -1
- package/src/assets/shapes/heart.svg +0 -1
- package/src/assets/shapes/leaf-clover4.svg +0 -1
- package/src/assets/shapes/leaf-clover8.svg +0 -1
- package/src/assets/shapes/loading-indicator.svg +0 -1
- package/src/assets/shapes/oval.svg +0 -1
- package/src/assets/shapes/pentagon.svg +0 -1
- package/src/assets/shapes/pill.svg +0 -1
- package/src/assets/shapes/pixel-circle.svg +0 -1
- package/src/assets/shapes/pixel-triangle.svg +0 -1
- package/src/assets/shapes/puffy-diamond.svg +0 -1
- package/src/assets/shapes/puffy.svg +0 -1
- package/src/assets/shapes/semicircle.svg +0 -1
- package/src/assets/shapes/sided-cookie12.svg +0 -1
- package/src/assets/shapes/sided-cookie4.svg +0 -1
- package/src/assets/shapes/sided-cookie6.svg +0 -1
- package/src/assets/shapes/sided-cookie7.svg +0 -1
- package/src/assets/shapes/sided-cookie9.svg +0 -1
- package/src/assets/shapes/slanted.svg +0 -1
- package/src/assets/shapes/soft-boom.svg +0 -1
- package/src/assets/shapes/soft-burst.svg +0 -1
- package/src/assets/shapes/square.svg +0 -1
- package/src/assets/shapes/sunny.svg +0 -1
- package/src/assets/shapes/triangle.svg +0 -1
- package/src/assets/shapes/very-sunny.svg +0 -1
- package/src/assets/shapes/wavy-circle.svg +0 -1
- package/src/assets/shapes/wavy.svg +0 -1
|
@@ -1,26 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-nav.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
import { MoniElement } from './_base/index.js';
|
|
2
8
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
9
|
+
* Material Design 3 Navigation container component.
|
|
10
|
+
*
|
|
11
|
+
* `<moni-nav>` is the container that wraps `<moni-nav-item>` elements and
|
|
12
|
+
* controls the M3 navigation pattern: navigation bar, navigation rail, or
|
|
13
|
+
* navigation drawer.
|
|
14
|
+
*
|
|
15
|
+
* **M3 spec references:**
|
|
16
|
+
* - Navigation bar: `m3-docs/components/navigation-bar/specs.md`
|
|
17
|
+
* - Navigation rail: `m3-docs/components/navigation-rail/specs.md`
|
|
18
|
+
* - Navigation drawer: `m3-docs/components/navigation-drawer/specs.md`
|
|
19
|
+
*
|
|
20
|
+
* **Navigation patterns:**
|
|
21
|
+
* - **Navigation bar** (`placement="bottom"`) — Horizontal bar of icon+label
|
|
22
|
+
* items at the bottom of the screen. Best for 3–5 top-level destinations.
|
|
23
|
+
* - **Navigation rail** (`variant="rail"`) — Vertical rail of icon+label items
|
|
24
|
+
* on the side of the screen. Best for medium/expanded breakpoints.
|
|
25
|
+
* - **Standard drawer** (`variant="drawer"`) — Always-visible vertical panel
|
|
26
|
+
* with full text labels. No scrim. Best for large screens.
|
|
27
|
+
* - **Modal drawer** (`variant="drawer" modal`) — Overlay drawer with scrim.
|
|
28
|
+
* Opened/closed via the `open` property. Traps keyboard focus while open.
|
|
29
|
+
* Closes on `Escape` key press.
|
|
30
|
+
*
|
|
31
|
+
* **Keyboard handling:**
|
|
32
|
+
* When `modal=true`, the component adds a global `keydown` listener in
|
|
33
|
+
* `connectedCallback` that closes the drawer on `Escape`. The listener is
|
|
34
|
+
* removed in `disconnectedCallback`.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```html
|
|
38
|
+
* <!-- Bottom navigation bar -->
|
|
39
|
+
* <moni-nav placement="bottom">
|
|
40
|
+
* <moni-nav-item icon="home" label="Home" active></moni-nav-item>
|
|
41
|
+
* <moni-nav-item icon="search" label="Search"></moni-nav-item>
|
|
42
|
+
* <moni-nav-item icon="person" label="Profile"></moni-nav-item>
|
|
43
|
+
* </moni-nav>
|
|
44
|
+
*
|
|
45
|
+
* <!-- Modal navigation drawer -->
|
|
46
|
+
* <moni-nav variant="drawer" modal open placement="left">
|
|
47
|
+
* <h3 slot="header">My App</h3>
|
|
48
|
+
* <moni-nav-item icon="home" label="Home" active></moni-nav-item>
|
|
49
|
+
* <moni-nav-item icon="settings" label="Settings"></moni-nav-item>
|
|
50
|
+
* </moni-nav>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @slot default - `<moni-nav-item>` children.
|
|
54
|
+
* @slot header - Content above the nav items (drawer variant only).
|
|
55
|
+
* @slot footer - Content below the nav items (drawer variant only).
|
|
56
|
+
*
|
|
57
|
+
* @csspart nav - The inner `<nav>` element.
|
|
58
|
+
* @csspart scrim - The backdrop scrim (modal drawer only).
|
|
24
59
|
*/
|
|
25
60
|
export declare class MoniNav extends MoniElement {
|
|
26
61
|
placement: 'top' | 'bottom' | 'left' | 'right';
|
|
@@ -35,7 +70,7 @@ export declare class MoniNav extends MoniElement {
|
|
|
35
70
|
updated(changed: Map<string, unknown>): void;
|
|
36
71
|
private _propagateToItems;
|
|
37
72
|
static styles: import("lit").CSSResult[];
|
|
38
|
-
render(): import("lit
|
|
73
|
+
render(): import("lit").TemplateResult<1>;
|
|
39
74
|
}
|
|
40
75
|
declare global {
|
|
41
76
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-nav.d.ts","sourceRoot":"","sources":["../../src/components/moni-nav.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-nav.d.ts","sourceRoot":"","sources":["../../src/components/moni-nav.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,qBACa,OAAQ,SAAQ,WAAW;IAEvC,SAAS,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAS;IAEvD,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAU;IACQ,KAAK,UAAS;IACd,IAAI,UAAQ;IAExD,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,MAAM,CAAU;IAE3C,iBAAiB;IAMjB,oBAAoB;IAK7B,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,WAAW;IAMV,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAY9C,OAAO,CAAC,iBAAiB,CAOvB;IAEF,OAAgB,MAAM,4BAoJpB;IAEO,MAAM;CAyBf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,UAAU,EAAE,OAAO,CAAC;KACpB;CACD;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-nav.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
8
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
9
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,27 +14,56 @@ import { html, css } from 'lit';
|
|
|
8
14
|
import { customElement, property } from 'lit/decorators.js';
|
|
9
15
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
17
|
+
* Material Design 3 Navigation container component.
|
|
18
|
+
*
|
|
19
|
+
* `<moni-nav>` is the container that wraps `<moni-nav-item>` elements and
|
|
20
|
+
* controls the M3 navigation pattern: navigation bar, navigation rail, or
|
|
21
|
+
* navigation drawer.
|
|
22
|
+
*
|
|
23
|
+
* **M3 spec references:**
|
|
24
|
+
* - Navigation bar: `m3-docs/components/navigation-bar/specs.md`
|
|
25
|
+
* - Navigation rail: `m3-docs/components/navigation-rail/specs.md`
|
|
26
|
+
* - Navigation drawer: `m3-docs/components/navigation-drawer/specs.md`
|
|
27
|
+
*
|
|
28
|
+
* **Navigation patterns:**
|
|
29
|
+
* - **Navigation bar** (`placement="bottom"`) — Horizontal bar of icon+label
|
|
30
|
+
* items at the bottom of the screen. Best for 3–5 top-level destinations.
|
|
31
|
+
* - **Navigation rail** (`variant="rail"`) — Vertical rail of icon+label items
|
|
32
|
+
* on the side of the screen. Best for medium/expanded breakpoints.
|
|
33
|
+
* - **Standard drawer** (`variant="drawer"`) — Always-visible vertical panel
|
|
34
|
+
* with full text labels. No scrim. Best for large screens.
|
|
35
|
+
* - **Modal drawer** (`variant="drawer" modal`) — Overlay drawer with scrim.
|
|
36
|
+
* Opened/closed via the `open` property. Traps keyboard focus while open.
|
|
37
|
+
* Closes on `Escape` key press.
|
|
38
|
+
*
|
|
39
|
+
* **Keyboard handling:**
|
|
40
|
+
* When `modal=true`, the component adds a global `keydown` listener in
|
|
41
|
+
* `connectedCallback` that closes the drawer on `Escape`. The listener is
|
|
42
|
+
* removed in `disconnectedCallback`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```html
|
|
46
|
+
* <!-- Bottom navigation bar -->
|
|
47
|
+
* <moni-nav placement="bottom">
|
|
48
|
+
* <moni-nav-item icon="home" label="Home" active></moni-nav-item>
|
|
49
|
+
* <moni-nav-item icon="search" label="Search"></moni-nav-item>
|
|
50
|
+
* <moni-nav-item icon="person" label="Profile"></moni-nav-item>
|
|
51
|
+
* </moni-nav>
|
|
12
52
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
53
|
+
* <!-- Modal navigation drawer -->
|
|
54
|
+
* <moni-nav variant="drawer" modal open placement="left">
|
|
55
|
+
* <h3 slot="header">My App</h3>
|
|
56
|
+
* <moni-nav-item icon="home" label="Home" active></moni-nav-item>
|
|
57
|
+
* <moni-nav-item icon="settings" label="Settings"></moni-nav-item>
|
|
58
|
+
* </moni-nav>
|
|
59
|
+
* ```
|
|
20
60
|
*
|
|
21
|
-
*
|
|
22
|
-
* -
|
|
23
|
-
* -
|
|
24
|
-
* - modal: present → drawer is modal (requires variant="drawer")
|
|
25
|
-
* - open: present → modal drawer is open (default true)
|
|
26
|
-
* - layout: vertical | horizontal | auto (default)
|
|
61
|
+
* @slot default - `<moni-nav-item>` children.
|
|
62
|
+
* @slot header - Content above the nav items (drawer variant only).
|
|
63
|
+
* @slot footer - Content below the nav items (drawer variant only).
|
|
27
64
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* - header: content above nav items (drawer only)
|
|
31
|
-
* - footer: content below nav items (drawer only)
|
|
65
|
+
* @csspart nav - The inner `<nav>` element.
|
|
66
|
+
* @csspart scrim - The backdrop scrim (modal drawer only).
|
|
32
67
|
*/
|
|
33
68
|
let MoniNav = class MoniNav extends MoniElement {
|
|
34
69
|
constructor() {
|
|
@@ -1,32 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-progress.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
import { MoniElement } from './_base/index.js';
|
|
2
8
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
9
|
+
* Material Design 3 Progress Indicator component.
|
|
10
|
+
*
|
|
11
|
+
* Progress indicators express an unspecified wait time or display the length
|
|
12
|
+
* of a process. They inform users about the status of ongoing processes such
|
|
13
|
+
* as loading an app, submitting a form, or saving updates.
|
|
14
|
+
*
|
|
15
|
+
* **M3 spec reference:** `m3-docs/components/progress-indicators/specs.md`
|
|
16
|
+
*
|
|
17
|
+
* **Variants:**
|
|
18
|
+
* - `linear` (default) — A horizontal bar that fills left-to-right.
|
|
19
|
+
* - `circular` — A circular SVG stroke indicator.
|
|
20
|
+
* - `wavy` — An animated wave bar (Moni extension; not in M3 spec).
|
|
21
|
+
* - `circular-wavy` — Circular + wave combo (Moni extension).
|
|
22
|
+
*
|
|
23
|
+
* **Shadow DOM compatibility note:**
|
|
24
|
+
* BeerCSS's progress uses native `<progress>` pseudo-elements (`::before`,
|
|
25
|
+
* `::after`, `::webkit-progress-value`) and `mask-image`, which are blocked
|
|
26
|
+
* by the UA shadow root in Chrome/Firefox. This component uses a plain `<div>`
|
|
27
|
+
* wrapper that replicates the visual rules exactly, and an `<svg>` element
|
|
28
|
+
* for the circular variant using SVG stroke-dashoffset animation for superior
|
|
29
|
+
* cross-browser support compared to `conic-gradient`.
|
|
30
|
+
*
|
|
31
|
+
* **Percentage computation:**
|
|
32
|
+
* `_pct` is computed in `willUpdate()` as `(value / max) * 100`, clamped to
|
|
33
|
+
* `[0, 100]`. When `indeterminate` is set, `_pct` is fixed at `50` to drive
|
|
34
|
+
* the infinite loop animation.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```html
|
|
38
|
+
* <!-- Determinate linear progress -->
|
|
39
|
+
* <moni-progress value="65" max="100"></moni-progress>
|
|
40
|
+
*
|
|
41
|
+
* <!-- Indeterminate circular progress (loading spinner) -->
|
|
42
|
+
* <moni-progress variant="circular" indeterminate></moni-progress>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @csspart bar - The outer container div.
|
|
46
|
+
* @csspart fill - The inner fill element (linear variant).
|
|
47
|
+
* @csspart svg - The SVG element (circular variant).
|
|
21
48
|
*/
|
|
22
49
|
export declare class MoniProgress extends MoniElement {
|
|
50
|
+
/**
|
|
51
|
+
* Current progress value.
|
|
52
|
+
*
|
|
53
|
+
* Must be in the range `[0, max]`. Values outside this range are clamped
|
|
54
|
+
* during percentage computation in `willUpdate()`. Ignored when
|
|
55
|
+
* `indeterminate` is set.
|
|
56
|
+
*
|
|
57
|
+
* @default 0
|
|
58
|
+
*/
|
|
23
59
|
value: number;
|
|
60
|
+
/**
|
|
61
|
+
* Maximum value of the progress range.
|
|
62
|
+
*
|
|
63
|
+
* Defaults to `100` so `value` can be set as a percentage directly.
|
|
64
|
+
* For non-percentage ranges (e.g. steps), set `max` to the total step count
|
|
65
|
+
* and `value` to the current step.
|
|
66
|
+
*
|
|
67
|
+
* @default 100
|
|
68
|
+
*/
|
|
24
69
|
max: number;
|
|
70
|
+
/**
|
|
71
|
+
* Visual variant of the progress indicator.
|
|
72
|
+
*
|
|
73
|
+
* - `'linear'` (default) — Horizontal fill bar.
|
|
74
|
+
* - `'circular'` — SVG circle with stroke-dashoffset animation.
|
|
75
|
+
* - `'wavy'` — Animated wave bar.
|
|
76
|
+
* - `'circular-wavy'` — Combination of circular and wave.
|
|
77
|
+
*
|
|
78
|
+
* @default 'linear'
|
|
79
|
+
*/
|
|
25
80
|
variant: 'linear' | 'circular' | 'wavy' | 'circular-wavy';
|
|
81
|
+
/**
|
|
82
|
+
* Visual size of the progress indicator.
|
|
83
|
+
*
|
|
84
|
+
* - `'small'` — Compact; suitable for inline or tight layouts.
|
|
85
|
+
* - `'medium'` — Standard M3 size (default).
|
|
86
|
+
* - `'large'` — Prominent; for full-page loading states.
|
|
87
|
+
*
|
|
88
|
+
* @default 'medium'
|
|
89
|
+
*/
|
|
26
90
|
size: 'small' | 'medium' | 'large';
|
|
91
|
+
/**
|
|
92
|
+
* When `true`, the indicator animates in an infinite loop regardless of `value`.
|
|
93
|
+
*
|
|
94
|
+
* Use for operations where the completion percentage is unknown
|
|
95
|
+
* (e.g. network requests, file processing). When `indeterminate` is set,
|
|
96
|
+
* `_pct` is fixed at `50` to drive a continuous sweep animation.
|
|
97
|
+
*
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
27
100
|
indeterminate: boolean;
|
|
28
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Computed fill percentage in the range `[0, 100]`.
|
|
103
|
+
*
|
|
104
|
+
* Updated in `willUpdate()` whenever `value`, `max`, or `indeterminate` changes.
|
|
105
|
+
* Used directly in CSS custom property bindings and SVG stroke attributes.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
29
109
|
private _pct;
|
|
110
|
+
/**
|
|
111
|
+
* Computes the fill percentage before each render.
|
|
112
|
+
*
|
|
113
|
+
* Recalculates `_pct` whenever `value`, `max`, or `indeterminate` changes.
|
|
114
|
+
* The `Math.max(1, max)` guard prevents division-by-zero when `max` is 0.
|
|
115
|
+
*
|
|
116
|
+
* @param changed - Map of property names to their previous values.
|
|
117
|
+
*/
|
|
30
118
|
willUpdate(changed: Map<string, unknown>): void;
|
|
31
119
|
static styles: import("lit").CSSResult[];
|
|
32
120
|
private _renderLinear;
|
|
@@ -34,7 +122,7 @@ export declare class MoniProgress extends MoniElement {
|
|
|
34
122
|
private _renderCircular;
|
|
35
123
|
/** Unique ID per instance for SVG clipPath IDs */
|
|
36
124
|
private readonly _instanceId;
|
|
37
|
-
render(): import("lit
|
|
125
|
+
render(): import("lit").TemplateResult<1>;
|
|
38
126
|
}
|
|
39
127
|
declare global {
|
|
40
128
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-progress.d.ts","sourceRoot":"","sources":["../../src/components/moni-progress.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-progress.d.ts","sourceRoot":"","sources":["../../src/components/moni-progress.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBACa,YAAa,SAAQ,WAAW;IAC5C;;;;;;;;OAQG;IACwC,KAAK,SAAK;IAErD;;;;;;;;OAQG;IACwC,GAAG,SAAO;IAErD;;;;;;;;;OASG;IAEH,OAAO,EAAE,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,eAAe,CAAY;IAErE;;;;;;;;OAQG;IAEH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAY;IAE9C;;;;;;;;OAQG;IACyC,aAAa,UAAS;IAElE;;;;;;;OAOG;IACM,OAAO,CAAC,IAAI,CAAK;IAE1B;;;;;;;OAOG;IACM,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAQjD,OAAgB,MAAM,4BA6HpB;IAEF,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,WAAW;IAyDnB,OAAO,CAAC,eAAe;IAoDvB,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0C;IAE7D,MAAM;CAYf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,YAAY,CAAC;KAC9B;CACD;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-progress.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
8
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
9
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,38 +14,120 @@ import { html, css, svg, nothing } from 'lit';
|
|
|
8
14
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
9
15
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
17
|
+
* Material Design 3 Progress Indicator component.
|
|
18
|
+
*
|
|
19
|
+
* Progress indicators express an unspecified wait time or display the length
|
|
20
|
+
* of a process. They inform users about the status of ongoing processes such
|
|
21
|
+
* as loading an app, submitting a form, or saving updates.
|
|
22
|
+
*
|
|
23
|
+
* **M3 spec reference:** `m3-docs/components/progress-indicators/specs.md`
|
|
24
|
+
*
|
|
25
|
+
* **Variants:**
|
|
26
|
+
* - `linear` (default) — A horizontal bar that fills left-to-right.
|
|
27
|
+
* - `circular` — A circular SVG stroke indicator.
|
|
28
|
+
* - `wavy` — An animated wave bar (Moni extension; not in M3 spec).
|
|
29
|
+
* - `circular-wavy` — Circular + wave combo (Moni extension).
|
|
30
|
+
*
|
|
31
|
+
* **Shadow DOM compatibility note:**
|
|
32
|
+
* BeerCSS's progress uses native `<progress>` pseudo-elements (`::before`,
|
|
33
|
+
* `::after`, `::webkit-progress-value`) and `mask-image`, which are blocked
|
|
34
|
+
* by the UA shadow root in Chrome/Firefox. This component uses a plain `<div>`
|
|
35
|
+
* wrapper that replicates the visual rules exactly, and an `<svg>` element
|
|
36
|
+
* for the circular variant using SVG stroke-dashoffset animation for superior
|
|
37
|
+
* cross-browser support compared to `conic-gradient`.
|
|
38
|
+
*
|
|
39
|
+
* **Percentage computation:**
|
|
40
|
+
* `_pct` is computed in `willUpdate()` as `(value / max) * 100`, clamped to
|
|
41
|
+
* `[0, 100]`. When `indeterminate` is set, `_pct` is fixed at `50` to drive
|
|
42
|
+
* the infinite loop animation.
|
|
12
43
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - `mask-image` on those pseudo-elements doesn't apply at all in shadows.
|
|
44
|
+
* @example
|
|
45
|
+
* ```html
|
|
46
|
+
* <!-- Determinate linear progress -->
|
|
47
|
+
* <moni-progress value="65" max="100"></moni-progress>
|
|
18
48
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
49
|
+
* <!-- Indeterminate circular progress (loading spinner) -->
|
|
50
|
+
* <moni-progress variant="circular" indeterminate></moni-progress>
|
|
51
|
+
* ```
|
|
22
52
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* - variant: linear (default) | circular | wavy | circular-wavy
|
|
27
|
-
* - size: small | medium (default) | large
|
|
28
|
-
* - indeterminate: present → infinite animation
|
|
53
|
+
* @csspart bar - The outer container div.
|
|
54
|
+
* @csspart fill - The inner fill element (linear variant).
|
|
55
|
+
* @csspart svg - The SVG element (circular variant).
|
|
29
56
|
*/
|
|
30
57
|
let MoniProgress = class MoniProgress extends MoniElement {
|
|
31
58
|
constructor() {
|
|
32
59
|
super(...arguments);
|
|
60
|
+
/**
|
|
61
|
+
* Current progress value.
|
|
62
|
+
*
|
|
63
|
+
* Must be in the range `[0, max]`. Values outside this range are clamped
|
|
64
|
+
* during percentage computation in `willUpdate()`. Ignored when
|
|
65
|
+
* `indeterminate` is set.
|
|
66
|
+
*
|
|
67
|
+
* @default 0
|
|
68
|
+
*/
|
|
33
69
|
this.value = 0;
|
|
70
|
+
/**
|
|
71
|
+
* Maximum value of the progress range.
|
|
72
|
+
*
|
|
73
|
+
* Defaults to `100` so `value` can be set as a percentage directly.
|
|
74
|
+
* For non-percentage ranges (e.g. steps), set `max` to the total step count
|
|
75
|
+
* and `value` to the current step.
|
|
76
|
+
*
|
|
77
|
+
* @default 100
|
|
78
|
+
*/
|
|
34
79
|
this.max = 100;
|
|
80
|
+
/**
|
|
81
|
+
* Visual variant of the progress indicator.
|
|
82
|
+
*
|
|
83
|
+
* - `'linear'` (default) — Horizontal fill bar.
|
|
84
|
+
* - `'circular'` — SVG circle with stroke-dashoffset animation.
|
|
85
|
+
* - `'wavy'` — Animated wave bar.
|
|
86
|
+
* - `'circular-wavy'` — Combination of circular and wave.
|
|
87
|
+
*
|
|
88
|
+
* @default 'linear'
|
|
89
|
+
*/
|
|
35
90
|
this.variant = 'linear';
|
|
91
|
+
/**
|
|
92
|
+
* Visual size of the progress indicator.
|
|
93
|
+
*
|
|
94
|
+
* - `'small'` — Compact; suitable for inline or tight layouts.
|
|
95
|
+
* - `'medium'` — Standard M3 size (default).
|
|
96
|
+
* - `'large'` — Prominent; for full-page loading states.
|
|
97
|
+
*
|
|
98
|
+
* @default 'medium'
|
|
99
|
+
*/
|
|
36
100
|
this.size = 'medium';
|
|
101
|
+
/**
|
|
102
|
+
* When `true`, the indicator animates in an infinite loop regardless of `value`.
|
|
103
|
+
*
|
|
104
|
+
* Use for operations where the completion percentage is unknown
|
|
105
|
+
* (e.g. network requests, file processing). When `indeterminate` is set,
|
|
106
|
+
* `_pct` is fixed at `50` to drive a continuous sweep animation.
|
|
107
|
+
*
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
37
110
|
this.indeterminate = false;
|
|
38
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Computed fill percentage in the range `[0, 100]`.
|
|
113
|
+
*
|
|
114
|
+
* Updated in `willUpdate()` whenever `value`, `max`, or `indeterminate` changes.
|
|
115
|
+
* Used directly in CSS custom property bindings and SVG stroke attributes.
|
|
116
|
+
*
|
|
117
|
+
* @internal
|
|
118
|
+
*/
|
|
39
119
|
this._pct = 0;
|
|
40
120
|
/** Unique ID per instance for SVG clipPath IDs */
|
|
41
121
|
this._instanceId = Math.random().toString(36).slice(2, 8);
|
|
42
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Computes the fill percentage before each render.
|
|
125
|
+
*
|
|
126
|
+
* Recalculates `_pct` whenever `value`, `max`, or `indeterminate` changes.
|
|
127
|
+
* The `Math.max(1, max)` guard prevents division-by-zero when `max` is 0.
|
|
128
|
+
*
|
|
129
|
+
* @param changed - Map of property names to their previous values.
|
|
130
|
+
*/
|
|
43
131
|
willUpdate(changed) {
|
|
44
132
|
if (changed.has('value') || changed.has('max') || changed.has('indeterminate')) {
|
|
45
133
|
this._pct = this.indeterminate
|
|
@@ -1,33 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-radio.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
import { MoniElement } from './_base/index.js';
|
|
2
8
|
/**
|
|
3
|
-
*
|
|
9
|
+
* Material Design 3 Radio Button component.
|
|
10
|
+
*
|
|
11
|
+
* Radio buttons allow users to select exactly one item from a set of mutually
|
|
12
|
+
* exclusive options. They share the same visual architecture as
|
|
13
|
+
* `<moni-checkbox>` but use `type="radio"` and implement group deselection.
|
|
14
|
+
*
|
|
15
|
+
* **M3 spec reference:** `m3-docs/components/radio/specs.md`
|
|
16
|
+
*
|
|
17
|
+
* **Visual architecture (BeerCSS pattern):**
|
|
18
|
+
* Identical to the checkbox pattern: the native `<input type="radio">` occupies
|
|
19
|
+
* real layout space at `--_size` × `--_size` but is hidden via `opacity: 0`.
|
|
20
|
+
* A sibling `<span>` renders:
|
|
21
|
+
* - `::before` — the radio icon (`radio_button_unchecked` / `radio_button_checked`).
|
|
22
|
+
* - `::after` — the hover/focus ripple ring.
|
|
23
|
+
*
|
|
24
|
+
* **Group deselection:**
|
|
25
|
+
* When a radio is checked, `_onChange` queries the component's `getRootNode()`
|
|
26
|
+
* for all `moni-radio` elements sharing the same `name` attribute and sets
|
|
27
|
+
* their `checked` property to `false`. This mirrors native browser behavior
|
|
28
|
+
* for radio groups across shadow DOM boundaries where `name` grouping does
|
|
29
|
+
* not work natively.
|
|
30
|
+
*
|
|
31
|
+
* @fires change - Bubbles and is composed. Fired when this radio is selected.
|
|
32
|
+
* Read `element.checked` for the new state.
|
|
4
33
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```html
|
|
36
|
+
* <moni-radio name="color" value="red" label="Red"></moni-radio>
|
|
37
|
+
* <moni-radio name="color" value="green" label="Green"></moni-radio>
|
|
38
|
+
* <moni-radio name="color" value="blue" label="Blue" checked></moni-radio>
|
|
39
|
+
* ```
|
|
10
40
|
*
|
|
11
|
-
*
|
|
12
|
-
* - label: text label
|
|
13
|
-
* - checked: present
|
|
14
|
-
* - disabled: present
|
|
15
|
-
* - size: small | medium (default) | large | extra
|
|
16
|
-
* - name: forwarded to input.name (group radios by name)
|
|
17
|
-
* - value: forwarded to input.value
|
|
41
|
+
* @csspart radio - The outer `<label>` element.
|
|
18
42
|
*/
|
|
19
43
|
export declare class MoniRadio extends MoniElement {
|
|
44
|
+
/**
|
|
45
|
+
* Text label displayed to the right of the radio icon.
|
|
46
|
+
*
|
|
47
|
+
* When non-empty, renders as a text node. When empty, the default slot
|
|
48
|
+
* is rendered, allowing slotted HTML content as the label.
|
|
49
|
+
*
|
|
50
|
+
* @default ''
|
|
51
|
+
*/
|
|
20
52
|
label: string;
|
|
53
|
+
/**
|
|
54
|
+
* Whether this radio button is currently selected.
|
|
55
|
+
*
|
|
56
|
+
* Reflected as an attribute so CSS selectors can target it. Synced to
|
|
57
|
+
* the native input via `updated()`.
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
21
61
|
checked: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* When `true`, the radio is non-interactive and renders at 50% opacity.
|
|
64
|
+
*
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
22
67
|
disabled: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Visual size of the radio icon and its invisible hit area.
|
|
70
|
+
*
|
|
71
|
+
* | Value | `--_size` |
|
|
72
|
+
* |------------|-----------|
|
|
73
|
+
* | `'small'` | 1rem |
|
|
74
|
+
* | `'medium'` | 1.5rem |
|
|
75
|
+
* | `'large'` | 2rem |
|
|
76
|
+
* | `'extra'` | 2.5rem |
|
|
77
|
+
*
|
|
78
|
+
* @default 'medium'
|
|
79
|
+
*/
|
|
23
80
|
size: 'small' | 'medium' | 'large' | 'extra';
|
|
81
|
+
/**
|
|
82
|
+
* Radio group name. Radios with the same `name` in the same root node
|
|
83
|
+
* are treated as a mutual-exclusion group by `_onChange`.
|
|
84
|
+
*
|
|
85
|
+
* Note: Native `<input type="radio">` groups only work within the same
|
|
86
|
+
* document root. Since `moni-radio` uses shadow DOM, the deselection
|
|
87
|
+
* of siblings is handled imperatively in `_onChange`.
|
|
88
|
+
*
|
|
89
|
+
* @default ''
|
|
90
|
+
*/
|
|
24
91
|
name: string;
|
|
92
|
+
/**
|
|
93
|
+
* Forwarded to the native `<input value>` attribute.
|
|
94
|
+
* The value submitted in a form when this radio is selected.
|
|
95
|
+
*
|
|
96
|
+
* @default ''
|
|
97
|
+
*/
|
|
25
98
|
value: string;
|
|
99
|
+
/** Direct reference to the native input element for programmatic access. */
|
|
26
100
|
private _input;
|
|
101
|
+
/**
|
|
102
|
+
* Syncs `checked` and `disabled` to the native input after each render cycle.
|
|
103
|
+
*
|
|
104
|
+
* @param changed - Map of changed property names to their previous values.
|
|
105
|
+
*/
|
|
27
106
|
updated(changed: Map<string, unknown>): void;
|
|
28
107
|
static styles: import("lit").CSSResult[];
|
|
108
|
+
/**
|
|
109
|
+
* Handles the native input `change` event.
|
|
110
|
+
*
|
|
111
|
+
* On selection, deselects all sibling `moni-radio` elements with the same
|
|
112
|
+
* `name` in the same root node (document or shadow root). This is necessary
|
|
113
|
+
* because native radio group exclusion only works within the same document
|
|
114
|
+
* root and does not cross shadow DOM boundaries.
|
|
115
|
+
*
|
|
116
|
+
* After deselection, dispatches a composed `'change'` event so it is
|
|
117
|
+
* audible to parent elements in the light DOM.
|
|
118
|
+
*
|
|
119
|
+
* @param e - The native `change` event from the hidden `<input>`.
|
|
120
|
+
*/
|
|
29
121
|
private _onChange;
|
|
30
|
-
render(): import("lit
|
|
122
|
+
render(): import("lit").TemplateResult<1>;
|
|
31
123
|
}
|
|
32
124
|
declare global {
|
|
33
125
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-radio.d.ts","sourceRoot":"","sources":["../../src/components/moni-radio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-radio.d.ts","sourceRoot":"","sources":["../../src/components/moni-radio.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,qBACa,SAAU,SAAQ,WAAW;IACzC;;;;;;;OAOG;IAC0B,KAAK,SAAM;IAExC;;;;;;;OAOG;IACyC,OAAO,UAAS;IAE5D;;;;OAIG;IACyC,QAAQ,UAAS;IAE7D;;;;;;;;;;;OAWG;IAEH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAY;IAExD;;;;;;;;;OASG;IAC0B,IAAI,SAAM;IAEvC;;;;;OAKG;IAC0B,KAAK,SAAM;IAExC,4EAA4E;IAC5D,OAAO,CAAC,MAAM,CAAoB;IAElD;;;;OAIG;IACM,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAO9C,OAAgB,MAAM,4BA8GpB;IAEF;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,SAAS;IAgBR,MAAM;CAiBf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,YAAY,EAAE,SAAS,CAAC;KACxB;CACD;AAED,eAAe,SAAS,CAAC"}
|