@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,32 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-badge.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
import { MoniElement } from './_base/index.js';
|
|
2
8
|
/**
|
|
3
|
-
*
|
|
9
|
+
* Material Design 3 Badge component.
|
|
10
|
+
*
|
|
11
|
+
* Badges are small status descriptors anchored to a parent element, used to
|
|
12
|
+
* convey supplementary information such as a notification count, online
|
|
13
|
+
* status, or selection indicator.
|
|
14
|
+
*
|
|
15
|
+
* **Positioning contract:**
|
|
16
|
+
* The badge uses `position: absolute` and anchors to the parent element.
|
|
17
|
+
* On `connectedCallback`, if the parent's computed `position` is `'static'`,
|
|
18
|
+
* the badge automatically sets `parent.style.position = 'relative'`.
|
|
19
|
+
* Consumers do not need to manually add `position: relative` to the parent.
|
|
20
|
+
*
|
|
21
|
+
* **Rendering model:**
|
|
22
|
+
* The `:host` displays as `contents`, making it transparent to layout.
|
|
23
|
+
* Only the inner `.badge` span is visually rendered. This allows the badge
|
|
24
|
+
* to be dropped inside any element without affecting its layout flow.
|
|
4
25
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```html
|
|
28
|
+
* <!-- Notification badge on a button -->
|
|
29
|
+
* <div style="position: relative; display: inline-flex;">
|
|
30
|
+
* <moni-button icon="notifications" variant="text"></moni-button>
|
|
31
|
+
* <moni-badge value="5"></moni-badge>
|
|
32
|
+
* </div>
|
|
33
|
+
* ```
|
|
8
34
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <!-- Inline dot badge for status -->
|
|
38
|
+
* <moni-badge shape="min" color="primary" inline></moni-badge>
|
|
39
|
+
* Online
|
|
40
|
+
* ```
|
|
11
41
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* - position: '' (top-right default) | top | bottom | left | right | none
|
|
15
|
-
* - shape: '' (round) | circle | square | min
|
|
16
|
-
* - color: error (default) | primary | secondary | tertiary
|
|
17
|
-
* - border: present → outlined badge (BeerCSS .badge.border)
|
|
18
|
-
* - inline: present → badge becomes inline (BeerCSS .badge.none)
|
|
42
|
+
* @csspart badge - The badge `<span>` element. Override `background-color`,
|
|
43
|
+
* `color`, or `border-radius` to customize appearance.
|
|
19
44
|
*/
|
|
20
45
|
export declare class MoniBadge extends MoniElement {
|
|
46
|
+
/**
|
|
47
|
+
* Text content of the badge label.
|
|
48
|
+
*
|
|
49
|
+
* Also accepts slotted content — the default slot inside the badge span
|
|
50
|
+
* falls back to this value when no children are slotted.
|
|
51
|
+
* Use an empty string with `shape="min"` to render a dot-only badge.
|
|
52
|
+
*
|
|
53
|
+
* @default ''
|
|
54
|
+
*/
|
|
21
55
|
value: string;
|
|
56
|
+
/**
|
|
57
|
+
* Anchor position relative to the parent element's edges.
|
|
58
|
+
*
|
|
59
|
+
* Uses `inset: 50% auto auto 50%` as the base and adjusts translation:
|
|
60
|
+
* - `''` (default) — top-right corner (translate: 0, -100%).
|
|
61
|
+
* - `'top'` — same as default, explicit alias.
|
|
62
|
+
* - `'bottom'` — bottom-right corner (translate: 0, 0).
|
|
63
|
+
* - `'left'` — top-left corner (translate: -100%, -100%).
|
|
64
|
+
* - `'right'` — top-right corner (translate: 0, -100%).
|
|
65
|
+
* - `'none'` — disables absolute positioning; see also the `inline` attribute.
|
|
66
|
+
*
|
|
67
|
+
* @default ''
|
|
68
|
+
*/
|
|
22
69
|
position: 'top' | 'bottom' | 'left' | 'right' | 'none' | '';
|
|
70
|
+
/**
|
|
71
|
+
* Shape of the badge container.
|
|
72
|
+
*
|
|
73
|
+
* - `''` (default) — Rounded pill shape (border-radius: 1rem).
|
|
74
|
+
* - `'circle'` — Alias for pill; the badge is always circular when the
|
|
75
|
+
* content is a single character or absent.
|
|
76
|
+
* - `'square'` — No border-radius (angular badge).
|
|
77
|
+
* - `'min'` — Dot only; content is hidden via `display: none` and the
|
|
78
|
+
* shape is clipped to a small circle via `clip-path`.
|
|
79
|
+
*
|
|
80
|
+
* @default ''
|
|
81
|
+
*/
|
|
23
82
|
shape: 'circle' | 'square' | 'min' | '';
|
|
83
|
+
/**
|
|
84
|
+
* Semantic color role of the badge.
|
|
85
|
+
*
|
|
86
|
+
* Maps to the M3 color palette roles:
|
|
87
|
+
* - `'error'` (default) — Red; standard for notification counts and alerts.
|
|
88
|
+
* - `'primary'` — Brand primary color; for selection or active states.
|
|
89
|
+
* - `'secondary'` — Secondary accent; for supplementary indicators.
|
|
90
|
+
* - `'tertiary'` — Tertiary accent; for decorative or informational badges.
|
|
91
|
+
*
|
|
92
|
+
* @default 'error'
|
|
93
|
+
*/
|
|
24
94
|
color: 'primary' | 'secondary' | 'tertiary' | 'error';
|
|
95
|
+
/**
|
|
96
|
+
* When `true`, the badge renders inline (resets `position: absolute` to
|
|
97
|
+
* `position: relative`) rather than anchoring to the parent.
|
|
98
|
+
*
|
|
99
|
+
* Equivalent to BeerCSS's `.badge.none` class. Use for inline status
|
|
100
|
+
* indicators that flow within text or flex containers.
|
|
101
|
+
*
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
25
104
|
inline: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* When present, renders the badge with an outlined style:
|
|
107
|
+
* - Background becomes `--surface` (same as the page background).
|
|
108
|
+
* - Border and text color use the palette color token (e.g. `--error`).
|
|
109
|
+
*
|
|
110
|
+
* Equivalent to BeerCSS's `.badge.border` class.
|
|
111
|
+
*
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
26
114
|
border: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Ensures the parent element can contain the absolutely-positioned badge.
|
|
117
|
+
*
|
|
118
|
+
* Reads the parent's computed `position` via `getComputedStyle`. If it is
|
|
119
|
+
* `'static'` (the browser default), sets `parent.style.position = 'relative'`
|
|
120
|
+
* so the badge anchors correctly. This is a convenience that avoids requiring
|
|
121
|
+
* consumers to remember to add `position: relative` to the parent themselves.
|
|
122
|
+
*/
|
|
27
123
|
connectedCallback(): void;
|
|
28
124
|
static styles: import("lit").CSSResult[];
|
|
29
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Renders the badge span with the computed class list.
|
|
127
|
+
*
|
|
128
|
+
* Class composition:
|
|
129
|
+
* - `'badge'` — always present (base styles).
|
|
130
|
+
* - `this.position` — position variant class (e.g. `'bottom'`, `'left'`).
|
|
131
|
+
* - `this.shape` — shape variant class (e.g. `'min'`, `'square'`).
|
|
132
|
+
* - `'none'` — added when `inline=true` to reset absolute positioning.
|
|
133
|
+
*
|
|
134
|
+
* Falsy values are filtered out so no extra spaces appear in the class string.
|
|
135
|
+
* The default slot falls back to the `value` attribute text node.
|
|
136
|
+
*/
|
|
137
|
+
render(): import("lit").TemplateResult<1>;
|
|
30
138
|
}
|
|
31
139
|
declare global {
|
|
32
140
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-badge.d.ts","sourceRoot":"","sources":["../../src/components/moni-badge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-badge.d.ts","sourceRoot":"","sources":["../../src/components/moni-badge.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBACa,SAAU,SAAQ,WAAW;IACzC;;;;;;;;OAQG;IAC0B,KAAK,SAAM;IAExC;;;;;;;;;;;;OAYG;IAEH,QAAQ,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,EAAE,CAAM;IAEjE;;;;;;;;;;;OAWG;IAEH,KAAK,EAAE,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,EAAE,CAAM;IAE7C;;;;;;;;;;OAUG;IAEH,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,OAAO,CAAW;IAEhE;;;;;;;;OAQG;IACyC,MAAM,UAAS;IAE3D;;;;;;;;OAQG;IACyC,MAAM,UAAS;IAE3D;;;;;;;OAOG;IACM,iBAAiB;IAY1B,OAAgB,MAAM,4BAqEpB;IAEF;;;;;;;;;;;OAWG;IACM,MAAM;CAYf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,YAAY,EAAE,SAAS,CAAC;KACxB;CACD;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-badge.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
8
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
9
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,36 +14,126 @@ import { html, css } from 'lit';
|
|
|
8
14
|
import { customElement, property } from 'lit/decorators.js';
|
|
9
15
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
17
|
+
* Material Design 3 Badge component.
|
|
18
|
+
*
|
|
19
|
+
* Badges are small status descriptors anchored to a parent element, used to
|
|
20
|
+
* convey supplementary information such as a notification count, online
|
|
21
|
+
* status, or selection indicator.
|
|
22
|
+
*
|
|
23
|
+
* **Positioning contract:**
|
|
24
|
+
* The badge uses `position: absolute` and anchors to the parent element.
|
|
25
|
+
* On `connectedCallback`, if the parent's computed `position` is `'static'`,
|
|
26
|
+
* the badge automatically sets `parent.style.position = 'relative'`.
|
|
27
|
+
* Consumers do not need to manually add `position: relative` to the parent.
|
|
28
|
+
*
|
|
29
|
+
* **Rendering model:**
|
|
30
|
+
* The `:host` displays as `contents`, making it transparent to layout.
|
|
31
|
+
* Only the inner `.badge` span is visually rendered. This allows the badge
|
|
32
|
+
* to be dropped inside any element without affecting its layout flow.
|
|
12
33
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```html
|
|
36
|
+
* <!-- Notification badge on a button -->
|
|
37
|
+
* <div style="position: relative; display: inline-flex;">
|
|
38
|
+
* <moni-button icon="notifications" variant="text"></moni-button>
|
|
39
|
+
* <moni-badge value="5"></moni-badge>
|
|
40
|
+
* </div>
|
|
41
|
+
* ```
|
|
16
42
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```html
|
|
45
|
+
* <!-- Inline dot badge for status -->
|
|
46
|
+
* <moni-badge shape="min" color="primary" inline></moni-badge>
|
|
47
|
+
* Online
|
|
48
|
+
* ```
|
|
19
49
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* - position: '' (top-right default) | top | bottom | left | right | none
|
|
23
|
-
* - shape: '' (round) | circle | square | min
|
|
24
|
-
* - color: error (default) | primary | secondary | tertiary
|
|
25
|
-
* - border: present → outlined badge (BeerCSS .badge.border)
|
|
26
|
-
* - inline: present → badge becomes inline (BeerCSS .badge.none)
|
|
50
|
+
* @csspart badge - The badge `<span>` element. Override `background-color`,
|
|
51
|
+
* `color`, or `border-radius` to customize appearance.
|
|
27
52
|
*/
|
|
28
53
|
let MoniBadge = class MoniBadge extends MoniElement {
|
|
29
54
|
constructor() {
|
|
30
55
|
super(...arguments);
|
|
56
|
+
/**
|
|
57
|
+
* Text content of the badge label.
|
|
58
|
+
*
|
|
59
|
+
* Also accepts slotted content — the default slot inside the badge span
|
|
60
|
+
* falls back to this value when no children are slotted.
|
|
61
|
+
* Use an empty string with `shape="min"` to render a dot-only badge.
|
|
62
|
+
*
|
|
63
|
+
* @default ''
|
|
64
|
+
*/
|
|
31
65
|
this.value = '';
|
|
66
|
+
/**
|
|
67
|
+
* Anchor position relative to the parent element's edges.
|
|
68
|
+
*
|
|
69
|
+
* Uses `inset: 50% auto auto 50%` as the base and adjusts translation:
|
|
70
|
+
* - `''` (default) — top-right corner (translate: 0, -100%).
|
|
71
|
+
* - `'top'` — same as default, explicit alias.
|
|
72
|
+
* - `'bottom'` — bottom-right corner (translate: 0, 0).
|
|
73
|
+
* - `'left'` — top-left corner (translate: -100%, -100%).
|
|
74
|
+
* - `'right'` — top-right corner (translate: 0, -100%).
|
|
75
|
+
* - `'none'` — disables absolute positioning; see also the `inline` attribute.
|
|
76
|
+
*
|
|
77
|
+
* @default ''
|
|
78
|
+
*/
|
|
32
79
|
this.position = '';
|
|
80
|
+
/**
|
|
81
|
+
* Shape of the badge container.
|
|
82
|
+
*
|
|
83
|
+
* - `''` (default) — Rounded pill shape (border-radius: 1rem).
|
|
84
|
+
* - `'circle'` — Alias for pill; the badge is always circular when the
|
|
85
|
+
* content is a single character or absent.
|
|
86
|
+
* - `'square'` — No border-radius (angular badge).
|
|
87
|
+
* - `'min'` — Dot only; content is hidden via `display: none` and the
|
|
88
|
+
* shape is clipped to a small circle via `clip-path`.
|
|
89
|
+
*
|
|
90
|
+
* @default ''
|
|
91
|
+
*/
|
|
33
92
|
this.shape = '';
|
|
93
|
+
/**
|
|
94
|
+
* Semantic color role of the badge.
|
|
95
|
+
*
|
|
96
|
+
* Maps to the M3 color palette roles:
|
|
97
|
+
* - `'error'` (default) — Red; standard for notification counts and alerts.
|
|
98
|
+
* - `'primary'` — Brand primary color; for selection or active states.
|
|
99
|
+
* - `'secondary'` — Secondary accent; for supplementary indicators.
|
|
100
|
+
* - `'tertiary'` — Tertiary accent; for decorative or informational badges.
|
|
101
|
+
*
|
|
102
|
+
* @default 'error'
|
|
103
|
+
*/
|
|
34
104
|
this.color = 'error';
|
|
105
|
+
/**
|
|
106
|
+
* When `true`, the badge renders inline (resets `position: absolute` to
|
|
107
|
+
* `position: relative`) rather than anchoring to the parent.
|
|
108
|
+
*
|
|
109
|
+
* Equivalent to BeerCSS's `.badge.none` class. Use for inline status
|
|
110
|
+
* indicators that flow within text or flex containers.
|
|
111
|
+
*
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
35
114
|
this.inline = false;
|
|
115
|
+
/**
|
|
116
|
+
* When present, renders the badge with an outlined style:
|
|
117
|
+
* - Background becomes `--surface` (same as the page background).
|
|
118
|
+
* - Border and text color use the palette color token (e.g. `--error`).
|
|
119
|
+
*
|
|
120
|
+
* Equivalent to BeerCSS's `.badge.border` class.
|
|
121
|
+
*
|
|
122
|
+
* @default false
|
|
123
|
+
*/
|
|
36
124
|
this.border = false;
|
|
37
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Ensures the parent element can contain the absolutely-positioned badge.
|
|
128
|
+
*
|
|
129
|
+
* Reads the parent's computed `position` via `getComputedStyle`. If it is
|
|
130
|
+
* `'static'` (the browser default), sets `parent.style.position = 'relative'`
|
|
131
|
+
* so the badge anchors correctly. This is a convenience that avoids requiring
|
|
132
|
+
* consumers to remember to add `position: relative` to the parent themselves.
|
|
133
|
+
*/
|
|
38
134
|
connectedCallback() {
|
|
39
135
|
super.connectedCallback();
|
|
40
|
-
//
|
|
136
|
+
// Ensure the badge's absolutely-positioned anchor point is correct.
|
|
41
137
|
const parent = this.parentElement;
|
|
42
138
|
if (parent) {
|
|
43
139
|
const computed = getComputedStyle(parent);
|
|
@@ -116,6 +212,18 @@ let MoniBadge = class MoniBadge extends MoniElement {
|
|
|
116
212
|
.badge.min { clip-path: circle(18.75% at 50% 50%); }
|
|
117
213
|
`
|
|
118
214
|
]; }
|
|
215
|
+
/**
|
|
216
|
+
* Renders the badge span with the computed class list.
|
|
217
|
+
*
|
|
218
|
+
* Class composition:
|
|
219
|
+
* - `'badge'` — always present (base styles).
|
|
220
|
+
* - `this.position` — position variant class (e.g. `'bottom'`, `'left'`).
|
|
221
|
+
* - `this.shape` — shape variant class (e.g. `'min'`, `'square'`).
|
|
222
|
+
* - `'none'` — added when `inline=true` to reset absolute positioning.
|
|
223
|
+
*
|
|
224
|
+
* Falsy values are filtered out so no extra spaces appear in the class string.
|
|
225
|
+
* The default slot falls back to the `value` attribute text node.
|
|
226
|
+
*/
|
|
119
227
|
render() {
|
|
120
228
|
const classes = [
|
|
121
229
|
'badge',
|
|
@@ -1,30 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-bottom-sheet.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
import { MoniElement } from './_base/index.js';
|
|
2
8
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
9
|
+
* Material Design 3 Bottom Sheet component.
|
|
10
|
+
*
|
|
11
|
+
* Bottom sheets are surfaces anchored to the bottom of the screen that
|
|
12
|
+
* supplement the main view. They display supplementary content, contextual
|
|
13
|
+
* actions, or task flows without fully obscuring the primary content.
|
|
14
|
+
*
|
|
15
|
+
* **M3 spec reference:** `m3-docs/components/sheets-bottom/specs.md`
|
|
16
|
+
*
|
|
17
|
+
* **Implementation note — native `<dialog>` element:**
|
|
18
|
+
* Like `<moni-dialog>`, this component wraps the native `<dialog>` element.
|
|
19
|
+
* The `open` property drives `dialog.showModal()` / `dialog.close()`. When
|
|
20
|
+
* `modal=true` (default), a `::backdrop` scrim is rendered automatically.
|
|
21
|
+
*
|
|
22
|
+
* **Teleportation (body-level mounting):**
|
|
23
|
+
* When `positioning="body"` (default), the component moves itself to
|
|
24
|
+
* `document.body` on `connectedCallback` so the fixed-bottom dialog renders
|
|
25
|
+
* above all stacking contexts. On `disconnectedCallback`, it is moved back
|
|
26
|
+
* to its original DOM position. This avoids clipping by `overflow: hidden`
|
|
27
|
+
* or `transform` ancestors.
|
|
28
|
+
*
|
|
29
|
+
* **Sizes:**
|
|
30
|
+
* - `small` — Compact sheet; suitable for simple action menus.
|
|
31
|
+
* - `medium` — Standard height (default).
|
|
32
|
+
* - `large` — Expanded height (`expandedHeight` controls the max block-size).
|
|
33
|
+
* - `auto` — Content-driven height.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```html
|
|
37
|
+
* <moni-bottom-sheet title="Share">
|
|
38
|
+
* <moni-list-item icon="share">Copy link</moni-list-item>
|
|
39
|
+
* <moni-list-item icon="mail">Send via email</moni-list-item>
|
|
40
|
+
* </moni-bottom-sheet>
|
|
41
|
+
*
|
|
42
|
+
* <script>
|
|
43
|
+
* document.querySelector('moni-bottom-sheet').open = true;
|
|
44
|
+
* </script>
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @slot default - The body content of the bottom sheet.
|
|
48
|
+
* @slot handle - The drag handle area at the top of the sheet.
|
|
49
|
+
* @slot footer - Action buttons at the bottom of the sheet.
|
|
50
|
+
*
|
|
51
|
+
* @csspart dialog - The native `<dialog>` element.
|
|
52
|
+
* @csspart header - The header container with title and close button.
|
|
53
|
+
* @csspart body - The scrollable body content area.
|
|
54
|
+
* @csspart footer - The footer action buttons area.
|
|
17
55
|
*/
|
|
18
56
|
export declare class MoniBottomSheet extends MoniElement {
|
|
57
|
+
/**
|
|
58
|
+
* Controls the open/closed state of the bottom sheet.
|
|
59
|
+
*
|
|
60
|
+
* When set to `true`, calls `dialog.showModal()` or `dialog.show()`
|
|
61
|
+
* depending on the `modal` property. When set to `false`, calls `dialog.close()`.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
19
65
|
open: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Height variant of the sheet container.
|
|
68
|
+
*
|
|
69
|
+
* - `'small'` — Compact; suitable for quick confirmations.
|
|
70
|
+
* - `'medium'` — Standard height (default).
|
|
71
|
+
* - `'large'` — Fills `expandedHeight` of the viewport.
|
|
72
|
+
* - `'auto'` — Content-driven; height adapts to the slotted content.
|
|
73
|
+
*
|
|
74
|
+
* @default 'medium'
|
|
75
|
+
*/
|
|
20
76
|
size: 'small' | 'medium' | 'large' | 'auto';
|
|
77
|
+
/**
|
|
78
|
+
* When `true` (default), the sheet opens as a modal dialog with a backdrop
|
|
79
|
+
* scrim. When `false`, it opens as a non-modal overlay with no scrim.
|
|
80
|
+
*
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
21
83
|
modal: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Heading text displayed in the sheet's header area.
|
|
86
|
+
*
|
|
87
|
+
* @default ''
|
|
88
|
+
*/
|
|
22
89
|
title: string;
|
|
90
|
+
/**
|
|
91
|
+
* Controls how the sheet is positioned in the document.
|
|
92
|
+
*
|
|
93
|
+
* - `'body'` (default) — Teleports the element to `document.body` so
|
|
94
|
+
* the fixed overlay renders above all stacking contexts.
|
|
95
|
+
* - `'fixed'` — Fixed positioning within its current DOM subtree.
|
|
96
|
+
* - `'absolute'` — Absolute within the nearest positioned ancestor.
|
|
97
|
+
* - `'static'` — Static flow (rarely needed; for testing only).
|
|
98
|
+
*
|
|
99
|
+
* @default 'fixed'
|
|
100
|
+
*/
|
|
23
101
|
positioning: 'body' | 'fixed' | 'absolute' | 'static';
|
|
102
|
+
/**
|
|
103
|
+
* Maximum block-size (height) of the sheet when `size="large"`.
|
|
104
|
+
*
|
|
105
|
+
* Accepts any valid CSS `max-block-size` value (e.g. `'85%'`, `'600px'`).
|
|
106
|
+
* Defaults to `'85%'` which is the M3-recommended maximum for bottom sheets
|
|
107
|
+
* on compact screens.
|
|
108
|
+
*
|
|
109
|
+
* @default '85%'
|
|
110
|
+
*/
|
|
24
111
|
expandedHeight: string;
|
|
112
|
+
/**
|
|
113
|
+
* Optional maximum inline-size (width) constraint for the sheet.
|
|
114
|
+
*
|
|
115
|
+
* When set (e.g. `'640px'`), the sheet will not exceed this width even on
|
|
116
|
+
* wide displays. Useful for tablet/desktop breakpoints where a centered
|
|
117
|
+
* modal is preferred over a full-width sheet.
|
|
118
|
+
*
|
|
119
|
+
* @default '' (no constraint)
|
|
120
|
+
*/
|
|
25
121
|
maxWidth: string;
|
|
122
|
+
/**
|
|
123
|
+
* Original parent node before teleportation to `document.body`.
|
|
124
|
+
* Used to restore the element's DOM position in `disconnectedCallback`.
|
|
125
|
+
*/
|
|
26
126
|
private _originalParent;
|
|
127
|
+
/**
|
|
128
|
+
* Original next sibling before teleportation to `document.body`.
|
|
129
|
+
* Used alongside `_originalParent` to restore the exact DOM position.
|
|
130
|
+
*/
|
|
27
131
|
private _originalSibling;
|
|
132
|
+
/** Direct reference to the native `<dialog>` element. */
|
|
28
133
|
private _dialog;
|
|
29
134
|
private _isDragging;
|
|
30
135
|
private _startY;
|
|
@@ -41,7 +146,7 @@ export declare class MoniBottomSheet extends MoniElement {
|
|
|
41
146
|
updated(changed: Map<string, unknown>): void;
|
|
42
147
|
disconnectedCallback(): void;
|
|
43
148
|
static styles: import("lit").CSSResult[];
|
|
44
|
-
render(): import("lit
|
|
149
|
+
render(): import("lit").TemplateResult<1>;
|
|
45
150
|
}
|
|
46
151
|
declare global {
|
|
47
152
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-bottom-sheet.d.ts","sourceRoot":"","sources":["../../src/components/moni-bottom-sheet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-bottom-sheet.d.ts","sourceRoot":"","sources":["../../src/components/moni-bottom-sheet.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBACa,eAAgB,SAAQ,WAAW;IAC/C;;;;;;;OAOG;IACyC,IAAI,UAAS;IAEzD;;;;;;;;;OASG;IAEH,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAY;IAEvD;;;;;OAKG;IACyC,KAAK,UAAQ;IAEzD;;;;OAIG;IAC0B,KAAK,SAAM;IAExC;;;;;;;;;;OAUG;IAEH,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAW;IAEhE;;;;;;;;OAQG;IAEH,cAAc,SAAS;IAEvB;;;;;;;;OAQG;IAEH,QAAQ,SAAM;IAEd;;;OAGG;IACH,OAAO,CAAC,eAAe,CAAqB;IAE5C;;;OAGG;IACH,OAAO,CAAC,gBAAgB,CAAqB;IAE7C,yDAAyD;IACxC,OAAO,CAAC,OAAO,CAAqB;IACrD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,oBAAoB,CAAK;IACjC,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,YAAY,CAAS;IAE7B,OAAO,CAAC,eAAe;IAcvB,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,cAAc;IAkCtB,OAAO,CAAC,YAAY;IAwFpB,OAAO,CAAC,gBAAgB;IAWxB,OAAO,CAAC,cAAc;IAyBb,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IA4BrC,oBAAoB;IAO7B,OAAgB,MAAM,4BAyHpB;IAEO,MAAM;CAsBf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,eAAe,CAAC;KACrC;CACD;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-bottom-sheet.ts
|
|
3
|
+
* @package @moni-labs/moni-ui
|
|
4
|
+
* @license MIT
|
|
5
|
+
* @contributors Moni Labs & Contributors
|
|
6
|
+
*/
|
|
1
7
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
8
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
9
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,32 +14,130 @@ import { html, css } from 'lit';
|
|
|
8
14
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
9
15
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
10
16
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
17
|
+
* Material Design 3 Bottom Sheet component.
|
|
18
|
+
*
|
|
19
|
+
* Bottom sheets are surfaces anchored to the bottom of the screen that
|
|
20
|
+
* supplement the main view. They display supplementary content, contextual
|
|
21
|
+
* actions, or task flows without fully obscuring the primary content.
|
|
22
|
+
*
|
|
23
|
+
* **M3 spec reference:** `m3-docs/components/sheets-bottom/specs.md`
|
|
24
|
+
*
|
|
25
|
+
* **Implementation note — native `<dialog>` element:**
|
|
26
|
+
* Like `<moni-dialog>`, this component wraps the native `<dialog>` element.
|
|
27
|
+
* The `open` property drives `dialog.showModal()` / `dialog.close()`. When
|
|
28
|
+
* `modal=true` (default), a `::backdrop` scrim is rendered automatically.
|
|
29
|
+
*
|
|
30
|
+
* **Teleportation (body-level mounting):**
|
|
31
|
+
* When `positioning="body"` (default), the component moves itself to
|
|
32
|
+
* `document.body` on `connectedCallback` so the fixed-bottom dialog renders
|
|
33
|
+
* above all stacking contexts. On `disconnectedCallback`, it is moved back
|
|
34
|
+
* to its original DOM position. This avoids clipping by `overflow: hidden`
|
|
35
|
+
* or `transform` ancestors.
|
|
36
|
+
*
|
|
37
|
+
* **Sizes:**
|
|
38
|
+
* - `small` — Compact sheet; suitable for simple action menus.
|
|
39
|
+
* - `medium` — Standard height (default).
|
|
40
|
+
* - `large` — Expanded height (`expandedHeight` controls the max block-size).
|
|
41
|
+
* - `auto` — Content-driven height.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```html
|
|
45
|
+
* <moni-bottom-sheet title="Share">
|
|
46
|
+
* <moni-list-item icon="share">Copy link</moni-list-item>
|
|
47
|
+
* <moni-list-item icon="mail">Send via email</moni-list-item>
|
|
48
|
+
* </moni-bottom-sheet>
|
|
49
|
+
*
|
|
50
|
+
* <script>
|
|
51
|
+
* document.querySelector('moni-bottom-sheet').open = true;
|
|
52
|
+
* </script>
|
|
53
|
+
* ```
|
|
14
54
|
*
|
|
15
|
-
*
|
|
16
|
-
* -
|
|
17
|
-
* -
|
|
18
|
-
* - modal: present → backdrop rendered
|
|
19
|
-
* - title: heading text
|
|
55
|
+
* @slot default - The body content of the bottom sheet.
|
|
56
|
+
* @slot handle - The drag handle area at the top of the sheet.
|
|
57
|
+
* @slot footer - Action buttons at the bottom of the sheet.
|
|
20
58
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
59
|
+
* @csspart dialog - The native `<dialog>` element.
|
|
60
|
+
* @csspart header - The header container with title and close button.
|
|
61
|
+
* @csspart body - The scrollable body content area.
|
|
62
|
+
* @csspart footer - The footer action buttons area.
|
|
25
63
|
*/
|
|
26
64
|
let MoniBottomSheet = class MoniBottomSheet extends MoniElement {
|
|
27
65
|
constructor() {
|
|
28
66
|
super(...arguments);
|
|
67
|
+
/**
|
|
68
|
+
* Controls the open/closed state of the bottom sheet.
|
|
69
|
+
*
|
|
70
|
+
* When set to `true`, calls `dialog.showModal()` or `dialog.show()`
|
|
71
|
+
* depending on the `modal` property. When set to `false`, calls `dialog.close()`.
|
|
72
|
+
*
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
29
75
|
this.open = false;
|
|
76
|
+
/**
|
|
77
|
+
* Height variant of the sheet container.
|
|
78
|
+
*
|
|
79
|
+
* - `'small'` — Compact; suitable for quick confirmations.
|
|
80
|
+
* - `'medium'` — Standard height (default).
|
|
81
|
+
* - `'large'` — Fills `expandedHeight` of the viewport.
|
|
82
|
+
* - `'auto'` — Content-driven; height adapts to the slotted content.
|
|
83
|
+
*
|
|
84
|
+
* @default 'medium'
|
|
85
|
+
*/
|
|
30
86
|
this.size = 'medium';
|
|
87
|
+
/**
|
|
88
|
+
* When `true` (default), the sheet opens as a modal dialog with a backdrop
|
|
89
|
+
* scrim. When `false`, it opens as a non-modal overlay with no scrim.
|
|
90
|
+
*
|
|
91
|
+
* @default true
|
|
92
|
+
*/
|
|
31
93
|
this.modal = true;
|
|
94
|
+
/**
|
|
95
|
+
* Heading text displayed in the sheet's header area.
|
|
96
|
+
*
|
|
97
|
+
* @default ''
|
|
98
|
+
*/
|
|
32
99
|
this.title = '';
|
|
100
|
+
/**
|
|
101
|
+
* Controls how the sheet is positioned in the document.
|
|
102
|
+
*
|
|
103
|
+
* - `'body'` (default) — Teleports the element to `document.body` so
|
|
104
|
+
* the fixed overlay renders above all stacking contexts.
|
|
105
|
+
* - `'fixed'` — Fixed positioning within its current DOM subtree.
|
|
106
|
+
* - `'absolute'` — Absolute within the nearest positioned ancestor.
|
|
107
|
+
* - `'static'` — Static flow (rarely needed; for testing only).
|
|
108
|
+
*
|
|
109
|
+
* @default 'fixed'
|
|
110
|
+
*/
|
|
33
111
|
this.positioning = 'fixed';
|
|
112
|
+
/**
|
|
113
|
+
* Maximum block-size (height) of the sheet when `size="large"`.
|
|
114
|
+
*
|
|
115
|
+
* Accepts any valid CSS `max-block-size` value (e.g. `'85%'`, `'600px'`).
|
|
116
|
+
* Defaults to `'85%'` which is the M3-recommended maximum for bottom sheets
|
|
117
|
+
* on compact screens.
|
|
118
|
+
*
|
|
119
|
+
* @default '85%'
|
|
120
|
+
*/
|
|
34
121
|
this.expandedHeight = '85%';
|
|
122
|
+
/**
|
|
123
|
+
* Optional maximum inline-size (width) constraint for the sheet.
|
|
124
|
+
*
|
|
125
|
+
* When set (e.g. `'640px'`), the sheet will not exceed this width even on
|
|
126
|
+
* wide displays. Useful for tablet/desktop breakpoints where a centered
|
|
127
|
+
* modal is preferred over a full-width sheet.
|
|
128
|
+
*
|
|
129
|
+
* @default '' (no constraint)
|
|
130
|
+
*/
|
|
35
131
|
this.maxWidth = '';
|
|
132
|
+
/**
|
|
133
|
+
* Original parent node before teleportation to `document.body`.
|
|
134
|
+
* Used to restore the element's DOM position in `disconnectedCallback`.
|
|
135
|
+
*/
|
|
36
136
|
this._originalParent = null;
|
|
137
|
+
/**
|
|
138
|
+
* Original next sibling before teleportation to `document.body`.
|
|
139
|
+
* Used alongside `_originalParent` to restore the exact DOM position.
|
|
140
|
+
*/
|
|
37
141
|
this._originalSibling = null;
|
|
38
142
|
this._isDragging = false;
|
|
39
143
|
this._startY = 0;
|