@kaizen/components 0.0.0-canary-cg-test-20231011234329 → 0.0.0-canary-cg-test-20231012014902
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/dist/cjs/KaizenProvider/KaizenProvider.cjs +2 -3
- package/dist/cjs/KaizenProvider/KaizenProvider.cjs.map +1 -1
- package/dist/cjs/KaizenProvider/ThemeProvider/ThemeProvider.cjs +10 -22
- package/dist/cjs/KaizenProvider/ThemeProvider/ThemeProvider.cjs.map +1 -1
- package/dist/cjs/KaizenProvider/ThemeProvider/useThemeManager.cjs +37 -0
- package/dist/cjs/KaizenProvider/ThemeProvider/useThemeManager.cjs.map +1 -0
- package/dist/cjs/dts/KaizenProvider/KaizenProvider.d.ts +4 -4
- package/dist/cjs/dts/KaizenProvider/ThemeProvider/ThemeProvider.d.ts +8 -7
- package/dist/cjs/dts/KaizenProvider/ThemeProvider/index.d.ts +0 -1
- package/dist/cjs/dts/KaizenProvider/ThemeProvider/useThemeManager.d.ts +6 -0
- package/dist/cjs/index.cjs +0 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.css +4 -4
- package/dist/esm/KaizenProvider/KaizenProvider.mjs +2 -3
- package/dist/esm/KaizenProvider/KaizenProvider.mjs.map +1 -1
- package/dist/esm/KaizenProvider/ThemeProvider/ThemeProvider.mjs +11 -23
- package/dist/esm/KaizenProvider/ThemeProvider/ThemeProvider.mjs.map +1 -1
- package/dist/esm/KaizenProvider/ThemeProvider/useThemeManager.mjs +35 -0
- package/dist/esm/KaizenProvider/ThemeProvider/useThemeManager.mjs.map +1 -0
- package/dist/esm/dts/KaizenProvider/KaizenProvider.d.ts +4 -4
- package/dist/esm/dts/KaizenProvider/ThemeProvider/ThemeProvider.d.ts +8 -7
- package/dist/esm/dts/KaizenProvider/ThemeProvider/index.d.ts +0 -1
- package/dist/esm/dts/KaizenProvider/ThemeProvider/useThemeManager.d.ts +6 -0
- package/dist/esm/index.css +1 -1
- package/dist/esm/index.mjs +0 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/index.d.ts +15 -41
- package/dist/styles.css +1 -1
- package/future/package.json +2 -2
- package/package.json +3 -3
- package/dist/cjs/KaizenProvider/ThemeProvider/ThemeManager.cjs +0 -88
- package/dist/cjs/KaizenProvider/ThemeProvider/ThemeManager.cjs.map +0 -1
- package/dist/cjs/dts/KaizenProvider/ThemeProvider/ThemeManager.d.ts +0 -25
- package/dist/esm/KaizenProvider/ThemeProvider/ThemeManager.mjs +0 -86
- package/dist/esm/KaizenProvider/ThemeProvider/ThemeManager.mjs.map +0 -1
- package/dist/esm/dts/KaizenProvider/ThemeProvider/ThemeManager.d.ts +0 -25
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
var React = require('react');
|
|
4
4
|
var OptionalIntlProvider = require('./OptionalIntlProvider/OptionalIntlProvider.cjs');
|
|
5
5
|
var ThemeProvider = require('./ThemeProvider/ThemeProvider.cjs');
|
|
6
|
-
require('@kaizen/design-tokens');
|
|
7
6
|
const KaizenProvider = /*#__PURE__*/function () {
|
|
8
7
|
const KaizenProvider = function (_a) {
|
|
9
8
|
var children = _a.children,
|
|
10
|
-
|
|
9
|
+
theme = _a.theme,
|
|
11
10
|
_b = _a.locale,
|
|
12
11
|
locale = _b === void 0 ? "en" : _b;
|
|
13
12
|
return React.createElement(OptionalIntlProvider.OptionalIntlProvider, {
|
|
14
13
|
locale: locale
|
|
15
14
|
}, React.createElement(ThemeProvider.ThemeProvider, {
|
|
16
|
-
|
|
15
|
+
theme: theme
|
|
17
16
|
}, children));
|
|
18
17
|
};
|
|
19
18
|
KaizenProvider.displayName = "KaizenProvider";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KaizenProvider.cjs","sources":["../../../src/KaizenProvider/KaizenProvider.tsx"],"sourcesContent":["import React from \"react\"\nimport { OptionalIntlProvider } from \"./OptionalIntlProvider\"\nimport { ThemeProvider
|
|
1
|
+
{"version":3,"file":"KaizenProvider.cjs","sources":["../../../src/KaizenProvider/KaizenProvider.tsx"],"sourcesContent":["import React from \"react\"\nimport { Theme as BaseTheme } from \"@kaizen/design-tokens\"\nimport { OptionalIntlProvider } from \"./OptionalIntlProvider\"\nimport { ThemeProvider } from \"./ThemeProvider\"\n\nexport type KaizenProviderProps<Theme extends BaseTheme = BaseTheme> = {\n children: React.ReactNode\n theme?: Theme\n locale?: string\n}\n\nexport const KaizenProvider = ({\n children,\n theme,\n locale = \"en\",\n}: KaizenProviderProps): JSX.Element => (\n <OptionalIntlProvider locale={locale}>\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </OptionalIntlProvider>\n)\n\nKaizenProvider.displayName = \"KaizenProvider\"\n"],"names":["KaizenProvider","_a","children","theme","_b","locale","React","createElement","OptionalIntlProvider","ThemeProvider","displayName"],"mappings":";;;;;MAWaA,cAAc;EAAA,MAAdA,cAAc,GAAG,SAAAA,CAACC,EAIT,EAAA;QAHpBC,QAAQ,GAAAD,EAAA,CAAAC,QAAA;MACRC,KAAK,GAAAF,EAAA,CAAAE,KAAA;MACLC,cAAa;MAAbC,MAAM,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,IAAI,GAAAA,EAAA;IACyB,OACtCE,KAAC,CAAAC,aAAA,CAAAC,oBAAoB,CAAAA,oBAAA,EAAC;MAAAH,MAAM,EAAEA;IAAM,CAAA,EAClCC,KAAC,CAAAC,aAAA,CAAAE,2BAAa;MAACN,KAAK,EAAEA;IAAQ,CAAA,EAAAD,QAAQ,CAAiB,CAClC;EAHe,CAIvC;EAEDF,cAAc,CAACU,WAAW,GAAG,gBAAgB;EAAA,OAVhCV,cAAc;AAAA;"}
|
|
@@ -2,33 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
-
var ThemeManager = require('./ThemeManager.cjs');
|
|
6
5
|
var index = require('./themes/index.cjs');
|
|
7
|
-
var
|
|
6
|
+
var useThemeManager = require('./useThemeManager.cjs');
|
|
7
|
+
var ThemeContext = React.createContext(null);
|
|
8
8
|
/**
|
|
9
9
|
* Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
|
|
10
10
|
* This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
|
|
11
11
|
*/
|
|
12
12
|
var ThemeProvider = function (_a) {
|
|
13
|
-
var
|
|
14
|
-
props = tslib.__rest(_a, ["
|
|
15
|
-
var
|
|
16
|
-
return themeManager || new ThemeManager.ThemeManager(index.defaultTheme);
|
|
17
|
-
})[0];
|
|
18
|
-
var _b = React.useState(themeManagerInstance.getCurrentTheme()),
|
|
19
|
-
theme = _b[0],
|
|
20
|
-
setTheme = _b[1];
|
|
21
|
-
React.useEffect(function () {
|
|
22
|
-
var cancelled = false;
|
|
23
|
-
var listener = function (newTheme) {
|
|
24
|
-
if (!cancelled) setTheme(newTheme);
|
|
25
|
-
};
|
|
26
|
-
themeManagerInstance.addThemeChangeListener(listener);
|
|
27
|
-
return function () {
|
|
28
|
-
cancelled = true;
|
|
29
|
-
themeManagerInstance.removeThemeChangeListener(listener);
|
|
30
|
-
};
|
|
31
|
-
}, []);
|
|
13
|
+
var userTheme = _a.theme,
|
|
14
|
+
props = tslib.__rest(_a, ["theme"]);
|
|
15
|
+
var theme = useThemeManager.useThemeManager(userTheme !== null && userTheme !== void 0 ? userTheme : index.defaultTheme).theme;
|
|
32
16
|
return React.createElement(React.Fragment, null, React.createElement(ThemeContext.Provider, {
|
|
33
17
|
value: theme
|
|
34
18
|
}, props.children), React.createElement("link", {
|
|
@@ -64,7 +48,11 @@ var ThemeProvider = function (_a) {
|
|
|
64
48
|
}));
|
|
65
49
|
};
|
|
66
50
|
var useTheme = function () {
|
|
67
|
-
|
|
51
|
+
var context = React.useContext(ThemeContext);
|
|
52
|
+
if (!context) {
|
|
53
|
+
throw new Error("useTheme must be used within the ThemeContext.Provider");
|
|
54
|
+
}
|
|
55
|
+
return context;
|
|
68
56
|
};
|
|
69
57
|
exports.ThemeContext = ThemeContext;
|
|
70
58
|
exports.ThemeProvider = ThemeProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.cjs","sources":["../../../../src/KaizenProvider/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"ThemeProvider.cjs","sources":["../../../../src/KaizenProvider/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\"\nimport { defaultTheme, Theme as BaseTheme } from \"./themes\"\nimport { useThemeManager } from \"./useThemeManager\"\n\n// We set the generic default value to `any` as SelectContext\n// is instantiated as a constant which does not accept generics.\ntype ThemeContextValue<Theme extends BaseTheme = any> = Theme\n\nexport const ThemeContext = createContext<ThemeContextValue | null>(null)\n\n/**\n * Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.\n * This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.\n */\nexport const ThemeProvider = <Theme extends BaseTheme = BaseTheme>({\n theme: userTheme,\n ...props\n}: {\n theme?: Theme\n children: React.ReactNode\n}): JSX.Element => {\n const { theme } = useThemeManager(userTheme ?? defaultTheme)\n\n return (\n <>\n <ThemeContext.Provider value={theme}>\n {props.children}\n </ThemeContext.Provider>\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n </>\n )\n}\n\nexport const useTheme = <\n Theme extends BaseTheme = BaseTheme,\n>(): ThemeContextValue<Theme> => {\n const context = useContext(ThemeContext)\n\n if (!context) {\n throw new Error(\"useTheme must be used within the ThemeContext.Provider\")\n }\n\n return context\n}\n"],"names":["ThemeContext","createContext","ThemeProvider","_a","userTheme","theme","props","__rest","useThemeManager","defaultTheme","React","createElement","Fragment","Provider","value","children","rel","href","as","type","crossOrigin","useTheme","context","useContext","Error"],"mappings":";;;;;;IAQaA,YAAY,GAAGC,KAAa,CAAAA,aAAA,CAA2B,IAAI,CAAC;AAEzE;;;AAGG;AACI,IAAMC,aAAa,GAAG,SAAAA,CAAsCC,EAMlE,EAAA;EALC,IAAOC,SAAS,GAAAD,EAAA,CAAAE,KAAA;IACbC,KAAK,GAAAC,KAAAA,CAAAA,MAAA,CAAAJ,EAAA,EAFyD,SAGlE,CADS;EAKA,IAAAE,KAAK,GAAKG,eAAAA,CAAAA,eAAe,CAACJ,SAAS,KAAA,IAAA,IAATA,SAAS,KAAA,KAAA,CAAA,GAATA,SAAS,GAAIK,kBAAY,CAAC,MAA/C;EAEb,OACEC,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EAAA,IAAA,EACEF,KAAC,CAAAC,aAAA,CAAAX,YAAY,CAACa,QAAQ,EAAC;IAAAC,KAAK,EAAET;EAAK,CAChC,EAAAC,KAAK,CAACS,QAAQ,CACO,EACxBL,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,oEAAoE;IACzEC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,EACFV,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,yEAAyE;IAC9EC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,EACFV,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,sEAAsE;IAC3EC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,EACFV,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,uEAAuE;IAC5EC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,EACFV,KACE,CAAAC,aAAA,CAAA,MAAA,EAAA;IAAAK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,iFAAiF;IACtFC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CAAA,CACvB,CACD;AAEP,CAAC;AAEY,IAAAC,QAAQ,GAAG,SAAAA,CAAA,EAAA;EAGtB,IAAMC,OAAO,GAAGC,gBAAU,CAACvB,YAAY,CAAC;EAExC,IAAI,CAACsB,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,wDAAwD,CAAC;EAC1E;EAED,OAAOF,OAAO;AAChB,CAAA;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var designTokens = require('@kaizen/design-tokens');
|
|
5
|
+
var useThemeManager = function (theme, rootElementId, apply) {
|
|
6
|
+
if (apply === void 0) {
|
|
7
|
+
apply = true;
|
|
8
|
+
}
|
|
9
|
+
var _a = React.useState(null),
|
|
10
|
+
rootElement = _a[0],
|
|
11
|
+
setRootElement = _a[1];
|
|
12
|
+
var applyTheme = function () {
|
|
13
|
+
if (rootElement) {
|
|
14
|
+
var cssVariableDefinitions = designTokens.makeCssVariableDefinitionsMap(theme);
|
|
15
|
+
Object.entries(cssVariableDefinitions).forEach(function (_a) {
|
|
16
|
+
var key = _a[0],
|
|
17
|
+
value = _a[1];
|
|
18
|
+
rootElement.style.setProperty(key, value);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
React.useEffect(function () {
|
|
23
|
+
if (typeof window !== "undefined") {
|
|
24
|
+
setRootElement(rootElementId ? document.getElementById(rootElementId) : document.documentElement);
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
React.useEffect(function () {
|
|
28
|
+
if (apply && rootElement) {
|
|
29
|
+
applyTheme();
|
|
30
|
+
}
|
|
31
|
+
}, [rootElement]);
|
|
32
|
+
return {
|
|
33
|
+
theme: theme
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.useThemeManager = useThemeManager;
|
|
37
|
+
//# sourceMappingURL=useThemeManager.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeManager.cjs","sources":["../../../../src/KaizenProvider/ThemeProvider/useThemeManager.ts"],"sourcesContent":["import { useEffect, useState } from \"react\"\nimport { makeCssVariableDefinitionsMap } from \"@kaizen/design-tokens\"\nimport { Theme as BaseTheme } from \"./themes\"\n\ntype UseThemeManagerReturn<Theme extends BaseTheme = BaseTheme> = {\n theme: Theme\n}\n\nexport const useThemeManager = <Theme extends BaseTheme = BaseTheme>(\n theme: Theme,\n rootElementId?: string,\n apply: boolean = true\n): UseThemeManagerReturn<Theme> => {\n const [rootElement, setRootElement] = useState<HTMLElement | null>(null)\n\n const applyTheme = (): void => {\n if (rootElement) {\n const cssVariableDefinitions = makeCssVariableDefinitionsMap(theme)\n Object.entries(cssVariableDefinitions).forEach(([key, value]) => {\n rootElement.style.setProperty(key, value)\n })\n }\n }\n\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n setRootElement(\n rootElementId\n ? document.getElementById(rootElementId)\n : document.documentElement\n )\n }\n }, [])\n\n useEffect(() => {\n if (apply && rootElement) {\n applyTheme()\n }\n }, [rootElement])\n\n return {\n theme,\n }\n}\n"],"names":["useThemeManager","theme","rootElementId","apply","_a","useState","rootElement","setRootElement","applyTheme","cssVariableDefinitions","makeCssVariableDefinitionsMap","Object","entries","forEach","key","value","style","setProperty","useEffect","window","document","getElementById","documentElement"],"mappings":";;;;IAQaA,eAAe,GAAG,SAAAA,CAC7BC,KAAY,EACZC,aAAsB,EACtBC,KAAqB,EAAA;EAArB,IAAAA,KAAA,KAAA,KAAA,CAAA,EAAA;IAAAA,KAAqB,GAAA,IAAA;EAAA;EAEf,IAAAC,EAAA,GAAgCC,KAAAA,CAAAA,QAAQ,CAAqB,IAAI,CAAC;IAAjEC,WAAW,GAAAF,EAAA,CAAA,CAAA,CAAA;IAAEG,cAAc,GAAAH,EAAA,CAAA,CAAA,CAAsC;EAExE,IAAMI,UAAU,GAAG,SAAAA,CAAA,EAAA;IACjB,IAAIF,WAAW,EAAE;MACf,IAAMG,sBAAsB,GAAGC,0CAA6B,CAACT,KAAK,CAAC;MACnEU,MAAM,CAACC,OAAO,CAACH,sBAAsB,CAAC,CAACI,OAAO,CAAC,UAACT,EAAY,EAAA;YAAXU,GAAG,GAAAV,EAAA,CAAA,CAAA,CAAA;UAAEW,KAAK,GAAAX,EAAA,CAAA,CAAA,CAAA;QACzDE,WAAW,CAACU,KAAK,CAACC,WAAW,CAACH,GAAG,EAAEC,KAAK,CAAC;MAC3C,CAAC,CAAC;IACH;EACH,CAAC;EAEDG,KAAAA,CAAAA,SAAS,CAAC,YAAA;IACR,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;MACjCZ,cAAc,CACZL,aAAa,GACTkB,QAAQ,CAACC,cAAc,CAACnB,aAAa,CAAC,GACtCkB,QAAQ,CAACE,eAAe,CAC7B;IACF;EACF,CAAA,EAAE,EAAE,CAAC;EAENJ,KAAAA,CAAAA,SAAS,CAAC,YAAA;IACR,IAAIf,KAAK,IAAIG,WAAW,EAAE;MACxBE,UAAU,EAAE;IACb;EACH,CAAC,EAAE,CAACF,WAAW,CAAC,CAAC;EAEjB,OAAO;IACLL,KAAK,EAAAA;GACN;AACH,CAAA;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
export type KaizenProviderProps = {
|
|
2
|
+
import { Theme as BaseTheme } from "@kaizen/design-tokens";
|
|
3
|
+
export type KaizenProviderProps<Theme extends BaseTheme = BaseTheme> = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
|
|
5
|
+
theme?: Theme;
|
|
6
6
|
locale?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const KaizenProvider: {
|
|
9
|
-
({ children,
|
|
9
|
+
({ children, theme, locale, }: KaizenProviderProps): JSX.Element;
|
|
10
10
|
displayName: string;
|
|
11
11
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const ThemeContext: Context<
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Theme as BaseTheme } from "./themes";
|
|
3
|
+
type ThemeContextValue<Theme extends BaseTheme = any> = Theme;
|
|
4
|
+
export declare const ThemeContext: React.Context<any>;
|
|
5
5
|
/**
|
|
6
6
|
* Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
|
|
7
7
|
* This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
|
|
8
8
|
*/
|
|
9
|
-
export declare const ThemeProvider: ({
|
|
10
|
-
|
|
9
|
+
export declare const ThemeProvider: <Theme extends BaseTheme = BaseTheme>({ theme: userTheme, ...props }: {
|
|
10
|
+
theme?: Theme | undefined;
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
}) => JSX.Element;
|
|
13
|
-
export declare const useTheme: () => Theme;
|
|
13
|
+
export declare const useTheme: <Theme extends BaseTheme = BaseTheme>() => Theme;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Theme as BaseTheme } from "./themes";
|
|
2
|
+
type UseThemeManagerReturn<Theme extends BaseTheme = BaseTheme> = {
|
|
3
|
+
theme: Theme;
|
|
4
|
+
};
|
|
5
|
+
export declare const useThemeManager: <Theme extends BaseTheme = BaseTheme>(theme: Theme, rootElementId?: string, apply?: boolean) => UseThemeManagerReturn<Theme>;
|
|
6
|
+
export {};
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -285,7 +285,6 @@ var InputRange = require('./Input/InputRange/InputRange.cjs');
|
|
|
285
285
|
var InputSearch = require('./Input/InputSearch/InputSearch.cjs');
|
|
286
286
|
var KaizenProvider = require('./KaizenProvider/KaizenProvider.cjs');
|
|
287
287
|
var ThemeProvider = require('./KaizenProvider/ThemeProvider/ThemeProvider.cjs');
|
|
288
|
-
var ThemeManager = require('./KaizenProvider/ThemeProvider/ThemeManager.cjs');
|
|
289
288
|
var index = require('./KaizenProvider/ThemeProvider/themes/index.cjs');
|
|
290
289
|
var Label = require('./Label/Label.cjs');
|
|
291
290
|
var LabelledMessage = require('./LabelledMessage/LabelledMessage.cjs');
|
|
@@ -592,7 +591,6 @@ exports.KaizenProvider = KaizenProvider.KaizenProvider;
|
|
|
592
591
|
exports.ThemeContext = ThemeProvider.ThemeContext;
|
|
593
592
|
exports.ThemeProvider = ThemeProvider.ThemeProvider;
|
|
594
593
|
exports.useTheme = ThemeProvider.useTheme;
|
|
595
|
-
exports.ThemeManager = ThemeManager.ThemeManager;
|
|
596
594
|
exports.defaultTheme = index.defaultTheme;
|
|
597
595
|
exports.Label = Label.Label;
|
|
598
596
|
exports.LabelledMessage = LabelledMessage.LabelledMessage;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/cjs/index.css
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
.Popover-module_popover__B7k5I{background:var(--color-white,#fff);border-radius:var(--border-solid-border-radius,7px);box-shadow:var(--shadow-large-box-shadow,0 8px 40px rgba(0,0,0,.08),0 3px 9px rgba(0,0,0,.1));box-sizing:border-box;overflow:auto}
|
|
4
4
|
.Main-module_main__hMyB1{z-index:0}
|
|
5
5
|
.Wrapper-module_wrapper__89WmC{background:var(--color-gray-100,#f9f9f9);display:grid;grid-template-rows:min-content 1fr min-content;min-height:100vh;position:relative}
|
|
6
|
-
.FooterRoot-module_footerRoot__N-6nQ{align-items:center;background:var(--color-blue-500,#0168b3);display:grid;flex-grow:1;gap:var(--spacing-16,1rem);grid-template-areas:"prev stepper next";grid-template-columns:1fr 2fr 1fr;justify-content:center;padding:var(--spacing-24,1.5rem) var(--spacing-12,.75rem)}@media (min-width:768px){.FooterRoot-module_footerRoot__N-6nQ{bottom:0;grid-template-columns:1fr 5fr 1fr;padding:var(--spacing-24,1.5rem) var(--spacing-32,2rem);position:sticky;z-index:1}}
|
|
7
|
-
.Actions-module_actions__Prrp0{align-items:center;display:flex;flex-direction:column;flex-grow:1;grid-area:actions;justify-content:center}@media (min-width:768px){.Actions-module_actions__Prrp0{align-items:flex-start;flex-direction:row;justify-content:flex-end;margin-top:calc(var(--spacing-12, .75rem)*-1)}}
|
|
8
|
-
.FooterActions-module_footerAction__v7eL-{display:flex;flex-basis:auto;flex-grow:1}.FooterActions-module_footerActionPrevious__2XByZ{grid-area:"prev";justify-content:start}.FooterActions-module_footerActionNext__IKRta{grid-area:"next";justify-content:end}
|
|
9
6
|
.Titles-module_titles__JYwU0{align-items:center;flex-grow:1;grid-area:titles;justify-content:center}.Titles-module_pageTitle__YDp9S,.Titles-module_titles__JYwU0{display:flex;flex-direction:column}.Titles-module_prefix__40x8n{margin-bottom:var(--spacing-4,.25rem)}.Titles-module_status__huuP7{margin-top:var(--spacing-8,.5rem)}
|
|
10
|
-
.
|
|
7
|
+
.FooterActions-module_footerAction__v7eL-{display:flex;flex-basis:auto;flex-grow:1}.FooterActions-module_footerActionPrevious__2XByZ{grid-area:"prev";justify-content:start}.FooterActions-module_footerActionNext__IKRta{grid-area:"next";justify-content:end}
|
|
8
|
+
.FooterRoot-module_footerRoot__N-6nQ{align-items:center;background:var(--color-blue-500,#0168b3);display:grid;flex-grow:1;gap:var(--spacing-16,1rem);grid-template-areas:"prev stepper next";grid-template-columns:1fr 2fr 1fr;justify-content:center;padding:var(--spacing-24,1.5rem) var(--spacing-12,.75rem)}@media (min-width:768px){.FooterRoot-module_footerRoot__N-6nQ{bottom:0;grid-template-columns:1fr 5fr 1fr;padding:var(--spacing-24,1.5rem) var(--spacing-32,2rem);position:sticky;z-index:1}}
|
|
11
9
|
.ProgressStepper-module_stepsContainer__WMxXN{grid-area:stepper;width:100%}.ProgressStepper-module_stepList__b1wWX{align-items:flex-end;display:none;justify-content:center;list-style:none;margin:0;padding:0}@media (min-width:768px){.ProgressStepper-module_stepList__b1wWX{display:flex}}.ProgressStepper-module_step__-Ep19{container:step/inline-size;display:flex;flex-basis:100%;flex-grow:1;justify-content:center;max-width:var(--spacing-96,6rem);overflow-wrap:break-word;position:relative}.ProgressStepper-module_stepContent__B4uFS{align-items:center;display:flex;flex-direction:column}.ProgressStepper-module_stepIndicator__-qEWT{height:1.25rem;position:relative;width:1.25rem}.ProgressStepper-module_stepName__hS4lp{display:none;font-weight:var(--typography-paragraph-bold-font-weight,600);margin-bottom:var(--spacing-12,.75rem);text-align:center}.ProgressStepper-module_stepIcon__0Kh4y{color:var(--color-white,#fff);height:1.25rem;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:1.25rem}.ProgressStepper-module_stepDivider__KEZPU{border:var(--spacing-1,.0625rem) solid var(--color-white,#fff);border-radius:var(--border-solid-border-radius,7px);display:flex;flex-grow:1;height:0;left:100%;margin:0;min-width:calc(100% - var(--spacing-24, 1.5rem));position:absolute;top:calc(100% - .625rem);transform:translateX(-50%)}[dir=rtl] .ProgressStepper-module_stepDivider__KEZPU{left:unset;right:100%;transform:translateX(50%)}.ProgressStepper-module_stepperDescription__B00hX{display:flex;justify-content:center}@media (min-width:768px){.ProgressStepper-module_stepperDescription__B00hX{height:0;overflow:hidden;position:absolute;width:0}}@container step (min-width: 4.5rem){.ProgressStepper-module_stepName__hS4lp{display:inline}}
|
|
10
|
+
.Branding-module_branding__4h-rD{display:flex;flex-grow:1;grid-area:branding;justify-content:center;padding-top:var(--spacing-4,.25rem)}@media (min-width:768px){.Branding-module_branding__4h-rD{justify-content:unset}}.Branding-module_logo__vqqec{flex-basis:7.5rem}
|
|
12
11
|
.Root-module_root__7DVw5{align-items:center;background-color:var(--color-white,#fff);box-shadow:var(--shadow-small-box-shadow,0 3px 16px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.1));display:grid;flex-grow:1;gap:var(--spacing-16,1rem);grid-template:"branding" min-content "titles" max-content "actions" min-content/1fr;justify-content:center;padding:var(--spacing-24,1.5rem);text-align:center}@media (min-width:768px){.Root-module_root__7DVw5{align-items:start;grid-template:"branding titles actions" min-content/1fr max-content 1fr;position:sticky;top:0;z-index:1}}
|
|
12
|
+
.Actions-module_actions__Prrp0{align-items:center;display:flex;flex-direction:column;flex-grow:1;grid-area:actions;justify-content:center}@media (min-width:768px){.Actions-module_actions__Prrp0{align-items:flex-start;flex-direction:row;justify-content:flex-end;margin-top:calc(var(--spacing-12, .75rem)*-1)}}
|
|
13
13
|
.SVG-module_icon__8J5Ev{display:inline-block;height:20px;width:20px}.SVG-module_icon__8J5Ev>use{pointer-events:none}@media screen and (-ms-high-contrast:active){.SVG-module_icon__8J5Ev{color:#000}}@media screen and (-ms-high-contrast:white-on-black){.SVG-module_icon__8J5Ev{color:#fff}}@media screen and (-ms-high-contrast:black-on-white){.SVG-module_icon__8J5Ev{color:#000}}.SVG-module_inheritSize__Q8iam{display:block;height:inherit;width:inherit}
|
|
14
14
|
.Avatar-module_wrapper__LY2q2{align-items:center;background:var(--color-gray-300,#eaeaec);border-radius:100%;box-sizing:border-box;display:flex;justify-content:center;overflow:hidden}.Avatar-module_wrapper__LY2q2:not(.Avatar-module_small__PeksS){border:3px solid var(--color-white,#fff);box-shadow:var(--shadow-small-box-shadow,0 3px 16px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.1))}.Avatar-module_wrapper__LY2q2.Avatar-module_personal__2U7--{background:var(--color-orange-100,#fff0e8)}.Avatar-module_wrapper__LY2q2.Avatar-module_otherUser__b-drl{background:var(--color-gray-300,#eaeaec)}.Avatar-module_wrapper__LY2q2.Avatar-module_company__2qtJE{background:var(--color-white,#fff);border:0;border-radius:var(--border-solid-border-radius,7px);padding:6px}.Avatar-module_wrapper__LY2q2.Avatar-module_small__PeksS{height:1.25rem;width:1.25rem}.Avatar-module_wrapper__LY2q2.Avatar-module_small__PeksS .Avatar-module_initials__VDY2Q{margin-bottom:-1px}.Avatar-module_wrapper__LY2q2.Avatar-module_small__PeksS.Avatar-module_company__2qtJE{padding:0}.Avatar-module_wrapper__LY2q2.Avatar-module_medium__Vy3V8{height:3rem;width:3rem}.Avatar-module_wrapper__LY2q2.Avatar-module_medium__Vy3V8 .Avatar-module_initials__VDY2Q{margin-bottom:-1px}.Avatar-module_wrapper__LY2q2.Avatar-module_large__qiNWs{height:4.5rem;width:4.5rem}.Avatar-module_wrapper__LY2q2.Avatar-module_xlarge__Vx4IG{height:6rem;width:6rem}.Avatar-module_wrapper__LY2q2.Avatar-module_xxlarge__oOoGq{height:7.75rem;width:7.75rem}.Avatar-module_wrapper__LY2q2 .Avatar-module_initials__VDY2Q{speak-as:spell-out;border-bottom:none;text-decoration:none}.Avatar-module_avatarImage__FuULy{height:100%;-o-object-fit:cover;object-fit:cover;width:100%}.Avatar-module_loading__i9V-D .Avatar-module_avatarImage__FuULy{display:none}.Avatar-module_companyAvatarImage__7rlfG{border-radius:4px;box-sizing:border-box;-o-object-fit:contain;object-fit:contain}.Avatar-module_fallbackIcon__MPWxq{color:rgba(var(--color-purple-800-rgb,47,36,56),.7);width:28px}.Avatar-module_xxlarge__oOoGq .Avatar-module_fallbackIcon__MPWxq{width:75px}.Avatar-module_xlarge__Vx4IG .Avatar-module_fallbackIcon__MPWxq{width:60px}.Avatar-module_large__qiNWs .Avatar-module_fallbackIcon__MPWxq{width:35px}.Avatar-module_medium__Vy3V8 .Avatar-module_fallbackIcon__MPWxq{margin-bottom:-1px;width:25px}.Avatar-module_small__PeksS .Avatar-module_fallbackIcon__MPWxq{margin-bottom:-1px;width:10px}.Avatar-module_initials__VDY2Q{box-sizing:border-box;color:var(--color-purple-800,#2f2438);font-family:var(--typography-heading-1-font-family,"Inter","Noto Sans",Helvetica,Arial,sans-serif);font-size:22px;font-weight:var(--typography-heading-1-font-weight,700);letter-spacing:var(--typography-heading-3-letter-spacing,normal);padding-left:5px;padding-right:5px;text-align:center;width:100%}.Avatar-module_initials__VDY2Q:not(.Avatar-module_longName__31Yuf):before{content:"";display:block;margin-top:-.001em}.Avatar-module_xlarge__Vx4IG .Avatar-module_initials__VDY2Q,.Avatar-module_xxlarge__oOoGq .Avatar-module_initials__VDY2Q{font-size:34px;letter-spacing:var(--typography-heading-1-letter-spacing,normal)}.Avatar-module_medium__Vy3V8 .Avatar-module_initials__VDY2Q{font-size:16px}.Avatar-module_medium__Vy3V8 .Avatar-module_initials__VDY2Q,.Avatar-module_small__PeksS .Avatar-module_initials__VDY2Q{font-weight:var(--typography-heading-5-font-weight,600);letter-spacing:var(--typography-heading-5-letter-spacing,normal)}.Avatar-module_small__PeksS .Avatar-module_initials__VDY2Q{font-size:8px}
|
|
15
15
|
.AvatarGroup-module_AvatarGroup__bdL0o{display:inline-flex;list-style:none;margin:0;padding:0}.AvatarGroup-module_small__7uv8k .AvatarGroup-module_AvatarGroupItem__xQol-+.AvatarGroup-module_AvatarGroupItem__xQol-{margin-inline-start:-.625rem}[dir=rtl] .AvatarGroup-module_small__7uv8k .AvatarGroup-module_AvatarGroupItem__xQol-+.AvatarGroup-module_AvatarGroupItem__xQol-{margin-left:0}.AvatarGroup-module_medium__af52y .AvatarGroup-module_AvatarGroupItem__xQol-+.AvatarGroup-module_AvatarGroupItem__xQol-{margin-inline-start:-1.5rem}[dir=rtl] .AvatarGroup-module_medium__af52y .AvatarGroup-module_AvatarGroupItem__xQol-+.AvatarGroup-module_AvatarGroupItem__xQol-{margin-left:0}.AvatarGroup-module_large__HN9Yy .AvatarGroup-module_AvatarGroupItem__xQol-+.AvatarGroup-module_AvatarGroupItem__xQol-{margin-inline-start:-2.25rem}[dir=rtl] .AvatarGroup-module_large__HN9Yy .AvatarGroup-module_AvatarGroupItem__xQol-+.AvatarGroup-module_AvatarGroupItem__xQol-{margin-left:0}.AvatarGroup-module_AvatarCounter__PKFzl{align-items:center;background:var(--color-gray-300,#eaeaec);border:3px solid var(--color-white,#fff);border-radius:100%;box-shadow:var(--shadow-small-box-shadow,0 3px 16px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.1));box-sizing:border-box;display:flex;justify-content:center;overflow:hidden}.AvatarGroup-module_small__7uv8k .AvatarGroup-module_AvatarCounter__PKFzl{border:none;box-shadow:none;font-size:.5rem;height:1.25rem;width:1.25rem}.AvatarGroup-module_medium__af52y .AvatarGroup-module_AvatarCounter__PKFzl,.AvatarGroup-module_small__7uv8k .AvatarGroup-module_AvatarCounter__PKFzl{font-family:var(--typography-heading-5-font-family,"Inter","Noto Sans",Helvetica,Arial,sans-serif);font-weight:var(--typography-heading-5-font-weight,600);letter-spacing:var(--typography-heading-5-letter-spacing,normal)}.AvatarGroup-module_medium__af52y .AvatarGroup-module_AvatarCounter__PKFzl{font-size:var(--typography-heading-5-font-size,1rem);height:3rem;width:3rem}.AvatarGroup-module_large__HN9Yy .AvatarGroup-module_AvatarCounter__PKFzl{font-family:var(--typography-heading-3-font-family,"Inter","Noto Sans",Helvetica,Arial,sans-serif);font-size:var(--typography-heading-3-font-size,1.375rem);font-weight:var(--typography-heading-3-font-weight,700);height:4.5rem;letter-spacing:var(--typography-heading-3-letter-spacing,normal);width:4.5rem}[dir=rtl] .AvatarGroup-module_AvatarCounter__PKFzl{direction:ltr;margin-left:0}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OptionalIntlProvider } from './OptionalIntlProvider/OptionalIntlProvider.mjs';
|
|
3
3
|
import { ThemeProvider } from './ThemeProvider/ThemeProvider.mjs';
|
|
4
|
-
import '@kaizen/design-tokens';
|
|
5
4
|
const KaizenProvider = /*#__PURE__*/function () {
|
|
6
5
|
const KaizenProvider = function (_a) {
|
|
7
6
|
var children = _a.children,
|
|
8
|
-
|
|
7
|
+
theme = _a.theme,
|
|
9
8
|
_b = _a.locale,
|
|
10
9
|
locale = _b === void 0 ? "en" : _b;
|
|
11
10
|
return /*#__PURE__*/React.createElement(OptionalIntlProvider, {
|
|
12
11
|
locale: locale
|
|
13
12
|
}, /*#__PURE__*/React.createElement(ThemeProvider, {
|
|
14
|
-
|
|
13
|
+
theme: theme
|
|
15
14
|
}, children));
|
|
16
15
|
};
|
|
17
16
|
KaizenProvider.displayName = "KaizenProvider";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KaizenProvider.mjs","sources":["../../../src/KaizenProvider/KaizenProvider.tsx"],"sourcesContent":["import React from \"react\"\nimport { OptionalIntlProvider } from \"./OptionalIntlProvider\"\nimport { ThemeProvider
|
|
1
|
+
{"version":3,"file":"KaizenProvider.mjs","sources":["../../../src/KaizenProvider/KaizenProvider.tsx"],"sourcesContent":["import React from \"react\"\nimport { Theme as BaseTheme } from \"@kaizen/design-tokens\"\nimport { OptionalIntlProvider } from \"./OptionalIntlProvider\"\nimport { ThemeProvider } from \"./ThemeProvider\"\n\nexport type KaizenProviderProps<Theme extends BaseTheme = BaseTheme> = {\n children: React.ReactNode\n theme?: Theme\n locale?: string\n}\n\nexport const KaizenProvider = ({\n children,\n theme,\n locale = \"en\",\n}: KaizenProviderProps): JSX.Element => (\n <OptionalIntlProvider locale={locale}>\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </OptionalIntlProvider>\n)\n\nKaizenProvider.displayName = \"KaizenProvider\"\n"],"names":["KaizenProvider","_a","children","theme","_b","locale","React","createElement","OptionalIntlProvider","ThemeProvider","displayName"],"mappings":";;;MAWaA,cAAc;EAAA,MAAdA,cAAc,GAAG,SAAAA,CAACC,EAIT,EAAA;QAHpBC,QAAQ,GAAAD,EAAA,CAAAC,QAAA;MACRC,KAAK,GAAAF,EAAA,CAAAE,KAAA;MACLC,cAAa;MAAbC,MAAM,GAAGD,EAAA,KAAA,KAAA,CAAA,GAAA,IAAI,GAAAA,EAAA;IACyB,oBACtCE,KAAC,CAAAC,aAAA,CAAAC,oBAAoB,EAAC;MAAAH,MAAM,EAAEA;IAAM,CAAA,eAClCC,KAAC,CAAAC,aAAA,CAAAE,aAAa;MAACN,KAAK,EAAEA;IAAQ,CAAA,EAAAD,QAAQ,CAAiB,CAClC;EAHe,CAIvC;EAEDF,cAAc,CAACU,WAAW,GAAG,gBAAgB;EAAA,OAVhCV,cAAc;AAAA;"}
|
|
@@ -1,32 +1,16 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
|
-
import React, { createContext,
|
|
3
|
-
import { ThemeManager } from './ThemeManager.mjs';
|
|
2
|
+
import React, { createContext, useContext } from 'react';
|
|
4
3
|
import { defaultTheme } from './themes/index.mjs';
|
|
5
|
-
|
|
4
|
+
import { useThemeManager } from './useThemeManager.mjs';
|
|
5
|
+
var ThemeContext = /*#__PURE__*/createContext(null);
|
|
6
6
|
/**
|
|
7
7
|
* Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
|
|
8
8
|
* This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
|
|
9
9
|
*/
|
|
10
10
|
var ThemeProvider = function (_a) {
|
|
11
|
-
var
|
|
12
|
-
props = __rest(_a, ["
|
|
13
|
-
var
|
|
14
|
-
return themeManager || new ThemeManager(defaultTheme);
|
|
15
|
-
})[0];
|
|
16
|
-
var _b = useState(themeManagerInstance.getCurrentTheme()),
|
|
17
|
-
theme = _b[0],
|
|
18
|
-
setTheme = _b[1];
|
|
19
|
-
useEffect(function () {
|
|
20
|
-
var cancelled = false;
|
|
21
|
-
var listener = function (newTheme) {
|
|
22
|
-
if (!cancelled) setTheme(newTheme);
|
|
23
|
-
};
|
|
24
|
-
themeManagerInstance.addThemeChangeListener(listener);
|
|
25
|
-
return function () {
|
|
26
|
-
cancelled = true;
|
|
27
|
-
themeManagerInstance.removeThemeChangeListener(listener);
|
|
28
|
-
};
|
|
29
|
-
}, []);
|
|
11
|
+
var userTheme = _a.theme,
|
|
12
|
+
props = __rest(_a, ["theme"]);
|
|
13
|
+
var theme = useThemeManager(userTheme !== null && userTheme !== void 0 ? userTheme : defaultTheme).theme;
|
|
30
14
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ThemeContext.Provider, {
|
|
31
15
|
value: theme
|
|
32
16
|
}, props.children), /*#__PURE__*/React.createElement("link", {
|
|
@@ -62,7 +46,11 @@ var ThemeProvider = function (_a) {
|
|
|
62
46
|
}));
|
|
63
47
|
};
|
|
64
48
|
var useTheme = function () {
|
|
65
|
-
|
|
49
|
+
var context = useContext(ThemeContext);
|
|
50
|
+
if (!context) {
|
|
51
|
+
throw new Error("useTheme must be used within the ThemeContext.Provider");
|
|
52
|
+
}
|
|
53
|
+
return context;
|
|
66
54
|
};
|
|
67
55
|
export { ThemeContext, ThemeProvider, useTheme };
|
|
68
56
|
//# sourceMappingURL=ThemeProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.mjs","sources":["../../../../src/KaizenProvider/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"ThemeProvider.mjs","sources":["../../../../src/KaizenProvider/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["import React, { createContext, useContext } from \"react\"\nimport { defaultTheme, Theme as BaseTheme } from \"./themes\"\nimport { useThemeManager } from \"./useThemeManager\"\n\n// We set the generic default value to `any` as SelectContext\n// is instantiated as a constant which does not accept generics.\ntype ThemeContextValue<Theme extends BaseTheme = any> = Theme\n\nexport const ThemeContext = createContext<ThemeContextValue | null>(null)\n\n/**\n * Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.\n * This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.\n */\nexport const ThemeProvider = <Theme extends BaseTheme = BaseTheme>({\n theme: userTheme,\n ...props\n}: {\n theme?: Theme\n children: React.ReactNode\n}): JSX.Element => {\n const { theme } = useThemeManager(userTheme ?? defaultTheme)\n\n return (\n <>\n <ThemeContext.Provider value={theme}>\n {props.children}\n </ThemeContext.Provider>\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-bold.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-demi-bold.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-medium.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/inter/inter-regular.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n <link\n rel=\"preload\"\n href=\"https://d1e7r7b0lb8p4d.cloudfront.net/fonts/tiempos/tiempos-headline-bold.woff2\"\n as=\"font\"\n type=\"font/woff2\"\n crossOrigin=\"anonymous\"\n />\n </>\n )\n}\n\nexport const useTheme = <\n Theme extends BaseTheme = BaseTheme,\n>(): ThemeContextValue<Theme> => {\n const context = useContext(ThemeContext)\n\n if (!context) {\n throw new Error(\"useTheme must be used within the ThemeContext.Provider\")\n }\n\n return context\n}\n"],"names":["ThemeContext","createContext","ThemeProvider","_a","userTheme","theme","props","__rest","useThemeManager","defaultTheme","React","createElement","Fragment","Provider","value","children","rel","href","as","type","crossOrigin","useTheme","context","useContext","Error"],"mappings":";;;;IAQaA,YAAY,gBAAGC,aAAa,CAA2B,IAAI,CAAC;AAEzE;;;AAGG;AACI,IAAMC,aAAa,GAAG,SAAAA,CAAsCC,EAMlE,EAAA;EALC,IAAOC,SAAS,GAAAD,EAAA,CAAAE,KAAA;IACbC,KAAK,GAAAC,MAAA,CAAAJ,EAAA,EAFyD,SAGlE,CADS;EAKA,IAAAE,KAAK,GAAKG,eAAe,CAACJ,SAAS,KAAA,IAAA,IAATA,SAAS,KAAA,KAAA,CAAA,GAATA,SAAS,GAAIK,YAAY,CAAC,MAA/C;EAEb,oBACEC,KAAA,CAAAC,aAAA,CAAAD,KAAA,CAAAE,QAAA,EAAA,IAAA,eACEF,KAAC,CAAAC,aAAA,CAAAX,YAAY,CAACa,QAAQ,EAAC;IAAAC,KAAK,EAAET;EAAK,CAChC,EAAAC,KAAK,CAACS,QAAQ,CACO,eACxBL,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,oEAAoE;IACzEC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,eACFV,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,yEAAyE;IAC9EC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,eACFV,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,sEAAsE;IAC3EC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,eACFV,KAAA,CAAAC,aAAA,CAAA,MAAA,EAAA;IACEK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,uEAAuE;IAC5EC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CACvB,CAAA,eACFV,KACE,CAAAC,aAAA,CAAA,MAAA,EAAA;IAAAK,GAAG,EAAC,SAAS;IACbC,IAAI,EAAC,iFAAiF;IACtFC,EAAE,EAAC,MAAM;IACTC,IAAI,EAAC,YAAY;IACjBC,WAAW,EAAC;EAAW,CAAA,CACvB,CACD;AAEP,CAAC;AAEY,IAAAC,QAAQ,GAAG,SAAAA,CAAA,EAAA;EAGtB,IAAMC,OAAO,GAAGC,UAAU,CAACvB,YAAY,CAAC;EAExC,IAAI,CAACsB,OAAO,EAAE;IACZ,MAAM,IAAIE,KAAK,CAAC,wDAAwD,CAAC;EAC1E;EAED,OAAOF,OAAO;AAChB,CAAA;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { makeCssVariableDefinitionsMap } from '@kaizen/design-tokens';
|
|
3
|
+
var useThemeManager = function (theme, rootElementId, apply) {
|
|
4
|
+
if (apply === void 0) {
|
|
5
|
+
apply = true;
|
|
6
|
+
}
|
|
7
|
+
var _a = useState(null),
|
|
8
|
+
rootElement = _a[0],
|
|
9
|
+
setRootElement = _a[1];
|
|
10
|
+
var applyTheme = function () {
|
|
11
|
+
if (rootElement) {
|
|
12
|
+
var cssVariableDefinitions = makeCssVariableDefinitionsMap(theme);
|
|
13
|
+
Object.entries(cssVariableDefinitions).forEach(function (_a) {
|
|
14
|
+
var key = _a[0],
|
|
15
|
+
value = _a[1];
|
|
16
|
+
rootElement.style.setProperty(key, value);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
useEffect(function () {
|
|
21
|
+
if (typeof window !== "undefined") {
|
|
22
|
+
setRootElement(rootElementId ? document.getElementById(rootElementId) : document.documentElement);
|
|
23
|
+
}
|
|
24
|
+
}, []);
|
|
25
|
+
useEffect(function () {
|
|
26
|
+
if (apply && rootElement) {
|
|
27
|
+
applyTheme();
|
|
28
|
+
}
|
|
29
|
+
}, [rootElement]);
|
|
30
|
+
return {
|
|
31
|
+
theme: theme
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export { useThemeManager };
|
|
35
|
+
//# sourceMappingURL=useThemeManager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useThemeManager.mjs","sources":["../../../../src/KaizenProvider/ThemeProvider/useThemeManager.ts"],"sourcesContent":["import { useEffect, useState } from \"react\"\nimport { makeCssVariableDefinitionsMap } from \"@kaizen/design-tokens\"\nimport { Theme as BaseTheme } from \"./themes\"\n\ntype UseThemeManagerReturn<Theme extends BaseTheme = BaseTheme> = {\n theme: Theme\n}\n\nexport const useThemeManager = <Theme extends BaseTheme = BaseTheme>(\n theme: Theme,\n rootElementId?: string,\n apply: boolean = true\n): UseThemeManagerReturn<Theme> => {\n const [rootElement, setRootElement] = useState<HTMLElement | null>(null)\n\n const applyTheme = (): void => {\n if (rootElement) {\n const cssVariableDefinitions = makeCssVariableDefinitionsMap(theme)\n Object.entries(cssVariableDefinitions).forEach(([key, value]) => {\n rootElement.style.setProperty(key, value)\n })\n }\n }\n\n useEffect(() => {\n if (typeof window !== \"undefined\") {\n setRootElement(\n rootElementId\n ? document.getElementById(rootElementId)\n : document.documentElement\n )\n }\n }, [])\n\n useEffect(() => {\n if (apply && rootElement) {\n applyTheme()\n }\n }, [rootElement])\n\n return {\n theme,\n }\n}\n"],"names":["useThemeManager","theme","rootElementId","apply","_a","useState","rootElement","setRootElement","applyTheme","cssVariableDefinitions","makeCssVariableDefinitionsMap","Object","entries","forEach","key","value","style","setProperty","useEffect","window","document","getElementById","documentElement"],"mappings":";;IAQaA,eAAe,GAAG,SAAAA,CAC7BC,KAAY,EACZC,aAAsB,EACtBC,KAAqB,EAAA;EAArB,IAAAA,KAAA,KAAA,KAAA,CAAA,EAAA;IAAAA,KAAqB,GAAA,IAAA;EAAA;EAEf,IAAAC,EAAA,GAAgCC,QAAQ,CAAqB,IAAI,CAAC;IAAjEC,WAAW,GAAAF,EAAA,CAAA,CAAA,CAAA;IAAEG,cAAc,GAAAH,EAAA,CAAA,CAAA,CAAsC;EAExE,IAAMI,UAAU,GAAG,SAAAA,CAAA,EAAA;IACjB,IAAIF,WAAW,EAAE;MACf,IAAMG,sBAAsB,GAAGC,6BAA6B,CAACT,KAAK,CAAC;MACnEU,MAAM,CAACC,OAAO,CAACH,sBAAsB,CAAC,CAACI,OAAO,CAAC,UAACT,EAAY,EAAA;YAAXU,GAAG,GAAAV,EAAA,CAAA,CAAA,CAAA;UAAEW,KAAK,GAAAX,EAAA,CAAA,CAAA,CAAA;QACzDE,WAAW,CAACU,KAAK,CAACC,WAAW,CAACH,GAAG,EAAEC,KAAK,CAAC;MAC3C,CAAC,CAAC;IACH;EACH,CAAC;EAEDG,SAAS,CAAC,YAAA;IACR,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;MACjCZ,cAAc,CACZL,aAAa,GACTkB,QAAQ,CAACC,cAAc,CAACnB,aAAa,CAAC,GACtCkB,QAAQ,CAACE,eAAe,CAC7B;IACF;EACF,CAAA,EAAE,EAAE,CAAC;EAENJ,SAAS,CAAC,YAAA;IACR,IAAIf,KAAK,IAAIG,WAAW,EAAE;MACxBE,UAAU,EAAE;IACb;EACH,CAAC,EAAE,CAACF,WAAW,CAAC,CAAC;EAEjB,OAAO;IACLL,KAAK,EAAAA;GACN;AACH,CAAA;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
export type KaizenProviderProps = {
|
|
2
|
+
import { Theme as BaseTheme } from "@kaizen/design-tokens";
|
|
3
|
+
export type KaizenProviderProps<Theme extends BaseTheme = BaseTheme> = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
|
-
|
|
5
|
+
theme?: Theme;
|
|
6
6
|
locale?: string;
|
|
7
7
|
};
|
|
8
8
|
export declare const KaizenProvider: {
|
|
9
|
-
({ children,
|
|
9
|
+
({ children, theme, locale, }: KaizenProviderProps): JSX.Element;
|
|
10
10
|
displayName: string;
|
|
11
11
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const ThemeContext: Context<
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Theme as BaseTheme } from "./themes";
|
|
3
|
+
type ThemeContextValue<Theme extends BaseTheme = any> = Theme;
|
|
4
|
+
export declare const ThemeContext: React.Context<any>;
|
|
5
5
|
/**
|
|
6
6
|
* Wrap your application in this provider using a ThemeManager, to synchronise it with a react context.
|
|
7
7
|
* This allows child react elements to more easily use theme variables, using the {@link useTheme} hook.
|
|
8
8
|
*/
|
|
9
|
-
export declare const ThemeProvider: ({
|
|
10
|
-
|
|
9
|
+
export declare const ThemeProvider: <Theme extends BaseTheme = BaseTheme>({ theme: userTheme, ...props }: {
|
|
10
|
+
theme?: Theme | undefined;
|
|
11
11
|
children: React.ReactNode;
|
|
12
12
|
}) => JSX.Element;
|
|
13
|
-
export declare const useTheme: () => Theme;
|
|
13
|
+
export declare const useTheme: <Theme extends BaseTheme = BaseTheme>() => Theme;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Theme as BaseTheme } from "./themes";
|
|
2
|
+
type UseThemeManagerReturn<Theme extends BaseTheme = BaseTheme> = {
|
|
3
|
+
theme: Theme;
|
|
4
|
+
};
|
|
5
|
+
export declare const useThemeManager: <Theme extends BaseTheme = BaseTheme>(theme: Theme, rootElementId?: string, apply?: boolean) => UseThemeManagerReturn<Theme>;
|
|
6
|
+
export {};
|
package/dist/esm/index.css
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
.Popover-module_popover__B7k5I{background:var(--color-white,#fff);border-radius:var(--border-solid-border-radius,7px);box-shadow:var(--shadow-large-box-shadow,0 8px 40px rgba(0,0,0,.08),0 3px 9px rgba(0,0,0,.1));box-sizing:border-box;overflow:auto}
|
|
5
5
|
.Wrapper-module_wrapper__89WmC{background:var(--color-gray-100,#f9f9f9);display:grid;grid-template-rows:min-content 1fr min-content;min-height:100vh;position:relative}
|
|
6
6
|
.FooterRoot-module_footerRoot__N-6nQ{align-items:center;background:var(--color-blue-500,#0168b3);display:grid;flex-grow:1;gap:var(--spacing-16,1rem);grid-template-areas:"prev stepper next";grid-template-columns:1fr 2fr 1fr;justify-content:center;padding:var(--spacing-24,1.5rem) var(--spacing-12,.75rem)}@media (min-width:768px){.FooterRoot-module_footerRoot__N-6nQ{bottom:0;grid-template-columns:1fr 5fr 1fr;padding:var(--spacing-24,1.5rem) var(--spacing-32,2rem);position:sticky;z-index:1}}
|
|
7
|
+
.FooterActions-module_footerAction__v7eL-{display:flex;flex-basis:auto;flex-grow:1}.FooterActions-module_footerActionPrevious__2XByZ{grid-area:"prev";justify-content:start}.FooterActions-module_footerActionNext__IKRta{grid-area:"next";justify-content:end}
|
|
7
8
|
.Titles-module_titles__JYwU0{align-items:center;flex-grow:1;grid-area:titles;justify-content:center}.Titles-module_pageTitle__YDp9S,.Titles-module_titles__JYwU0{display:flex;flex-direction:column}.Titles-module_prefix__40x8n{margin-bottom:var(--spacing-4,.25rem)}.Titles-module_status__huuP7{margin-top:var(--spacing-8,.5rem)}
|
|
8
9
|
.Actions-module_actions__Prrp0{align-items:center;display:flex;flex-direction:column;flex-grow:1;grid-area:actions;justify-content:center}@media (min-width:768px){.Actions-module_actions__Prrp0{align-items:flex-start;flex-direction:row;justify-content:flex-end;margin-top:calc(var(--spacing-12, .75rem)*-1)}}
|
|
9
|
-
.FooterActions-module_footerAction__v7eL-{display:flex;flex-basis:auto;flex-grow:1}.FooterActions-module_footerActionPrevious__2XByZ{grid-area:"prev";justify-content:start}.FooterActions-module_footerActionNext__IKRta{grid-area:"next";justify-content:end}
|
|
10
10
|
.Branding-module_branding__4h-rD{display:flex;flex-grow:1;grid-area:branding;justify-content:center;padding-top:var(--spacing-4,.25rem)}@media (min-width:768px){.Branding-module_branding__4h-rD{justify-content:unset}}.Branding-module_logo__vqqec{flex-basis:7.5rem}
|
|
11
11
|
.ProgressStepper-module_stepsContainer__WMxXN{grid-area:stepper;width:100%}.ProgressStepper-module_stepList__b1wWX{align-items:flex-end;display:none;justify-content:center;list-style:none;margin:0;padding:0}@media (min-width:768px){.ProgressStepper-module_stepList__b1wWX{display:flex}}.ProgressStepper-module_step__-Ep19{container:step/inline-size;display:flex;flex-basis:100%;flex-grow:1;justify-content:center;max-width:var(--spacing-96,6rem);overflow-wrap:break-word;position:relative}.ProgressStepper-module_stepContent__B4uFS{align-items:center;display:flex;flex-direction:column}.ProgressStepper-module_stepIndicator__-qEWT{height:1.25rem;position:relative;width:1.25rem}.ProgressStepper-module_stepName__hS4lp{display:none;font-weight:var(--typography-paragraph-bold-font-weight,600);margin-bottom:var(--spacing-12,.75rem);text-align:center}.ProgressStepper-module_stepIcon__0Kh4y{color:var(--color-white,#fff);height:1.25rem;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:1.25rem}.ProgressStepper-module_stepDivider__KEZPU{border:var(--spacing-1,.0625rem) solid var(--color-white,#fff);border-radius:var(--border-solid-border-radius,7px);display:flex;flex-grow:1;height:0;left:100%;margin:0;min-width:calc(100% - var(--spacing-24, 1.5rem));position:absolute;top:calc(100% - .625rem);transform:translateX(-50%)}[dir=rtl] .ProgressStepper-module_stepDivider__KEZPU{left:unset;right:100%;transform:translateX(50%)}.ProgressStepper-module_stepperDescription__B00hX{display:flex;justify-content:center}@media (min-width:768px){.ProgressStepper-module_stepperDescription__B00hX{height:0;overflow:hidden;position:absolute;width:0}}@container step (min-width: 4.5rem){.ProgressStepper-module_stepName__hS4lp{display:inline}}
|
|
12
12
|
.Root-module_root__7DVw5{align-items:center;background-color:var(--color-white,#fff);box-shadow:var(--shadow-small-box-shadow,0 3px 16px rgba(0,0,0,.06),0 1px 3px rgba(0,0,0,.1));display:grid;flex-grow:1;gap:var(--spacing-16,1rem);grid-template:"branding" min-content "titles" max-content "actions" min-content/1fr;justify-content:center;padding:var(--spacing-24,1.5rem);text-align:center}@media (min-width:768px){.Root-module_root__7DVw5{align-items:start;grid-template:"branding titles actions" min-content/1fr max-content 1fr;position:sticky;top:0;z-index:1}}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -283,7 +283,6 @@ export { InputRange } from './Input/InputRange/InputRange.mjs';
|
|
|
283
283
|
export { InputSearch } from './Input/InputSearch/InputSearch.mjs';
|
|
284
284
|
export { KaizenProvider } from './KaizenProvider/KaizenProvider.mjs';
|
|
285
285
|
export { ThemeContext, ThemeProvider, useTheme } from './KaizenProvider/ThemeProvider/ThemeProvider.mjs';
|
|
286
|
-
export { ThemeManager } from './KaizenProvider/ThemeProvider/ThemeManager.mjs';
|
|
287
286
|
export { defaultTheme } from './KaizenProvider/ThemeProvider/themes/index.mjs';
|
|
288
287
|
export { Label } from './Label/Label.mjs';
|
|
289
288
|
export { LabelledMessage } from './LabelledMessage/LabelledMessage.mjs';
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|