@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,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-switch.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, query } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -5,33 +12,111 @@ import { MoniElement, sharedStyles } from './_base/index.js';
|
|
|
5
12
|
import './moni-icon.js';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
|
-
*
|
|
15
|
+
* Material Design 3 Switch component.
|
|
16
|
+
*
|
|
17
|
+
* Switches toggle the state of a single setting on or off. They are the
|
|
18
|
+
* binary on/off equivalent of a checkbox, but optimized for toggling a
|
|
19
|
+
* single state rather than selecting from a list.
|
|
20
|
+
*
|
|
21
|
+
* **M3 spec reference:** `m3-docs/components/switch/specs.md`
|
|
22
|
+
*
|
|
23
|
+
* **M3 measurements:**
|
|
24
|
+
* - Track: 52dp × 32dp, 2dp border, full-radius pill shape.
|
|
25
|
+
* - Handle (thumb): 16dp unselected → 24dp selected → 28dp pressed.
|
|
26
|
+
* - State layer: 40dp circular ripple on hover/focus/pressed states.
|
|
27
|
+
* - Icon (optional): 16dp icon rendered inside the thumb when `icon` is set.
|
|
28
|
+
*
|
|
29
|
+
* **Visual architecture:**
|
|
30
|
+
* Like `<moni-checkbox>`, the native `<input type="checkbox" role="switch">`
|
|
31
|
+
* occupies real layout space but is visually hidden via `opacity: 0`. Two
|
|
32
|
+
* `<span>` pseudo-elements render the track (`::after`) and thumb (`::before`).
|
|
33
|
+
* When `icon=true`, `<i>` elements render `close` and `check` glyphs inside
|
|
34
|
+
* the thumb, with visibility toggled via CSS based on the checked state.
|
|
9
35
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - Handle (thumb): 16dp unselected, 24dp selected, 28dp pressed
|
|
13
|
-
* - State layer: 40dp circular ripple on hover/focus/pressed
|
|
14
|
-
* - Icon (optional): 16dp on selected and/or unselected handle
|
|
36
|
+
* @fires change - Bubbles and is composed. Fired when the switch is toggled.
|
|
37
|
+
* Read `element.checked` for the new state.
|
|
15
38
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```html
|
|
41
|
+
* <moni-switch label="Dark mode" name="dark-mode"></moni-switch>
|
|
42
|
+
* <moni-switch icon checked label="Notifications"></moni-switch>
|
|
43
|
+
*
|
|
44
|
+
* <script>
|
|
45
|
+
* document.querySelector('moni-switch').addEventListener('change', (e) => {
|
|
46
|
+
* console.log('enabled:', e.target.checked);
|
|
47
|
+
* });
|
|
48
|
+
* </script>
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @csspart switch - The outer `<label>` element containing the switch.
|
|
23
52
|
*/
|
|
24
53
|
@customElement('moni-switch')
|
|
25
54
|
export class MoniSwitch extends MoniElement {
|
|
55
|
+
/**
|
|
56
|
+
* Text label displayed to the right of the switch.
|
|
57
|
+
*
|
|
58
|
+
* When non-empty, renders as a padded text span after the track.
|
|
59
|
+
* When empty, the default slot is rendered, allowing custom HTML labels.
|
|
60
|
+
*
|
|
61
|
+
* @default ''
|
|
62
|
+
*/
|
|
26
63
|
@property({ reflect: true }) label = '';
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Whether the switch is in the "on" (checked) state.
|
|
67
|
+
*
|
|
68
|
+
* When `true`:
|
|
69
|
+
* - Track fills with `--primary` color.
|
|
70
|
+
* - Thumb grows from 16dp to 24dp and slides to the trailing edge.
|
|
71
|
+
* - Thumb color changes to `--on-primary`.
|
|
72
|
+
*
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
27
75
|
@property({ type: Boolean, reflect: true }) checked = false;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* When `true`, the switch is non-interactive and renders at 50% opacity.
|
|
79
|
+
*
|
|
80
|
+
* @default false
|
|
81
|
+
*/
|
|
28
82
|
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* When `true`, renders icon glyphs inside the thumb.
|
|
86
|
+
*
|
|
87
|
+
* Uses Material Symbols ligatures:
|
|
88
|
+
* - Unchecked state: `close` icon.
|
|
89
|
+
* - Checked state: `check` icon.
|
|
90
|
+
*
|
|
91
|
+
* The icon size (16dp) is set via the `--_thumb` CSS custom property.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
29
95
|
@property({ type: Boolean, reflect: true }) icon = false;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Forwarded to the native `<input name>` attribute for form participation.
|
|
99
|
+
*
|
|
100
|
+
* @default ''
|
|
101
|
+
*/
|
|
30
102
|
@property({ reflect: true }) name = '';
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Forwarded to the native `<input value>` attribute.
|
|
106
|
+
* The value submitted in a form when this switch is checked.
|
|
107
|
+
*
|
|
108
|
+
* @default ''
|
|
109
|
+
*/
|
|
31
110
|
@property({ reflect: true }) value = '';
|
|
32
111
|
|
|
112
|
+
/** Direct reference to the native input element for programmatic access. */
|
|
33
113
|
@query('input') private _input!: HTMLInputElement;
|
|
34
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Syncs `checked` and `disabled` imperatively to the native input after render.
|
|
117
|
+
*
|
|
118
|
+
* @param changed - Map of changed property names to their previous values.
|
|
119
|
+
*/
|
|
35
120
|
override updated(changed: Map<string, unknown>) {
|
|
36
121
|
if (this._input) {
|
|
37
122
|
if (changed.has('checked')) this._input.checked = this.checked;
|
|
@@ -39,6 +124,14 @@ export class MoniSwitch extends MoniElement {
|
|
|
39
124
|
}
|
|
40
125
|
}
|
|
41
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Handles the native input `change` event.
|
|
129
|
+
*
|
|
130
|
+
* Updates `this.checked` and re-dispatches a composed `'change'` event
|
|
131
|
+
* so it bubbles across shadow DOM boundaries.
|
|
132
|
+
*
|
|
133
|
+
* @param e - The native `change` event from the hidden `<input>`.
|
|
134
|
+
*/
|
|
42
135
|
private _onChange(e: Event) {
|
|
43
136
|
this.checked = (e.target as HTMLInputElement).checked;
|
|
44
137
|
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
@@ -1,17 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-tab.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
|
-
*
|
|
8
|
-
*
|
|
14
|
+
* Material Design 3 Tab component.
|
|
15
|
+
*
|
|
16
|
+
* An individual interactive tab element designed to be placed inside a
|
|
17
|
+
* `<moni-tabs>` container. Tabs organize content across different screens,
|
|
18
|
+
* data sets, and other interactions.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/tabs/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **Visual layout & interaction:**
|
|
23
|
+
* Internally renders as an `<a>` element to support native link behavior when
|
|
24
|
+
* an `href` is provided, but behaves visually as a tab button. It displays a
|
|
25
|
+
* text label and an optional Material icon. If the parent `<moni-tabs>` has the
|
|
26
|
+
* `vertical` attribute set, the layout automatically adjusts to stack the icon
|
|
27
|
+
* above the text.
|
|
28
|
+
*
|
|
29
|
+
* **State:**
|
|
30
|
+
* The `active` attribute highlights the tab, applying the primary color to the
|
|
31
|
+
* text and rendering the active indicator line (handled via CSS in the parent
|
|
32
|
+
* container or pseudo-elements).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```html
|
|
36
|
+
* <moni-tabs>
|
|
37
|
+
* <moni-tab active icon="home" label="Home"></moni-tab>
|
|
38
|
+
* <moni-tab icon="settings" label="Settings" href="/settings"></moni-tab>
|
|
39
|
+
* </moni-tabs>
|
|
40
|
+
* ```
|
|
9
41
|
*
|
|
10
|
-
*
|
|
11
|
-
* - active: present → active style
|
|
12
|
-
* - icon: Material Symbols name
|
|
13
|
-
* - label: tab text
|
|
14
|
-
* - href: link target
|
|
42
|
+
* @csspart tab - The inner `<a>` element acting as the tab button.
|
|
15
43
|
*/
|
|
16
44
|
@customElement('moni-tab')
|
|
17
45
|
export class MoniTab extends MoniElement {
|
|
@@ -1,20 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-tabs.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
|
-
*
|
|
7
|
-
*
|
|
13
|
+
* Material Design 3 Tabs container component.
|
|
14
|
+
*
|
|
15
|
+
* A navigational container that groups multiple `<moni-tab>` elements. Tabs
|
|
16
|
+
* organize content into high-level categories and allow the user to switch
|
|
17
|
+
* between them.
|
|
18
|
+
*
|
|
19
|
+
* **M3 spec reference:** `m3-docs/components/tabs/specs.md`
|
|
20
|
+
*
|
|
21
|
+
* **Modes (Primary vs Secondary):**
|
|
22
|
+
* - `primary` (default): Used for top-level navigation at the highest hierarchy,
|
|
23
|
+
* often placed directly below a top app bar. They span the full width and
|
|
24
|
+
* feature a prominent active indicator.
|
|
25
|
+
* - `secondary`: Used for deeper content hierarchies within a specific area
|
|
26
|
+
* or page. They are typically more subtle.
|
|
27
|
+
*
|
|
28
|
+
* **Layout & Alignment:**
|
|
29
|
+
* - `scrollable`: If the number of tabs exceeds the container width, this
|
|
30
|
+
* enables horizontal scrolling (`overflow-x: auto`) rather than squishing.
|
|
31
|
+
* - `align`: Controls how the tabs are distributed (`default` space-around,
|
|
32
|
+
* `left`, `center`, or `right`).
|
|
33
|
+
* - `vertical`: Stacks the icon above the text label inside the child tabs.
|
|
34
|
+
*
|
|
35
|
+
* **Active Indicator:**
|
|
36
|
+
* The `indicator-size` attribute allows customizing the width of the active
|
|
37
|
+
* underline indicator (`default` fits the tab content, `min` is narrow, `max`
|
|
38
|
+
* fills the full tab width).
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```html
|
|
42
|
+
* <!-- Primary, scrollable tabs -->
|
|
43
|
+
* <moni-tabs scrollable>
|
|
44
|
+
* <moni-tab active label="Flights"></moni-tab>
|
|
45
|
+
* <moni-tab label="Trips"></moni-tab>
|
|
46
|
+
* <moni-tab label="Explore"></moni-tab>
|
|
47
|
+
* </moni-tabs>
|
|
8
48
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
49
|
+
* <!-- Secondary, centered tabs with vertical layout -->
|
|
50
|
+
* <moni-tabs mode="secondary" align="center" vertical>
|
|
51
|
+
* <moni-tab active icon="video_camera_front" label="Video"></moni-tab>
|
|
52
|
+
* <moni-tab icon="photo_camera" label="Photo"></moni-tab>
|
|
53
|
+
* </moni-tabs>
|
|
54
|
+
* ```
|
|
15
55
|
*
|
|
16
|
-
*
|
|
17
|
-
* - default: <moni-tab> children
|
|
56
|
+
* @slot default - `<moni-tab>` child elements.
|
|
18
57
|
*/
|
|
19
58
|
@customElement('moni-tabs')
|
|
20
59
|
export class MoniTabs extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-text-field.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, nothing } from 'lit';
|
|
2
9
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -7,17 +14,56 @@ import './moni-icon.js';
|
|
|
7
14
|
import './moni-progress.js';
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
17
|
+
* Material Design 3 Text Field component.
|
|
18
|
+
*
|
|
19
|
+
* A full-featured input field that wraps a native `<input>` inside the M3
|
|
20
|
+
* field shell (`.field` class from `fieldStyles`). Supports floating labels,
|
|
21
|
+
* filled and outlined variants, leading/trailing icons, helper text, and
|
|
22
|
+
* error states.
|
|
23
|
+
*
|
|
24
|
+
* **M3 spec reference:** `m3-docs/components/text-fields/specs.md`
|
|
25
|
+
*
|
|
26
|
+
* **Visual architecture:**
|
|
27
|
+
* Uses `fieldStyles` for the complete CSS field shell. The field container
|
|
28
|
+
* is a `<div class="field [modifiers]">` wrapping:
|
|
29
|
+
* 1. Optional leading icon.
|
|
30
|
+
* 2. Native `<input>` element.
|
|
31
|
+
* 3. Floating `<label>` (when `label` is set).
|
|
32
|
+
* 4. Optional trailing icon or loading spinner.
|
|
33
|
+
* 5. `<output>` for helper/error text.
|
|
34
|
+
*
|
|
35
|
+
* **Visual-only contract:**
|
|
36
|
+
* This component does **not** listen to `@input` events to sync the `value`
|
|
37
|
+
* attribute back from the underlying `<input>`. Consumers must either:
|
|
38
|
+
* - Submit the native form (the `<input name>` participates in form submission).
|
|
39
|
+
* - Listen to `change` or `input` events via standard DOM event handling.
|
|
40
|
+
* - Use a framework binding (e.g. `bind:value` in Svelte, `v-model` in Vue).
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```html
|
|
44
|
+
* <moni-text-field
|
|
45
|
+
* label="Email address"
|
|
46
|
+
* type="email"
|
|
47
|
+
* name="email"
|
|
48
|
+
* icon="mail"
|
|
49
|
+
* variant="outlined"
|
|
50
|
+
* helper="We'll never share your email."
|
|
51
|
+
* ></moni-text-field>
|
|
12
52
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
53
|
+
* <moni-text-field
|
|
54
|
+
* label="Amount"
|
|
55
|
+
* type="number"
|
|
56
|
+
* prefix="$"
|
|
57
|
+
* error
|
|
58
|
+
* error-text="Value must be positive"
|
|
59
|
+
* ></moni-text-field>
|
|
60
|
+
* ```
|
|
16
61
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
62
|
+
* @csspart field - The outer `.field` div container.
|
|
63
|
+
* @csspart input - The native `<input>` element.
|
|
64
|
+
* @csspart label - The floating `<label>` element.
|
|
65
|
+
* @csspart helper - The helper `<output>` element.
|
|
66
|
+
* @csspart error-output - The error `<output>` element.
|
|
21
67
|
*/
|
|
22
68
|
@customElement('moni-text-field')
|
|
23
69
|
export class MoniTextField extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-textarea.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, nothing } from 'lit';
|
|
2
9
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -7,26 +14,50 @@ import './moni-icon.js';
|
|
|
7
14
|
import './moni-progress.js';
|
|
8
15
|
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
17
|
+
* Material Design 3 Textarea component.
|
|
18
|
+
*
|
|
19
|
+
* A multi-line text input field designed for collecting longer amounts of text,
|
|
20
|
+
* such as comments, descriptions, or messages.
|
|
21
|
+
*
|
|
22
|
+
* **M3 spec reference:** `m3-docs/components/text-fields/specs.md`
|
|
23
|
+
*
|
|
24
|
+
* **Visual architecture:**
|
|
25
|
+
* It shares the exact same `.field` shell and styling engine as
|
|
26
|
+
* `<moni-text-field>`, but internally renders a native `<textarea>` instead
|
|
27
|
+
* of an `<input>`. This ensures visual consistency across all form elements
|
|
28
|
+
* regarding floating labels, helper text, error states, and icons.
|
|
29
|
+
*
|
|
30
|
+
* **Character Counter:**
|
|
31
|
+
* If the `maxlength` attribute is set, the textarea automatically displays
|
|
32
|
+
* a character counter (`{current length} / {maxlength}`) positioned at the
|
|
33
|
+
* trailing edge of the supporting text area (bottom right). This can be
|
|
34
|
+
* suppressed by setting the `no-counter` attribute.
|
|
35
|
+
*
|
|
36
|
+
* **State management:**
|
|
37
|
+
* This component is purely visual and presentational. It reflects attributes
|
|
38
|
+
* down to the native textarea, but it does NOT attach internal `@input` or
|
|
39
|
+
* `@change` listeners. Consumers should attach standard DOM listeners directly
|
|
40
|
+
* to this element to capture user input, just as they would with a native
|
|
41
|
+
* textarea.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```html
|
|
45
|
+
* <!-- Standard filled textarea -->
|
|
46
|
+
* <moni-textarea label="Description" rows="4"></moni-textarea>
|
|
12
47
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
48
|
+
* <!-- Outlined textarea with character counter -->
|
|
49
|
+
* <moni-textarea
|
|
50
|
+
* variant="outlined"
|
|
51
|
+
* label="Bio"
|
|
52
|
+
* maxlength="160"
|
|
53
|
+
* ></moni-textarea>
|
|
54
|
+
* ```
|
|
17
55
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* - prefix: short text rendered before the input (e.g. "https://")
|
|
24
|
-
* - suffix: short text rendered after the input (e.g. ".com")
|
|
25
|
-
* - loading: present → shows indeterminate circular progress
|
|
26
|
-
* - rows: native textarea rows attribute (default 3)
|
|
27
|
-
* - maxlength: when set, displays a character counter
|
|
28
|
-
* (auto-shown; can be hidden via `no-counter`)
|
|
29
|
-
* - no-counter: suppress the character counter even when maxlength is set
|
|
56
|
+
* @csspart field - The outer `.field` div container.
|
|
57
|
+
* @csspart input - The native `<textarea>` element.
|
|
58
|
+
* @csspart label - The floating `<label>` element.
|
|
59
|
+
* @csspart helper - The helper/error text area.
|
|
60
|
+
* @csspart counter - The character counter element.
|
|
30
61
|
*/
|
|
31
62
|
@customElement('moni-textarea')
|
|
32
63
|
export class MoniTextarea extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-time-picker.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, state, query } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
@@ -5,18 +12,42 @@ import './moni-icon.js';
|
|
|
5
12
|
import './moni-button.js';
|
|
6
13
|
|
|
7
14
|
/**
|
|
8
|
-
* Material Design 3 Time Picker
|
|
9
|
-
*
|
|
15
|
+
* Material Design 3 Time Picker component.
|
|
16
|
+
*
|
|
17
|
+
* A highly interactive control that allows users to select a specific time.
|
|
18
|
+
* It provides two distinct input modes:
|
|
19
|
+
* 1. **Dial mode:** An interactive clock face where users can drag or click
|
|
20
|
+
* to select hours and minutes.
|
|
21
|
+
* 2. **Input mode:** Standard text inputs for precise keyboard entry.
|
|
22
|
+
*
|
|
23
|
+
* **M3 spec reference:** `m3-docs/components/time-pickers/specs.md`
|
|
24
|
+
*
|
|
25
|
+
* **Time formats & modes:**
|
|
26
|
+
* - The `value` property expects and always outputs a 24-hour formatted string
|
|
27
|
+
* (`HH:MM`, e.g., `"14:30"`).
|
|
28
|
+
* - Setting `use-24-hour` configures the visual presentation to use a 24-hour
|
|
29
|
+
* clock dial (inner and outer rings) and removes the AM/PM toggle. Otherwise,
|
|
30
|
+
* it uses a standard 12-hour dial with an AM/PM toggle.
|
|
31
|
+
*
|
|
32
|
+
* **Responsive design:**
|
|
33
|
+
* The `orientation` attribute configures the layout. `vertical` stacks the
|
|
34
|
+
* time display above the clock face, `horizontal` places them side-by-side,
|
|
35
|
+
* and `auto` responds to the container/viewport width automatically.
|
|
36
|
+
*
|
|
37
|
+
* @fires change - Fired when the selected time changes interactively. The
|
|
38
|
+
* `detail.value` contains the new time in `HH:MM` format.
|
|
39
|
+
* @fires cancel - Fired when the 'Cancel' button is clicked.
|
|
40
|
+
* @fires ok - Fired when the 'OK' button is clicked. The `detail.value`
|
|
41
|
+
* contains the final confirmed time.
|
|
10
42
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```html
|
|
45
|
+
* <!-- 12-hour format (AM/PM) -->
|
|
46
|
+
* <moni-time-picker value="14:30"></moni-time-picker>
|
|
15
47
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - ok: Fired when OK button is clicked (detail: { value })
|
|
48
|
+
* <!-- 24-hour format -->
|
|
49
|
+
* <moni-time-picker use-24-hour value="14:30"></moni-time-picker>
|
|
50
|
+
* ```
|
|
20
51
|
*/
|
|
21
52
|
@customElement('moni-time-picker')
|
|
22
53
|
export class MoniTimePicker extends MoniElement {
|
|
@@ -1,26 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-toolbar.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
|
-
* Material 3
|
|
13
|
+
* Material Design 3 Top App Bar (Toolbar) component.
|
|
14
|
+
*
|
|
15
|
+
* Top app bars display information and actions at the top of a screen.
|
|
16
|
+
* They are used for branding, screen titles, navigation, and actions.
|
|
17
|
+
*
|
|
18
|
+
* **M3 spec reference:** `m3-docs/components/top-app-bar/specs.md`
|
|
19
|
+
*
|
|
20
|
+
* **Note:** This is the standard top-level toolbar. For bottom navigation
|
|
21
|
+
* bars (often used on mobile), use `<moni-app-bar>`.
|
|
22
|
+
*
|
|
23
|
+
* **Variants:**
|
|
24
|
+
* - `standard` (default): A full-width bar (64dp height) that sits flush
|
|
25
|
+
* against the top of the screen.
|
|
26
|
+
* - `floating`: A detached bar with a 4dp margin and rounded 8dp corners,
|
|
27
|
+
* appearing to float above the content.
|
|
7
28
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
29
|
+
* **Scroll behavior:**
|
|
30
|
+
* When the `scroll` attribute is present, the toolbar visually responds to
|
|
31
|
+
* scrolling by increasing its elevation (shadow) and dynamically shifting
|
|
32
|
+
* its surface color to indicate depth over the scrolling content.
|
|
10
33
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```html
|
|
36
|
+
* <!-- Standard toolbar with navigation and actions -->
|
|
37
|
+
* <moni-toolbar title="Inbox">
|
|
38
|
+
* <moni-icon-button slot="leading" icon="menu"></moni-icon-button>
|
|
39
|
+
* <moni-icon-button slot="trailing" icon="search"></moni-icon-button>
|
|
40
|
+
* <moni-icon-button slot="trailing" icon="more_vert"></moni-icon-button>
|
|
41
|
+
* </moni-toolbar>
|
|
14
42
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
43
|
+
* <!-- Floating toolbar with an attached FAB -->
|
|
44
|
+
* <moni-toolbar type="floating" title="Notes">
|
|
45
|
+
* <moni-fab slot="action-button" icon="add"></moni-fab>
|
|
46
|
+
* </moni-toolbar>
|
|
47
|
+
* ```
|
|
20
48
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
49
|
+
* @slot default - The title text or center content.
|
|
50
|
+
* @slot leading - Navigation icon/button placed on the far left.
|
|
51
|
+
* @slot trailing - Action icons/buttons placed on the far right.
|
|
52
|
+
* @slot action-button - A floating action button (FAB) anchored to the right side.
|
|
24
53
|
*/
|
|
25
54
|
@customElement('moni-toolbar')
|
|
26
55
|
export class MoniToolbar extends MoniElement {
|
|
@@ -1,36 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-tooltip.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
|
-
*
|
|
7
|
-
*
|
|
13
|
+
* Material Design 3 Tooltip component.
|
|
14
|
+
*
|
|
15
|
+
* Tooltips provide contextual text labels or rich content that appear when
|
|
16
|
+
* users hover over, focus on, or tap an element. They surface supplementary
|
|
17
|
+
* information that helps users understand interface elements without
|
|
18
|
+
* permanently occupying screen space.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/tooltips/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **Types:**
|
|
23
|
+
* - **Plain** (default) — Text-only label for simple descriptions (max 1 line).
|
|
24
|
+
* - **Rich** (`rich` attribute) — HTML content including formatted text,
|
|
25
|
+
* links, and icons. Rich tooltips can contain multiple lines and action links.
|
|
26
|
+
*
|
|
27
|
+
* **Placements:**
|
|
28
|
+
* - `top` (default), `top-start`, `top-end`
|
|
29
|
+
* - `bottom`, `bottom-start`, `bottom-end`
|
|
30
|
+
*
|
|
31
|
+
* **Trigger mechanism:**
|
|
32
|
+
* The tooltip uses `position: absolute` inside the parent element. The parent
|
|
33
|
+
* must have `position: relative` (set automatically via `connectedCallback`).
|
|
34
|
+
* Hover/focus events on the parent trigger the tooltip's CSS `:hover` and
|
|
35
|
+
* `:focus-within` selectors, which drive the show/hide transition.
|
|
36
|
+
*
|
|
37
|
+
* **Accessibility:**
|
|
38
|
+
* - The tooltip has `role="tooltip"`.
|
|
39
|
+
* - For keyboard accessibility, the parent should have `aria-describedby`
|
|
40
|
+
* pointing to the tooltip's `id` attribute. The component exposes a
|
|
41
|
+
* `tooltipId` getter for this purpose.
|
|
42
|
+
* - The `Escape` key closes rich tooltips.
|
|
8
43
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```html
|
|
46
|
+
* <!-- Plain tooltip -->
|
|
47
|
+
* <button aria-describedby="save-tip">
|
|
48
|
+
* Save
|
|
49
|
+
* <moni-tooltip id="save-tip" text="Ctrl+S"></moni-tooltip>
|
|
50
|
+
* </button>
|
|
14
51
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
52
|
+
* <!-- Rich tooltip -->
|
|
53
|
+
* <button>
|
|
54
|
+
* Filter
|
|
55
|
+
* <moni-tooltip rich position="bottom">
|
|
56
|
+
* <strong>Filter by date</strong>
|
|
57
|
+
* <p>Select a date range to filter results.</p>
|
|
58
|
+
* </moni-tooltip>
|
|
59
|
+
* </button>
|
|
60
|
+
* ```
|
|
18
61
|
*
|
|
19
|
-
*
|
|
20
|
-
* - The tooltip has `role="tooltip"` (M3 spec).
|
|
21
|
-
* - When `rich` content is used, the parent should also have
|
|
22
|
-
* `aria-describedby="<tooltip-id>"`. The component sets a unique `id` on
|
|
23
|
-
* the tooltip element and exposes it via `tooltipId` getter.
|
|
24
|
-
* - `Escape` closes the tooltip (WAI-ARIA tooltip pattern).
|
|
62
|
+
* @slot default - Rich content for the tooltip body (only used when `rich=true`).
|
|
25
63
|
*
|
|
26
|
-
*
|
|
27
|
-
* - text: tooltip text (plain tooltip)
|
|
28
|
-
* - position: top (default) | top-start | top-end | bottom | bottom-start | bottom-end
|
|
29
|
-
* - size: '' (default) | small | medium | large
|
|
30
|
-
* - rich: boolean — when true, the default slot accepts arbitrary HTML
|
|
31
|
-
* for rich content (links, icons, etc.). When false (default),
|
|
32
|
-
* the slot is rendered as text only.
|
|
33
|
-
* - id: forwarded to the tooltip element (useful for aria-describedby)
|
|
64
|
+
* @csspart tooltip - The tooltip container element.
|
|
34
65
|
*/
|
|
35
66
|
@customElement('moni-tooltip')
|
|
36
67
|
export class MoniTooltip extends MoniElement {
|