igniteui-webcomponents 6.1.0 → 6.1.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 +8 -0
- package/components/accordion/accordion.js +3 -3
- package/components/accordion/accordion.js.map +1 -1
- package/components/avatar/avatar.d.ts +8 -9
- package/components/avatar/avatar.js +29 -32
- package/components/avatar/avatar.js.map +1 -1
- package/components/badge/badge.d.ts +3 -3
- package/components/badge/badge.js +15 -18
- package/components/badge/badge.js.map +1 -1
- package/components/banner/banner.d.ts +2 -3
- package/components/banner/banner.js +14 -13
- package/components/banner/banner.js.map +1 -1
- package/components/button/button-base.d.ts +4 -11
- package/components/button/button-base.js +14 -15
- package/components/button/button-base.js.map +1 -1
- package/components/button/button.d.ts +1 -0
- package/components/button/button.js +9 -12
- package/components/button/button.js.map +1 -1
- package/components/button/icon-button.d.ts +3 -2
- package/components/button/icon-button.js +10 -13
- package/components/button/icon-button.js.map +1 -1
- package/components/button-group/button-group.js +8 -11
- package/components/button-group/button-group.js.map +1 -1
- package/components/button-group/toggle-button.d.ts +1 -6
- package/components/button-group/toggle-button.js +9 -11
- package/components/button-group/toggle-button.js.map +1 -1
- package/components/calendar/calendar.js +7 -10
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.js +6 -6
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/months-view/months-view.js +8 -8
- package/components/calendar/months-view/months-view.js.map +1 -1
- package/components/calendar/years-view/years-view.js +8 -8
- package/components/calendar/years-view/years-view.js.map +1 -1
- package/components/card/card.actions.d.ts +1 -0
- package/components/card/card.actions.js +10 -13
- package/components/card/card.actions.js.map +1 -1
- package/components/card/card.content.d.ts +1 -0
- package/components/card/card.content.js +9 -15
- package/components/card/card.content.js.map +1 -1
- package/components/card/card.d.ts +1 -0
- package/components/card/card.header.d.ts +1 -0
- package/components/card/card.header.js +9 -15
- package/components/card/card.header.js.map +1 -1
- package/components/card/card.js +11 -14
- package/components/card/card.js.map +1 -1
- package/components/card/card.media.js +1 -1
- package/components/card/card.media.js.map +1 -1
- package/components/carousel/carousel-indicator-container.d.ts +1 -0
- package/components/carousel/carousel-indicator-container.js +9 -18
- package/components/carousel/carousel-indicator-container.js.map +1 -1
- package/components/carousel/carousel-indicator.d.ts +5 -7
- package/components/carousel/carousel-indicator.js +19 -19
- package/components/carousel/carousel-indicator.js.map +1 -1
- package/components/carousel/carousel-slide.d.ts +2 -3
- package/components/carousel/carousel-slide.js +17 -11
- package/components/carousel/carousel-slide.js.map +1 -1
- package/components/carousel/carousel.d.ts +0 -1
- package/components/carousel/carousel.js +22 -21
- package/components/carousel/carousel.js.map +1 -1
- package/components/checkbox/checkbox-base.js.map +1 -1
- package/components/checkbox/checkbox.d.ts +1 -1
- package/components/checkbox/checkbox.js +11 -15
- package/components/checkbox/checkbox.js.map +1 -1
- package/components/checkbox/switch.d.ts +1 -0
- package/components/checkbox/switch.js +10 -19
- package/components/checkbox/switch.js.map +1 -1
- package/components/checkbox/validators.js.map +1 -1
- package/components/chip/chip.js +7 -10
- package/components/chip/chip.js.map +1 -1
- package/components/combo/combo-header.d.ts +1 -0
- package/components/combo/combo-header.js +9 -15
- package/components/combo/combo-header.js.map +1 -1
- package/components/combo/combo-item.d.ts +4 -5
- package/components/combo/combo-item.js +22 -23
- package/components/combo/combo-item.js.map +1 -1
- package/components/combo/combo.d.ts +1 -1
- package/components/combo/combo.js +16 -16
- package/components/combo/combo.js.map +1 -1
- package/components/common/abort-handler.d.ts +39 -0
- package/components/common/abort-handler.js +19 -0
- package/components/common/abort-handler.js.map +1 -0
- package/components/common/controllers/drag.d.ts +3 -2
- package/components/common/controllers/drag.js +7 -6
- package/components/common/controllers/drag.js.map +1 -1
- package/components/common/controllers/focus-ring.d.ts +1 -0
- package/components/common/controllers/focus-ring.js +5 -4
- package/components/common/controllers/focus-ring.js.map +1 -1
- package/components/common/controllers/gestures.d.ts +6 -2
- package/components/common/controllers/gestures.js +15 -11
- package/components/common/controllers/gestures.js.map +1 -1
- package/components/common/controllers/internals.d.ts +33 -0
- package/components/common/controllers/internals.js +25 -0
- package/components/common/controllers/internals.js.map +1 -0
- package/components/common/controllers/key-bindings.d.ts +1 -0
- package/components/common/controllers/key-bindings.js +6 -4
- package/components/common/controllers/key-bindings.js.map +1 -1
- package/components/common/controllers/mutation-observer.d.ts +25 -15
- package/components/common/controllers/mutation-observer.js +23 -12
- package/components/common/controllers/mutation-observer.js.map +1 -1
- package/components/common/controllers/resize-observer.js.map +1 -1
- package/components/common/controllers/root-click.d.ts +58 -13
- package/components/common/controllers/root-click.js +47 -35
- package/components/common/controllers/root-click.js.map +1 -1
- package/components/common/decorators/shadow-options.d.ts +10 -0
- package/components/common/decorators/shadow-options.js +10 -0
- package/components/common/decorators/shadow-options.js.map +1 -0
- package/components/common/definitions/defineAllComponents.js +12 -12
- package/components/common/definitions/defineAllComponents.js.map +1 -1
- package/components/common/mixins/alert.d.ts +1 -2
- package/components/common/mixins/alert.js +13 -9
- package/components/common/mixins/alert.js.map +1 -1
- package/components/common/mixins/combo-box.d.ts +2 -1
- package/components/common/mixins/combo-box.js +0 -2
- package/components/common/mixins/combo-box.js.map +1 -1
- package/components/common/mixins/forms/associated.js +2 -2
- package/components/common/mixins/forms/associated.js.map +1 -1
- package/components/common/mixins/option.d.ts +1 -2
- package/components/common/mixins/option.js +13 -11
- package/components/common/mixins/option.js.map +1 -1
- package/components/common/part-map.js +1 -1
- package/components/common/part-map.js.map +1 -1
- package/components/common/util.d.ts +9 -0
- package/components/common/util.js +9 -1
- package/components/common/util.js.map +1 -1
- package/components/date-picker/date-picker.d.ts +2 -7
- package/components/date-picker/date-picker.js +18 -19
- package/components/date-picker/date-picker.js.map +1 -1
- package/components/date-picker/validators.js.map +1 -1
- package/components/date-range-picker/date-range-picker.d.ts +3 -8
- package/components/date-range-picker/date-range-picker.js +16 -17
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-range-picker/predefined-ranges-area.d.ts +1 -0
- package/components/date-range-picker/predefined-ranges-area.js +10 -13
- package/components/date-range-picker/predefined-ranges-area.js.map +1 -1
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/date-time-input/validators.js.map +1 -1
- package/components/dialog/dialog.d.ts +1 -0
- package/components/dialog/dialog.js +13 -13
- package/components/dialog/dialog.js.map +1 -1
- package/components/divider/divider.d.ts +5 -2
- package/components/divider/divider.js +17 -18
- package/components/divider/divider.js.map +1 -1
- package/components/dropdown/dropdown-group.d.ts +0 -1
- package/components/dropdown/dropdown-group.js +13 -12
- package/components/dropdown/dropdown-group.js.map +1 -1
- package/components/dropdown/dropdown-header.d.ts +1 -0
- package/components/dropdown/dropdown-header.js +9 -15
- package/components/dropdown/dropdown-header.js.map +1 -1
- package/components/dropdown/dropdown-item.d.ts +1 -0
- package/components/dropdown/dropdown-item.js +8 -14
- package/components/dropdown/dropdown-item.js.map +1 -1
- package/components/dropdown/dropdown.d.ts +2 -1
- package/components/dropdown/dropdown.js +7 -4
- package/components/dropdown/dropdown.js.map +1 -1
- package/components/dropdown/themes/item.js +7 -0
- package/components/dropdown/themes/item.js.map +1 -1
- package/components/dropdown/themes/shared/item/dropdown-item.bootstrap.css.d.ts +1 -0
- package/components/dropdown/themes/shared/item/dropdown-item.bootstrap.css.js +3 -0
- package/components/dropdown/themes/shared/item/dropdown-item.bootstrap.css.js.map +1 -0
- package/components/expansion-panel/expansion-panel.js +8 -11
- package/components/expansion-panel/expansion-panel.js.map +1 -1
- package/components/file-input/file-input.d.ts +1 -1
- package/components/file-input/file-input.js +18 -21
- package/components/file-input/file-input.js.map +1 -1
- package/components/file-input/themes/shared/file-input.material.css.js +1 -1
- package/components/file-input/themes/shared/file-input.material.css.js.map +1 -1
- package/components/file-input/validators.js.map +1 -1
- package/components/focus-trap/focus-trap.js +4 -4
- package/components/focus-trap/focus-trap.js.map +1 -1
- package/components/icon/icon.d.ts +2 -1
- package/components/icon/icon.js +18 -15
- package/components/icon/icon.js.map +1 -1
- package/components/input/input-base.d.ts +2 -8
- package/components/input/input-base.js +8 -11
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.js.map +1 -1
- package/components/input/themes/shared/input.material.css.js +1 -1
- package/components/input/themes/shared/input.material.css.js.map +1 -1
- package/components/input/validators.js.map +1 -1
- package/components/list/list-header.d.ts +0 -1
- package/components/list/list-header.js +10 -17
- package/components/list/list-header.js.map +1 -1
- package/components/list/list-item.d.ts +0 -1
- package/components/list/list-item.js +13 -12
- package/components/list/list-item.js.map +1 -1
- package/components/list/list.d.ts +0 -1
- package/components/list/list.js +12 -17
- package/components/list/list.js.map +1 -1
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/mask-input/validators.js.map +1 -1
- package/components/nav-drawer/nav-drawer-header-item.d.ts +1 -0
- package/components/nav-drawer/nav-drawer-header-item.js +9 -15
- package/components/nav-drawer/nav-drawer-header-item.js.map +1 -1
- package/components/nav-drawer/nav-drawer-item.d.ts +1 -0
- package/components/nav-drawer/nav-drawer-item.js +10 -13
- package/components/nav-drawer/nav-drawer-item.js.map +1 -1
- package/components/nav-drawer/nav-drawer.d.ts +1 -0
- package/components/nav-drawer/nav-drawer.js +10 -13
- package/components/nav-drawer/nav-drawer.js.map +1 -1
- package/components/navbar/navbar.d.ts +1 -0
- package/components/navbar/navbar.js +9 -15
- package/components/navbar/navbar.js.map +1 -1
- package/components/popover/popover.js +1 -1
- package/components/popover/popover.js.map +1 -1
- package/components/progress/base.d.ts +1 -2
- package/components/progress/base.js +28 -26
- package/components/progress/base.js.map +1 -1
- package/components/progress/circular-progress.d.ts +1 -0
- package/components/progress/circular-progress.js +10 -13
- package/components/progress/circular-progress.js.map +1 -1
- package/components/progress/linear-progress.d.ts +1 -0
- package/components/progress/linear-progress.js +9 -12
- package/components/progress/linear-progress.js.map +1 -1
- package/components/radio/radio.js +8 -11
- package/components/radio/radio.js.map +1 -1
- package/components/radio/utils.js.map +1 -1
- package/components/radio-group/radio-group.d.ts +1 -1
- package/components/radio-group/radio-group.js +15 -17
- package/components/radio-group/radio-group.js.map +1 -1
- package/components/rating/rating-symbol.js +1 -1
- package/components/rating/rating-symbol.js.map +1 -1
- package/components/rating/rating.js +7 -10
- package/components/rating/rating.js.map +1 -1
- package/components/resize-container/resize-container.js +7 -10
- package/components/resize-container/resize-container.js.map +1 -1
- package/components/resize-container/resize-controller.d.ts +3 -2
- package/components/resize-container/resize-controller.js +6 -4
- package/components/resize-container/resize-controller.js.map +1 -1
- package/components/ripple/ripple.js +3 -2
- package/components/ripple/ripple.js.map +1 -1
- package/components/select/select-group.d.ts +1 -1
- package/components/select/select-group.js +15 -14
- package/components/select/select-group.js.map +1 -1
- package/components/select/select-header.d.ts +1 -0
- package/components/select/select-header.js +9 -15
- package/components/select/select-header.js.map +1 -1
- package/components/select/select-item.d.ts +1 -0
- package/components/select/select-item.js +9 -9
- package/components/select/select-item.js.map +1 -1
- package/components/select/select.d.ts +1 -0
- package/components/select/select.js +11 -8
- package/components/select/select.js.map +1 -1
- package/components/select/validators.js.map +1 -1
- package/components/slider/slider-base.js +8 -8
- package/components/slider/slider-base.js.map +1 -1
- package/components/slider/slider-label.js +1 -1
- package/components/slider/slider-label.js.map +1 -1
- package/components/slider/slider.js.map +1 -1
- package/components/snackbar/snackbar.d.ts +1 -0
- package/components/snackbar/snackbar.js +9 -12
- package/components/snackbar/snackbar.js.map +1 -1
- package/components/stepper/step.d.ts +1 -0
- package/components/stepper/step.js +10 -13
- package/components/stepper/step.js.map +1 -1
- package/components/stepper/stepper.js +10 -13
- package/components/stepper/stepper.js.map +1 -1
- package/components/tabs/tab.d.ts +1 -0
- package/components/tabs/tab.js +12 -15
- package/components/tabs/tab.js.map +1 -1
- package/components/tabs/tabs.js +10 -13
- package/components/tabs/tabs.js.map +1 -1
- package/components/textarea/textarea.d.ts +2 -8
- package/components/textarea/textarea.js +11 -14
- package/components/textarea/textarea.js.map +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js +1 -1
- package/components/textarea/themes/shared/textarea.material.css.js.map +1 -1
- package/components/textarea/validators.js.map +1 -1
- package/components/tile-manager/position.d.ts +1 -1
- package/components/tile-manager/position.js.map +1 -1
- package/components/tile-manager/themes/container.js.map +1 -1
- package/components/tile-manager/tile-manager.d.ts +0 -1
- package/components/tile-manager/tile-manager.js +5 -7
- package/components/tile-manager/tile-manager.js.map +1 -1
- package/components/tile-manager/tile.d.ts +1 -0
- package/components/tile-manager/tile.js +54 -57
- package/components/tile-manager/tile.js.map +1 -1
- package/components/toast/toast.d.ts +1 -0
- package/components/toast/toast.js +8 -17
- package/components/toast/toast.js.map +1 -1
- package/components/tooltip/controller.d.ts +2 -4
- package/components/tooltip/controller.js +11 -20
- package/components/tooltip/controller.js.map +1 -1
- package/components/tooltip/themes/themes.js +1 -1
- package/components/tooltip/themes/themes.js.map +1 -1
- package/components/tooltip/tooltip.js +17 -16
- package/components/tooltip/tooltip.js.map +1 -1
- package/components/tree/tree-item.d.ts +1 -0
- package/components/tree/tree-item.js +30 -33
- package/components/tree/tree-item.js.map +1 -1
- package/components/tree/tree.d.ts +1 -1
- package/components/tree/tree.js +6 -5
- package/components/tree/tree.js.map +1 -1
- package/components/tree/tree.navigation.d.ts +1 -1
- package/components/tree/tree.navigation.js.map +1 -1
- package/components/tree/tree.selection.d.ts +1 -1
- package/components/tree/tree.selection.js.map +1 -1
- package/components/validation-container/themes/themes.js.map +1 -1
- package/components/validation-container/validation-container.d.ts +2 -1
- package/components/validation-container/validation-container.js +13 -16
- package/components/validation-container/validation-container.js.map +1 -1
- package/custom-elements.json +1641 -1753
- package/igniteui-webcomponents.html-data.json +1 -1
- package/package.json +1 -1
- package/theming/config.d.ts +3 -3
- package/theming/config.js +14 -18
- package/theming/config.js.map +1 -1
- package/theming/theming-controller.d.ts +17 -13
- package/theming/theming-controller.js +29 -23
- package/theming/theming-controller.js.map +1 -1
- package/theming/theming-event.d.ts +1 -0
- package/theming/theming-event.js.map +1 -1
- package/theming/types.d.ts +3 -14
- package/theming/types.js.map +1 -1
- package/theming/utils.js +24 -23
- package/theming/utils.js.map +1 -1
- package/web-types.json +1 -1
- package/theming/theming-decorator.d.ts +0 -43
- package/theming/theming-decorator.js +0 -25
- package/theming/theming-decorator.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "igniteui-webcomponents",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "Ignite UI for Web Components is a complete library of UI components, giving you the ability to build modern web applications using encapsulation and the concept of reusable components in a dependency-free approach.",
|
|
5
5
|
"author": "Infragistics",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
package/theming/config.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Theme, ThemeVariant } from './types.js';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function getTheme(): {
|
|
3
3
|
theme: Theme;
|
|
4
4
|
themeVariant: ThemeVariant;
|
|
5
5
|
};
|
|
6
|
-
export declare
|
|
6
|
+
export declare function setTheme(value: Theme, variant: ThemeVariant): void;
|
|
7
7
|
/**
|
|
8
8
|
* Allows the global configuration of the active theme.
|
|
9
9
|
*
|
|
@@ -14,4 +14,4 @@ export declare const setTheme: (value: Theme, variant: ThemeVariant) => void;
|
|
|
14
14
|
* configureTheme('material', 'light');
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export declare
|
|
17
|
+
export declare function configureTheme(t: Theme, v?: ThemeVariant): void;
|
package/theming/config.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isServer } from 'lit';
|
|
2
2
|
import { CHANGE_THEME_EVENT, } from './theming-event.js';
|
|
3
3
|
import { getAllCssVariables } from './utils.js';
|
|
4
4
|
let theme;
|
|
5
5
|
let themeVariant;
|
|
6
6
|
function dispatchThemingEvent(detail) {
|
|
7
|
-
if (
|
|
7
|
+
if (!isServer) {
|
|
8
8
|
globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, { detail }));
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -14,28 +14,24 @@ function isOfTypeTheme(theme) {
|
|
|
14
14
|
function isOfTypeThemeVariant(variant) {
|
|
15
15
|
return ['light', 'dark'].includes(variant);
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export function getTheme() {
|
|
18
18
|
if (!(theme && themeVariant)) {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
themeVariant =
|
|
25
|
-
_variant?.[1] && isOfTypeThemeVariant(_variant[1])
|
|
26
|
-
? _variant[1]
|
|
27
|
-
: 'light';
|
|
19
|
+
const cssVars = getAllCssVariables();
|
|
20
|
+
const foundTheme = cssVars.igTheme;
|
|
21
|
+
const foundVariant = cssVars.igThemeVariant;
|
|
22
|
+
theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';
|
|
23
|
+
themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';
|
|
28
24
|
}
|
|
29
25
|
return { theme, themeVariant };
|
|
30
|
-
}
|
|
31
|
-
export
|
|
26
|
+
}
|
|
27
|
+
export function setTheme(value, variant) {
|
|
32
28
|
theme = value;
|
|
33
29
|
themeVariant = variant;
|
|
34
|
-
}
|
|
35
|
-
export
|
|
30
|
+
}
|
|
31
|
+
export function configureTheme(t, v = 'light') {
|
|
36
32
|
if (isOfTypeTheme(t) && isOfTypeThemeVariant(v)) {
|
|
37
33
|
setTheme(t, v);
|
|
34
|
+
dispatchThemingEvent({ theme, themeVariant });
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
};
|
|
36
|
+
}
|
|
41
37
|
//# 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,
|
|
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,GAEnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,IAAI,KAAY,CAAC;AACjB,IAAI,YAA0B,CAAC;AAK/B,SAAS,oBAAoB,CAAC,MAA8B;IAC1D,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,UAAU,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,kBAAkB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,oBAAoB,CAAC,OAAe;IAC3C,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,IAAI,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;QACrC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;QACnC,MAAM,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC;QAE5C,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,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;AAED,MAAM,UAAU,QAAQ,CAAC,KAAY,EAAE,OAAqB;IAC1D,KAAK,GAAG,KAAK,CAAC;IACd,YAAY,GAAG,OAAO,CAAC;AACzB,CAAC;AAYD,MAAM,UAAU,cAAc,CAAC,CAAQ,EAAE,IAAkB,OAAO;IAChE,IAAI,aAAa,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACf,oBAAoB,CAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;IAChD,CAAC;AACH,CAAC","sourcesContent":["import { isServer } from 'lit';\nimport {\n CHANGE_THEME_EVENT,\n type ChangeThemeEventDetail,\n} from './theming-event.js';\nimport type { Theme, ThemeVariant } from './types.js';\nimport { getAllCssVariables } from './utils.js';\n\nlet theme: Theme;\nlet themeVariant: ThemeVariant;\n\n/**\n * Dispatch an \"igc-change-theme\" event to `window` with the given detail.\n */\nfunction dispatchThemingEvent(detail: ChangeThemeEventDetail): void {\n if (!isServer) {\n globalThis.dispatchEvent(new CustomEvent(CHANGE_THEME_EVENT, { detail }));\n }\n}\n\nfunction isOfTypeTheme(theme: string): theme is Theme {\n return ['bootstrap', 'material', 'indigo', 'fluent'].includes(theme);\n}\n\nfunction isOfTypeThemeVariant(variant: string): variant is ThemeVariant {\n return ['light', 'dark'].includes(variant);\n}\n\nexport function getTheme() {\n if (!(theme && themeVariant)) {\n const cssVars = getAllCssVariables();\n const foundTheme = cssVars.igTheme;\n const foundVariant = cssVars.igThemeVariant;\n\n theme = isOfTypeTheme(foundTheme) ? foundTheme : 'bootstrap';\n themeVariant = isOfTypeThemeVariant(foundVariant) ? foundVariant : 'light';\n }\n\n return { theme, themeVariant };\n}\n\nexport function setTheme(value: Theme, variant: ThemeVariant): void {\n theme = value;\n themeVariant = variant;\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 setTheme(t, v);\n dispatchThemingEvent({ theme, themeVariant });\n }\n}\n"]}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { type ReactiveController, type ReactiveControllerHost, type ReactiveElement } from 'lit';
|
|
2
|
-
import type { Theme,
|
|
3
|
-
declare class ThemingController implements ReactiveController
|
|
4
|
-
private
|
|
5
|
-
private
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import type { Theme, Themes, ThemingControllerConfig } from './types.js';
|
|
3
|
+
declare class ThemingController implements ReactiveController {
|
|
4
|
+
private readonly _host;
|
|
5
|
+
private readonly _themes;
|
|
6
|
+
private readonly _options?;
|
|
7
|
+
private _theme;
|
|
8
|
+
private _variant;
|
|
9
|
+
get theme(): Theme;
|
|
10
|
+
constructor(host: ReactiveControllerHost & ReactiveElement, themes: Themes, config?: ThemingControllerConfig);
|
|
11
|
+
/** @internal */
|
|
10
12
|
hostConnected(): void;
|
|
13
|
+
/** @internal */
|
|
11
14
|
hostDisconnected(): void;
|
|
15
|
+
/** @internal */
|
|
12
16
|
handleEvent(): void;
|
|
13
|
-
private
|
|
14
|
-
protected
|
|
15
|
-
private
|
|
17
|
+
private _getStyles;
|
|
18
|
+
protected _adoptStyles(): void;
|
|
19
|
+
private _handleThemeChanged;
|
|
16
20
|
}
|
|
17
|
-
export declare function
|
|
18
|
-
export {};
|
|
21
|
+
export declare function addThemingController(host: ReactiveControllerHost & ReactiveElement, themes: Themes, config?: ThemingControllerConfig): ThemingController;
|
|
22
|
+
export type { ThemingController };
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { adoptStyles, css, } from 'lit';
|
|
2
2
|
import { getTheme } from './config.js';
|
|
3
|
-
import {
|
|
3
|
+
import { _themeChangedEmitter, CHANGED_THEME_EVENT } from './theming-event.js';
|
|
4
4
|
class ThemingController {
|
|
5
|
-
|
|
6
|
-
this.
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
get theme() {
|
|
6
|
+
return this._theme;
|
|
7
|
+
}
|
|
8
|
+
constructor(host, themes, config) {
|
|
9
|
+
this._theme = 'bootstrap';
|
|
10
|
+
this._variant = 'light';
|
|
11
|
+
this._host = host;
|
|
12
|
+
this._themes = themes;
|
|
13
|
+
this._options = config;
|
|
14
|
+
this._host.addController(this);
|
|
9
15
|
}
|
|
10
16
|
hostConnected() {
|
|
11
|
-
this.
|
|
17
|
+
this._handleThemeChanged();
|
|
12
18
|
_themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);
|
|
13
19
|
}
|
|
14
20
|
hostDisconnected() {
|
|
15
21
|
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
16
22
|
}
|
|
17
23
|
handleEvent() {
|
|
18
|
-
this.
|
|
24
|
+
this._handleThemeChanged();
|
|
19
25
|
}
|
|
20
|
-
|
|
21
|
-
const
|
|
26
|
+
_getStyles() {
|
|
27
|
+
const props = this._themes[this._variant];
|
|
22
28
|
const styles = { shared: css ``, theme: css `` };
|
|
23
|
-
for (const [name, sheet] of
|
|
29
|
+
for (const [name, sheet] of Object.entries(props)) {
|
|
24
30
|
if (name === 'shared') {
|
|
25
31
|
styles.shared = sheet;
|
|
26
32
|
}
|
|
@@ -30,21 +36,21 @@ class ThemingController {
|
|
|
30
36
|
}
|
|
31
37
|
return styles;
|
|
32
38
|
}
|
|
33
|
-
|
|
34
|
-
const { theme, themeVariant } = getTheme();
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
const ctor = this.
|
|
38
|
-
const { shared, theme
|
|
39
|
-
adoptStyles(this.
|
|
39
|
+
_adoptStyles() {
|
|
40
|
+
const { theme: currentTheme, themeVariant } = getTheme();
|
|
41
|
+
this._theme = currentTheme;
|
|
42
|
+
this._variant = themeVariant;
|
|
43
|
+
const ctor = this._host.constructor;
|
|
44
|
+
const { shared, theme } = this._getStyles();
|
|
45
|
+
adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, shared, theme]);
|
|
40
46
|
}
|
|
41
|
-
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
47
|
+
_handleThemeChanged() {
|
|
48
|
+
this._adoptStyles();
|
|
49
|
+
this._options?.themeChange?.call(this._host, this._theme);
|
|
50
|
+
this._host.requestUpdate();
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
|
-
export function
|
|
48
|
-
return new ThemingController(host, themes);
|
|
53
|
+
export function addThemingController(host, themes, config) {
|
|
54
|
+
return new ThemingController(host, themes, config);
|
|
49
55
|
}
|
|
50
56
|
//# sourceMappingURL=theming-controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,GAAG,GAKJ,MAAM,KAAK,CAAC;AAEb,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQ/E,MAAM,iBAAiB;IAQrB,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,YACE,IAA8C,EAC9C,MAAc,EACd,MAAgC;QAV1B,WAAM,GAAU,WAAW,CAAC;QAC5B,aAAQ,GAAiB,OAAO,CAAC;QAWvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAGM,aAAa;QAClB,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC3B,oBAAoB,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAGM,gBAAgB;QACrB,oBAAoB,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC;IAGM,WAAW;QAChB,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;IAEO,UAAU;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,GAAG,CAAA,EAAE,EAAE,KAAK,EAAE,GAAG,CAAA,EAAE,EAAE,CAAC;QAE/C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtB,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;YACxB,CAAC;YACD,IAAI,IAAI,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC;gBACxB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,YAAY;QACpB,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,CAAC;QACzD,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC;QAE7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAgC,CAAC;QACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAE5C,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,UAAW,EAAE,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,mBAAmB;QACzB,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;CACF;AAED,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 {\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 { _themeChangedEmitter, CHANGED_THEME_EVENT } from './theming-event.js';\nimport type {\n Theme,\n Themes,\n ThemeVariant,\n ThemingControllerConfig,\n} from './types.js';\n\nclass ThemingController implements ReactiveController {\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\n public get theme(): Theme {\n return this._theme;\n }\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 this._host.addController(this);\n }\n\n /** @internal */\n public hostConnected(): void {\n this._handleThemeChanged();\n _themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);\n }\n\n /** @internal */\n public hostDisconnected(): void {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n }\n\n /** @internal */\n public handleEvent(): void {\n this._handleThemeChanged();\n }\n\n private _getStyles() {\n const props = this._themes[this._variant];\n const styles = { shared: css``, theme: css`` };\n\n for (const [name, sheet] of Object.entries(props)) {\n if (name === 'shared') {\n styles.shared = sheet;\n }\n if (name === this.theme) {\n styles.theme = sheet;\n }\n }\n\n return styles;\n }\n\n protected _adoptStyles(): void {\n const { theme: currentTheme, themeVariant } = getTheme();\n this._theme = currentTheme;\n this._variant = themeVariant;\n\n const ctor = this._host.constructor as typeof LitElement;\n const { shared, theme } = this._getStyles();\n\n adoptStyles(this._host.shadowRoot!, [...ctor.elementStyles, shared, theme]);\n }\n\n private _handleThemeChanged(): void {\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theming-event.js","sourceRoot":"","sources":["../../src/theming/theming-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG/B,MAAM,mBAAoB,SAAQ,WAAW;IAC3C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;
|
|
1
|
+
{"version":3,"file":"theming-event.js","sourceRoot":"","sources":["../../src/theming/theming-event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAG/B,MAAM,mBAAoB,SAAQ,WAAW;IAC3C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,UAAU,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;IAGM,WAAW;QAChB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AACrD,MAAM,CAAC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AACvD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,mBAAmB,EAAE,CAAC","sourcesContent":["import { isServer } from 'lit';\nimport type { Theme, ThemeVariant } from './types.js';\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(): void {\n this.dispatchEvent(new CustomEvent(CHANGED_THEME_EVENT));\n }\n}\n\nexport const CHANGE_THEME_EVENT = 'igc-change-theme';\nexport const CHANGED_THEME_EVENT = 'igc-changed-theme';\nexport const _themeChangedEmitter = new ThemeChangedEmitter();\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
|
@@ -10,17 +10,6 @@ export type Themes = {
|
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
12
|
export type ThemeChangedCallback = (theme: Theme) => unknown;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
17
|
-
export interface ThemeController {
|
|
18
|
-
/**
|
|
19
|
-
* The name of the currently adopted theme. See {@link Theme}.
|
|
20
|
-
*/
|
|
21
|
-
theme: Theme;
|
|
22
|
-
/**
|
|
23
|
-
* Optional callback function to invoke when the theme is changed at runtime.
|
|
24
|
-
*/
|
|
25
|
-
onThemeChanged?: ThemeChangedCallback;
|
|
26
|
-
}
|
|
13
|
+
export type ThemingControllerConfig = {
|
|
14
|
+
themeChange?: ThemeChangedCallback;
|
|
15
|
+
};
|
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 = {\n light: {\n [K in Theme | 'shared']?: CSSResult;\n };\n dark: {\n [K in Theme | 'shared']?: CSSResult;\n };\n};\n\nexport type ThemeChangedCallback = (theme: Theme) => unknown;\
|
|
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 = {\n light: {\n [K in Theme | 'shared']?: CSSResult;\n };\n dark: {\n [K in Theme | 'shared']?: CSSResult;\n };\n};\n\nexport type ThemeChangedCallback = (theme: Theme) => unknown;\nexport type ThemingControllerConfig = {\n themeChange?: ThemeChangedCallback;\n};\n"]}
|
package/theming/utils.js
CHANGED
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
import { isServer } from 'lit';
|
|
2
|
-
import { isDefined } from '../components/common/util.js';
|
|
3
2
|
function isStyleRule(rule) {
|
|
4
|
-
return
|
|
3
|
+
return rule != null && 'style' in rule;
|
|
5
4
|
}
|
|
6
5
|
function cssKeyToJsKey(key) {
|
|
7
|
-
return key.replace(
|
|
6
|
+
return key.replace(/^--|-./g, (match) => {
|
|
7
|
+
return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();
|
|
8
|
+
});
|
|
8
9
|
}
|
|
9
10
|
function getAllCssVariableNames() {
|
|
10
11
|
const cssVars = new Set();
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const styleSheets = Array.from(globalThis.document.styleSheets).filter((sheet) => {
|
|
12
|
+
const styleSheets = Array.from(document.styleSheets);
|
|
13
|
+
for (const sheet of styleSheets) {
|
|
14
|
+
let rules;
|
|
15
15
|
try {
|
|
16
|
-
|
|
16
|
+
rules = sheet.cssRules;
|
|
17
17
|
}
|
|
18
18
|
catch {
|
|
19
|
-
|
|
19
|
+
continue;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
for (const rule of rules) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
if (!rules) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
for (const rule of Array.from(rules)) {
|
|
25
|
+
if (isStyleRule(rule)) {
|
|
26
|
+
const length = rule.style.length;
|
|
27
|
+
for (let i = 0; i < length; i++) {
|
|
28
|
+
const style = rule.style[i];
|
|
29
|
+
if (style.startsWith('--')) {
|
|
30
|
+
cssVars.add(style);
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
|
-
}
|
|
33
|
+
}
|
|
30
34
|
}
|
|
31
35
|
}
|
|
32
36
|
return cssVars;
|
|
33
37
|
}
|
|
34
38
|
function getElementCssVariables(allCssVars, element, pseudo) {
|
|
35
39
|
const cssVars = {};
|
|
36
|
-
|
|
37
|
-
return cssVars;
|
|
38
|
-
}
|
|
39
|
-
const styles = globalThis.getComputedStyle(element, pseudo);
|
|
40
|
+
const styles = getComputedStyle(element, pseudo);
|
|
40
41
|
for (const key of allCssVars) {
|
|
41
42
|
const value = styles.getPropertyValue(key);
|
|
42
43
|
if (value) {
|
|
@@ -46,8 +47,8 @@ function getElementCssVariables(allCssVars, element, pseudo) {
|
|
|
46
47
|
return cssVars;
|
|
47
48
|
}
|
|
48
49
|
export function getAllCssVariables() {
|
|
49
|
-
return isServer
|
|
50
|
+
return isServer
|
|
50
51
|
? {}
|
|
51
|
-
: getElementCssVariables(getAllCssVariableNames(),
|
|
52
|
+
: getElementCssVariables(getAllCssVariableNames(), document.documentElement);
|
|
52
53
|
}
|
|
53
54
|
//# sourceMappingURL=utils.js.map
|
package/theming/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/theming/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/theming/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAE/B,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;AACzC,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACtC,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB;IAC7B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAClC,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAErD,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,IAAI,KAA8B,CAAC;QAGnC,IAAI,CAAC;YACH,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,SAAS;QACX,CAAC;QAED,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;gBACtB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;gBAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;oBAChC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAE5B,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;wBAC3B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;oBACrB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,sBAAsB,CAC7B,UAAuB,EACvB,OAAoB,EACpB,MAAe;IAEf,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAEjD,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAE3C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAEhC,OAAO,QAAQ;QACb,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,sBAAsB,CACpB,sBAAsB,EAAE,EACxB,QAAQ,CAAC,eAAe,CACzB,CAAC;AACR,CAAC","sourcesContent":["import { isServer } from 'lit';\n\nfunction isStyleRule(rule: CSSRule): rule is CSSStyleRule {\n return rule != null && 'style' in rule;\n}\n\nfunction cssKeyToJsKey(key: string): string {\n return key.replace(/^--|-./g, (match) => {\n return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();\n });\n}\n\nfunction getAllCssVariableNames(): Set<string> {\n const cssVars = new Set<string>();\n const styleSheets = Array.from(document.styleSheets);\n\n for (const sheet of styleSheets) {\n let rules: CSSRuleList | undefined;\n\n // Potential CORS or access errors\n try {\n rules = sheet.cssRules;\n } catch {\n continue;\n }\n\n if (!rules) {\n continue;\n }\n\n for (const rule of Array.from(rules)) {\n if (isStyleRule(rule)) {\n const length = rule.style.length;\n\n for (let i = 0; i < length; i++) {\n const style = rule.style[i];\n\n if (style.startsWith('--')) {\n cssVars.add(style);\n }\n }\n }\n }\n }\n\n return cssVars;\n}\n\nfunction getElementCssVariables(\n allCssVars: Set<string>,\n element: HTMLElement,\n pseudo?: string\n): Record<string, string> {\n const cssVars: Record<string, string> = {};\n const styles = getComputedStyle(element, pseudo);\n\n for (const key of allCssVars) {\n const value = styles.getPropertyValue(key);\n\n if (value) {\n cssVars[cssKeyToJsKey(key)] = value.trim();\n }\n }\n\n return cssVars;\n}\n\nexport function getAllCssVariables(): Record<string, string> {\n /* c8 ignore next 2 */\n return isServer\n ? {}\n : getElementCssVariables(\n getAllCssVariableNames(),\n document.documentElement\n );\n}\n"]}
|