@wise/components-theming 0.1.1-next-74bd02ad78.0 → 0.1.1-next-e4db433fcd.2433
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/index.js +11 -11
- package/dist/cjs/index.js.map +1 -1
- package/dist/es/index.js +11 -11
- package/dist/es/index.js.map +1 -1
- package/package.json +2 -2
- package/src/ThemeProvider.tsx +1 -4
package/dist/cjs/index.js
CHANGED
|
@@ -7,16 +7,6 @@ var modernThemes = ['personal'];
|
|
|
7
7
|
var darkThemes = [];
|
|
8
8
|
var DEFAULT_COMPONENT_THEME = 'light';
|
|
9
9
|
|
|
10
|
-
var isThemeModern = function isThemeModern(theme) {
|
|
11
|
-
return modernThemes.includes(theme);
|
|
12
|
-
};
|
|
13
|
-
var isThemeDark = function isThemeDark(theme) {
|
|
14
|
-
return darkThemes.includes(theme);
|
|
15
|
-
};
|
|
16
|
-
var getThemeClassName = function getThemeClassName(theme) {
|
|
17
|
-
return "np-theme-".concat(theme);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
10
|
var ThemeContext = /*#__PURE__*/react.createContext(DEFAULT_COMPONENT_THEME);
|
|
21
11
|
var ThemeProvider = function ThemeProvider(_ref) {
|
|
22
12
|
var _ref$theme = _ref.theme,
|
|
@@ -35,7 +25,7 @@ var ThemeProvider = function ThemeProvider(_ref) {
|
|
|
35
25
|
} // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
36
26
|
|
|
37
27
|
|
|
38
|
-
var classNames = [
|
|
28
|
+
var classNames = ["np-theme-".concat(theme), child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.className].filter(Boolean).join(' ');
|
|
39
29
|
return /*#__PURE__*/react.cloneElement(child, {
|
|
40
30
|
className: classNames // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
31
|
|
|
@@ -47,6 +37,16 @@ var ThemeProvider = function ThemeProvider(_ref) {
|
|
|
47
37
|
});
|
|
48
38
|
};
|
|
49
39
|
|
|
40
|
+
var isThemeModern = function isThemeModern(theme) {
|
|
41
|
+
return modernThemes.includes(theme);
|
|
42
|
+
};
|
|
43
|
+
var isThemeDark = function isThemeDark(theme) {
|
|
44
|
+
return darkThemes.includes(theme);
|
|
45
|
+
};
|
|
46
|
+
var getThemeClassName = function getThemeClassName(theme) {
|
|
47
|
+
return "np-theme-".concat(theme);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
50
|
var useTheme = function useTheme() {
|
|
51
51
|
var _useContext;
|
|
52
52
|
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/ThemeProvider.tsx","../../src/helpers.ts","../../src/useTheme.ts"],"sourcesContent":["export const componentThemes = ['light', 'personal'] as const;\nexport const modernThemes = ['personal'] as const;\nexport const darkThemes = [] as const;\n\nexport type ComponentTheme = typeof componentThemes[number];\nexport type ModernTheme = typeof modernThemes[number];\nexport type DarkTheme = typeof darkThemes[number];\n\nexport const DEFAULT_COMPONENT_THEME = 'light' as const;\n","import { Children, cloneElement, createContext, isValidElement, PropsWithChildren } from 'react';\n\nimport { ComponentTheme, DEFAULT_COMPONENT_THEME } from './const';\nimport { getThemeClassName } from './helpers';\n\nexport const ThemeContext = createContext<ComponentTheme>(DEFAULT_COMPONENT_THEME);\n\ntype ThemeProviderProps = PropsWithChildren<{\n theme: ComponentTheme | undefined;\n}>;\n\nexport const ThemeProvider = ({\n theme = DEFAULT_COMPONENT_THEME,\n children,\n}: ThemeProviderProps) => {\n const themedChildren = Children.map(children, (child) => {\n if (!isValidElement(child)) {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n '[ThemeProvider] Trying to inject `className` to an invalid React element, this will be skipped!',\n );\n }\n return child;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const classNames = [`np-theme-${theme}`, child?.props?.className].filter(Boolean).join(' ');\n\n return cloneElement(child, {\n className: classNames,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any);\n });\n\n return <ThemeContext.Provider value={theme}>{themedChildren}</ThemeContext.Provider>;\n};\n","import { ComponentTheme, DarkTheme, ModernTheme, modernThemes, darkThemes } from './const';\n\nexport const isThemeModern = (theme: ComponentTheme): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isThemeDark = (theme: ComponentTheme): theme is DarkTheme =>\n darkThemes.includes(theme as DarkTheme);\n\nexport const getThemeClassName = (theme: ComponentTheme) => `np-theme-${theme}`;\n","import { useContext, useMemo } from 'react';\n\nimport { ThemeContext } from './ThemeProvider';\nimport { ComponentTheme, DEFAULT_COMPONENT_THEME } from './const';\nimport { getThemeClassName, isThemeDark, isThemeModern } from './helpers';\n\ninterface ThemeHookValue {\n theme: ComponentTheme;\n isModern: boolean;\n isDark: boolean;\n className: string;\n}\n\nexport const useTheme = (): ThemeHookValue => {\n const theme = useContext(ThemeContext) ?? DEFAULT_COMPONENT_THEME;\n\n return useMemo(\n () => ({\n theme,\n isModern: isThemeModern(theme),\n isDark: isThemeDark(theme),\n className: getThemeClassName(theme),\n }),\n [theme],\n );\n};\n"],"names":["modernThemes","darkThemes","DEFAULT_COMPONENT_THEME","ThemeContext","createContext","ThemeProvider","theme","children","themedChildren","Children","map","child","isValidElement","process","env","NODE_ENV","console","warn","classNames","props","className","filter","Boolean","join","cloneElement","_jsx","Provider","value","isThemeModern","includes","isThemeDark","getThemeClassName","useTheme","useContext","useMemo","isModern","isDark"],"mappings":";;;;;AACO,IAAMA,YAAY,GAAG,CAAC,UAAD,CAArB,CAAA;AACA,IAAMC,UAAU,GAAG,EAAnB,CAAA;AAMA,IAAMC,uBAAuB,GAAG,OAAhC;;ACHA,IAAMC,YAAY,gBAAGC,mBAAa,CAAiBF,uBAAjB,CAAlC,CAAA;AA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AACtB,KAAD,EAAA;AAAA,EAAA,OAC3BN,YAAY,CAAC6B,QAAb,CAAsBvB,KAAtB,CAD2B,CAAA;AAAA,CAAtB,CAAA;AAGA,IAAMwB,WAAW,GAAG,SAAdA,WAAc,CAACxB,KAAD,EAAA;AAAA,EAAA,OACzBL,UAAU,CAAC4B,QAAX,CAAoBvB,KAApB,CADyB,CAAA;AAAA,CAApB,CAAA;AAGA,IAAMyB,iBAAiB,GAAG,SAApBA,iBAAoB,CAACzB,KAAD,EAAA;AAAA,EAAA,OAAA,WAAA,CAAA,MAAA,CAAuCA,KAAvC,CAAA,CAAA;AAAA,CAA1B;;ACKM0B,IAAAA,QAAQ,GAAG,SAAXA,QAAW,GAAqB;AAAA,EAAA,IAAA,WAAA,CAAA;;AAC3C,EAAA,IAAM1B,KAAK,GAAG2B,CAAAA,WAAAA,GAAAA,gBAAU,CAAC9B,YAAD,CAAb,qDAA+BD,uBAA1C,CAAA;AAEA,EAAA,OAAOgC,aAAO,CACZ,YAAA;IAAA,OAAO;AACL5B,MAAAA,KAAK,EAALA,KADK;AAEL6B,MAAAA,QAAQ,EAAEP,aAAa,CAACtB,KAAD,CAFlB;AAGL8B,MAAAA,MAAM,EAAEN,WAAW,CAACxB,KAAD,CAHd;MAILc,SAAS,EAAEW,iBAAiB,CAACzB,KAAD,CAAA;KAJ9B,CAAA;AAAA,GADY,EAOZ,CAACA,KAAD,CAPY,CAAd,CAAA;AASD;;;;;"}
|
package/dist/es/index.js
CHANGED
|
@@ -5,16 +5,6 @@ var modernThemes = ['personal'];
|
|
|
5
5
|
var darkThemes = [];
|
|
6
6
|
var DEFAULT_COMPONENT_THEME = 'light';
|
|
7
7
|
|
|
8
|
-
var isThemeModern = function isThemeModern(theme) {
|
|
9
|
-
return modernThemes.includes(theme);
|
|
10
|
-
};
|
|
11
|
-
var isThemeDark = function isThemeDark(theme) {
|
|
12
|
-
return darkThemes.includes(theme);
|
|
13
|
-
};
|
|
14
|
-
var getThemeClassName = function getThemeClassName(theme) {
|
|
15
|
-
return "np-theme-".concat(theme);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
8
|
var ThemeContext = /*#__PURE__*/createContext(DEFAULT_COMPONENT_THEME);
|
|
19
9
|
var ThemeProvider = function ThemeProvider(_ref) {
|
|
20
10
|
var _ref$theme = _ref.theme,
|
|
@@ -33,7 +23,7 @@ var ThemeProvider = function ThemeProvider(_ref) {
|
|
|
33
23
|
} // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
34
24
|
|
|
35
25
|
|
|
36
|
-
var classNames = [
|
|
26
|
+
var classNames = ["np-theme-".concat(theme), child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.className].filter(Boolean).join(' ');
|
|
37
27
|
return /*#__PURE__*/cloneElement(child, {
|
|
38
28
|
className: classNames // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
29
|
|
|
@@ -45,6 +35,16 @@ var ThemeProvider = function ThemeProvider(_ref) {
|
|
|
45
35
|
});
|
|
46
36
|
};
|
|
47
37
|
|
|
38
|
+
var isThemeModern = function isThemeModern(theme) {
|
|
39
|
+
return modernThemes.includes(theme);
|
|
40
|
+
};
|
|
41
|
+
var isThemeDark = function isThemeDark(theme) {
|
|
42
|
+
return darkThemes.includes(theme);
|
|
43
|
+
};
|
|
44
|
+
var getThemeClassName = function getThemeClassName(theme) {
|
|
45
|
+
return "np-theme-".concat(theme);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
48
|
var useTheme = function useTheme() {
|
|
49
49
|
var _useContext;
|
|
50
50
|
|
package/dist/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/ThemeProvider.tsx","../../src/helpers.ts","../../src/useTheme.ts"],"sourcesContent":["export const componentThemes = ['light', 'personal'] as const;\nexport const modernThemes = ['personal'] as const;\nexport const darkThemes = [] as const;\n\nexport type ComponentTheme = typeof componentThemes[number];\nexport type ModernTheme = typeof modernThemes[number];\nexport type DarkTheme = typeof darkThemes[number];\n\nexport const DEFAULT_COMPONENT_THEME = 'light' as const;\n","import { Children, cloneElement, createContext, isValidElement, PropsWithChildren } from 'react';\n\nimport { ComponentTheme, DEFAULT_COMPONENT_THEME } from './const';\nimport { getThemeClassName } from './helpers';\n\nexport const ThemeContext = createContext<ComponentTheme>(DEFAULT_COMPONENT_THEME);\n\ntype ThemeProviderProps = PropsWithChildren<{\n theme: ComponentTheme | undefined;\n}>;\n\nexport const ThemeProvider = ({\n theme = DEFAULT_COMPONENT_THEME,\n children,\n}: ThemeProviderProps) => {\n const themedChildren = Children.map(children, (child) => {\n if (!isValidElement(child)) {\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line no-console\n console.warn(\n '[ThemeProvider] Trying to inject `className` to an invalid React element, this will be skipped!',\n );\n }\n return child;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const classNames = [`np-theme-${theme}`, child?.props?.className].filter(Boolean).join(' ');\n\n return cloneElement(child, {\n className: classNames,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } as any);\n });\n\n return <ThemeContext.Provider value={theme}>{themedChildren}</ThemeContext.Provider>;\n};\n","import { ComponentTheme, DarkTheme, ModernTheme, modernThemes, darkThemes } from './const';\n\nexport const isThemeModern = (theme: ComponentTheme): theme is ModernTheme =>\n modernThemes.includes(theme as ModernTheme);\n\nexport const isThemeDark = (theme: ComponentTheme): theme is DarkTheme =>\n darkThemes.includes(theme as DarkTheme);\n\nexport const getThemeClassName = (theme: ComponentTheme) => `np-theme-${theme}`;\n","import { useContext, useMemo } from 'react';\n\nimport { ThemeContext } from './ThemeProvider';\nimport { ComponentTheme, DEFAULT_COMPONENT_THEME } from './const';\nimport { getThemeClassName, isThemeDark, isThemeModern } from './helpers';\n\ninterface ThemeHookValue {\n theme: ComponentTheme;\n isModern: boolean;\n isDark: boolean;\n className: string;\n}\n\nexport const useTheme = (): ThemeHookValue => {\n const theme = useContext(ThemeContext) ?? DEFAULT_COMPONENT_THEME;\n\n return useMemo(\n () => ({\n theme,\n isModern: isThemeModern(theme),\n isDark: isThemeDark(theme),\n className: getThemeClassName(theme),\n }),\n [theme],\n );\n};\n"],"names":["modernThemes","darkThemes","DEFAULT_COMPONENT_THEME","ThemeContext","createContext","ThemeProvider","theme","children","themedChildren","Children","map","child","isValidElement","process","env","NODE_ENV","console","warn","classNames","props","className","filter","Boolean","join","cloneElement","_jsx","Provider","value","isThemeModern","includes","isThemeDark","getThemeClassName","useTheme","useContext","useMemo","isModern","isDark"],"mappings":";;;AACO,IAAMA,YAAY,GAAG,CAAC,UAAD,CAArB,CAAA;AACA,IAAMC,UAAU,GAAG,EAAnB,CAAA;AAMA,IAAMC,uBAAuB,GAAG,OAAhC;;ACHA,IAAMC,YAAY,gBAAGC,aAAa,CAAiBF,uBAAjB,CAAlC,CAAA;AAMMG,IAAAA,aAAa,GAAG,SAAhBA,aAAgB,CAGJ,IAAA,EAAA;AAAA,EAAA,IAAA,UAAA,GAAA,IAAA,CAFvBC,KAEuB;MAFvBA,KAEuB,2BAFfJ,uBAEe,GAAA,UAAA;MADvBK,QACuB,QADvBA,QACuB,CAAA;EACvB,IAAMC,cAAc,GAAGC,QAAQ,CAACC,GAAT,CAAaH,QAAb,EAAuB,UAACI,KAAD,EAAU;AAAA,IAAA,IAAA,YAAA,CAAA;;AACtD,IAAA,IAAI,eAACC,cAAc,CAACD,KAAD,CAAnB,EAA4B;AAC1B,MAAA,IAAIE,OAAO,CAACC,GAAR,CAAYC,QAAZ,KAAyB,YAA7B,EAA2C;AACzC;QACAC,OAAO,CAACC,IAAR,CACE,iGADF,CAAA,CAAA;AAGD,OAAA;;AACD,MAAA,OAAON,KAAP,CAAA;AACD,KATqD;;;IAYtD,IAAMO,UAAU,GAAG,CAAaZ,WAAAA,CAAAA,MAAAA,CAAAA,KAAb,GAA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AA;IAAA,OAAO;AACL5B,MAAAA,KAAK,EAALA,KADK;AAEL6B,MAAAA,QAAQ,EAAEP,aAAa,CAACtB,KAAD,CAFlB;AAGL8B,MAAAA,MAAM,EAAEN,WAAW,CAACxB,KAAD,CAHd;MAILc,SAAS,EAAEW,iBAAiB,CAACzB,KAAD,CAAA;KAJ9B,CAAA;AAAA,GADY,EAOZ,CAACA,KAAD,CAPY,CAAd,CAAA;AASD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/components-theming",
|
|
3
|
-
"version": "0.1.1-next-
|
|
3
|
+
"version": "0.1.1-next-e4db433fcd.2433+e4db433fcd",
|
|
4
4
|
"description": "Provides theming support for the Wise Design system components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"dist/",
|
|
44
44
|
"src/"
|
|
45
45
|
],
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "e4db433fcd77d4458ac255860df2945983800984"
|
|
47
47
|
}
|
package/src/ThemeProvider.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { Children, cloneElement, createContext, isValidElement, PropsWithChildren } from 'react';
|
|
3
2
|
|
|
4
3
|
import { ComponentTheme, DEFAULT_COMPONENT_THEME } from './const';
|
|
@@ -26,9 +25,7 @@ export const ThemeProvider = ({
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
29
|
-
const classNames = [
|
|
30
|
-
.filter(Boolean)
|
|
31
|
-
.join(' ');
|
|
28
|
+
const classNames = [`np-theme-${theme}`, child?.props?.className].filter(Boolean).join(' ');
|
|
32
29
|
|
|
33
30
|
return cloneElement(child, {
|
|
34
31
|
className: classNames,
|