@moni-labs/moni-ui 0.2.0 → 0.3.1
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 +1709 -338
- 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 +80 -17
- package/dist/components/moni-carousel.d.ts.map +1 -1
- package/dist/components/moni-carousel.js +258 -34
- 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 +282 -34
- 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,31 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-fab.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 } 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 Floating Action Button (FAB) component.
|
|
15
|
+
*
|
|
16
|
+
* FABs represent the primary, or most common, action on a screen. They appear
|
|
17
|
+
* in front of all screen content, typically as a circular shape with an icon in
|
|
18
|
+
* its center.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/floating-action-buttons/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **M3 Expressive Updates & Deprecations (May 2025):**
|
|
23
|
+
* - `size="small"` is **no longer recommended** by M3. Use `medium` (40dp or 56dp)
|
|
24
|
+
* or `large` (96dp). Deprecated in v0.3.1; will be removed in v1.0.
|
|
25
|
+
* - `shape="circle"` is **not part of M3**. M3 FABs use a `rounded` shape with a
|
|
26
|
+
* 16dp corner radius (which morphs to a `full` radius on hover/focus).
|
|
27
|
+
* Deprecated in v0.3.1; will be removed in v1.0.
|
|
28
|
+
* - `color="surface"` is **no longer recommended**. Use `primary`, `secondary`,
|
|
29
|
+
* or `tertiary` to ensure proper color mapping to the M3 theme.
|
|
30
|
+
*
|
|
31
|
+
* **Extended FABs:**
|
|
32
|
+
* When `extended` is true, the FAB displays a text label next to the icon.
|
|
33
|
+
* Extended FABs are wider and are typically used when the action needs explicit
|
|
34
|
+
* text to be clear. The `expanded` attribute forces the FAB to its full extended
|
|
35
|
+
* width, useful for animating between standard and extended states on scroll.
|
|
36
|
+
*
|
|
37
|
+
* **Positioning:**
|
|
38
|
+
* The `position` attribute applies predefined absolute/fixed positioning
|
|
39
|
+
* (e.g. `bottom-trailing`), snapping the FAB to standard screen corners.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```html
|
|
43
|
+
* <!-- Standard primary FAB -->
|
|
44
|
+
* <moni-fab icon="edit"></moni-fab>
|
|
45
|
+
*
|
|
46
|
+
* <!-- Extended tertiary FAB -->
|
|
47
|
+
* <moni-fab color="tertiary" extended icon="add" label="New task"></moni-fab>
|
|
8
48
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - `shape="circle"` is **not part of M3**; M3 FABs are `rounded` with a 16dp
|
|
13
|
-
* corner radius (or `full` when on hover/focus). The M3 spec does not
|
|
14
|
-
* define a perfect-circle FAB. Deprecated in v0.3.1; will be removed in v1.0.
|
|
15
|
-
* - `color="surface"` is **no longer recommended** by M3. Use `primary`,
|
|
16
|
-
* `secondary`, or `tertiary` (and their container variants).
|
|
49
|
+
* <!-- Positioned FAB -->
|
|
50
|
+
* <moni-fab position="bottom-trailing" icon="navigation"></moni-fab>
|
|
51
|
+
* ```
|
|
17
52
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* -
|
|
21
|
-
* - shape: rounded (default) (circle: deprecated)
|
|
22
|
-
* - extended: present → wider with label always visible
|
|
23
|
-
* - expanded: present → force expanded
|
|
24
|
-
* - disabled: present
|
|
25
|
-
* - icon: Material Symbols name
|
|
26
|
-
* - label: text when extended
|
|
27
|
-
* - position: bottom-trailing (default) | bottom-leading
|
|
28
|
-
* | top-trailing | top-leading
|
|
53
|
+
* @csspart button - The internal `<button>` element.
|
|
54
|
+
* @csspart icon - The container for the icon.
|
|
55
|
+
* @csspart label - The text label (only visible when extended).
|
|
29
56
|
*/
|
|
30
57
|
@customElement('moni-fab')
|
|
31
58
|
export class MoniFab extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-file-field.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, query } from 'lit/decorators.js';
|
|
3
10
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -6,21 +13,55 @@ import { MoniElement, sharedStyles, fieldStyles } from './_base/index.js';
|
|
|
6
13
|
import './moni-icon.js';
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* Material Design 3 File Field component.
|
|
17
|
+
*
|
|
18
|
+
* A specialized field component that provides a styled, accessible alternative
|
|
19
|
+
* to the native `<input type="file">`. It wraps a native file input inside
|
|
20
|
+
* the M3 `.field` shell and presents a read-only text input showing the
|
|
21
|
+
* selected file name(s) alongside a stylized "Choose file" action button.
|
|
22
|
+
*
|
|
23
|
+
* **Visual architecture:**
|
|
24
|
+
* The component leverages the `fieldStyles` CSS patterns. The internal DOM
|
|
25
|
+
* structure is specifically ordered as:
|
|
26
|
+
* `[text input] -> [label] -> [file input] -> [output]`
|
|
27
|
+
* This specific ordering ensures that the CSS adjacent sibling selector
|
|
28
|
+
* (`input + label`) can correctly float the label when the field is populated,
|
|
29
|
+
* even though the visible field is actually the read-only text input.
|
|
30
|
+
*
|
|
31
|
+
* **State management:**
|
|
32
|
+
* When the user selects files via the hidden file input, the component listens
|
|
33
|
+
* for the native `change` event, reads `input.files`, and updates the read-only
|
|
34
|
+
* text input with a comma-separated list of file names. The `value` property
|
|
35
|
+
* is kept in sync, and a composed `'change'` event is re-dispatched.
|
|
36
|
+
*
|
|
37
|
+
* @fires change - Bubbles and is composed. Fired when files are selected or
|
|
38
|
+
* cleared. The consumer can read the internal input's `files`
|
|
39
|
+
* list by querying the component.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```html
|
|
43
|
+
* <!-- Single file upload -->
|
|
44
|
+
* <moni-file-field
|
|
45
|
+
* label="Profile picture"
|
|
46
|
+
* name="avatar"
|
|
47
|
+
* accept="image/png, image/jpeg"
|
|
48
|
+
* button-label="Browse..."
|
|
49
|
+
* ></moni-file-field>
|
|
11
50
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
51
|
+
* <!-- Multiple file upload with error state -->
|
|
52
|
+
* <moni-file-field
|
|
53
|
+
* label="Documents"
|
|
54
|
+
* multiple
|
|
55
|
+
* error
|
|
56
|
+
* error-text="Files exceed maximum size limit"
|
|
57
|
+
* ></moni-file-field>
|
|
58
|
+
* ```
|
|
15
59
|
*
|
|
16
|
-
*
|
|
17
|
-
* -
|
|
18
|
-
*
|
|
19
|
-
* -
|
|
20
|
-
*
|
|
21
|
-
* - button-label: text on the picker button (visual only, default: "Choose file")
|
|
22
|
-
* - icon: leading Material Symbols name
|
|
23
|
-
* - trailing-icon: trailing Material Symbols name
|
|
60
|
+
* @csspart field - The outer `.field` div container.
|
|
61
|
+
* @csspart input-text - The visible read-only `<input type="text">`.
|
|
62
|
+
* @csspart label - The floating `<label>` element.
|
|
63
|
+
* @csspart input-file - The hidden native `<input type="file">`.
|
|
64
|
+
* @csspart button - The button element (styled via CSS `::file-selector-button`).
|
|
24
65
|
*/
|
|
25
66
|
@customElement('moni-file-field')
|
|
26
67
|
export class MoniFileField extends MoniElement {
|
|
@@ -1,27 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-icon.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
|
-
* Visual-only icon.
|
|
13
|
+
* Visual-only icon component using Material Symbols variable font.
|
|
14
|
+
*
|
|
15
|
+
* Renders a Material Symbols glyph by its ligature name. The icon font
|
|
16
|
+
* must be loaded globally by the host document — it is not bundled with
|
|
17
|
+
* the component. Add the font via the `@moni-labs/moni-ui/styles` stylesheet
|
|
18
|
+
* or by including the Google Fonts CDN link.
|
|
19
|
+
*
|
|
20
|
+
* **Font rendering:**
|
|
21
|
+
* The icon uses `font-family: var(--font-icon)` which defaults to
|
|
22
|
+
* `'Material Symbols Rounded'`. Override `--font-icon-override` in the
|
|
23
|
+
* host document's `:root` to switch to a different icon set variant
|
|
24
|
+
* (e.g. `'Material Symbols Outlined'` or `'Material Symbols Sharp'`).
|
|
25
|
+
*
|
|
26
|
+
* **Variable font settings:**
|
|
27
|
+
* The default `font-variation-settings` is `'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24`.
|
|
28
|
+
* Setting the `filled` attribute switches to `'FILL' 1` for the solid icon variant.
|
|
7
29
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
30
|
+
* **Color inheritance:**
|
|
31
|
+
* The icon always inherits color from its parent via `color: inherit`, making it
|
|
32
|
+
* automatically adapt to button variants, chip selected states, list item active
|
|
33
|
+
* states, and other color-context containers.
|
|
10
34
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <!-- Basic icon -->
|
|
38
|
+
* <moni-icon name="home"></moni-icon>
|
|
15
39
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
40
|
+
* <!-- Filled large icon -->
|
|
41
|
+
* <moni-icon name="favorite" size="large" filled></moni-icon>
|
|
42
|
+
*
|
|
43
|
+
* <!-- Custom SVG override via slot -->
|
|
44
|
+
* <moni-icon>
|
|
45
|
+
* <svg slot="default" viewBox="0 0 24 24">...</svg>
|
|
46
|
+
* </moni-icon>
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @slot default - Fallback content when `name` is empty. Accepts `<svg>` or `<img>`
|
|
50
|
+
* elements which are sized to 100% of the icon box.
|
|
51
|
+
*
|
|
52
|
+
* @cssproperty --font-icon-override - Overrides the icon font family at the
|
|
53
|
+
* document level. Set on `:root`.
|
|
19
54
|
*/
|
|
20
55
|
@customElement('moni-icon')
|
|
21
56
|
export class MoniIcon extends MoniElement {
|
|
57
|
+
/**
|
|
58
|
+
* Material Symbols ligature name for the icon to render.
|
|
59
|
+
*
|
|
60
|
+
* Use the name exactly as shown on https://fonts.google.com/icons
|
|
61
|
+
* (e.g. `'home'`, `'settings'`, `'arrow_forward'`).
|
|
62
|
+
* When empty, the default slot is rendered instead.
|
|
63
|
+
*
|
|
64
|
+
* @default ''
|
|
65
|
+
*/
|
|
22
66
|
@property({ reflect: true }) name = '';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Size of the icon bounding box.
|
|
70
|
+
*
|
|
71
|
+
* Maps to the `--_size` custom property:
|
|
72
|
+
* | Value | Size |
|
|
73
|
+
* |------------|----------|
|
|
74
|
+
* | `'tiny'` | 1rem |
|
|
75
|
+
* | `'small'` | 1.25rem |
|
|
76
|
+
* | `'medium'` | 1.5rem |
|
|
77
|
+
* | `'large'` | 1.75rem |
|
|
78
|
+
* | `'extra'` | 2rem |
|
|
79
|
+
*
|
|
80
|
+
* @default 'medium'
|
|
81
|
+
*/
|
|
23
82
|
@property({ reflect: true })
|
|
24
83
|
size: 'tiny' | 'small' | 'medium' | 'large' | 'extra' = 'medium';
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* When `true`, switches to the filled variant of the icon by setting
|
|
87
|
+
* `font-variation-settings: 'FILL' 1`.
|
|
88
|
+
*
|
|
89
|
+
* This works only with variable icon fonts that include the `FILL` axis
|
|
90
|
+
* (all Material Symbols variants do). It has no effect if a different
|
|
91
|
+
* icon font is loaded that does not support `FILL`.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
25
95
|
@property({ type: Boolean, reflect: true }) filled = false;
|
|
26
96
|
|
|
27
97
|
static override styles = [
|
|
@@ -1,38 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-list-item.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 } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
import './moni-icon.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
|
-
* Material 3 List Item
|
|
14
|
+
* Material Design 3 List Item component.
|
|
15
|
+
*
|
|
16
|
+
* A single row within a `<moni-list>`. List items display a headline and
|
|
17
|
+
* optional supporting text, metadata, icons, or avatars.
|
|
18
|
+
*
|
|
19
|
+
* **M3 spec reference:** `m3-docs/components/lists/specs.md`
|
|
20
|
+
*
|
|
21
|
+
* **Line configurations:**
|
|
22
|
+
* The `lines` attribute configures the layout and minimum height of the item:
|
|
23
|
+
* - `lines="1"` (default) — 56dp min height. Only the headline slot is shown.
|
|
24
|
+
* - `lines="2"` — 72dp min height. Shows headline and supporting text.
|
|
25
|
+
* - `lines="3"` — 88dp min height. Shows headline, supporting text, and meta text.
|
|
26
|
+
*
|
|
27
|
+
* **Interactive behavior:**
|
|
28
|
+
* By default, items render as `<button>` elements, gaining the M3 state layer
|
|
29
|
+
* (hover, focus, and press ripple effects).
|
|
30
|
+
* If the `href` attribute is provided, the item internally renders as an `<a>`
|
|
31
|
+
* element, allowing native link routing and interactions while preserving the
|
|
32
|
+
* list item styling.
|
|
33
|
+
*
|
|
34
|
+
* **Visual elements:**
|
|
35
|
+
* - `icon` (attribute) — Material Symbol name for the leading icon (24dp).
|
|
36
|
+
* - `avatar` (attribute) — URL for a leading circular image (40dp).
|
|
37
|
+
* - `trailing-icon` (attribute) — Material Symbol name for the trailing icon.
|
|
8
38
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```html
|
|
41
|
+
* <!-- 1-line item with icon -->
|
|
42
|
+
* <moni-list-item icon="inbox">
|
|
43
|
+
* Inbox
|
|
44
|
+
* </moni-list-item>
|
|
13
45
|
*
|
|
14
|
-
*
|
|
46
|
+
* <!-- 2-line item with avatar and trailing meta -->
|
|
47
|
+
* <moni-list-item lines="2" avatar="/user.jpg">
|
|
48
|
+
* Ali Connors
|
|
49
|
+
* <span slot="supporting">Brunch this weekend?</span>
|
|
50
|
+
* <span slot="trailing-meta">10 min</span>
|
|
51
|
+
* </moni-list-item>
|
|
15
52
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
53
|
+
* <!-- Link item -->
|
|
54
|
+
* <moni-list-item href="/settings" icon="settings">
|
|
55
|
+
* Settings
|
|
56
|
+
* </moni-list-item>
|
|
57
|
+
* ```
|
|
21
58
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* - trailing-icon: Material Symbols name (trailing icon)
|
|
27
|
-
* - active: present → background uses secondary-container
|
|
28
|
-
* - disabled: present → opacity 38%, cursor not-allowed
|
|
29
|
-
* - href: present → renders as <a>; otherwise <button>
|
|
59
|
+
* @slot default - Headline text (Line 1).
|
|
60
|
+
* @slot supporting - Supporting text (Line 2, requires `lines>=2`).
|
|
61
|
+
* @slot meta - Additional meta text (Line 3, requires `lines=3`).
|
|
62
|
+
* @slot trailing-meta - Small text displayed on the far right edge.
|
|
30
63
|
*
|
|
31
|
-
*
|
|
32
|
-
* -
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* - trailing-meta: trailing small text (right side)
|
|
64
|
+
* @csspart item - The outer `<button>` or `<a>` container.
|
|
65
|
+
* @csspart leading-icon - Container for the leading icon/avatar.
|
|
66
|
+
* @csspart text - Container for the multi-line text block.
|
|
67
|
+
* @csspart trailing-icon - Container for the trailing icon.
|
|
36
68
|
*/
|
|
37
69
|
@customElement('moni-list-item')
|
|
38
70
|
export class MoniListItem extends MoniElement {
|
|
@@ -1,24 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-list.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 List
|
|
13
|
+
* Material Design 3 List component.
|
|
14
|
+
*
|
|
15
|
+
* Lists are continuous, vertical indexes of text or images. They are
|
|
16
|
+
* container elements that provide structural grouping and optional
|
|
17
|
+
* divider lines for `<moni-list-item>` children.
|
|
18
|
+
*
|
|
19
|
+
* **M3 spec reference:** `m3-docs/components/lists/specs.md`
|
|
20
|
+
*
|
|
21
|
+
* **Container role:**
|
|
22
|
+
* The list itself does not apply padding or margins to its children. Spacing
|
|
23
|
+
* and internal padding are controlled entirely by the `<moni-list-item>`
|
|
24
|
+
* elements themselves to ensure proper hit targets and alignment.
|
|
7
25
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
26
|
+
* **Variants:**
|
|
27
|
+
* - `default` (empty string) — A clean, borderless list container.
|
|
28
|
+
* - `border` — Adds a bottom border to the list and displays horizontal
|
|
29
|
+
* dividers (`outline-variant` color) between list items.
|
|
11
30
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html
|
|
33
|
+
* <!-- Standard list -->
|
|
34
|
+
* <moni-list>
|
|
35
|
+
* <moni-list-item headline="Item 1"></moni-list-item>
|
|
36
|
+
* <moni-list-item headline="Item 2"></moni-list-item>
|
|
37
|
+
* </moni-list>
|
|
15
38
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
39
|
+
* <!-- List with dividers and rounded items -->
|
|
40
|
+
* <moni-list variant="border" rounded>
|
|
41
|
+
* <moni-list-item icon="inbox" headline="Inbox"></moni-list-item>
|
|
42
|
+
* <moni-list-item icon="send" headline="Sent"></moni-list-item>
|
|
43
|
+
* </moni-list>
|
|
44
|
+
* ```
|
|
19
45
|
*
|
|
20
|
-
*
|
|
21
|
-
* - default: <moni-list-item> children.
|
|
46
|
+
* @slot default - `<moni-list-item>` elements.
|
|
22
47
|
*/
|
|
23
48
|
@customElement('moni-list')
|
|
24
49
|
export class MoniList extends MoniElement {
|
|
@@ -1,21 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-loading-indicator.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { html, css, unsafeCSS } from 'lit';
|
|
2
9
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
import { loadingIndicatorPolygons } from './loading-shapes.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
14
|
+
* Material Design 3 Loading Indicator component.
|
|
15
|
+
*
|
|
16
|
+
* An indeterminate loading indicator that visually represents an unspecified
|
|
17
|
+
* wait time. Unlike standard circular spinners, this component uses a morphing
|
|
18
|
+
* polygon animation that shifts between shapes (circle, rounded square, etc.)
|
|
19
|
+
* in accordance with the high-fidelity M3 Expressive motion specifications.
|
|
20
|
+
*
|
|
21
|
+
* **Variants:**
|
|
22
|
+
* - `uncontained` (default) — A standalone morphing shape that inherits color
|
|
23
|
+
* from its text context (or defaults to `primary`).
|
|
24
|
+
* - `contained` — The morphing shape is placed inside a circular container
|
|
25
|
+
* with a distinct background color, useful for high-contrast loading states
|
|
26
|
+
* or overlaying imagery.
|
|
27
|
+
*
|
|
28
|
+
* **Animation & Accessibility:**
|
|
29
|
+
* The component manages its own SVG `<animate>` tags. The animation is
|
|
30
|
+
* automatically started/stopped via `connectedCallback`/`disconnectedCallback`
|
|
31
|
+
* to save CPU cycles when the element is off-screen. It applies standard ARIA
|
|
32
|
+
* roles (`role="progressbar"`) and value attributes to ensure screen readers
|
|
33
|
+
* identify it correctly as an indeterminate loading state.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <!-- Uncontained indicator -->
|
|
38
|
+
* <moni-loading-indicator></moni-loading-indicator>
|
|
8
39
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
40
|
+
* <!-- Contained indicator (default container is secondary-container) -->
|
|
41
|
+
* <moni-loading-indicator variant="contained"></moni-loading-indicator>
|
|
42
|
+
* ```
|
|
11
43
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - --moni-loading-indicator-contained-active-color: Active indicator color in contained mode (default: var(--on-primary-container))
|
|
16
|
-
* - --moni-loading-indicator-contained-container-color: Background color of container in contained mode (default: var(--secondary-container))
|
|
17
|
-
* - --moni-loading-indicator-container-shape: Border radius of container in contained mode (default: 9999px)
|
|
18
|
-
* - --moni-loading-indicator-container-size: Container size (default: 3rem)
|
|
44
|
+
* @csspart container - The outer `.container` wrapper.
|
|
45
|
+
* @csspart svg - The inner `<svg>` element.
|
|
46
|
+
* @csspart shape - The `<path>` element that morphs.
|
|
19
47
|
*/
|
|
20
48
|
@customElement('moni-loading-indicator')
|
|
21
49
|
export class MoniLoadingIndicator extends MoniElement {
|
|
@@ -1,17 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-menu-item.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 Menu Item component.
|
|
15
|
+
*
|
|
16
|
+
* A single interactive item within a `<moni-menu>` or `<moni-context-menu>`.
|
|
17
|
+
* It provides standard M3 menu item styling, hover states, and optional
|
|
18
|
+
* leading icons.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/menus/specs.md`
|
|
21
|
+
*
|
|
22
|
+
* **Interaction states:**
|
|
23
|
+
* - Hover: applies an opacity layer.
|
|
24
|
+
* - Active (`active=true`): applies a `tertiary-container` background highlight,
|
|
25
|
+
* useful for indicating the currently selected option in a list.
|
|
26
|
+
* - Disabled (`disabled=true`): reduces opacity and disables pointer events.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <moni-menu-item icon="edit">Edit text</moni-menu-item>
|
|
31
|
+
* <moni-menu-item icon="content_copy" disabled>Copy</moni-menu-item>
|
|
32
|
+
* <moni-menu-item active>Currently selected</moni-menu-item>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @slot default - The text label for the menu item.
|
|
9
36
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* - disabled: present
|
|
13
|
-
* - icon: Material Symbols name
|
|
14
|
-
* - label: item text
|
|
37
|
+
* @csspart item - The outer `<li>` element.
|
|
38
|
+
* @csspart icon - The container for the leading icon.
|
|
15
39
|
*/
|
|
16
40
|
@customElement('moni-menu-item')
|
|
17
41
|
export class MoniMenuItem extends MoniElement {
|
|
@@ -1,40 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-menu.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, state } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
13
|
+
* Material Design 3 Menu component.
|
|
14
|
+
*
|
|
15
|
+
* Menus display a list of choices on a temporary surface. They appear when
|
|
16
|
+
* users interact with a button, action, or other control.
|
|
17
|
+
*
|
|
18
|
+
* **M3 spec reference:** `m3-docs/components/menus/guidelines.md`
|
|
19
|
+
*
|
|
20
|
+
* **Positioning architecture:**
|
|
21
|
+
* The menu uses `position: absolute` relative to its nearest positioned
|
|
22
|
+
* ancestor. The component's `:host` uses `display: contents`, meaning the
|
|
23
|
+
* inner `<menu>` element directly participates in the consumer's layout context.
|
|
24
|
+
* **Crucial:** The consumer must apply `position: relative` to the wrapper
|
|
25
|
+
* element that contains both the trigger and the `<moni-menu>`.
|
|
26
|
+
*
|
|
27
|
+
* **Auto-flip positioning:**
|
|
28
|
+
* Per M3 guidelines, menus should flip to the opposite side of the anchor
|
|
29
|
+
* if they overflow the viewport.
|
|
30
|
+
* - **Modern browsers (Chrome/Edge 125+, Safari 18+):** Uses CSS anchor
|
|
31
|
+
* positioning and `@position-try-fallback` natively when `flip=true`.
|
|
32
|
+
* - **Fallback:** A JavaScript polyfill measures the menu after it opens. If
|
|
33
|
+
* it overflows the requested `placement`, it sets an internal state to flip
|
|
34
|
+
* the placement classes.
|
|
7
35
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
36
|
+
* **State management:**
|
|
37
|
+
* The `active` attribute controls visibility. Consumers must listen to trigger
|
|
38
|
+
* events (like `click`) and toggle the `active` property.
|
|
11
39
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```html
|
|
42
|
+
* <!-- Wrapper must have position: relative -->
|
|
43
|
+
* <div style="position: relative; display: inline-block;">
|
|
44
|
+
* <moni-button id="menu-trigger">Open Menu</moni-button>
|
|
15
45
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
46
|
+
* <moni-menu placement="bottom" flip id="my-menu">
|
|
47
|
+
* <moni-menu-item icon="edit">Edit</moni-menu-item>
|
|
48
|
+
* <moni-menu-item icon="content_copy">Copy</moni-menu-item>
|
|
49
|
+
* <moni-divider></moni-divider>
|
|
50
|
+
* <moni-menu-item icon="delete">Delete</moni-menu-item>
|
|
51
|
+
* </moni-menu>
|
|
52
|
+
* </div>
|
|
19
53
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* to the opposite side and the CSS picks up the change.
|
|
54
|
+
* <script>
|
|
55
|
+
* const btn = document.getElementById('menu-trigger');
|
|
56
|
+
* const menu = document.getElementById('my-menu');
|
|
57
|
+
* btn.addEventListener('click', () => menu.active = !menu.active);
|
|
58
|
+
* </script>
|
|
59
|
+
* ```
|
|
27
60
|
*
|
|
28
|
-
*
|
|
29
|
-
* - placement: bottom (default) | top | left | right | min | max
|
|
30
|
-
* - no-wrap: present
|
|
31
|
-
* - space: no-space | space | small-space | medium-space | large-space | extra-space
|
|
32
|
-
* - active: present → menu is visible
|
|
33
|
-
* - flip: present → enable auto-flip when there is no viewport space
|
|
34
|
-
* (works on all browsers; CSS-native when supported)
|
|
61
|
+
* @slot default - `<moni-menu-item>`, `<moni-divider>`, or raw `<li>` elements.
|
|
35
62
|
*
|
|
36
|
-
*
|
|
37
|
-
* - default: menu items (moni-menu-item or li elements)
|
|
63
|
+
* @csspart menu - The inner `<menu>` container.
|
|
38
64
|
*/
|
|
39
65
|
@customElement('moni-menu')
|
|
40
66
|
export class MoniMenu extends MoniElement {
|