@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,1107 @@
|
|
|
1
|
+
import { html, css, nothing } from 'lit';
|
|
2
|
+
import { customElement, property, state, query } from 'lit/decorators.js';
|
|
3
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { MoniElement, sharedStyles, fieldStyles } from './_base/index.js';
|
|
6
|
+
import './moni-icon.js';
|
|
7
|
+
import './moni-progress.js';
|
|
8
|
+
import './moni-select-option.js';
|
|
9
|
+
|
|
10
|
+
interface OptionNode {
|
|
11
|
+
type: 'option';
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
element?: HTMLElement;
|
|
16
|
+
group?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface GroupNode {
|
|
20
|
+
type: 'group';
|
|
21
|
+
label: string;
|
|
22
|
+
children: DropdownNode[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type DropdownNode = OptionNode | GroupNode;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Custom Searchable Select Component with Subcategories, Animations, and Drawer/Sheet option.
|
|
29
|
+
*/
|
|
30
|
+
@customElement('moni-select')
|
|
31
|
+
export class MoniSelect extends MoniElement {
|
|
32
|
+
@property({ reflect: true }) name = '';
|
|
33
|
+
@property({ reflect: true }) label = '';
|
|
34
|
+
@property({ reflect: true }) variant: 'filled' | 'outlined' = 'filled';
|
|
35
|
+
@property({ reflect: true })
|
|
36
|
+
size: 'small' | 'medium' | 'large' | 'extra' = 'medium';
|
|
37
|
+
@property({ reflect: true })
|
|
38
|
+
shape: 'round' | 'square' | 'no-round' = 'no-round';
|
|
39
|
+
@property({ type: Boolean, reflect: true }) disabled = false;
|
|
40
|
+
@property({ type: Boolean, reflect: true }) loading = false;
|
|
41
|
+
@property({ reflect: true }) helper = '';
|
|
42
|
+
@property({ reflect: true, attribute: 'error-text' }) errorText = '';
|
|
43
|
+
@property({ type: Boolean, reflect: true }) error = false;
|
|
44
|
+
@property({ reflect: true }) value = '';
|
|
45
|
+
@property({ reflect: true }) icon = '';
|
|
46
|
+
@property({ reflect: true, attribute: 'trailing-icon' }) trailingIcon =
|
|
47
|
+
'arrow_drop_down';
|
|
48
|
+
@property({ type: Boolean, reflect: true }) searchable = false;
|
|
49
|
+
@property({ type: Boolean, reflect: true }) clearable = false;
|
|
50
|
+
@property({ type: Boolean, reflect: true }) sheet = false;
|
|
51
|
+
@property({ reflect: true }) placeholder = '';
|
|
52
|
+
@property({ reflect: true }) positioning: 'absolute' | 'fixed' = 'absolute';
|
|
53
|
+
@property({ reflect: true }) placement: 'top' | 'bottom' | 'left' | 'right' | 'auto' = 'auto';
|
|
54
|
+
@property({ reflect: true, attribute: 'dropdown-width' }) dropdownWidth = 'trigger';
|
|
55
|
+
|
|
56
|
+
@state() private _open = false;
|
|
57
|
+
@state() private _searchQuery = '';
|
|
58
|
+
@state() private _actualPlacement: 'top' | 'bottom' | 'left' | 'right' = 'bottom';
|
|
59
|
+
@state() private _parsedOptions: DropdownNode[] = [];
|
|
60
|
+
@state() private _activeIndex = -1;
|
|
61
|
+
@state() private _menuStyle = '';
|
|
62
|
+
@state() private _useInlineCategories = false;
|
|
63
|
+
@state() private _drilldownPath: GroupNode[] = [];
|
|
64
|
+
|
|
65
|
+
@query('slot') private _slot!: HTMLSlotElement;
|
|
66
|
+
@query('input') private _input!: HTMLInputElement;
|
|
67
|
+
|
|
68
|
+
static override styles = [
|
|
69
|
+
sharedStyles,
|
|
70
|
+
fieldStyles,
|
|
71
|
+
css`
|
|
72
|
+
:host {
|
|
73
|
+
position: relative;
|
|
74
|
+
display: block;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.field {
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
input[type='text'] {
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
width: 100%;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
input[type='text'][readonly] {
|
|
87
|
+
caret-color: transparent;
|
|
88
|
+
user-select: none;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* Dropdown menu overlay */
|
|
92
|
+
.dropdown-menu {
|
|
93
|
+
position: absolute;
|
|
94
|
+
top: 100%;
|
|
95
|
+
left: 0;
|
|
96
|
+
right: 0;
|
|
97
|
+
z-index: 100;
|
|
98
|
+
background-color: var(--surface-container);
|
|
99
|
+
box-shadow: var(--elevate3);
|
|
100
|
+
border-radius: 0.5rem;
|
|
101
|
+
margin-top: 4px;
|
|
102
|
+
padding: 4px 0;
|
|
103
|
+
list-style: none;
|
|
104
|
+
opacity: 0;
|
|
105
|
+
visibility: hidden;
|
|
106
|
+
transform: scale(0.95) translateY(-8px);
|
|
107
|
+
transform-origin: top;
|
|
108
|
+
transition:
|
|
109
|
+
opacity var(--speed3) cubic-bezier(0.2, 0.8, 0.2, 1),
|
|
110
|
+
transform var(--speed3) cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
111
|
+
visibility var(--speed3);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.dropdown-menu.open {
|
|
115
|
+
opacity: 1;
|
|
116
|
+
visibility: visible;
|
|
117
|
+
transform: scale(1) translateY(0);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.dropdown-menu.placement-top {
|
|
121
|
+
top: auto;
|
|
122
|
+
bottom: 100%;
|
|
123
|
+
margin-top: 0;
|
|
124
|
+
margin-bottom: 4px;
|
|
125
|
+
transform-origin: bottom;
|
|
126
|
+
transform: scale(0.95) translateY(8px);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.dropdown-menu.placement-top.open {
|
|
130
|
+
transform: scale(1) translateY(0);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.dropdown-menu.placement-left {
|
|
134
|
+
top: 0;
|
|
135
|
+
left: auto;
|
|
136
|
+
right: 100%;
|
|
137
|
+
margin-top: 0;
|
|
138
|
+
margin-right: 4px;
|
|
139
|
+
transform-origin: right center;
|
|
140
|
+
transform: scale(0.95) translateX(8px);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.dropdown-menu.placement-left.open {
|
|
144
|
+
transform: scale(1) translateX(0);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.dropdown-menu.placement-right {
|
|
148
|
+
top: 0;
|
|
149
|
+
left: 100%;
|
|
150
|
+
right: auto;
|
|
151
|
+
margin-top: 0;
|
|
152
|
+
margin-left: 4px;
|
|
153
|
+
transform-origin: left center;
|
|
154
|
+
transform: scale(0.95) translateX(-8px);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.dropdown-menu.placement-right.open {
|
|
158
|
+
transform: scale(1) translateX(0);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.dropdown-menu.open.searching,
|
|
162
|
+
.dropdown-menu.open.inline-categories {
|
|
163
|
+
max-height: 250px;
|
|
164
|
+
overflow-y: auto;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.dropdown-menu.open:not(.searching):not(.inline-categories) {
|
|
168
|
+
overflow: visible;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Bottom sheet drawer styles */
|
|
172
|
+
.sheet-backdrop {
|
|
173
|
+
position: fixed;
|
|
174
|
+
inset: 0;
|
|
175
|
+
z-index: 1000;
|
|
176
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
177
|
+
opacity: 0;
|
|
178
|
+
visibility: hidden;
|
|
179
|
+
transition: opacity var(--speed3) cubic-bezier(0.2, 0.8, 0.2, 1), visibility var(--speed3);
|
|
180
|
+
display: flex;
|
|
181
|
+
flex-direction: column;
|
|
182
|
+
justify-content: flex-end;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.sheet-backdrop.open {
|
|
186
|
+
opacity: 1;
|
|
187
|
+
visibility: visible;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.sheet-drawer {
|
|
191
|
+
background-color: var(--surface-container);
|
|
192
|
+
border-radius: 1.75rem 1.75rem 0 0;
|
|
193
|
+
box-shadow: var(--elevate3);
|
|
194
|
+
max-height: 70vh;
|
|
195
|
+
display: flex;
|
|
196
|
+
flex-direction: column;
|
|
197
|
+
transform: translateY(100%);
|
|
198
|
+
transition: transform var(--speed3) cubic-bezier(0.16, 1, 0.3, 1);
|
|
199
|
+
padding: 16px 0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.sheet-drawer.open {
|
|
203
|
+
transform: translateY(0);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.sheet-handle {
|
|
207
|
+
width: 40px;
|
|
208
|
+
height: 4px;
|
|
209
|
+
background-color: var(--outline-variant);
|
|
210
|
+
border-radius: 2px;
|
|
211
|
+
margin: 0 auto 16px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.sheet-title {
|
|
215
|
+
padding: 0 24px 8px;
|
|
216
|
+
font-size: 1.125rem;
|
|
217
|
+
font-weight: 700;
|
|
218
|
+
color: var(--on-surface);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.sheet-search-wrapper {
|
|
222
|
+
padding: 0 16px 12px;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.sheet-search-input {
|
|
226
|
+
width: 100%;
|
|
227
|
+
box-sizing: border-box;
|
|
228
|
+
padding: 10px 16px;
|
|
229
|
+
border: 1px solid var(--outline);
|
|
230
|
+
border-radius: 9999px;
|
|
231
|
+
background: var(--surface-container-high);
|
|
232
|
+
color: var(--on-surface);
|
|
233
|
+
font-size: 1rem;
|
|
234
|
+
outline: none;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.sheet-search-input:focus {
|
|
238
|
+
border-color: var(--primary);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.sheet-options-list {
|
|
242
|
+
list-style: none;
|
|
243
|
+
padding: 0;
|
|
244
|
+
margin: 0;
|
|
245
|
+
overflow-y: auto;
|
|
246
|
+
flex: 1;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/* Animated Drilldown Slide Layout */
|
|
250
|
+
.drilldown-wrapper {
|
|
251
|
+
width: 100%;
|
|
252
|
+
overflow: hidden;
|
|
253
|
+
position: relative;
|
|
254
|
+
transition: height var(--speed3) cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.drilldown-track {
|
|
258
|
+
display: flex;
|
|
259
|
+
width: 200%;
|
|
260
|
+
transition: transform var(--speed3) cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.drilldown-track.slide-active {
|
|
264
|
+
transform: translateX(-50%);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.drilldown-panel {
|
|
268
|
+
width: 50%;
|
|
269
|
+
box-sizing: border-box;
|
|
270
|
+
list-style: none;
|
|
271
|
+
padding: 0;
|
|
272
|
+
margin: 0;
|
|
273
|
+
flex-shrink: 0;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.drilldown-panel.panel-active {
|
|
277
|
+
max-height: none;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.drilldown-panel.panel-inactive {
|
|
281
|
+
max-height: 0;
|
|
282
|
+
overflow: hidden;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/* Group / Subcategory header (Browsing mode - acts as a hover trigger for submenus) */
|
|
286
|
+
.group-header {
|
|
287
|
+
padding: 8px 16px;
|
|
288
|
+
font-size: 0.875rem;
|
|
289
|
+
font-weight: 500;
|
|
290
|
+
color: var(--on-surface);
|
|
291
|
+
cursor: pointer;
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
position: relative;
|
|
295
|
+
user-select: none;
|
|
296
|
+
transition: background-color var(--speed2) ease, color var(--speed2) ease;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.group-header:hover,
|
|
300
|
+
.group-header.active {
|
|
301
|
+
background-color: var(--surface-container-high);
|
|
302
|
+
color: var(--primary);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* Inline header (Searching mode & Sheet mode - flat layout) */
|
|
306
|
+
.group-header-flat {
|
|
307
|
+
padding: 6px 16px;
|
|
308
|
+
font-size: 0.75rem;
|
|
309
|
+
font-weight: 700;
|
|
310
|
+
text-transform: uppercase;
|
|
311
|
+
color: var(--primary);
|
|
312
|
+
letter-spacing: 0.05em;
|
|
313
|
+
background-color: var(--surface-container-low);
|
|
314
|
+
user-select: none;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/* Hierarchical sub-menu with premium flyout animation */
|
|
318
|
+
.submenu {
|
|
319
|
+
display: block;
|
|
320
|
+
opacity: 0;
|
|
321
|
+
visibility: hidden;
|
|
322
|
+
position: absolute;
|
|
323
|
+
top: 0;
|
|
324
|
+
background-color: var(--surface-container-highest);
|
|
325
|
+
box-shadow: var(--elevate3);
|
|
326
|
+
border-radius: 0.5rem;
|
|
327
|
+
padding: 4px 0;
|
|
328
|
+
list-style: none;
|
|
329
|
+
min-width: 160px;
|
|
330
|
+
z-index: 110;
|
|
331
|
+
transition:
|
|
332
|
+
opacity var(--speed2) cubic-bezier(0.2, 0.8, 0.2, 1),
|
|
333
|
+
transform var(--speed2) cubic-bezier(0.34, 1.56, 0.64, 1),
|
|
334
|
+
visibility var(--speed2);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.submenu.open-right {
|
|
338
|
+
left: 100%;
|
|
339
|
+
margin-left: 2px;
|
|
340
|
+
transform: scale(0.9) translateX(-10px);
|
|
341
|
+
transform-origin: top left;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
.submenu.open-left {
|
|
345
|
+
right: 100%;
|
|
346
|
+
margin-right: 2px;
|
|
347
|
+
transform: scale(0.9) translateX(10px);
|
|
348
|
+
transform-origin: top right;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
.group-header:hover > .submenu.active,
|
|
352
|
+
.group-header.active > .submenu.active {
|
|
353
|
+
opacity: 1;
|
|
354
|
+
visibility: visible;
|
|
355
|
+
transform: scale(1) translateX(0);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.option-item {
|
|
359
|
+
cursor: pointer;
|
|
360
|
+
padding: 8px 16px;
|
|
361
|
+
font-size: 0.875rem;
|
|
362
|
+
color: var(--on-surface);
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
transition: background-color var(--speed2) ease;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.option-item:hover,
|
|
369
|
+
.option-item.active-nav {
|
|
370
|
+
background-color: var(--surface-container-high);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.option-item.selected {
|
|
374
|
+
background-color: var(--tertiary-container);
|
|
375
|
+
color: var(--on-tertiary-container);
|
|
376
|
+
font-weight: 500;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.option-item.disabled {
|
|
380
|
+
opacity: 0.5;
|
|
381
|
+
pointer-events: none;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.no-options {
|
|
385
|
+
padding: 12px 16px;
|
|
386
|
+
font-size: 0.875rem;
|
|
387
|
+
color: var(--outline);
|
|
388
|
+
text-align: center;
|
|
389
|
+
}
|
|
390
|
+
`
|
|
391
|
+
];
|
|
392
|
+
|
|
393
|
+
override connectedCallback() {
|
|
394
|
+
super.connectedCallback();
|
|
395
|
+
document.addEventListener('click', this._handleOutsideClick);
|
|
396
|
+
window.addEventListener('scroll', this._handleScroll, { capture: true });
|
|
397
|
+
window.addEventListener('resize', this._handleResize);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
override disconnectedCallback() {
|
|
401
|
+
super.disconnectedCallback();
|
|
402
|
+
document.removeEventListener('click', this._handleOutsideClick);
|
|
403
|
+
window.removeEventListener('scroll', this._handleScroll, { capture: true });
|
|
404
|
+
window.removeEventListener('resize', this._handleResize);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
override updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
408
|
+
super.updated(changedProperties);
|
|
409
|
+
if (
|
|
410
|
+
changedProperties.has('_open') ||
|
|
411
|
+
changedProperties.has('_drilldownPath') ||
|
|
412
|
+
changedProperties.has('_searchQuery') ||
|
|
413
|
+
changedProperties.has('_useInlineCategories') ||
|
|
414
|
+
changedProperties.has('_parsedOptions')
|
|
415
|
+
) {
|
|
416
|
+
this._updateWrapperHeight();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
private _updateWrapperHeight() {
|
|
421
|
+
const wrapper = this.shadowRoot?.querySelector('.drilldown-wrapper') as HTMLElement;
|
|
422
|
+
if (!wrapper) return;
|
|
423
|
+
|
|
424
|
+
if (!this._open || this.sheet) {
|
|
425
|
+
wrapper.style.height = '';
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Wait for Lit render and styles to apply
|
|
430
|
+
requestAnimationFrame(() => {
|
|
431
|
+
const activePanel = this.shadowRoot?.querySelector('.drilldown-panel.panel-active') as HTMLElement;
|
|
432
|
+
if (activePanel) {
|
|
433
|
+
wrapper.style.height = `${activePanel.scrollHeight}px`;
|
|
434
|
+
} else {
|
|
435
|
+
wrapper.style.height = '';
|
|
436
|
+
}
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
private _handleOutsideClick = (e: MouseEvent) => {
|
|
441
|
+
if (this._open && !e.composedPath().includes(this)) {
|
|
442
|
+
this._closeDropdown();
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
private _determineActualPlacement() {
|
|
447
|
+
if (this.sheet) {
|
|
448
|
+
this._actualPlacement = 'bottom';
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const rect = this.getBoundingClientRect();
|
|
453
|
+
const viewportHeight = window.innerHeight;
|
|
454
|
+
const viewportWidth = window.innerWidth;
|
|
455
|
+
const spaceBelow = viewportHeight - rect.bottom;
|
|
456
|
+
const spaceAbove = rect.top;
|
|
457
|
+
const spaceRight = viewportWidth - rect.right;
|
|
458
|
+
const spaceLeft = rect.left;
|
|
459
|
+
const menuHeight = 260; // 250px max-height + 10px buffer
|
|
460
|
+
const menuWidth = 180; // Estimated menu width buffer
|
|
461
|
+
|
|
462
|
+
let preferred = this.placement;
|
|
463
|
+
if (preferred === 'auto') {
|
|
464
|
+
preferred = spaceBelow >= menuHeight ? 'bottom' : (spaceAbove > spaceBelow ? 'top' : 'bottom');
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (preferred === 'top') {
|
|
468
|
+
if (spaceAbove < menuHeight && spaceBelow > spaceAbove) {
|
|
469
|
+
this._actualPlacement = 'bottom';
|
|
470
|
+
} else {
|
|
471
|
+
this._actualPlacement = 'top';
|
|
472
|
+
}
|
|
473
|
+
} else if (preferred === 'bottom') {
|
|
474
|
+
if (spaceBelow < menuHeight && spaceAbove > spaceBelow) {
|
|
475
|
+
this._actualPlacement = 'top';
|
|
476
|
+
} else {
|
|
477
|
+
this._actualPlacement = 'bottom';
|
|
478
|
+
}
|
|
479
|
+
} else if (preferred === 'left') {
|
|
480
|
+
if (spaceLeft < menuWidth && spaceRight > spaceLeft) {
|
|
481
|
+
this._actualPlacement = 'right';
|
|
482
|
+
} else {
|
|
483
|
+
this._actualPlacement = 'left';
|
|
484
|
+
}
|
|
485
|
+
} else if (preferred === 'right') {
|
|
486
|
+
if (spaceRight < menuWidth && spaceLeft > spaceRight) {
|
|
487
|
+
this._actualPlacement = 'left';
|
|
488
|
+
} else {
|
|
489
|
+
this._actualPlacement = 'right';
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
private _handleScroll = () => {
|
|
495
|
+
if (this._open) {
|
|
496
|
+
this._determineActualPlacement();
|
|
497
|
+
this._updateMenuPosition();
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
private _handleResize = () => {
|
|
502
|
+
if (this._open) {
|
|
503
|
+
this._determineActualPlacement();
|
|
504
|
+
this._updateMenuPosition();
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
private _updateMenuPosition() {
|
|
509
|
+
if (!this._open || this.sheet) return;
|
|
510
|
+
|
|
511
|
+
this._determineActualPlacement();
|
|
512
|
+
|
|
513
|
+
if (this.positioning !== 'fixed') return;
|
|
514
|
+
|
|
515
|
+
const rect = this.getBoundingClientRect();
|
|
516
|
+
let widthStyle = '';
|
|
517
|
+
if (this.dropdownWidth === 'trigger') {
|
|
518
|
+
widthStyle = `width: ${rect.width}px;`;
|
|
519
|
+
} else if (this.dropdownWidth === 'auto') {
|
|
520
|
+
widthStyle = 'width: auto; min-width: 160px; max-width: 320px;';
|
|
521
|
+
} else {
|
|
522
|
+
widthStyle = `width: ${this.dropdownWidth};`;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (this._actualPlacement === 'top') {
|
|
526
|
+
this._menuStyle = `
|
|
527
|
+
position: fixed;
|
|
528
|
+
bottom: ${window.innerHeight - rect.top}px;
|
|
529
|
+
left: ${rect.left}px;
|
|
530
|
+
${widthStyle}
|
|
531
|
+
top: auto;
|
|
532
|
+
right: auto;
|
|
533
|
+
`;
|
|
534
|
+
} else if (this._actualPlacement === 'bottom') {
|
|
535
|
+
this._menuStyle = `
|
|
536
|
+
position: fixed;
|
|
537
|
+
top: ${rect.bottom}px;
|
|
538
|
+
left: ${rect.left}px;
|
|
539
|
+
${widthStyle}
|
|
540
|
+
bottom: auto;
|
|
541
|
+
right: auto;
|
|
542
|
+
`;
|
|
543
|
+
} else if (this._actualPlacement === 'left') {
|
|
544
|
+
this._menuStyle = `
|
|
545
|
+
position: fixed;
|
|
546
|
+
top: ${rect.top}px;
|
|
547
|
+
right: ${window.innerWidth - rect.left + 4}px;
|
|
548
|
+
${widthStyle}
|
|
549
|
+
left: auto;
|
|
550
|
+
bottom: auto;
|
|
551
|
+
`;
|
|
552
|
+
} else if (this._actualPlacement === 'right') {
|
|
553
|
+
this._menuStyle = `
|
|
554
|
+
position: fixed;
|
|
555
|
+
top: ${rect.top}px;
|
|
556
|
+
left: ${rect.right + 4}px;
|
|
557
|
+
${widthStyle}
|
|
558
|
+
right: auto;
|
|
559
|
+
bottom: auto;
|
|
560
|
+
`;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
private _getMenuStyle() {
|
|
565
|
+
if (this.positioning === 'fixed') {
|
|
566
|
+
return this._menuStyle;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
if (this.dropdownWidth === 'auto') {
|
|
570
|
+
return 'width: max-content; min-width: 160px; max-width: 320px;';
|
|
571
|
+
} else if (this.dropdownWidth !== 'trigger') {
|
|
572
|
+
return `width: ${this.dropdownWidth};`;
|
|
573
|
+
}
|
|
574
|
+
return '';
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
private _onSlotChange() {
|
|
578
|
+
if (!this._slot) return;
|
|
579
|
+
const assigned = this._slot.assignedElements({ flatten: true });
|
|
580
|
+
|
|
581
|
+
const tree: DropdownNode[] = [];
|
|
582
|
+
|
|
583
|
+
const findOrCreateGroup = (nodes: DropdownNode[], label: string): GroupNode => {
|
|
584
|
+
let group = nodes.find(n => n.type === 'group' && n.label === label) as GroupNode;
|
|
585
|
+
if (!group) {
|
|
586
|
+
group = { type: 'group', label, children: [] };
|
|
587
|
+
nodes.push(group);
|
|
588
|
+
}
|
|
589
|
+
return group;
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
const insertOption = (targetTree: DropdownNode[], opt: OptionNode, groupPath: string[]) => {
|
|
593
|
+
let currentLevel = targetTree;
|
|
594
|
+
if (groupPath.length > 0) {
|
|
595
|
+
opt.group = groupPath.join(' / ');
|
|
596
|
+
}
|
|
597
|
+
groupPath.forEach(part => {
|
|
598
|
+
const group = findOrCreateGroup(currentLevel, part);
|
|
599
|
+
currentLevel = group.children;
|
|
600
|
+
});
|
|
601
|
+
currentLevel.push(opt);
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
const parseElement = (el: Element, parentGroupPath: string[]) => {
|
|
605
|
+
const tag = el.tagName.toLowerCase();
|
|
606
|
+
if (tag === 'option' || tag === 'moni-select-option') {
|
|
607
|
+
const opt: OptionNode = {
|
|
608
|
+
type: 'option',
|
|
609
|
+
value: el.getAttribute('value') || '',
|
|
610
|
+
label: el.textContent?.trim() || el.getAttribute('label') || el.getAttribute('value') || '',
|
|
611
|
+
disabled: el.hasAttribute('disabled'),
|
|
612
|
+
element: el as HTMLElement
|
|
613
|
+
};
|
|
614
|
+
const groupAttr = el.getAttribute('group');
|
|
615
|
+
const localPath = groupAttr ? groupAttr.split('/').map(s => s.trim()).filter(Boolean) : [];
|
|
616
|
+
const finalPath = [...parentGroupPath, ...localPath];
|
|
617
|
+
insertOption(tree, opt, finalPath);
|
|
618
|
+
} else if (tag === 'optgroup') {
|
|
619
|
+
const label = el.getAttribute('label') || '';
|
|
620
|
+
const localPath = [...parentGroupPath, label];
|
|
621
|
+
Array.from(el.children).forEach(child => parseElement(child, localPath));
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
assigned.forEach(el => parseElement(el, []));
|
|
626
|
+
this._parsedOptions = tree;
|
|
627
|
+
this.requestUpdate();
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
private _toggleDropdown(e?: Event) {
|
|
631
|
+
if (e) {
|
|
632
|
+
e.stopPropagation();
|
|
633
|
+
}
|
|
634
|
+
if (this.disabled) return;
|
|
635
|
+
if (this._open) {
|
|
636
|
+
this._closeDropdown();
|
|
637
|
+
} else {
|
|
638
|
+
this._openDropdown();
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
private _onInputClick(e: MouseEvent) {
|
|
643
|
+
if (this.disabled) return;
|
|
644
|
+
if (this.searchable && !this.sheet) {
|
|
645
|
+
if (!this._open) {
|
|
646
|
+
this._openDropdown();
|
|
647
|
+
}
|
|
648
|
+
} else {
|
|
649
|
+
this._toggleDropdown(e);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
private _openDropdown() {
|
|
654
|
+
this._open = true;
|
|
655
|
+
this._activeIndex = -1;
|
|
656
|
+
this._drilldownPath = [];
|
|
657
|
+
|
|
658
|
+
this._determineActualPlacement();
|
|
659
|
+
|
|
660
|
+
// Measure viewport to determine if we should fall back to inline categories
|
|
661
|
+
const rect = this.getBoundingClientRect();
|
|
662
|
+
const spaceOnRight = window.innerWidth - rect.right;
|
|
663
|
+
const spaceOnLeft = rect.left;
|
|
664
|
+
this._useInlineCategories = window.innerWidth < 600 || (spaceOnRight < 160 && spaceOnLeft < 160);
|
|
665
|
+
|
|
666
|
+
if (this.positioning === 'fixed') {
|
|
667
|
+
this._updateMenuPosition();
|
|
668
|
+
}
|
|
669
|
+
if (this.searchable) {
|
|
670
|
+
const selectedOpt = this._findOptionByValue(this.value);
|
|
671
|
+
this._searchQuery = selectedOpt ? selectedOpt.label : '';
|
|
672
|
+
setTimeout(() => {
|
|
673
|
+
if (this._input && !this.sheet) {
|
|
674
|
+
this._input.focus();
|
|
675
|
+
this._input.select();
|
|
676
|
+
} else if (this.sheet) {
|
|
677
|
+
const sheetInput = this.shadowRoot?.querySelector('.sheet-search-input') as HTMLInputElement;
|
|
678
|
+
if (sheetInput) {
|
|
679
|
+
sheetInput.focus();
|
|
680
|
+
sheetInput.select();
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}, 50);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
private _closeDropdown() {
|
|
688
|
+
this._open = false;
|
|
689
|
+
this._searchQuery = '';
|
|
690
|
+
this.requestUpdate();
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
private _findOptionByValue(value: string): OptionNode | undefined {
|
|
694
|
+
return this._getFlatOptions(this._parsedOptions).find(opt => opt.value === value);
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
private _onSearchInput(e: Event) {
|
|
698
|
+
const query = (e.target as HTMLInputElement).value;
|
|
699
|
+
this._searchQuery = query;
|
|
700
|
+
this._open = true;
|
|
701
|
+
this._activeIndex = -1;
|
|
702
|
+
|
|
703
|
+
if (this.clearable && query.trim() === '') {
|
|
704
|
+
this.value = '';
|
|
705
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
706
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
const flat = this._getFlatOptions(this._parsedOptions);
|
|
711
|
+
const exactMatch = flat.find(
|
|
712
|
+
opt => opt.label.toLowerCase() === query.trim().toLowerCase()
|
|
713
|
+
);
|
|
714
|
+
if (exactMatch && !exactMatch.disabled) {
|
|
715
|
+
this._selectOption(exactMatch);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
private _selectOption(option: OptionNode) {
|
|
720
|
+
if (option.disabled) return;
|
|
721
|
+
this.value = option.value;
|
|
722
|
+
this._closeDropdown();
|
|
723
|
+
|
|
724
|
+
this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
725
|
+
this.dispatchEvent(new Event('change', { bubbles: true, composed: true }));
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
private _onSubmenuMouseEnter(e: MouseEvent) {
|
|
729
|
+
const headerEl = e.currentTarget as HTMLElement;
|
|
730
|
+
const submenu = headerEl.querySelector(':scope > .submenu') as HTMLElement;
|
|
731
|
+
if (!submenu) return;
|
|
732
|
+
|
|
733
|
+
const rect = headerEl.getBoundingClientRect();
|
|
734
|
+
const spaceOnRight = window.innerWidth - rect.right;
|
|
735
|
+
const spaceOnLeft = rect.left;
|
|
736
|
+
const submenuWidth = 160;
|
|
737
|
+
|
|
738
|
+
if (spaceOnRight < submenuWidth && spaceOnLeft > spaceOnRight) {
|
|
739
|
+
submenu.classList.remove('open-right');
|
|
740
|
+
submenu.classList.add('open-left');
|
|
741
|
+
} else {
|
|
742
|
+
submenu.classList.remove('open-left');
|
|
743
|
+
submenu.classList.add('open-right');
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
private _onKeyDown(e: KeyboardEvent) {
|
|
748
|
+
if (this.disabled) return;
|
|
749
|
+
|
|
750
|
+
const visible = this._getVisibleOptions();
|
|
751
|
+
|
|
752
|
+
if (e.key === 'ArrowDown') {
|
|
753
|
+
e.preventDefault();
|
|
754
|
+
if (!this._open) {
|
|
755
|
+
this._openDropdown();
|
|
756
|
+
} else if (visible.length > 0) {
|
|
757
|
+
this._activeIndex = (this._activeIndex + 1) % visible.length;
|
|
758
|
+
this._scrollToActive();
|
|
759
|
+
}
|
|
760
|
+
} else if (e.key === 'ArrowUp') {
|
|
761
|
+
e.preventDefault();
|
|
762
|
+
if (this._open && visible.length > 0) {
|
|
763
|
+
this._activeIndex = (this._activeIndex - 1 + visible.length) % visible.length;
|
|
764
|
+
this._scrollToActive();
|
|
765
|
+
}
|
|
766
|
+
} else if (e.key === 'Enter') {
|
|
767
|
+
e.preventDefault();
|
|
768
|
+
if (this._open) {
|
|
769
|
+
if (this._activeIndex >= 0 && this._activeIndex < visible.length) {
|
|
770
|
+
this._selectOption(visible[this._activeIndex]);
|
|
771
|
+
}
|
|
772
|
+
} else {
|
|
773
|
+
this._openDropdown();
|
|
774
|
+
}
|
|
775
|
+
} else if (e.key === 'Escape') {
|
|
776
|
+
e.preventDefault();
|
|
777
|
+
this._closeDropdown();
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
private _scrollToActive() {
|
|
782
|
+
setTimeout(() => {
|
|
783
|
+
const activeEl = this.shadowRoot?.querySelector('.option-item.active-nav');
|
|
784
|
+
if (activeEl) {
|
|
785
|
+
activeEl.scrollIntoView({ block: 'nearest' });
|
|
786
|
+
}
|
|
787
|
+
}, 0);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
private _getFlatOptions(nodes: DropdownNode[]): OptionNode[] {
|
|
791
|
+
const flat: OptionNode[] = [];
|
|
792
|
+
const traverse = (n: DropdownNode) => {
|
|
793
|
+
if (n.type === 'option') {
|
|
794
|
+
flat.push(n);
|
|
795
|
+
} else {
|
|
796
|
+
n.children.forEach(traverse);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
nodes.forEach(traverse);
|
|
800
|
+
return flat;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
private _getFilteredOptions(): OptionNode[] {
|
|
804
|
+
const flat = this._getFlatOptions(this._parsedOptions);
|
|
805
|
+
if (!this._searchQuery) return flat;
|
|
806
|
+
const query = this._searchQuery.toLowerCase();
|
|
807
|
+
return flat.filter(opt =>
|
|
808
|
+
opt.label.toLowerCase().includes(query) || opt.value.toLowerCase().includes(query)
|
|
809
|
+
);
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
private _getVisibleOptions(): OptionNode[] {
|
|
813
|
+
const filtered = this._getFilteredOptions();
|
|
814
|
+
if (this._searchQuery) return filtered;
|
|
815
|
+
|
|
816
|
+
if (this.sheet || this._useInlineCategories) {
|
|
817
|
+
if (this._drilldownPath.length > 0) {
|
|
818
|
+
const activeGroup = this._drilldownPath[this._drilldownPath.length - 1];
|
|
819
|
+
return activeGroup.children.filter(n => n.type === 'option') as OptionNode[];
|
|
820
|
+
}
|
|
821
|
+
return this._parsedOptions.filter(n => n.type === 'option') as OptionNode[];
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
return filtered;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
private _renderRootList() {
|
|
828
|
+
let visibleIndex = 0;
|
|
829
|
+
return this._parsedOptions.map(node => {
|
|
830
|
+
if (node.type === 'option') {
|
|
831
|
+
const currentIdx = visibleIndex++;
|
|
832
|
+
const isSelected = node.value === this.value;
|
|
833
|
+
const isActiveNav = this._drilldownPath.length === 0 && currentIdx === this._activeIndex;
|
|
834
|
+
return html`
|
|
835
|
+
<li
|
|
836
|
+
class="option-item ${isSelected ? 'selected' : ''} ${isActiveNav ? 'active-nav' : ''} ${node.disabled ? 'disabled' : ''}"
|
|
837
|
+
@click=${() => this._selectOption(node)}
|
|
838
|
+
>
|
|
839
|
+
${node.label}
|
|
840
|
+
</li>
|
|
841
|
+
`;
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
return html`
|
|
845
|
+
<li class="group-header" @click=${(e: Event) => { e.stopPropagation(); this._drilldownPath = [...this._drilldownPath, node]; }}>
|
|
846
|
+
<span>${node.label}</span>
|
|
847
|
+
<moni-icon name="chevron_right" style="margin-inline-start: auto; font-size: 1.125rem;"></moni-icon>
|
|
848
|
+
</li>
|
|
849
|
+
`;
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
private _renderSubcategoryList() {
|
|
854
|
+
if (this._drilldownPath.length === 0) return nothing;
|
|
855
|
+
const activeGroup = this._drilldownPath[this._drilldownPath.length - 1];
|
|
856
|
+
let visibleIndex = 0;
|
|
857
|
+
|
|
858
|
+
return html`
|
|
859
|
+
<li class="group-header" @click=${(e: Event) => { e.stopPropagation(); this._drilldownPath = this._drilldownPath.slice(0, -1); }}>
|
|
860
|
+
<moni-icon name="arrow_back" style="font-size: 1.25rem; margin-inline-end: 8px;"></moni-icon>
|
|
861
|
+
<span>Regresar</span>
|
|
862
|
+
</li>
|
|
863
|
+
<li class="group-header-flat">${activeGroup.label}</li>
|
|
864
|
+
${activeGroup.children.map(node => {
|
|
865
|
+
if (node.type === 'option') {
|
|
866
|
+
const currentIdx = visibleIndex++;
|
|
867
|
+
const isSelected = node.value === this.value;
|
|
868
|
+
const isActiveNav = this._drilldownPath.length > 0 && currentIdx === this._activeIndex;
|
|
869
|
+
return html`
|
|
870
|
+
<li
|
|
871
|
+
class="option-item ${isSelected ? 'selected' : ''} ${isActiveNav ? 'active-nav' : ''} ${node.disabled ? 'disabled' : ''}"
|
|
872
|
+
@click=${() => this._selectOption(node)}
|
|
873
|
+
>
|
|
874
|
+
${node.label}
|
|
875
|
+
</li>
|
|
876
|
+
`;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
return html`
|
|
880
|
+
<li class="group-header" @click=${(e: Event) => { e.stopPropagation(); this._drilldownPath = [...this._drilldownPath, node]; }}>
|
|
881
|
+
<span>${node.label}</span>
|
|
882
|
+
<moni-icon name="chevron_right" style="margin-inline-start: auto; font-size: 1.125rem;"></moni-icon>
|
|
883
|
+
</li>
|
|
884
|
+
`;
|
|
885
|
+
})}
|
|
886
|
+
`;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
private _renderDesktopNode(node: DropdownNode, flatIndexRef: { value: number }): any {
|
|
890
|
+
if (node.type === 'option') {
|
|
891
|
+
const currentIdx = flatIndexRef.value++;
|
|
892
|
+
const isSelected = node.value === this.value;
|
|
893
|
+
const isActiveNav = currentIdx === this._activeIndex;
|
|
894
|
+
return html`
|
|
895
|
+
<li
|
|
896
|
+
class="option-item ${isSelected ? 'selected' : ''} ${isActiveNav ? 'active-nav' : ''} ${node.disabled ? 'disabled' : ''}"
|
|
897
|
+
@click=${() => this._selectOption(node)}
|
|
898
|
+
>
|
|
899
|
+
${node.label}
|
|
900
|
+
</li>
|
|
901
|
+
`;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
return html`
|
|
905
|
+
<li
|
|
906
|
+
class="group-header"
|
|
907
|
+
@mouseenter=${this._onSubmenuMouseEnter}
|
|
908
|
+
@click=${(e: Event) => e.stopPropagation()}
|
|
909
|
+
>
|
|
910
|
+
<span>${node.label}</span>
|
|
911
|
+
<moni-icon name="chevron_right" style="margin-inline-start: auto; font-size: 1.125rem;"></moni-icon>
|
|
912
|
+
|
|
913
|
+
<ul class="submenu active open-right">
|
|
914
|
+
${node.children.map(child => this._renderDesktopNode(child, flatIndexRef))}
|
|
915
|
+
</ul>
|
|
916
|
+
</li>
|
|
917
|
+
`;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
private _renderOptionsList(filtered: OptionNode[]) {
|
|
921
|
+
if (this._parsedOptions.length === 0) {
|
|
922
|
+
return html`<li class="no-options">No options found</li>`;
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
if (this._searchQuery) {
|
|
926
|
+
const groups: { [key: string]: OptionNode[] } = {};
|
|
927
|
+
filtered.forEach(opt => {
|
|
928
|
+
const gName = opt.group || '';
|
|
929
|
+
if (!groups[gName]) groups[gName] = [];
|
|
930
|
+
groups[gName].push(opt);
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
let flatIndex = 0;
|
|
934
|
+
return Object.entries(groups).map(([groupName, groupOpts]) => html`
|
|
935
|
+
${groupName ? html`<li class="group-header-flat">${groupName}</li>` : nothing}
|
|
936
|
+
${groupOpts.map(opt => {
|
|
937
|
+
const currentIdx = flatIndex++;
|
|
938
|
+
const isSelected = opt.value === this.value;
|
|
939
|
+
const isActiveNav = currentIdx === this._activeIndex;
|
|
940
|
+
return html`
|
|
941
|
+
<li
|
|
942
|
+
class="option-item ${isSelected ? 'selected' : ''} ${isActiveNav ? 'active-nav' : ''} ${opt.disabled ? 'disabled' : ''}"
|
|
943
|
+
@click=${() => this._selectOption(opt)}
|
|
944
|
+
>
|
|
945
|
+
${opt.label}
|
|
946
|
+
</li>
|
|
947
|
+
`;
|
|
948
|
+
})}
|
|
949
|
+
`);
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
if (this.sheet || this._useInlineCategories) {
|
|
953
|
+
const isRootActive = this._drilldownPath.length === 0;
|
|
954
|
+
const isSubActive = !isRootActive;
|
|
955
|
+
|
|
956
|
+
return html`
|
|
957
|
+
<div class="drilldown-wrapper">
|
|
958
|
+
<div class="drilldown-track ${this._drilldownPath.length > 0 ? 'slide-active' : ''}">
|
|
959
|
+
<ul class="drilldown-panel ${isRootActive ? 'panel-active' : 'panel-inactive'}">
|
|
960
|
+
${this._renderRootList()}
|
|
961
|
+
</ul>
|
|
962
|
+
<ul class="drilldown-panel ${isSubActive ? 'panel-active' : 'panel-inactive'}">
|
|
963
|
+
${this._renderSubcategoryList()}
|
|
964
|
+
</ul>
|
|
965
|
+
</div>
|
|
966
|
+
</div>
|
|
967
|
+
`;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
const flatIndexRef = { value: 0 };
|
|
971
|
+
return this._parsedOptions.map(node => this._renderDesktopNode(node, flatIndexRef));
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
override render() {
|
|
975
|
+
const hasLeading = Boolean(this.icon);
|
|
976
|
+
const filtered = this._getFilteredOptions();
|
|
977
|
+
|
|
978
|
+
// Find selected option label
|
|
979
|
+
const selectedOpt = this._findOptionByValue(this.value);
|
|
980
|
+
const displayValue = this._open && this.searchable && !this.sheet
|
|
981
|
+
? this._searchQuery
|
|
982
|
+
: (selectedOpt ? selectedOpt.label : '');
|
|
983
|
+
|
|
984
|
+
const isActive = Boolean(displayValue || this.placeholder);
|
|
985
|
+
|
|
986
|
+
const fieldClasses = {
|
|
987
|
+
field: true,
|
|
988
|
+
label: Boolean(this.label),
|
|
989
|
+
fill: this.variant === 'filled',
|
|
990
|
+
border: this.variant === 'outlined',
|
|
991
|
+
small: this.size === 'small',
|
|
992
|
+
large: this.size === 'large',
|
|
993
|
+
extra: this.size === 'extra',
|
|
994
|
+
prefix: hasLeading,
|
|
995
|
+
suffix: true,
|
|
996
|
+
invalid: this.error,
|
|
997
|
+
round: this.shape === 'round',
|
|
998
|
+
square: this.shape === 'no-round'
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
const leading = this.icon
|
|
1002
|
+
? html`<i class="leading-icon" part="leading-icon"
|
|
1003
|
+
><moni-icon name="${this.icon}"></moni-icon
|
|
1004
|
+
></i>`
|
|
1005
|
+
: nothing;
|
|
1006
|
+
|
|
1007
|
+
const trailing = this.loading
|
|
1008
|
+
? html`<i class="trailing-icon" part="trailing-icon"
|
|
1009
|
+
><moni-progress
|
|
1010
|
+
variant="circular"
|
|
1011
|
+
indeterminate
|
|
1012
|
+
size="small"
|
|
1013
|
+
style="inline-size: 1.25rem; block-size: 1.25rem; color: currentColor;"
|
|
1014
|
+
></moni-progress
|
|
1015
|
+
></i>`
|
|
1016
|
+
: html`<i class="trailing-icon" part="trailing-icon" @click=${this._toggleDropdown}
|
|
1017
|
+
><moni-icon name="${this.trailingIcon}"></moni-icon
|
|
1018
|
+
></i>`;
|
|
1019
|
+
|
|
1020
|
+
const menuClasses = {
|
|
1021
|
+
'dropdown-menu': true,
|
|
1022
|
+
open: this._open,
|
|
1023
|
+
searching: Boolean(this._searchQuery),
|
|
1024
|
+
'inline-categories': this._useInlineCategories,
|
|
1025
|
+
'placement-top': this._actualPlacement === 'top',
|
|
1026
|
+
'placement-bottom': this._actualPlacement === 'bottom'
|
|
1027
|
+
};
|
|
1028
|
+
|
|
1029
|
+
return html`<div class=${classMap(fieldClasses)} part="field">
|
|
1030
|
+
${leading}
|
|
1031
|
+
<input
|
|
1032
|
+
type="text"
|
|
1033
|
+
part="input"
|
|
1034
|
+
.value=${displayValue}
|
|
1035
|
+
?readonly=${!this.searchable || this.sheet}
|
|
1036
|
+
?disabled=${this.disabled}
|
|
1037
|
+
inputmode=${ifDefined(!this.searchable || this.sheet ? 'none' : undefined)}
|
|
1038
|
+
placeholder=${this.placeholder || ''}
|
|
1039
|
+
class=${isActive ? 'active' : ''}
|
|
1040
|
+
@click=${this._onInputClick}
|
|
1041
|
+
@input=${this._onSearchInput}
|
|
1042
|
+
@keydown=${this._onKeyDown}
|
|
1043
|
+
/>
|
|
1044
|
+
${this.label
|
|
1045
|
+
? html`<label
|
|
1046
|
+
part="label"
|
|
1047
|
+
class=${classMap({ active: isActive })}
|
|
1048
|
+
>${this.label}</label
|
|
1049
|
+
>`
|
|
1050
|
+
: nothing}
|
|
1051
|
+
${trailing}
|
|
1052
|
+
|
|
1053
|
+
${this.sheet
|
|
1054
|
+
? html`
|
|
1055
|
+
<div class="sheet-backdrop ${this._open ? 'open' : ''}" @click=${this._closeDropdown}>
|
|
1056
|
+
<div class="sheet-drawer ${this._open ? 'open' : ''}" @click=${(e: Event) => e.stopPropagation()}>
|
|
1057
|
+
<div class="sheet-handle"></div>
|
|
1058
|
+
${this.label ? html`<div class="sheet-title">${this.label}</div>` : nothing}
|
|
1059
|
+
${this.searchable
|
|
1060
|
+
? html`
|
|
1061
|
+
<div class="sheet-search-wrapper">
|
|
1062
|
+
<input
|
|
1063
|
+
type="text"
|
|
1064
|
+
class="sheet-search-input"
|
|
1065
|
+
.value=${this._searchQuery}
|
|
1066
|
+
placeholder="Buscar..."
|
|
1067
|
+
@input=${this._onSearchInput}
|
|
1068
|
+
/>
|
|
1069
|
+
</div>
|
|
1070
|
+
`
|
|
1071
|
+
: nothing}
|
|
1072
|
+
<ul class="sheet-options-list">
|
|
1073
|
+
${this._renderOptionsList(filtered)}
|
|
1074
|
+
</ul>
|
|
1075
|
+
</div>
|
|
1076
|
+
</div>
|
|
1077
|
+
`
|
|
1078
|
+
: html`
|
|
1079
|
+
<ul
|
|
1080
|
+
class=${classMap(menuClasses)}
|
|
1081
|
+
part="menu"
|
|
1082
|
+
style=${this._getMenuStyle()}
|
|
1083
|
+
>
|
|
1084
|
+
${this._renderOptionsList(filtered)}
|
|
1085
|
+
</ul>
|
|
1086
|
+
`}
|
|
1087
|
+
|
|
1088
|
+
<slot style="display: none;" @slotchange=${this._onSlotChange}></slot>
|
|
1089
|
+
|
|
1090
|
+
${this.error
|
|
1091
|
+
? html`<output part="helper" class="invalid"
|
|
1092
|
+
>${this.errorText || this.helper}</output
|
|
1093
|
+
>`
|
|
1094
|
+
: this.helper
|
|
1095
|
+
? html`<output part="helper">${this.helper}</output>`
|
|
1096
|
+
: nothing}
|
|
1097
|
+
</div>`;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
declare global {
|
|
1102
|
+
interface HTMLElementTagNameMap {
|
|
1103
|
+
'moni-select': MoniSelect;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
export default MoniSelect;
|