Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@okta/odyssey-react-theme

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okta/odyssey-react-theme - npm Package Compare versions

Comparing version
0.15.0
to
0.15.1
+1
-1
dist/index.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from \"./ThemeProvider\";\nexport * from \"./withTheme\";\n"],"file":"index.js"}
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from \"./ThemeProvider\";\nexport * from \"./withTheme\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/ThemeProvider/context.ts"],"names":["createContext","DesignTokens","tokens","ThemeContext","displayName"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,OAA9B;AACA,OAAO,KAAKC,YAAZ,MAA8B,6BAA9B;AAEA,OAAO,MAAMC,MAAM,GAAG,EAAE,GAAGD;AAAL,CAAf;AAQP,MAAME,YAAY,GAAGH,aAAa,CAAQE,MAAR,CAAlC;AAEAC,YAAY,CAACC,WAAb,GAA2B,cAA3B;AAEA,SAASD,YAAT","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { createContext } from \"react\";\nimport * as DesignTokens from \"@okta/odyssey-design-tokens\";\n\nexport const tokens = { ...DesignTokens };\n\ntype TokensType = typeof tokens;\nexport type Theme = { [T in keyof TokensType]: TokensType[T] };\nexport type PartialTheme = Partial<Theme>;\nexport type ThemeKey = keyof Theme;\nexport type ThemeValue = Theme[ThemeKey];\n\nconst ThemeContext = createContext<Theme>(tokens);\n\nThemeContext.displayName = \"ThemeContext\";\n\nexport { ThemeContext };\n"],"file":"context.js"}
{"version":3,"file":"context.js","names":["createContext","DesignTokens","tokens","ThemeContext","displayName"],"sources":["../../src/ThemeProvider/context.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { createContext } from \"react\";\nimport * as DesignTokens from \"@okta/odyssey-design-tokens\";\n\nexport const tokens = { ...DesignTokens };\n\ntype TokensType = typeof tokens;\nexport type Theme = { [T in keyof TokensType]: TokensType[T] };\nexport type PartialTheme = Partial<Theme>;\nexport type ThemeKey = keyof Theme;\nexport type ThemeValue = Theme[ThemeKey];\n\nconst ThemeContext = createContext<Theme>(tokens);\n\nThemeContext.displayName = \"ThemeContext\";\n\nexport { ThemeContext };\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,aAAT,QAA8B,OAA9B;AACA,OAAO,KAAKC,YAAZ,MAA8B,6BAA9B;AAEA,OAAO,MAAMC,MAAM,GAAG,EAAE,GAAGD;AAAL,CAAf;AAQP,MAAME,YAAY,GAAGH,aAAa,CAAQE,MAAR,CAAlC;AAEAC,YAAY,CAACC,WAAb,GAA2B,cAA3B;AAEA,SAASD,YAAT"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/ThemeProvider/index.ts"],"names":["useTheme"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;SAISA,Q","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from \"./ThemeProvider\";\nexport type { Theme } from \"./context\";\nexport { useTheme } from \"./useTheme\";\n"],"file":"index.js"}
{"version":3,"file":"index.js","names":["useTheme"],"sources":["../../src/ThemeProvider/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from \"./ThemeProvider\";\nexport type { Theme } from \"./context\";\nexport { useTheme } from \"./useTheme\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;SAISA,Q"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/ThemeProvider/ThemeProvider.tsx"],"names":["React","useCallback","ThemeContext","asCustomProps","reduceTheme","ThemeProvider","props","as","Tag","theme","children","themeConsumer","prevTheme"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;SACSC,Y;SACAC,a,EAAeC,W;AAuBxB,OAAO,MAAMC,aAAa,GAAIC,KAAD,IAA6C;AACxE,QAAM;AAAEC,IAAAA,EAAE,EAAEC,GAAG,GAAG,MAAZ;AAAoBC,IAAAA,KAApB;AAA2BC,IAAAA;AAA3B,MAAwCJ,KAA9C;AAEA,QAAMK,aAAa,GAAGV,WAAW,CAC9BW,SAAD,IACE,oBAAC,GAAD;AAAK,IAAA,KAAK,EAAET,aAAa,CAACM,KAAD;AAAzB,KACE,oBAAC,YAAD,CAAc,QAAd;AACE,IAAA,KAAK,EAAEL,WAAW,CAACQ,SAAD,EAAYH,KAAZ,CADpB;AAEE,IAAA,QAAQ,EAAEC;AAFZ,IADF,CAF6B,EAS/B,CAACA,QAAD,EAAWF,GAAX,EAAgBC,KAAhB,CAT+B,CAAjC;AAYA,SAAO,oBAAC,YAAD,CAAc,QAAd;AAAuB,IAAA,QAAQ,EAAEE;AAAjC,IAAP;AACD,CAhBM","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { useCallback } from \"react\";\nimport { ThemeContext } from \"./context\";\nimport { asCustomProps, reduceTheme } from \"./utils\";\nimport type { Theme, PartialTheme } from \"./context\";\nimport type { ReactElement } from \"react\";\n\ninterface ThemeProviderProps {\n /**\n * The theme overrides to apply to children\n */\n theme: PartialTheme;\n /**\n * Children affected by the theme overrides\n */\n children: ReactElement | ReactElement[];\n /**\n * The element to be rendered in to the DOM\n * @default span\n */\n as?: \"span\" | \"div\";\n}\n\n/**\n * A provider component for overriding theme values.\n */\nexport const ThemeProvider = (props: ThemeProviderProps): ReactElement => {\n const { as: Tag = \"span\", theme, children } = props;\n\n const themeConsumer = useCallback(\n (prevTheme: Theme) => (\n <Tag style={asCustomProps(theme)}>\n <ThemeContext.Provider\n value={reduceTheme(prevTheme, theme)}\n children={children}\n />\n </Tag>\n ),\n [children, Tag, theme]\n );\n\n return <ThemeContext.Consumer children={themeConsumer} />;\n};\n"],"file":"ThemeProvider.js"}
{"version":3,"file":"ThemeProvider.js","names":["React","useCallback","ThemeContext","asCustomProps","reduceTheme","ThemeProvider","props","as","Tag","theme","children","themeConsumer","prevTheme"],"sources":["../../src/ThemeProvider/ThemeProvider.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { useCallback } from \"react\";\nimport { ThemeContext } from \"./context\";\nimport { asCustomProps, reduceTheme } from \"./utils\";\nimport type { Theme, PartialTheme } from \"./context\";\nimport type { ReactElement } from \"react\";\n\ninterface ThemeProviderProps {\n /**\n * The theme overrides to apply to children\n */\n theme: PartialTheme;\n /**\n * Children affected by the theme overrides\n */\n children: ReactElement | ReactElement[];\n /**\n * The element to be rendered in to the DOM\n * @default span\n */\n as?: \"span\" | \"div\";\n}\n\n/**\n * A provider component for overriding theme values.\n */\nexport const ThemeProvider = (props: ThemeProviderProps): ReactElement => {\n const { as: Tag = \"span\", theme, children } = props;\n\n const themeConsumer = useCallback(\n (prevTheme: Theme) => (\n <Tag style={asCustomProps(theme)}>\n <ThemeContext.Provider\n value={reduceTheme(prevTheme, theme)}\n children={children}\n />\n </Tag>\n ),\n [children, Tag, theme]\n );\n\n return <ThemeContext.Consumer children={themeConsumer} />;\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,WAAhB,QAAmC,OAAnC;SACSC,Y;SACAC,a,EAAeC,W;AAuBxB,OAAO,MAAMC,aAAa,GAAIC,KAAD,IAA6C;EACxE,MAAM;IAAEC,EAAE,EAAEC,GAAG,GAAG,MAAZ;IAAoBC,KAApB;IAA2BC;EAA3B,IAAwCJ,KAA9C;EAEA,MAAMK,aAAa,GAAGV,WAAW,CAC9BW,SAAD,IACE,oBAAC,GAAD;IAAK,KAAK,EAAET,aAAa,CAACM,KAAD;EAAzB,GACE,oBAAC,YAAD,CAAc,QAAd;IACE,KAAK,EAAEL,WAAW,CAACQ,SAAD,EAAYH,KAAZ,CADpB;IAEE,QAAQ,EAAEC;EAFZ,EADF,CAF6B,EAS/B,CAACA,QAAD,EAAWF,GAAX,EAAgBC,KAAhB,CAT+B,CAAjC;EAYA,OAAO,oBAAC,YAAD,CAAc,QAAd;IAAuB,QAAQ,EAAEE;EAAjC,EAAP;AACD,CAhBM"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/ThemeProvider/useTheme.ts"],"names":["useContext","ThemeContext","useTheme"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,UAAT,QAA2B,OAA3B;SACSC,Y;AAGT,OAAO,MAAMC,QAAQ,GAAG,MAAaF,UAAU,CAACC,YAAD,CAAxC","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { useContext } from \"react\";\nimport { ThemeContext } from \"./context\";\nimport type { Theme } from \"./context\";\n\nexport const useTheme = (): Theme => useContext(ThemeContext);\n"],"file":"useTheme.js"}
{"version":3,"file":"useTheme.js","names":["useContext","ThemeContext","useTheme"],"sources":["../../src/ThemeProvider/useTheme.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { useContext } from \"react\";\nimport { ThemeContext } from \"./context\";\nimport type { Theme } from \"./context\";\n\nexport const useTheme = (): Theme => useContext(ThemeContext);\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,UAAT,QAA2B,OAA3B;SACSC,Y;AAGT,OAAO,MAAMC,QAAQ,GAAG,MAAaF,UAAU,CAACC,YAAD,CAAxC"}

@@ -17,15 +17,25 @@ /*!

if (prevTheme === nextTheme) return prevTheme;
return Object.entries(nextTheme).reduce((memo, [k, v]) => isThemeValue(v) ? { ...memo,
[k]: v
} : memo, prevTheme);
return Object.entries(nextTheme).reduce((memo, _ref) => {
let [k, v] = _ref;
return isThemeValue(v) ? { ...memo,
[k]: v
} : memo;
}, prevTheme);
};
export const asCustomProps = theme => {
return Object.fromEntries(Object.entries(flat(theme)).map(([k, v]) => ["--" + k, v]));
return Object.fromEntries(Object.entries(flat(theme)).map(_ref2 => {
let [k, v] = _ref2;
return ["--" + k, v];
}));
};
function flat(theme, prefix = "") {
return Object.entries(theme).reduce((memo, [k, v]) => Object.assign(memo, v === Object(v) ? flat(v, k + "-") : {
[prefix + k]: v
}), {});
function flat(theme) {
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
return Object.entries(theme).reduce((memo, _ref3) => {
let [k, v] = _ref3;
return Object.assign(memo, v === Object(v) ? flat(v, k + "-") : {
[prefix + k]: v
});
}, {});
}
//# sourceMappingURL=utils.js.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/ThemeProvider/utils.ts"],"names":["isThemeValue","value","includes","reduceTheme","prevTheme","nextTheme","Object","entries","reduce","memo","k","v","asCustomProps","theme","fromEntries","flat","map","prefix","assign"],"mappings":"AAAA;AACA;A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","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport type { Theme, PartialTheme, ThemeValue } from \"./context\";\n\nexport const isThemeValue = (value: unknown): value is ThemeValue => {\n return [\"number\", \"string\"].includes(typeof value);\n};\n\nexport const reduceTheme = (\n prevTheme: Theme,\n nextTheme: PartialTheme\n): Theme => {\n if (prevTheme === nextTheme) return prevTheme;\n\n return Object.entries(nextTheme).reduce(\n (memo, [k, v]) => (isThemeValue(v) ? { ...memo, [k]: v } : memo),\n prevTheme\n );\n};\n\nexport const asCustomProps = (\n theme: PartialTheme\n): Record<string, ThemeValue> => {\n return Object.fromEntries(\n Object.entries(flat(theme)).map(([k, v]) => [\"--\" + k, v])\n );\n};\n\nfunction flat(theme: PartialTheme, prefix = \"\"): PartialTheme {\n return Object.entries(theme).reduce(\n (memo, [k, v]) =>\n Object.assign(\n memo,\n v === Object(v) ? flat(v as PartialTheme, k + \"-\") : { [prefix + k]: v }\n ),\n {}\n );\n}\n"],"file":"utils.js"}
{"version":3,"file":"utils.js","names":["isThemeValue","value","includes","reduceTheme","prevTheme","nextTheme","Object","entries","reduce","memo","k","v","asCustomProps","theme","fromEntries","flat","map","prefix","assign"],"sources":["../../src/ThemeProvider/utils.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport type { Theme, PartialTheme, ThemeValue } from \"./context\";\n\nexport const isThemeValue = (value: unknown): value is ThemeValue => {\n return [\"number\", \"string\"].includes(typeof value);\n};\n\nexport const reduceTheme = (\n prevTheme: Theme,\n nextTheme: PartialTheme\n): Theme => {\n if (prevTheme === nextTheme) return prevTheme;\n\n return Object.entries(nextTheme).reduce(\n (memo, [k, v]) => (isThemeValue(v) ? { ...memo, [k]: v } : memo),\n prevTheme\n );\n};\n\nexport const asCustomProps = (\n theme: PartialTheme\n): Record<string, ThemeValue> => {\n return Object.fromEntries(\n Object.entries(flat(theme)).map(([k, v]) => [\"--\" + k, v])\n );\n};\n\nfunction flat(theme: PartialTheme, prefix = \"\"): PartialTheme {\n return Object.entries(theme).reduce(\n (memo, [k, v]) =>\n Object.assign(\n memo,\n v === Object(v) ? flat(v as PartialTheme, k + \"-\") : { [prefix + k]: v }\n ),\n {}\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA,OAAO,MAAMA,YAAY,GAAIC,KAAD,IAAyC;EACnE,OAAO,CAAC,QAAD,EAAW,QAAX,EAAqBC,QAArB,CAA8B,OAAOD,KAArC,CAAP;AACD,CAFM;AAIP,OAAO,MAAME,WAAW,GAAG,CACzBC,SADyB,EAEzBC,SAFyB,KAGf;EACV,IAAID,SAAS,KAAKC,SAAlB,EAA6B,OAAOD,SAAP;EAE7B,OAAOE,MAAM,CAACC,OAAP,CAAeF,SAAf,EAA0BG,MAA1B,CACL,CAACC,IAAD;IAAA,IAAO,CAACC,CAAD,EAAIC,CAAJ,CAAP;IAAA,OAAmBX,YAAY,CAACW,CAAD,CAAZ,GAAkB,EAAE,GAAGF,IAAL;MAAW,CAACC,CAAD,GAAKC;IAAhB,CAAlB,GAAwCF,IAA3D;EAAA,CADK,EAELL,SAFK,CAAP;AAID,CAVM;AAYP,OAAO,MAAMQ,aAAa,GACxBC,KAD2B,IAEI;EAC/B,OAAOP,MAAM,CAACQ,WAAP,CACLR,MAAM,CAACC,OAAP,CAAeQ,IAAI,CAACF,KAAD,CAAnB,EAA4BG,GAA5B,CAAgC;IAAA,IAAC,CAACN,CAAD,EAAIC,CAAJ,CAAD;IAAA,OAAY,CAAC,OAAOD,CAAR,EAAWC,CAAX,CAAZ;EAAA,CAAhC,CADK,CAAP;AAGD,CANM;;AAQP,SAASI,IAAT,CAAcF,KAAd,EAA8D;EAAA,IAA3BI,MAA2B,uEAAlB,EAAkB;EAC5D,OAAOX,MAAM,CAACC,OAAP,CAAeM,KAAf,EAAsBL,MAAtB,CACL,CAACC,IAAD;IAAA,IAAO,CAACC,CAAD,EAAIC,CAAJ,CAAP;IAAA,OACEL,MAAM,CAACY,MAAP,CACET,IADF,EAEEE,CAAC,KAAKL,MAAM,CAACK,CAAD,CAAZ,GAAkBI,IAAI,CAACJ,CAAD,EAAoBD,CAAC,GAAG,GAAxB,CAAtB,GAAqD;MAAE,CAACO,MAAM,GAAGP,CAAV,GAAcC;IAAhB,CAFvD,CADF;EAAA,CADK,EAML,EANK,CAAP;AAQD"}

@@ -1,2 +0,2 @@

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -62,3 +62,4 @@ /*!

templateThemeEntry([key, candidate]) {
templateThemeEntry(_ref) {
let [key, candidate] = _ref;
const isMappedValue = Array.isArray(candidate);

@@ -65,0 +66,0 @@ const fallbackValue = isMappedValue ? candidate[1] : candidate;

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/withTheme/factory.tsx"],"names":["React","Component","supportsCustomProperties","OStyleSheet","sheet","withThemeFactory","themeReducer","styles","Composed","__digest","digest","__template","template","WithTheme","constructor","props","has","inject","themedStyles","templateTheme","Object","fromEntries","entries","componentTheme","map","templateThemeEntry","Proxy","get","target","key","TypeError","String","displayName","reducerTheme","shallowCopyTheme","assign","create","theme","candidate","isMappedValue","Array","isArray","fallbackValue","value","name","render","composedRef","ref","rest","ComposedComponent"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;SAQSC,wB;SACAC,W;AAET,MAAMC,KAAK,GAAG,IAAID,WAAJ,EAAd;AAuBA,OAAO,SAASE,gBAAT,CAKLC,YALK,EAMLC,MANK,EAOLC,QAPK,EAQuD;AAE5D,QAAM;AAAEC,IAAAA,QAAQ,EAAEC,MAAZ;AAAoBC,IAAAA,UAAU,EAAEC;AAAhC,MAA6CL,MAAnD;AAEA,SAAO,MAAMM,SAAN,SAAwBZ,SAAxB,CAAyC;AAC9Ca,IAAAA,WAAW,CAACC,KAAD,EAAe;AACxB,YAAMA,KAAN;AAEA,UAAI,OAAOH,QAAP,KAAoB,UAAxB,EAAoC;AACpC,UAAIR,KAAK,CAACY,GAAN,CAAUN,MAAV,CAAJ,EAAuB;AAEvBN,MAAAA,KAAK,CAACa,MAAN,CAAaP,MAAb,EAAqB,KAAKQ,YAA1B;AACD;;AAEuB,QAAZA,YAAY,GAAW;AACjC,aAAQN,QAAD,CAAuB,KAAKO,aAA5B,CAAP;AACD;;AAEwB,QAAbA,aAAa,GAAkB;AACzC,YAAMA,aAA4B,GAAGC,MAAM,CAACC,WAAP,CACnCD,MAAM,CAACE,OAAP,CAAe,KAAKC,cAApB,EAAoCC,GAApC,CAAwC,KAAKC,kBAA7C,CADmC,CAArC;A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AAI,KAAII,aAAc,IADrD,GAEV,SAAQhC,MAAO,IAAGmB,GAAI,KAAIa,aAAc,GAHT,GAIlCA,aAJJ;AAMA,aAAO,CAACb,GAAD,EAAMc,KAAN,CAAP;AACD;;AAEsB,QAAXX,WAAW,GAAW;AAChC,aAAOxB,QAAQ,CAACwB,WAAT,IAAwBxB,QAAQ,CAACoC,IAAjC,IAAyC,WAAhD;AACD;;AAEQC,IAAAA,MAAM,GAAG;AAEhB,YAAM;AAAEC,QAAAA,WAAW,EAAEC,GAAf;AAAoBV,QAAAA,KAApB;AAA2B,WAAGW;AAA9B,UAAuC,KAAKjC,KAAlD;AACA,YAAMkC,iBAAgC,GAAGzC,QAAzC;AACA,aAAO,oBAAC,iBAAD;AAAmB,QAAA,GAAG,EAAEuC;AAAxB,SAAiCC,IAAjC,EAAP;AACD;;AA7E6C,GAAhD;AA+ED","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { Component } from \"react\";\nimport type {\n ForwardedRef,\n ComponentType,\n NamedExoticComponent,\n ComponentClass,\n} from \"react\";\nimport type { Theme, ThemeKey, ThemeValue } from \"../ThemeProvider/context\";\nimport { supportsCustomProperties } from \"./utils\";\nimport { OStyleSheet } from \"./stylesheet\";\n\nconst sheet = new OStyleSheet();\n\ntype SourceStyles = Record<string, string>;\ntype TemplateTheme = Record<string, ThemeValue>;\ninterface TranspiledStyles {\n __digest: string;\n __template: (theme: TemplateTheme) => string;\n}\n\ntype ComponentThemeValue = ThemeValue | [ThemeKey, ThemeValue];\nexport type ComponentTheme = Record<string, ComponentThemeValue>;\ntype VirtualComponentTheme = Record<string, ThemeValue>;\nexport type ThemeReducer = (theme: Theme) => VirtualComponentTheme;\n\nexport type Template = TranspiledStyles[\"__template\"];\nexport type Styles = SourceStyles | TranspiledStyles;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Composable = ComponentType<any> | NamedExoticComponent<any>;\ntype WithThemeProps<P, R> = P & {\n theme: Theme;\n composedRef: ForwardedRef<R>;\n};\n\nexport function withThemeFactory<\n ComposedRef,\n ComposedProps,\n C extends Composable\n>(\n themeReducer: ThemeReducer,\n styles: Styles,\n Composed: C\n): ComponentClass<WithThemeProps<ComposedProps, ComposedRef>> {\n type Props = WithThemeProps<ComposedProps, ComposedRef>;\n const { __digest: digest, __template: template } = styles;\n\n return class WithTheme extends Component<Props> {\n constructor(props: Props) {\n super(props);\n\n if (typeof template !== \"function\") return;\n if (sheet.has(digest)) return;\n\n sheet.inject(digest, this.themedStyles);\n }\n\n private get themedStyles(): string {\n return (template as Template)(this.templateTheme);\n }\n\n private get templateTheme(): TemplateTheme {\n const templateTheme: TemplateTheme = Object.fromEntries(\n Object.entries(this.componentTheme).map(this.templateThemeEntry)\n );\n\n return new Proxy(templateTheme, {\n get: (target, key) => {\n if (key in target) return target[key as string];\n throw new TypeError(\n `Missing property '${String(key)}' within ${\n this.displayName\n } style module`\n );\n },\n });\n }\n\n private get componentTheme(): ComponentTheme {\n return themeReducer(this.reducerTheme);\n }\n\n private get reducerTheme(): Theme {\n return new Proxy(this.shallowCopyTheme, {\n get: (target, key) => {\n if (key in target) return [key, target[key as keyof Theme]];\n throw new TypeError(\n `Missing property '${String(key)}' within ${\n this.displayName\n } theme module`\n );\n },\n });\n }\n\n private get shallowCopyTheme(): Theme {\n return Object.assign(Object.create(null), this.props.theme);\n }\n\n private templateThemeEntry([key, candidate]: [\n string,\n ComponentThemeValue\n ]): [string, ThemeValue] {\n const isMappedValue = Array.isArray(candidate);\n const fallbackValue = isMappedValue ? candidate[1] : candidate;\n\n const value = supportsCustomProperties\n ? isMappedValue\n ? `var(--${digest}-${key}, var(--${candidate[0]}, ${fallbackValue}))`\n : `var(--${digest}-${key}, ${fallbackValue})`\n : fallbackValue;\n\n return [key, value];\n }\n\n private get displayName(): string {\n return Composed.displayName || Composed.name || \"Component\";\n }\n\n override render() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { composedRef: ref, theme, ...rest } = this.props;\n const ComposedComponent: ComponentType = Composed;\n return <ComposedComponent ref={ref} {...rest} />;\n }\n };\n}\n"],"file":"factory.js"}
{"version":3,"file":"factory.js","names":["React","Component","supportsCustomProperties","OStyleSheet","sheet","withThemeFactory","themeReducer","styles","Composed","__digest","digest","__template","template","WithTheme","constructor","props","has","inject","themedStyles","templateTheme","Object","fromEntries","entries","componentTheme","map","templateThemeEntry","Proxy","get","target","key","TypeError","String","displayName","reducerTheme","shallowCopyTheme","assign","create","theme","candidate","isMappedValue","Array","isArray","fallbackValue","value","name","render","composedRef","ref","rest","ComposedComponent"],"sources":["../../src/withTheme/factory.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { Component } from \"react\";\nimport type {\n ForwardedRef,\n ComponentType,\n NamedExoticComponent,\n ComponentClass,\n} from \"react\";\nimport type { Theme, ThemeKey, ThemeValue } from \"../ThemeProvider/context\";\nimport { supportsCustomProperties } from \"./utils\";\nimport { OStyleSheet } from \"./stylesheet\";\n\nconst sheet = new OStyleSheet();\n\ntype SourceStyles = Record<string, string>;\ntype TemplateTheme = Record<string, ThemeValue>;\ninterface TranspiledStyles {\n __digest: string;\n __template: (theme: TemplateTheme) => string;\n}\n\ntype ComponentThemeValue = ThemeValue | [ThemeKey, ThemeValue];\nexport type ComponentTheme = Record<string, ComponentThemeValue>;\ntype VirtualComponentTheme = Record<string, ThemeValue>;\nexport type ThemeReducer = (theme: Theme) => VirtualComponentTheme;\n\nexport type Template = TranspiledStyles[\"__template\"];\nexport type Styles = SourceStyles | TranspiledStyles;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Composable = ComponentType<any> | NamedExoticComponent<any>;\ntype WithThemeProps<P, R> = P & {\n theme: Theme;\n composedRef: ForwardedRef<R>;\n};\n\nexport function withThemeFactory<\n ComposedRef,\n ComposedProps,\n C extends Composable\n>(\n themeReducer: ThemeReducer,\n styles: Styles,\n Composed: C\n): ComponentClass<WithThemeProps<ComposedProps, ComposedRef>> {\n type Props = WithThemeProps<ComposedProps, ComposedRef>;\n const { __digest: digest, __template: template } = styles;\n\n return class WithTheme extends Component<Props> {\n constructor(props: Props) {\n super(props);\n\n if (typeof template !== \"function\") return;\n if (sheet.has(digest)) return;\n\n sheet.inject(digest, this.themedStyles);\n }\n\n private get themedStyles(): string {\n return (template as Template)(this.templateTheme);\n }\n\n private get templateTheme(): TemplateTheme {\n const templateTheme: TemplateTheme = Object.fromEntries(\n Object.entries(this.componentTheme).map(this.templateThemeEntry)\n );\n\n return new Proxy(templateTheme, {\n get: (target, key) => {\n if (key in target) return target[key as string];\n throw new TypeError(\n `Missing property '${String(key)}' within ${\n this.displayName\n } style module`\n );\n },\n });\n }\n\n private get componentTheme(): ComponentTheme {\n return themeReducer(this.reducerTheme);\n }\n\n private get reducerTheme(): Theme {\n return new Proxy(this.shallowCopyTheme, {\n get: (target, key) => {\n if (key in target) return [key, target[key as keyof Theme]];\n throw new TypeError(\n `Missing property '${String(key)}' within ${\n this.displayName\n } theme module`\n );\n },\n });\n }\n\n private get shallowCopyTheme(): Theme {\n return Object.assign(Object.create(null), this.props.theme);\n }\n\n private templateThemeEntry([key, candidate]: [\n string,\n ComponentThemeValue\n ]): [string, ThemeValue] {\n const isMappedValue = Array.isArray(candidate);\n const fallbackValue = isMappedValue ? candidate[1] : candidate;\n\n const value = supportsCustomProperties\n ? isMappedValue\n ? `var(--${digest}-${key}, var(--${candidate[0]}, ${fallbackValue}))`\n : `var(--${digest}-${key}, ${fallbackValue})`\n : fallbackValue;\n\n return [key, value];\n }\n\n private get displayName(): string {\n return Composed.displayName || Composed.name || \"Component\";\n }\n\n override render() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { composedRef: ref, theme, ...rest } = this.props;\n const ComposedComponent: ComponentType = Composed;\n return <ComposedComponent ref={ref} {...rest} />;\n }\n };\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,SAAhB,QAAiC,OAAjC;SAQSC,wB;SACAC,W;AAET,MAAMC,KAAK,GAAG,IAAID,WAAJ,EAAd;AAuBA,OAAO,SAASE,gBAAT,CAKLC,YALK,EAMLC,MANK,EAOLC,QAPK,EAQuD;EAE5D,MAAM;IAAEC,QAAQ,EAAEC,MAAZ;IAAoBC,UAAU,EAAEC;EAAhC,IAA6CL,MAAnD;EAEA,OAAO,MAAMM,SAAN,SAAwBZ,SAAxB,CAAyC;IAC9Ca,WAAW,CAACC,KAAD,EAAe;MACxB,MAAMA,KAAN;MAEA,IAAI,OAAOH,QAAP,KAAoB,UAAxB,EAAoC;MACpC,IAAIR,KAAK,CAACY,GAAN,CAAUN,MAAV,CAAJ,EAAuB;MAEvBN,KAAK,CAACa,MAAN,CAAaP,MAAb,EAAqB,KAAKQ,YAA1B;IACD;;IAEuB,IAAZA,YAAY,GAAW;MACjC,OAAQN,QAAD,CAAuB,KAAKO,aAA5B,CAAP;IACD;;IAEwB,IAAbA,aAAa,GAAkB;MACzC,MAAMA,aAA4B,GAAGC,MAAM,CAACC,WAAP,CACnCD,MAAM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Aa,GACV,SAAQ7B,MAAO,IAAGmB,GAAI,WAAUS,SAAS,CAAC,CAAD,CAAI,KAAII,aAAc,IADrD,GAEV,SAAQhC,MAAO,IAAGmB,GAAI,KAAIa,aAAc,GAHT,GAIlCA,aAJJ;MAMA,OAAO,CAACb,GAAD,EAAMc,KAAN,CAAP;IACD;;IAEsB,IAAXX,WAAW,GAAW;MAChC,OAAOxB,QAAQ,CAACwB,WAAT,IAAwBxB,QAAQ,CAACoC,IAAjC,IAAyC,WAAhD;IACD;;IAEQC,MAAM,GAAG;MAEhB,MAAM;QAAEC,WAAW,EAAEC,GAAf;QAAoBV,KAApB;QAA2B,GAAGW;MAA9B,IAAuC,KAAKjC,KAAlD;MACA,MAAMkC,iBAAgC,GAAGzC,QAAzC;MACA,OAAO,oBAAC,iBAAD;QAAmB,GAAG,EAAEuC;MAAxB,GAAiCC,IAAjC,EAAP;IACD;;EA7E6C,CAAhD;AA+ED"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/withTheme/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from \"./withTheme\";\nexport type { ThemeReducer } from \"./factory\";\n"],"file":"index.js"}
{"version":3,"file":"index.js","names":[],"sources":["../../src/withTheme/index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from \"./withTheme\";\nexport type { ThemeReducer } from \"./factory\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/withTheme/stylesheet.ts"],"names":["OStyleSheet","Set","constructor","el","document","createElement","setAttribute","window","cspNonce","element","head","appendChild","inject","key","styles","has","innerHTML","add"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,WAAN,SAA0BC,GAA1B,CAAsC;AAG3CC,EAAAA,WAAW,GAAG;AACZ;AACA,UAAMC,EAAE,GAAGC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAX;AACAF,IAAAA,EAAE,CAACG,YAAH,CAAgB,UAAhB,EAA4B,EAA5B;AAEAH,IAAAA,EAAE,CAACG,YAAH,CAAgB,OAAhB,EAAyBC,MAAM,CAACC,QAAhC;AACA,SAAKC,OAAL,GAAeL,QAAQ,CAACM,IAAT,CAAcC,WAAd,CAA0BR,EAA1B,CAAf;AACD;;AAEDS,EAAAA,MAAM,CAACC,GAAD,EAAcC,MAAd,EAAuC;AAC3C,QAAI,KAAKC,GAAL,CAASF,GAAT,CAAJ,EAAmB,OAAO,KAAP;AACnB,SAAKJ,OAAL,CAAaO,SAAb,IAA0BF,MAA1B;AACA,SAAKG,GAAL,CAASJ,GAAT;AACA,WAAO,IAAP;AACD;;AAjB0C","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport class OStyleSheet extends Set<string> {\n private element: HTMLStyleElement;\n\n constructor() {\n super();\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-ods\", \"\");\n // @ts-expect-error ts(2339)\n el.setAttribute(\"nonce\", window.cspNonce);\n this.element = document.head.appendChild(el);\n }\n\n inject(key: string, styles: string): boolean {\n if (this.has(key)) return false;\n this.element.innerHTML += styles;\n this.add(key);\n return true;\n }\n}\n"],"file":"stylesheet.js"}
{"version":3,"file":"stylesheet.js","names":["OStyleSheet","Set","constructor","el","document","createElement","setAttribute","window","cspNonce","element","head","appendChild","inject","key","styles","has","innerHTML","add"],"sources":["../../src/withTheme/stylesheet.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport class OStyleSheet extends Set<string> {\n private element: HTMLStyleElement;\n\n constructor() {\n super();\n const el = document.createElement(\"style\");\n el.setAttribute(\"data-ods\", \"\");\n // @ts-expect-error ts(2339)\n el.setAttribute(\"nonce\", window.cspNonce);\n this.element = document.head.appendChild(el);\n }\n\n inject(key: string, styles: string): boolean {\n if (this.has(key)) return false;\n this.element.innerHTML += styles;\n this.add(key);\n return true;\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,WAAN,SAA0BC,GAA1B,CAAsC;EAG3CC,WAAW,GAAG;IACZ;IACA,MAAMC,EAAE,GAAGC,QAAQ,CAACC,aAAT,CAAuB,OAAvB,CAAX;IACAF,EAAE,CAACG,YAAH,CAAgB,UAAhB,EAA4B,EAA5B;IAEAH,EAAE,CAACG,YAAH,CAAgB,OAAhB,EAAyBC,MAAM,CAACC,QAAhC;IACA,KAAKC,OAAL,GAAeL,QAAQ,CAACM,IAAT,CAAcC,WAAd,CAA0BR,EAA1B,CAAf;EACD;;EAEDS,MAAM,CAACC,GAAD,EAAcC,MAAd,EAAuC;IAC3C,IAAI,KAAKC,GAAL,CAASF,GAAT,CAAJ,EAAmB,OAAO,KAAP;IACnB,KAAKJ,OAAL,CAAaO,SAAb,IAA0BF,MAA1B;IACA,KAAKG,GAAL,CAASJ,GAAT;IACA,OAAO,IAAP;EACD;;AAjB0C"}

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/withTheme/utils.ts"],"names":["supportsCustomProperties","window","CSS","supports","_"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,wBAAiC,GAAG,CAAC,MAAM;AACtD,MAAI;AACF,WAAOC,MAAM,CAACC,GAAP,CAAWC,QAAX,CAAoB,sBAApB,CAAP;AACD,GAFD,CAEE,OAAOC,CAAP,EAAU;AACV,WAAO,KAAP;AACD;AACF,CANgD,GAA1C","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport const supportsCustomProperties: boolean = (() => {\n try {\n return window.CSS.supports(\"--custom: properties\");\n } catch (_) {\n return false;\n }\n})();\n"],"file":"utils.js"}
{"version":3,"file":"utils.js","names":["supportsCustomProperties","window","CSS","supports","_"],"sources":["../../src/withTheme/utils.ts"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport const supportsCustomProperties: boolean = (() => {\n try {\n return window.CSS.supports(\"--custom: properties\");\n } catch (_) {\n return false;\n }\n})();\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAO,MAAMA,wBAAiC,GAAG,CAAC,MAAM;EACtD,IAAI;IACF,OAAOC,MAAM,CAACC,GAAP,CAAWC,QAAX,CAAoB,sBAApB,CAAP;EACD,CAFD,CAEE,OAAOC,CAAP,EAAU;IACV,OAAO,KAAP;EACD;AACF,CANgD,GAA1C"}

@@ -1,2 +0,2 @@

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

@@ -3,0 +3,0 @@ /*!

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/withTheme/withTheme.tsx"],"names":["React","forwardRef","useCallback","hoistNonReactStatics","withThemeFactory","ThemeContext","withTheme","themeReducer","styles","Composed","WithTheme","Object","assign","props","ref","themeConsumer","theme","__digest"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,WAA5B,QAA+C,OAA/C;AAEA,OAAOC,oBAAP,MAAiC,yBAAjC;SACSC,gB;SAEAC,Y;AAST,OAAO,SAASC,SAAT,CAAmBC,YAAnB,EAA+CC,MAA/C,EAA+D;AACpE,SAA8BC,QAAvB,IAAqD;AAI1D,UAAMC,SAAS,GAAGN,gBAAgB,CAChCG,YADgC,EAEhCC,MAFgC,EAGhCC,QAHgC,CAAlC;AAMA,WAAON,oBAAoB,CACzBQ,MAAM,CAACC,MAAP,CACEX,UAAU,CAAa,CAACY,KAAD,EAAQC,GAAR,KAAgB;AACrC,YAAMC,aAAa,GAAGb,WAAW,CAC9Bc,KAAD,IAAW,oBAAC,SAAD,eAAeH,KAAf;AAAsB,QAAA,KAAK,EAAEG,KAA7B;AAAoC,QAAA,WAAW,EAAEF;AAAjD,SADoB,EAE/B,CAACD,KAAD,EAAQC,GAAR,CAF+B,CAAjC;AAKA,aAAO,oBAAC,YAAD,CAAc,QAAd;AAAuB,QAAA,QAAQ,EAAEC;AAAjC,QAAP;AACD,KAPS,CADZ,EASE;AACEC,MAAAA,KAAK,EAAER,MAAM,CAACS;AADhB,KATF,CADyB,EAczBR,QAdyB,CAA3B;AAgBD,GA1BD;AA2BD","sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { forwardRef, useCallback } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\nimport { withThemeFactory } from \"./factory\";\nimport type { Composable, Styles, ThemeReducer } from \"./factory\";\nimport { ThemeContext } from \"../ThemeProvider/context\";\n\ntype WithTheme<C> = C & { theme: string };\n\n/**\n * A higher order component to apply themed styles\n * @param theme - a theme reducer function which maps global values to component values\n * @param styles - a CSS module object transpiled by theme build tooling\n */\nexport function withTheme(themeReducer: ThemeReducer, styles: Styles) {\n return <C extends Composable>(Composed: C): WithTheme<C> => {\n type Ref = ElementRef<C>;\n type Props = ComponentPropsWithoutRef<C>;\n\n const WithTheme = withThemeFactory<Ref, Props, typeof Composed>(\n themeReducer,\n styles,\n Composed\n );\n\n return hoistNonReactStatics(\n Object.assign(\n forwardRef<Ref, Props>((props, ref) => {\n const themeConsumer = useCallback(\n (theme) => <WithTheme {...props} theme={theme} composedRef={ref} />,\n [props, ref]\n );\n\n return <ThemeContext.Consumer children={themeConsumer} />;\n }),\n {\n theme: styles.__digest,\n }\n ),\n Composed\n ) as unknown as WithTheme<C>;\n };\n}\n"],"file":"withTheme.js"}
{"version":3,"file":"withTheme.js","names":["React","forwardRef","useCallback","hoistNonReactStatics","withThemeFactory","ThemeContext","withTheme","themeReducer","styles","Composed","WithTheme","Object","assign","props","ref","themeConsumer","theme","__digest"],"sources":["../../src/withTheme/withTheme.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2021-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport React, { forwardRef, useCallback } from \"react\";\nimport type { ComponentPropsWithoutRef, ElementRef } from \"react\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\nimport { withThemeFactory } from \"./factory\";\nimport type { Composable, Styles, ThemeReducer } from \"./factory\";\nimport { ThemeContext } from \"../ThemeProvider/context\";\n\ntype WithTheme<C> = C & { theme: string };\n\n/**\n * A higher order component to apply themed styles\n * @param theme - a theme reducer function which maps global values to component values\n * @param styles - a CSS module object transpiled by theme build tooling\n */\nexport function withTheme(themeReducer: ThemeReducer, styles: Styles) {\n return <C extends Composable>(Composed: C): WithTheme<C> => {\n type Ref = ElementRef<C>;\n type Props = ComponentPropsWithoutRef<C>;\n\n const WithTheme = withThemeFactory<Ref, Props, typeof Composed>(\n themeReducer,\n styles,\n Composed\n );\n\n return hoistNonReactStatics(\n Object.assign(\n forwardRef<Ref, Props>((props, ref) => {\n const themeConsumer = useCallback(\n (theme) => <WithTheme {...props} theme={theme} composedRef={ref} />,\n [props, ref]\n );\n\n return <ThemeContext.Consumer children={themeConsumer} />;\n }),\n {\n theme: styles.__digest,\n }\n ),\n Composed\n ) as unknown as WithTheme<C>;\n };\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,OAAOA,KAAP,IAAgBC,UAAhB,EAA4BC,WAA5B,QAA+C,OAA/C;AAEA,OAAOC,oBAAP,MAAiC,yBAAjC;SACSC,gB;SAEAC,Y;AAST,OAAO,SAASC,SAAT,CAAmBC,YAAnB,EAA+CC,MAA/C,EAA+D;EACpE,OAA8BC,QAAvB,IAAqD;IAI1D,MAAMC,SAAS,GAAGN,gBAAgB,CAChCG,YADgC,EAEhCC,MAFgC,EAGhCC,QAHgC,CAAlC;IAMA,OAAON,oBAAoB,CACzBQ,MAAM,CAACC,MAAP,CACEX,UAAU,CAAa,CAACY,KAAD,EAAQC,GAAR,KAAgB;MACrC,MAAMC,aAAa,GAAGb,WAAW,CAC9Bc,KAAD,IAAW,oBAAC,SAAD,eAAeH,KAAf;QAAsB,KAAK,EAAEG,KAA7B;QAAoC,WAAW,EAAEF;MAAjD,GADoB,EAE/B,CAACD,KAAD,EAAQC,GAAR,CAF+B,CAAjC;MAKA,OAAO,oBAAC,YAAD,CAAc,QAAd;QAAuB,QAAQ,EAAEC;MAAjC,EAAP;IACD,CAPS,CADZ,EASE;MACEC,KAAK,EAAER,MAAM,CAACS;IADhB,CATF,CADyB,EAczBR,QAdyB,CAA3B;EAgBD,CA1BD;AA2BD"}
{
"name": "@okta/odyssey-react-theme",
"version": "0.15.0",
"version": "0.15.1",
"description": "React theme logic for Odyssey, Okta's design system",
"author": "Okta, Inc.",
"license": "Apache-2.0",
"sideEffects": false,
"main": "dist/index.js",

@@ -11,3 +12,2 @@ "module": "dist/index.js",

"type": "module",
"sideEffects": false,
"exports": {

@@ -24,3 +24,3 @@ ".": {

"dependencies": {
"@okta/odyssey-design-tokens": "^0.15.0",
"@okta/odyssey-design-tokens": "^0.15.1",
"hoist-non-react-statics": "^3.3.2"

@@ -32,3 +32,3 @@ },

},
"gitHead": "0b9b95e150ac14ec2d65e74d97353ee8b869536b"
"gitHead": "ae87e24beead8b4eaafb35d9fd0e3597c50104dc"
}