igniteui-webcomponents 7.3.2 → 7.4.1
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/CHANGELOG.md +87 -0
- package/animations/easings.d.ts +21 -31
- package/animations/easings.js +21 -34
- package/animations/easings.js.map +1 -1
- package/animations/player.d.ts +8 -16
- package/animations/player.js +5 -8
- package/animations/player.js.map +1 -1
- package/animations/view-transition.d.ts +10 -10
- package/animations/view-transition.js +26 -37
- package/animations/view-transition.js.map +1 -1
- package/components/breadcrumb/breadcrumb.d.ts +74 -0
- package/components/breadcrumb/breadcrumb.js +107 -0
- package/components/breadcrumb/breadcrumb.js.map +1 -0
- package/components/breadcrumb/breadcrumbs.d.ts +60 -0
- package/components/breadcrumb/breadcrumbs.js +50 -0
- package/components/breadcrumb/breadcrumbs.js.map +1 -0
- package/components/breadcrumb/themes/breadcrumb.base.css.js +3 -0
- package/components/breadcrumb/themes/breadcrumb.base.css.js.map +1 -0
- package/components/breadcrumb/themes/breadcrumbs.base.css.d.ts +1 -0
- package/components/{resize-container/themes/resize-container.base.css.js → breadcrumb/themes/breadcrumbs.base.css.js} +2 -2
- package/components/breadcrumb/themes/breadcrumbs.base.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.bootstrap.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.fluent.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.indigo.css.js.map +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.material.css.d.ts +1 -0
- package/components/breadcrumb/themes/dark/breadcrumb.material.css.js +3 -0
- package/components/breadcrumb/themes/dark/breadcrumb.material.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.bootstrap.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.fluent.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.fluent.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.fluent.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.indigo.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.indigo.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.indigo.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.material.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.material.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.material.css.js.map +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.shared.css.d.ts +1 -0
- package/components/breadcrumb/themes/light/breadcrumb.shared.css.js +3 -0
- package/components/breadcrumb/themes/light/breadcrumb.shared.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.bootstrap.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.common.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.common.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.common.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.fluent.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.indigo.css.js.map +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.material.css.d.ts +1 -0
- package/components/breadcrumb/themes/shared/breadcrumb.material.css.js +3 -0
- package/components/breadcrumb/themes/shared/breadcrumb.material.css.js.map +1 -0
- package/components/breadcrumb/themes/themes.d.ts +2 -0
- package/components/breadcrumb/themes/themes.js +50 -0
- package/components/breadcrumb/themes/themes.js.map +1 -0
- package/components/button/button.d.ts +0 -2
- package/components/button/button.js.map +1 -1
- package/components/button-group/button-group.d.ts +42 -12
- package/components/button-group/button-group.js +82 -34
- package/components/button-group/button-group.js.map +1 -1
- package/components/button-group/toggle-button.d.ts +6 -1
- package/components/button-group/toggle-button.js +28 -2
- package/components/button-group/toggle-button.js.map +1 -1
- package/components/calendar/base.js +2 -1
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.d.ts +2 -3
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +2 -2
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/carousel/carousel-indicator.js +1 -0
- package/components/carousel/carousel-indicator.js.map +1 -1
- package/components/carousel/carousel-slide.d.ts +1 -1
- package/components/carousel/carousel-slide.js.map +1 -1
- package/components/carousel/carousel.d.ts +3 -3
- package/components/carousel/carousel.js.map +1 -1
- package/components/chat/chat-input.d.ts +1 -2
- package/components/chat/chat-input.js +1 -1
- package/components/chat/chat-input.js.map +1 -1
- package/components/chat/chat-state.d.ts +8 -9
- package/components/chat/chat-state.js.map +1 -1
- package/components/chat/chat.d.ts +1 -3
- package/components/chat/chat.js +2 -2
- package/components/chat/chat.js.map +1 -1
- package/components/chat/message-attachments.d.ts +6 -15
- package/components/chat/message-attachments.js.map +1 -1
- package/components/chat/utils.d.ts +0 -1
- package/components/chat/utils.js +1 -1
- package/components/chat/utils.js.map +1 -1
- package/components/checkbox/checkbox-base.d.ts +3 -1
- package/components/checkbox/checkbox-base.js +4 -0
- package/components/checkbox/checkbox-base.js.map +1 -1
- package/components/checkbox/checkbox.js +4 -12
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/checkbox/switch.js +1 -8
- package/components/checkbox/switch.js.map +1 -1
- package/components/chip/chip.d.ts +2 -2
- package/components/chip/chip.js.map +1 -1
- package/components/color-picker/color-picker.d.ts +35 -34
- package/components/color-picker/color-picker.js +12 -7
- package/components/color-picker/color-picker.js.map +1 -1
- package/components/color-picker/common.d.ts +0 -2
- package/components/color-picker/common.js +2 -2
- package/components/color-picker/common.js.map +1 -1
- package/components/color-picker/converters.js.map +1 -1
- package/components/color-picker/picker-canvas.js.map +1 -1
- package/components/combo/combo.d.ts +24 -24
- package/components/combo/combo.js +21 -26
- package/components/combo/combo.js.map +1 -1
- package/components/combo/controllers/data.d.ts +7 -10
- package/components/combo/controllers/data.js.map +1 -1
- package/components/date-picker/date-picker.base.d.ts +22 -27
- package/components/date-picker/date-picker.base.js +9 -3
- package/components/date-picker/date-picker.base.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +1 -1
- package/components/date-picker/date-picker.js +5 -3
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-range-picker/date-range-input.d.ts +0 -2
- package/components/date-range-picker/date-range-input.js +0 -6
- package/components/date-range-picker/date-range-input.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +22 -31
- package/components/date-range-picker/date-range-picker.js +7 -7
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/i18n.d.ts +21 -0
- package/components/date-range-picker/i18n.js +10 -0
- package/components/date-range-picker/i18n.js.map +1 -0
- package/components/date-range-picker/predefined-ranges-area.d.ts +3 -3
- package/components/date-range-picker/predefined-ranges-area.js +2 -5
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-range-picker/validators.d.ts +0 -4
- package/components/date-range-picker/validators.js +4 -4
- package/components/date-range-picker/validators.js.map +1 -1
- package/components/date-time-input/date-time-input.base.d.ts +42 -40
- package/components/date-time-input/date-time-input.base.js +9 -5
- package/components/date-time-input/date-time-input.base.js.map +1 -1
- package/components/date-time-input/date-time-input.d.ts +1 -11
- package/components/date-time-input/date-time-input.js +0 -6
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/date-time-input/datetime-mask-parser.d.ts +0 -10
- package/components/date-time-input/datetime-mask-parser.js +1 -1
- package/components/date-time-input/datetime-mask-parser.js.map +1 -1
- package/components/dialog/dialog.js.map +1 -1
- package/components/dropdown/dropdown-group.d.ts +2 -10
- package/components/dropdown/dropdown-group.js +2 -27
- package/components/dropdown/dropdown-group.js.map +1 -1
- package/components/dropdown/dropdown.d.ts +17 -23
- package/components/dropdown/dropdown.js +5 -17
- package/components/dropdown/dropdown.js.map +1 -1
- package/components/file-input/file-input.d.ts +7 -2
- package/components/file-input/file-input.js +4 -0
- package/components/file-input/file-input.js.map +1 -1
- package/components/icon/icon.d.ts +1 -1
- package/components/icon/icon.registry.d.ts +6 -6
- package/components/icon/icon.registry.js.map +1 -1
- package/components/input/input-base.d.ts +2 -2
- package/components/input/input-base.js +3 -5
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.d.ts +3 -3
- package/components/input/input.js.map +1 -1
- package/components/mask-input/mask-history.d.ts +22 -18
- package/components/mask-input/mask-history.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +1 -1
- package/components/mask-input/mask-parser.d.ts +11 -13
- package/components/mask-input/mask-parser.js.map +1 -1
- package/components/popover/popover.d.ts +45 -34
- package/components/popover/popover.js +54 -122
- package/components/popover/popover.js.map +1 -1
- package/components/popover/position/arrow.d.ts +19 -0
- package/components/popover/position/arrow.js +33 -0
- package/components/popover/position/arrow.js.map +1 -0
- package/components/popover/position/floating.d.ts +40 -0
- package/components/popover/position/floating.js +146 -0
- package/components/popover/position/floating.js.map +1 -0
- package/components/popover/position/native.d.ts +45 -0
- package/components/popover/position/native.js +158 -0
- package/components/popover/position/native.js.map +1 -0
- package/components/popover/position/strategy.d.ts +37 -0
- package/components/popover/position/strategy.js +21 -0
- package/components/popover/position/strategy.js.map +1 -0
- package/components/popover/position/types.d.ts +26 -0
- package/components/popover/position/types.js +15 -0
- package/components/popover/position/types.js.map +1 -0
- package/components/popover/themes/light/popover.base.css.js +1 -1
- package/components/popover/themes/light/popover.base.css.js.map +1 -1
- package/components/progress/circular-progress.d.ts +0 -5
- package/components/progress/circular-progress.js.map +1 -1
- package/components/qr-code/qr-code.d.ts +1 -1
- package/components/radio/radio.d.ts +6 -4
- package/components/radio/radio.js +24 -25
- package/components/radio/radio.js.map +1 -1
- package/components/radio-group/radio-group.js.map +1 -1
- package/components/rating/rating.d.ts +9 -6
- package/components/rating/rating.js +17 -18
- package/components/rating/rating.js.map +1 -1
- package/components/select/select-group.d.ts +5 -10
- package/components/select/select-group.js +10 -34
- package/components/select/select-group.js.map +1 -1
- package/components/select/select.d.ts +12 -20
- package/components/select/select.js +5 -15
- package/components/select/select.js.map +1 -1
- package/components/slider/range-slider.d.ts +0 -1
- package/components/slider/range-slider.js +6 -11
- package/components/slider/range-slider.js.map +1 -1
- package/components/slider/slider-base.d.ts +4 -1
- package/components/slider/slider-base.js +20 -18
- package/components/slider/slider-base.js.map +1 -1
- package/components/slider/slider.d.ts +2 -0
- package/components/slider/slider.js +5 -1
- package/components/slider/slider.js.map +1 -1
- package/components/splitter/splitter.d.ts +6 -6
- package/components/splitter/splitter.js.map +1 -1
- package/components/textarea/textarea.d.ts +2 -5
- package/components/textarea/textarea.js +3 -5
- package/components/textarea/textarea.js.map +1 -1
- package/components/tile-manager/tile-manager.d.ts +6 -7
- package/components/tile-manager/tile-manager.js.map +1 -1
- package/components/tile-manager/tile.d.ts +3 -3
- package/components/tile-manager/tile.js.map +1 -1
- package/components/toast/toast.d.ts +0 -2
- package/components/toast/toast.js.map +1 -1
- package/components/tooltip/controller.js.map +1 -1
- package/components/tooltip/service.js +4 -5
- package/components/tooltip/service.js.map +1 -1
- package/components/tooltip/tooltip.d.ts +34 -13
- package/components/tooltip/tooltip.js +8 -4
- package/components/tooltip/tooltip.js.map +1 -1
- package/components/tree/tree-item.d.ts +6 -6
- package/components/tree/tree-item.js.map +1 -1
- package/components/tree/tree.navigation.d.ts +5 -6
- package/components/tree/tree.navigation.js.map +1 -1
- package/components/tree/tree.selection.js.map +1 -1
- package/components/types.d.ts +1 -1
- package/components/types.js.map +1 -1
- package/components/validation-container/validation-container.js +2 -1
- package/components/validation-container/validation-container.js.map +1 -1
- package/components/virtualization/engine.d.ts +40 -9
- package/components/virtualization/engine.js +126 -61
- package/components/virtualization/engine.js.map +1 -1
- package/components/virtualization/recycle.d.ts +13 -0
- package/components/virtualization/recycle.js +152 -0
- package/components/virtualization/recycle.js.map +1 -0
- package/components/virtualization/virtualization.d.ts +84 -65
- package/components/virtualization/virtualization.js +20 -16
- package/components/virtualization/virtualization.js.map +1 -1
- package/custom-elements.json +18455 -19551
- package/igniteui-webcomponents.css-data.json +2 -2
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -1
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/internals/abort-handler.d.ts +13 -25
- package/internals/abort-handler.js +4 -6
- package/internals/abort-handler.js.map +1 -1
- package/internals/context.d.ts +13 -7
- package/internals/context.js +2 -1
- package/internals/context.js.map +1 -1
- package/internals/controllers/adopt-styles.d.ts +19 -20
- package/internals/controllers/adopt-styles.js +3 -8
- package/internals/controllers/adopt-styles.js.map +1 -1
- package/internals/controllers/aria-projection.d.ts +100 -61
- package/internals/controllers/aria-projection.js +81 -31
- package/internals/controllers/aria-projection.js.map +1 -1
- package/internals/controllers/async-consumer.js.map +1 -1
- package/internals/controllers/command.d.ts +15 -30
- package/internals/controllers/command.js +2 -7
- package/internals/controllers/command.js.map +1 -1
- package/internals/controllers/context-provider.d.ts +7 -13
- package/internals/controllers/context-provider.js.map +1 -1
- package/internals/controllers/focus-ring.d.ts +10 -30
- package/internals/controllers/focus-ring.js +6 -12
- package/internals/controllers/focus-ring.js.map +1 -1
- package/internals/controllers/fullscreen.d.ts +7 -23
- package/internals/controllers/fullscreen.js +3 -9
- package/internals/controllers/fullscreen.js.map +1 -1
- package/internals/controllers/gestures.d.ts +10 -29
- package/internals/controllers/gestures.js +1 -3
- package/internals/controllers/gestures.js.map +1 -1
- package/internals/controllers/group.d.ts +13 -30
- package/internals/controllers/group.js.map +1 -1
- package/internals/controllers/host-listeners.d.ts +28 -0
- package/internals/controllers/host-listeners.js +27 -0
- package/internals/controllers/host-listeners.js.map +1 -0
- package/internals/controllers/id-resolver.d.ts +8 -9
- package/internals/controllers/id-resolver.js +6 -14
- package/internals/controllers/id-resolver.js.map +1 -1
- package/internals/controllers/internals.d.ts +53 -104
- package/internals/controllers/internals.js +40 -13
- package/internals/controllers/internals.js.map +1 -1
- package/internals/controllers/key-bindings.d.ts +61 -158
- package/internals/controllers/key-bindings.js +68 -67
- package/internals/controllers/key-bindings.js.map +1 -1
- package/internals/controllers/keys.d.ts +32 -0
- package/internals/controllers/keys.js +20 -0
- package/internals/controllers/keys.js.map +1 -0
- package/internals/controllers/mutation-observer.d.ts +14 -37
- package/internals/controllers/mutation-observer.js +1 -1
- package/internals/controllers/mutation-observer.js.map +1 -1
- package/internals/controllers/resize-observer.d.ts +9 -19
- package/internals/controllers/resize-observer.js.map +1 -1
- package/internals/controllers/root-click.d.ts +11 -42
- package/internals/controllers/root-click.js +4 -6
- package/internals/controllers/root-click.js.map +1 -1
- package/internals/controllers/roving-focus.d.ts +16 -35
- package/internals/controllers/roving-focus.js.map +1 -1
- package/internals/controllers/slot.d.ts +25 -54
- package/internals/controllers/slot.js +6 -6
- package/internals/controllers/slot.js.map +1 -1
- package/internals/controllers/toggle.d.ts +44 -48
- package/internals/controllers/toggle.js.map +1 -1
- package/internals/date/compare.js.map +1 -1
- package/internals/date/converters.d.ts +10 -7
- package/internals/date/converters.js.map +1 -1
- package/internals/date/model.d.ts +9 -16
- package/internals/date/model.js +22 -25
- package/internals/date/model.js.map +1 -1
- package/internals/decorators/blazorAdditionalDependencies.d.ts +4 -2
- package/internals/decorators/blazorAdditionalDependencies.js.map +1 -1
- package/internals/decorators/blazorDeepImport.d.ts +1 -3
- package/internals/decorators/blazorDeepImport.js.map +1 -1
- package/internals/decorators/blazorInclude.d.ts +3 -2
- package/internals/decorators/blazorInclude.js.map +1 -1
- package/internals/decorators/blazorIndirectRender.d.ts +1 -3
- package/internals/decorators/blazorIndirectRender.js.map +1 -1
- package/internals/decorators/blazorSuppressComponent.d.ts +1 -3
- package/internals/decorators/blazorSuppressComponent.js.map +1 -1
- package/internals/decorators/coerced-property.d.ts +14 -20
- package/internals/decorators/coerced-property.js.map +1 -1
- package/internals/decorators/shadow-options.d.ts +2 -5
- package/internals/decorators/shadow-options.js.map +1 -1
- package/internals/definitions/defineAllComponents.js +2 -0
- package/internals/definitions/defineAllComponents.js.map +1 -1
- package/internals/directives/drag.d.ts +51 -81
- package/internals/directives/drag.js +27 -89
- package/internals/directives/drag.js.map +1 -1
- package/internals/directives/pointer-operation.d.ts +75 -0
- package/internals/directives/pointer-operation.js +92 -0
- package/internals/directives/pointer-operation.js.map +1 -0
- package/internals/directives/resize.d.ts +36 -64
- package/internals/directives/resize.js +18 -85
- package/internals/directives/resize.js.map +1 -1
- package/internals/i18n/EN/calendar.resources.d.ts +8 -2
- package/internals/i18n/EN/calendar.resources.js +2 -2
- package/internals/i18n/EN/calendar.resources.js.map +1 -1
- package/internals/i18n/EN/chat.resources.d.ts +8 -2
- package/internals/i18n/EN/chat.resources.js +3 -10
- package/internals/i18n/EN/chat.resources.js.map +1 -1
- package/internals/i18n/EN/date-picker.resources.d.ts +6 -4
- package/internals/i18n/EN/date-picker.resources.js +1 -7
- package/internals/i18n/EN/date-picker.resources.js.map +1 -1
- package/internals/i18n/EN/date-range-picker.resources.d.ts +9 -2
- package/internals/i18n/EN/date-range-picker.resources.js +2 -2
- package/internals/i18n/EN/date-range-picker.resources.js.map +1 -1
- package/internals/i18n/i18n-controller.d.ts +44 -46
- package/internals/i18n/i18n-controller.js +46 -33
- package/internals/i18n/i18n-controller.js.map +1 -1
- package/internals/i18n/utils.d.ts +9 -4
- package/internals/i18n/utils.js +4 -27
- package/internals/i18n/utils.js.map +1 -1
- package/internals/mixins/alert.d.ts +10 -25
- package/internals/mixins/alert.js.map +1 -1
- package/internals/mixins/combo-box.d.ts +21 -11
- package/internals/mixins/combo-box.js +16 -22
- package/internals/mixins/combo-box.js.map +1 -1
- package/internals/mixins/event-emitter.js +9 -11
- package/internals/mixins/event-emitter.js.map +1 -1
- package/internals/mixins/forms/associated-required.d.ts +4 -4
- package/internals/mixins/forms/associated-required.js.map +1 -1
- package/internals/mixins/forms/associated.d.ts +4 -2
- package/internals/mixins/forms/associated.js +42 -19
- package/internals/mixins/forms/associated.js.map +1 -1
- package/internals/mixins/forms/form-transformers.js.map +1 -1
- package/internals/mixins/forms/types.d.ts +27 -78
- package/internals/mixins/forms/types.js.map +1 -1
- package/internals/mixins/group.d.ts +18 -0
- package/internals/mixins/group.js +37 -0
- package/internals/mixins/group.js.map +1 -0
- package/internals/mixins/i18n.d.ts +10 -16
- package/internals/mixins/i18n.js.map +1 -1
- package/internals/mixins/mask-behavior.d.ts +8 -22
- package/internals/mixins/mask-behavior.js +1 -2
- package/internals/mixins/mask-behavior.js.map +1 -1
- package/internals/mixins/option.d.ts +1 -2
- package/internals/mixins/option.js +2 -1
- package/internals/mixins/option.js.map +1 -1
- package/internals/part-map.d.ts +4 -2
- package/internals/part-map.js +1 -1
- package/internals/part-map.js.map +1 -1
- package/internals/templates/input-shell.d.ts +8 -17
- package/internals/templates/input-shell.js +4 -1
- package/internals/templates/input-shell.js.map +1 -1
- package/internals/templates/masked-input.d.ts +7 -8
- package/internals/templates/masked-input.js.map +1 -1
- package/internals/templates/slotted-icon.d.ts +7 -12
- package/internals/templates/slotted-icon.js.map +1 -1
- package/internals/templates/toggle-shell.d.ts +19 -19
- package/internals/templates/toggle-shell.js +12 -8
- package/internals/templates/toggle-shell.js.map +1 -1
- package/internals/timing.d.ts +5 -14
- package/internals/timing.js.map +1 -1
- package/internals/utils/arrays.d.ts +21 -21
- package/internals/utils/arrays.js +14 -0
- package/internals/utils/arrays.js.map +1 -1
- package/internals/utils/dom.d.ts +53 -41
- package/internals/utils/dom.js +3 -4
- package/internals/utils/dom.js.map +1 -1
- package/internals/utils/events.d.ts +29 -16
- package/internals/utils/events.js +9 -1
- package/internals/utils/events.js.map +1 -1
- package/internals/utils/lit.d.ts +5 -2
- package/internals/utils/lit.js.map +1 -1
- package/internals/utils/math.d.ts +8 -6
- package/internals/utils/math.js.map +1 -1
- package/internals/utils/objects.d.ts +3 -20
- package/internals/utils/objects.js +1 -39
- package/internals/utils/objects.js.map +1 -1
- package/internals/utils/strings.d.ts +9 -11
- package/internals/utils/strings.js.map +1 -1
- package/internals/utils/types.d.ts +16 -3
- package/internals/utils/types.js +3 -0
- package/internals/utils/types.js.map +1 -1
- package/internals/validators.d.ts +9 -8
- package/internals/validators.js +12 -6
- package/internals/validators.js.map +1 -1
- package/package.json +1 -1
- package/skills/README.md +4 -3
- package/skills/igniteui-wc-choose-components/SKILL.md +2 -1
- package/skills/igniteui-wc-customize-component-theme/SKILL.md +2 -1
- package/skills/igniteui-wc-figma-to-app/SKILL.md +328 -0
- package/skills/igniteui-wc-figma-to-app/references/asset-extraction.md +343 -0
- package/skills/igniteui-wc-figma-to-app/references/design-provenance.md +199 -0
- package/skills/igniteui-wc-figma-to-app/references/design-token-bridge.md +489 -0
- package/skills/igniteui-wc-figma-to-app/references/figma-component-map.md +370 -0
- package/skills/igniteui-wc-figma-to-app/references/figma-exploration.md +222 -0
- package/skills/igniteui-wc-figma-to-app/references/mcp-setup.md +363 -0
- package/skills/igniteui-wc-figma-to-app/references/project-setup.md +105 -0
- package/skills/igniteui-wc-figma-to-app/references/theme-generation.md +180 -0
- package/skills/igniteui-wc-figma-to-app/references/validation-patterns.md +370 -0
- package/skills/igniteui-wc-generate-from-image-design/SKILL.md +2 -1
- package/skills/igniteui-wc-generate-from-image-design/references/gotchas.md +3 -3
- package/skills/igniteui-wc-grids/SKILL.md +133 -0
- package/skills/igniteui-wc-integrate-with-framework/SKILL.md +2 -1
- package/skills/igniteui-wc-migrate-grid-lite-to-premium/SKILL.md +2 -1
- package/skills/igniteui-wc-optimize-bundle-size/SKILL.md +2 -1
- package/theming/config.d.ts +14 -5
- package/theming/config.js +38 -18
- package/theming/config.js.map +1 -1
- package/theming/context.d.ts +1 -23
- package/theming/context.js.map +1 -1
- package/theming/theming-controller.d.ts +2 -32
- package/theming/theming-controller.js +15 -21
- package/theming/theming-controller.js.map +1 -1
- package/theming/theming-event.d.ts +0 -7
- package/theming/theming-event.js +0 -13
- package/theming/theming-event.js.map +1 -1
- package/theming/types.d.ts +1 -8
- package/theming/types.js.map +1 -1
- package/web-types.json +3 -3
- package/animations/presets/slide/index.d.ts +0 -3
- package/animations/presets/slide/index.js +0 -16
- package/animations/presets/slide/index.js.map +0 -1
- package/components/resize-container/themes/resize-container.base.css.js.map +0 -1
- package/internals/controllers/root-scroll.d.ts +0 -31
- package/internals/controllers/root-scroll.js +0 -71
- package/internals/controllers/root-scroll.js.map +0 -1
- package/theming/utils.d.ts +0 -11
- package/theming/utils.js +0 -20
- package/theming/utils.js.map +0 -1
- /package/components/{resize-container/themes/resize-container.base.css.d.ts → breadcrumb/themes/breadcrumb.base.css.d.ts} +0 -0
package/theming/config.js
CHANGED
|
@@ -1,37 +1,57 @@
|
|
|
1
1
|
import { isServer } from 'lit';
|
|
2
|
-
import { CHANGE_THEME_EVENT, } from './theming-event.js';
|
|
3
|
-
|
|
2
|
+
import { CHANGE_THEME_EVENT, CHANGED_THEME_EVENT, } from './theming-event.js';
|
|
3
|
+
const THEMES = new Set(['bootstrap', 'material', 'indigo', 'fluent']);
|
|
4
|
+
const THEME_VARIANTS = new Set(['light', 'dark']);
|
|
4
5
|
let theme;
|
|
5
6
|
let themeVariant;
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, { detail }));
|
|
9
|
-
}
|
|
7
|
+
function isOfTypeTheme(value) {
|
|
8
|
+
return THEMES.has(value);
|
|
10
9
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
10
|
+
function isOfTypeThemeVariant(value) {
|
|
11
|
+
return THEME_VARIANTS.has(value);
|
|
13
12
|
}
|
|
14
|
-
function
|
|
15
|
-
|
|
13
|
+
function setTheme(value, variant) {
|
|
14
|
+
theme = value;
|
|
15
|
+
themeVariant = variant;
|
|
16
16
|
}
|
|
17
|
+
class ThemeChangedEmitter extends EventTarget {
|
|
18
|
+
constructor() {
|
|
19
|
+
super();
|
|
20
|
+
if (!isServer) {
|
|
21
|
+
globalThis.addEventListener(CHANGE_THEME_EVENT, this);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
handleEvent({ detail }) {
|
|
25
|
+
if (isOfTypeTheme(detail?.theme) &&
|
|
26
|
+
isOfTypeThemeVariant(detail?.themeVariant)) {
|
|
27
|
+
setTheme(detail.theme, detail.themeVariant);
|
|
28
|
+
this.dispatchEvent(new CustomEvent(CHANGED_THEME_EVENT));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export const _themeChangedEmitter = new ThemeChangedEmitter();
|
|
17
33
|
export function getTheme() {
|
|
18
34
|
if (!(theme && themeVariant)) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
const rootStyles = isServer
|
|
36
|
+
? undefined
|
|
37
|
+
: getComputedStyle(document.documentElement);
|
|
38
|
+
const foundTheme = rootStyles?.getPropertyValue('--ig-theme').trim();
|
|
39
|
+
const foundVariant = rootStyles
|
|
40
|
+
?.getPropertyValue('--ig-theme-variant')
|
|
41
|
+
.trim();
|
|
22
42
|
theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';
|
|
23
43
|
themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';
|
|
24
44
|
}
|
|
25
45
|
return { theme, themeVariant };
|
|
26
46
|
}
|
|
27
|
-
export function setTheme(value, variant) {
|
|
28
|
-
theme = value;
|
|
29
|
-
themeVariant = variant;
|
|
30
|
-
}
|
|
31
47
|
export function configureTheme(t, v = 'light') {
|
|
32
48
|
if (isOfTypeTheme(t) && isOfTypeThemeVariant(v)) {
|
|
33
49
|
setTheme(t, v);
|
|
34
|
-
|
|
50
|
+
if (!isServer) {
|
|
51
|
+
globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, {
|
|
52
|
+
detail: { theme, themeVariant },
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
35
55
|
}
|
|
36
56
|
}
|
|
37
57
|
//# sourceMappingURL=config.js.map
|
package/theming/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/theming/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACL,kBAAkB,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/theming/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAU,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,IAAI,GAAG,CAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3D,IAAI,KAAY,CAAC;AACjB,IAAI,YAA0B,CAAC;AAE/B,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CA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CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;QAC7D,YAAY,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7E,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;AACjC,CAAC;AAYD,MAAM,UAAU,cAAc,CAAC,CAAQ,EAAE,IAAkB,OAAO;IAChE,IAAI,aAAa,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QAEhD,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEf,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,UAAU,CAAC,aAAa,CACtB,IAAI,WAAW,CAAC,kBAAkB,EAAE;gBAClC,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE;aAChC,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { isServer } from 'lit';\nimport {\n CHANGE_THEME_EVENT,\n CHANGED_THEME_EVENT,\n type ChangeThemeEventDetail,\n} from './theming-event.js';\nimport type { Theme, ThemeVariant } from './types.js';\n\nconst THEMES = new Set<unknown>(['bootstrap', 'material', 'indigo', 'fluent']);\nconst THEME_VARIANTS = new Set<unknown>(['light', 'dark']);\n\nlet theme: Theme;\nlet themeVariant: ThemeVariant;\n\nfunction isOfTypeTheme(value: unknown): value is Theme {\n return THEMES.has(value);\n}\n\nfunction isOfTypeThemeVariant(value: unknown): value is ThemeVariant {\n return THEME_VARIANTS.has(value);\n}\n\nfunction setTheme(value: Theme, variant: ThemeVariant): void {\n theme = value;\n themeVariant = variant;\n}\n\n/**\n * Relays \"igc-change-theme\" events from `window` to the theming controllers.\n * It also syncs the module state from the event detail, so an event from another\n * copy of the library changes the theme here too.\n */\nclass ThemeChangedEmitter extends EventTarget {\n constructor() {\n super();\n if (!isServer) {\n globalThis.addEventListener(CHANGE_THEME_EVENT, this);\n }\n }\n\n /** @internal */\n public handleEvent({ detail }: CustomEvent<ChangeThemeEventDetail>): void {\n if (\n isOfTypeTheme(detail?.theme) &&\n isOfTypeThemeVariant(detail?.themeVariant)\n ) {\n setTheme(detail.theme, detail.themeVariant);\n this.dispatchEvent(new CustomEvent(CHANGED_THEME_EVENT));\n }\n }\n}\n\nexport const _themeChangedEmitter = new ThemeChangedEmitter();\n\nexport function getTheme(): ChangeThemeEventDetail {\n if (!(theme && themeVariant)) {\n const rootStyles = isServer\n ? undefined\n : getComputedStyle(document.documentElement);\n const foundTheme = rootStyles?.getPropertyValue('--ig-theme').trim();\n const foundVariant = rootStyles\n ?.getPropertyValue('--ig-theme-variant')\n .trim();\n\n theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';\n themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';\n }\n\n return { theme, themeVariant };\n}\n\n/**\n * Allows the global configuration of the active theme.\n *\n * Usage:\n * ```ts\n * import { configureTheme } from 'igniteui-webcomponents';\n *\n * configureTheme('material', 'light');\n * ```\n */\nexport function configureTheme(t: Theme, v: ThemeVariant = 'light'): void {\n if (isOfTypeTheme(t) && isOfTypeThemeVariant(v)) {\n // Also set by the emitter's window listener, but that listener does not exist on the server.\n setTheme(t, v);\n\n if (!isServer) {\n globalThis.dispatchEvent(\n new CustomEvent(CHANGE_THEME_EVENT, {\n detail: { theme, themeVariant },\n })\n );\n }\n }\n}\n"]}
|
package/theming/context.d.ts
CHANGED
|
@@ -7,29 +7,7 @@ export interface ThemeContext {
|
|
|
7
7
|
variant: ThemeVariant;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Components can consume this context to receive theme information from a theme provider
|
|
13
|
-
* instead of relying on global theming events.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* // In a component
|
|
18
|
-
* import { ContextConsumer } from '@lit/context';
|
|
19
|
-
* import { themeContext } from './context.js';
|
|
20
|
-
*
|
|
21
|
-
* class MyComponent extends LitElement {
|
|
22
|
-
* private _themeConsumer = new ContextConsumer(this, {
|
|
23
|
-
* context: themeContext,
|
|
24
|
-
* subscribe: true
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* render() {
|
|
28
|
-
* const theme = this._themeConsumer.value;
|
|
29
|
-
* // ...
|
|
30
|
-
* }
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
10
|
+
* Theme context provided by the theme provider component and consumed by the theming controller.
|
|
33
11
|
*/
|
|
34
12
|
export declare const themeContext: {
|
|
35
13
|
__context__: ThemeContext;
|
package/theming/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/theming/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/theming/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAc7C,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAe,kBAAkB,CAAC,CAAC","sourcesContent":["import { createContext } from '@lit/context';\nimport type { Theme, ThemeVariant } from './types.js';\n\n/**\n * The theme context value.\n */\nexport interface ThemeContext {\n theme: Theme;\n variant: ThemeVariant;\n}\n\n/**\n * Theme context provided by the theme provider component and consumed by the theming controller.\n */\nexport const themeContext = createContext<ThemeContext>('ig-theme-context');\n"]}
|
|
@@ -5,7 +5,7 @@ import type { Theme, Themes, ThemeVariant, ThemingControllerConfig } from './typ
|
|
|
5
5
|
*
|
|
6
6
|
* It resolves the active theme from one of two sources, in order of priority:
|
|
7
7
|
*
|
|
8
|
-
* 1. **Context** - provided by an ancestor
|
|
8
|
+
* 1. **Context** - provided by an ancestor theme provider component via the Lit context API.
|
|
9
9
|
* 2. **Global** - the application-wide theme set via `configureTheme()`.
|
|
10
10
|
*
|
|
11
11
|
* When a context provider is present, the controller subscribes to its updates
|
|
@@ -15,41 +15,11 @@ import type { Theme, Themes, ThemeVariant, ThemingControllerConfig } from './typ
|
|
|
15
15
|
*
|
|
16
16
|
* Theme styles are applied directly to the host's shadow root via `adoptStyles`
|
|
17
17
|
* every time the active theme or variant changes.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* Basic usage - typically created via {@link addThemingController}:
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { addThemingController } from '#theming/theming-controller.js';
|
|
23
|
-
* import { all } from './themes/themes.js';
|
|
24
|
-
*
|
|
25
|
-
* export default class IgcMyComponent extends LitElement {
|
|
26
|
-
* constructor() {
|
|
27
|
-
* super();
|
|
28
|
-
* addThemingController(this, all);
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* Accessing the current theme and variant at runtime:
|
|
35
|
-
* ```typescript
|
|
36
|
-
* export default class IgcMyComponent extends LitElement {
|
|
37
|
-
* private readonly _themes = addThemingController(this, all);
|
|
38
|
-
*
|
|
39
|
-
* protected override render() {
|
|
40
|
-
* // Conditionally render based on active theme
|
|
41
|
-
* return this._themes.variant === 'dark'
|
|
42
|
-
* ? html`<div class="dark-layout"></div>`
|
|
43
|
-
* : html`<div class="light-layout"></div>`;
|
|
44
|
-
* }
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
18
|
*/
|
|
48
19
|
declare class ThemingController implements ReactiveController {
|
|
49
20
|
private readonly _host;
|
|
50
21
|
private readonly _themes;
|
|
51
22
|
private readonly _options?;
|
|
52
|
-
private readonly _contextConsumer;
|
|
53
23
|
private _theme;
|
|
54
24
|
private _variant;
|
|
55
25
|
private _themeSource;
|
|
@@ -74,7 +44,7 @@ declare class ThemingController implements ReactiveController {
|
|
|
74
44
|
*
|
|
75
45
|
* This is the preferred way to add theming support to a component. The controller
|
|
76
46
|
* is registered with the host's reactive controller lifecycle and automatically
|
|
77
|
-
* resolves the active theme from an ancestor
|
|
47
|
+
* resolves the active theme from an ancestor theme provider context or
|
|
78
48
|
* falls back to the application-wide theme set via `configureTheme()`.
|
|
79
49
|
*
|
|
80
50
|
* @param host - The Lit element that will host the controller.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ContextConsumer } from '@lit/context';
|
|
2
|
-
import { adoptStyles,
|
|
3
|
-
import { getTheme } from './config.js';
|
|
2
|
+
import { adoptStyles, } from 'lit';
|
|
3
|
+
import { _themeChangedEmitter, getTheme } from './config.js';
|
|
4
4
|
import { themeContext } from './context.js';
|
|
5
|
-
import {
|
|
5
|
+
import { CHANGED_THEME_EVENT } from './theming-event.js';
|
|
6
6
|
class ThemingController {
|
|
7
7
|
get theme() {
|
|
8
8
|
return this._theme;
|
|
@@ -17,8 +17,7 @@ class ThemingController {
|
|
|
17
17
|
this._host = host;
|
|
18
18
|
this._themes = themes;
|
|
19
19
|
this._options = config;
|
|
20
|
-
this._host
|
|
21
|
-
this._contextConsumer = new ContextConsumer(this._host, {
|
|
20
|
+
new ContextConsumer(this._host, {
|
|
22
21
|
context: themeContext,
|
|
23
22
|
callback: (value) => {
|
|
24
23
|
if (value) {
|
|
@@ -27,33 +26,29 @@ class ThemingController {
|
|
|
27
26
|
},
|
|
28
27
|
subscribe: true,
|
|
29
28
|
});
|
|
29
|
+
this._host.addController(this);
|
|
30
30
|
}
|
|
31
31
|
hostConnected() {
|
|
32
|
-
this.
|
|
32
|
+
if (this._themeSource === 'uninitialized') {
|
|
33
|
+
_themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);
|
|
34
|
+
this._applyGlobalTheme();
|
|
35
|
+
}
|
|
33
36
|
}
|
|
34
37
|
hostDisconnected() {
|
|
35
|
-
|
|
36
|
-
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
37
|
-
}
|
|
38
|
+
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
38
39
|
this._themeSource = 'uninitialized';
|
|
39
|
-
this._contextConsumer.value = undefined;
|
|
40
40
|
}
|
|
41
41
|
handleEvent() {
|
|
42
42
|
if (this._themeSource === 'global') {
|
|
43
43
|
this._applyGlobalTheme();
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
_applyContextTheme(
|
|
47
|
-
|
|
48
|
-
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
49
|
-
}
|
|
46
|
+
_applyContextTheme({ theme, variant }) {
|
|
47
|
+
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
50
48
|
this._themeSource = 'context';
|
|
51
|
-
this._applyTheme(
|
|
49
|
+
this._applyTheme(theme, variant);
|
|
52
50
|
}
|
|
53
51
|
_applyGlobalTheme() {
|
|
54
|
-
if (this._themeSource === 'uninitialized') {
|
|
55
|
-
_themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);
|
|
56
|
-
}
|
|
57
52
|
const { theme, themeVariant } = getTheme();
|
|
58
53
|
this._themeSource = 'global';
|
|
59
54
|
this._applyTheme(theme, themeVariant);
|
|
@@ -67,9 +62,8 @@ class ThemingController {
|
|
|
67
62
|
}
|
|
68
63
|
_adoptStyles() {
|
|
69
64
|
const ctor = this._host.constructor;
|
|
70
|
-
const shared = this._themes[this._variant]
|
|
71
|
-
|
|
72
|
-
adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, shared, theme]);
|
|
65
|
+
const { shared, [this._theme]: theme } = this._themes[this._variant];
|
|
66
|
+
adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, shared, theme].filter((s) => s !== undefined));
|
|
73
67
|
}
|
|
74
68
|
}
|
|
75
69
|
export function addThemingController(host, themes, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,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AEO,YAAY;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAgC,CAAC;QACzD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,IAAI,GAAG,CAAA,EAAE,CAAC;QAC3D,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,GAAG,CAAA,EAAE,CAAC;QAEhE,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAW,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;CAGF;AAkDD,MAAM,UAAU,oBAAoB,CAClC,IAA8C,EAC9C,MAAc,EACd,MAAgC;IAEhC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { ContextConsumer } from '@lit/context';\nimport {\n adoptStyles,\n css,\n type LitElement,\n type ReactiveController,\n type ReactiveControllerHost,\n type ReactiveElement,\n} from 'lit';\n\nimport { getTheme } from './config.js';\nimport { themeContext } from './context.js';\nimport { _themeChangedEmitter, CHANGED_THEME_EVENT } from './theming-event.js';\nimport type {\n Theme,\n Themes,\n ThemeVariant,\n ThemingControllerConfig,\n} from './types.js';\n\ntype ThemeProviderSource = 'uninitialized' | 'context' | 'global';\n\n/**\n * A reactive controller that manages theme adoption for a Lit host element.\n *\n * It resolves the active theme from one of two sources, in order of priority:\n *\n * 1. **Context** - provided by an ancestor `<igc-theme-provider>` element via the Lit context API.\n * 2. **Global** - the application-wide theme set via `configureTheme()`.\n *\n * When a context provider is present, the controller subscribes to its updates\n * and stops listening to global theme change events. When the host element is\n * disconnected and reconnected outside a provider, it automatically falls back\n * to the global theme.\n *\n * Theme styles are applied directly to the host's shadow root via `adoptStyles`\n * every time the active theme or variant changes.\n *\n * @example\n * Basic usage - typically created via {@link addThemingController}:\n * ```typescript\n * import { addThemingController } from '#theming/theming-controller.js';\n * import { all } from './themes/themes.js';\n *\n * export default class IgcMyComponent extends LitElement {\n * constructor() {\n * super();\n * addThemingController(this, all);\n * }\n * }\n * ```\n *\n * @example\n * Accessing the current theme and variant at runtime:\n * ```typescript\n * export default class IgcMyComponent extends LitElement {\n * private readonly _themes = addThemingController(this, all);\n *\n * protected override render() {\n * // Conditionally render based on active theme\n * return this._themes.variant === 'dark'\n * ? html`<div class=\"dark-layout\"></div>`\n * : html`<div class=\"light-layout\"></div>`;\n * }\n * }\n * ```\n */\nclass ThemingController implements ReactiveController {\n //#region Internal state\n\n private readonly _host: ReactiveControllerHost & ReactiveElement;\n private readonly _themes: Themes;\n private readonly _options?: ThemingControllerConfig;\n private readonly _contextConsumer: ContextConsumer<\n typeof themeContext,\n ReactiveElement\n >;\n\n private _theme: Theme = 'bootstrap';\n private _variant: ThemeVariant = 'light';\n private _themeSource: ThemeProviderSource = 'uninitialized';\n\n //#endregion\n\n //#region Public properties\n\n /** Gets the current theme. */\n public get theme(): Theme {\n return this._theme;\n }\n\n /** Gets the current theme variant. */\n public get variant(): ThemeVariant {\n return this._variant;\n }\n\n //#endregion\n\n constructor(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n ) {\n this._host = host;\n this._themes = themes;\n this._options = config;\n\n this._host.addController(this);\n\n this._contextConsumer = new ContextConsumer(this._host, {\n context: themeContext,\n callback: (value) => {\n if (value) {\n this._applyContextTheme(value);\n }\n },\n subscribe: true,\n });\n }\n\n //#region ReactiveController implementation\n\n /** @internal */\n public hostConnected(): void {\n // Apply the global theme initially. When the host's first update cycle begins, if a context provider is\n // present and has set its value, the callback will be invoked and override with the context value.\n this._applyGlobalTheme();\n }\n\n /** @internal */\n public hostDisconnected(): void {\n if (this._themeSource === 'global') {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n }\n\n // Reset to initial state so that if the host reconnects in a different part of the tree,\n // it can properly re-resolve the theme source.\n this._themeSource = 'uninitialized';\n this._contextConsumer.value = undefined;\n }\n\n //#endregion\n\n //#region Event handling\n\n /** @internal */\n public handleEvent(): void {\n if (this._themeSource === 'global') {\n this._applyGlobalTheme();\n }\n }\n\n //#endregion\n\n //#region Internal methods\n\n private _applyContextTheme(contextValue: {\n theme: Theme;\n variant: ThemeVariant;\n }): void {\n // If we were using global theme, unsubscribe from global events\n if (this._themeSource === 'global') {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n }\n\n this._themeSource = 'context';\n this._applyTheme(contextValue.theme, contextValue.variant);\n }\n\n private _applyGlobalTheme(): void {\n // Subscribe to global events only on first initialization\n if (this._themeSource === 'uninitialized') {\n _themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);\n }\n\n const { theme, themeVariant } = getTheme();\n\n this._themeSource = 'global';\n this._applyTheme(theme, themeVariant);\n }\n\n private _applyTheme(theme: Theme, variant: ThemeVariant): void {\n this._theme = theme;\n this._variant = variant;\n\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\n }\n\n private _adoptStyles(): void {\n const ctor = this._host.constructor as typeof LitElement;\n const shared = this._themes[this._variant].shared || css``;\n const theme = this._themes[this._variant][this._theme] || css``;\n\n adoptStyles(this._host.shadowRoot!, [...ctor.elementStyles, shared, theme]);\n }\n\n //#endregion\n}\n\n/**\n * Creates and attaches a {@link ThemingController} to the given host element.\n *\n * This is the preferred way to add theming support to a component. The controller\n * is registered with the host's reactive controller lifecycle and automatically\n * resolves the active theme from an ancestor `<igc-theme-provider>` context or\n * falls back to the application-wide theme set via `configureTheme()`.\n *\n * @param host - The Lit element that will host the controller.\n * @param themes - The theme styles map containing `light` and `dark` variant entries,\n * each keyed by theme name (`bootstrap`, `material`, `fluent`, `indigo`) and\n * an optional `shared` entry applied regardless of theme.\n * @param config - Optional configuration.\n * @param config.themeChange - Callback invoked on the host whenever the active theme changes.\n *\n * @returns The created {@link ThemingController} instance.\n *\n * @example\n * Minimal setup in a component constructor:\n * ```typescript\n * import { addThemingController } from '#theming/theming-controller.js';\n * import { all } from './themes/themes.js';\n *\n * export default class IgcMyComponent extends LitElement {\n * constructor() {\n * super();\n * addThemingController(this, all);\n * }\n * }\n * ```\n *\n * @example\n * With a `themeChange` callback and retained controller reference:\n * ```typescript\n * export default class IgcMyComponent extends LitElement {\n * private readonly _themingController = addThemingController(this, all, {\n * themeChange(theme) {\n * // Called on `this` (the host) whenever the theme switches\n * console.log(`Theme changed to: ${theme}`);\n * },\n * });\n *\n * protected override render() {\n * return html`<span>Current variant: ${this._themingController.variant}</span>`;\n * }\n * }\n * ```\n */\nexport function addThemingController(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n): ThemingController {\n return new ThemingController(host, themes, config);\n}\n\nexport type { ThemingController };\n"]}
|
|
1
|
+
{"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,WAAW,GAKZ,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAqB,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AA0BzD,MAAM,iBAAiB;IAgBrB,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAGD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAID,YACE,IAA8C,EAC9C,MAAc,EACd,MAAgC;QAvB1B,WAAM,GAAU,WAAW,CAAC;QAC5B,aAAQ,GAAiB,OAAO,CAAC;QACjC,iBAAY,GAAwB,eAAe,C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,QAAQ,EAAE,CAAC;QAE3C,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC;QAC7B,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACxC,CAAC;IAEO,WAAW,CAAC,KAAY,EAAE,OAAqB;QACrD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;IAC7B,CAAC;IAEO,YAAY;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAgC,CAAC;QACzD,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrE,WAAW,CACT,IAAI,CAAC,KAAK,CAAC,UAAW,EACtB,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CACtE,CAAC;IACJ,CAAC;CAGF;AAkDD,MAAM,UAAU,oBAAoB,CAClC,IAA8C,EAC9C,MAAc,EACd,MAAgC;IAEhC,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { ContextConsumer } from '@lit/context';\nimport {\n adoptStyles,\n type LitElement,\n type ReactiveController,\n type ReactiveControllerHost,\n type ReactiveElement,\n} from 'lit';\n\nimport { _themeChangedEmitter, getTheme } from './config.js';\nimport { type ThemeContext, themeContext } from './context.js';\nimport { CHANGED_THEME_EVENT } from './theming-event.js';\nimport type {\n Theme,\n Themes,\n ThemeVariant,\n ThemingControllerConfig,\n} from './types.js';\n\ntype ThemeProviderSource = 'uninitialized' | 'context' | 'global';\n\n/**\n * A reactive controller that manages theme adoption for a Lit host element.\n *\n * It resolves the active theme from one of two sources, in order of priority:\n *\n * 1. **Context** - provided by an ancestor theme provider component via the Lit context API.\n * 2. **Global** - the application-wide theme set via `configureTheme()`.\n *\n * When a context provider is present, the controller subscribes to its updates\n * and stops listening to global theme change events. When the host element is\n * disconnected and reconnected outside a provider, it automatically falls back\n * to the global theme.\n *\n * Theme styles are applied directly to the host's shadow root via `adoptStyles`\n * every time the active theme or variant changes.\n */\nclass ThemingController implements ReactiveController {\n //#region Internal state\n\n private readonly _host: ReactiveControllerHost & ReactiveElement;\n private readonly _themes: Themes;\n private readonly _options?: ThemingControllerConfig;\n\n private _theme: Theme = 'bootstrap';\n private _variant: ThemeVariant = 'light';\n private _themeSource: ThemeProviderSource = 'uninitialized';\n\n //#endregion\n\n //#region Public properties\n\n /** Gets the current theme. */\n public get theme(): Theme {\n return this._theme;\n }\n\n /** Gets the current theme variant. */\n public get variant(): ThemeVariant {\n return this._variant;\n }\n\n //#endregion\n\n constructor(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n ) {\n this._host = host;\n this._themes = themes;\n this._options = config;\n\n // Registered before this controller, so a connected provider answers its\n // context request before `hostConnected` below falls back to the global theme.\n new ContextConsumer(this._host, {\n context: themeContext,\n callback: (value) => {\n if (value) {\n this._applyContextTheme(value);\n }\n },\n subscribe: true,\n });\n\n this._host.addController(this);\n }\n\n //#region ReactiveController implementation\n\n /** @internal */\n public hostConnected(): void {\n if (this._themeSource === 'uninitialized') {\n _themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);\n this._applyGlobalTheme();\n }\n }\n\n /** @internal */\n public hostDisconnected(): void {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n\n // Re-resolve the theme source on reconnect, which may be in another part of the tree.\n this._themeSource = 'uninitialized';\n }\n\n //#endregion\n\n //#region Event handling\n\n /** @internal */\n public handleEvent(): void {\n if (this._themeSource === 'global') {\n this._applyGlobalTheme();\n }\n }\n\n //#endregion\n\n //#region Internal methods\n\n private _applyContextTheme({ theme, variant }: ThemeContext): void {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n this._themeSource = 'context';\n this._applyTheme(theme, variant);\n }\n\n private _applyGlobalTheme(): void {\n const { theme, themeVariant } = getTheme();\n\n this._themeSource = 'global';\n this._applyTheme(theme, themeVariant);\n }\n\n private _applyTheme(theme: Theme, variant: ThemeVariant): void {\n this._theme = theme;\n this._variant = variant;\n\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\n }\n\n private _adoptStyles(): void {\n const ctor = this._host.constructor as typeof LitElement;\n const { shared, [this._theme]: theme } = this._themes[this._variant];\n adoptStyles(\n this._host.shadowRoot!,\n [...ctor.elementStyles, shared, theme].filter((s) => s !== undefined)\n );\n }\n\n //#endregion\n}\n\n/**\n * Creates and attaches a {@link ThemingController} to the given host element.\n *\n * This is the preferred way to add theming support to a component. The controller\n * is registered with the host's reactive controller lifecycle and automatically\n * resolves the active theme from an ancestor theme provider context or\n * falls back to the application-wide theme set via `configureTheme()`.\n *\n * @param host - The Lit element that will host the controller.\n * @param themes - The theme styles map containing `light` and `dark` variant entries,\n * each keyed by theme name (`bootstrap`, `material`, `fluent`, `indigo`) and\n * an optional `shared` entry applied regardless of theme.\n * @param config - Optional configuration.\n * @param config.themeChange - Callback invoked on the host whenever the active theme changes.\n *\n * @returns The created {@link ThemingController} instance.\n *\n * @example\n * Minimal setup in a component constructor:\n * ```typescript\n * import { addThemingController } from '#theming/theming-controller.js';\n * import { all } from './themes/themes.js';\n *\n * export default class IgcMyComponent extends LitElement {\n * constructor() {\n * super();\n * addThemingController(this, all);\n * }\n * }\n * ```\n *\n * @example\n * With a `themeChange` callback and retained controller reference:\n * ```typescript\n * export default class IgcMyComponent extends LitElement {\n * private readonly _themingController = addThemingController(this, all, {\n * themeChange(theme) {\n * // Called on `this` (the host) whenever the theme switches\n * console.log(`Theme changed to: ${theme}`);\n * },\n * });\n *\n * protected override render() {\n * return html`<span>Current variant: ${this._themingController.variant}</span>`;\n * }\n * }\n * ```\n */\nexport function addThemingController(\n host: ReactiveControllerHost & ReactiveElement,\n themes: Themes,\n config?: ThemingControllerConfig\n): ThemingController {\n return new ThemingController(host, themes, config);\n}\n\nexport type { ThemingController };\n"]}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Theme, ThemeVariant } from './types.js';
|
|
2
|
-
declare class ThemeChangedEmitter extends EventTarget {
|
|
3
|
-
constructor();
|
|
4
|
-
/** @internal */
|
|
5
|
-
handleEvent(): void;
|
|
6
|
-
}
|
|
7
2
|
export declare const CHANGE_THEME_EVENT = "igc-change-theme";
|
|
8
3
|
export declare const CHANGED_THEME_EVENT = "igc-changed-theme";
|
|
9
|
-
export declare const _themeChangedEmitter: ThemeChangedEmitter;
|
|
10
4
|
declare global {
|
|
11
5
|
interface WindowEventMap {
|
|
12
6
|
[CHANGE_THEME_EVENT]: CustomEvent<ChangeThemeEventDetail>;
|
|
@@ -19,4 +13,3 @@ export type ChangeThemeEventDetail = {
|
|
|
19
13
|
theme: Theme;
|
|
20
14
|
themeVariant: ThemeVariant;
|
|
21
15
|
};
|
|
22
|
-
export {};
|
package/theming/theming-event.js
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import { isServer } from 'lit';
|
|
2
|
-
class ThemeChangedEmitter extends EventTarget {
|
|
3
|
-
constructor() {
|
|
4
|
-
super();
|
|
5
|
-
if (!isServer) {
|
|
6
|
-
globalThis.addEventListener(CHANGE_THEME_EVENT, this);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
handleEvent() {
|
|
10
|
-
this.dispatchEvent(new CustomEvent(CHANGED_THEME_EVENT));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
1
|
export const CHANGE_THEME_EVENT = 'igc-change-theme';
|
|
14
2
|
export const CHANGED_THEME_EVENT = 'igc-changed-theme';
|
|
15
|
-
export const _themeChangedEmitter = new ThemeChangedEmitter();
|
|
16
3
|
//# sourceMappingURL=theming-event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theming-event.js","sourceRoot":"","sources":["../../src/theming/theming-event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theming-event.js","sourceRoot":"","sources":["../../src/theming/theming-event.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC","sourcesContent":["import type { Theme, ThemeVariant } from './types.js';\n\nexport const CHANGE_THEME_EVENT = 'igc-change-theme';\nexport const CHANGED_THEME_EVENT = 'igc-changed-theme';\n\ndeclare global {\n interface WindowEventMap {\n [CHANGE_THEME_EVENT]: CustomEvent<ChangeThemeEventDetail>;\n }\n}\n\n/**\n * The possible details of the \"igc-change-theme\" event.\n */\nexport type ChangeThemeEventDetail = {\n theme: Theme;\n themeVariant: ThemeVariant;\n};\n"]}
|
package/theming/types.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { CSSResult } from 'lit';
|
|
2
2
|
export type Theme = 'material' | 'bootstrap' | 'indigo' | 'fluent';
|
|
3
3
|
export type ThemeVariant = 'light' | 'dark';
|
|
4
|
-
export type Themes =
|
|
5
|
-
light: {
|
|
6
|
-
[K in Theme | 'shared']?: CSSResult;
|
|
7
|
-
};
|
|
8
|
-
dark: {
|
|
9
|
-
[K in Theme | 'shared']?: CSSResult;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
4
|
+
export type Themes = Record<ThemeVariant, Partial<Record<Theme | 'shared', CSSResult>>>;
|
|
12
5
|
export type ThemeChangedCallback = (theme: Theme) => unknown;
|
|
13
6
|
export type ThemingControllerConfig = {
|
|
14
7
|
themeChange?: ThemeChangedCallback;
|
package/theming/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/theming/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CSSResult } from 'lit';\n\nexport type Theme = 'material' | 'bootstrap' | 'indigo' | 'fluent';\nexport type ThemeVariant = 'light' | 'dark';\n\nexport type Themes =
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/theming/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { CSSResult } from 'lit';\n\nexport type Theme = 'material' | 'bootstrap' | 'indigo' | 'fluent';\nexport type ThemeVariant = 'light' | 'dark';\n\nexport type Themes = Record<\n ThemeVariant,\n Partial<Record<Theme | 'shared', CSSResult>>\n>;\n\nexport type ThemeChangedCallback = (theme: Theme) => unknown;\nexport type ThemingControllerConfig = {\n themeChange?: ThemeChangedCallback;\n};\n"]}
|