@moni-labs/moni-ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -194
- package/custom-elements.json +1636 -350
- package/dist/actions/index.d.ts +6 -0
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +6 -0
- package/dist/components/_base/field-styles.d.ts +51 -16
- package/dist/components/_base/field-styles.d.ts.map +1 -1
- package/dist/components/_base/field-styles.js +164 -36
- package/dist/components/_base/index.d.ts +25 -0
- package/dist/components/_base/index.d.ts.map +1 -1
- package/dist/components/_base/index.js +25 -0
- package/dist/components/_base/interaction-styles.d.ts +39 -12
- package/dist/components/_base/interaction-styles.d.ts.map +1 -1
- package/dist/components/_base/interaction-styles.js +85 -33
- package/dist/components/_base/moni-element.d.ts +43 -8
- package/dist/components/_base/moni-element.d.ts.map +1 -1
- package/dist/components/_base/moni-element.js +43 -8
- package/dist/components/_base/shared-styles.d.ts +41 -17
- package/dist/components/_base/shared-styles.d.ts.map +1 -1
- package/dist/components/_base/shared-styles.js +113 -21
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +6 -0
- package/dist/components/loading-shapes.d.ts +6 -0
- package/dist/components/loading-shapes.d.ts.map +1 -1
- package/dist/components/loading-shapes.js +6 -0
- package/dist/components/moni-app-bar.d.ts +128 -33
- package/dist/components/moni-app-bar.d.ts.map +1 -1
- package/dist/components/moni-app-bar.js +121 -26
- package/dist/components/moni-badge.d.ts +122 -14
- package/dist/components/moni-badge.d.ts.map +1 -1
- package/dist/components/moni-badge.js +122 -14
- package/dist/components/moni-bottom-sheet.d.ts +120 -15
- package/dist/components/moni-bottom-sheet.d.ts.map +1 -1
- package/dist/components/moni-bottom-sheet.js +116 -12
- package/dist/components/moni-button-group.d.ts +53 -27
- package/dist/components/moni-button-group.d.ts.map +1 -1
- package/dist/components/moni-button-group.js +49 -23
- package/dist/components/moni-button-segment.d.ts +28 -8
- package/dist/components/moni-button-segment.d.ts.map +1 -1
- package/dist/components/moni-button-segment.js +27 -7
- package/dist/components/moni-button.d.ts +51 -32
- package/dist/components/moni-button.d.ts.map +1 -1
- package/dist/components/moni-button.js +50 -31
- package/dist/components/moni-card.d.ts +91 -31
- package/dist/components/moni-card.d.ts.map +1 -1
- package/dist/components/moni-card.js +86 -26
- package/dist/components/moni-carousel.d.ts +67 -17
- package/dist/components/moni-carousel.d.ts.map +1 -1
- package/dist/components/moni-carousel.js +59 -16
- package/dist/components/moni-checkbox.d.ts +122 -17
- package/dist/components/moni-checkbox.d.ts.map +1 -1
- package/dist/components/moni-checkbox.js +118 -14
- package/dist/components/moni-chip.d.ts +56 -30
- package/dist/components/moni-chip.d.ts.map +1 -1
- package/dist/components/moni-chip.js +51 -25
- package/dist/components/moni-color-field.d.ts +44 -6
- package/dist/components/moni-color-field.d.ts.map +1 -1
- package/dist/components/moni-color-field.js +43 -5
- package/dist/components/moni-context-menu.d.ts +44 -22
- package/dist/components/moni-context-menu.d.ts.map +1 -1
- package/dist/components/moni-context-menu.js +43 -21
- package/dist/components/moni-dialog.d.ts +107 -15
- package/dist/components/moni-dialog.d.ts.map +1 -1
- package/dist/components/moni-dialog.js +105 -14
- package/dist/components/moni-divider.d.ts +50 -15
- package/dist/components/moni-divider.d.ts.map +1 -1
- package/dist/components/moni-divider.js +49 -14
- package/dist/components/moni-expansion.d.ts +44 -8
- package/dist/components/moni-expansion.d.ts.map +1 -1
- package/dist/components/moni-expansion.js +43 -7
- package/dist/components/moni-fab-menu.d.ts +39 -20
- package/dist/components/moni-fab-menu.d.ts.map +1 -1
- package/dist/components/moni-fab-menu.js +38 -19
- package/dist/components/moni-fab.d.ts +49 -23
- package/dist/components/moni-fab.d.ts.map +1 -1
- package/dist/components/moni-fab.js +46 -20
- package/dist/components/moni-file-field.d.ts +54 -14
- package/dist/components/moni-file-field.d.ts.map +1 -1
- package/dist/components/moni-file-field.js +53 -13
- package/dist/components/moni-icon.d.ts +78 -11
- package/dist/components/moni-icon.d.ts.map +1 -1
- package/dist/components/moni-icon.js +77 -10
- package/dist/components/moni-list-item.d.ts +61 -30
- package/dist/components/moni-list-item.d.ts.map +1 -1
- package/dist/components/moni-list-item.js +55 -24
- package/dist/components/moni-list.d.ts +37 -13
- package/dist/components/moni-list.d.ts.map +1 -1
- package/dist/components/moni-list.js +36 -12
- package/dist/components/moni-loading-indicator.d.ts +38 -11
- package/dist/components/moni-loading-indicator.d.ts.map +1 -1
- package/dist/components/moni-loading-indicator.js +37 -10
- package/dist/components/moni-menu-item.d.ts +31 -8
- package/dist/components/moni-menu-item.d.ts.map +1 -1
- package/dist/components/moni-menu-item.js +30 -7
- package/dist/components/moni-menu.d.ts +58 -33
- package/dist/components/moni-menu.d.ts.map +1 -1
- package/dist/components/moni-menu.js +51 -26
- package/dist/components/moni-morph-modal.d.ts +7 -1
- package/dist/components/moni-morph-modal.d.ts.map +1 -1
- package/dist/components/moni-morph-modal.js +46 -24
- package/dist/components/moni-nav-item.d.ts +50 -10
- package/dist/components/moni-nav-item.d.ts.map +1 -1
- package/dist/components/moni-nav-item.js +48 -8
- package/dist/components/moni-nav.d.ts +57 -22
- package/dist/components/moni-nav.d.ts.map +1 -1
- package/dist/components/moni-nav.js +53 -18
- package/dist/components/moni-progress.d.ts +108 -20
- package/dist/components/moni-progress.d.ts.map +1 -1
- package/dist/components/moni-progress.js +104 -16
- package/dist/components/moni-radio.d.ts +106 -14
- package/dist/components/moni-radio.d.ts.map +1 -1
- package/dist/components/moni-radio.js +104 -13
- package/dist/components/moni-ripple.d.ts +121 -10
- package/dist/components/moni-ripple.d.ts.map +1 -1
- package/dist/components/moni-ripple.js +120 -9
- package/dist/components/moni-segmented-button.d.ts +31 -11
- package/dist/components/moni-segmented-button.d.ts.map +1 -1
- package/dist/components/moni-segmented-button.js +30 -10
- package/dist/components/moni-select-option.d.ts +43 -9
- package/dist/components/moni-select-option.d.ts.map +1 -1
- package/dist/components/moni-select-option.js +41 -7
- package/dist/components/moni-select.d.ts +59 -2
- package/dist/components/moni-select.d.ts.map +1 -1
- package/dist/components/moni-select.js +58 -1
- package/dist/components/moni-shape.d.ts +1 -1
- package/dist/components/moni-side-sheet.d.ts +56 -19
- package/dist/components/moni-side-sheet.d.ts.map +1 -1
- package/dist/components/moni-side-sheet.js +53 -16
- package/dist/components/moni-slider.d.ts +56 -25
- package/dist/components/moni-slider.d.ts.map +1 -1
- package/dist/components/moni-slider.js +55 -24
- package/dist/components/moni-snackbar.d.ts +86 -17
- package/dist/components/moni-snackbar.d.ts.map +1 -1
- package/dist/components/moni-snackbar.js +85 -16
- package/dist/components/moni-split-button.d.ts +38 -9
- package/dist/components/moni-split-button.d.ts.map +1 -1
- package/dist/components/moni-split-button.js +37 -8
- package/dist/components/moni-step.d.ts +42 -9
- package/dist/components/moni-step.d.ts.map +1 -1
- package/dist/components/moni-step.js +41 -8
- package/dist/components/moni-stepper.d.ts +43 -6
- package/dist/components/moni-stepper.d.ts.map +1 -1
- package/dist/components/moni-stepper.js +42 -5
- package/dist/components/moni-switch.d.ts +103 -16
- package/dist/components/moni-switch.d.ts.map +1 -1
- package/dist/components/moni-switch.js +99 -13
- package/dist/components/moni-tab.d.ts +35 -8
- package/dist/components/moni-tab.d.ts.map +1 -1
- package/dist/components/moni-tab.js +34 -7
- package/dist/components/moni-tabs.d.ts +51 -13
- package/dist/components/moni-tabs.d.ts.map +1 -1
- package/dist/components/moni-tabs.js +48 -10
- package/dist/components/moni-text-field.d.ts +55 -10
- package/dist/components/moni-text-field.d.ts.map +1 -1
- package/dist/components/moni-text-field.js +54 -9
- package/dist/components/moni-textarea.d.ts +51 -21
- package/dist/components/moni-textarea.d.ts.map +1 -1
- package/dist/components/moni-textarea.js +48 -18
- package/dist/components/moni-time-picker.d.ts +41 -11
- package/dist/components/moni-time-picker.d.ts.map +1 -1
- package/dist/components/moni-time-picker.js +40 -10
- package/dist/components/moni-toolbar.d.ts +43 -15
- package/dist/components/moni-toolbar.d.ts.map +1 -1
- package/dist/components/moni-toolbar.js +42 -14
- package/dist/components/moni-tooltip.d.ts +55 -25
- package/dist/components/moni-tooltip.d.ts.map +1 -1
- package/dist/components/moni-tooltip.js +54 -24
- package/dist/components/moni-typography.d.ts +43 -18
- package/dist/components/moni-typography.d.ts.map +1 -1
- package/dist/components/moni-typography.js +42 -17
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -2
- package/dist/styles/tailwind.css +67 -0
- package/dist/styles/tokens.css +111 -99
- package/dist/utils/color.d.ts +181 -2
- package/dist/utils/color.d.ts.map +1 -1
- package/dist/utils/color.js +182 -4
- package/dist/utils/theme.svelte.d.ts +305 -2
- package/dist/utils/theme.svelte.d.ts.map +1 -1
- package/dist/utils/theme.svelte.js +331 -2
- package/dist/web-components.d.ts +28 -0
- package/dist/web-components.d.ts.map +1 -1
- package/dist/web-components.js +29 -2
- package/package.json +1 -1
- package/src/actions/index.ts +7 -0
- package/src/components/_base/field-styles.ts +165 -37
- package/src/components/_base/index.ts +27 -0
- package/src/components/_base/interaction-styles.ts +86 -33
- package/src/components/_base/moni-element.ts +44 -8
- package/src/components/_base/shared-styles.ts +114 -21
- package/src/components/index.ts +7 -0
- package/src/components/loading-shapes.ts +7 -0
- package/src/components/moni-app-bar.ts +127 -26
- package/src/components/moni-badge.ts +128 -14
- package/src/components/moni-bottom-sheet.ts +125 -13
- package/src/components/moni-button-group.ts +50 -23
- package/src/components/moni-button-segment.ts +28 -7
- package/src/components/moni-button.ts +51 -31
- package/src/components/moni-card.ts +90 -26
- package/src/components/moni-carousel.ts +67 -16
- package/src/components/moni-checkbox.ts +125 -14
- package/src/components/moni-chip.ts +52 -25
- package/src/components/moni-color-field.ts +44 -5
- package/src/components/moni-context-menu.ts +44 -21
- package/src/components/moni-dialog.ts +111 -14
- package/src/components/moni-divider.ts +50 -14
- package/src/components/moni-expansion.ts +44 -7
- package/src/components/moni-fab-menu.ts +39 -19
- package/src/components/moni-fab.ts +47 -20
- package/src/components/moni-file-field.ts +54 -13
- package/src/components/moni-icon.ts +80 -10
- package/src/components/moni-list-item.ts +56 -24
- package/src/components/moni-list.ts +37 -12
- package/src/components/moni-loading-indicator.ts +38 -10
- package/src/components/moni-menu-item.ts +31 -7
- package/src/components/moni-menu.ts +52 -26
- package/src/components/moni-morph-modal.ts +58 -24
- package/src/components/moni-nav-item.ts +49 -8
- package/src/components/moni-nav.ts +54 -18
- package/src/components/moni-progress.ts +109 -16
- package/src/components/moni-radio.ts +111 -13
- package/src/components/moni-ripple.ts +126 -9
- package/src/components/moni-segmented-button.ts +31 -10
- package/src/components/moni-select-option.ts +42 -7
- package/src/components/moni-select.ts +79 -1
- package/src/components/moni-side-sheet.ts +54 -16
- package/src/components/moni-slider.ts +56 -24
- package/src/components/moni-snackbar.ts +90 -16
- package/src/components/moni-split-button.ts +38 -8
- package/src/components/moni-step.ts +42 -8
- package/src/components/moni-stepper.ts +43 -5
- package/src/components/moni-switch.ts +106 -13
- package/src/components/moni-tab.ts +35 -7
- package/src/components/moni-tabs.ts +49 -10
- package/src/components/moni-text-field.ts +55 -9
- package/src/components/moni-textarea.ts +49 -18
- package/src/components/moni-time-picker.ts +41 -10
- package/src/components/moni-toolbar.ts +43 -14
- package/src/components/moni-tooltip.ts +55 -24
- package/src/components/moni-typography.ts +43 -17
- package/src/index.ts +67 -3
- package/src/styles/tailwind.css +67 -0
- package/src/styles/tokens.css +111 -99
- package/src/types/svelte-runes.d.ts +64 -2
- package/src/utils/color.ts +286 -5
- package/src/utils/theme.svelte.ts +411 -2
- package/src/web-components.ts +31 -2
- package/dist/assets/shapes/arch.svg +0 -1
- package/dist/assets/shapes/arrow.svg +0 -1
- package/dist/assets/shapes/boom.svg +0 -1
- package/dist/assets/shapes/burst.svg +0 -1
- package/dist/assets/shapes/circle.svg +0 -1
- package/dist/assets/shapes/clamshell.svg +0 -1
- package/dist/assets/shapes/diamond.svg +0 -1
- package/dist/assets/shapes/fan.svg +0 -1
- package/dist/assets/shapes/flower.svg +0 -1
- package/dist/assets/shapes/gem.svg +0 -1
- package/dist/assets/shapes/ghost-ish.svg +0 -1
- package/dist/assets/shapes/heart.svg +0 -1
- package/dist/assets/shapes/leaf-clover4.svg +0 -1
- package/dist/assets/shapes/leaf-clover8.svg +0 -1
- package/dist/assets/shapes/loading-indicator.svg +0 -1
- package/dist/assets/shapes/oval.svg +0 -1
- package/dist/assets/shapes/pentagon.svg +0 -1
- package/dist/assets/shapes/pill.svg +0 -1
- package/dist/assets/shapes/pixel-circle.svg +0 -1
- package/dist/assets/shapes/pixel-triangle.svg +0 -1
- package/dist/assets/shapes/puffy-diamond.svg +0 -1
- package/dist/assets/shapes/puffy.svg +0 -1
- package/dist/assets/shapes/semicircle.svg +0 -1
- package/dist/assets/shapes/sided-cookie12.svg +0 -1
- package/dist/assets/shapes/sided-cookie4.svg +0 -1
- package/dist/assets/shapes/sided-cookie6.svg +0 -1
- package/dist/assets/shapes/sided-cookie7.svg +0 -1
- package/dist/assets/shapes/sided-cookie9.svg +0 -1
- package/dist/assets/shapes/slanted.svg +0 -1
- package/dist/assets/shapes/soft-boom.svg +0 -1
- package/dist/assets/shapes/soft-burst.svg +0 -1
- package/dist/assets/shapes/square.svg +0 -1
- package/dist/assets/shapes/sunny.svg +0 -1
- package/dist/assets/shapes/triangle.svg +0 -1
- package/dist/assets/shapes/very-sunny.svg +0 -1
- package/dist/assets/shapes/wavy-circle.svg +0 -1
- package/dist/assets/shapes/wavy.svg +0 -1
- package/src/assets/shapes/arch.svg +0 -1
- package/src/assets/shapes/arrow.svg +0 -1
- package/src/assets/shapes/boom.svg +0 -1
- package/src/assets/shapes/burst.svg +0 -1
- package/src/assets/shapes/circle.svg +0 -1
- package/src/assets/shapes/clamshell.svg +0 -1
- package/src/assets/shapes/diamond.svg +0 -1
- package/src/assets/shapes/fan.svg +0 -1
- package/src/assets/shapes/flower.svg +0 -1
- package/src/assets/shapes/gem.svg +0 -1
- package/src/assets/shapes/ghost-ish.svg +0 -1
- package/src/assets/shapes/heart.svg +0 -1
- package/src/assets/shapes/leaf-clover4.svg +0 -1
- package/src/assets/shapes/leaf-clover8.svg +0 -1
- package/src/assets/shapes/loading-indicator.svg +0 -1
- package/src/assets/shapes/oval.svg +0 -1
- package/src/assets/shapes/pentagon.svg +0 -1
- package/src/assets/shapes/pill.svg +0 -1
- package/src/assets/shapes/pixel-circle.svg +0 -1
- package/src/assets/shapes/pixel-triangle.svg +0 -1
- package/src/assets/shapes/puffy-diamond.svg +0 -1
- package/src/assets/shapes/puffy.svg +0 -1
- package/src/assets/shapes/semicircle.svg +0 -1
- package/src/assets/shapes/sided-cookie12.svg +0 -1
- package/src/assets/shapes/sided-cookie4.svg +0 -1
- package/src/assets/shapes/sided-cookie6.svg +0 -1
- package/src/assets/shapes/sided-cookie7.svg +0 -1
- package/src/assets/shapes/sided-cookie9.svg +0 -1
- package/src/assets/shapes/slanted.svg +0 -1
- package/src/assets/shapes/soft-boom.svg +0 -1
- package/src/assets/shapes/soft-burst.svg +0 -1
- package/src/assets/shapes/square.svg +0 -1
- package/src/assets/shapes/sunny.svg +0 -1
- package/src/assets/shapes/triangle.svg +0 -1
- package/src/assets/shapes/very-sunny.svg +0 -1
- package/src/assets/shapes/wavy-circle.svg +0 -1
- package/src/assets/shapes/wavy.svg +0 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-checkbox.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);
|
|
@@ -10,33 +16,114 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
10
16
|
import { live } from 'lit/directives/live.js';
|
|
11
17
|
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* Material Design 3 Checkbox component.
|
|
20
|
+
*
|
|
21
|
+
* Checkboxes allow users to select one or more items from a set, or toggle
|
|
22
|
+
* a single binary option. They are visual-only shells — the consumer is
|
|
23
|
+
* responsible for wiring up form submission and validation logic.
|
|
24
|
+
*
|
|
25
|
+
* **Visual architecture (BeerCSS pattern):**
|
|
26
|
+
* The native `<input type="checkbox">` occupies real layout space (16×16 minimum)
|
|
27
|
+
* but is visually hidden via `opacity: 0`. A `<span>` sibling rendered after
|
|
28
|
+
* the input holds two pseudo-elements:
|
|
29
|
+
* - `::before` — the visible checkbox icon (Material Symbols ligature).
|
|
30
|
+
* - `::after` — the hover/focus state layer ripple ring.
|
|
31
|
+
*
|
|
32
|
+
* The `::before` content switches between:
|
|
33
|
+
* - `'check_box_outline_blank'` (unchecked)
|
|
34
|
+
* - `'check_box'` (checked)
|
|
35
|
+
* - `'indeterminate_check_box'` (native indeterminate state)
|
|
36
|
+
*
|
|
37
|
+
* **Form integration:**
|
|
38
|
+
* Setting `name` and `value` passes them to the native `<input>` element,
|
|
39
|
+
* enabling participation in HTML form submissions.
|
|
40
|
+
*
|
|
41
|
+
* @fires change - Bubbles and is composed. Fired when the checkbox is toggled.
|
|
42
|
+
* The consumer can read `element.checked` for the new state.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```html
|
|
46
|
+
* <moni-checkbox label="Accept terms" name="terms" value="yes"></moni-checkbox>
|
|
14
47
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
48
|
+
* <script>
|
|
49
|
+
* document.querySelector('moni-checkbox').addEventListener('change', (e) => {
|
|
50
|
+
* console.log('checked:', e.target.checked);
|
|
51
|
+
* });
|
|
52
|
+
* </script>
|
|
53
|
+
* ```
|
|
21
54
|
*
|
|
22
|
-
*
|
|
23
|
-
* - label: text label
|
|
24
|
-
* - checked: present → input is checked
|
|
25
|
-
* - disabled: present → input is disabled
|
|
26
|
-
* - size: small | medium (default) | large | extra
|
|
27
|
-
* - name: forwarded to input.name
|
|
28
|
-
* - value: forwarded to input.value
|
|
55
|
+
* @csspart checkbox - The outer `<label>` element.
|
|
29
56
|
*/
|
|
30
57
|
let MoniCheckbox = class MoniCheckbox extends MoniElement {
|
|
31
58
|
constructor() {
|
|
32
59
|
super(...arguments);
|
|
60
|
+
/**
|
|
61
|
+
* Text label displayed to the right of the checkbox icon.
|
|
62
|
+
*
|
|
63
|
+
* When non-empty, the label is rendered as a text node inside the `<span>`.
|
|
64
|
+
* When empty, the default slot is rendered instead, allowing slotted HTML.
|
|
65
|
+
*
|
|
66
|
+
* @default ''
|
|
67
|
+
*/
|
|
33
68
|
this.label = '';
|
|
69
|
+
/**
|
|
70
|
+
* Whether the checkbox is currently checked.
|
|
71
|
+
*
|
|
72
|
+
* Reflected as an attribute so CSS attribute selectors and external state
|
|
73
|
+
* readers can observe the checked state without accessing the JS property.
|
|
74
|
+
* Synced to the native input via `updated()`.
|
|
75
|
+
*
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
34
78
|
this.checked = false;
|
|
79
|
+
/**
|
|
80
|
+
* When `true`, the native input is disabled: the checkbox is not interactive
|
|
81
|
+
* and renders at 50% opacity.
|
|
82
|
+
*
|
|
83
|
+
* @default false
|
|
84
|
+
*/
|
|
35
85
|
this.disabled = false;
|
|
86
|
+
/**
|
|
87
|
+
* Visual size of the checkbox icon.
|
|
88
|
+
*
|
|
89
|
+
* Maps to the `--_size` custom property which controls both the invisible
|
|
90
|
+
* input's hit area and the visible `::before` icon size.
|
|
91
|
+
*
|
|
92
|
+
* | Value | `--_size` |
|
|
93
|
+
* |------------|-----------|
|
|
94
|
+
* | `'small'` | 1rem |
|
|
95
|
+
* | `'medium'` | 1.5rem |
|
|
96
|
+
* | `'large'` | 2rem |
|
|
97
|
+
* | `'extra'` | 2.5rem |
|
|
98
|
+
*
|
|
99
|
+
* @default 'medium'
|
|
100
|
+
*/
|
|
36
101
|
this.size = 'medium';
|
|
102
|
+
/**
|
|
103
|
+
* Forwarded to the native `<input name>` attribute.
|
|
104
|
+
* Required for grouping checkboxes within a form.
|
|
105
|
+
*
|
|
106
|
+
* @default ''
|
|
107
|
+
*/
|
|
37
108
|
this.name = '';
|
|
109
|
+
/**
|
|
110
|
+
* Forwarded to the native `<input value>` attribute.
|
|
111
|
+
* The value submitted in a form when this checkbox is checked.
|
|
112
|
+
*
|
|
113
|
+
* @default ''
|
|
114
|
+
*/
|
|
38
115
|
this.value = '';
|
|
39
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Syncs `checked` and `disabled` back to the native input element after
|
|
119
|
+
* Lit's render cycle, ensuring the DOM stays in sync with component state.
|
|
120
|
+
*
|
|
121
|
+
* This is necessary because Lit's `.property=${value}` binding updates the
|
|
122
|
+
* DOM property, but the `live()` directive and direct property assignment
|
|
123
|
+
* are more reliable for boolean inputs across browser implementations.
|
|
124
|
+
*
|
|
125
|
+
* @param changed - Map of changed property names to their previous values.
|
|
126
|
+
*/
|
|
40
127
|
updated(changed) {
|
|
41
128
|
if (this._input) {
|
|
42
129
|
if (changed.has('checked'))
|
|
@@ -162,10 +249,27 @@ let MoniCheckbox = class MoniCheckbox extends MoniElement {
|
|
|
162
249
|
}
|
|
163
250
|
`
|
|
164
251
|
]; }
|
|
252
|
+
/**
|
|
253
|
+
* Handles the native input's `change` event.
|
|
254
|
+
*
|
|
255
|
+
* Reads the new checked state from the input and re-dispatches a composed
|
|
256
|
+
* `'change'` event so the signal crosses shadow DOM boundaries and can be
|
|
257
|
+
* heard by parent elements in the light DOM.
|
|
258
|
+
*
|
|
259
|
+
* @param e - The native `change` event from the hidden `<input>`.
|
|
260
|
+
*/
|
|
165
261
|
_onChange(e) {
|
|
166
262
|
this.checked = e.target.checked;
|
|
167
263
|
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
168
264
|
}
|
|
265
|
+
/**
|
|
266
|
+
* Renders the accessible checkbox label structure.
|
|
267
|
+
*
|
|
268
|
+
* The `<label>` wraps the hidden `<input>` and a `<span>` so that clicking
|
|
269
|
+
* anywhere on the label area (including the text) toggles the checkbox.
|
|
270
|
+
* The `has-label` class on the span adds left padding to separate the icon
|
|
271
|
+
* from the label text.
|
|
272
|
+
*/
|
|
169
273
|
render() {
|
|
170
274
|
return html `<label part="checkbox">
|
|
171
275
|
<input
|
|
@@ -1,36 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-chip.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
|
import './moni-icon.js';
|
|
3
9
|
import './moni-progress.js';
|
|
4
10
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
11
|
+
* Material Design 3 Chip component.
|
|
12
|
+
*
|
|
13
|
+
* Chips are compact, interactive elements that represent actions, filters,
|
|
14
|
+
* attributes, or user inputs. They are visual-only shells — the consumer
|
|
15
|
+
* owns all state management (selection, removal, active filter state).
|
|
16
|
+
*
|
|
17
|
+
* **M3 spec reference:** `m3-docs/components/chips/specs.md`
|
|
18
|
+
*
|
|
19
|
+
* **Variants:**
|
|
20
|
+
* - `assist` (default) — Smart or suggested actions. Uses `var(--outline)` border
|
|
21
|
+
* to ensure 3:1 contrast per the M3 accessibility spec. Alias: `outlined`.
|
|
22
|
+
* - `filter` — Filters for a content collection. Shows a leading checkmark when
|
|
23
|
+
* `selected`. Alias: `fill`.
|
|
24
|
+
* - `input` — Represents discrete user input (tags, tokens). Adds a trailing
|
|
25
|
+
* remove icon when `removable`.
|
|
26
|
+
* - `suggestion` — Product-generated suggestions. Outlined, no icons.
|
|
27
|
+
*
|
|
28
|
+
* **M3 measurements:**
|
|
29
|
+
* - Default height: 32dp (`small` size = M3 spec baseline).
|
|
30
|
+
* - Corner radius: 8dp.
|
|
31
|
+
* - Icon size: 18dp.
|
|
32
|
+
* - `medium` and `large` sizes are Moni extensions with larger touch targets.
|
|
33
|
+
*
|
|
34
|
+
* **Accessibility:**
|
|
35
|
+
* `assist` and `suggestion` chips use `var(--outline)` for their stroke to
|
|
36
|
+
* guarantee 3:1 contrast against the surface background at rest.
|
|
37
|
+
* `filter` and `input` use `outline-variant` at rest but achieve contrast
|
|
38
|
+
* through the `secondary-container` fill when selected.
|
|
39
|
+
*
|
|
40
|
+
* @fires remove - Bubbles and is composed. Fired when the trailing remove
|
|
41
|
+
* icon is clicked on an `input` chip with `removable`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```html
|
|
45
|
+
* <!-- Filter chip with selected state -->
|
|
46
|
+
* <moni-chip variant="filter" selected>Technology</moni-chip>
|
|
47
|
+
*
|
|
48
|
+
* <!-- Input chip (tag/token) -->
|
|
49
|
+
* <moni-chip variant="input" removable icon="label">TypeScript</moni-chip>
|
|
50
|
+
*
|
|
51
|
+
* <!-- Assist chip with icon -->
|
|
52
|
+
* <moni-chip icon="directions_car">Get directions</moni-chip>
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @slot default - The chip label text.
|
|
56
|
+
* @slot icon - Override for the leading icon (alternative to the `icon` attribute).
|
|
57
|
+
*
|
|
58
|
+
* @csspart chip - The inner `<button>` element.
|
|
59
|
+
* @csspart label - The label `<span>` element.
|
|
34
60
|
*/
|
|
35
61
|
export declare class MoniChip extends MoniElement {
|
|
36
62
|
variant: 'assist' | 'filter' | 'input' | 'suggestion' | 'outlined' | 'fill';
|
|
@@ -46,7 +72,7 @@ export declare class MoniChip extends MoniElement {
|
|
|
46
72
|
/** Normalize legacy variant names to M3 spec. */
|
|
47
73
|
private get _variant();
|
|
48
74
|
static styles: import("lit").CSSResult[];
|
|
49
|
-
render(): import("lit
|
|
75
|
+
render(): import("lit").TemplateResult<1>;
|
|
50
76
|
}
|
|
51
77
|
declare global {
|
|
52
78
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-chip.d.ts","sourceRoot":"","sources":["../../src/components/moni-chip.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-chip.d.ts","sourceRoot":"","sources":["../../src/components/moni-chip.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,gBAAgB,CAAC;AACxB,OAAO,oBAAoB,CAAC;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,qBACa,QAAS,SAAQ,WAAW;IAExC,OAAO,EACJ,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,YAAY,GACZ,UAAU,GACV,MAAM,CAAY;IAErB,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAW;IAE7C,KAAK,EACF,OAAO,GACP,UAAU,GACV,QAAQ,GACR,QAAQ,GACR,YAAY,GACZ,aAAa,GACb,WAAW,GACX,cAAc,CAAW;IACgB,QAAQ,UAAS;IACjB,SAAS,UAAS;IAClB,QAAQ,UAAS;IACjB,OAAO,UAAS;IAC/B,IAAI,SAAM;IAGvC,OAAO,CAAC,eAAe,CAAS;IAEhC,OAAO,CAAC,iBAAiB;IAKzB,iDAAiD;IACjD,OAAO,KAAK,QAAQ,GAInB;IAED,OAAgB,MAAM,4BAqLpB;IAEO,MAAM;CA+Df;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,WAAW,EAAE,QAAQ,CAAC;KACtB;CACD;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-chip.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);
|
|
@@ -10,35 +16,55 @@ import { MoniElement, sharedStyles } from './_base/index.js';
|
|
|
10
16
|
import './moni-icon.js';
|
|
11
17
|
import './moni-progress.js';
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* Material Design 3 Chip component.
|
|
20
|
+
*
|
|
21
|
+
* Chips are compact, interactive elements that represent actions, filters,
|
|
22
|
+
* attributes, or user inputs. They are visual-only shells — the consumer
|
|
23
|
+
* owns all state management (selection, removal, active filter state).
|
|
24
|
+
*
|
|
25
|
+
* **M3 spec reference:** `m3-docs/components/chips/specs.md`
|
|
26
|
+
*
|
|
27
|
+
* **Variants:**
|
|
28
|
+
* - `assist` (default) — Smart or suggested actions. Uses `var(--outline)` border
|
|
29
|
+
* to ensure 3:1 contrast per the M3 accessibility spec. Alias: `outlined`.
|
|
30
|
+
* - `filter` — Filters for a content collection. Shows a leading checkmark when
|
|
31
|
+
* `selected`. Alias: `fill`.
|
|
32
|
+
* - `input` — Represents discrete user input (tags, tokens). Adds a trailing
|
|
33
|
+
* remove icon when `removable`.
|
|
34
|
+
* - `suggestion` — Product-generated suggestions. Outlined, no icons.
|
|
35
|
+
*
|
|
36
|
+
* **M3 measurements:**
|
|
37
|
+
* - Default height: 32dp (`small` size = M3 spec baseline).
|
|
38
|
+
* - Corner radius: 8dp.
|
|
39
|
+
* - Icon size: 18dp.
|
|
40
|
+
* - `medium` and `large` sizes are Moni extensions with larger touch targets.
|
|
41
|
+
*
|
|
42
|
+
* **Accessibility:**
|
|
43
|
+
* `assist` and `suggestion` chips use `var(--outline)` for their stroke to
|
|
44
|
+
* guarantee 3:1 contrast against the surface background at rest.
|
|
45
|
+
* `filter` and `input` use `outline-variant` at rest but achieve contrast
|
|
46
|
+
* through the `secondary-container` fill when selected.
|
|
47
|
+
*
|
|
48
|
+
* @fires remove - Bubbles and is composed. Fired when the trailing remove
|
|
49
|
+
* icon is clicked on an `input` chip with `removable`.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```html
|
|
53
|
+
* <!-- Filter chip with selected state -->
|
|
54
|
+
* <moni-chip variant="filter" selected>Technology</moni-chip>
|
|
14
55
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* - **filter** — filters for a collection; outlined; leading check when selected.
|
|
18
|
-
* - **input** — discrete user input; outlined; trailing remove icon.
|
|
19
|
-
* - **suggestion** — product-generated suggestions; outlined; no icons.
|
|
56
|
+
* <!-- Input chip (tag/token) -->
|
|
57
|
+
* <moni-chip variant="input" removable icon="label">TypeScript</moni-chip>
|
|
20
58
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
59
|
+
* <!-- Assist chip with icon -->
|
|
60
|
+
* <moni-chip icon="directions_car">Get directions</moni-chip>
|
|
61
|
+
* ```
|
|
24
62
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* § *Showing chip interactivity*). `filter` and `input` use `outline-variant`
|
|
28
|
-
* for the resting state but show a clear `secondary-container` background
|
|
29
|
-
* when selected, passing contrast.
|
|
63
|
+
* @slot default - The chip label text.
|
|
64
|
+
* @slot icon - Override for the leading icon (alternative to the `icon` attribute).
|
|
30
65
|
*
|
|
31
|
-
*
|
|
32
|
-
* -
|
|
33
|
-
* | outlined (alias for assist) | fill (alias for filter)
|
|
34
|
-
* - size: small (default, 32dp = M3) | medium | large
|
|
35
|
-
* - shape: round (default) | square | circle | no-round
|
|
36
|
-
* | left-round | right-round | top-round | bottom-round
|
|
37
|
-
* - selected: present → background uses secondary-container (M3 filter/input)
|
|
38
|
-
* - removable: present → adds a trailing ✕ icon (M3 input chip, visual only)
|
|
39
|
-
* - disabled: present → native disabled
|
|
40
|
-
* - loading: present → shows indeterminate circular progress
|
|
41
|
-
* - icon: Material Symbols name (leading icon)
|
|
66
|
+
* @csspart chip - The inner `<button>` element.
|
|
67
|
+
* @csspart label - The label `<span>` element.
|
|
42
68
|
*/
|
|
43
69
|
let MoniChip = class MoniChip extends MoniElement {
|
|
44
70
|
constructor() {
|
|
@@ -1,11 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-color-field.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
|
-
*
|
|
9
|
+
* Material Design 3 Color Field component.
|
|
10
|
+
*
|
|
11
|
+
* A specialized text field for color input that combines a native
|
|
12
|
+
* `<input type="color">` with a read-only text display of the selected
|
|
13
|
+
* hex value, wrapped in the standard M3 field shell.
|
|
14
|
+
*
|
|
15
|
+
* **Visual architecture:**
|
|
16
|
+
* Extends the field styling pattern used by `<moni-text-field>`. The
|
|
17
|
+
* leading icon slot is replaced by a circular color swatch (`.swatch`)
|
|
18
|
+
* which is absolutely positioned over an invisible native color input.
|
|
19
|
+
* Clicking the swatch opens the system color picker. The text input portion
|
|
20
|
+
* displays the selected hex code and is strictly `readOnly`.
|
|
21
|
+
*
|
|
22
|
+
* **State syncing:**
|
|
23
|
+
* The component listens to the native `change` event on the color input,
|
|
24
|
+
* updates the `value` property, and re-dispatches a composed `'change'` event.
|
|
25
|
+
* It does not listen to `input` (continuous drag in the color picker) to avoid
|
|
26
|
+
* excessive event firing, but consumers can attach their own `input` listeners
|
|
27
|
+
* directly to the element if live preview is needed.
|
|
28
|
+
*
|
|
29
|
+
* @fires change - Bubbles and is composed. Fired when the color picker closes
|
|
30
|
+
* and the value is committed. Read `element.value`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```html
|
|
34
|
+
* <moni-color-field
|
|
35
|
+
* label="Theme Color"
|
|
36
|
+
* name="primaryColor"
|
|
37
|
+
* value="#6750a4"
|
|
38
|
+
* variant="outlined"
|
|
39
|
+
* ></moni-color-field>
|
|
40
|
+
* ```
|
|
5
41
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
42
|
+
* @csspart field - The outer `.field` div container.
|
|
43
|
+
* @csspart swatch - The circular color preview element.
|
|
44
|
+
* @csspart input-color - The native, visually hidden `<input type="color">`.
|
|
45
|
+
* @csspart input-text - The native `<input type="text">` displaying the hex code.
|
|
46
|
+
* @csspart label - The floating `<label>` element.
|
|
9
47
|
*/
|
|
10
48
|
export declare class MoniColorField extends MoniElement {
|
|
11
49
|
name: string;
|
|
@@ -22,7 +60,7 @@ export declare class MoniColorField extends MoniElement {
|
|
|
22
60
|
private _textInput;
|
|
23
61
|
updated(changed: Map<string, unknown>): void;
|
|
24
62
|
static styles: import("lit").CSSResult[];
|
|
25
|
-
render(): import("lit
|
|
63
|
+
render(): import("lit").TemplateResult<1>;
|
|
26
64
|
}
|
|
27
65
|
declare global {
|
|
28
66
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-color-field.d.ts","sourceRoot":"","sources":["../../src/components/moni-color-field.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-color-field.d.ts","sourceRoot":"","sources":["../../src/components/moni-color-field.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAE,WAAW,EAA6B,MAAM,kBAAkB,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBACa,cAAe,SAAQ,WAAW;IACjB,IAAI,SAAM;IACV,KAAK,SAAM;IACX,OAAO,EAAE,QAAQ,GAAG,UAAU,CAAc;IAEzE,IAAI,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,CAAY;IAExD,KAAK,EAAE,OAAO,GAAG,QAAQ,GAAG,UAAU,CAAc;IACR,QAAQ,UAAS;IAChC,MAAM,SAAM;IACa,SAAS,SAAM;IACzB,KAAK,UAAS;IAC7B,KAAK,SAAa;IAEjB,OAAO,CAAC,WAAW,CAAoB;IACxC,OAAO,CAAC,UAAU,CAAoB;IAE1D,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;IAW9C,OAAgB,MAAM,4BA0BpB;IAEO,MAAM;CAuDf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,kBAAkB,EAAE,cAAc,CAAC;KACnC;CACD;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-color-field.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);
|
|
@@ -10,12 +16,44 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|
|
10
16
|
import { classMap } from 'lit/directives/class-map.js';
|
|
11
17
|
import { MoniElement, sharedStyles, fieldStyles } from './_base/index.js';
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
19
|
+
* Material Design 3 Color Field component.
|
|
20
|
+
*
|
|
21
|
+
* A specialized text field for color input that combines a native
|
|
22
|
+
* `<input type="color">` with a read-only text display of the selected
|
|
23
|
+
* hex value, wrapped in the standard M3 field shell.
|
|
24
|
+
*
|
|
25
|
+
* **Visual architecture:**
|
|
26
|
+
* Extends the field styling pattern used by `<moni-text-field>`. The
|
|
27
|
+
* leading icon slot is replaced by a circular color swatch (`.swatch`)
|
|
28
|
+
* which is absolutely positioned over an invisible native color input.
|
|
29
|
+
* Clicking the swatch opens the system color picker. The text input portion
|
|
30
|
+
* displays the selected hex code and is strictly `readOnly`.
|
|
31
|
+
*
|
|
32
|
+
* **State syncing:**
|
|
33
|
+
* The component listens to the native `change` event on the color input,
|
|
34
|
+
* updates the `value` property, and re-dispatches a composed `'change'` event.
|
|
35
|
+
* It does not listen to `input` (continuous drag in the color picker) to avoid
|
|
36
|
+
* excessive event firing, but consumers can attach their own `input` listeners
|
|
37
|
+
* directly to the element if live preview is needed.
|
|
38
|
+
*
|
|
39
|
+
* @fires change - Bubbles and is composed. Fired when the color picker closes
|
|
40
|
+
* and the value is committed. Read `element.value`.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```html
|
|
44
|
+
* <moni-color-field
|
|
45
|
+
* label="Theme Color"
|
|
46
|
+
* name="primaryColor"
|
|
47
|
+
* value="#6750a4"
|
|
48
|
+
* variant="outlined"
|
|
49
|
+
* ></moni-color-field>
|
|
50
|
+
* ```
|
|
15
51
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
52
|
+
* @csspart field - The outer `.field` div container.
|
|
53
|
+
* @csspart swatch - The circular color preview element.
|
|
54
|
+
* @csspart input-color - The native, visually hidden `<input type="color">`.
|
|
55
|
+
* @csspart input-text - The native `<input type="text">` displaying the hex code.
|
|
56
|
+
* @csspart label - The floating `<label>` element.
|
|
19
57
|
*/
|
|
20
58
|
let MoniColorField = class MoniColorField extends MoniElement {
|
|
21
59
|
constructor() {
|
|
@@ -1,31 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file components/moni-context-menu.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
|
import './moni-menu.js';
|
|
3
9
|
/**
|
|
4
|
-
*
|
|
10
|
+
* Material Design 3 Context Menu component.
|
|
11
|
+
*
|
|
12
|
+
* A specialized menu that opens at the exact coordinates of a pointer event,
|
|
13
|
+
* typically triggered by a right-click (`contextmenu` event). It provides
|
|
14
|
+
* contextual actions related to the specific item clicked.
|
|
15
|
+
*
|
|
16
|
+
* **M3 spec reference:** `m3-docs/components/menus/specs.md` (Contextual menus)
|
|
17
|
+
*
|
|
18
|
+
* **Triggering mechanism:**
|
|
19
|
+
* The component does not require programmatic triggering via an `open` property.
|
|
20
|
+
* Instead, it attaches a `contextmenu` event listener to its parent element
|
|
21
|
+
* during `connectedCallback`. When the parent is right-clicked, the menu
|
|
22
|
+
* captures the `clientX`/`clientY` coordinates, prevents the default browser
|
|
23
|
+
* context menu, and opens itself at the cursor position using `position: fixed`.
|
|
5
24
|
*
|
|
6
|
-
* **
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
25
|
+
* **Auto-flip behavior (`flip` attribute):**
|
|
26
|
+
* Per the M3 guidelines, menus should flip to the opposite side of the cursor
|
|
27
|
+
* if opening in the requested `placement` would cause them to overflow the
|
|
28
|
+
* viewport. When `flip=true`, the component dynamically calculates viewport
|
|
29
|
+
* bounds before opening and overrides `placement` if necessary (e.g., flipping
|
|
30
|
+
* from `bottom` to `top` if clicked near the bottom of the screen).
|
|
9
31
|
*
|
|
10
|
-
* **
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* <moni-context-menu flip>
|
|
14
|
-
* <moni-menu-item>Cut</moni-menu-item>
|
|
15
|
-
* <moni-menu-item>Copy</moni-menu-item>
|
|
16
|
-
* <moni-menu-item>Paste</moni-menu-item>
|
|
17
|
-
* </moni-context-menu>
|
|
18
|
-
* Right-click anywhere in this div
|
|
19
|
-
* </div>
|
|
20
|
-
* ```
|
|
32
|
+
* **Auto-dismiss:**
|
|
33
|
+
* Closes automatically when clicking anywhere outside the menu, or when
|
|
34
|
+
* pressing the `Escape` key.
|
|
21
35
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```html
|
|
38
|
+
* <!-- Wrap the trigger area and the menu in a container -->
|
|
39
|
+
* <div>
|
|
40
|
+
* <p>Right-click me for options</p>
|
|
41
|
+
* <moni-context-menu flip>
|
|
42
|
+
* <moni-menu-item>Copy</moni-menu-item>
|
|
43
|
+
* <moni-menu-item>Paste</moni-menu-item>
|
|
44
|
+
* <moni-divider></moni-divider>
|
|
45
|
+
* <moni-menu-item>Delete</moni-menu-item>
|
|
46
|
+
* </moni-context-menu>
|
|
47
|
+
* </div>
|
|
48
|
+
* ```
|
|
26
49
|
*
|
|
27
|
-
*
|
|
28
|
-
* - default: menu items
|
|
50
|
+
* @slot default - The `<moni-menu-item>` elements that make up the menu.
|
|
29
51
|
*/
|
|
30
52
|
export declare class MoniContextMenu extends MoniElement {
|
|
31
53
|
placement: 'bottom' | 'top' | 'left' | 'right';
|
|
@@ -44,7 +66,7 @@ export declare class MoniContextMenu extends MoniElement {
|
|
|
44
66
|
private _onDocumentClick;
|
|
45
67
|
private _onDocKeydown;
|
|
46
68
|
static styles: import("lit").CSSResult[];
|
|
47
|
-
render(): import("lit
|
|
69
|
+
render(): import("lit").TemplateResult<1>;
|
|
48
70
|
}
|
|
49
71
|
declare global {
|
|
50
72
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"moni-context-menu.d.ts","sourceRoot":"","sources":["../../src/components/moni-context-menu.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"moni-context-menu.d.ts","sourceRoot":"","sources":["../../src/components/moni-context-menu.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAgB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,qBACa,eAAgB,SAAQ,WAAW;IAE/C,SAAS,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAY;IACd,IAAI,UAAS;IAEhD,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,EAAE,CAAK;IACf,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,kBAAkB,CAAiD;IAEhE,OAAO,CAAC,OAAO,CAAC,CAAc;IAElD,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,WAAW,CAA+C;IAEzD,iBAAiB;IAejB,oBAAoB;IAS7B,OAAO,CAAC,cAAc,CAcpB;IAEF,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,gBAAgB,CAItB;IAEF,OAAO,CAAC,aAAa,CAInB;IAEF,OAAgB,MAAM,4BAgBpB;IAEO,MAAM;CAmBf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,mBAAmB,EAAE,eAAe,CAAC;KACrC;CACD;AAED,eAAe,eAAe,CAAC"}
|