@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,16 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-select-option.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Material Design 3 Select Option component.
|
|
14
|
+
*
|
|
15
|
+
* An individual selectable item designed to be placed inside a
|
|
16
|
+
* `<moni-select>` dropdown.
|
|
17
|
+
*
|
|
18
|
+
* **Interaction and layout:**
|
|
19
|
+
* Options are rendered as accessible `<li>` elements styled identically to
|
|
20
|
+
* `<moni-menu-item>`. When slotted into a `<moni-select>`, the parent
|
|
21
|
+
* component extracts their `value`, `label`, and `group` attributes to build
|
|
22
|
+
* its internal data model and handles the actual selection logic, keyboard
|
|
23
|
+
* navigation, and rendering within the dropdown popup.
|
|
24
|
+
*
|
|
25
|
+
* **Grouping:**
|
|
26
|
+
* Options can be categorized into subcategories by providing a `group`
|
|
27
|
+
* attribute. The parent `<moni-select>` uses this to automatically generate
|
|
28
|
+
* group headers (`<moni-select-group>`) in the dropdown list.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```html
|
|
32
|
+
* <moni-select label="Favorite framework">
|
|
33
|
+
* <!-- Standard option -->
|
|
34
|
+
* <moni-select-option value="lit">Lit Element</moni-select-option>
|
|
35
|
+
*
|
|
36
|
+
* <!-- Disabled option -->
|
|
37
|
+
* <moni-select-option value="react" disabled>React (not allowed)</moni-select-option>
|
|
38
|
+
*
|
|
39
|
+
* <!-- Grouped option -->
|
|
40
|
+
* <moni-select-option value="vue" group="Other">Vue.js</moni-select-option>
|
|
41
|
+
* </moni-select>
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @slot default - The text label for the option. If the `label` attribute is
|
|
45
|
+
* omitted, the parent `<moni-select>` will read this slot's
|
|
46
|
+
* `textContent`.
|
|
7
47
|
*
|
|
8
|
-
*
|
|
9
|
-
* - value: string value of the option
|
|
10
|
-
* - label: text label (uses textContent or slot if empty)
|
|
11
|
-
* - group: subcategory group/category name
|
|
12
|
-
* - selected: present -> active highlight state
|
|
13
|
-
* - disabled: present -> disabled
|
|
48
|
+
* @csspart item - The outer `<li>` element.
|
|
14
49
|
*/
|
|
15
50
|
@customElement('moni-select-option')
|
|
16
51
|
export class MoniSelectOption extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-select.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css, nothing } from 'lit';
|
|
2
9
|
import { customElement, property, state, query } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -7,25 +14,96 @@ import './moni-icon.js';
|
|
|
7
14
|
import './moni-progress.js';
|
|
8
15
|
import './moni-select-option.js';
|
|
9
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Internal representation of a single option within the select dropdown.
|
|
19
|
+
*
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
10
22
|
interface OptionNode {
|
|
23
|
+
/** Discriminant property that identifies this node as an option. */
|
|
11
24
|
type: 'option';
|
|
25
|
+
/** The value submitted when this option is selected. */
|
|
12
26
|
value: string;
|
|
27
|
+
/** The display label shown in the dropdown list. */
|
|
13
28
|
label: string;
|
|
29
|
+
/** When `true`, the option is non-interactive and grayed out. */
|
|
14
30
|
disabled?: boolean;
|
|
31
|
+
/** Reference to the original slotted `<moni-select-option>` element, if any. */
|
|
15
32
|
element?: HTMLElement;
|
|
33
|
+
/** Optional group name for organizing options under a `<moni-select-group>`. */
|
|
16
34
|
group?: string;
|
|
17
35
|
}
|
|
18
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Internal representation of an option group within the select dropdown.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
19
42
|
interface GroupNode {
|
|
43
|
+
/** Discriminant property that identifies this node as a group. */
|
|
20
44
|
type: 'group';
|
|
45
|
+
/** The group header label displayed above the group's options. */
|
|
21
46
|
label: string;
|
|
47
|
+
/** The options nested within this group. */
|
|
22
48
|
children: DropdownNode[];
|
|
23
49
|
}
|
|
24
50
|
|
|
51
|
+
/** Union type for any node in the dropdown tree. @internal */
|
|
25
52
|
type DropdownNode = OptionNode | GroupNode;
|
|
26
53
|
|
|
27
54
|
/**
|
|
28
|
-
*
|
|
55
|
+
* Material Design 3 Select (Dropdown) component.
|
|
56
|
+
*
|
|
57
|
+
* A fully-featured custom select dropdown with searchability, option groups,
|
|
58
|
+
* keyboard navigation, animation, and optional mobile drawer/sheet mode.
|
|
59
|
+
* Replaces the native `<select>` element with a fully styled, accessible
|
|
60
|
+
* M3-compliant alternative.
|
|
61
|
+
*
|
|
62
|
+
* **M3 spec reference:** `m3-docs/components/menus/specs.md` (dropdown menus)
|
|
63
|
+
*
|
|
64
|
+
* **Feature summary:**
|
|
65
|
+
* - Filled and outlined variants matching the M3 text field styles.
|
|
66
|
+
* - Floating label with the standard field-styles floating label animation.
|
|
67
|
+
* - Searchable mode: `searchable` attribute adds an inline filter input.
|
|
68
|
+
* - Option groups: slot `<moni-select-group>` elements for hierarchical options.
|
|
69
|
+
* - Mobile drawer: `drawer` attribute opens options in a `<moni-bottom-sheet>`
|
|
70
|
+
* instead of a dropdown popup, ideal for touch UIs.
|
|
71
|
+
* - Keyboard navigation: Arrow keys, Enter, Escape, and Tab per ARIA combobox.
|
|
72
|
+
* - Loading state: `loading` shows an indeterminate circular progress.
|
|
73
|
+
* - Multi-value support: `multiple` enables multiple selection.
|
|
74
|
+
*
|
|
75
|
+
* **Option sources:**
|
|
76
|
+
* Options can be provided in two ways:
|
|
77
|
+
* 1. **Slotted `<moni-select-option>` elements** (default, recommended for SSR).
|
|
78
|
+
* 2. **`options` property** — a `DropdownNode[]` array for fully programmatic control.
|
|
79
|
+
*
|
|
80
|
+
* **Value binding:**
|
|
81
|
+
* The `value` property holds the currently selected option's value string.
|
|
82
|
+
* For multiple selection, `values` holds `string[]`. On change, a composed
|
|
83
|
+
* `'change'` event is fired.
|
|
84
|
+
*
|
|
85
|
+
* @fires change - Bubbles and is composed. Fired when the selected value changes.
|
|
86
|
+
* Read `element.value` (or `element.values` for `multiple`).
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```html
|
|
90
|
+
* <moni-select label="Country" name="country" variant="outlined">
|
|
91
|
+
* <moni-select-option value="us">United States</moni-select-option>
|
|
92
|
+
* <moni-select-option value="gb">United Kingdom</moni-select-option>
|
|
93
|
+
* <moni-select-option value="de">Germany</moni-select-option>
|
|
94
|
+
* </moni-select>
|
|
95
|
+
*
|
|
96
|
+
* <!-- Searchable select -->
|
|
97
|
+
* <moni-select label="Language" searchable>
|
|
98
|
+
* <moni-select-option value="ts">TypeScript</moni-select-option>
|
|
99
|
+
* <moni-select-option value="py">Python</moni-select-option>
|
|
100
|
+
* </moni-select>
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* @slot default - `<moni-select-option>` or `<moni-select-group>` children.
|
|
104
|
+
*
|
|
105
|
+
* @csspart field - The outer `.field` div container.
|
|
106
|
+
* @csspart dropdown - The floating option list container.
|
|
29
107
|
*/
|
|
30
108
|
@customElement('moni-select')
|
|
31
109
|
export class MoniSelect extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-side-sheet.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css, PropertyValues } from 'lit';
|
|
2
9
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
@@ -5,24 +12,55 @@ import './moni-icon.js';
|
|
|
5
12
|
import './moni-button.js';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
|
-
* Material Design 3 Side Sheet
|
|
9
|
-
*
|
|
15
|
+
* Material Design 3 Side Sheet component.
|
|
16
|
+
*
|
|
17
|
+
* Side sheets show supplementary content that is anchored to the left or right
|
|
18
|
+
* edge of the screen. They can be standard (inline with content) or modal
|
|
19
|
+
* (overlaying content with a scrim).
|
|
20
|
+
*
|
|
21
|
+
* **M3 spec reference:** `m3-docs/components/side-sheets/specs.md`
|
|
22
|
+
*
|
|
23
|
+
* **Dialog behavior:**
|
|
24
|
+
* Internally, this component uses the native HTML `<dialog>` element for robust
|
|
25
|
+
* accessibility, focus trapping, and top-layer rendering.
|
|
26
|
+
* - When `modal=true`, the sheet uses `dialog.showModal()`, rendering a scrim
|
|
27
|
+
* backdrop and trapping focus. Pressing `Escape` closes it.
|
|
28
|
+
* - When `modal=false`, the sheet uses `dialog.show()` and remains interactive
|
|
29
|
+
* alongside the main page content.
|
|
30
|
+
*
|
|
31
|
+
* **Drag & Resize (Moni feature):**
|
|
32
|
+
* Setting the `with-handle` attribute adds a draggable grab handle to the inner
|
|
33
|
+
* edge of the sheet. Users can click and drag this handle to resize the sheet's
|
|
34
|
+
* width up to the `max-width` limit. If the user drags the sheet towards the
|
|
35
|
+
* screen edge quickly or beyond a certain threshold, it automatically closes.
|
|
36
|
+
*
|
|
37
|
+
* **Animations:**
|
|
38
|
+
* Side sheets slide in from the specified `side` (`left` or `right`). The open
|
|
39
|
+
* and close animations are handled via CSS transitions tied to the `open` property.
|
|
40
|
+
*
|
|
41
|
+
* @fires close - Fired when the side sheet is completely closed (after animations
|
|
42
|
+
* finish), either via the close button, scrim click, drag-to-close,
|
|
43
|
+
* or `Escape` key.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```html
|
|
47
|
+
* <!-- Modal side sheet on the right -->
|
|
48
|
+
* <moni-side-sheet id="details-sheet" modal title="Item Details">
|
|
49
|
+
* <p>Here is more information about the selected item.</p>
|
|
50
|
+
* <div slot="footer">
|
|
51
|
+
* <moni-button>Save</moni-button>
|
|
52
|
+
* </div>
|
|
53
|
+
* </moni-side-sheet>
|
|
10
54
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* - detached: boolean (adds 16px/16dp margins/rounded corners all around)
|
|
17
|
-
* - showClose: boolean (shows standard close button)
|
|
18
|
-
* - showBack: boolean (shows standard back button)
|
|
19
|
-
* - noBorder: boolean (removes borders, default: false)
|
|
20
|
-
* - withHandle: boolean (shows grab handle and enables dragging to close/resize, default: false)
|
|
21
|
-
* - expanded-width: string (width when expanded, default: '600px')
|
|
22
|
-
* - max-width: string (maximum width restriction, default: '100%')
|
|
55
|
+
* <!-- Resizable, detached side sheet on the left -->
|
|
56
|
+
* <moni-side-sheet side="left" detached with-handle max-width="50vw">
|
|
57
|
+
* <p>Navigation options</p>
|
|
58
|
+
* </moni-side-sheet>
|
|
59
|
+
* ```
|
|
23
60
|
*
|
|
24
|
-
*
|
|
25
|
-
* -
|
|
61
|
+
* @slot default - Main body content.
|
|
62
|
+
* @slot header - Custom header content (overrides `title`, close/back buttons remain).
|
|
63
|
+
* @slot footer - Bottom-anchored action area.
|
|
26
64
|
*/
|
|
27
65
|
@customElement('moni-side-sheet')
|
|
28
66
|
export class MoniSideSheet extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-slider.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css, nothing } from 'lit';
|
|
2
9
|
import { customElement, property, state } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -5,33 +12,58 @@ import { MoniElement, sharedStyles } from './_base/index.js';
|
|
|
5
12
|
import './moni-icon.js';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
|
-
*
|
|
15
|
+
* Material Design 3 Slider component.
|
|
16
|
+
*
|
|
17
|
+
* Sliders allow users to select a single value or a range of values from a
|
|
18
|
+
* continuous or discrete scale.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/sliders/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **Slider modes:**
|
|
23
|
+
* - **Continuous** (default) — Smooth drag between `min` and `max`. Use when
|
|
24
|
+
* the exact value does not need to be defined by the user (e.g. volume).
|
|
25
|
+
* - **Discrete** — Set `step` to snap to discrete intervals. Tick marks
|
|
26
|
+
* appear via the native `<datalist>` element in Chrome/Edge. Firefox does
|
|
27
|
+
* not render datalist ticks for range inputs.
|
|
28
|
+
* - **Range** (`range` attribute) — Two thumbs that define a minimum and
|
|
29
|
+
* maximum value within the slider's extent.
|
|
30
|
+
* - **Vertical** (`vertical` attribute) — 90° rotated slider.
|
|
31
|
+
*
|
|
32
|
+
* **Value label tooltip:**
|
|
33
|
+
* When `indicator` is set, the current value is displayed in a tooltip above
|
|
34
|
+
* (or below, via `indicator-placement`) the active thumb during focus/drag.
|
|
35
|
+
*
|
|
36
|
+
* **Tick marks:**
|
|
37
|
+
* - `ticks` attribute: adds datalist with marks at `min` and `max` only.
|
|
38
|
+
* - `tick-interval` attribute: generates datalist options at every N units
|
|
39
|
+
* between `min` and `max`, creating visible tick marks at those positions.
|
|
40
|
+
*
|
|
41
|
+
* **Internal state management:**
|
|
42
|
+
* Uses `@state()` for `_value` and `_valueHigh` so the fill track width and
|
|
43
|
+
* tooltip position update reactively on every drag `input` event without
|
|
44
|
+
* waiting for the `change` event.
|
|
45
|
+
*
|
|
46
|
+
* @fires change - Bubbles and is composed. Fired when dragging ends and the
|
|
47
|
+
* value is committed. Read `element.value` for the new value.
|
|
48
|
+
* @fires input - Fired on every drag step. Read `element.value` for the
|
|
49
|
+
* live value during drag.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```html
|
|
53
|
+
* <!-- Continuous slider -->
|
|
54
|
+
* <moni-slider name="volume" min="0" max="100" value="60"></moni-slider>
|
|
9
55
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - Track visual (span) and tooltip positions update immediately on drag
|
|
56
|
+
* <!-- Discrete slider with ticks every 10 units -->
|
|
57
|
+
* <moni-slider step="10" tick-interval="10" indicator></moni-slider>
|
|
13
58
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - Tick marks: in Chrome/Edge, native `<datalist>` ticks render at every
|
|
18
|
-
* option value. In Firefox, the datalist ticks are not rendered for
|
|
19
|
-
* range inputs; consumers can use `tick-interval` to manually generate
|
|
20
|
-
* a visual fallback if needed (P3.4 — outside the scope of this release).
|
|
21
|
-
* - State layer: hover/focus state uses CSS `::before` overlay at 0.08/0.12
|
|
22
|
-
* opacity per M3 (handled by `interaction-styles.ts`).
|
|
59
|
+
* <!-- Range slider -->
|
|
60
|
+
* <moni-slider range min="0" max="100" value="20" value-high="80"></moni-slider>
|
|
61
|
+
* ```
|
|
23
62
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* - range: present → two thumbs
|
|
29
|
-
* - ticks: present → datalist with min/max marks
|
|
30
|
-
* - tick-interval: number — when set, generates datalist options every
|
|
31
|
-
* N units between min and max. Overrides `ticks`.
|
|
32
|
-
* - indicator: present → show value tooltip on focus
|
|
33
|
-
* - indicator-placement: top (default) | bottom
|
|
34
|
-
* - inset-icon: Material Symbols name inside the colored track
|
|
63
|
+
* @csspart slider - The outer slider container.
|
|
64
|
+
* @csspart track - The track background.
|
|
65
|
+
* @csspart fill - The filled portion of the track.
|
|
66
|
+
* @csspart indicator - The value label tooltip.
|
|
35
67
|
*/
|
|
36
68
|
@customElement('moni-slider')
|
|
37
69
|
export class MoniSlider extends MoniElement {
|
|
@@ -1,37 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-snackbar.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
import './moni-icon.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
14
|
+
* Material Design 3 Snackbar component.
|
|
15
|
+
*
|
|
16
|
+
* Snackbars provide brief messages about app processes at the bottom of the
|
|
17
|
+
* screen. They disappear automatically and do not require user action,
|
|
18
|
+
* but may contain a single optional action.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/snackbar/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **Positioning model:**
|
|
23
|
+
* The snackbar uses `position: fixed` so it renders in the viewport
|
|
24
|
+
* regardless of which element it is placed in the DOM. The host element
|
|
25
|
+
* displays as `block` rather than `contents` to ensure `position: fixed`
|
|
26
|
+
* inside the shadow root anchors to the viewport (not to a stacking context
|
|
27
|
+
* created by a transformed ancestor).
|
|
8
28
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
29
|
+
* **Show/hide mechanism:**
|
|
30
|
+
* Visibility is controlled by `:host([active]) .snackbar` via CSS
|
|
31
|
+
* `opacity`, `visibility`, and `transform`. This mirrors BeerCSS's
|
|
32
|
+
* `.snackbar.active` pattern and allows CSS transition animations.
|
|
11
33
|
*
|
|
12
|
-
*
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
34
|
+
* **M3 text truncation:**
|
|
35
|
+
* The message text is clamped to `maxLines` lines with `-webkit-line-clamp`.
|
|
36
|
+
* The M3 spec requires a maximum of 2 lines; consumers can override this
|
|
37
|
+
* via the `max-lines` attribute.
|
|
15
38
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* const snackbar = document.querySelector('moni-snackbar') as MoniSnackbar;
|
|
19
42
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
43
|
+
* // Show for 3 seconds
|
|
44
|
+
* snackbar.text = 'Item deleted';
|
|
45
|
+
* snackbar.action = 'Undo';
|
|
46
|
+
* snackbar.active = true;
|
|
47
|
+
* setTimeout(() => { snackbar.active = false; }, 3000);
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @slot default - Additional content placed inside the snackbar container.
|
|
51
|
+
*
|
|
52
|
+
* @csspart snackbar - The inner snackbar container element.
|
|
53
|
+
* @csspart text - The message text element.
|
|
54
|
+
* @csspart action - The action button element.
|
|
26
55
|
*/
|
|
27
56
|
@customElement('moni-snackbar')
|
|
28
57
|
export class MoniSnackbar extends MoniElement {
|
|
58
|
+
/**
|
|
59
|
+
* The main message text displayed in the snackbar.
|
|
60
|
+
*
|
|
61
|
+
* Clamped to `maxLines` lines. Long messages are truncated with `…`.
|
|
62
|
+
* Per M3 spec, keep messages short and informative (under 60 characters).
|
|
63
|
+
*
|
|
64
|
+
* @default ''
|
|
65
|
+
*/
|
|
29
66
|
@property({ reflect: true }) text = '';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Label for the optional action button.
|
|
70
|
+
*
|
|
71
|
+
* When non-empty, renders a text button on the trailing edge of the snackbar.
|
|
72
|
+
* The component dispatches a `'action'` event when the action is clicked.
|
|
73
|
+
* This is a visual-only label — the consumer handles the action logic.
|
|
74
|
+
*
|
|
75
|
+
* @default ''
|
|
76
|
+
*/
|
|
30
77
|
@property({ reflect: true }) action = '';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Vertical placement of the snackbar on the screen.
|
|
81
|
+
*
|
|
82
|
+
* - `'bottom'` (default) — Fixed 6rem from the bottom, centered horizontally.
|
|
83
|
+
* - `'top'` — Fixed 6rem from the top, centered horizontally.
|
|
84
|
+
*
|
|
85
|
+
* @default 'bottom'
|
|
86
|
+
*/
|
|
31
87
|
@property({ reflect: true })
|
|
32
88
|
placement: 'bottom' | 'top' = 'bottom';
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* When `true`, the snackbar is visible.
|
|
92
|
+
*
|
|
93
|
+
* Toggle this attribute to show/hide the snackbar. The CSS transition
|
|
94
|
+
* handles the fade-in/slide-up animation automatically.
|
|
95
|
+
* Consumers are responsible for implementing the auto-dismiss timer.
|
|
96
|
+
*
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
33
99
|
@property({ type: Boolean, reflect: true }) active = false;
|
|
34
|
-
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Maximum number of lines of message text before it is clamped.
|
|
103
|
+
*
|
|
104
|
+
* Uses `-webkit-line-clamp` with `display: -webkit-box` for cross-browser
|
|
105
|
+
* multi-line truncation. The M3 spec recommends a maximum of 2 lines.
|
|
106
|
+
*
|
|
107
|
+
* @default 2
|
|
108
|
+
*/
|
|
35
109
|
@property({ type: Number, reflect: true, attribute: 'max-lines' })
|
|
36
110
|
maxLines = 2;
|
|
37
111
|
|
|
@@ -1,18 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-split-button.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property, queryAssignedElements } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Material Design 3 Split Button component.
|
|
14
|
+
*
|
|
15
|
+
* A split button combines a primary action button with a secondary dropdown
|
|
16
|
+
* button. The two buttons sit flush against each other, typically sharing
|
|
17
|
+
* a background color and elevation, but separated by a distinct border.
|
|
18
|
+
*
|
|
19
|
+
* **Visual architecture:**
|
|
20
|
+
* The component acts as a layout container (`display: inline-flex`) that
|
|
21
|
+
* groups two standard buttons. It overrides the margins of the trailing
|
|
22
|
+
* button to create the "connected" look (similar to connected button groups).
|
|
23
|
+
*
|
|
24
|
+
* **Usage:**
|
|
25
|
+
* Consumers must provide exactly two buttons via the named slots:
|
|
26
|
+
* - `slot="leading-button"` — The primary action (usually text or text+icon).
|
|
27
|
+
* - `slot="trailing-button"` — The secondary action (usually just a dropdown icon).
|
|
28
|
+
*
|
|
29
|
+
* Both buttons should be standard `<moni-button>` or `<moni-icon-button>`
|
|
30
|
+
* elements configured with matching variants for a cohesive appearance.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```html
|
|
34
|
+
* <moni-split-button variant="filled">
|
|
35
|
+
* <moni-button slot="leading-button" icon="send">Send</moni-button>
|
|
36
|
+
* <moni-button slot="trailing-button" icon="arrow_drop_down" id="schedule-trigger"></moni-button>
|
|
37
|
+
* </moni-split-button>
|
|
7
38
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
39
|
+
* <moni-menu id="schedule-menu" placement="bottom">
|
|
40
|
+
* <moni-menu-item>Schedule send...</moni-menu-item>
|
|
41
|
+
* </moni-menu>
|
|
42
|
+
* ```
|
|
12
43
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - trailing-button: The menu dropdown button
|
|
44
|
+
* @slot leading-button - The primary action button on the left.
|
|
45
|
+
* @slot trailing-button - The secondary action (dropdown trigger) on the right.
|
|
16
46
|
*/
|
|
17
47
|
@customElement('moni-split-button')
|
|
18
48
|
export class MoniSplitButton extends MoniElement {
|
|
@@ -1,18 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-step.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
import './moni-icon.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
14
|
+
* Material Design 3 Step component.
|
|
15
|
+
*
|
|
16
|
+
* An individual step within a `<moni-stepper>`. Steps display progress through
|
|
17
|
+
* a sequence of logical and numbered operations.
|
|
18
|
+
*
|
|
19
|
+
* **M3 spec reference:** `m3-docs/components/progress-indicators/specs.md` (Stepper pattern)
|
|
20
|
+
*
|
|
21
|
+
* **Anatomy & Visuals:**
|
|
22
|
+
* A step renders a circular indicator containing either its sequence number
|
|
23
|
+
* (automatically injected by the parent stepper) or a custom icon. Below or
|
|
24
|
+
* beside the indicator (depending on the parent's `orientation`), it renders
|
|
25
|
+
* the `title` and an optional `description`.
|
|
26
|
+
*
|
|
27
|
+
* **State management:**
|
|
28
|
+
* The parent `<moni-stepper>` automatically calculates and injects the `index`,
|
|
29
|
+
* `active`, and `completed` properties based on its current state.
|
|
30
|
+
* - **Active:** Highlighted with the primary color, indicating the current step.
|
|
31
|
+
* - **Completed:** Displayed with a solid primary background and a checkmark
|
|
32
|
+
* icon (`completed` state overrides the numeric index).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```html
|
|
36
|
+
* <!-- Typically used inside a stepper -->
|
|
37
|
+
* <moni-stepper current="1">
|
|
38
|
+
* <moni-step title="Shipping" description="Enter address"></moni-step>
|
|
39
|
+
* <moni-step title="Payment" description="Credit card details"></moni-step>
|
|
40
|
+
* <moni-step title="Review" description="Confirm order"></moni-step>
|
|
41
|
+
* </moni-stepper>
|
|
42
|
+
*
|
|
43
|
+
* <!-- Overriding the icon -->
|
|
44
|
+
* <moni-step title="Done" icon="celebration"></moni-step>
|
|
45
|
+
* ```
|
|
8
46
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - active: present → primary color highlight
|
|
13
|
-
* - completed: present → filled circle with check
|
|
14
|
-
* - icon: Material Symbols name (overrides the number)
|
|
15
|
-
* - index: numeric label (auto-set by parent stepper, optional)
|
|
47
|
+
* @csspart step-indicator - The circular badge containing the number/icon.
|
|
48
|
+
* @csspart title - The main title text.
|
|
49
|
+
* @csspart description - The secondary description text.
|
|
16
50
|
*/
|
|
17
51
|
@customElement('moni-step')
|
|
18
52
|
export class MoniStep extends MoniElement {
|
|
@@ -1,15 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-stepper.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css } from 'lit';
|
|
2
9
|
import { customElement, property, queryAssignedElements } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
import type { MoniStep } from './moni-step.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
14
|
+
* Material Design 3 Stepper component.
|
|
15
|
+
*
|
|
16
|
+
* A container for a linear progression of `<moni-step>` elements. Steppers
|
|
17
|
+
* convey progress through numbered steps and indicate the user's current
|
|
18
|
+
* position within a flow.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/progress-indicators/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **Orchestration:**
|
|
23
|
+
* This component acts as the orchestrator for its slotted `<moni-step>` children.
|
|
24
|
+
* Whenever the `current` property changes, or children are added/removed, the
|
|
25
|
+
* stepper iterates over all child steps and injects their state:
|
|
26
|
+
* - Assigns the sequential `index` (0-based) to each step.
|
|
27
|
+
* - Sets `active=true` on the step matching the `current` index.
|
|
28
|
+
* - Sets `completed=true` on all steps prior to the `current` index.
|
|
29
|
+
*
|
|
30
|
+
* **Visual layout:**
|
|
31
|
+
* The stepper manages the layout (flex row or column based on `orientation`)
|
|
32
|
+
* and ensures the connector lines between steps are rendered correctly via
|
|
33
|
+
* CSS pseudo-elements defined in the child `<moni-step>` styling.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <moni-stepper current="1" orientation="horizontal">
|
|
38
|
+
* <moni-step title="Step 1"></moni-step>
|
|
39
|
+
* <moni-step title="Step 2"></moni-step>
|
|
40
|
+
* <moni-step title="Step 3"></moni-step>
|
|
41
|
+
* </moni-stepper>
|
|
42
|
+
*
|
|
43
|
+
* <script>
|
|
44
|
+
* const stepper = document.querySelector('moni-stepper');
|
|
45
|
+
* // Move to next step
|
|
46
|
+
* stepper.current = 2;
|
|
47
|
+
* </script>
|
|
48
|
+
* ```
|
|
9
49
|
*
|
|
10
|
-
*
|
|
11
|
-
* - orientation: horizontal (default) | vertical
|
|
12
|
-
* - current: zero-based index of the active step
|
|
50
|
+
* @slot default - `<moni-step>` elements.
|
|
13
51
|
*/
|
|
14
52
|
@customElement('moni-stepper')
|
|
15
53
|
export class MoniStepper extends MoniElement {
|