@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,34 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-context-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, state, query } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
import './moni-menu.js';
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
|
-
*
|
|
14
|
+
* Material Design 3 Context Menu component.
|
|
15
|
+
*
|
|
16
|
+
* A specialized menu that opens at the exact coordinates of a pointer event,
|
|
17
|
+
* typically triggered by a right-click (`contextmenu` event). It provides
|
|
18
|
+
* contextual actions related to the specific item clicked.
|
|
19
|
+
*
|
|
20
|
+
* **M3 spec reference:** `m3-docs/components/menus/specs.md` (Contextual menus)
|
|
21
|
+
*
|
|
22
|
+
* **Triggering mechanism:**
|
|
23
|
+
* The component does not require programmatic triggering via an `open` property.
|
|
24
|
+
* Instead, it attaches a `contextmenu` event listener to its parent element
|
|
25
|
+
* during `connectedCallback`. When the parent is right-clicked, the menu
|
|
26
|
+
* captures the `clientX`/`clientY` coordinates, prevents the default browser
|
|
27
|
+
* context menu, and opens itself at the cursor position using `position: fixed`.
|
|
8
28
|
*
|
|
9
|
-
* **
|
|
10
|
-
* the
|
|
11
|
-
*
|
|
29
|
+
* **Auto-flip behavior (`flip` attribute):**
|
|
30
|
+
* Per the M3 guidelines, menus should flip to the opposite side of the cursor
|
|
31
|
+
* if opening in the requested `placement` would cause them to overflow the
|
|
32
|
+
* viewport. When `flip=true`, the component dynamically calculates viewport
|
|
33
|
+
* bounds before opening and overrides `placement` if necessary (e.g., flipping
|
|
34
|
+
* from `bottom` to `top` if clicked near the bottom of the screen).
|
|
12
35
|
*
|
|
13
|
-
* **
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* <moni-context-menu flip>
|
|
17
|
-
* <moni-menu-item>Cut</moni-menu-item>
|
|
18
|
-
* <moni-menu-item>Copy</moni-menu-item>
|
|
19
|
-
* <moni-menu-item>Paste</moni-menu-item>
|
|
20
|
-
* </moni-context-menu>
|
|
21
|
-
* Right-click anywhere in this div
|
|
22
|
-
* </div>
|
|
23
|
-
* ```
|
|
36
|
+
* **Auto-dismiss:**
|
|
37
|
+
* Closes automatically when clicking anywhere outside the menu, or when
|
|
38
|
+
* pressing the `Escape` key.
|
|
24
39
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```html
|
|
42
|
+
* <!-- Wrap the trigger area and the menu in a container -->
|
|
43
|
+
* <div>
|
|
44
|
+
* <p>Right-click me for options</p>
|
|
45
|
+
* <moni-context-menu flip>
|
|
46
|
+
* <moni-menu-item>Copy</moni-menu-item>
|
|
47
|
+
* <moni-menu-item>Paste</moni-menu-item>
|
|
48
|
+
* <moni-divider></moni-divider>
|
|
49
|
+
* <moni-menu-item>Delete</moni-menu-item>
|
|
50
|
+
* </moni-context-menu>
|
|
51
|
+
* </div>
|
|
52
|
+
* ```
|
|
29
53
|
*
|
|
30
|
-
*
|
|
31
|
-
* - default: menu items
|
|
54
|
+
* @slot default - The `<moni-menu-item>` elements that make up the menu.
|
|
32
55
|
*/
|
|
33
56
|
@customElement('moni-context-menu')
|
|
34
57
|
export class MoniContextMenu extends MoniElement {
|
|
@@ -1,37 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-dialog.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 { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
11
|
|
|
5
12
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
13
|
+
* Material Design 3 Dialog component.
|
|
14
|
+
*
|
|
15
|
+
* Dialogs inform users about a task and can contain critical information,
|
|
16
|
+
* require decisions, or involve multiple tasks. They interrupt the user's
|
|
17
|
+
* workflow and should be used sparingly.
|
|
18
|
+
*
|
|
19
|
+
* **M3 spec reference:** `m3-docs/components/dialogs/specs.md`
|
|
20
|
+
*
|
|
21
|
+
* **Implementation note — native `<dialog>` element:**
|
|
22
|
+
* This component wraps the native `<dialog>` HTML element. Opening and closing
|
|
23
|
+
* are controlled via the `open` attribute (and its JS property). The component
|
|
24
|
+
* syncs `open` changes to the native `<dialog>` in `updated()`:
|
|
25
|
+
* - `modal=true` → calls `dialog.showModal()` (blocks focus, adds backdrop).
|
|
26
|
+
* - `modal=false` → calls `dialog.show()` (non-blocking, no backdrop).
|
|
27
|
+
* - `open=false` → calls `dialog.close()`.
|
|
10
28
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - modal: present → adds the `modal` class (used by BeerCSS)
|
|
16
|
-
* - title: header text
|
|
29
|
+
* **Placement (`side` attribute):**
|
|
30
|
+
* - `center` (default) — Centered in the viewport. Standard M3 dialog.
|
|
31
|
+
* - `top`, `right`, `bottom`, `left` — Edge-anchored panels (side sheet pattern).
|
|
32
|
+
* - `max` — Full-screen dialog for complex flows.
|
|
17
33
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```html
|
|
36
|
+
* <!-- Basic modal dialog -->
|
|
37
|
+
* <moni-dialog open modal title="Delete item?" size="small">
|
|
38
|
+
* <p>This action cannot be undone.</p>
|
|
39
|
+
* <div slot="footer">
|
|
40
|
+
* <moni-button variant="text">Cancel</moni-button>
|
|
41
|
+
* <moni-button>Delete</moni-button>
|
|
42
|
+
* </div>
|
|
43
|
+
* </moni-dialog>
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @slot default - The dialog body content.
|
|
47
|
+
* @slot header - Custom header content (overrides `title` attribute).
|
|
48
|
+
* @slot footer - Action buttons row at the bottom of the dialog.
|
|
49
|
+
*
|
|
50
|
+
* @csspart dialog - The native `<dialog>` element.
|
|
51
|
+
* @csspart header - The header container.
|
|
52
|
+
* @csspart body - The body content wrapper.
|
|
53
|
+
* @csspart footer - The footer actions wrapper.
|
|
22
54
|
*/
|
|
23
55
|
@customElement('moni-dialog')
|
|
24
56
|
export class MoniDialog extends MoniElement {
|
|
57
|
+
/**
|
|
58
|
+
* Controls the open/closed state of the dialog.
|
|
59
|
+
*
|
|
60
|
+
* When set to `true`, the component calls `dialog.showModal()` (if `modal`)
|
|
61
|
+
* or `dialog.show()`. When set to `false`, calls `dialog.close()`.
|
|
62
|
+
* Reflected as an HTML attribute for CSS and external state readers.
|
|
63
|
+
*
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
25
66
|
@property({ type: Boolean, reflect: true }) open = false;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* When `true`, opens the dialog as a modal using `<dialog>.showModal()`.
|
|
70
|
+
*
|
|
71
|
+
* Modal dialogs:
|
|
72
|
+
* - Block keyboard focus from leaving the dialog.
|
|
73
|
+
* - Render a `::backdrop` scrim over the rest of the page.
|
|
74
|
+
* - Can be closed by pressing `Escape` (native browser behavior).
|
|
75
|
+
*
|
|
76
|
+
* When `false`, uses `<dialog>.show()` which is non-blocking (no focus trap
|
|
77
|
+
* and no backdrop).
|
|
78
|
+
*
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
26
81
|
@property({ type: Boolean, reflect: true }) modal = false;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Placement of the dialog within the viewport.
|
|
85
|
+
*
|
|
86
|
+
* - `'center'` (default) — Centered. Standard M3 dialog placement.
|
|
87
|
+
* - `'top'` — Anchored to the top edge (drawer from top).
|
|
88
|
+
* - `'right'` — Anchored to the right edge (side sheet pattern).
|
|
89
|
+
* - `'bottom'` — Anchored to the bottom edge (bottom sheet alternative).
|
|
90
|
+
* - `'left'` — Anchored to the left edge (navigation drawer pattern).
|
|
91
|
+
* - `'max'` — Full-screen (covers the entire viewport).
|
|
92
|
+
*
|
|
93
|
+
* @default 'center'
|
|
94
|
+
*/
|
|
27
95
|
@property({ reflect: true })
|
|
28
96
|
side: 'center' | 'top' | 'right' | 'bottom' | 'left' | 'max' = 'center';
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Size of the dialog container.
|
|
100
|
+
*
|
|
101
|
+
* - `'small'` — Narrow dialog; ideal for simple confirmations.
|
|
102
|
+
* - `'medium'` — Standard dialog width (default).
|
|
103
|
+
* - `'large'` — Wide dialog; for forms or complex content.
|
|
104
|
+
*
|
|
105
|
+
* @default 'medium'
|
|
106
|
+
*/
|
|
29
107
|
@property({ reflect: true })
|
|
30
108
|
size: 'small' | 'medium' | 'large' = 'medium';
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Text displayed in the dialog header area.
|
|
112
|
+
*
|
|
113
|
+
* When non-empty, renders as a styled heading inside the header container.
|
|
114
|
+
* The `header` slot takes precedence over this attribute when both are present.
|
|
115
|
+
*
|
|
116
|
+
* @default ''
|
|
117
|
+
*/
|
|
31
118
|
@property({ reflect: true }) title = '';
|
|
32
119
|
|
|
120
|
+
/** Direct reference to the native `<dialog>` element for programmatic access. */
|
|
33
121
|
@query('dialog') private _dialog!: HTMLDialogElement;
|
|
34
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Syncs the `open` and `modal` state to the native `<dialog>` element.
|
|
125
|
+
*
|
|
126
|
+
* Called by Lit after every render cycle where tracked properties change.
|
|
127
|
+
* Avoids calling `showModal()` or `show()` if the dialog is already open
|
|
128
|
+
* (prevents the `InvalidStateError` DOMException).
|
|
129
|
+
*
|
|
130
|
+
* @param changed - Map of changed property names to their previous values.
|
|
131
|
+
*/
|
|
35
132
|
override updated(changed: Map<string, unknown>) {
|
|
36
133
|
if (changed.has('open') && this._dialog) {
|
|
37
134
|
if (this.open) {
|
|
@@ -1,29 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-divider.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 Divider
|
|
13
|
+
* Material Design 3 Divider component.
|
|
14
|
+
*
|
|
15
|
+
* A thin horizontal (or vertical) rule used to visually separate content
|
|
16
|
+
* sections within lists, layouts, and cards.
|
|
17
|
+
*
|
|
18
|
+
* **M3 spec reference:** `m3-docs/components/divider/specs.md`
|
|
19
|
+
*
|
|
20
|
+
* **M3 measurements:**
|
|
21
|
+
* - Thickness: 1dp (`0.0625rem`).
|
|
22
|
+
* - Color: `outline-variant` — subtle on all surface backgrounds.
|
|
23
|
+
* - Inset variants align the line with list content:
|
|
24
|
+
* - `leading` — 16dp margin from the leading edge (aligns with icon text).
|
|
25
|
+
* - `middle` — 16dp margin on both edges.
|
|
26
|
+
* - `none` — full-bleed (no margin).
|
|
7
27
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* with text content below an icon.
|
|
13
|
-
* - **middle**: indented from both edges (16dp each).
|
|
28
|
+
* **Vertical usage:**
|
|
29
|
+
* While not yet exposed as an attribute, the `[vertical]` CSS attribute selector
|
|
30
|
+
* is supported. Set `vertical` as an HTML attribute to render a 1dp-wide
|
|
31
|
+
* vertical divider that stretches to match its flex container's cross-axis.
|
|
14
32
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```html
|
|
35
|
+
* <!-- Full-bleed divider between sections -->
|
|
36
|
+
* <moni-divider inset="none"></moni-divider>
|
|
18
37
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
38
|
+
* <!-- Leading-inset divider in a list (aligns with list item text) -->
|
|
39
|
+
* <moni-divider></moni-divider>
|
|
21
40
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
41
|
+
* <!-- Vertical divider inside a flex container -->
|
|
42
|
+
* <div style="display:flex; height: 3rem; align-items:center; gap: 1rem;">
|
|
43
|
+
* <span>Section A</span>
|
|
44
|
+
* <moni-divider vertical></moni-divider>
|
|
45
|
+
* <span>Section B</span>
|
|
46
|
+
* </div>
|
|
47
|
+
* ```
|
|
24
48
|
*/
|
|
25
49
|
@customElement('moni-divider')
|
|
26
50
|
export class MoniDivider extends MoniElement {
|
|
51
|
+
/**
|
|
52
|
+
* Controls the horizontal margin on the divider line.
|
|
53
|
+
*
|
|
54
|
+
* - `'leading'` (default) — 16dp margin from the leading (start) edge only.
|
|
55
|
+
* Use in lists to align the divider with the primary text of list items.
|
|
56
|
+
* - `'middle'` — 16dp margin on both the leading and trailing edges.
|
|
57
|
+
* Use to separate sections where full-bleed would be too visually heavy.
|
|
58
|
+
* - `'none'` — No margin; the line spans the full parent width.
|
|
59
|
+
* Use as a section separator or between cards.
|
|
60
|
+
*
|
|
61
|
+
* @default 'leading'
|
|
62
|
+
*/
|
|
27
63
|
@property({ reflect: true })
|
|
28
64
|
inset: 'leading' | 'middle' | 'none' = 'leading';
|
|
29
65
|
|
|
@@ -1,17 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-expansion.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 Expansion panel component.
|
|
14
|
+
*
|
|
15
|
+
* A lightweight wrapper around the native HTML `<details>` and `<summary>`
|
|
16
|
+
* elements, styled according to M3 surface and elevation guidelines.
|
|
17
|
+
* Expansion panels contain creation flows and allow lightweight editing of an element.
|
|
18
|
+
*
|
|
19
|
+
* **Visual architecture:**
|
|
20
|
+
* The component renders a `<details>` element with a `<summary>` that acts
|
|
21
|
+
* as the expandable header. The default slot content is placed inside the
|
|
22
|
+
* `<details>` tag (but outside the `<summary>`), naturally hiding and showing
|
|
23
|
+
* based on the native behavior. An M3 `expand_more` icon is added via a CSS
|
|
24
|
+
* `::after` pseudo-element and rotates when the panel is open.
|
|
25
|
+
*
|
|
26
|
+
* **Usage:**
|
|
27
|
+
* Set the `title` attribute for a simple text header, or use the `summary`
|
|
28
|
+
* slot to project custom rich content (like icons or secondary text) into the
|
|
29
|
+
* header area.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```html
|
|
33
|
+
* <!-- Simple text title -->
|
|
34
|
+
* <moni-expansion title="Advanced Settings">
|
|
35
|
+
* <p>Enable developer mode features here.</p>
|
|
36
|
+
* </moni-expansion>
|
|
7
37
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
38
|
+
* <!-- Rich summary content via slot -->
|
|
39
|
+
* <moni-expansion open>
|
|
40
|
+
* <div slot="summary" style="display: flex; gap: 8px;">
|
|
41
|
+
* <moni-icon>person</moni-icon>
|
|
42
|
+
* <span>Personal Information</span>
|
|
43
|
+
* </div>
|
|
44
|
+
* <form>
|
|
45
|
+
* <moni-text-field label="Name"></moni-text-field>
|
|
46
|
+
* </form>
|
|
47
|
+
* </moni-expansion>
|
|
48
|
+
* ```
|
|
11
49
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - summary: custom summary content (overrides title)
|
|
50
|
+
* @slot default - The content of the expansion panel body.
|
|
51
|
+
* @slot summary - Custom header content (overrides the `title` attribute).
|
|
15
52
|
*/
|
|
16
53
|
@customElement('moni-expansion')
|
|
17
54
|
export class MoniExpansion extends MoniElement {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-fab-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 } from 'lit/decorators.js';
|
|
3
10
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
@@ -6,28 +13,41 @@ import './moni-icon.js';
|
|
|
6
13
|
import type { MoniFab } from './moni-fab.js';
|
|
7
14
|
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
16
|
+
* Material Design 3 FAB Menu component.
|
|
17
|
+
*
|
|
18
|
+
* A specialized container that combines a main `<moni-fab>` trigger with a
|
|
19
|
+
* `<menu>` of secondary FABs. It allows multiple actions to be tucked away
|
|
20
|
+
* behind a single primary Floating Action Button, reducing screen clutter.
|
|
21
|
+
*
|
|
22
|
+
* **M3 spec reference:** `m3-docs/components/floating-action-buttons/specs.md` (FAB menus)
|
|
23
|
+
*
|
|
24
|
+
* **Trigger and animation:**
|
|
25
|
+
* The component wires the primary trigger FAB's `click` event to toggle its
|
|
26
|
+
* internal `open` state. When `open=true`, the nested secondary FABs scale up
|
|
27
|
+
* and fade in via CSS transitions. Consumers can also control the `open` state
|
|
28
|
+
* programmatically by setting the attribute.
|
|
29
|
+
*
|
|
30
|
+
* **Focus management (Accessibility):**
|
|
31
|
+
* - When the menu opens, focus automatically moves to the first focusable
|
|
32
|
+
* secondary item (or remains on the trigger if empty).
|
|
33
|
+
* - While open, the `Tab` key cycles focus strictly within the menu items to
|
|
34
|
+
* prevent keyboard focus from escaping (focus trap).
|
|
35
|
+
* - Pressing `Escape` or clicking anywhere outside the menu closes it and
|
|
36
|
+
* returns focus to the primary trigger FAB.
|
|
11
37
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```html
|
|
40
|
+
* <!-- Bottom-trailing FAB menu opening upwards -->
|
|
41
|
+
* <moni-fab-menu icon="add" color="tertiary" direction="up">
|
|
42
|
+
* <moni-fab size="small" icon="edit" label="Draft"></moni-fab>
|
|
43
|
+
* <moni-fab size="small" icon="photo_camera" label="Camera"></moni-fab>
|
|
44
|
+
* </moni-fab-menu>
|
|
45
|
+
* ```
|
|
15
46
|
*
|
|
16
|
-
*
|
|
17
|
-
* - When `open` becomes true, focus moves to the first focusable item in
|
|
18
|
-
* the menu (or stays on the trigger if the menu is empty).
|
|
19
|
-
* - When `open` becomes false, focus returns to the trigger.
|
|
20
|
-
* - `Tab` cycles within the menu while open; `Escape` closes the menu.
|
|
21
|
-
* - Click outside the menu closes it.
|
|
47
|
+
* @slot default - The secondary `<moni-fab>` elements that appear when open.
|
|
22
48
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* - icon: Material Symbols name for the trigger
|
|
26
|
-
* - size: small | medium (default) | large
|
|
27
|
-
* - color: primary (default) | secondary | tertiary | surface
|
|
28
|
-
* - shape: rounded (default) | circle
|
|
29
|
-
* - direction: up (default) | down | left | right
|
|
30
|
-
* - position: same as moni-fab
|
|
49
|
+
* @csspart trigger - The primary `<moni-fab>` trigger element.
|
|
50
|
+
* @csspart menu - The `<menu>` container holding the secondary items.
|
|
31
51
|
*/
|
|
32
52
|
@customElement('moni-fab-menu')
|
|
33
53
|
export class MoniFabMenu extends MoniElement {
|
|
@@ -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 {
|