@melodicdev/components 2.0.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/assets/melodic-components.js +5570 -4150
- package/assets/melodic-components.js.map +1 -1
- package/assets/melodic-components.min.js +6466 -5147
- package/lib/components/data-display/activity-feed/activity-feed-item.component.d.ts +15 -14
- package/lib/components/data-display/activity-feed/activity-feed-item.component.d.ts.map +1 -1
- package/lib/components/data-display/activity-feed/activity-feed-item.component.js +36 -16
- package/lib/components/data-display/activity-feed/activity-feed-item.styles.d.ts.map +1 -1
- package/lib/components/data-display/activity-feed/activity-feed-item.styles.js +4 -0
- package/lib/components/data-display/activity-feed/activity-feed-item.template.d.ts.map +1 -1
- package/lib/components/data-display/activity-feed/activity-feed-item.template.js +15 -14
- package/lib/components/data-display/avatar/avatar.component.d.ts +9 -4
- package/lib/components/data-display/avatar/avatar.component.d.ts.map +1 -1
- package/lib/components/data-display/avatar/avatar.component.js +12 -3
- package/lib/components/data-display/avatar/avatar.template.js +1 -1
- package/lib/components/data-display/badge/badge.component.d.ts +2 -3
- package/lib/components/data-display/badge/badge.component.d.ts.map +1 -1
- package/lib/components/data-display/badge/badge.styles.d.ts.map +1 -1
- package/lib/components/data-display/badge/badge.styles.js +56 -35
- package/lib/components/data-display/badge/badge.types.d.ts +2 -0
- package/lib/components/data-display/badge/badge.types.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts +10 -0
- package/lib/components/data-display/calendar-view/calendar-view.utils.d.ts.map +1 -1
- package/lib/components/data-display/calendar-view/calendar-view.utils.js +59 -27
- package/lib/components/data-display/data-grid/data-grid.component.d.ts +6 -5
- package/lib/components/data-display/data-grid/data-grid.component.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.component.js +49 -110
- package/lib/components/data-display/data-grid/data-grid.template.d.ts.map +1 -1
- package/lib/components/data-display/data-grid/data-grid.template.js +2 -6
- package/lib/components/data-display/list/list-item.component.d.ts +15 -6
- package/lib/components/data-display/list/list-item.component.d.ts.map +1 -1
- package/lib/components/data-display/list/list-item.component.js +57 -6
- package/lib/components/data-display/list/list-item.styles.d.ts.map +1 -1
- package/lib/components/data-display/list/list-item.styles.js +5 -0
- package/lib/components/data-display/list/list-item.template.d.ts.map +1 -1
- package/lib/components/data-display/list/list-item.template.js +18 -12
- package/lib/components/data-display/profile-card/profile-card.component.d.ts +2 -2
- package/lib/components/data-display/profile-card/profile-card.component.d.ts.map +1 -1
- package/lib/components/data-display/profile-card/profile-card.component.js +17 -15
- package/lib/components/data-display/profile-card/profile-card.template.js +1 -1
- package/lib/components/data-display/stat-card/stat-card.component.d.ts +6 -6
- package/lib/components/data-display/stat-card/stat-card.component.d.ts.map +1 -1
- package/lib/components/data-display/stat-card/stat-card.component.js +14 -6
- package/lib/components/data-display/stat-card/stat-card.template.js +4 -4
- package/lib/components/data-display/table/table.component.d.ts +7 -5
- package/lib/components/data-display/table/table.component.d.ts.map +1 -1
- package/lib/components/data-display/table/table.component.js +40 -117
- package/lib/components/data-display/table/table.template.d.ts.map +1 -1
- package/lib/components/data-display/table/table.template.js +1 -6
- package/lib/components/data-display/table-core/index.d.ts +3 -0
- package/lib/components/data-display/table-core/index.d.ts.map +1 -0
- package/lib/components/data-display/table-core/index.js +2 -0
- package/lib/components/data-display/table-core/table-core.d.ts +137 -0
- package/lib/components/data-display/table-core/table-core.d.ts.map +1 -0
- package/lib/components/data-display/table-core/table-core.js +225 -0
- package/lib/components/data-display/tag/tag.component.d.ts +14 -7
- package/lib/components/data-display/tag/tag.component.d.ts.map +1 -1
- package/lib/components/data-display/tag/tag.component.js +29 -5
- package/lib/components/data-display/tag/tag.template.js +2 -2
- package/lib/components/data-display/tag/tag.types.d.ts +8 -1
- package/lib/components/data-display/tag/tag.types.d.ts.map +1 -1
- package/lib/components/feedback/alert/alert.component.d.ts +6 -3
- package/lib/components/feedback/alert/alert.component.d.ts.map +1 -1
- package/lib/components/feedback/alert/alert.component.js +13 -4
- package/lib/components/feedback/alert/alert.template.js +1 -1
- package/lib/components/feedback/progress/progress.component.d.ts +4 -0
- package/lib/components/feedback/progress/progress.component.d.ts.map +1 -1
- package/lib/components/feedback/progress/progress.component.js +9 -0
- package/lib/components/feedback/progress/progress.template.d.ts.map +1 -1
- package/lib/components/feedback/progress/progress.template.js +19 -5
- package/lib/components/feedback/toast/toast.component.d.ts +6 -3
- package/lib/components/feedback/toast/toast.component.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.component.js +13 -4
- package/lib/components/feedback/toast/toast.service.d.ts.map +1 -1
- package/lib/components/feedback/toast/toast.service.js +2 -1
- package/lib/components/feedback/toast/toast.template.js +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts +12 -4
- package/lib/components/forms/autocomplete/autocomplete.component.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.component.js +39 -30
- package/lib/components/forms/autocomplete/autocomplete.template.d.ts.map +1 -1
- package/lib/components/forms/autocomplete/autocomplete.template.js +14 -0
- package/lib/components/forms/button/button.component.d.ts +28 -3
- package/lib/components/forms/button/button.component.d.ts.map +1 -1
- package/lib/components/forms/button/button.component.js +81 -6
- package/lib/components/forms/button/button.template.js +1 -1
- package/lib/components/forms/button/button.types.d.ts +8 -1
- package/lib/components/forms/button/button.types.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group-item.component.d.ts +2 -2
- package/lib/components/forms/button-group/button-group-item.component.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.component.d.ts +4 -2
- package/lib/components/forms/button-group/button-group.component.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.component.js +3 -1
- package/lib/components/forms/button-group/button-group.styles.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.styles.js +15 -1
- package/lib/components/forms/button-group/button-group.template.d.ts.map +1 -1
- package/lib/components/forms/button-group/button-group.template.js +4 -2
- package/lib/components/forms/checkbox/checkbox.component.d.ts +4 -2
- package/lib/components/forms/checkbox/checkbox.component.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.component.js +3 -1
- package/lib/components/forms/checkbox/checkbox.styles.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.styles.js +19 -0
- package/lib/components/forms/checkbox/checkbox.template.d.ts.map +1 -1
- package/lib/components/forms/checkbox/checkbox.template.js +4 -2
- package/lib/components/forms/date-picker/calendar.component.js +1 -1
- package/lib/components/forms/date-picker/date-picker.component.d.ts +11 -4
- package/lib/components/forms/date-picker/date-picker.component.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.component.js +99 -32
- package/lib/components/forms/date-picker/date-picker.styles.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.styles.js +0 -10
- package/lib/components/forms/date-picker/date-picker.template.d.ts.map +1 -1
- package/lib/components/forms/date-picker/date-picker.template.js +3 -4
- package/lib/components/forms/file-upload/file-upload-item.component.d.ts +7 -0
- package/lib/components/forms/file-upload/file-upload-item.component.d.ts.map +1 -1
- package/lib/components/forms/file-upload/file-upload-item.component.js +15 -0
- package/lib/components/forms/file-upload/file-upload.component.d.ts +15 -0
- package/lib/components/forms/file-upload/file-upload.component.d.ts.map +1 -1
- package/lib/components/forms/file-upload/file-upload.component.js +56 -0
- package/lib/components/forms/form-field/form-field.component.d.ts +12 -4
- package/lib/components/forms/form-field/form-field.component.d.ts.map +1 -1
- package/lib/components/forms/form-field/form-field.component.js +50 -31
- package/lib/components/forms/form-field/form-field.template.js +1 -1
- package/lib/components/forms/input/input.component.d.ts +2 -2
- package/lib/components/forms/input/input.component.d.ts.map +1 -1
- package/lib/components/forms/radio/radio-group.component.d.ts +6 -0
- package/lib/components/forms/radio/radio-group.component.d.ts.map +1 -1
- package/lib/components/forms/radio/radio-group.component.js +69 -2
- package/lib/components/forms/radio/radio-group.template.js +1 -1
- package/lib/components/forms/radio/radio.component.d.ts +7 -2
- package/lib/components/forms/radio/radio.component.d.ts.map +1 -1
- package/lib/components/forms/radio/radio.component.js +5 -0
- package/lib/components/forms/radio/radio.template.d.ts.map +1 -1
- package/lib/components/forms/radio/radio.template.js +1 -0
- package/lib/components/forms/select/select.component.d.ts +13 -6
- package/lib/components/forms/select/select.component.d.ts.map +1 -1
- package/lib/components/forms/select/select.component.js +32 -36
- package/lib/components/forms/select/select.template.d.ts.map +1 -1
- package/lib/components/forms/select/select.template.js +6 -2
- package/lib/components/forms/slider/slider.component.d.ts +2 -2
- package/lib/components/forms/slider/slider.component.d.ts.map +1 -1
- package/lib/components/forms/slider/slider.component.js +5 -1
- package/lib/components/forms/textarea/textarea.component.d.ts +2 -2
- package/lib/components/forms/textarea/textarea.component.d.ts.map +1 -1
- package/lib/components/forms/toggle/toggle.component.d.ts +4 -2
- package/lib/components/forms/toggle/toggle.component.d.ts.map +1 -1
- package/lib/components/forms/toggle/toggle.component.js +3 -1
- package/lib/components/forms/toggle/toggle.styles.d.ts.map +1 -1
- package/lib/components/forms/toggle/toggle.styles.js +19 -0
- package/lib/components/forms/toggle/toggle.template.d.ts.map +1 -1
- package/lib/components/forms/toggle/toggle.template.js +11 -3
- package/lib/components/foundation/card/card.component.d.ts +7 -6
- package/lib/components/foundation/card/card.component.d.ts.map +1 -1
- package/lib/components/foundation/card/card.component.js +18 -7
- package/lib/components/foundation/card/card.styles.d.ts.map +1 -1
- package/lib/components/foundation/card/card.styles.js +5 -0
- package/lib/components/foundation/card/card.template.d.ts.map +1 -1
- package/lib/components/foundation/card/card.template.js +16 -11
- package/lib/components/foundation/divider/divider.component.d.ts +5 -4
- package/lib/components/foundation/divider/divider.component.d.ts.map +1 -1
- package/lib/components/foundation/divider/divider.component.js +11 -3
- package/lib/components/foundation/divider/divider.styles.d.ts.map +1 -1
- package/lib/components/foundation/divider/divider.styles.js +6 -0
- package/lib/components/foundation/divider/divider.template.d.ts +5 -0
- package/lib/components/foundation/divider/divider.template.d.ts.map +1 -1
- package/lib/components/foundation/divider/divider.template.js +9 -6
- package/lib/components/general/icon/icon.template.d.ts.map +1 -1
- package/lib/components/general/icon/icon.template.js +3 -1
- package/lib/components/navigation/pagination/pagination.component.d.ts +5 -0
- package/lib/components/navigation/pagination/pagination.component.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.component.js +22 -10
- package/lib/components/navigation/pagination/pagination.styles.d.ts.map +1 -1
- package/lib/components/navigation/pagination/pagination.styles.js +6 -4
- package/lib/components/navigation/sidebar/sidebar-item.component.d.ts +4 -4
- package/lib/components/navigation/sidebar/sidebar-item.component.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar-item.component.js +11 -4
- package/lib/components/navigation/sidebar/sidebar-item.template.js +2 -2
- package/lib/components/navigation/sidebar/sidebar.component.d.ts +7 -0
- package/lib/components/navigation/sidebar/sidebar.component.d.ts.map +1 -1
- package/lib/components/navigation/sidebar/sidebar.component.js +48 -5
- package/lib/components/navigation/steps/step-panel.component.d.ts +7 -0
- package/lib/components/navigation/steps/step-panel.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/step-panel.component.js +7 -0
- package/lib/components/navigation/steps/step-panel.template.d.ts +1 -1
- package/lib/components/navigation/steps/step-panel.template.d.ts.map +1 -1
- package/lib/components/navigation/steps/step-panel.template.js +2 -2
- package/lib/components/navigation/steps/step.component.d.ts +2 -2
- package/lib/components/navigation/steps/step.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/step.component.js +8 -2
- package/lib/components/navigation/steps/step.template.js +1 -1
- package/lib/components/navigation/steps/steps.component.d.ts +3 -1
- package/lib/components/navigation/steps/steps.component.d.ts.map +1 -1
- package/lib/components/navigation/steps/steps.component.js +47 -14
- package/lib/components/navigation/steps/steps.template.d.ts.map +1 -1
- package/lib/components/navigation/steps/steps.template.js +5 -1
- package/lib/components/navigation/tabs/tab-panel.component.d.ts +7 -0
- package/lib/components/navigation/tabs/tab-panel.component.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tab-panel.component.js +7 -0
- package/lib/components/navigation/tabs/tab-panel.template.d.ts +1 -1
- package/lib/components/navigation/tabs/tab-panel.template.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tab-panel.template.js +2 -2
- package/lib/components/navigation/tabs/tabs.component.d.ts +5 -3
- package/lib/components/navigation/tabs/tabs.component.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tabs.component.js +49 -14
- package/lib/components/navigation/tabs/tabs.template.d.ts.map +1 -1
- package/lib/components/navigation/tabs/tabs.template.js +6 -1
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts +17 -2
- package/lib/components/overlays/dialog/dialog-ref.class.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog-ref.class.js +52 -6
- package/lib/components/overlays/dialog/dialog.component.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog.component.js +5 -1
- package/lib/components/overlays/dialog/dialog.service.d.ts +2 -2
- package/lib/components/overlays/dialog/dialog.service.d.ts.map +1 -1
- package/lib/components/overlays/dialog/dialog.service.js +46 -18
- package/lib/components/overlays/drawer/drawer.component.d.ts +9 -2
- package/lib/components/overlays/drawer/drawer.component.d.ts.map +1 -1
- package/lib/components/overlays/drawer/drawer.component.js +34 -4
- package/lib/components/overlays/drawer/drawer.styles.d.ts.map +1 -1
- package/lib/components/overlays/drawer/drawer.styles.js +4 -0
- package/lib/components/overlays/dropdown/dropdown-item.component.d.ts +5 -2
- package/lib/components/overlays/dropdown/dropdown-item.component.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown-item.component.js +18 -0
- package/lib/components/overlays/dropdown/dropdown-item.template.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown-item.template.js +0 -3
- package/lib/components/overlays/dropdown/dropdown.component.d.ts +8 -4
- package/lib/components/overlays/dropdown/dropdown.component.d.ts.map +1 -1
- package/lib/components/overlays/dropdown/dropdown.component.js +61 -60
- package/lib/components/overlays/popover/popover.component.d.ts +6 -4
- package/lib/components/overlays/popover/popover.component.d.ts.map +1 -1
- package/lib/components/overlays/popover/popover.component.js +37 -51
- package/lib/components/overlays/tooltip/tooltip.component.d.ts +29 -4
- package/lib/components/overlays/tooltip/tooltip.component.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.component.js +73 -31
- package/lib/components/overlays/tooltip/tooltip.styles.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.styles.js +22 -10
- package/lib/components/overlays/tooltip/tooltip.template.d.ts.map +1 -1
- package/lib/components/overlays/tooltip/tooltip.template.js +3 -2
- package/lib/components/pages/auth/login-page.component.d.ts +11 -4
- package/lib/components/pages/auth/login-page.component.d.ts.map +1 -1
- package/lib/components/pages/auth/login-page.component.js +18 -5
- package/lib/components/pages/auth/login-page.template.d.ts.map +1 -1
- package/lib/components/pages/auth/login-page.template.js +9 -10
- package/lib/components/pages/auth/signup-page.component.d.ts +11 -4
- package/lib/components/pages/auth/signup-page.component.d.ts.map +1 -1
- package/lib/components/pages/auth/signup-page.component.js +18 -5
- package/lib/components/pages/auth/signup-page.template.d.ts.map +1 -1
- package/lib/components/pages/auth/signup-page.template.js +9 -10
- package/lib/components/pages/dashboard/dashboard-page.component.d.ts +18 -11
- package/lib/components/pages/dashboard/dashboard-page.component.d.ts.map +1 -1
- package/lib/components/pages/dashboard/dashboard-page.component.js +55 -13
- package/lib/components/pages/dashboard/dashboard-page.template.js +1 -1
- package/lib/components/sections/app-shell/app-shell.component.d.ts +6 -6
- package/lib/components/sections/app-shell/app-shell.component.d.ts.map +1 -1
- package/lib/components/sections/app-shell/app-shell.component.js +14 -6
- package/lib/components/sections/app-shell/app-shell.template.js +3 -3
- package/lib/components/sections/hero/hero-section.component.d.ts +6 -3
- package/lib/components/sections/hero/hero-section.component.d.ts.map +1 -1
- package/lib/components/sections/hero/hero-section.component.js +13 -4
- package/lib/components/sections/hero/hero-section.template.js +2 -2
- package/lib/components/sections/page-header/page-header.component.d.ts +16 -17
- package/lib/components/sections/page-header/page-header.component.d.ts.map +1 -1
- package/lib/components/sections/page-header/page-header.component.js +36 -25
- package/lib/components/sections/page-header/page-header.styles.d.ts.map +1 -1
- package/lib/components/sections/page-header/page-header.styles.js +9 -0
- package/lib/components/sections/page-header/page-header.template.d.ts +5 -0
- package/lib/components/sections/page-header/page-header.template.d.ts.map +1 -1
- package/lib/components/sections/page-header/page-header.template.js +42 -31
- package/lib/components/sections/page-section/page-section.component.d.ts +16 -12
- package/lib/components/sections/page-section/page-section.component.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.component.js +34 -12
- package/lib/components/sections/page-section/page-section.styles.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.styles.js +6 -0
- package/lib/components/sections/page-section/page-section.template.d.ts +6 -0
- package/lib/components/sections/page-section/page-section.template.d.ts.map +1 -1
- package/lib/components/sections/page-section/page-section.template.js +26 -15
- package/lib/components/sections/page-section/sanitize-href.function.d.ts +12 -0
- package/lib/components/sections/page-section/sanitize-href.function.d.ts.map +1 -0
- package/lib/components/sections/page-section/sanitize-href.function.js +15 -0
- package/lib/directives/tooltip.directive.d.ts +8 -2
- package/lib/directives/tooltip.directive.d.ts.map +1 -1
- package/lib/directives/tooltip.directive.js +103 -9
- package/lib/functions/deprecation.functions.d.ts +21 -0
- package/lib/functions/deprecation.functions.d.ts.map +1 -0
- package/lib/functions/deprecation.functions.js +44 -0
- package/lib/functions/index.d.ts +2 -0
- package/lib/functions/index.d.ts.map +1 -1
- package/lib/functions/index.js +2 -0
- package/lib/functions/watch-slot-presence.function.d.ts +17 -0
- package/lib/functions/watch-slot-presence.function.d.ts.map +1 -0
- package/lib/functions/watch-slot-presence.function.js +27 -0
- package/lib/theme/functions/create-theme.function.d.ts +15 -1
- package/lib/theme/functions/create-theme.function.d.ts.map +1 -1
- package/lib/theme/functions/create-theme.function.js +57 -11
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.d.ts.map +1 -1
- package/lib/types/index.d.ts +8 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/utils/accessibility/focus-trap.d.ts +19 -1
- package/lib/utils/accessibility/focus-trap.d.ts.map +1 -1
- package/lib/utils/accessibility/focus-trap.js +77 -8
- package/lib/utils/accessibility/index.d.ts +2 -1
- package/lib/utils/accessibility/index.d.ts.map +1 -1
- package/lib/utils/accessibility/index.js +1 -1
- package/lib/utils/accessibility/live-region.d.ts +10 -3
- package/lib/utils/accessibility/live-region.d.ts.map +1 -1
- package/lib/utils/accessibility/live-region.js +64 -35
- package/lib/utils/directives/click-outside.directive.d.ts.map +1 -1
- package/lib/utils/directives/click-outside.directive.js +5 -3
- package/lib/utils/overlay/index.d.ts +4 -0
- package/lib/utils/overlay/index.d.ts.map +1 -0
- package/lib/utils/overlay/index.js +2 -0
- package/lib/utils/overlay/overlay-positioner.d.ts +54 -0
- package/lib/utils/overlay/overlay-positioner.d.ts.map +1 -0
- package/lib/utils/overlay/overlay-positioner.js +85 -0
- package/lib/utils/overlay/toggle-dismiss-guard.d.ts +24 -0
- package/lib/utils/overlay/toggle-dismiss-guard.d.ts.map +1 -0
- package/lib/utils/overlay/toggle-dismiss-guard.js +36 -0
- package/lib/utils/positioning/auto-update.d.ts.map +1 -1
- package/lib/utils/positioning/auto-update.js +3 -0
- package/lib/utils/positioning/compute-position.d.ts.map +1 -1
- package/lib/utils/positioning/compute-position.js +8 -4
- package/lib/utils/positioning/middlewares/flip.middleware.d.ts.map +1 -1
- package/lib/utils/positioning/middlewares/flip.middleware.js +10 -3
- package/lib/utils/positioning/middlewares/offset.middleware.d.ts +15 -0
- package/lib/utils/positioning/middlewares/offset.middleware.d.ts.map +1 -1
- package/lib/utils/positioning/middlewares/offset.middleware.js +31 -1
- package/lib/utils/positioning/middlewares/shift.middleware.d.ts +13 -3
- package/lib/utils/positioning/middlewares/shift.middleware.d.ts.map +1 -1
- package/lib/utils/positioning/middlewares/shift.middleware.js +15 -7
- package/package.json +6 -2
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import type { AttributeDirectiveCleanupFunction } from '@melodicdev/core/template';
|
|
2
|
+
import '../components/overlays/tooltip/index.js';
|
|
2
3
|
/**
|
|
3
|
-
* Tooltip attribute directive -
|
|
4
|
+
* Tooltip attribute directive - attaches an ml-tooltip to an element
|
|
4
5
|
*
|
|
5
6
|
* Usage:
|
|
6
7
|
* ```html
|
|
7
8
|
* <!-- Static content -->
|
|
8
9
|
* <div :tooltip="Helpful tip">Hover me</div>
|
|
9
10
|
*
|
|
10
|
-
* <!-- Dynamic content -->
|
|
11
|
+
* <!-- Dynamic content (updates propagate on re-render) -->
|
|
11
12
|
* <ml-button :tooltip=${this.helpText}>Help</ml-button>
|
|
12
13
|
*
|
|
13
14
|
* <!-- With placement (defaults to "top") -->
|
|
14
15
|
* <span :tooltip=${{ content: 'Info', placement: 'bottom' }}>Info</span>
|
|
15
16
|
* ```
|
|
17
|
+
*
|
|
18
|
+
* The element is never reparented: a slotless ml-tooltip is managed as a
|
|
19
|
+
* sibling overlay whose popup is anchored to the element (via the tooltip's
|
|
20
|
+
* `anchorEl` override), and shows/hides on the same triggers ml-tooltip uses
|
|
21
|
+
* (hover, focusin/focusout, Escape-to-dismiss).
|
|
16
22
|
*/
|
|
17
23
|
export interface TooltipDirectiveOptions {
|
|
18
24
|
content: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.directive.d.ts","sourceRoot":"","sources":["../../src/directives/tooltip.directive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAEnF
|
|
1
|
+
{"version":3,"file":"tooltip.directive.d.ts","sourceRoot":"","sources":["../../src/directives/tooltip.directive.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,2BAA2B,CAAC;AAEnF,OAAO,yCAAyC,CAAC;AAGjD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,uBAAuB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA4GD,iBAAS,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,iCAAiC,GAAG,IAAI,CA0CpG;AAID,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { registerAttributeDirective } from '@melodicdev/core/template';
|
|
2
|
+
// Registers the <ml-tooltip> custom element the directive instantiates.
|
|
3
|
+
import '../components/overlays/tooltip/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Live tooltip state per decorated element. The template engine always runs
|
|
6
|
+
* the previous cleanup before re-running a directive with a new value; the
|
|
7
|
+
* map lets that re-run adopt the existing ml-tooltip (updating its content
|
|
8
|
+
* in place) instead of destroying and recreating it.
|
|
9
|
+
*/
|
|
10
|
+
const tooltipStates = new WeakMap();
|
|
2
11
|
function parseValue(value) {
|
|
3
12
|
if (typeof value === 'string') {
|
|
4
13
|
return { content: value };
|
|
@@ -8,23 +17,108 @@ function parseValue(value) {
|
|
|
8
17
|
}
|
|
9
18
|
return { content: String(value ?? '') };
|
|
10
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Insert the tooltip as the element's next sibling so its popup inherits the
|
|
22
|
+
* element's theme context. Safe when the element has no parent yet — in that
|
|
23
|
+
* case insertion is retried on the first show trigger (by which point the
|
|
24
|
+
* element is in the DOM and can receive events).
|
|
25
|
+
*/
|
|
26
|
+
function ensureInserted(element, tooltip) {
|
|
27
|
+
if (tooltip.isConnected || !element.parentNode)
|
|
28
|
+
return;
|
|
29
|
+
element.parentNode.insertBefore(tooltip, element.nextSibling);
|
|
30
|
+
}
|
|
31
|
+
function createState(element) {
|
|
32
|
+
const tooltip = document.createElement('ml-tooltip');
|
|
33
|
+
// The tooltip host holds no slotted trigger (the popup content is
|
|
34
|
+
// position: fixed) — take it out of the layout flow so the extra sibling
|
|
35
|
+
// never affects flex/grid/gap layouts around the element.
|
|
36
|
+
tooltip.style.position = 'absolute';
|
|
37
|
+
tooltip.style.width = '0';
|
|
38
|
+
tooltip.style.height = '0';
|
|
39
|
+
tooltip.style.overflow = 'visible';
|
|
40
|
+
// Anchor the popup to the decorated element instead of the empty slot.
|
|
41
|
+
tooltip.anchorEl = element;
|
|
42
|
+
const component = tooltip.component;
|
|
43
|
+
const show = () => {
|
|
44
|
+
ensureInserted(element, tooltip);
|
|
45
|
+
component?.show();
|
|
46
|
+
};
|
|
47
|
+
const hide = () => {
|
|
48
|
+
component?.hide();
|
|
49
|
+
};
|
|
50
|
+
// Same triggers ml-tooltip binds on its trigger wrapper. Escape-to-dismiss
|
|
51
|
+
// is handled by the tooltip component itself while visible.
|
|
52
|
+
element.addEventListener('mouseenter', show);
|
|
53
|
+
element.addEventListener('mouseleave', hide);
|
|
54
|
+
element.addEventListener('focusin', show);
|
|
55
|
+
element.addEventListener('focusout', hide);
|
|
56
|
+
const state = { tooltip, pendingRemoval: false, ownsDescribedBy: false, show, hide };
|
|
57
|
+
// Mirror ml-tooltip's slotted-trigger ARIA wiring: point the element's
|
|
58
|
+
// aria-describedby at the tooltip content unless it already has one.
|
|
59
|
+
const contentID = component?.tooltipID;
|
|
60
|
+
if (contentID && !element.hasAttribute('aria-describedby')) {
|
|
61
|
+
element.setAttribute('aria-describedby', contentID);
|
|
62
|
+
state.ownsDescribedBy = true;
|
|
63
|
+
}
|
|
64
|
+
return state;
|
|
65
|
+
}
|
|
66
|
+
function destroyState(element, state) {
|
|
67
|
+
element.removeEventListener('mouseenter', state.show);
|
|
68
|
+
element.removeEventListener('mouseleave', state.hide);
|
|
69
|
+
element.removeEventListener('focusin', state.show);
|
|
70
|
+
element.removeEventListener('focusout', state.hide);
|
|
71
|
+
if (state.ownsDescribedBy) {
|
|
72
|
+
element.removeAttribute('aria-describedby');
|
|
73
|
+
}
|
|
74
|
+
state.tooltip.anchorEl = null;
|
|
75
|
+
// Disconnecting runs the tooltip component's onDestroy (timers, autoUpdate,
|
|
76
|
+
// document listeners).
|
|
77
|
+
state.tooltip.remove();
|
|
78
|
+
if (tooltipStates.get(element) === state) {
|
|
79
|
+
tooltipStates.delete(element);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
11
82
|
function tooltipDirective(element, value) {
|
|
12
83
|
if (!value)
|
|
13
84
|
return;
|
|
14
85
|
const { content, placement } = parseValue(value);
|
|
15
86
|
if (!content)
|
|
16
87
|
return;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
88
|
+
let state = tooltipStates.get(element);
|
|
89
|
+
if (state) {
|
|
90
|
+
// Value changed on re-render: adopt the live tooltip (cancels the
|
|
91
|
+
// deferred removal scheduled by the previous cleanup) and update it.
|
|
92
|
+
state.pendingRemoval = false;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
state = createState(element);
|
|
96
|
+
tooltipStates.set(element, state);
|
|
97
|
+
}
|
|
98
|
+
// Diff before writing: an object-form value (`{content, placement}`) is a
|
|
99
|
+
// fresh reference every render, so the engine re-runs this directive even
|
|
100
|
+
// when nothing changed — an unconditional setAttribute would fire the
|
|
101
|
+
// tooltip's attributeChangedCallback each time.
|
|
102
|
+
if (state.tooltip.getAttribute('content') !== content) {
|
|
103
|
+
state.tooltip.setAttribute('content', content);
|
|
104
|
+
}
|
|
105
|
+
const resolvedPlacement = placement ?? 'top';
|
|
106
|
+
if (state.tooltip.getAttribute('placement') !== resolvedPlacement) {
|
|
107
|
+
state.tooltip.setAttribute('placement', resolvedPlacement);
|
|
22
108
|
}
|
|
23
|
-
element.
|
|
24
|
-
|
|
109
|
+
ensureInserted(element, state.tooltip);
|
|
110
|
+
const currentState = state;
|
|
25
111
|
return () => {
|
|
26
|
-
|
|
27
|
-
|
|
112
|
+
// The engine runs cleanup both when the value changes (the directive
|
|
113
|
+
// re-runs synchronously right after) and when the part is disposed
|
|
114
|
+
// (removal via when/repeat, host teardown). Defer teardown a microtask
|
|
115
|
+
// so a same-tick re-run can adopt the tooltip instead of recreating it.
|
|
116
|
+
currentState.pendingRemoval = true;
|
|
117
|
+
queueMicrotask(() => {
|
|
118
|
+
if (currentState.pendingRemoval) {
|
|
119
|
+
destroyState(element, currentState);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
28
122
|
};
|
|
29
123
|
}
|
|
30
124
|
registerAttributeDirective('tooltip', tooltipDirective);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Log a deprecation warning once per key for the page's lifetime. */
|
|
2
|
+
export declare function warnDeprecatedOnce(key: string, message: string): void;
|
|
3
|
+
/**
|
|
4
|
+
* Deprecation warning for the `title` shim several components carry: `title`
|
|
5
|
+
* collides with the global HTML title attribute (native tooltip), so each
|
|
6
|
+
* component exposes a prefixed replacement (`alert-title`, `page-title`, ...).
|
|
7
|
+
*/
|
|
8
|
+
export declare function warnDeprecatedTitleOnce(tag: string, replacement: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Define deprecated quoted kebab-case property aliases (`el['dot-color']`)
|
|
11
|
+
* that forward to their camelCase properties, warning once per alias on
|
|
12
|
+
* first use. Kebab-case ATTRIBUTES already reach the camelCase property via
|
|
13
|
+
* attributeChangedCallback — these aliases only serve legacy JS property
|
|
14
|
+
* access and will be removed in the next major release.
|
|
15
|
+
*
|
|
16
|
+
* Call at module scope, right after the class definition:
|
|
17
|
+
*
|
|
18
|
+
* defineLegacyAliases(TagComponent.prototype, 'ml-tag', { 'dot-color': 'dotColor' });
|
|
19
|
+
*/
|
|
20
|
+
export declare function defineLegacyAliases<T extends object>(proto: T, tag: string, aliases: Record<string, keyof T & string>): void;
|
|
21
|
+
//# sourceMappingURL=deprecation.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deprecation.functions.d.ts","sourceRoot":"","sources":["../../src/functions/deprecation.functions.ts"],"names":[],"mappings":"AAEA,sEAAsE;AACtE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAK9E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,CAmB5H"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const warned = new Set();
|
|
2
|
+
/** Log a deprecation warning once per key for the page's lifetime. */
|
|
3
|
+
export function warnDeprecatedOnce(key, message) {
|
|
4
|
+
if (warned.has(key))
|
|
5
|
+
return;
|
|
6
|
+
warned.add(key);
|
|
7
|
+
console.warn(message);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Deprecation warning for the `title` shim several components carry: `title`
|
|
11
|
+
* collides with the global HTML title attribute (native tooltip), so each
|
|
12
|
+
* component exposes a prefixed replacement (`alert-title`, `page-title`, ...).
|
|
13
|
+
*/
|
|
14
|
+
export function warnDeprecatedTitleOnce(tag, replacement) {
|
|
15
|
+
warnDeprecatedOnce(`${tag}.title`, `[${tag}] The "title" attribute/property is deprecated because it collides with the global HTML title attribute (native tooltip). Use "${replacement}" instead. The "title" shim will be removed in the next major release.`);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Define deprecated quoted kebab-case property aliases (`el['dot-color']`)
|
|
19
|
+
* that forward to their camelCase properties, warning once per alias on
|
|
20
|
+
* first use. Kebab-case ATTRIBUTES already reach the camelCase property via
|
|
21
|
+
* attributeChangedCallback — these aliases only serve legacy JS property
|
|
22
|
+
* access and will be removed in the next major release.
|
|
23
|
+
*
|
|
24
|
+
* Call at module scope, right after the class definition:
|
|
25
|
+
*
|
|
26
|
+
* defineLegacyAliases(TagComponent.prototype, 'ml-tag', { 'dot-color': 'dotColor' });
|
|
27
|
+
*/
|
|
28
|
+
export function defineLegacyAliases(proto, tag, aliases) {
|
|
29
|
+
for (const [alias, prop] of Object.entries(aliases)) {
|
|
30
|
+
Object.defineProperty(proto, alias, {
|
|
31
|
+
// The getter is deliberately silent: property observation reads every
|
|
32
|
+
// property once at construction, which must not trigger the warning.
|
|
33
|
+
get() {
|
|
34
|
+
return this[prop];
|
|
35
|
+
},
|
|
36
|
+
set(value) {
|
|
37
|
+
warnDeprecatedOnce(`${tag}.${alias}`, `[${tag}] The quoted "${alias}" property is deprecated — use the camelCase property "${prop}" (attribute "${alias}"). The alias will be removed in the next major release.`);
|
|
38
|
+
this[prop] = value;
|
|
39
|
+
},
|
|
40
|
+
enumerable: false,
|
|
41
|
+
configurable: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
package/lib/functions/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC"}
|
package/lib/functions/index.js
CHANGED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watches every `<slot>` currently in a shadow root and reports whether each
|
|
3
|
+
* has slotted content — immediately, and again on every `slotchange` — so
|
|
4
|
+
* content added or removed after mount projects correctly instead of being
|
|
5
|
+
* frozen at first render.
|
|
6
|
+
*
|
|
7
|
+
* Whitespace-only text nodes do not count as content. This matters for
|
|
8
|
+
* default slots (`<my-el> </my-el>` has no label); named slots only ever
|
|
9
|
+
* receive elements, so they are unaffected.
|
|
10
|
+
*
|
|
11
|
+
* The callback receives the slot's name (`''` for the default slot) and its
|
|
12
|
+
* presence. Slots rendered conditionally (not in the shadow root when this is
|
|
13
|
+
* called) are not watched — components with conditional slots need a light
|
|
14
|
+
* DOM MutationObserver instead (see ml-dashboard-page).
|
|
15
|
+
*/
|
|
16
|
+
export declare function watchSlotPresence(shadow: ShadowRoot, onChange: (slotName: string, hasContent: boolean) => void): void;
|
|
17
|
+
//# sourceMappingURL=watch-slot-presence.function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watch-slot-presence.function.d.ts","sourceRoot":"","sources":["../../src/functions/watch-slot-presence.function.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI,CAWrH"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watches every `<slot>` currently in a shadow root and reports whether each
|
|
3
|
+
* has slotted content — immediately, and again on every `slotchange` — so
|
|
4
|
+
* content added or removed after mount projects correctly instead of being
|
|
5
|
+
* frozen at first render.
|
|
6
|
+
*
|
|
7
|
+
* Whitespace-only text nodes do not count as content. This matters for
|
|
8
|
+
* default slots (`<my-el> </my-el>` has no label); named slots only ever
|
|
9
|
+
* receive elements, so they are unaffected.
|
|
10
|
+
*
|
|
11
|
+
* The callback receives the slot's name (`''` for the default slot) and its
|
|
12
|
+
* presence. Slots rendered conditionally (not in the shadow root when this is
|
|
13
|
+
* called) are not watched — components with conditional slots need a light
|
|
14
|
+
* DOM MutationObserver instead (see ml-dashboard-page).
|
|
15
|
+
*/
|
|
16
|
+
export function watchSlotPresence(shadow, onChange) {
|
|
17
|
+
shadow.querySelectorAll('slot').forEach((slot) => {
|
|
18
|
+
const update = () => {
|
|
19
|
+
const hasContent = slot
|
|
20
|
+
.assignedNodes()
|
|
21
|
+
.some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? '').trim() !== '');
|
|
22
|
+
onChange(slot.name, hasContent);
|
|
23
|
+
};
|
|
24
|
+
slot.addEventListener('slotchange', update);
|
|
25
|
+
update();
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
type TokenOverrides = Partial<Record<string, string>>;
|
|
2
2
|
/**
|
|
3
|
-
* Create a custom theme by overriding default tokens
|
|
3
|
+
* Create a custom theme by overriding default tokens.
|
|
4
|
+
*
|
|
5
|
+
* The theme name and every override are validated before being interpolated
|
|
6
|
+
* into CSS: names must match `^[a-z0-9-]+$`, keys must be CSS custom
|
|
7
|
+
* properties, and values must not contain characters that could break out of
|
|
8
|
+
* the declaration block. Invalid input throws.
|
|
9
|
+
*
|
|
4
10
|
* @param name - Theme name (used in data-theme attribute)
|
|
5
11
|
* @param overrides - Token values to override
|
|
6
12
|
* @returns CSS string to inject into document
|
|
@@ -13,10 +19,16 @@ export declare function createTheme(name: string, overrides: TokenOverrides): st
|
|
|
13
19
|
* @returns Style element that was injected (can be removed to unload theme)
|
|
14
20
|
*/
|
|
15
21
|
export declare function injectTheme(name: string, overrides: TokenOverrides): HTMLStyleElement;
|
|
22
|
+
/** Color mode a brand theme is generated for. */
|
|
23
|
+
export type BrandThemeMode = 'light' | 'dark';
|
|
16
24
|
/**
|
|
17
25
|
* Create a brand theme from semantic colors. Each color also generates matching
|
|
18
26
|
* hover/active/subtle variants so interaction states aren't left at the default
|
|
19
27
|
* (e.g. a purple primary no longer hovers blue).
|
|
28
|
+
*
|
|
29
|
+
* Pass `mode: 'dark'` to generate variants suited to dark surfaces
|
|
30
|
+
* (hover/active lighten instead of darken; -subtle mixes toward black instead
|
|
31
|
+
* of white). Defaults to `'light'` for backwards compatibility.
|
|
20
32
|
*/
|
|
21
33
|
export declare function createBrandTheme(name: string, options: {
|
|
22
34
|
primary?: string;
|
|
@@ -24,6 +36,8 @@ export declare function createBrandTheme(name: string, options: {
|
|
|
24
36
|
success?: string;
|
|
25
37
|
warning?: string;
|
|
26
38
|
danger?: string;
|
|
39
|
+
/** Color mode the variants are generated for (default: 'light') */
|
|
40
|
+
mode?: BrandThemeMode;
|
|
27
41
|
}): string;
|
|
28
42
|
export {};
|
|
29
43
|
//# sourceMappingURL=create-theme.function.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-theme.function.d.ts","sourceRoot":"","sources":["../../../src/theme/functions/create-theme.function.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-theme.function.d.ts","sourceRoot":"","sources":["../../../src/theme/functions/create-theme.function.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAsCtD;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,MAAM,CAY3E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,GAAG,gBAAgB,CAkBrF;AAED,iDAAiD;AACjD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,MAAM,CAAC;AAqB9C;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,IAAI,CAAC,EAAE,cAAc,CAAC;CACtB,GACC,MAAM,CAqBR"}
|
|
@@ -1,12 +1,47 @@
|
|
|
1
|
+
/** Theme names end up inside a CSS attribute selector — keep them boring. */
|
|
2
|
+
const THEME_NAME_PATTERN = /^[a-z0-9-]+$/;
|
|
3
|
+
/** Override keys must be CSS custom properties (design tokens). */
|
|
4
|
+
const TOKEN_NAME_PATTERN = /^--[a-zA-Z0-9_-]+$/;
|
|
1
5
|
/**
|
|
2
|
-
*
|
|
6
|
+
* Characters that would let a value break out of its declaration and inject
|
|
7
|
+
* arbitrary CSS rules (`;`, `{`, `}`) or markup when the returned CSS string
|
|
8
|
+
* is embedded in a page (`<`, `>`), plus control characters.
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line no-control-regex
|
|
11
|
+
const UNSAFE_VALUE_PATTERN = /[;{}<>\u0000-\u001f\u007f]/;
|
|
12
|
+
function assertValidThemeName(name) {
|
|
13
|
+
if (!THEME_NAME_PATTERN.test(name)) {
|
|
14
|
+
throw new Error(`[melodic] Invalid theme name "${name}". Theme names may only contain lowercase letters, digits, and hyphens (matching ${THEME_NAME_PATTERN}).`);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function assertValidOverride(key, value) {
|
|
18
|
+
if (!TOKEN_NAME_PATTERN.test(key)) {
|
|
19
|
+
throw new Error(`[melodic] Invalid theme token "${key}". Token names must be CSS custom properties (e.g. "--ml-color-primary") matching ${TOKEN_NAME_PATTERN}.`);
|
|
20
|
+
}
|
|
21
|
+
if (UNSAFE_VALUE_PATTERN.test(value)) {
|
|
22
|
+
throw new Error(`[melodic] Invalid value for theme token "${key}". Values must not contain ";", "{", "}", "<", ">", or control characters.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a custom theme by overriding default tokens.
|
|
27
|
+
*
|
|
28
|
+
* The theme name and every override are validated before being interpolated
|
|
29
|
+
* into CSS: names must match `^[a-z0-9-]+$`, keys must be CSS custom
|
|
30
|
+
* properties, and values must not contain characters that could break out of
|
|
31
|
+
* the declaration block. Invalid input throws.
|
|
32
|
+
*
|
|
3
33
|
* @param name - Theme name (used in data-theme attribute)
|
|
4
34
|
* @param overrides - Token values to override
|
|
5
35
|
* @returns CSS string to inject into document
|
|
6
36
|
*/
|
|
7
37
|
export function createTheme(name, overrides) {
|
|
38
|
+
assertValidThemeName(name);
|
|
8
39
|
const cssProperties = Object.entries(overrides)
|
|
9
|
-
.map(([key, value]) =>
|
|
40
|
+
.map(([key, value]) => {
|
|
41
|
+
const stringValue = String(value ?? '');
|
|
42
|
+
assertValidOverride(key, stringValue);
|
|
43
|
+
return `${key}: ${stringValue};`;
|
|
44
|
+
})
|
|
10
45
|
.join('\n\t');
|
|
11
46
|
return `[data-theme="${name}"] {\n\t${cssProperties}\n}`;
|
|
12
47
|
}
|
|
@@ -36,34 +71,45 @@ export function injectTheme(name, overrides) {
|
|
|
36
71
|
* Emit a base semantic color plus its -hover / -active / -subtle variants, so a
|
|
37
72
|
* brand theme stays visually consistent (components reference the variants for
|
|
38
73
|
* interaction states, not just the base).
|
|
74
|
+
*
|
|
75
|
+
* In light mode, hover/active darken the base and -subtle is a near-white
|
|
76
|
+
* tint. In dark mode, hover/active lighten the base and -subtle is a
|
|
77
|
+
* near-black tint, so subtle backgrounds sit correctly on dark surfaces.
|
|
39
78
|
*/
|
|
40
|
-
function setColorWithVariants(overrides, token, color) {
|
|
79
|
+
function setColorWithVariants(overrides, token, color, mode) {
|
|
80
|
+
const interactionMix = mode === 'dark' ? 'white' : 'black';
|
|
81
|
+
const subtleMix = mode === 'dark' ? 'black' : 'white';
|
|
41
82
|
overrides[token] = color;
|
|
42
|
-
overrides[`${token}-hover`] = `color-mix(in srgb, ${color},
|
|
43
|
-
overrides[`${token}-active`] = `color-mix(in srgb, ${color},
|
|
44
|
-
overrides[`${token}-subtle`] = `color-mix(in srgb, ${color},
|
|
83
|
+
overrides[`${token}-hover`] = `color-mix(in srgb, ${color}, ${interactionMix} 12%)`;
|
|
84
|
+
overrides[`${token}-active`] = `color-mix(in srgb, ${color}, ${interactionMix} 22%)`;
|
|
85
|
+
overrides[`${token}-subtle`] = `color-mix(in srgb, ${color}, ${subtleMix} 88%)`;
|
|
45
86
|
}
|
|
46
87
|
/**
|
|
47
88
|
* Create a brand theme from semantic colors. Each color also generates matching
|
|
48
89
|
* hover/active/subtle variants so interaction states aren't left at the default
|
|
49
90
|
* (e.g. a purple primary no longer hovers blue).
|
|
91
|
+
*
|
|
92
|
+
* Pass `mode: 'dark'` to generate variants suited to dark surfaces
|
|
93
|
+
* (hover/active lighten instead of darken; -subtle mixes toward black instead
|
|
94
|
+
* of white). Defaults to `'light'` for backwards compatibility.
|
|
50
95
|
*/
|
|
51
96
|
export function createBrandTheme(name, options) {
|
|
52
97
|
const overrides = {};
|
|
98
|
+
const mode = options.mode ?? 'light';
|
|
53
99
|
if (options.primary) {
|
|
54
|
-
setColorWithVariants(overrides, '--ml-color-primary', options.primary);
|
|
100
|
+
setColorWithVariants(overrides, '--ml-color-primary', options.primary, mode);
|
|
55
101
|
}
|
|
56
102
|
if (options.secondary) {
|
|
57
|
-
setColorWithVariants(overrides, '--ml-color-secondary', options.secondary);
|
|
103
|
+
setColorWithVariants(overrides, '--ml-color-secondary', options.secondary, mode);
|
|
58
104
|
}
|
|
59
105
|
if (options.success) {
|
|
60
|
-
setColorWithVariants(overrides, '--ml-color-success', options.success);
|
|
106
|
+
setColorWithVariants(overrides, '--ml-color-success', options.success, mode);
|
|
61
107
|
}
|
|
62
108
|
if (options.warning) {
|
|
63
|
-
setColorWithVariants(overrides, '--ml-color-warning', options.warning);
|
|
109
|
+
setColorWithVariants(overrides, '--ml-color-warning', options.warning, mode);
|
|
64
110
|
}
|
|
65
111
|
if (options.danger) {
|
|
66
|
-
setColorWithVariants(overrides, '--ml-color-danger', options.danger);
|
|
112
|
+
setColorWithVariants(overrides, '--ml-color-danger', options.danger, mode);
|
|
67
113
|
}
|
|
68
114
|
return createTheme(name, overrides);
|
|
69
115
|
}
|
package/lib/theme/index.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export * from './tokens/index.js';
|
|
|
2
2
|
export * from './presets/index.js';
|
|
3
3
|
export { applyTheme, getResolvedTheme, getTheme, onThemeChange, toggleTheme } from './functions/apply-theme.function.js';
|
|
4
4
|
export { createTheme, injectTheme, createBrandTheme } from './functions/create-theme.function.js';
|
|
5
|
+
export type { BrandThemeMode } from './functions/create-theme.function.js';
|
|
5
6
|
export type { ThemeMode } from '../types/index.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/theme/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACzH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AACA,cAAc,mBAAmB,CAAC;AAGlC,cAAc,oBAAoB,CAAC;AAGnC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AACzH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAClG,YAAY,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAG3E,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'link';
|
|
1
|
+
export type ButtonVariant = 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger' | 'error' | 'link';
|
|
2
2
|
export type AlertVariant = 'info' | 'success' | 'warning' | 'error';
|
|
3
|
-
export type BadgeVariant = 'default' | 'primary' | 'success' | 'warning' | 'error';
|
|
3
|
+
export type BadgeVariant = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'error';
|
|
4
|
+
/** Full size scale. Only components that actually style all five steps
|
|
5
|
+
* (button, spinner, avatar, file-icon) use this directly. */
|
|
4
6
|
export type Size = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
7
|
+
/** The sizes most controls actually style (inputs, toggles, tabs, tags,
|
|
8
|
+
* button groups, …). Kept separate from `Size` so component props no longer
|
|
9
|
+
* promise xs/xl variants that have no styles. */
|
|
10
|
+
export type ControlSize = 'sm' | 'md' | 'lg';
|
|
5
11
|
export type ComponentSize = Size;
|
|
6
12
|
export type Side = 'top' | 'right' | 'bottom' | 'left';
|
|
7
13
|
export type Alignment = 'start' | 'center' | 'end';
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AACxG,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AACpE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAGjG;6DAC6D;AAC7D,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AACpD;;iDAEiD;AACjD,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC7C,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC;AAGjC,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AACvD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AACnD,MAAM,MAAM,SAAS,GAClB,KAAK,GACL,WAAW,GACX,SAAS,GACT,QAAQ,GACR,cAAc,GACd,YAAY,GACZ,MAAM,GACN,YAAY,GACZ,UAAU,GACV,OAAO,GACP,aAAa,GACb,WAAW,CAAC;AAGf,MAAM,MAAM,WAAW,GAAG,YAAY,GAAG,UAAU,CAAC;AAGpD,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC"}
|
|
@@ -6,11 +6,29 @@ export interface FocusTrapOptions {
|
|
|
6
6
|
/** Whether to auto-focus first element if initialFocus not provided */
|
|
7
7
|
autoFocus?: boolean;
|
|
8
8
|
}
|
|
9
|
+
export interface FocusTrapDeactivateOptions {
|
|
10
|
+
/** Whether to restore focus to the previously-focused element (default: true) */
|
|
11
|
+
returnFocus?: boolean;
|
|
12
|
+
}
|
|
9
13
|
export interface FocusTrap {
|
|
10
14
|
activate(): void;
|
|
11
|
-
deactivate(): void;
|
|
15
|
+
deactivate(options?: FocusTrapDeactivateOptions): void;
|
|
12
16
|
isActive(): boolean;
|
|
13
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* The element that actually has focus, descending through nested shadow roots.
|
|
20
|
+
* `document.activeElement` alone reports the outermost shadow host.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getDeepActiveElement(): Element | null;
|
|
23
|
+
/**
|
|
24
|
+
* True when the (deep) focused element is `container` or lives inside it,
|
|
25
|
+
* crossing shadow boundaries in both directions: the active element is
|
|
26
|
+
* resolved through nested shadow roots, and the ancestor walk climbs from
|
|
27
|
+
* shadow roots to their hosts. Overlays use this to decide whether a
|
|
28
|
+
* dismissal happened while focus was parked in their content (and therefore
|
|
29
|
+
* whether focus should be returned to the trigger).
|
|
30
|
+
*/
|
|
31
|
+
export declare function isDeepFocusWithin(container: Node): boolean;
|
|
14
32
|
/**
|
|
15
33
|
* Create a focus trap within a container element
|
|
16
34
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-trap.d.ts","sourceRoot":"","sources":["../../../src/utils/accessibility/focus-trap.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAChC,8CAA8C;IAC9C,YAAY,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,IAAI,IAAI,CAAC;IACjB,UAAU,
|
|
1
|
+
{"version":3,"file":"focus-trap.d.ts","sourceRoot":"","sources":["../../../src/utils/accessibility/focus-trap.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAChC,8CAA8C;IAC9C,YAAY,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAClC,0DAA0D;IAC1D,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,0BAA0B;IAC1C,iFAAiF;IACjF,WAAW,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACzB,QAAQ,IAAI,IAAI,CAAC;IACjB,UAAU,CAAC,OAAO,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACvD,QAAQ,IAAI,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,GAAG,IAAI,CAMrD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,IAAI,GAAG,OAAO,CAO1D;AA4BD;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,GAAE,gBAAqB,GAAG,SAAS,CAuFjG;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,IAAI,CAIxF"}
|