igniteui-webcomponents 6.4.0 → 6.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/components/calendar/base.d.ts +7 -3
- package/components/calendar/base.js +10 -14
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.d.ts +48 -46
- package/components/calendar/calendar.js +259 -242
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +49 -27
- package/components/calendar/days-view/days-view.js +169 -160
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/helpers.js +40 -28
- package/components/calendar/helpers.js.map +1 -1
- package/components/calendar/model.d.ts +9 -3
- package/components/calendar/model.js +29 -19
- package/components/calendar/model.js.map +1 -1
- package/components/calendar/months-view/months-view.d.ts +6 -7
- package/components/calendar/months-view/months-view.js +24 -27
- package/components/calendar/months-view/months-view.js.map +1 -1
- package/components/calendar/years-view/years-view.d.ts +6 -5
- package/components/calendar/years-view/years-view.js +11 -14
- package/components/calendar/years-view/years-view.js.map +1 -1
- package/components/checkbox/checkbox-base.d.ts +1 -1
- package/components/chip/themes/dark/chip.fluent.css.js +1 -1
- package/components/chip/themes/dark/chip.fluent.css.js.map +1 -1
- package/components/chip/themes/dark/chip.indigo.css.js +1 -1
- package/components/chip/themes/dark/chip.indigo.css.js.map +1 -1
- package/components/chip/themes/light/chip.fluent.css.js +1 -1
- package/components/chip/themes/light/chip.fluent.css.js.map +1 -1
- package/components/chip/themes/light/chip.indigo.css.js +1 -1
- package/components/chip/themes/light/chip.indigo.css.js.map +1 -1
- package/components/chip/themes/light/chip.shared.css.js +1 -1
- package/components/chip/themes/light/chip.shared.css.js.map +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
- package/components/common/definitions/defineAllComponents.js +2 -0
- package/components/common/definitions/defineAllComponents.js.map +1 -1
- package/components/date-range-picker/date-range-picker.js +1 -1
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-time-input/date-time-input.d.ts +4 -1
- package/components/date-time-input/date-time-input.js +17 -6
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/file-input/file-input.d.ts +15 -13
- package/components/file-input/file-input.js +49 -47
- package/components/file-input/file-input.js.map +1 -1
- package/components/input/input-base.d.ts +31 -34
- package/components/input/input-base.js +58 -83
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.d.ts +18 -7
- package/components/input/input.js +34 -19
- package/components/input/input.js.map +1 -1
- package/components/mask-input/mask-input-base.d.ts +10 -4
- package/components/mask-input/mask-input-base.js +18 -14
- package/components/mask-input/mask-input-base.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +9 -3
- package/components/mask-input/mask-input.js +26 -6
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/mask-input/validators.js +1 -1
- package/components/mask-input/validators.js.map +1 -1
- package/components/theme-provider/theme-provider.d.ts +65 -0
- package/components/theme-provider/theme-provider.js +58 -0
- package/components/theme-provider/theme-provider.js.map +1 -0
- package/components/tile-manager/tile.js +6 -3
- package/components/tile-manager/tile.js.map +1 -1
- package/custom-elements.json +2136 -1596
- package/extras/chat-markdown-renderer.d.ts +72 -4
- package/extras/chat-markdown-renderer.js +19 -7
- package/extras/chat-markdown-renderer.js.map +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dark/bootstrap.css +1 -1
- package/themes/dark/fluent.css +1 -1
- package/themes/dark/indigo.css +1 -1
- package/themes/dark/material.css +1 -1
- package/themes/light/bootstrap.css +1 -1
- package/themes/light/fluent.css +1 -1
- package/themes/light/indigo.css +1 -1
- package/themes/light/material.css +1 -1
- package/theming/context.d.ts +36 -0
- package/theming/context.js +3 -0
- package/theming/context.js.map +1 -0
- package/theming/theming-controller.d.ts +7 -1
- package/theming/theming-controller.js +48 -12
- package/theming/theming-controller.js.map +1 -1
- package/theming/utils.d.ts +10 -0
- package/theming/utils.js +8 -42
- package/theming/utils.js.map +1 -1
- package/web-types.json +1 -1
|
@@ -4,8 +4,10 @@ declare class ThemingController implements ReactiveController {
|
|
|
4
4
|
private readonly _host;
|
|
5
5
|
private readonly _themes;
|
|
6
6
|
private readonly _options?;
|
|
7
|
+
private readonly _contextConsumer;
|
|
7
8
|
private _theme;
|
|
8
9
|
private _variant;
|
|
10
|
+
private _themeSource;
|
|
9
11
|
get theme(): Theme;
|
|
10
12
|
constructor(host: ReactiveControllerHost & ReactiveElement, themes: Themes, config?: ThemingControllerConfig);
|
|
11
13
|
/** @internal */
|
|
@@ -14,9 +16,13 @@ declare class ThemingController implements ReactiveController {
|
|
|
14
16
|
hostDisconnected(): void;
|
|
15
17
|
/** @internal */
|
|
16
18
|
handleEvent(): void;
|
|
19
|
+
private _applyContextTheme;
|
|
20
|
+
private _applyGlobalTheme;
|
|
17
21
|
private _getStyles;
|
|
18
22
|
protected _adoptStyles(): void;
|
|
19
|
-
private _handleThemeChanged;
|
|
20
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Adds theming controller to the host component.
|
|
26
|
+
*/
|
|
21
27
|
export declare function addThemingController(host: ReactiveControllerHost & ReactiveElement, themes: Themes, config?: ThemingControllerConfig): ThemingController;
|
|
22
28
|
export type { ThemingController };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { ContextConsumer } from '@lit/context';
|
|
1
2
|
import { adoptStyles, css, } from 'lit';
|
|
2
3
|
import { getTheme } from './config.js';
|
|
4
|
+
import { themeContext } from './context.js';
|
|
3
5
|
import { _themeChangedEmitter, CHANGED_THEME_EVENT } from './theming-event.js';
|
|
4
6
|
class ThemingController {
|
|
5
7
|
get theme() {
|
|
@@ -8,20 +10,62 @@ class ThemingController {
|
|
|
8
10
|
constructor(host, themes, config) {
|
|
9
11
|
this._theme = 'bootstrap';
|
|
10
12
|
this._variant = 'light';
|
|
13
|
+
this._themeSource = 'uninitialized';
|
|
11
14
|
this._host = host;
|
|
12
15
|
this._themes = themes;
|
|
13
16
|
this._options = config;
|
|
14
17
|
this._host.addController(this);
|
|
18
|
+
this._contextConsumer = new ContextConsumer(this._host, {
|
|
19
|
+
context: themeContext,
|
|
20
|
+
callback: (value) => {
|
|
21
|
+
if (value) {
|
|
22
|
+
this._applyContextTheme(value);
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
subscribe: true,
|
|
26
|
+
});
|
|
15
27
|
}
|
|
16
28
|
hostConnected() {
|
|
17
|
-
this.
|
|
18
|
-
|
|
29
|
+
const contextValue = this._contextConsumer.value;
|
|
30
|
+
if (contextValue) {
|
|
31
|
+
this._applyContextTheme(contextValue);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this._applyGlobalTheme();
|
|
35
|
+
}
|
|
19
36
|
}
|
|
20
37
|
hostDisconnected() {
|
|
21
|
-
|
|
38
|
+
if (this._themeSource === 'global') {
|
|
39
|
+
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
40
|
+
}
|
|
22
41
|
}
|
|
23
42
|
handleEvent() {
|
|
24
|
-
this.
|
|
43
|
+
if (this._themeSource === 'global') {
|
|
44
|
+
this._applyGlobalTheme();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
_applyContextTheme(contextValue) {
|
|
48
|
+
if (this._themeSource === 'global') {
|
|
49
|
+
_themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);
|
|
50
|
+
}
|
|
51
|
+
this._themeSource = 'context';
|
|
52
|
+
this._theme = contextValue.theme;
|
|
53
|
+
this._variant = contextValue.variant;
|
|
54
|
+
this._adoptStyles();
|
|
55
|
+
this._options?.themeChange?.call(this._host, this._theme);
|
|
56
|
+
this._host.requestUpdate();
|
|
57
|
+
}
|
|
58
|
+
_applyGlobalTheme() {
|
|
59
|
+
if (this._themeSource === 'uninitialized') {
|
|
60
|
+
_themeChangedEmitter.addEventListener(CHANGED_THEME_EVENT, this);
|
|
61
|
+
}
|
|
62
|
+
this._themeSource = 'global';
|
|
63
|
+
const { theme: currentTheme, themeVariant } = getTheme();
|
|
64
|
+
this._theme = currentTheme;
|
|
65
|
+
this._variant = themeVariant;
|
|
66
|
+
this._adoptStyles();
|
|
67
|
+
this._options?.themeChange?.call(this._host, this._theme);
|
|
68
|
+
this._host.requestUpdate();
|
|
25
69
|
}
|
|
26
70
|
_getStyles() {
|
|
27
71
|
const props = this._themes[this._variant];
|
|
@@ -37,18 +81,10 @@ class ThemingController {
|
|
|
37
81
|
return styles;
|
|
38
82
|
}
|
|
39
83
|
_adoptStyles() {
|
|
40
|
-
const { theme: currentTheme, themeVariant } = getTheme();
|
|
41
|
-
this._theme = currentTheme;
|
|
42
|
-
this._variant = themeVariant;
|
|
43
84
|
const ctor = this._host.constructor;
|
|
44
85
|
const { shared, theme } = this._getStyles();
|
|
45
86
|
adoptStyles(this._host.shadowRoot, [...ctor.elementStyles, shared, theme]);
|
|
46
87
|
}
|
|
47
|
-
_handleThemeChanged() {
|
|
48
|
-
this._adoptStyles();
|
|
49
|
-
this._options?.themeChange?.call(this._host, this._theme);
|
|
50
|
-
this._host.requestUpdate();
|
|
51
|
-
}
|
|
52
88
|
}
|
|
53
89
|
export function addThemingController(host, themes, config) {
|
|
54
90
|
return new ThemingController(host, themes, config);
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
1
|
+
{"version":3,"file":"theming-controller.js","sourceRoot":"","sources":["../../src/theming/theming-controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAA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,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,KAAK,CAAC,aAAa,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,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;CACF;AAKD,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\nclass ThemingController implements ReactiveController {\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 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 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 /** @internal */\n public hostConnected(): void {\n // Check if we have a context value immediately when connected usually after the parent provider\n // is already in the DOM (i.e. creation of the component after initial render)\n const contextValue = this._contextConsumer.value;\n\n if (contextValue) {\n this._applyContextTheme(contextValue);\n } else {\n this._applyGlobalTheme();\n }\n }\n\n /** @internal */\n public hostDisconnected(): void {\n if (this._themeSource === 'global') {\n _themeChangedEmitter.removeEventListener(CHANGED_THEME_EVENT, this);\n }\n }\n\n /** @internal */\n public handleEvent(): void {\n // Only handle global theme change events\n if (this._themeSource === 'global') {\n this._applyGlobalTheme();\n }\n }\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._theme = contextValue.theme;\n this._variant = contextValue.variant;\n\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\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 this._themeSource = 'global';\n\n const { theme: currentTheme, themeVariant } = getTheme();\n this._theme = currentTheme;\n this._variant = themeVariant;\n\n this._adoptStyles();\n this._options?.themeChange?.call(this._host, this._theme);\n this._host.requestUpdate();\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 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\n/**\n * Adds theming controller to the host component.\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"]}
|
package/theming/utils.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves all CSS custom properties from the document root element.
|
|
3
|
+
* Property names are converted from kebab-case to camelCase.
|
|
4
|
+
*
|
|
5
|
+
* @returns An object mapping camelCase property names to their values.
|
|
6
|
+
* Returns an empty object in SSR environments.
|
|
7
|
+
* @example
|
|
8
|
+
* // CSS: --my-primary-color: #ff0000;
|
|
9
|
+
* // Returns: { myPrimaryColor: '#ff0000' }
|
|
10
|
+
*/
|
|
1
11
|
export declare function getAllCssVariables(): Record<string, string>;
|
package/theming/utils.js
CHANGED
|
@@ -1,54 +1,20 @@
|
|
|
1
1
|
import { isServer } from 'lit';
|
|
2
|
-
function isStyleRule(rule) {
|
|
3
|
-
return rule != null && 'style' in rule;
|
|
4
|
-
}
|
|
5
2
|
function cssKeyToJsKey(key) {
|
|
6
3
|
return key.replace(/^--|-./g, (match) => {
|
|
7
4
|
return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();
|
|
8
5
|
});
|
|
9
6
|
}
|
|
10
|
-
function
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
rules = sheet.cssRules;
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
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
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return cssVars;
|
|
37
|
-
}
|
|
38
|
-
function getElementCssVariables(allCssVars, element, pseudo) {
|
|
39
|
-
const cssVars = {};
|
|
40
|
-
const styles = getComputedStyle(element, pseudo);
|
|
41
|
-
for (const key of allCssVars) {
|
|
42
|
-
const value = styles.getPropertyValue(key);
|
|
43
|
-
if (value) {
|
|
44
|
-
cssVars[cssKeyToJsKey(key)] = value.trim();
|
|
7
|
+
function getCssVariables() {
|
|
8
|
+
const rootStyles = getComputedStyle(document.documentElement);
|
|
9
|
+
const result = {};
|
|
10
|
+
for (const key of Array.from(rootStyles)) {
|
|
11
|
+
if (key.startsWith('--')) {
|
|
12
|
+
result[cssKeyToJsKey(key)] = rootStyles.getPropertyValue(key).trim();
|
|
45
13
|
}
|
|
46
14
|
}
|
|
47
|
-
return
|
|
15
|
+
return result;
|
|
48
16
|
}
|
|
49
17
|
export function getAllCssVariables() {
|
|
50
|
-
return isServer
|
|
51
|
-
? {}
|
|
52
|
-
: getElementCssVariables(getAllCssVariableNames(), document.documentElement);
|
|
18
|
+
return isServer ? {} : getCssVariables();
|
|
53
19
|
}
|
|
54
20
|
//# 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;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/theming/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAQ/B,SAAS,aAAa,CAAC,GAAW;IAEhC,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,eAAe;IACtB,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QACzC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACvE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAYD,MAAM,UAAU,kBAAkB;IAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,eAAe,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import { isServer } from 'lit';\n\n/**\n * Converts a CSS custom property name to a camelCase JavaScript key.\n * Removes leading '--' and converts kebab-case to camelCase.\n * @param key - The CSS variable name (e.g., '--my-color')\n * @returns The JavaScript key (e.g., 'myColor')\n */\nfunction cssKeyToJsKey(key: string): string {\n // Regex: matches '--' at start OR '-x' pattern to convert to camelCase\n return key.replace(/^--|-./g, (match) => {\n return match.startsWith('--') ? '' : match.charAt(1).toUpperCase();\n });\n}\n\nfunction getCssVariables(): Record<string, string> {\n const rootStyles = getComputedStyle(document.documentElement);\n const result: Record<string, string> = {};\n\n for (const key of Array.from(rootStyles)) {\n if (key.startsWith('--')) {\n result[cssKeyToJsKey(key)] = rootStyles.getPropertyValue(key).trim();\n }\n }\n\n return result;\n}\n\n/**\n * Retrieves all CSS custom properties from the document root element.\n * Property names are converted from kebab-case to camelCase.\n *\n * @returns An object mapping camelCase property names to their values.\n * Returns an empty object in SSR environments.\n * @example\n * // CSS: --my-primary-color: #ff0000;\n * // Returns: { myPrimaryColor: '#ff0000' }\n */\nexport function getAllCssVariables(): Record<string, string> {\n return isServer ? {} : getCssVariables();\n}\n"]}
|