@wise/components-theming 0.1.1-next-b7bb815196.2417 → 0.1.1-next-74bd02ad78.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/dist/cjs/index.js CHANGED
@@ -20,25 +20,27 @@ var getThemeClassName = function getThemeClassName(theme) {
20
20
  var ThemeContext = /*#__PURE__*/react.createContext(DEFAULT_COMPONENT_THEME);
21
21
  var ThemeProvider = function ThemeProvider(_ref) {
22
22
  var _ref$theme = _ref.theme,
23
- theme = _ref$theme === void 0 ? DEFAULT_COMPONENT_THEME : _ref$theme,
24
- children = _ref.children;
23
+ theme = _ref$theme === void 0 ? DEFAULT_COMPONENT_THEME : _ref$theme,
24
+ children = _ref.children;
25
25
  var themedChildren = react.Children.map(children, function (child) {
26
26
  var _child$props;
27
+
27
28
  if (! /*#__PURE__*/react.isValidElement(child)) {
28
29
  if (process.env.NODE_ENV !== 'production') {
29
30
  // eslint-disable-next-line no-console
30
31
  console.warn('[ThemeProvider] Trying to inject `className` to an invalid React element, this will be skipped!');
31
32
  }
33
+
32
34
  return child;
33
- }
34
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
35
+ } // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
36
+
37
+
35
38
  var classNames = [getThemeClassName(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(' ');
36
39
  return /*#__PURE__*/react.cloneElement(child, {
37
- className: classNames
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ className: classNames // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+
39
42
  });
40
43
  });
41
-
42
44
  return jsxRuntime.jsx(ThemeContext.Provider, {
43
45
  value: theme,
44
46
  children: themedChildren
@@ -47,6 +49,7 @@ var ThemeProvider = function ThemeProvider(_ref) {
47
49
 
48
50
  var useTheme = function useTheme() {
49
51
  var _useContext;
52
+
50
53
  var theme = (_useContext = react.useContext(ThemeContext)) !== null && _useContext !== void 0 ? _useContext : DEFAULT_COMPONENT_THEME;
51
54
  return react.useMemo(function () {
52
55
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/helpers.ts","../../src/ThemeProvider.tsx","../../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 { 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 React from 'react';\nimport { 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 = [getThemeClassName(theme), child?.props?.className]\n .filter(Boolean)\n .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 { 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","isThemeModern","theme","includes","isThemeDark","getThemeClassName","ThemeContext","createContext","ThemeProvider","children","themedChildren","Children","map","child","isValidElement","process","env","NODE_ENV","console","warn","classNames","props","className","filter","Boolean","join","cloneElement","_jsx","Provider","value","useTheme","useContext","useMemo","isModern","isDark"],"mappings":";;;;;AACO,IAAMA,YAAY,GAAG,CAAC,UAAU,CAAU,CAAA;AAC1C,IAAMC,UAAU,GAAG,EAAW,CAAA;AAM9B,IAAMC,uBAAuB,GAAG,OAAgB;;ACNhD,IAAMC,aAAa,GAAG,SAAhBA,aAAa,CAAIC,KAAqB,EAAA;AAAA,EAAA,OACjDJ,YAAY,CAACK,QAAQ,CAACD,KAAoB,CAAC,CAAA;AAAA,CAAA,CAAA;AAEtC,IAAME,WAAW,GAAG,SAAdA,WAAW,CAAIF,KAAqB,EAAA;AAAA,EAAA,OAC/CH,UAAU,CAACI,QAAQ,CAACD,KAAkB,CAAC,CAAA;AAAA,CAAA,CAAA;AAElC,IAAMG,iBAAiB,GAAG,SAApBA,iBAAiB,CAAIH,KAAqB,EAAA;AAAA,EAAA,OAAA,WAAA,CAAA,MAAA,CAAiBA,KAAK,CAAA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AC1BaoB,IAAAA,QAAQ,GAAG,SAAXA,QAAQ,GAAwB;AAAA,EAAA,IAAA,WAAA,CAAA;AAC3C,EAAA,IAAM5B,KAAK,GAAG6B,CAAAA,WAAAA,GAAAA,gBAAU,CAACzB,YAAY,CAAC,qDAAIN,uBAAuB,CAAA;AAEjE,EAAA,OAAOgC,aAAO,CACZ,YAAA;IAAA,OAAO;AACL9B,MAAAA,KAAK,EAALA,KAAK;AACL+B,MAAAA,QAAQ,EAAEhC,aAAa,CAACC,KAAK,CAAC;AAC9BgC,MAAAA,MAAM,EAAE9B,WAAW,CAACF,KAAK,CAAC;MAC1BoB,SAAS,EAAEjB,iBAAiB,CAACH,KAAK,CAAA;AACnC,KAAA,CAAA;AAAA,GAAC,EACF,CAACA,KAAK,CAAC,CACR,CAAA;AACH;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/helpers.ts","../../src/ThemeProvider.tsx","../../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 { 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 React from 'react';\nimport { 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 = [getThemeClassName(theme), child?.props?.className]\n .filter(Boolean)\n .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 { 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","isThemeModern","theme","includes","isThemeDark","getThemeClassName","ThemeContext","createContext","ThemeProvider","children","themedChildren","Children","map","child","isValidElement","process","env","NODE_ENV","console","warn","classNames","props","className","filter","Boolean","join","cloneElement","_jsx","Provider","value","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;;ACN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MAAA,IAAA,IAAA,YAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAA2B,YAAcC,CAAAA,SAAzC,CAChBC,CAAAA,MADgB,CACTC,OADS,CAEhBC,CAAAA,IAFgB,CAEX,GAFW,CAAnB,CAAA;IAIA,oBAAOC,kBAAY,CAACb,KAAD,EAAQ;MACzBS,SAAS,EAAEF,UADc;;AAAA,KAAR,CAAnB,CAAA;AAID,GApBsB,CAAvB,CAAA;AAsBA,EAAA,OAAOO,cAACrB,CAAAA,YAAY,CAACsB,QAAd,EAAsB;AAACC,IAAAA,KAAK,EAAE3B,KAAR;IAAaO,QAAGC,EAAAA,cAAAA;AAAhB,GAAtB,CAAP,CAAA;AACD;;AC1BYoB,IAAAA,QAAQ,GAAG,SAAXA,QAAW,GAAqB;AAAA,EAAA,IAAA,WAAA,CAAA;;AAC3C,EAAA,IAAM5B,KAAK,GAAG6B,CAAAA,WAAAA,GAAAA,gBAAU,CAACzB,YAAD,CAAb,qDAA+BN,uBAA1C,CAAA;AAEA,EAAA,OAAOgC,aAAO,CACZ,YAAA;IAAA,OAAO;AACL9B,MAAAA,KAAK,EAALA,KADK;AAEL+B,MAAAA,QAAQ,EAAEhC,aAAa,CAACC,KAAD,CAFlB;AAGLgC,MAAAA,MAAM,EAAE9B,WAAW,CAACF,KAAD,CAHd;MAILoB,SAAS,EAAEjB,iBAAiB,CAACH,KAAD,CAAA;KAJ9B,CAAA;AAAA,GADY,EAOZ,CAACA,KAAD,CAPY,CAAd,CAAA;AASD;;;;;"}
package/dist/es/index.js CHANGED
@@ -18,25 +18,27 @@ var getThemeClassName = function getThemeClassName(theme) {
18
18
  var ThemeContext = /*#__PURE__*/createContext(DEFAULT_COMPONENT_THEME);
19
19
  var ThemeProvider = function ThemeProvider(_ref) {
20
20
  var _ref$theme = _ref.theme,
21
- theme = _ref$theme === void 0 ? DEFAULT_COMPONENT_THEME : _ref$theme,
22
- children = _ref.children;
21
+ theme = _ref$theme === void 0 ? DEFAULT_COMPONENT_THEME : _ref$theme,
22
+ children = _ref.children;
23
23
  var themedChildren = Children.map(children, function (child) {
24
24
  var _child$props;
25
+
25
26
  if (! /*#__PURE__*/isValidElement(child)) {
26
27
  if (process.env.NODE_ENV !== 'production') {
27
28
  // eslint-disable-next-line no-console
28
29
  console.warn('[ThemeProvider] Trying to inject `className` to an invalid React element, this will be skipped!');
29
30
  }
31
+
30
32
  return child;
31
- }
32
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
33
+ } // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
34
+
35
+
33
36
  var classNames = [getThemeClassName(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(' ');
34
37
  return /*#__PURE__*/cloneElement(child, {
35
- className: classNames
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ className: classNames // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+
37
40
  });
38
41
  });
39
-
40
42
  return jsx(ThemeContext.Provider, {
41
43
  value: theme,
42
44
  children: themedChildren
@@ -45,6 +47,7 @@ var ThemeProvider = function ThemeProvider(_ref) {
45
47
 
46
48
  var useTheme = function useTheme() {
47
49
  var _useContext;
50
+
48
51
  var theme = (_useContext = useContext(ThemeContext)) !== null && _useContext !== void 0 ? _useContext : DEFAULT_COMPONENT_THEME;
49
52
  return useMemo(function () {
50
53
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/helpers.ts","../../src/ThemeProvider.tsx","../../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 { 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 React from 'react';\nimport { 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 = [getThemeClassName(theme), child?.props?.className]\n .filter(Boolean)\n .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 { 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","isThemeModern","theme","includes","isThemeDark","getThemeClassName","ThemeContext","createContext","ThemeProvider","children","themedChildren","Children","map","child","isValidElement","process","env","NODE_ENV","console","warn","classNames","props","className","filter","Boolean","join","cloneElement","_jsx","Provider","value","useTheme","useContext","useMemo","isModern","isDark"],"mappings":";;;AACO,IAAMA,YAAY,GAAG,CAAC,UAAU,CAAU,CAAA;AAC1C,IAAMC,UAAU,GAAG,EAAW,CAAA;AAM9B,IAAMC,uBAAuB,GAAG,OAAgB;;ACNhD,IAAMC,aAAa,GAAG,SAAhBA,aAAa,CAAIC,KAAqB,EAAA;AAAA,EAAA,OACjDJ,YAAY,CAACK,QAAQ,CAACD,KAAoB,CAAC,CAAA;AAAA,CAAA,CAAA;AAEtC,IAAME,WAAW,GAAG,SAAdA,WAAW,CAAIF,KAAqB,EAAA;AAAA,EAAA,OAC/CH,UAAU,CAACI,QAAQ,CAACD,KAAkB,CAAC,CAAA;AAAA,CAAA,CAAA;AAElC,IAAMG,iBAAiB,GAAG,SAApBA,iBAAiB,CAAIH,KAAqB,EAAA;AAAA,EAAA,OAAA,WAAA,CAAA,MAAA,CAAiBA,KAAK,CAAA,CAAA;AAAA,CAAE;;ACFxE,IAAMI,YAAY,gBAAGC,aAAa,CAAiBP,uBAAuB,CAAC,CAAA;AAMrEQ,IAAAA,aAAa,GAAG,SAAhBA,aAAa,CAGD,IAAA,EAAA;AAAA,EAAA,IAAA,UAAA,GAAA,IAAA,CAFvBN,KAAK;AAALA,IAAAA,KAAK,2BAAGF,uBAAuB,GAAA,UAAA;AAC/BS,IAAAA,QAAQ,QAARA,QAAQ,CAAA;EAER,IAAMC,cAAc,GAAGC,QAAQ,CAACC,GAAG,CAACH,QAAQ,EAAE,UAACI,KAAK,EAAI;AAAA,IAAA,IAAA,YAAA,CAAA;AACtD,IAAA,IAAI,eAACC,cAAc,CAACD,KAAK,CAAC,EAAE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,GAAC,EACF,CAACA,KAAK,CAAC,CACR,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/const.ts","../../src/helpers.ts","../../src/ThemeProvider.tsx","../../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 { 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 React from 'react';\nimport { 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 = [getThemeClassName(theme), child?.props?.className]\n .filter(Boolean)\n .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 { 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","isThemeModern","theme","includes","isThemeDark","getThemeClassName","ThemeContext","createContext","ThemeProvider","children","themedChildren","Children","map","child","isValidElement","process","env","NODE_ENV","console","warn","classNames","props","className","filter","Boolean","join","cloneElement","_jsx","Provider","value","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;;ACNA,IAAMC,aAAa,GAAG,SAAhBA,aAAgB,CAACC,KAAD,EAAA;AAAA,EAAA,OAC3BJ,YAAY,CAACK,QAAb,CAAsBD,KAAtB,CAD2B,CAAA;AAAA,CAAtB,CAAA;AAGA,IAAME,WAAW,GAAG,SAAdA,WAAc,CAACF,KAAD,EAAA;AAAA,EAAA,OACzBH,UAAU,CAACI,QAAX,CAAoBD,KAApB,CADyB,CAAA;AAAA,CAApB,CAAA;AAGA,IAAMG,iBAAiB,GAAG,SAApBA,iBAAoB,CAACH,KAAD,EAAA;AAAA,EAAA,OAAA,WAAA,CAAA,MAAA,CAAuCA,KAAvC,CAAA,CAAA;AAAA,CAA1B;;ACFA,IAAMI,YAAY,gBAAGC,aAAa,CAAiB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Q,GAAG,SAAXA,QAAW,GAAqB;AAAA,EAAA,IAAA,WAAA,CAAA;;AAC3C,EAAA,IAAM5B,KAAK,GAAG6B,CAAAA,WAAAA,GAAAA,UAAU,CAACzB,YAAD,CAAb,qDAA+BN,uBAA1C,CAAA;AAEA,EAAA,OAAOgC,OAAO,CACZ,YAAA;IAAA,OAAO;AACL9B,MAAAA,KAAK,EAALA,KADK;AAEL+B,MAAAA,QAAQ,EAAEhC,aAAa,CAACC,KAAD,CAFlB;AAGLgC,MAAAA,MAAM,EAAE9B,WAAW,CAACF,KAAD,CAHd;MAILoB,SAAS,EAAEjB,iBAAiB,CAACH,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-b7bb815196.2417+b7bb815196",
3
+ "version": "0.1.1-next-74bd02ad78.0+74bd02ad78",
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": "b7bb815196ab445648a3d802ea54a7f1ce7936e6"
46
+ "gitHead": "74bd02ad78b0fdafed567c3bc0eb7a1049ec1ccd"
47
47
  }