@moni-labs/moni-ui 0.2.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/LICENSE +34 -0
- package/README.md +264 -0
- package/custom-elements.json +12510 -0
- package/dist/actions/index.d.ts +2 -0
- package/dist/actions/index.d.ts.map +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/assets/arch.svg +1 -0
- package/dist/assets/arrow.svg +1 -0
- package/dist/assets/boom.svg +1 -0
- package/dist/assets/bun.svg +1 -0
- package/dist/assets/burst.svg +1 -0
- package/dist/assets/circle.svg +1 -0
- package/dist/assets/clamshell.svg +1 -0
- package/dist/assets/diamond.svg +1 -0
- package/dist/assets/fan.svg +1 -0
- package/dist/assets/flower.svg +1 -0
- package/dist/assets/gem.svg +1 -0
- package/dist/assets/ghost-ish.svg +1 -0
- package/dist/assets/heart.svg +1 -0
- package/dist/assets/leaf-clover4.svg +1 -0
- package/dist/assets/leaf-clover8.svg +1 -0
- package/dist/assets/loading-indicator.svg +1 -0
- package/dist/assets/material-symbols-rounded.woff2 +0 -0
- package/dist/assets/material-symbols-subset.woff2 +0 -0
- package/dist/assets/oval.svg +1 -0
- package/dist/assets/pentagon.svg +1 -0
- package/dist/assets/pill.svg +1 -0
- package/dist/assets/pixel-circle.svg +1 -0
- package/dist/assets/pixel-triangle.svg +1 -0
- package/dist/assets/puffy-diamond.svg +1 -0
- package/dist/assets/puffy.svg +1 -0
- package/dist/assets/semicircle.svg +1 -0
- package/dist/assets/shapes/arch.svg +1 -0
- package/dist/assets/shapes/arrow.svg +1 -0
- package/dist/assets/shapes/boom.svg +1 -0
- package/dist/assets/shapes/burst.svg +1 -0
- package/dist/assets/shapes/circle.svg +1 -0
- package/dist/assets/shapes/clamshell.svg +1 -0
- package/dist/assets/shapes/diamond.svg +1 -0
- package/dist/assets/shapes/fan.svg +1 -0
- package/dist/assets/shapes/flower.svg +1 -0
- package/dist/assets/shapes/gem.svg +1 -0
- package/dist/assets/shapes/ghost-ish.svg +1 -0
- package/dist/assets/shapes/heart.svg +1 -0
- package/dist/assets/shapes/leaf-clover4.svg +1 -0
- package/dist/assets/shapes/leaf-clover8.svg +1 -0
- package/dist/assets/shapes/loading-indicator.svg +1 -0
- package/dist/assets/shapes/oval.svg +1 -0
- package/dist/assets/shapes/pentagon.svg +1 -0
- package/dist/assets/shapes/pill.svg +1 -0
- package/dist/assets/shapes/pixel-circle.svg +1 -0
- package/dist/assets/shapes/pixel-triangle.svg +1 -0
- package/dist/assets/shapes/puffy-diamond.svg +1 -0
- package/dist/assets/shapes/puffy.svg +1 -0
- package/dist/assets/shapes/semicircle.svg +1 -0
- package/dist/assets/shapes/sided-cookie12.svg +1 -0
- package/dist/assets/shapes/sided-cookie4.svg +1 -0
- package/dist/assets/shapes/sided-cookie6.svg +1 -0
- package/dist/assets/shapes/sided-cookie7.svg +1 -0
- package/dist/assets/shapes/sided-cookie9.svg +1 -0
- package/dist/assets/shapes/slanted.svg +1 -0
- package/dist/assets/shapes/soft-boom.svg +1 -0
- package/dist/assets/shapes/soft-burst.svg +1 -0
- package/dist/assets/shapes/square.svg +1 -0
- package/dist/assets/shapes/sunny.svg +1 -0
- package/dist/assets/shapes/triangle.svg +1 -0
- package/dist/assets/shapes/very-sunny.svg +1 -0
- package/dist/assets/shapes/wavy-circle.svg +1 -0
- package/dist/assets/shapes/wavy.svg +1 -0
- package/dist/assets/sided-cookie12.svg +1 -0
- package/dist/assets/sided-cookie4.svg +1 -0
- package/dist/assets/sided-cookie6.svg +1 -0
- package/dist/assets/sided-cookie7.svg +1 -0
- package/dist/assets/sided-cookie9.svg +1 -0
- package/dist/assets/slanted.svg +1 -0
- package/dist/assets/soft-boom.svg +1 -0
- package/dist/assets/soft-burst.svg +1 -0
- package/dist/assets/square.svg +1 -0
- package/dist/assets/star.svg +1 -0
- package/dist/assets/sunny.svg +1 -0
- package/dist/assets/triangle.svg +1 -0
- package/dist/assets/very-sunny.svg +1 -0
- package/dist/assets/wavy-circle.svg +1 -0
- package/dist/assets/wavy.svg +1 -0
- package/dist/components/_base/field-styles.d.ts +24 -0
- package/dist/components/_base/field-styles.d.ts.map +1 -0
- package/dist/components/_base/field-styles.js +504 -0
- package/dist/components/_base/index.d.ts +4 -0
- package/dist/components/_base/index.d.ts.map +1 -0
- package/dist/components/_base/index.js +3 -0
- package/dist/components/_base/interaction-styles.d.ts +22 -0
- package/dist/components/_base/interaction-styles.d.ts.map +1 -0
- package/dist/components/_base/interaction-styles.js +123 -0
- package/dist/components/_base/moni-element.d.ts +18 -0
- package/dist/components/_base/moni-element.d.ts.map +1 -0
- package/dist/components/_base/moni-element.js +19 -0
- package/dist/components/_base/shared-styles.d.ts +22 -0
- package/dist/components/_base/shared-styles.d.ts.map +1 -0
- package/dist/components/_base/shared-styles.js +146 -0
- package/dist/components/index.d.ts +42 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +43 -0
- package/dist/components/loading-shapes.d.ts +10 -0
- package/dist/components/loading-shapes.d.ts.map +1 -0
- package/dist/components/loading-shapes.js +9 -0
- package/dist/components/moni-app-bar.d.ts +52 -0
- package/dist/components/moni-app-bar.d.ts.map +1 -0
- package/dist/components/moni-app-bar.js +207 -0
- package/dist/components/moni-badge.d.ts +37 -0
- package/dist/components/moni-badge.d.ts.map +1 -0
- package/dist/components/moni-badge.js +153 -0
- package/dist/components/moni-bottom-sheet.d.ts +52 -0
- package/dist/components/moni-bottom-sheet.d.ts.map +1 -0
- package/dist/components/moni-bottom-sheet.js +440 -0
- package/dist/components/moni-button-group.d.ts +55 -0
- package/dist/components/moni-button-group.d.ts.map +1 -0
- package/dist/components/moni-button-group.js +278 -0
- package/dist/components/moni-button-segment.d.ts +29 -0
- package/dist/components/moni-button-segment.d.ts.map +1 -0
- package/dist/components/moni-button-segment.js +300 -0
- package/dist/components/moni-button.d.ts +70 -0
- package/dist/components/moni-button.d.ts.map +1 -0
- package/dist/components/moni-button.js +727 -0
- package/dist/components/moni-card.d.ts +48 -0
- package/dist/components/moni-card.d.ts.map +1 -0
- package/dist/components/moni-card.js +216 -0
- package/dist/components/moni-carousel.d.ts +111 -0
- package/dist/components/moni-carousel.d.ts.map +1 -0
- package/dist/components/moni-carousel.js +1007 -0
- package/dist/components/moni-checkbox.d.ts +39 -0
- package/dist/components/moni-checkbox.d.ts.map +1 -0
- package/dist/components/moni-checkbox.js +212 -0
- package/dist/components/moni-chip.d.ts +57 -0
- package/dist/components/moni-chip.d.ts.map +1 -0
- package/dist/components/moni-chip.js +340 -0
- package/dist/components/moni-color-field.d.ts +33 -0
- package/dist/components/moni-color-field.d.ts.map +1 -0
- package/dist/components/moni-color-field.js +170 -0
- package/dist/components/moni-context-menu.d.ts +55 -0
- package/dist/components/moni-context-menu.d.ts.map +1 -0
- package/dist/components/moni-context-menu.js +184 -0
- package/dist/components/moni-dialog.d.ts +37 -0
- package/dist/components/moni-dialog.d.ts.map +1 -0
- package/dist/components/moni-dialog.js +257 -0
- package/dist/components/moni-divider.d.ts +33 -0
- package/dist/components/moni-divider.d.ts.map +1 -0
- package/dist/components/moni-divider.js +81 -0
- package/dist/components/moni-expansion.d.ts +25 -0
- package/dist/components/moni-expansion.d.ts.map +1 -0
- package/dist/components/moni-expansion.js +94 -0
- package/dist/components/moni-fab-menu.d.ts +58 -0
- package/dist/components/moni-fab-menu.d.ts.map +1 -0
- package/dist/components/moni-fab-menu.js +247 -0
- package/dist/components/moni-fab.d.ts +48 -0
- package/dist/components/moni-fab.d.ts.map +1 -0
- package/dist/components/moni-fab.js +284 -0
- package/dist/components/moni-file-field.d.ts +47 -0
- package/dist/components/moni-file-field.d.ts.map +1 -0
- package/dist/components/moni-file-field.js +189 -0
- package/dist/components/moni-icon.d.ts +30 -0
- package/dist/components/moni-icon.d.ts.map +1 -0
- package/dist/components/moni-icon.js +107 -0
- package/dist/components/moni-list-item.d.ts +51 -0
- package/dist/components/moni-list-item.d.ts.map +1 -0
- package/dist/components/moni-list-item.js +239 -0
- package/dist/components/moni-list.d.ts +32 -0
- package/dist/components/moni-list.d.ts.map +1 -0
- package/dist/components/moni-list.js +67 -0
- package/dist/components/moni-loading-indicator.d.ts +32 -0
- package/dist/components/moni-loading-indicator.d.ts.map +1 -0
- package/dist/components/moni-loading-indicator.js +189 -0
- package/dist/components/moni-menu-item.d.ts +27 -0
- package/dist/components/moni-menu-item.d.ts.map +1 -0
- package/dist/components/moni-menu-item.js +99 -0
- package/dist/components/moni-menu.d.ts +55 -0
- package/dist/components/moni-menu.d.ts.map +1 -0
- package/dist/components/moni-menu.js +295 -0
- package/dist/components/moni-morph-modal.d.ts +78 -0
- package/dist/components/moni-morph-modal.d.ts.map +1 -0
- package/dist/components/moni-morph-modal.js +1223 -0
- package/dist/components/moni-nav-item.d.ts +38 -0
- package/dist/components/moni-nav-item.d.ts.map +1 -0
- package/dist/components/moni-nav-item.js +262 -0
- package/dist/components/moni-nav.d.ts +46 -0
- package/dist/components/moni-nav.d.ts.map +1 -0
- package/dist/components/moni-nav.js +272 -0
- package/dist/components/moni-progress.d.ts +45 -0
- package/dist/components/moni-progress.d.ts.map +1 -0
- package/dist/components/moni-progress.js +333 -0
- package/dist/components/moni-radio.d.ts +38 -0
- package/dist/components/moni-radio.d.ts.map +1 -0
- package/dist/components/moni-radio.js +218 -0
- package/dist/components/moni-ripple.d.ts +35 -0
- package/dist/components/moni-ripple.d.ts.map +1 -0
- package/dist/components/moni-ripple.js +156 -0
- package/dist/components/moni-segmented-button.d.ts +52 -0
- package/dist/components/moni-segmented-button.d.ts.map +1 -0
- package/dist/components/moni-segmented-button.js +208 -0
- package/dist/components/moni-select-option.d.ts +27 -0
- package/dist/components/moni-select-option.d.ts.map +1 -0
- package/dist/components/moni-select-option.js +102 -0
- package/dist/components/moni-select.d.ts +76 -0
- package/dist/components/moni-select.d.ts.map +1 -0
- package/dist/components/moni-select.js +1136 -0
- package/dist/components/moni-shape.d.ts +30 -0
- package/dist/components/moni-shape.d.ts.map +1 -0
- package/dist/components/moni-shape.js +146 -0
- package/dist/components/moni-side-sheet.d.ts +62 -0
- package/dist/components/moni-side-sheet.d.ts.map +1 -0
- package/dist/components/moni-side-sheet.js +576 -0
- package/dist/components/moni-slider.d.ts +73 -0
- package/dist/components/moni-slider.d.ts.map +1 -0
- package/dist/components/moni-slider.js +422 -0
- package/dist/components/moni-snackbar.d.ts +40 -0
- package/dist/components/moni-snackbar.d.ts.map +1 -0
- package/dist/components/moni-snackbar.js +161 -0
- package/dist/components/moni-split-button.d.ts +33 -0
- package/dist/components/moni-split-button.d.ts.map +1 -0
- package/dist/components/moni-split-button.js +122 -0
- package/dist/components/moni-step.d.ts +30 -0
- package/dist/components/moni-step.d.ts.map +1 -0
- package/dist/components/moni-step.js +175 -0
- package/dist/components/moni-stepper.d.ts +35 -0
- package/dist/components/moni-stepper.d.ts.map +1 -0
- package/dist/components/moni-stepper.js +101 -0
- package/dist/components/moni-switch.d.ts +39 -0
- package/dist/components/moni-switch.d.ts.map +1 -0
- package/dist/components/moni-switch.js +258 -0
- package/dist/components/moni-tab.d.ts +27 -0
- package/dist/components/moni-tab.d.ts.map +1 -0
- package/dist/components/moni-tab.js +147 -0
- package/dist/components/moni-tabs.d.ts +31 -0
- package/dist/components/moni-tabs.d.ts.map +1 -0
- package/dist/components/moni-tabs.js +106 -0
- package/dist/components/moni-text-field.d.ts +46 -0
- package/dist/components/moni-text-field.d.ts.map +1 -0
- package/dist/components/moni-text-field.js +190 -0
- package/dist/components/moni-textarea.d.ts +57 -0
- package/dist/components/moni-textarea.d.ts.map +1 -0
- package/dist/components/moni-textarea.js +228 -0
- package/dist/components/moni-time-picker.d.ts +51 -0
- package/dist/components/moni-time-picker.d.ts.map +1 -0
- package/dist/components/moni-time-picker.js +823 -0
- package/dist/components/moni-toolbar.d.ts +35 -0
- package/dist/components/moni-toolbar.d.ts.map +1 -0
- package/dist/components/moni-toolbar.js +128 -0
- package/dist/components/moni-tooltip.d.ts +65 -0
- package/dist/components/moni-tooltip.d.ts.map +1 -0
- package/dist/components/moni-tooltip.js +320 -0
- package/dist/components/moni-typography.d.ts +42 -0
- package/dist/components/moni-typography.d.ts.map +1 -0
- package/dist/components/moni-typography.js +205 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/styles/animations.css +46 -0
- package/dist/styles/base.css +248 -0
- package/dist/styles/index.css +3 -0
- package/dist/styles/tokens.css +190 -0
- package/dist/utils/color.d.ts +51 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/color.js +107 -0
- package/dist/utils/theme.svelte.d.ts +45 -0
- package/dist/utils/theme.svelte.d.ts.map +1 -0
- package/dist/utils/theme.svelte.js +168 -0
- package/dist/web-components.d.ts +3 -0
- package/dist/web-components.d.ts.map +1 -0
- package/dist/web-components.js +4 -0
- package/package.json +76 -0
- package/src/actions/index.ts +2 -0
- package/src/assets/arch.svg +1 -0
- package/src/assets/arrow.svg +1 -0
- package/src/assets/boom.svg +1 -0
- package/src/assets/bun.svg +1 -0
- package/src/assets/burst.svg +1 -0
- package/src/assets/circle.svg +1 -0
- package/src/assets/clamshell.svg +1 -0
- package/src/assets/diamond.svg +1 -0
- package/src/assets/fan.svg +1 -0
- package/src/assets/flower.svg +1 -0
- package/src/assets/gem.svg +1 -0
- package/src/assets/ghost-ish.svg +1 -0
- package/src/assets/heart.svg +1 -0
- package/src/assets/leaf-clover4.svg +1 -0
- package/src/assets/leaf-clover8.svg +1 -0
- package/src/assets/loading-indicator.svg +1 -0
- package/src/assets/material-symbols-rounded.woff2 +0 -0
- package/src/assets/material-symbols-subset.woff2 +0 -0
- package/src/assets/oval.svg +1 -0
- package/src/assets/pentagon.svg +1 -0
- package/src/assets/pill.svg +1 -0
- package/src/assets/pixel-circle.svg +1 -0
- package/src/assets/pixel-triangle.svg +1 -0
- package/src/assets/puffy-diamond.svg +1 -0
- package/src/assets/puffy.svg +1 -0
- package/src/assets/semicircle.svg +1 -0
- package/src/assets/shapes/arch.svg +1 -0
- package/src/assets/shapes/arrow.svg +1 -0
- package/src/assets/shapes/boom.svg +1 -0
- package/src/assets/shapes/burst.svg +1 -0
- package/src/assets/shapes/circle.svg +1 -0
- package/src/assets/shapes/clamshell.svg +1 -0
- package/src/assets/shapes/diamond.svg +1 -0
- package/src/assets/shapes/fan.svg +1 -0
- package/src/assets/shapes/flower.svg +1 -0
- package/src/assets/shapes/gem.svg +1 -0
- package/src/assets/shapes/ghost-ish.svg +1 -0
- package/src/assets/shapes/heart.svg +1 -0
- package/src/assets/shapes/leaf-clover4.svg +1 -0
- package/src/assets/shapes/leaf-clover8.svg +1 -0
- package/src/assets/shapes/loading-indicator.svg +1 -0
- package/src/assets/shapes/oval.svg +1 -0
- package/src/assets/shapes/pentagon.svg +1 -0
- package/src/assets/shapes/pill.svg +1 -0
- package/src/assets/shapes/pixel-circle.svg +1 -0
- package/src/assets/shapes/pixel-triangle.svg +1 -0
- package/src/assets/shapes/puffy-diamond.svg +1 -0
- package/src/assets/shapes/puffy.svg +1 -0
- package/src/assets/shapes/semicircle.svg +1 -0
- package/src/assets/shapes/sided-cookie12.svg +1 -0
- package/src/assets/shapes/sided-cookie4.svg +1 -0
- package/src/assets/shapes/sided-cookie6.svg +1 -0
- package/src/assets/shapes/sided-cookie7.svg +1 -0
- package/src/assets/shapes/sided-cookie9.svg +1 -0
- package/src/assets/shapes/slanted.svg +1 -0
- package/src/assets/shapes/soft-boom.svg +1 -0
- package/src/assets/shapes/soft-burst.svg +1 -0
- package/src/assets/shapes/square.svg +1 -0
- package/src/assets/shapes/sunny.svg +1 -0
- package/src/assets/shapes/triangle.svg +1 -0
- package/src/assets/shapes/very-sunny.svg +1 -0
- package/src/assets/shapes/wavy-circle.svg +1 -0
- package/src/assets/shapes/wavy.svg +1 -0
- package/src/assets/sided-cookie12.svg +1 -0
- package/src/assets/sided-cookie4.svg +1 -0
- package/src/assets/sided-cookie6.svg +1 -0
- package/src/assets/sided-cookie7.svg +1 -0
- package/src/assets/sided-cookie9.svg +1 -0
- package/src/assets/slanted.svg +1 -0
- package/src/assets/soft-boom.svg +1 -0
- package/src/assets/soft-burst.svg +1 -0
- package/src/assets/square.svg +1 -0
- package/src/assets/star.svg +1 -0
- package/src/assets/sunny.svg +1 -0
- package/src/assets/triangle.svg +1 -0
- package/src/assets/very-sunny.svg +1 -0
- package/src/assets/wavy-circle.svg +1 -0
- package/src/assets/wavy.svg +1 -0
- package/src/assets.d.ts +12 -0
- package/src/components/_base/field-styles.ts +507 -0
- package/src/components/_base/index.ts +3 -0
- package/src/components/_base/interaction-styles.ts +125 -0
- package/src/components/_base/moni-element.ts +21 -0
- package/src/components/_base/shared-styles.ts +148 -0
- package/src/components/index.ts +45 -0
- package/src/components/loading-shapes.ts +9 -0
- package/src/components/moni-app-bar.test.ts +86 -0
- package/src/components/moni-app-bar.ts +190 -0
- package/src/components/moni-badge.ts +138 -0
- package/src/components/moni-bottom-sheet.test.ts +420 -0
- package/src/components/moni-bottom-sheet.ts +425 -0
- package/src/components/moni-button-group.test.ts +148 -0
- package/src/components/moni-button-group.ts +277 -0
- package/src/components/moni-button-segment.ts +291 -0
- package/src/components/moni-button.test.ts +166 -0
- package/src/components/moni-button.ts +709 -0
- package/src/components/moni-card.test.ts +83 -0
- package/src/components/moni-card.ts +203 -0
- package/src/components/moni-carousel.test.ts +238 -0
- package/src/components/moni-carousel.ts +1027 -0
- package/src/components/moni-checkbox.test.ts +78 -0
- package/src/components/moni-checkbox.ts +192 -0
- package/src/components/moni-chip.test.ts +168 -0
- package/src/components/moni-chip.ts +335 -0
- package/src/components/moni-color-field.test.ts +56 -0
- package/src/components/moni-color-field.ts +135 -0
- package/src/components/moni-context-menu.test.ts +99 -0
- package/src/components/moni-context-menu.ts +166 -0
- package/src/components/moni-dialog.ts +240 -0
- package/src/components/moni-divider.test.ts +42 -0
- package/src/components/moni-divider.ts +77 -0
- package/src/components/moni-expansion.ts +86 -0
- package/src/components/moni-fab-menu.test.ts +118 -0
- package/src/components/moni-fab-menu.ts +237 -0
- package/src/components/moni-fab.test.ts +128 -0
- package/src/components/moni-fab.ts +262 -0
- package/src/components/moni-file-field.test.ts +81 -0
- package/src/components/moni-file-field.ts +149 -0
- package/src/components/moni-icon.test.ts +70 -0
- package/src/components/moni-icon.ts +97 -0
- package/src/components/moni-list-item.test.ts +114 -0
- package/src/components/moni-list-item.ts +222 -0
- package/src/components/moni-list.ts +59 -0
- package/src/components/moni-loading-indicator.test.ts +41 -0
- package/src/components/moni-loading-indicator.ts +188 -0
- package/src/components/moni-menu-item.ts +85 -0
- package/src/components/moni-menu.test.ts +87 -0
- package/src/components/moni-menu.ts +287 -0
- package/src/components/moni-morph-modal.test.ts +286 -0
- package/src/components/moni-morph-modal.ts +1312 -0
- package/src/components/moni-nav-item.ts +243 -0
- package/src/components/moni-nav.test.ts +139 -0
- package/src/components/moni-nav.ts +266 -0
- package/src/components/moni-progress.test.ts +90 -0
- package/src/components/moni-progress.ts +322 -0
- package/src/components/moni-radio.test.ts +86 -0
- package/src/components/moni-radio.ts +196 -0
- package/src/components/moni-ripple.ts +146 -0
- package/src/components/moni-segmented-button.test.ts +99 -0
- package/src/components/moni-segmented-button.ts +220 -0
- package/src/components/moni-select-option.ts +85 -0
- package/src/components/moni-select.test.ts +210 -0
- package/src/components/moni-select.ts +1107 -0
- package/src/components/moni-shape.ts +128 -0
- package/src/components/moni-side-sheet.test.ts +128 -0
- package/src/components/moni-side-sheet.ts +544 -0
- package/src/components/moni-slider.test.ts +82 -0
- package/src/components/moni-slider.ts +387 -0
- package/src/components/moni-snackbar.test.ts +82 -0
- package/src/components/moni-snackbar.ts +146 -0
- package/src/components/moni-split-button.ts +121 -0
- package/src/components/moni-step.test.ts +57 -0
- package/src/components/moni-step.ts +155 -0
- package/src/components/moni-stepper.test.ts +116 -0
- package/src/components/moni-stepper.ts +100 -0
- package/src/components/moni-switch.test.ts +117 -0
- package/src/components/moni-switch.ts +237 -0
- package/src/components/moni-tab.test.ts +54 -0
- package/src/components/moni-tab.ts +133 -0
- package/src/components/moni-tabs.ts +92 -0
- package/src/components/moni-text-field.test.ts +115 -0
- package/src/components/moni-text-field.ts +149 -0
- package/src/components/moni-textarea.test.ts +147 -0
- package/src/components/moni-textarea.ts +176 -0
- package/src/components/moni-time-picker.test.ts +61 -0
- package/src/components/moni-time-picker.ts +800 -0
- package/src/components/moni-toolbar.test.ts +93 -0
- package/src/components/moni-toolbar.ts +119 -0
- package/src/components/moni-tooltip.test.ts +122 -0
- package/src/components/moni-tooltip.ts +324 -0
- package/src/components/moni-typography.test.ts +119 -0
- package/src/components/moni-typography.ts +195 -0
- package/src/index.ts +65 -0
- package/src/styles/animations.css +46 -0
- package/src/styles/base.css +248 -0
- package/src/styles/index.css +3 -0
- package/src/styles/tokens.css +190 -0
- package/src/types/svelte-runes.d.ts +7 -0
- package/src/utils/color.ts +170 -0
- package/src/utils/theme.svelte.ts +206 -0
- package/src/web-components.ts +5 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import './moni-toolbar.js';
|
|
3
|
+
import type { MoniToolbar } from './moni-toolbar.js';
|
|
4
|
+
|
|
5
|
+
describe('moni-toolbar (P5.4 — recreated)', () => {
|
|
6
|
+
let el: MoniToolbar;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
el = document.createElement('moni-toolbar') as MoniToolbar;
|
|
10
|
+
document.body.appendChild(el);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
el.remove();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('defaults to type=standard', async () => {
|
|
18
|
+
await el.updateComplete;
|
|
19
|
+
expect(el.type).toBe('standard');
|
|
20
|
+
expect(el.getAttribute('type')).toBe('standard');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('renders a <header> container', async () => {
|
|
24
|
+
await el.updateComplete;
|
|
25
|
+
const header = el.shadowRoot?.querySelector('header');
|
|
26
|
+
expect(header).toBeTruthy();
|
|
27
|
+
expect(header?.getAttribute('part')).toBe('container');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders the title attribute in the title span', async () => {
|
|
31
|
+
el.title = 'My App';
|
|
32
|
+
await el.updateComplete;
|
|
33
|
+
const title = el.shadowRoot?.querySelector('[part="title"]');
|
|
34
|
+
expect(title?.textContent?.trim()).toBe('My App');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('supports slot fallback when title attribute is empty', async () => {
|
|
38
|
+
const heading = document.createElement('h1');
|
|
39
|
+
heading.textContent = 'Slotted Title';
|
|
40
|
+
el.appendChild(heading);
|
|
41
|
+
await el.updateComplete;
|
|
42
|
+
const title = el.shadowRoot?.querySelector('[part="title"]');
|
|
43
|
+
const slot = title?.querySelector('slot') as HTMLSlotElement | null;
|
|
44
|
+
const assigned = slot?.assignedNodes({ flatten: true }) ?? [];
|
|
45
|
+
const text = assigned.map((n) => n.textContent ?? '').join('').trim();
|
|
46
|
+
expect(text).toBe('Slotted Title');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('renders leading and trailing slots', async () => {
|
|
50
|
+
const leading = document.createElement('button');
|
|
51
|
+
leading.setAttribute('slot', 'leading');
|
|
52
|
+
leading.textContent = 'Menu';
|
|
53
|
+
const trailing = document.createElement('button');
|
|
54
|
+
trailing.setAttribute('slot', 'trailing');
|
|
55
|
+
trailing.textContent = 'Search';
|
|
56
|
+
el.appendChild(leading);
|
|
57
|
+
el.appendChild(trailing);
|
|
58
|
+
await el.updateComplete;
|
|
59
|
+
|
|
60
|
+
const leadingSlot = el.shadowRoot
|
|
61
|
+
?.querySelector('[part="leading"] slot') as HTMLSlotElement | null;
|
|
62
|
+
const trailingSlot = el.shadowRoot
|
|
63
|
+
?.querySelector('[part="trailing"] slot') as HTMLSlotElement | null;
|
|
64
|
+
|
|
65
|
+
expect(leadingSlot?.assignedNodes({ flatten: true }).length).toBeGreaterThan(0);
|
|
66
|
+
expect(trailingSlot?.assignedNodes({ flatten: true }).length).toBeGreaterThan(0);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('switches to floating type', async () => {
|
|
70
|
+
el.type = 'floating';
|
|
71
|
+
await el.updateComplete;
|
|
72
|
+
expect(el.getAttribute('type')).toBe('floating');
|
|
73
|
+
const header = el.shadowRoot?.querySelector('header');
|
|
74
|
+
expect(header).toBeTruthy();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('reflects scroll attribute', async () => {
|
|
78
|
+
el.scrolled = true;
|
|
79
|
+
await el.updateComplete;
|
|
80
|
+
expect(el.hasAttribute('scroll')).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('reserves a slot for the action-button', async () => {
|
|
84
|
+
const fab = document.createElement('button');
|
|
85
|
+
fab.setAttribute('slot', 'action-button');
|
|
86
|
+
fab.textContent = '+';
|
|
87
|
+
el.appendChild(fab);
|
|
88
|
+
await el.updateComplete;
|
|
89
|
+
const slot = el.shadowRoot?.querySelector('slot[name="action-button"]') as HTMLSlotElement | null;
|
|
90
|
+
const assigned = slot?.assignedNodes({ flatten: true }) ?? [];
|
|
91
|
+
expect(assigned.length).toBeGreaterThan(0);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { html, css } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Material 3 Toolbar (`m3-docs/components/top-app-bar/specs.md`).
|
|
7
|
+
*
|
|
8
|
+
* This is the larger/top-level variant. If you need the compact
|
|
9
|
+
* Navigation Bar at the bottom of the screen, use `<moni-app-bar>`.
|
|
10
|
+
*
|
|
11
|
+
* Supported M3 types:
|
|
12
|
+
* - **standard** (default): 64dp height, flat surface color, bottom shadow.
|
|
13
|
+
* - **floating**: 4dp margin, rounded 8dp corners, elevated.
|
|
14
|
+
*
|
|
15
|
+
* Slots:
|
|
16
|
+
* - default: title / center content.
|
|
17
|
+
* - leading: navigation icon/button.
|
|
18
|
+
* - trailing: action icons/buttons.
|
|
19
|
+
* - action-button: floating action button (moni-fab) anchored right.
|
|
20
|
+
*
|
|
21
|
+
* Attributes:
|
|
22
|
+
* - type: standard (default) | floating
|
|
23
|
+
* - scroll: true | false (default). When true, elevation increases on scroll.
|
|
24
|
+
*/
|
|
25
|
+
@customElement('moni-toolbar')
|
|
26
|
+
export class MoniToolbar extends MoniElement {
|
|
27
|
+
@property({ reflect: true })
|
|
28
|
+
type: 'standard' | 'floating' = 'standard';
|
|
29
|
+
@property({ type: Boolean, reflect: true, attribute: 'scroll' })
|
|
30
|
+
scrolled = false;
|
|
31
|
+
@property({ reflect: true }) title = '';
|
|
32
|
+
|
|
33
|
+
static override styles = [
|
|
34
|
+
sharedStyles,
|
|
35
|
+
css`
|
|
36
|
+
:host {
|
|
37
|
+
display: block;
|
|
38
|
+
position: relative;
|
|
39
|
+
z-index: var(--z-index-toolbar, 1000);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.container {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: 1rem;
|
|
46
|
+
block-size: 4rem;
|
|
47
|
+
padding-inline: 0.25rem;
|
|
48
|
+
padding-block: 0.5rem;
|
|
49
|
+
background-color: var(--surface-container);
|
|
50
|
+
color: var(--on-surface);
|
|
51
|
+
font-family: var(--font);
|
|
52
|
+
transition: box-shadow var(--speed2), background-color var(--speed2);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
:host([type='standard']) .container {
|
|
56
|
+
box-shadow: var(--shadow1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host([type='floating']) .container {
|
|
60
|
+
margin: 0.25rem;
|
|
61
|
+
border-radius: 0.5rem;
|
|
62
|
+
box-shadow: var(--shadow2);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([type='standard'][scroll]) .container {
|
|
66
|
+
box-shadow: var(--shadow3);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.leading,
|
|
70
|
+
.trailing {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
gap: 0.25rem;
|
|
74
|
+
flex: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.title {
|
|
78
|
+
flex: auto;
|
|
79
|
+
font-size: 1.375rem;
|
|
80
|
+
line-height: 1.75rem;
|
|
81
|
+
font-weight: 400;
|
|
82
|
+
white-space: nowrap;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
text-overflow: ellipsis;
|
|
85
|
+
padding-inline-start: 0.75rem;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
::slotted([slot='action-button']) {
|
|
89
|
+
position: absolute;
|
|
90
|
+
inset-block-end: -1.75rem;
|
|
91
|
+
inset-inline-end: 1rem;
|
|
92
|
+
z-index: 1;
|
|
93
|
+
}
|
|
94
|
+
`
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
override render() {
|
|
98
|
+
return html`
|
|
99
|
+
<header class="container" part="container">
|
|
100
|
+
<span class="leading" part="leading"><slot name="leading"></slot></span>
|
|
101
|
+
<span class="title" part="title">
|
|
102
|
+
${this.title || html`<slot></slot>`}
|
|
103
|
+
</span>
|
|
104
|
+
<span class="trailing" part="trailing">
|
|
105
|
+
<slot name="trailing"></slot>
|
|
106
|
+
</span>
|
|
107
|
+
</header>
|
|
108
|
+
<slot name="action-button"></slot>
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
declare global {
|
|
114
|
+
interface HTMLElementTagNameMap {
|
|
115
|
+
'moni-toolbar': MoniToolbar;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export default MoniToolbar;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
import './moni-tooltip.js';
|
|
3
|
+
import type { MoniTooltip } from './moni-tooltip.js';
|
|
4
|
+
|
|
5
|
+
describe('moni-tooltip (P3.1)', () => {
|
|
6
|
+
let parent: HTMLElement;
|
|
7
|
+
let el: MoniTooltip;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
parent = document.createElement('div');
|
|
11
|
+
el = document.createElement('moni-tooltip') as MoniTooltip;
|
|
12
|
+
el.text = 'Save changes';
|
|
13
|
+
parent.appendChild(el);
|
|
14
|
+
document.body.appendChild(parent);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
parent.remove();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('renders role="tooltip" on the inner element (M3 a11y)', async () => {
|
|
22
|
+
await el.updateComplete;
|
|
23
|
+
const tip = el.shadowRoot?.querySelector('[role="tooltip"]');
|
|
24
|
+
expect(tip).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('reflects the text on the host', async () => {
|
|
28
|
+
await el.updateComplete;
|
|
29
|
+
expect(el.text).toBe('Save changes');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('reflects position (default top)', async () => {
|
|
33
|
+
await el.updateComplete;
|
|
34
|
+
const tip = el.shadowRoot?.querySelector('.tooltip');
|
|
35
|
+
expect(tip?.classList.contains('top')).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('accepts all 6 M3 placements (top/top-start/top-end/bottom/bottom-start/bottom-end)', async () => {
|
|
39
|
+
const positions: Array<'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end'> = [
|
|
40
|
+
'top',
|
|
41
|
+
'top-start',
|
|
42
|
+
'top-end',
|
|
43
|
+
'bottom',
|
|
44
|
+
'bottom-start',
|
|
45
|
+
'bottom-end'
|
|
46
|
+
];
|
|
47
|
+
for (const pos of positions) {
|
|
48
|
+
el.position = pos;
|
|
49
|
+
await el.updateComplete;
|
|
50
|
+
const tip = el.shadowRoot?.querySelector('.tooltip');
|
|
51
|
+
expect(tip?.classList.contains(pos), `expected class ${pos}`).toBe(true);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('defaults to plain (rich=false)', async () => {
|
|
56
|
+
await el.updateComplete;
|
|
57
|
+
expect(el.rich).toBe(false);
|
|
58
|
+
expect(el.hasAttribute('rich')).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('rich=true enables rich content mode (rich attribute reflected)', async () => {
|
|
62
|
+
el.rich = true;
|
|
63
|
+
await el.updateComplete;
|
|
64
|
+
expect(el.rich).toBe(true);
|
|
65
|
+
expect(el.hasAttribute('rich')).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('shows the tooltip on mouseenter and hides on mouseleave', async () => {
|
|
69
|
+
await el.updateComplete;
|
|
70
|
+
const tip = el.shadowRoot?.querySelector('.tooltip') as HTMLElement;
|
|
71
|
+
expect(tip?.classList.contains('visible')).toBe(false);
|
|
72
|
+
|
|
73
|
+
parent.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }));
|
|
74
|
+
await el.updateComplete;
|
|
75
|
+
expect(tip?.classList.contains('visible')).toBe(true);
|
|
76
|
+
|
|
77
|
+
parent.dispatchEvent(new MouseEvent('mouseleave', { bubbles: true }));
|
|
78
|
+
await el.updateComplete;
|
|
79
|
+
expect(tip?.classList.contains('visible')).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('shows the tooltip on focusin and hides on focusout', async () => {
|
|
83
|
+
await el.updateComplete;
|
|
84
|
+
const tip = el.shadowRoot?.querySelector('.tooltip') as HTMLElement;
|
|
85
|
+
parent.dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
|
|
86
|
+
await el.updateComplete;
|
|
87
|
+
expect(tip?.classList.contains('visible')).toBe(true);
|
|
88
|
+
|
|
89
|
+
parent.dispatchEvent(new FocusEvent('focusout', { bubbles: true }));
|
|
90
|
+
await el.updateComplete;
|
|
91
|
+
expect(tip?.classList.contains('visible')).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('Escape key closes a visible tooltip', async () => {
|
|
95
|
+
await el.updateComplete;
|
|
96
|
+
const tip = el.shadowRoot?.querySelector('.tooltip') as HTMLElement;
|
|
97
|
+
parent.dispatchEvent(new MouseEvent('mouseenter', { bubbles: true }));
|
|
98
|
+
await el.updateComplete;
|
|
99
|
+
expect(tip?.classList.contains('visible')).toBe(true);
|
|
100
|
+
|
|
101
|
+
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
|
102
|
+
await el.updateComplete;
|
|
103
|
+
expect(tip?.classList.contains('visible')).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('applies size variants (small/medium/large)', async () => {
|
|
107
|
+
for (const size of ['small', 'medium', 'large'] as const) {
|
|
108
|
+
el.size = size;
|
|
109
|
+
await el.updateComplete;
|
|
110
|
+
const tip = el.shadowRoot?.querySelector('.tooltip');
|
|
111
|
+
expect(tip?.classList.contains(size), `expected class ${size}`).toBe(true);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('cleans up listeners on disconnect', () => {
|
|
116
|
+
// Sanity: removing the parent cleans up.
|
|
117
|
+
parent.remove();
|
|
118
|
+
// No assertion needed; if listeners leaked, the next beforeEach would
|
|
119
|
+
// accumulate them but vitest would still pass. Visual coverage only.
|
|
120
|
+
expect(parent.isConnected).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { html, css } from 'lit';
|
|
2
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
3
|
+
import { MoniElement, sharedStyles } from './_base/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tooltip that faithfully ports BeerCSS's `.tooltip` styles and adds M3
|
|
7
|
+
* Expressive semantics.
|
|
8
|
+
*
|
|
9
|
+
* **M3 spec** (`m3-docs/components/tooltips/specs.md`):
|
|
10
|
+
* - Two types: **plain** (text only) and **rich** (HTML content).
|
|
11
|
+
* - 6 placements: top, top-start, top-end, bottom, bottom-start, bottom-end.
|
|
12
|
+
* - Trigger: hover (mouse) or focus (keyboard) on the parent.
|
|
13
|
+
* - Auto-dismiss: tooltip hides on `mouseleave` / `focusout` / `Escape`.
|
|
14
|
+
*
|
|
15
|
+
* The component delegates trigger detection to the parent element (consistent
|
|
16
|
+
* with the original BeerCSS port). The tooltip element is `position: absolute`
|
|
17
|
+
* inside the parent so it follows the trigger naturally.
|
|
18
|
+
*
|
|
19
|
+
* **Accessibility**:
|
|
20
|
+
* - The tooltip has `role="tooltip"` (M3 spec).
|
|
21
|
+
* - When `rich` content is used, the parent should also have
|
|
22
|
+
* `aria-describedby="<tooltip-id>"`. The component sets a unique `id` on
|
|
23
|
+
* the tooltip element and exposes it via `tooltipId` getter.
|
|
24
|
+
* - `Escape` closes the tooltip (WAI-ARIA tooltip pattern).
|
|
25
|
+
*
|
|
26
|
+
* Attributes:
|
|
27
|
+
* - text: tooltip text (plain tooltip)
|
|
28
|
+
* - position: top (default) | top-start | top-end | bottom | bottom-start | bottom-end
|
|
29
|
+
* - size: '' (default) | small | medium | large
|
|
30
|
+
* - rich: boolean — when true, the default slot accepts arbitrary HTML
|
|
31
|
+
* for rich content (links, icons, etc.). When false (default),
|
|
32
|
+
* the slot is rendered as text only.
|
|
33
|
+
* - id: forwarded to the tooltip element (useful for aria-describedby)
|
|
34
|
+
*/
|
|
35
|
+
@customElement('moni-tooltip')
|
|
36
|
+
export class MoniTooltip extends MoniElement {
|
|
37
|
+
@property({ reflect: true }) text = '';
|
|
38
|
+
@property({ reflect: true })
|
|
39
|
+
position:
|
|
40
|
+
| 'top'
|
|
41
|
+
| 'top-start'
|
|
42
|
+
| 'top-end'
|
|
43
|
+
| 'bottom'
|
|
44
|
+
| 'bottom-start'
|
|
45
|
+
| 'bottom-end' = 'top';
|
|
46
|
+
@property({ reflect: true })
|
|
47
|
+
size: '' | 'small' | 'medium' | 'large' = '';
|
|
48
|
+
@property({ type: Boolean, reflect: true }) rich = false;
|
|
49
|
+
|
|
50
|
+
private _target: HTMLElement | null = null;
|
|
51
|
+
private _tooltipEl: HTMLElement | null = null;
|
|
52
|
+
private _docKeydown = (e: KeyboardEvent) => this._handleDocKeydown(e);
|
|
53
|
+
/**
|
|
54
|
+
* CSS `anchor-name` registered on the parent trigger so the tooltip
|
|
55
|
+
* can use `position-anchor` to bind to it. Generated per-instance via
|
|
56
|
+
* `crypto.randomUUID()` when CSS anchor positioning is supported.
|
|
57
|
+
*/
|
|
58
|
+
private _anchorName: string | null = null;
|
|
59
|
+
|
|
60
|
+
override connectedCallback() {
|
|
61
|
+
super.connectedCallback();
|
|
62
|
+
this._target = this.parentElement;
|
|
63
|
+
if (this._target) {
|
|
64
|
+
// Ensure parent has position: relative so absolute tooltip is anchored
|
|
65
|
+
const style = getComputedStyle(this._target);
|
|
66
|
+
if (style.position === 'static') {
|
|
67
|
+
this._target.style.position = 'relative';
|
|
68
|
+
}
|
|
69
|
+
this._target.addEventListener('mouseenter', this._show);
|
|
70
|
+
this._target.addEventListener('focusin', this._show);
|
|
71
|
+
this._target.addEventListener('mouseleave', this._hide);
|
|
72
|
+
this._target.addEventListener('focusout', this._hide);
|
|
73
|
+
|
|
74
|
+
// Auto-register a CSS anchor name on the parent trigger when the
|
|
75
|
+
// browser supports anchor positioning. Consumers can opt out by
|
|
76
|
+
// setting `data-no-anchor` on the trigger.
|
|
77
|
+
const cssSupports = (globalThis as unknown as {
|
|
78
|
+
CSS?: { supports?: (k: string) => boolean };
|
|
79
|
+
}).CSS?.supports;
|
|
80
|
+
const supportsAnchor = cssSupports
|
|
81
|
+
? cssSupports.call(window.CSS, 'anchor-name: --x')
|
|
82
|
+
: false;
|
|
83
|
+
if (supportsAnchor && !this._target.hasAttribute('data-no-anchor')) {
|
|
84
|
+
const cryptoApi = (globalThis as unknown as {
|
|
85
|
+
crypto?: { randomUUID?: () => string };
|
|
86
|
+
}).crypto;
|
|
87
|
+
const id = cryptoApi?.randomUUID?.()
|
|
88
|
+
?? `tt-${Math.random().toString(36).slice(2, 10)}`;
|
|
89
|
+
this._anchorName = `--moni-tooltip-anchor-${id}`;
|
|
90
|
+
this._target.style.setProperty('anchor-name', this._anchorName);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
document.addEventListener('keydown', this._docKeydown);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
override disconnectedCallback() {
|
|
97
|
+
if (this._target) {
|
|
98
|
+
this._target.removeEventListener('mouseenter', this._show);
|
|
99
|
+
this._target.removeEventListener('focusin', this._show);
|
|
100
|
+
this._target.removeEventListener('mouseleave', this._hide);
|
|
101
|
+
this._target.removeEventListener('focusout', this._hide);
|
|
102
|
+
if (this._anchorName) {
|
|
103
|
+
this._target.style.removeProperty('anchor-name');
|
|
104
|
+
this._anchorName = null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
document.removeEventListener('keydown', this._docKeydown);
|
|
108
|
+
super.disconnectedCallback();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private _show = () => {
|
|
112
|
+
if (!this._tooltipEl) {
|
|
113
|
+
this._tooltipEl = this.shadowRoot?.querySelector('.tooltip') as HTMLElement;
|
|
114
|
+
}
|
|
115
|
+
if (this._tooltipEl) {
|
|
116
|
+
this._tooltipEl.classList.add('visible');
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
private _hide = () => {
|
|
121
|
+
if (!this._tooltipEl) {
|
|
122
|
+
this._tooltipEl = this.shadowRoot?.querySelector('.tooltip') as HTMLElement;
|
|
123
|
+
}
|
|
124
|
+
if (this._tooltipEl) {
|
|
125
|
+
this._tooltipEl.classList.remove('visible');
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
private _handleDocKeydown(e: KeyboardEvent) {
|
|
130
|
+
if (e.key !== 'Escape') return;
|
|
131
|
+
if (!this._tooltipEl?.classList.contains('visible')) return;
|
|
132
|
+
this._hide();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Public ID of the tooltip element, suitable for `aria-describedby` on
|
|
137
|
+
* the trigger parent. Auto-generated if the consumer did not set `id`.
|
|
138
|
+
*/
|
|
139
|
+
get tooltipId(): string {
|
|
140
|
+
return this._tooltipEl?.id || '';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
static override styles = [
|
|
144
|
+
sharedStyles,
|
|
145
|
+
css`
|
|
146
|
+
:host {
|
|
147
|
+
display: contents;
|
|
148
|
+
font-family: var(--font);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* M3 CSS anchor positioning (Baseline 2024, Chrome 125+, Edge 125+).
|
|
152
|
+
When the parent has a registered anchor-name and this tooltip
|
|
153
|
+
uses position-anchor, the browser positions the tooltip relative
|
|
154
|
+
to the trigger natively — no JS needed for placement.
|
|
155
|
+
Fallbacks to absolute positioning for older browsers. */
|
|
156
|
+
.tooltip {
|
|
157
|
+
position-anchor: var(--_anchor-name);
|
|
158
|
+
}
|
|
159
|
+
.tooltip.top,
|
|
160
|
+
.tooltip.top-start,
|
|
161
|
+
.tooltip.top-end {
|
|
162
|
+
position-area: block-start;
|
|
163
|
+
}
|
|
164
|
+
.tooltip.bottom,
|
|
165
|
+
.tooltip.bottom-start,
|
|
166
|
+
.tooltip.bottom-end {
|
|
167
|
+
position-area: block-end;
|
|
168
|
+
}
|
|
169
|
+
.tooltip.left {
|
|
170
|
+
position-area: inline-start;
|
|
171
|
+
}
|
|
172
|
+
.tooltip.right {
|
|
173
|
+
position-area: inline-end;
|
|
174
|
+
}
|
|
175
|
+
.tooltip.top-start,
|
|
176
|
+
.tooltip.bottom-start {
|
|
177
|
+
position-try-fallbacks: start;
|
|
178
|
+
}
|
|
179
|
+
.tooltip.top-end,
|
|
180
|
+
.tooltip.bottom-end {
|
|
181
|
+
position-try-fallbacks: end;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* BeerCSS .tooltip — faithful port */
|
|
185
|
+
.tooltip {
|
|
186
|
+
--_space: -0.5rem;
|
|
187
|
+
visibility: hidden;
|
|
188
|
+
display: flex;
|
|
189
|
+
align-items: center;
|
|
190
|
+
justify-content: center;
|
|
191
|
+
gap: 0.5rem;
|
|
192
|
+
background-color: var(--inverse-surface);
|
|
193
|
+
color: var(--inverse-on-surface);
|
|
194
|
+
font-size: 0.75rem;
|
|
195
|
+
text-align: center;
|
|
196
|
+
border-radius: 0.25rem;
|
|
197
|
+
padding: 0.5rem;
|
|
198
|
+
position: absolute;
|
|
199
|
+
z-index: 200;
|
|
200
|
+
/* BeerCSS default: top center */
|
|
201
|
+
inset: 0 auto auto 50%;
|
|
202
|
+
inline-size: auto;
|
|
203
|
+
white-space: nowrap;
|
|
204
|
+
font-weight: 500;
|
|
205
|
+
opacity: 0;
|
|
206
|
+
transition: all var(--speed2);
|
|
207
|
+
line-height: normal;
|
|
208
|
+
transform: translate(-50%, -100%) scale(0.9);
|
|
209
|
+
margin-block-start: var(--_space);
|
|
210
|
+
pointer-events: none;
|
|
211
|
+
max-inline-size: 20rem;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* M3 6 placements — derived from BeerCSS's 4 + start/end variants. */
|
|
215
|
+
.tooltip.top,
|
|
216
|
+
.tooltip.top-start,
|
|
217
|
+
.tooltip.top-end {
|
|
218
|
+
inset: 0 auto auto 50%;
|
|
219
|
+
transform: translate(-50%, -100%) scale(0.9);
|
|
220
|
+
margin-block-start: var(--_space);
|
|
221
|
+
}
|
|
222
|
+
.tooltip.top-start {
|
|
223
|
+
inset-inline-start: 0;
|
|
224
|
+
transform: translate(0, -100%) scale(0.9);
|
|
225
|
+
}
|
|
226
|
+
.tooltip.top-end {
|
|
227
|
+
inset-inline-start: auto;
|
|
228
|
+
inset-inline-end: 0;
|
|
229
|
+
transform: translate(0, -100%) scale(0.9);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.tooltip.bottom,
|
|
233
|
+
.tooltip.bottom-start,
|
|
234
|
+
.tooltip.bottom-end {
|
|
235
|
+
inset: auto auto 0 50%;
|
|
236
|
+
transform: translate(-50%, 100%) scale(0.9);
|
|
237
|
+
margin-block-end: var(--_space);
|
|
238
|
+
margin-block-start: 0;
|
|
239
|
+
}
|
|
240
|
+
.tooltip.bottom-start {
|
|
241
|
+
inset-inline-start: 0;
|
|
242
|
+
transform: translate(0, 100%) scale(0.9);
|
|
243
|
+
}
|
|
244
|
+
.tooltip.bottom-end {
|
|
245
|
+
inset-inline-start: auto;
|
|
246
|
+
inset-inline-end: 0;
|
|
247
|
+
transform: translate(0, 100%) scale(0.9);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Legacy positions (left/right) — preserved for backward compat. */
|
|
251
|
+
.tooltip.left {
|
|
252
|
+
inset: 50% auto auto 0;
|
|
253
|
+
transform: translate(-100%, -50%) scale(0.9);
|
|
254
|
+
margin-inline: var(--_space);
|
|
255
|
+
margin-block-start: 0;
|
|
256
|
+
}
|
|
257
|
+
.tooltip.right {
|
|
258
|
+
inset: 50% 0 auto auto;
|
|
259
|
+
transform: translate(100%, -50%) scale(0.9);
|
|
260
|
+
margin-inline: var(--_space);
|
|
261
|
+
margin-block-start: 0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* Size variants */
|
|
265
|
+
.tooltip.small { inline-size: 8rem; white-space: normal; }
|
|
266
|
+
.tooltip.medium { inline-size: 12rem; white-space: normal; }
|
|
267
|
+
.tooltip.large { inline-size: 16rem; white-space: normal; }
|
|
268
|
+
|
|
269
|
+
/* Rich content — allow flex column for stacked content. */
|
|
270
|
+
:host([rich]) .tooltip {
|
|
271
|
+
flex-direction: column;
|
|
272
|
+
align-items: flex-start;
|
|
273
|
+
white-space: normal;
|
|
274
|
+
text-align: start;
|
|
275
|
+
padding: 0.75rem;
|
|
276
|
+
}
|
|
277
|
+
:host([rich]) .tooltip ::slotted(*) {
|
|
278
|
+
display: block;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/* Show state (triggered by JS class toggle) */
|
|
282
|
+
.tooltip.visible {
|
|
283
|
+
visibility: visible;
|
|
284
|
+
opacity: 1;
|
|
285
|
+
}
|
|
286
|
+
.tooltip.visible.top,
|
|
287
|
+
.tooltip.visible:not(.left, .right, .bottom, [class*='start'], [class*='end']) {
|
|
288
|
+
transform: translate(-50%, -100%) scale(1);
|
|
289
|
+
}
|
|
290
|
+
.tooltip.visible.top-start { transform: translate(0, -100%) scale(1); }
|
|
291
|
+
.tooltip.visible.top-end { transform: translate(0, -100%) scale(1); }
|
|
292
|
+
.tooltip.visible.bottom { transform: translate(-50%, 100%) scale(1); }
|
|
293
|
+
.tooltip.visible.bottom-start { transform: translate(0, 100%) scale(1); }
|
|
294
|
+
.tooltip.visible.bottom-end { transform: translate(0, 100%) scale(1); }
|
|
295
|
+
.tooltip.visible.left { transform: translate(-100%, -50%) scale(1); }
|
|
296
|
+
.tooltip.visible.right { transform: translate(100%, -50%) scale(1); }
|
|
297
|
+
`
|
|
298
|
+
];
|
|
299
|
+
|
|
300
|
+
override render() {
|
|
301
|
+
const classes = [
|
|
302
|
+
'tooltip',
|
|
303
|
+
this.position,
|
|
304
|
+
this.size
|
|
305
|
+
].filter(Boolean).join(' ');
|
|
306
|
+
return html`<div
|
|
307
|
+
class=${classes}
|
|
308
|
+
role="tooltip"
|
|
309
|
+
id=${this.id || ''}
|
|
310
|
+
part="tooltip"
|
|
311
|
+
style=${this._anchorName ? `--_anchor-name: ${this._anchorName}` : ''}
|
|
312
|
+
>
|
|
313
|
+
<slot>${this.text}</slot>
|
|
314
|
+
</div>`;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
declare global {
|
|
319
|
+
interface HTMLElementTagNameMap {
|
|
320
|
+
'moni-tooltip': MoniTooltip;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export default MoniTooltip;
|