@lidofinance/lido-ui 3.0.0-next.4 → 3.0.0-next.7

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.
Files changed (156) hide show
  1. package/dist/cjs/cookie-theme-toggler/src/cookie-theme-toggler.js +4 -4
  2. package/dist/cjs/cookie-theme-toggler/src/cookie-theme-toggler.js.map +1 -1
  3. package/dist/cjs/cookie-theme-toggler/src/index.js +0 -2
  4. package/dist/cjs/cookie-theme-toggler/src/index.js.map +1 -1
  5. package/dist/cjs/cookie-theme-toggler/src/styles.js +25 -3
  6. package/dist/cjs/cookie-theme-toggler/src/styles.js.map +1 -1
  7. package/dist/cjs/hooks/src/useSystemTheme.js +1 -1
  8. package/dist/cjs/hooks/src/useSystemTheme.js.map +1 -1
  9. package/dist/cjs/loaders/src/InlineLoaderStyles.js +2 -2
  10. package/dist/cjs/loaders/src/InlineLoaderStyles.js.map +1 -1
  11. package/dist/cjs/loaders/src/LoaderStyles.js +2 -2
  12. package/dist/cjs/loaders/src/LoaderStyles.js.map +1 -1
  13. package/dist/cjs/theme/src/base/colors.js +2 -0
  14. package/dist/cjs/theme/src/base/colors.js.map +1 -1
  15. package/dist/cjs/theme/src/constants.js +17 -12
  16. package/dist/cjs/theme/src/constants.js.map +1 -1
  17. package/dist/cjs/theme/src/cookie-theme-provider.js +110 -0
  18. package/dist/cjs/theme/src/cookie-theme-provider.js.map +1 -0
  19. package/dist/cjs/theme/src/document-head-contents/element-theme-colors.js +33 -20
  20. package/dist/cjs/theme/src/document-head-contents/element-theme-colors.js.map +1 -1
  21. package/dist/cjs/theme/src/document-head-contents/element-theme-script.js +26 -13
  22. package/dist/cjs/theme/src/document-head-contents/element-theme-script.js.map +1 -1
  23. package/dist/cjs/{cookie-theme-toggler → theme}/src/hooks.js +0 -0
  24. package/dist/cjs/theme/src/hooks.js.map +1 -0
  25. package/dist/cjs/theme/src/index.js +3 -1
  26. package/dist/cjs/theme/src/index.js.map +1 -1
  27. package/dist/cjs/theme/src/{provider.js → theme-provider.js} +13 -8
  28. package/dist/cjs/theme/src/theme-provider.js.map +1 -0
  29. package/dist/cjs/theme/src/themes.js +27 -3
  30. package/dist/cjs/theme/src/themes.js.map +1 -1
  31. package/dist/cjs/theme/src/types.js.map +1 -1
  32. package/dist/cjs/{cookie-theme-toggler/src/utils.js → theme/src/utils/cookies.js} +5 -3
  33. package/dist/cjs/theme/src/utils/cookies.js.map +1 -0
  34. package/dist/cjs/theme/src/{document-head-contents/utils → utils}/generate-css-color-variables.js +2 -2
  35. package/dist/cjs/theme/src/utils/generate-css-color-variables.js.map +1 -0
  36. package/dist/cjs/utils/src/index.js +10 -3
  37. package/dist/cjs/utils/src/index.js.map +1 -1
  38. package/dist/esm/cookie-theme-toggler/src/cookie-theme-toggler.js +4 -4
  39. package/dist/esm/cookie-theme-toggler/src/cookie-theme-toggler.js.map +1 -1
  40. package/dist/esm/cookie-theme-toggler/src/index.js +0 -2
  41. package/dist/esm/cookie-theme-toggler/src/index.js.map +1 -1
  42. package/dist/esm/cookie-theme-toggler/src/styles.js +14 -0
  43. package/dist/esm/cookie-theme-toggler/src/styles.js.map +1 -1
  44. package/dist/esm/hooks/src/useSystemTheme.js +2 -2
  45. package/dist/esm/hooks/src/useSystemTheme.js.map +1 -1
  46. package/dist/esm/loaders/src/InlineLoaderStyles.js +2 -2
  47. package/dist/esm/loaders/src/InlineLoaderStyles.js.map +1 -1
  48. package/dist/esm/loaders/src/LoaderStyles.js +2 -2
  49. package/dist/esm/loaders/src/LoaderStyles.js.map +1 -1
  50. package/dist/esm/theme/src/base/colors.js +2 -0
  51. package/dist/esm/theme/src/base/colors.js.map +1 -1
  52. package/dist/esm/theme/src/constants.js +11 -8
  53. package/dist/esm/theme/src/constants.js.map +1 -1
  54. package/dist/esm/theme/src/cookie-theme-provider.js +102 -0
  55. package/dist/esm/theme/src/cookie-theme-provider.js.map +1 -0
  56. package/dist/esm/theme/src/document-head-contents/element-theme-colors.js +28 -15
  57. package/dist/esm/theme/src/document-head-contents/element-theme-colors.js.map +1 -1
  58. package/dist/esm/theme/src/document-head-contents/element-theme-script.js +24 -10
  59. package/dist/esm/theme/src/document-head-contents/element-theme-script.js.map +1 -1
  60. package/dist/esm/{cookie-theme-toggler → theme}/src/hooks.js +0 -0
  61. package/dist/esm/theme/src/hooks.js.map +1 -0
  62. package/dist/esm/theme/src/index.js +3 -1
  63. package/dist/esm/theme/src/index.js.map +1 -1
  64. package/dist/esm/theme/src/theme-provider.js +37 -0
  65. package/dist/esm/theme/src/theme-provider.js.map +1 -0
  66. package/dist/esm/theme/src/themes.js +23 -1
  67. package/dist/esm/theme/src/themes.js.map +1 -1
  68. package/dist/esm/theme/src/types.js.map +1 -1
  69. package/dist/esm/{cookie-theme-toggler/src/utils.js → theme/src/utils/cookies.js} +5 -3
  70. package/dist/esm/theme/src/utils/cookies.js.map +1 -0
  71. package/dist/esm/theme/src/{document-head-contents/utils → utils}/generate-css-color-variables.js +2 -2
  72. package/dist/esm/theme/src/utils/generate-css-color-variables.js.map +1 -0
  73. package/dist/esm/utils/src/index.js +2 -0
  74. package/dist/esm/utils/src/index.js.map +1 -1
  75. package/dist/types/accordion/src/AccordionStyles.d.ts +1 -1
  76. package/dist/types/checkbox/src/CheckboxStyles.d.ts +1 -1
  77. package/dist/types/cookie-theme-toggler/src/cookie-theme-toggler.d.ts.map +1 -1
  78. package/dist/types/cookie-theme-toggler/src/index.d.ts +0 -2
  79. package/dist/types/cookie-theme-toggler/src/index.d.ts.map +1 -1
  80. package/dist/types/cookie-theme-toggler/src/styles.d.ts +3 -0
  81. package/dist/types/cookie-theme-toggler/src/styles.d.ts.map +1 -1
  82. package/dist/types/data-table/src/DataTableStyles.d.ts +1 -1
  83. package/dist/types/hooks/src/useSystemTheme.d.ts +2 -2
  84. package/dist/types/hooks/src/useSystemTheme.d.ts.map +1 -1
  85. package/dist/types/icons/src/index.d.ts +76 -76
  86. package/dist/types/select/src/Select.d.ts +1 -1
  87. package/dist/types/select/src/SelectArrowStyles.d.ts +1 -1
  88. package/dist/types/select/src/SelectIconStyles.d.ts +1 -1
  89. package/dist/types/select/src/SelectStyles.d.ts +1 -1
  90. package/dist/types/table/src/styles.d.ts +2 -2
  91. package/dist/types/theme/src/base/colors.d.ts +2 -0
  92. package/dist/types/theme/src/base/colors.d.ts.map +1 -1
  93. package/dist/types/theme/src/base/index.d.ts +2 -0
  94. package/dist/types/theme/src/base/index.d.ts.map +1 -1
  95. package/dist/types/theme/src/constants.d.ts +6 -4
  96. package/dist/types/theme/src/constants.d.ts.map +1 -1
  97. package/dist/types/theme/src/cookie-theme-provider.d.ts +17 -0
  98. package/dist/types/theme/src/cookie-theme-provider.d.ts.map +1 -0
  99. package/dist/types/theme/src/document-head-contents/element-theme-colors.d.ts.map +1 -1
  100. package/dist/types/theme/src/document-head-contents/element-theme-script.d.ts +0 -1
  101. package/dist/types/theme/src/document-head-contents/element-theme-script.d.ts.map +1 -1
  102. package/dist/types/theme/src/hooks.d.ts +3 -0
  103. package/dist/types/theme/src/hooks.d.ts.map +1 -0
  104. package/dist/types/theme/src/index.d.ts +3 -1
  105. package/dist/types/theme/src/index.d.ts.map +1 -1
  106. package/dist/types/theme/src/theme-provider.d.ts +8 -0
  107. package/dist/types/theme/src/theme-provider.d.ts.map +1 -0
  108. package/dist/types/theme/src/themes.d.ts +438 -1
  109. package/dist/types/theme/src/themes.d.ts.map +1 -1
  110. package/dist/types/theme/src/types.d.ts +5 -1
  111. package/dist/types/theme/src/types.d.ts.map +1 -1
  112. package/dist/types/theme/src/utils/cookies.d.ts +3 -0
  113. package/dist/types/theme/src/utils/cookies.d.ts.map +1 -0
  114. package/dist/types/theme/src/{document-head-contents/utils → utils}/generate-css-color-variables.d.ts +0 -0
  115. package/dist/types/theme/src/utils/generate-css-color-variables.d.ts.map +1 -0
  116. package/dist/types/utils/src/index.d.ts +1 -0
  117. package/dist/types/utils/src/index.d.ts.map +1 -1
  118. package/package.json +2 -2
  119. package/dist/cjs/cookie-theme-toggler/src/constants.js +0 -18
  120. package/dist/cjs/cookie-theme-toggler/src/constants.js.map +0 -1
  121. package/dist/cjs/cookie-theme-toggler/src/cookie-theme-provider.js +0 -66
  122. package/dist/cjs/cookie-theme-toggler/src/cookie-theme-provider.js.map +0 -1
  123. package/dist/cjs/cookie-theme-toggler/src/hooks.js.map +0 -1
  124. package/dist/cjs/cookie-theme-toggler/src/utils.js.map +0 -1
  125. package/dist/cjs/theme/src/document-head-contents/utils/generate-css-color-variables.js.map +0 -1
  126. package/dist/cjs/theme/src/globals.js +0 -26
  127. package/dist/cjs/theme/src/globals.js.map +0 -1
  128. package/dist/cjs/theme/src/provider.js.map +0 -1
  129. package/dist/cjs/theme/src/styles.js +0 -47
  130. package/dist/cjs/theme/src/styles.js.map +0 -1
  131. package/dist/esm/cookie-theme-toggler/src/constants.js +0 -4
  132. package/dist/esm/cookie-theme-toggler/src/constants.js.map +0 -1
  133. package/dist/esm/cookie-theme-toggler/src/cookie-theme-provider.js +0 -53
  134. package/dist/esm/cookie-theme-toggler/src/cookie-theme-provider.js.map +0 -1
  135. package/dist/esm/cookie-theme-toggler/src/hooks.js.map +0 -1
  136. package/dist/esm/cookie-theme-toggler/src/utils.js.map +0 -1
  137. package/dist/esm/theme/src/document-head-contents/utils/generate-css-color-variables.js.map +0 -1
  138. package/dist/esm/theme/src/globals.js +0 -11
  139. package/dist/esm/theme/src/globals.js.map +0 -1
  140. package/dist/esm/theme/src/provider.js +0 -32
  141. package/dist/esm/theme/src/provider.js.map +0 -1
  142. package/dist/esm/theme/src/styles.js +0 -38
  143. package/dist/esm/theme/src/styles.js.map +0 -1
  144. package/dist/types/cookie-theme-toggler/src/constants.d.ts +0 -3
  145. package/dist/types/cookie-theme-toggler/src/constants.d.ts.map +0 -1
  146. package/dist/types/cookie-theme-toggler/src/cookie-theme-provider.d.ts +0 -13
  147. package/dist/types/cookie-theme-toggler/src/cookie-theme-provider.d.ts.map +0 -1
  148. package/dist/types/cookie-theme-toggler/src/hooks.d.ts +0 -3
  149. package/dist/types/cookie-theme-toggler/src/hooks.d.ts.map +0 -1
  150. package/dist/types/cookie-theme-toggler/src/utils.d.ts +0 -3
  151. package/dist/types/cookie-theme-toggler/src/utils.d.ts.map +0 -1
  152. package/dist/types/theme/src/document-head-contents/utils/generate-css-color-variables.d.ts.map +0 -1
  153. package/dist/types/theme/src/globals.d.ts +0 -8
  154. package/dist/types/theme/src/globals.d.ts.map +0 -1
  155. package/dist/types/theme/src/provider.d.ts +0 -11
  156. package/dist/types/theme/src/provider.d.ts.map +0 -1
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "ThemeToggler", {
6
6
  enumerable: true,
7
7
  get: ()=>ThemeToggler
8
8
  });
9
- const _icons = require("../../icons/src/index");
10
9
  const _styles = require("./styles");
11
- const _hooks = require("./hooks");
10
+ const _icons = require("../../icons/src/index");
11
+ const _theme = require("../../theme/src/index");
12
12
  const ThemeToggler = ()=>{
13
- const { toggleTheme , themeName } = (0, _hooks.useThemeToggle)();
13
+ const { toggleTheme } = (0, _theme.useThemeToggle)();
14
14
  return /*#__PURE__*/ React.createElement(_styles.CookieThemeTogglerStyle, {
15
15
  color: "secondary",
16
16
  onClick: toggleTheme
17
- }, themeName === 'dark' ? /*#__PURE__*/ React.createElement(_icons.Light, null) : /*#__PURE__*/ React.createElement(_icons.Dark, null));
17
+ }, /*#__PURE__*/ React.createElement(_styles.DarkWrapper, null, /*#__PURE__*/ React.createElement(_icons.Dark, null)), /*#__PURE__*/ React.createElement(_styles.LightWrapper, null, /*#__PURE__*/ React.createElement(_icons.Light, null)));
18
18
  };
19
19
 
20
20
  //# sourceMappingURL=cookie-theme-toggler.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-toggler.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { Dark, Light } from '@lidofinance/icons'\nimport { CookieThemeTogglerStyle } from './styles'\nimport { useThemeToggle } from './hooks'\n\nexport const ThemeToggler: FC = () => {\n const { toggleTheme, themeName } = useThemeToggle()\n\n return (\n <CookieThemeTogglerStyle color='secondary' onClick={toggleTheme}>\n {themeName === 'dark' ? <Light /> : <Dark />}\n </CookieThemeTogglerStyle>\n )\n}\n"],"names":["ThemeToggler","toggleTheme","themeName","useThemeToggle","CookieThemeTogglerStyle","color","onClick","Light","Dark"],"mappings":"AAAA;;;;+BAKaA,cAAY;;aAAZA,YAAY;;uBAJG,uBAAoB;wBACR,UAAU;uBACnB,SAAS;AAEjC,MAAMA,YAAY,GAAO,IAAM;IACpC,MAAM,EAAEC,WAAW,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGC,IAAAA,MAAc,eAAA,GAAE;IAEnD,qBACE,oBAACC,OAAuB,wBAAA;QAACC,KAAK,EAAC,WAAW;QAACC,OAAO,EAAEL,WAAW;OAC5DC,SAAS,KAAK,MAAM,iBAAG,oBAACK,MAAK,MAAA,OAAG,iBAAG,oBAACC,MAAI,KAAA,OAAG,CACpB,CAC3B;AACH,CAAC"}
1
+ {"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/cookie-theme-toggler.tsx"],"sourcesContent":["import { FC } from 'react'\nimport { CookieThemeTogglerStyle, DarkWrapper, LightWrapper } from './styles'\nimport { Dark, Light } from '@lidofinance/icons'\nimport { useThemeToggle } from '@lidofinance/theme'\n\nexport const ThemeToggler: FC = () => {\n const { toggleTheme } = useThemeToggle()\n\n return (\n <CookieThemeTogglerStyle color='secondary' onClick={toggleTheme}>\n <DarkWrapper>\n <Dark />\n </DarkWrapper>\n <LightWrapper>\n <Light />\n </LightWrapper>\n </CookieThemeTogglerStyle>\n )\n}\n"],"names":["ThemeToggler","toggleTheme","useThemeToggle","CookieThemeTogglerStyle","color","onClick","DarkWrapper","Dark","LightWrapper","Light"],"mappings":"AAAA;;;;+BAKaA,cAAY;;aAAZA,YAAY;;wBAJ0C,UAAU;uBACjD,uBAAoB;uBACjB,uBAAoB;AAE5C,MAAMA,YAAY,GAAO,IAAM;IACpC,MAAM,EAAEC,WAAW,CAAA,EAAE,GAAGC,IAAAA,MAAc,eAAA,GAAE;IAExC,qBACE,oBAACC,OAAuB,wBAAA;QAACC,KAAK,EAAC,WAAW;QAACC,OAAO,EAAEJ,WAAW;qBAC7D,oBAACK,OAAW,YAAA,sBACV,oBAACC,MAAI,KAAA,OAAG,CACI,gBACd,oBAACC,OAAY,aAAA,sBACX,oBAACC,MAAK,MAAA,OAAG,CACI,CACS,CAC3B;AACH,CAAC"}
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
- _exportStar(require("./cookie-theme-provider"), exports);
7
6
  _exportStar(require("./cookie-theme-toggler"), exports);
8
- _exportStar(require("./hooks"), exports);
9
7
 
10
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/index.ts"],"sourcesContent":["export * from './cookie-theme-provider'\nexport * from './cookie-theme-toggler'\nexport * from './hooks'\n"],"names":[],"mappings":"AAAA;;;;;oBAAc,yBAAyB;oBACzB,wBAAwB;oBACxB,SAAS"}
1
+ {"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/index.ts"],"sourcesContent":["export * from './cookie-theme-toggler'\n"],"names":[],"mappings":"AAAA;;;;;oBAAc,wBAAwB"}
@@ -2,9 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "CookieThemeTogglerStyle", {
6
- enumerable: true,
7
- get: ()=>CookieThemeTogglerStyle
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ CookieThemeTogglerStyle: ()=>CookieThemeTogglerStyle,
13
+ IconWrapper: ()=>IconWrapper,
14
+ LightWrapper: ()=>LightWrapper,
15
+ DarkWrapper: ()=>DarkWrapper
8
16
  });
9
17
  const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
10
18
  const _styledComponents = /*#__PURE__*/ _interopRequireDefault(require("styled-components"));
@@ -22,6 +30,20 @@ const CookieThemeTogglerStyle = (0, _styledComponents.default)(_button.Button).a
22
30
  padding-right: 10px;
23
31
  line-height: 0;
24
32
  font-size: 0;
33
+
34
+ width: 44px;
35
+ height: 44px;
36
+ `;
37
+ const IconWrapper = _styledComponents.default.span`
38
+ position: absolute;
39
+ top: -12px;
40
+ left: -12px;
41
+ `;
42
+ const LightWrapper = (0, _styledComponents.default)(IconWrapper)`
43
+ visibility: var(--lido-color-lightModeVisibility);
44
+ `;
45
+ const DarkWrapper = (0, _styledComponents.default)(IconWrapper)`
46
+ visibility: var(--lido-color-darkModeVisibility);
25
47
  `;
26
48
 
27
49
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/styles.tsx"],"sourcesContent":["import styled from 'styled-components'\nimport { Button } from '@lidofinance/button'\n\nexport const CookieThemeTogglerStyle = styled(Button).attrs({\n variant: 'text',\n size: 'xs',\n})`\n min-width: 0;\n margin-left: ${({ theme }) => theme.spaceMap.sm}px;\n padding-left: 10px;\n padding-right: 10px;\n line-height: 0;\n font-size: 0;\n`\n"],"names":["CookieThemeTogglerStyle","styled","Button","attrs","variant","size","theme","spaceMap","sm"],"mappings":"AAAA;;;;+BAGaA,yBAAuB;;aAAvBA,uBAAuB;;;uEAHjB,mBAAmB;wBACf,wBAAqB;AAErC,MAAMA,uBAAuB,GAAGC,IAAAA,iBAAM,QAAA,EAACC,OAAM,OAAA,CAAC,CAACC,KAAK,CAAC;IAC1DC,OAAO,EAAE,MAAM;IACfC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;;eAEY,EAAE,SAAeC;QAAd,EAAEA,KAAK,CAAA,EAAE;WAAKA,KAAK,CAACC,QAAQ,CAACC,EAAE;AAAD,CAAC,CAAC;;;;;AAKlD,CAAC"}
1
+ {"version":3,"sources":["../../../../packages/cookie-theme-toggler/src/styles.tsx"],"sourcesContent":["import styled from 'styled-components'\nimport { Button } from '@lidofinance/button'\n\nexport const CookieThemeTogglerStyle = styled(Button).attrs({\n variant: 'text',\n size: 'xs',\n})`\n min-width: 0;\n margin-left: ${({ theme }) => theme.spaceMap.sm}px;\n padding-left: 10px;\n padding-right: 10px;\n line-height: 0;\n font-size: 0;\n\n width: 44px;\n height: 44px;\n`\n\nexport const IconWrapper = styled.span`\n position: absolute;\n top: -12px;\n left: -12px;\n`\n\nexport const LightWrapper = styled(IconWrapper)`\n visibility: var(--lido-color-lightModeVisibility);\n`\n\nexport const DarkWrapper = styled(IconWrapper)`\n visibility: var(--lido-color-darkModeVisibility);\n`\n"],"names":["CookieThemeTogglerStyle","IconWrapper","LightWrapper","DarkWrapper","styled","Button","attrs","variant","size","theme","spaceMap","sm","span"],"mappings":"AAAA;;;;;;;;;;;IAGaA,uBAAuB,MAAvBA,uBAAuB;IAevBC,WAAW,MAAXA,WAAW;IAMXC,YAAY,MAAZA,YAAY;IAIZC,WAAW,MAAXA,WAAW;;;uEA5BL,mBAAmB;wBACf,wBAAqB;AAErC,MAAMH,uBAAuB,GAAGI,IAAAA,iBAAM,QAAA,EAACC,OAAM,OAAA,CAAC,CAACC,KAAK,CAAC;IAC1DC,OAAO,EAAE,MAAM;IACfC,IAAI,EAAE,IAAI;CACX,CAAC,CAAC;;eAEY,EAAE,SAAeC;QAAd,EAAEA,KAAK,CAAA,EAAE;WAAKA,KAAK,CAACC,QAAQ,CAACC,EAAE;AAAD,CAAC,CAAC;;;;;;;;AAQlD,CAAC;AAEM,MAAMV,WAAW,GAAGG,iBAAM,QAAA,CAACQ,IAAI,CAAC;;;;AAIvC,CAAC;AAEM,MAAMV,YAAY,GAAGE,IAAAA,iBAAM,QAAA,EAACH,WAAW,CAAC,CAAC;;AAEhD,CAAC;AAEM,MAAME,WAAW,GAAGC,IAAAA,iBAAM,QAAA,EAACH,WAAW,CAAC,CAAC;;AAE/C,CAAC"}
@@ -14,7 +14,7 @@ const useSystemTheme = ()=>{
14
14
  const mql = window.matchMedia('(prefers-color-scheme: dark)');
15
15
  const setThemeFromQuery = (param)=>{
16
16
  let { matches } = param;
17
- setSystemTheme(matches ? _theme.THEME.dark : _theme.THEME.light);
17
+ setSystemTheme(matches ? _theme.ThemeName.dark : _theme.ThemeName.light);
18
18
  };
19
19
  mql.addEventListener('change', setThemeFromQuery);
20
20
  setThemeFromQuery(mql);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/hooks/src/useSystemTheme.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nimport { THEME } from '@lidofinance/theme'\n\nexport const useSystemTheme = (): THEME | undefined => {\n const [systemTheme, setSystemTheme] = useState<THEME>()\n\n useEffect(() => {\n const mql = window.matchMedia('(prefers-color-scheme: dark)')\n\n const setThemeFromQuery = ({ matches }: { matches: boolean }) => {\n setSystemTheme(matches ? THEME.dark : THEME.light)\n }\n\n mql.addEventListener('change', setThemeFromQuery)\n setThemeFromQuery(mql)\n\n return () => {\n mql.removeEventListener('change', setThemeFromQuery)\n }\n }, [])\n\n return systemTheme\n}\n"],"names":["useSystemTheme","systemTheme","setSystemTheme","useState","useEffect","mql","window","matchMedia","setThemeFromQuery","matches","THEME","dark","light","addEventListener","removeEventListener"],"mappings":"AAAA;;;;+BAIaA,gBAAc;;aAAdA,cAAc;;uBAJS,OAAO;uBAErB,uBAAoB;AAEnC,MAAMA,cAAc,GAAG,IAAyB;IACrD,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,IAAAA,MAAQ,SAAA,GAAS;IAEvDC,IAAAA,MAAS,UAAA,EAAC,IAAM;QACd,MAAMC,GAAG,GAAGC,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC;QAE7D,MAAMC,iBAAiB,GAAG,SAAuC;gBAAtC,EAAEC,OAAO,CAAA,EAAwB;YAC1DP,cAAc,CAACO,OAAO,GAAGC,MAAK,MAAA,CAACC,IAAI,GAAGD,MAAK,MAAA,CAACE,KAAK,CAAC;QACpD,CAAC;QAEDP,GAAG,CAACQ,gBAAgB,CAAC,QAAQ,EAAEL,iBAAiB,CAAC;QACjDA,iBAAiB,CAACH,GAAG,CAAC;QAEtB,OAAO,IAAM;YACXA,GAAG,CAACS,mBAAmB,CAAC,QAAQ,EAAEN,iBAAiB,CAAC;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC;IAEN,OAAOP,WAAW,CAAA;AACpB,CAAC"}
1
+ {"version":3,"sources":["../../../../packages/hooks/src/useSystemTheme.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nimport { ThemeName } from '@lidofinance/theme'\n\nexport const useSystemTheme = (): ThemeName | undefined => {\n const [systemTheme, setSystemTheme] = useState<ThemeName>()\n\n useEffect(() => {\n const mql = window.matchMedia('(prefers-color-scheme: dark)')\n\n const setThemeFromQuery = ({ matches }: { matches: boolean }) => {\n setSystemTheme(matches ? ThemeName.dark : ThemeName.light)\n }\n\n mql.addEventListener('change', setThemeFromQuery)\n setThemeFromQuery(mql)\n\n return () => {\n mql.removeEventListener('change', setThemeFromQuery)\n }\n }, [])\n\n return systemTheme\n}\n"],"names":["useSystemTheme","systemTheme","setSystemTheme","useState","useEffect","mql","window","matchMedia","setThemeFromQuery","matches","ThemeName","dark","light","addEventListener","removeEventListener"],"mappings":"AAAA;;;;+BAIaA,gBAAc;;aAAdA,cAAc;;uBAJS,OAAO;uBAEjB,uBAAoB;AAEvC,MAAMA,cAAc,GAAG,IAA6B;IACzD,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGC,IAAAA,MAAQ,SAAA,GAAa;IAE3DC,IAAAA,MAAS,UAAA,EAAC,IAAM;QACd,MAAMC,GAAG,GAAGC,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC;QAE7D,MAAMC,iBAAiB,GAAG,SAAuC;gBAAtC,EAAEC,OAAO,CAAA,EAAwB;YAC1DP,cAAc,CAACO,OAAO,GAAGC,MAAS,UAAA,CAACC,IAAI,GAAGD,MAAS,UAAA,CAACE,KAAK,CAAC;QAC5D,CAAC;QAEDP,GAAG,CAACQ,gBAAgB,CAAC,QAAQ,EAAEL,iBAAiB,CAAC;QACjDA,iBAAiB,CAACH,GAAG,CAAC;QAEtB,OAAO,IAAM;YACXA,GAAG,CAACS,mBAAmB,CAAC,QAAQ,EAAEN,iBAAiB,CAAC;QACtD,CAAC,CAAA;IACH,CAAC,EAAE,EAAE,CAAC;IAEN,OAAOP,WAAW,CAAA;AACpB,CAAC"}
@@ -21,8 +21,8 @@ const translation = (0, _styledComponents.keyframes)`
21
21
  `;
22
22
  const InlineLoaderStyle = _styledComponents.default.span`
23
23
  --loader-color: ${(param)=>{
24
- let { theme , $color } = param;
25
- return $color ? theme.colors[$color] : 'currentColor';
24
+ let { $color } = param;
25
+ return $color ? `var(--lido-color-${$color})` : 'currentColor';
26
26
  }};
27
27
 
28
28
  width: 100%;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/loaders/src/InlineLoaderStyles.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { InlineLoaderColors } from './types'\n\nexport const translation = keyframes`\n 100% {\n background-position: 0 0;\n }\n`\n\nexport const InlineLoaderStyle = styled.span<{ $color?: InlineLoaderColors }>`\n --loader-color: ${({ theme, $color }) =>\n $color ? theme.colors[$color] : 'currentColor'};\n\n width: 100%;\n display: inline-block;\n vertical-align: top;\n border-radius: 1000px;\n position: relative;\n overflow: hidden;\n user-select: none;\n opacity: 0.05;\n animation: ${translation} 2s infinite;\n background-size: 300% 100%;\n background-position: 100% 0;\n background-image: linear-gradient(\n 90deg,\n var(--loader-color) 0,\n var(--loader-color) 33.33%,\n transparent 44.44%,\n transparent 55.55%,\n var(--loader-color) 66.66%,\n var(--loader-color) 100%\n );\n\n &:after {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background: var(--loader-color);\n opacity: 0.2;\n }\n`\n"],"names":["translation","InlineLoaderStyle","keyframes","styled","span","$color","theme","colors"],"mappings":"AAAA;;;;;;;;;;;IAGaA,WAAW,MAAXA,WAAW;IAMXC,iBAAiB,MAAjBA,iBAAiB;;;wEATI,mBAAmB;AAG9C,MAAMD,WAAW,GAAGE,IAAAA,iBAAS,UAAA,CAAA,CAAC;;;;AAIrC,CAAC;AAEM,MAAMD,iBAAiB,GAAGE,iBAAM,QAAA,CAACC,IAAI,AAAiC,CAAC;kBAC5D,EAAE,SAChBC;QADiB,EAAEC,KAAK,CAAA,EAAED,MAAM,CAAA,EAAE;WAClCA,MAAM,GAAGC,KAAK,CAACC,MAAM,CAACF,MAAM,CAAC,GAAG,cAAc;AAAD,CAAC,CAAC;;;;;;;;;;aAUtC,EAAEL,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAuB3B,CAAC"}
1
+ {"version":3,"sources":["../../../../packages/loaders/src/InlineLoaderStyles.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { InlineLoaderColors } from './types'\n\nexport const translation = keyframes`\n 100% {\n background-position: 0 0;\n }\n`\n\nexport const InlineLoaderStyle = styled.span<{ $color?: InlineLoaderColors }>`\n --loader-color: ${({ $color }) =>\n $color ? `var(--lido-color-${$color})` : 'currentColor'};\n\n width: 100%;\n display: inline-block;\n vertical-align: top;\n border-radius: 1000px;\n position: relative;\n overflow: hidden;\n user-select: none;\n opacity: 0.05;\n animation: ${translation} 2s infinite;\n background-size: 300% 100%;\n background-position: 100% 0;\n background-image: linear-gradient(\n 90deg,\n var(--loader-color) 0,\n var(--loader-color) 33.33%,\n transparent 44.44%,\n transparent 55.55%,\n var(--loader-color) 66.66%,\n var(--loader-color) 100%\n );\n\n &:after {\n content: '';\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background: var(--loader-color);\n opacity: 0.2;\n }\n`\n"],"names":["translation","InlineLoaderStyle","keyframes","styled","span","$color"],"mappings":"AAAA;;;;;;;;;;;IAGaA,WAAW,MAAXA,WAAW;IAMXC,iBAAiB,MAAjBA,iBAAiB;;;wEATI,mBAAmB;AAG9C,MAAMD,WAAW,GAAGE,IAAAA,iBAAS,UAAA,CAAA,CAAC;;;;AAIrC,CAAC;AAEM,MAAMD,iBAAiB,GAAGE,iBAAM,QAAA,CAACC,IAAI,AAAiC,CAAC;kBAC5D,EAAE,SAChBC;QADiB,EAAEA,MAAM,CAAA,EAAE;WAC3BA,MAAM,GAAG,CAAC,iBAAiB,EAAEA,MAAM,CAAC,CAAC,CAAC,GAAG,cAAc;AAAD,CAAC,CAAC;;;;;;;;;;aAU/C,EAAEL,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;AAuB3B,CAAC"}
@@ -28,8 +28,8 @@ const LoaderStyle = _styledComponents.default.div`
28
28
  width: ${(props)=>props.$size}px;
29
29
  height: ${(props)=>props.$size}px;
30
30
  color: ${(param)=>{
31
- let { theme , $color } = param;
32
- return theme.colors[$color];
31
+ let { $color } = param;
32
+ return `var(--lido-color-${$color})`;
33
33
  }};
34
34
  `;
35
35
  const LoaderCircleBgStyle = _styledComponents.default.circle`
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/loaders/src/LoaderStyles.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { LoaderColors } from './types'\n\nexport const rotation = keyframes`\n 100% {\n transform: rotate(360deg);\n }\n`\n\nexport const LoaderStyle = styled.div<{\n $size: number\n $color: LoaderColors\n}>`\n margin: 0;\n padding: 0;\n line-height: 0;\n width: ${(props) => props.$size}px;\n height: ${(props) => props.$size}px;\n color: ${({ theme, $color }) => theme.colors[$color]};\n`\n\nexport const LoaderCircleBgStyle = styled.circle<{ $thickness: number }>`\n fill: none;\n stroke: currentColor;\n stroke-width: ${(props) => props.$thickness};\n opacity: 0.2;\n`\n\nexport const LoaderCircleFgStyle = styled.circle<{\n $thickness: number\n r: number\n}>`\n fill: none;\n stroke: currentColor;\n stroke-linecap: round;\n stroke-width: ${(props) => props.$thickness};\n stroke-dasharray: ${(props) => {\n const circumference = 2 * props.r * Math.PI\n const filledPart = 0.25\n\n return `${circumference * filledPart} ${circumference * (1 - filledPart)}`\n }};\n transform: rotate(0deg);\n transform-origin: 50% 50%;\n animation: ${rotation} 1.4s linear infinite;\n`\n"],"names":["rotation","LoaderStyle","LoaderCircleBgStyle","LoaderCircleFgStyle","keyframes","styled","div","props","$size","theme","$color","colors","circle","$thickness","circumference","r","Math","PI","filledPart"],"mappings":"AAAA;;;;;;;;;;;IAGaA,QAAQ,MAARA,QAAQ;IAMRC,WAAW,MAAXA,WAAW;IAYXC,mBAAmB,MAAnBA,mBAAmB;IAOnBC,mBAAmB,MAAnBA,mBAAmB;;;wEA5BE,mBAAmB;AAG9C,MAAMH,QAAQ,GAAGI,IAAAA,iBAAS,UAAA,CAAA,CAAC;;;;AAIlC,CAAC;AAEM,MAAMH,WAAW,GAAGI,iBAAM,QAAA,CAACC,GAAG,AAGnC,CAAC;;;;SAIM,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,KAAK,CAAC;UACxB,EAAE,CAACD,KAAK,GAAKA,KAAK,CAACC,KAAK,CAAC;SAC1B,EAAE,SAAuBC;QAAtB,EAAEA,KAAK,CAAA,EAAEC,MAAM,CAAA,EAAE;WAAKD,KAAK,CAACE,MAAM,CAACD,MAAM,CAAC;AAAD,CAAC,CAAC;AACvD,CAAC;AAEM,MAAMR,mBAAmB,GAAGG,iBAAM,QAAA,CAACO,MAAM,AAAwB,CAAC;;;gBAGzD,EAAE,CAACL,KAAK,GAAKA,KAAK,CAACM,UAAU,CAAC;;AAE9C,CAAC;AAEM,MAAMV,mBAAmB,GAAGE,iBAAM,QAAA,CAACO,MAAM,AAG9C,CAAC;;;;gBAIa,EAAE,CAACL,KAAK,GAAKA,KAAK,CAACM,UAAU,CAAC;oBAC1B,EAAE,CAACN,KAAK,GAAK;IAC7B,MAAMO,aAAa,GAAG,CAAC,GAAGP,KAAK,CAACQ,CAAC,GAAGC,IAAI,CAACC,EAAE;IAC3C,MAAMC,UAAU,GAAG,IAAI;IAEvB,OAAO,CAAC,EAAEJ,aAAa,GAAGI,UAAU,CAAC,CAAC,EAAEJ,aAAa,GAAG,CAAC,CAAC,GAAGI,UAAU,CAAC,CAAC,CAAC,CAAA;AAC5E,CAAC,CAAC;;;aAGS,EAAElB,QAAQ,CAAC;AACxB,CAAC"}
1
+ {"version":3,"sources":["../../../../packages/loaders/src/LoaderStyles.tsx"],"sourcesContent":["import styled, { keyframes } from 'styled-components'\nimport { LoaderColors } from './types'\n\nexport const rotation = keyframes`\n 100% {\n transform: rotate(360deg);\n }\n`\n\nexport const LoaderStyle = styled.div<{\n $size: number\n $color: LoaderColors\n}>`\n margin: 0;\n padding: 0;\n line-height: 0;\n width: ${(props) => props.$size}px;\n height: ${(props) => props.$size}px;\n color: ${({ $color }) => `var(--lido-color-${$color})`};\n`\n\nexport const LoaderCircleBgStyle = styled.circle<{ $thickness: number }>`\n fill: none;\n stroke: currentColor;\n stroke-width: ${(props) => props.$thickness};\n opacity: 0.2;\n`\n\nexport const LoaderCircleFgStyle = styled.circle<{\n $thickness: number\n r: number\n}>`\n fill: none;\n stroke: currentColor;\n stroke-linecap: round;\n stroke-width: ${(props) => props.$thickness};\n stroke-dasharray: ${(props) => {\n const circumference = 2 * props.r * Math.PI\n const filledPart = 0.25\n\n return `${circumference * filledPart} ${circumference * (1 - filledPart)}`\n }};\n transform: rotate(0deg);\n transform-origin: 50% 50%;\n animation: ${rotation} 1.4s linear infinite;\n`\n"],"names":["rotation","LoaderStyle","LoaderCircleBgStyle","LoaderCircleFgStyle","keyframes","styled","div","props","$size","$color","circle","$thickness","circumference","r","Math","PI","filledPart"],"mappings":"AAAA;;;;;;;;;;;IAGaA,QAAQ,MAARA,QAAQ;IAMRC,WAAW,MAAXA,WAAW;IAYXC,mBAAmB,MAAnBA,mBAAmB;IAOnBC,mBAAmB,MAAnBA,mBAAmB;;;wEA5BE,mBAAmB;AAG9C,MAAMH,QAAQ,GAAGI,IAAAA,iBAAS,UAAA,CAAA,CAAC;;;;AAIlC,CAAC;AAEM,MAAMH,WAAW,GAAGI,iBAAM,QAAA,CAACC,GAAG,AAGnC,CAAC;;;;SAIM,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,KAAK,CAAC;UACxB,EAAE,CAACD,KAAK,GAAKA,KAAK,CAACC,KAAK,CAAC;SAC1B,EAAE,SAAgB;QAAf,EAAEC,MAAM,CAAA,EAAE;WAAK,CAAC,iBAAiB,EAAEA,MAAM,CAAC,CAAC,CAAC;AAAD,CAAC,CAAC;AACzD,CAAC;AAEM,MAAMP,mBAAmB,GAAGG,iBAAM,QAAA,CAACK,MAAM,AAAwB,CAAC;;;gBAGzD,EAAE,CAACH,KAAK,GAAKA,KAAK,CAACI,UAAU,CAAC;;AAE9C,CAAC;AAEM,MAAMR,mBAAmB,GAAGE,iBAAM,QAAA,CAACK,MAAM,AAG9C,CAAC;;;;gBAIa,EAAE,CAACH,KAAK,GAAKA,KAAK,CAACI,UAAU,CAAC;oBAC1B,EAAE,CAACJ,KAAK,GAAK;IAC7B,MAAMK,aAAa,GAAG,CAAC,GAAGL,KAAK,CAACM,CAAC,GAAGC,IAAI,CAACC,EAAE;IAC3C,MAAMC,UAAU,GAAG,IAAI;IAEvB,OAAO,CAAC,EAAEJ,aAAa,GAAGI,UAAU,CAAC,CAAC,EAAEJ,aAAa,GAAG,CAAC,CAAC,GAAGI,UAAU,CAAC,CAAC,CAAC,CAAA;AAC5E,CAAC,CAAC;;;aAGS,EAAEhB,QAAQ,CAAC;AACxB,CAAC"}
@@ -7,6 +7,8 @@ Object.defineProperty(exports, "default", {
7
7
  get: ()=>_default
8
8
  });
9
9
  const colors = {
10
+ darkThemeOpacity: '0',
11
+ lightThemeOpacity: '1',
10
12
  primary: '#00a3ff',
11
13
  primaryHover: '#009bf2',
12
14
  primaryContrast: '#fff',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/theme/src/base/colors.ts"],"sourcesContent":["const colors = {\n primary: '#00a3ff',\n primaryHover: '#009bf2',\n primaryContrast: '#fff',\n primaryVisited: '#4bbeff',\n\n accent: '#27272e',\n accentContrast: '#fff',\n accentContrastSecondary: 'rgba(255, 255, 255, 0.6)',\n accentDarken: 'rgba(0, 0, 0, .2)',\n accentControlBg: 'rgba(0, 0, 0, .1)',\n accentBorder: 'rgba(255, 255, 255, 0.2)',\n accentBorderHover: 'rgba(255, 255, 255, 0.3)',\n\n error: '#e14d4d',\n errorHover: '#d44c4d',\n errorContrast: '#fff',\n\n warning: '#EC8600',\n warningHover: '#f0a431',\n warningContrast: '#fff',\n\n success: '#53BA95',\n successHover: '#5dae5e',\n successContrast: '#fff',\n} as const\n\nexport default { colors }\n"],"names":["colors","primary","primaryHover","primaryContrast","primaryVisited","accent","accentContrast","accentContrastSecondary","accentDarken","accentControlBg","accentBorder","accentBorderHover","error","errorHover","errorContrast","warning","warningHover","warningContrast","success","successHover","successContrast"],"mappings":"AAAA;;;;+BA2BA,SAAyB;;aAAzB,QAAyB;;AA3BzB,MAAMA,MAAM,GAAG;IACbC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,SAAS;IAEzBC,MAAM,EAAE,SAAS;IACjBC,cAAc,EAAE,MAAM;IACtBC,uBAAuB,EAAE,0BAA0B;IACnDC,YAAY,EAAE,mBAAmB;IACjCC,eAAe,EAAE,mBAAmB;IACpCC,YAAY,EAAE,0BAA0B;IACxCC,iBAAiB,EAAE,0BAA0B;IAE7CC,KAAK,EAAE,SAAS;IAChBC,UAAU,EAAE,SAAS;IACrBC,aAAa,EAAE,MAAM;IAErBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IAEvBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;CACxB,AAAS;MAEV,QAAyB,GAAV;IAAEpB,MAAM;CAAE"}
1
+ {"version":3,"sources":["../../../../../packages/theme/src/base/colors.ts"],"sourcesContent":["const colors = {\n darkThemeOpacity: '0',\n lightThemeOpacity: '1',\n primary: '#00a3ff',\n primaryHover: '#009bf2',\n primaryContrast: '#fff',\n primaryVisited: '#4bbeff',\n\n accent: '#27272e',\n accentContrast: '#fff',\n accentContrastSecondary: 'rgba(255, 255, 255, 0.6)',\n accentDarken: 'rgba(0, 0, 0, .2)',\n accentControlBg: 'rgba(0, 0, 0, .1)',\n accentBorder: 'rgba(255, 255, 255, 0.2)',\n accentBorderHover: 'rgba(255, 255, 255, 0.3)',\n\n error: '#e14d4d',\n errorHover: '#d44c4d',\n errorContrast: '#fff',\n\n warning: '#EC8600',\n warningHover: '#f0a431',\n warningContrast: '#fff',\n\n success: '#53BA95',\n successHover: '#5dae5e',\n successContrast: '#fff',\n} as const\n\nexport default { colors }\n"],"names":["colors","darkThemeOpacity","lightThemeOpacity","primary","primaryHover","primaryContrast","primaryVisited","accent","accentContrast","accentContrastSecondary","accentDarken","accentControlBg","accentBorder","accentBorderHover","error","errorHover","errorContrast","warning","warningHover","warningContrast","success","successHover","successContrast"],"mappings":"AAAA;;;;+BA6BA,SAAyB;;aAAzB,QAAyB;;AA7BzB,MAAMA,MAAM,GAAG;IACbC,gBAAgB,EAAE,GAAG;IACrBC,iBAAiB,EAAE,GAAG;IACtBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IACvBC,cAAc,EAAE,SAAS;IAEzBC,MAAM,EAAE,SAAS;IACjBC,cAAc,EAAE,MAAM;IACtBC,uBAAuB,EAAE,0BAA0B;IACnDC,YAAY,EAAE,mBAAmB;IACjCC,eAAe,EAAE,mBAAmB;IACpCC,YAAY,EAAE,0BAA0B;IACxCC,iBAAiB,EAAE,0BAA0B;IAE7CC,KAAK,EAAE,SAAS;IAChBC,UAAU,EAAE,SAAS;IACrBC,aAAa,EAAE,MAAM;IAErBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;IAEvBC,OAAO,EAAE,SAAS;IAClBC,YAAY,EAAE,SAAS;IACvBC,eAAe,EAAE,MAAM;CACxB,AAAS;MAEV,QAAyB,GAAV;IAAEtB,MAAM;CAAE"}
@@ -9,18 +9,23 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- THEME: ()=>THEME,
13
- LIGHT: ()=>LIGHT,
14
- DARK: ()=>DARK,
15
- DEFAULT_THEME_NAME: ()=>DEFAULT_THEME_NAME
12
+ ThemeName: ()=>ThemeName,
13
+ DEFAULT_THEME_NAME: ()=>DEFAULT_THEME_NAME,
14
+ themeCookieKey: ()=>themeCookieKey,
15
+ globalStyleDataAttribute: ()=>globalStyleDataAttribute,
16
+ themeCookieExpire: ()=>themeCookieExpire,
17
+ prefersDarkThemeMediaQuery: ()=>prefersDarkThemeMediaQuery
16
18
  });
17
- const LIGHT = 'light';
18
- const DARK = 'dark';
19
- var THEME;
20
- (function(THEME) {
21
- THEME["light"] = "light";
22
- THEME["dark"] = "dark";
23
- })(THEME || (THEME = {}));
24
- const DEFAULT_THEME_NAME = THEME.light;
19
+ var ref;
20
+ var ThemeName;
21
+ (function(ThemeName) {
22
+ ThemeName["light"] = "light";
23
+ ThemeName["dark"] = "dark";
24
+ })(ThemeName || (ThemeName = {}));
25
+ const DEFAULT_THEME_NAME = ThemeName.light;
26
+ const themeCookieKey = 'lido-theme-manual';
27
+ const globalStyleDataAttribute = 'data-lido-ui-global-style';
28
+ const themeCookieExpire = 365;
29
+ const prefersDarkThemeMediaQuery = window === null || window === void 0 ? void 0 : (ref = window.matchMedia) === null || ref === void 0 ? void 0 : ref.call(window, '(prefers-color-scheme: dark)');
25
30
 
26
31
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../packages/theme/src/constants.ts"],"sourcesContent":["export const LIGHT = 'light'\nexport const DARK = 'dark'\n\nexport enum THEME {\n light = 'light',\n dark = 'dark',\n}\n\nexport const DEFAULT_THEME_NAME = THEME.light\n"],"names":["LIGHT","DARK","DEFAULT_THEME_NAME","THEME","light","dark"],"mappings":"AAAA;;;;;;;;;;;;IAAaA,KAAK,MAALA,KAAK;IACLC,IAAI,MAAJA,IAAI;IAOJC,kBAAkB,MAAlBA,kBAAkB;;AARxB,MAAMF,KAAK,GAAG,OAAO;AACrB,MAAMC,IAAI,GAAG,MAAM;IAEnB,KAGN;UAHWE,KAAK;IAALA,KAAK,CACfC,OAAK,IAALA,OAAK;IADKD,KAAK,CAEfE,MAAI,IAAJA,MAAI;GAFMF,KAAK,KAALA,KAAK;AAKV,MAAMD,kBAAkB,GAAGC,KAAK,CAACC,KAAK"}
1
+ {"version":3,"sources":["../../../../packages/theme/src/constants.ts"],"sourcesContent":["export enum ThemeName {\n light = 'light',\n dark = 'dark',\n}\n\nexport const DEFAULT_THEME_NAME = ThemeName.light\n\nexport const themeCookieKey = 'lido-theme-manual'\nexport const globalStyleDataAttribute = 'data-lido-ui-global-style'\n\nexport const themeCookieExpire = 365\n\nexport const prefersDarkThemeMediaQuery = window?.matchMedia?.(\n '(prefers-color-scheme: dark)'\n)\n"],"names":["DEFAULT_THEME_NAME","themeCookieKey","globalStyleDataAttribute","themeCookieExpire","prefersDarkThemeMediaQuery","window","ThemeName","light","dark","matchMedia"],"mappings":"AAAA;;;;;;;;;;;;IAKaA,kBAAkB,MAAlBA,kBAAkB;IAElBC,cAAc,MAAdA,cAAc;IACdC,wBAAwB,MAAxBA,wBAAwB;IAExBC,iBAAiB,MAAjBA,iBAAiB;IAEjBC,0BAA0B,MAA1BA,0BAA0B;;IAAGC,GAAkB;IAZrD,SAGN;UAHWC,SAAS;IAATA,SAAS,CACnBC,OAAK,IAALA,OAAK;IADKD,SAAS,CAEnBE,MAAI,IAAJA,MAAI;GAFMF,SAAS,KAATA,SAAS;AAKd,MAAMN,kBAAkB,GAAGM,SAAS,CAACC,KAAK;AAE1C,MAAMN,cAAc,GAAG,mBAAmB;AAC1C,MAAMC,wBAAwB,GAAG,2BAA2B;AAE5D,MAAMC,iBAAiB,GAAG,GAAG;AAE7B,MAAMC,0BAA0B,GAAGC,MAAM,aAANA,MAAM,WAAY,GAAlBA,KAAAA,CAAkB,GAAlBA,CAAAA,GAAkB,GAAlBA,MAAM,CAAEI,UAAU,cAAlBJ,GAAkB,WAE3D,GAFyCA,KAAAA,CAEzC,GAFyCA,GAAkB,CAAlBA,IAEzC,CAFyCA,MAAM,EAC9C,8BAA8B,CAC/B"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: all[name]
9
+ });
10
+ }
11
+ _export(exports, {
12
+ ThemeToggleContext: ()=>ThemeToggleContext,
13
+ CookieThemeProvider: ()=>CookieThemeProvider
14
+ });
15
+ const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
16
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
17
+ const _constants = require("./constants");
18
+ const _themes = require("./themes");
19
+ const _cookies = require("./utils/cookies");
20
+ const _documentHeadContents = require("./document-head-contents/index");
21
+ const _elementThemeScript = require("./document-head-contents/element-theme-script");
22
+ const _styledComponents = require("styled-components");
23
+ const defaultThemeContext = {};
24
+ const ThemeToggleContext = /*#__PURE__*/ (0, _react.createContext)(defaultThemeContext);
25
+ // we need to initialize this before react component code if we're using this provider or ThemeProvider
26
+ (0, _documentHeadContents.initColors)();
27
+ const CookieThemeProvider = /*#__PURE__*/ _react.default.memo((param)=>{
28
+ let { children , initialThemeName , // overrideThemeName is mainly used for storybook
29
+ overrideThemeName , } = param;
30
+ const parentTheme = (0, _react.useContext)(ThemeToggleContext);
31
+ // we do not want to do nested injections, and we're checking
32
+ // if context we inject in this component is already provided
33
+ const isTopLevelProvider = parentTheme === defaultThemeContext;
34
+ // we always start with default theme, or, if server wants to provide
35
+ // specific default theme, with server-provided theme to avoid hydration errors
36
+ const [internalThemeName, setThemeName] = (0, _react.useState)(initialThemeName || _constants.DEFAULT_THEME_NAME);
37
+ // since we're using this component to provide cookie-theme,
38
+ // we eventually want to respect theme provided in cookie, not general theme,
39
+ // so we're picking `parentTheme.themeName` if we have one.
40
+ // If user needs custom theme, not "cookie theme", he should use ThemeProvider instead.
41
+ const themeName = parentTheme.themeName || internalThemeName;
42
+ const theme = _themes.themeMap[themeName];
43
+ // This logic is really hydrating everything, since we started with server-rendered default prop.
44
+ // It also follows cookie value change.
45
+ (0, _react.useEffect)(()=>{
46
+ // This logic is useless if we're nested - it is already done in top-level provider
47
+ if (!isTopLevelProvider) {
48
+ return;
49
+ }
50
+ const setTheme = ()=>{
51
+ const systemThemeName = (_constants.prefersDarkThemeMediaQuery === null || _constants.prefersDarkThemeMediaQuery === void 0 ? void 0 : _constants.prefersDarkThemeMediaQuery.matches) ? _constants.ThemeName.dark : _constants.ThemeName.light;
52
+ const themeNameCookie = (0, _cookies.getThemeNameFromCookies)();
53
+ const newThemeName = // first, if we have some override (e.g. in Storybook), we respect it
54
+ overrideThemeName || // then, if we have cookie theme, we use theme from cookie
55
+ themeNameCookie || // else, we follow theme we were provided in initialization from server,
56
+ // which means server explicitly wants specific theme by default, not "follow-system"
57
+ initialThemeName || // then, we use media query theme, if available (not all browsers may still support it)
58
+ systemThemeName || // and, finally, falling back to default
59
+ _constants.DEFAULT_THEME_NAME;
60
+ setThemeName(newThemeName);
61
+ // and when theme is switched, we're setting global-level CSS variable data-attribute
62
+ // to modify CSS vars provided on a top-level
63
+ document.documentElement.dataset.lidoTheme = newThemeName;
64
+ };
65
+ // Users may have auto-theme (switching on sunset or schedule or whatever) so we need to listen for this event
66
+ _constants.prefersDarkThemeMediaQuery === null || _constants.prefersDarkThemeMediaQuery === void 0 ? void 0 : _constants.prefersDarkThemeMediaQuery.addEventListener('change', setTheme);
67
+ setTheme();
68
+ }, [
69
+ initialThemeName,
70
+ isTopLevelProvider,
71
+ overrideThemeName,
72
+ parentTheme,
73
+ theme,
74
+ ]);
75
+ const value = (0, _react.useMemo)(()=>({
76
+ themeName,
77
+ toggleTheme () {
78
+ setThemeName((themeName)=>{
79
+ const newThemeName = themeName === _constants.ThemeName.light ? _constants.ThemeName.dark : _constants.ThemeName.light;
80
+ // note that we're writing cookie theme only on explicit calls,
81
+ // not on "internal theme state" change
82
+ (0, _elementThemeScript.updateGlobalTheme)(newThemeName);
83
+ return newThemeName;
84
+ });
85
+ }
86
+ }), [
87
+ themeName
88
+ ]);
89
+ if (isTopLevelProvider) {
90
+ // if this provider is top-level we rely on element-theme-script.tsx logic
91
+ // which defines data-lido-theme injection
92
+ return /*#__PURE__*/ _react.default.createElement(ThemeToggleContext.Provider, {
93
+ value: value
94
+ }, /*#__PURE__*/ _react.default.createElement(_styledComponents.ThemeProvider, {
95
+ theme: theme
96
+ }, children));
97
+ } else {
98
+ return /*#__PURE__*/ _react.default.createElement("div", {
99
+ style: {
100
+ display: 'contents'
101
+ },
102
+ "data-lido-theme": themeName
103
+ }, /*#__PURE__*/ _react.default.createElement(_styledComponents.ThemeProvider, {
104
+ theme: theme
105
+ }, children));
106
+ }
107
+ });
108
+ CookieThemeProvider.displayName = 'CookieThemeProvider';
109
+
110
+ //# sourceMappingURL=cookie-theme-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../packages/theme/src/cookie-theme-provider.tsx"],"sourcesContent":["import React, {\n createContext,\n FC,\n PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react'\nimport {\n DEFAULT_THEME_NAME,\n prefersDarkThemeMediaQuery,\n ThemeName,\n} from './constants'\nimport { themeMap } from './themes'\nimport { getThemeNameFromCookies } from './utils/cookies'\nimport { initColors } from './document-head-contents'\nimport { updateGlobalTheme } from './document-head-contents/element-theme-script'\nimport { ThemeProvider as StyledThemeProvider } from 'styled-components'\nimport { ThemeContext } from './types'\n\nconst defaultThemeContext = {} as ThemeContext\nexport const ThemeToggleContext =\n createContext<ThemeContext>(defaultThemeContext)\n\n// we need to initialize this before react component code if we're using this provider or ThemeProvider\ninitColors()\n\n/**\n * This is really complicated logic here. Comments will be added on specific lines\n *\n * Cookie theme provider acts differently from common theme provider.\n * 1. it can be nested, BUT it should re-use value provided by itself for optimisation purposes\n * 2. if it is top-level, it is not altering itself, but instead altering theme behavior on HTMLElement level\n * 3. it does not support custom themes, preferring pre-defined themes instead\n * */\n\nexport const CookieThemeProvider: FC<\n PropsWithChildren<{\n // Use themeNameParent if you need get cookie in SSR\n initialThemeName?: ThemeName\n overrideThemeName?: ThemeName\n }>\n> = React.memo(\n ({\n children,\n initialThemeName,\n // overrideThemeName is mainly used for storybook\n overrideThemeName,\n }) => {\n const parentTheme = useContext(ThemeToggleContext)\n // we do not want to do nested injections, and we're checking\n // if context we inject in this component is already provided\n const isTopLevelProvider = parentTheme === defaultThemeContext\n // we always start with default theme, or, if server wants to provide\n // specific default theme, with server-provided theme to avoid hydration errors\n const [internalThemeName, setThemeName] = useState<ThemeName>(\n initialThemeName || DEFAULT_THEME_NAME\n )\n // since we're using this component to provide cookie-theme,\n // we eventually want to respect theme provided in cookie, not general theme,\n // so we're picking `parentTheme.themeName` if we have one.\n // If user needs custom theme, not \"cookie theme\", he should use ThemeProvider instead.\n const themeName = parentTheme.themeName || internalThemeName\n\n const theme = themeMap[themeName]\n\n // This logic is really hydrating everything, since we started with server-rendered default prop.\n // It also follows cookie value change.\n useEffect(() => {\n // This logic is useless if we're nested - it is already done in top-level provider\n if (!isTopLevelProvider) {\n return\n }\n\n const setTheme = () => {\n const systemThemeName = prefersDarkThemeMediaQuery?.matches\n ? ThemeName.dark\n : ThemeName.light\n const themeNameCookie = getThemeNameFromCookies()\n const newThemeName =\n // first, if we have some override (e.g. in Storybook), we respect it\n overrideThemeName ||\n // then, if we have cookie theme, we use theme from cookie\n themeNameCookie ||\n // else, we follow theme we were provided in initialization from server,\n // which means server explicitly wants specific theme by default, not \"follow-system\"\n initialThemeName ||\n // then, we use media query theme, if available (not all browsers may still support it)\n systemThemeName ||\n // and, finally, falling back to default\n DEFAULT_THEME_NAME\n setThemeName(newThemeName)\n // and when theme is switched, we're setting global-level CSS variable data-attribute\n // to modify CSS vars provided on a top-level\n document.documentElement.dataset.lidoTheme = newThemeName\n }\n\n // Users may have auto-theme (switching on sunset or schedule or whatever) so we need to listen for this event\n prefersDarkThemeMediaQuery?.addEventListener('change', setTheme)\n setTheme()\n }, [\n initialThemeName,\n isTopLevelProvider,\n overrideThemeName,\n parentTheme,\n theme,\n ])\n\n const value = useMemo(\n () => ({\n themeName,\n toggleTheme() {\n setThemeName((themeName) => {\n const newThemeName =\n themeName === ThemeName.light ? ThemeName.dark : ThemeName.light\n // note that we're writing cookie theme only on explicit calls,\n // not on \"internal theme state\" change\n updateGlobalTheme(newThemeName)\n return newThemeName\n })\n },\n }),\n [themeName]\n )\n\n if (isTopLevelProvider) {\n // if this provider is top-level we rely on element-theme-script.tsx logic\n // which defines data-lido-theme injection\n return (\n <ThemeToggleContext.Provider value={value}>\n <StyledThemeProvider theme={theme}>{children}</StyledThemeProvider>\n </ThemeToggleContext.Provider>\n )\n } else {\n return (\n <div style={{ display: 'contents' }} data-lido-theme={themeName}>\n <StyledThemeProvider theme={theme}>{children}</StyledThemeProvider>\n </div>\n )\n }\n }\n)\n\nCookieThemeProvider.displayName = 'CookieThemeProvider'\n"],"names":["ThemeToggleContext","CookieThemeProvider","defaultThemeContext","createContext","initColors","React","memo","children","initialThemeName","overrideThemeName","parentTheme","useContext","isTopLevelProvider","internalThemeName","setThemeName","useState","DEFAULT_THEME_NAME","themeName","theme","themeMap","useEffect","setTheme","systemThemeName","prefersDarkThemeMediaQuery","matches","ThemeName","dark","light","themeNameCookie","getThemeNameFromCookies","newThemeName","document","documentElement","dataset","lidoTheme","addEventListener","value","useMemo","toggleTheme","updateGlobalTheme","Provider","StyledThemeProvider","div","style","display","data-lido-theme","displayName"],"mappings":"AAAA;;;;;;;;;;;IAsBaA,kBAAkB,MAAlBA,kBAAkB;IAelBC,mBAAmB,MAAnBA,mBAAmB;;;6DA7BzB,OAAO;2BAKP,aAAa;wBACK,UAAU;yBACK,iBAAiB;sCAC9B,gCAA0B;oCACnB,+CAA+C;kCAC5B,mBAAmB;AAGxE,MAAMC,mBAAmB,GAAG,EAAE,AAAgB;AACvC,MAAMF,kBAAkB,iBAC7BG,IAAAA,MAAa,cAAA,EAAeD,mBAAmB,CAAC;AAElD,uGAAuG;AACvGE,IAAAA,qBAAU,WAAA,GAAE;AAWL,MAAMH,mBAAmB,iBAM5BI,MAAK,QAAA,CAACC,IAAI,CACZ,SAKM;QALL,EACCC,QAAQ,CAAA,EACRC,gBAAgB,CAAA,EAChB,iDAAiD;IACjDC,iBAAiB,CAAA,IAClB;IACC,MAAMC,WAAW,GAAGC,IAAAA,MAAU,WAAA,EAACX,kBAAkB,CAAC;IAClD,6DAA6D;IAC7D,6DAA6D;IAC7D,MAAMY,kBAAkB,GAAGF,WAAW,KAAKR,mBAAmB;IAC9D,qEAAqE;IACrE,+EAA+E;IAC/E,MAAM,CAACW,iBAAiB,EAAEC,YAAY,CAAC,GAAGC,IAAAA,MAAQ,SAAA,EAChDP,gBAAgB,IAAIQ,UAAkB,mBAAA,CACvC;IACD,4DAA4D;IAC5D,6EAA6E;IAC7E,2DAA2D;IAC3D,uFAAuF;IACvF,MAAMC,SAAS,GAAGP,WAAW,CAACO,SAAS,IAAIJ,iBAAiB;IAE5D,MAAMK,KAAK,GAAGC,OAAQ,SAAA,CAACF,SAAS,CAAC;IAEjC,iGAAiG;IACjG,uCAAuC;IACvCG,IAAAA,MAAS,UAAA,EAAC,IAAM;QACd,mFAAmF;QACnF,IAAI,CAACR,kBAAkB,EAAE;YACvB,OAAM;QACR,CAAC;QAED,MAAMS,QAAQ,GAAG,IAAM;YACrB,MAAMC,eAAe,GAAGC,CAAAA,UAA0B,2BAAA,aAA1BA,UAA0B,2BAAA,WAAS,GAAnCA,KAAAA,CAAmC,GAAnCA,UAA0B,2BAAA,CAAEC,OAAO,CAAA,GACvDC,UAAS,UAAA,CAACC,IAAI,GACdD,UAAS,UAAA,CAACE,KAAK;YACnB,MAAMC,eAAe,GAAGC,IAAAA,QAAuB,wBAAA,GAAE;YACjD,MAAMC,YAAY,GAChB,qEAAqE;YACrErB,iBAAiB,IACjB,0DAA0D;YAC1DmB,eAAe,IACf,wEAAwE;YACxE,qFAAqF;YACrFpB,gBAAgB,IAChB,uFAAuF;YACvFc,eAAe,IACf,wCAAwC;YACxCN,UAAkB,mBAAA;YACpBF,YAAY,CAACgB,YAAY,CAAC;YAC1B,qFAAqF;YACrF,6CAA6C;YAC7CC,QAAQ,CAACC,eAAe,CAACC,OAAO,CAACC,SAAS,GAAGJ,YAAY;QAC3D,CAAC;QAED,8GAA8G;QAC9GP,UAA0B,2BAAA,aAA1BA,UAA0B,2BAAA,WAAkB,GAA5CA,KAAAA,CAA4C,GAA5CA,UAA0B,2BAAA,CAAEY,gBAAgB,CAAC,QAAQ,EAAEd,QAAQ,CAAC,CAAA;QAChEA,QAAQ,EAAE;IACZ,CAAC,EAAE;QACDb,gBAAgB;QAChBI,kBAAkB;QAClBH,iBAAiB;QACjBC,WAAW;QACXQ,KAAK;KACN,CAAC;IAEF,MAAMkB,KAAK,GAAGC,IAAAA,MAAO,QAAA,EACnB,IAAM,CAAC;YACLpB,SAAS;YACTqB,WAAW,IAAG;gBACZxB,YAAY,CAAC,CAACG,SAAS,GAAK;oBAC1B,MAAMa,YAAY,GAChBb,SAAS,KAAKQ,UAAS,UAAA,CAACE,KAAK,GAAGF,UAAS,UAAA,CAACC,IAAI,GAAGD,UAAS,UAAA,CAACE,KAAK;oBAClE,+DAA+D;oBAC/D,uCAAuC;oBACvCY,IAAAA,mBAAiB,kBAAA,EAACT,YAAY,CAAC;oBAC/B,OAAOA,YAAY,CAAA;gBACrB,CAAC,CAAC;YACJ,CAAC;SACF,CAAC,EACF;QAACb,SAAS;KAAC,CACZ;IAED,IAAIL,kBAAkB,EAAE;QACtB,0EAA0E;QAC1E,0CAA0C;QAC1C,qBACE,6BAACZ,kBAAkB,CAACwC,QAAQ;YAACJ,KAAK,EAAEA,KAAK;yBACvC,6BAACK,iBAAmB,cAAA;YAACvB,KAAK,EAAEA,KAAK;WAAGX,QAAQ,CAAuB,CACvC,CAC/B;IACH,OAAO;QACL,qBACE,6BAACmC,KAAG;YAACC,KAAK,EAAE;gBAAEC,OAAO,EAAE,UAAU;aAAE;YAAEC,iBAAe,EAAE5B,SAAS;yBAC7D,6BAACwB,iBAAmB,cAAA;YAACvB,KAAK,EAAEA,KAAK;WAAGX,QAAQ,CAAuB,CAC/D,CACP;IACH,CAAC;AACH,CAAC,CACF;AAEDN,mBAAmB,CAAC6C,WAAW,GAAG,qBAAqB"}
@@ -17,40 +17,53 @@ const _extends = require("@swc/helpers/lib/_extends.js").default;
17
17
  const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
18
18
  const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
19
19
  const _themes = require("../themes");
20
- const _globals = require("../globals");
21
- const _generateCssColorVariables = require("./utils/generate-css-color-variables");
22
- const darkThemeColors = (0, _generateCssColorVariables.generateCssColorVariables)(_themes.themeDark.colors);
20
+ const _generateCssColorVariables = require("../utils/generate-css-color-variables");
21
+ const _constants = require("../constants");
22
+ const _utils = require("../../../utils/src/index");
23
+ /**
24
+ * What is happening here:
25
+ * We want to have React dehydrated HTML to be loaded after theme is initialized.
26
+ * That means that we need to have some code executed BEFORE main react components code,
27
+ * before even injected script itself, so we need to provide some CSS and JS in document head
28
+ * to read the theme from cookie and make global CSS follow preferred palette.
29
+ * This file is providing CSS themes that defines custom CSS variables with palette to
30
+ * make HTML document styled even before any code is loaded
31
+ * */ const darkThemeColors = (0, _generateCssColorVariables.generateCssColorVariables)(_themes.themeDark.colors);
23
32
  const lightThemeColors = (0, _generateCssColorVariables.generateCssColorVariables)(_themes.themeLight.colors);
24
- let initGlobalColors = _globals.VOID_FN;
33
+ let initGlobalColors = _utils.VOID_FN;
25
34
  const themeCSSValueString = `
26
- html, [data-theme='${_globals.ThemeName.light}'] {
27
- color-theme: light;
28
- ${lightThemeColors}
35
+ html, [data-lido-theme='${_constants.ThemeName.light}'] {
36
+ color-theme: light;
37
+ ${lightThemeColors}
29
38
  }
30
39
  @media (prefers-color-scheme: dark) {
31
- html:not([data-theme='${_globals.ThemeName.light}']) {
32
- color-theme: dark;
33
- ${darkThemeColors}
34
- }
40
+ html:not([data-lido-theme='${_constants.ThemeName.light}']) {
41
+ color-theme: dark;
42
+ ${darkThemeColors}
43
+ }
35
44
  }
36
- [data-theme='${_globals.ThemeName.dark}'] {
37
- color-theme: dark;
38
- ${darkThemeColors}
45
+ [data-lido-theme='${_constants.ThemeName.dark}'] {
46
+ color-theme: dark;
47
+ ${darkThemeColors}
39
48
  }`;
40
49
  if (typeof window !== 'undefined') {
41
- if (!document.querySelector(`style[${_globals.globalStyleDataAttribute}]`)) {
50
+ if (!document.querySelector(`style[${_constants.globalStyleDataAttribute}]`)) {
42
51
  initGlobalColors = ()=>{
43
52
  const style = document.createElement('style');
44
- style.setAttribute(_globals.globalStyleDataAttribute, '');
45
- style.innerText = themeCSSValueString;
53
+ style.setAttribute(_constants.globalStyleDataAttribute, '');
54
+ style.innerHTML = themeCSSValueString;
46
55
  document.head.appendChild(style);
47
56
  // eslint-disable-next-line @typescript-eslint/no-empty-function
48
- initGlobalColors = _globals.VOID_FN;
57
+ initGlobalColors = _utils.VOID_FN;
49
58
  };
50
59
  }
51
60
  }
52
61
  const StyleThemeColors = ()=>/*#__PURE__*/ _react.default.createElement("style", _extends({}, {
53
- [_globals.globalStyleDataAttribute]: true
54
- }), "`$", themeCSSValueString, "`");
62
+ [_constants.globalStyleDataAttribute]: true
63
+ }, {
64
+ dangerouslySetInnerHTML: {
65
+ __html: themeCSSValueString
66
+ }
67
+ }));
55
68
 
56
69
  //# sourceMappingURL=element-theme-colors.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-colors.tsx"],"sourcesContent":["import React from 'react'\nimport { themeDark, themeLight } from '../themes'\nimport { globalStyleDataAttribute, ThemeName, VOID_FN } from '../globals'\nimport { generateCssColorVariables } from './utils/generate-css-color-variables'\n\nconst darkThemeColors = generateCssColorVariables(themeDark.colors)\nconst lightThemeColors = generateCssColorVariables(themeLight.colors)\n\nexport let initGlobalColors = VOID_FN\nexport const themeCSSValueString = `\nhtml, [data-theme='${ThemeName.light}'] { \n color-theme: light;\n ${lightThemeColors}\n}\n@media (prefers-color-scheme: dark) {\n html:not([data-theme='${ThemeName.light}']) { \n color-theme: dark;\n ${darkThemeColors} \n }\n}\n[data-theme='${ThemeName.dark}'] {\n color-theme: dark;\n ${darkThemeColors}\n}`\n\nif (typeof window !== 'undefined') {\n if (!document.querySelector(`style[${globalStyleDataAttribute}]`)) {\n initGlobalColors = () => {\n const style = document.createElement('style')\n style.setAttribute(globalStyleDataAttribute, '')\n style.innerText = themeCSSValueString\n\n document.head.appendChild(style)\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n initGlobalColors = VOID_FN\n }\n }\n}\n\nexport const StyleThemeColors = () => (\n <style {...{ [globalStyleDataAttribute]: true }}>\n `${themeCSSValueString}`\n </style>\n)\n"],"names":["initGlobalColors","themeCSSValueString","StyleThemeColors","darkThemeColors","generateCssColorVariables","themeDark","colors","lightThemeColors","themeLight","VOID_FN","ThemeName","light","dark","window","document","querySelector","globalStyleDataAttribute","style","createElement","setAttribute","innerText","head","appendChild"],"mappings":"AAAA;;;;;;;;;;;IAQWA,gBAAgB,MAAhBA,gBAAgB;IACdC,mBAAmB,MAAnBA,mBAAmB;IA8BnBC,gBAAgB,MAAhBA,gBAAgB;;;;4DAvCX,OAAO;wBACa,WAAW;yBACY,YAAY;2CAC/B,sCAAsC;AAEhF,MAAMC,eAAe,GAAGC,IAAAA,0BAAyB,0BAAA,EAACC,OAAS,UAAA,CAACC,MAAM,CAAC;AACnE,MAAMC,gBAAgB,GAAGH,IAAAA,0BAAyB,0BAAA,EAACI,OAAU,WAAA,CAACF,MAAM,CAAC;AAE9D,IAAIN,gBAAgB,GAAGS,QAAO,QAAA;AAC9B,MAAMR,mBAAmB,GAAG,CAAC;mBACjB,EAAES,QAAS,UAAA,CAACC,KAAK,CAAC;;IAEjC,EAAEJ,gBAAgB,CAAC;;;0BAGG,EAAEG,QAAS,UAAA,CAACC,KAAK,CAAC;;QAEpC,EAAER,eAAe,CAAC;;;aAGb,EAAEO,QAAS,UAAA,CAACE,IAAI,CAAC;;IAE1B,EAAET,eAAe,CAAC;CACrB,CAAC;AAEF,IAAI,OAAOU,MAAM,KAAK,WAAW,EAAE;IACjC,IAAI,CAACC,QAAQ,CAACC,aAAa,CAAC,CAAC,MAAM,EAAEC,QAAwB,yBAAA,CAAC,CAAC,CAAC,CAAC,EAAE;QACjEhB,gBAAgB,GAAG,IAAM;YACvB,MAAMiB,KAAK,GAAGH,QAAQ,CAACI,aAAa,CAAC,OAAO,CAAC;YAC7CD,KAAK,CAACE,YAAY,CAACH,QAAwB,yBAAA,EAAE,EAAE,CAAC;YAChDC,KAAK,CAACG,SAAS,GAAGnB,mBAAmB;YAErCa,QAAQ,CAACO,IAAI,CAACC,WAAW,CAACL,KAAK,CAAC;YAChC,gEAAgE;YAChEjB,gBAAgB,GAAGS,QAAO,QAAA;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;AAEM,MAAMP,gBAAgB,GAAG,kBAC9B,6BAACe,OAAK,eAAK;QAAE,CAACD,QAAwB,yBAAA,CAAC,EAAE,IAAI;KAAE,GAAE,IAC7C,EAACf,mBAAmB,EAAC,GACzB,CAAQ,AACT"}
1
+ {"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-colors.tsx"],"sourcesContent":["import React from 'react'\nimport { themeDark, themeLight } from '../themes'\nimport { generateCssColorVariables } from '../utils/generate-css-color-variables'\nimport { globalStyleDataAttribute, ThemeName } from '../constants'\nimport { VOID_FN } from '@lidofinance/utils'\n\n/**\n * What is happening here:\n * We want to have React dehydrated HTML to be loaded after theme is initialized.\n * That means that we need to have some code executed BEFORE main react components code,\n * before even injected script itself, so we need to provide some CSS and JS in document head\n * to read the theme from cookie and make global CSS follow preferred palette.\n * This file is providing CSS themes that defines custom CSS variables with palette to\n * make HTML document styled even before any code is loaded\n * */\n\nconst darkThemeColors = generateCssColorVariables(themeDark.colors)\nconst lightThemeColors = generateCssColorVariables(themeLight.colors)\n\nexport let initGlobalColors = VOID_FN\nexport const themeCSSValueString = `\nhtml, [data-lido-theme='${ThemeName.light}'] {\ncolor-theme: light;\n${lightThemeColors}\n}\n@media (prefers-color-scheme: dark) {\nhtml:not([data-lido-theme='${ThemeName.light}']) { \ncolor-theme: dark;\n${darkThemeColors} \n}\n}\n[data-lido-theme='${ThemeName.dark}'] {\ncolor-theme: dark;\n${darkThemeColors}\n}`\n\nif (typeof window !== 'undefined') {\n if (!document.querySelector(`style[${globalStyleDataAttribute}]`)) {\n initGlobalColors = () => {\n const style = document.createElement('style')\n style.setAttribute(globalStyleDataAttribute, '')\n style.innerHTML = themeCSSValueString\n\n document.head.appendChild(style)\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n initGlobalColors = VOID_FN\n }\n }\n}\n\nexport const StyleThemeColors = () => (\n <style\n {...{ [globalStyleDataAttribute]: true }}\n dangerouslySetInnerHTML={{ __html: themeCSSValueString }}\n />\n)\n"],"names":["initGlobalColors","themeCSSValueString","StyleThemeColors","darkThemeColors","generateCssColorVariables","themeDark","colors","lightThemeColors","themeLight","VOID_FN","ThemeName","light","dark","window","document","querySelector","globalStyleDataAttribute","style","createElement","setAttribute","innerHTML","head","appendChild","dangerouslySetInnerHTML","__html"],"mappings":"AAAA;;;;;;;;;;;IAmBWA,gBAAgB,MAAhBA,gBAAgB;IACdC,mBAAmB,MAAnBA,mBAAmB;IA8BnBC,gBAAgB,MAAhBA,gBAAgB;;;;4DAlDX,OAAO;wBACa,WAAW;2CACP,uCAAuC;2BAC7B,cAAc;uBAC1C,0BAAoB;AAE5C;;;;;;;;GAQG,GAEH,MAAMC,eAAe,GAAGC,IAAAA,0BAAyB,0BAAA,EAACC,OAAS,UAAA,CAACC,MAAM,CAAC;AACnE,MAAMC,gBAAgB,GAAGH,IAAAA,0BAAyB,0BAAA,EAACI,OAAU,WAAA,CAACF,MAAM,CAAC;AAE9D,IAAIN,gBAAgB,GAAGS,MAAO,QAAA;AAC9B,MAAMR,mBAAmB,GAAG,CAAC;wBACZ,EAAES,UAAS,UAAA,CAACC,KAAK,CAAC;;AAE1C,EAAEJ,gBAAgB,CAAC;;;2BAGQ,EAAEG,UAAS,UAAA,CAACC,KAAK,CAAC;;AAE7C,EAAER,eAAe,CAAC;;;kBAGA,EAAEO,UAAS,UAAA,CAACE,IAAI,CAAC;;AAEnC,EAAET,eAAe,CAAC;CACjB,CAAC;AAEF,IAAI,OAAOU,MAAM,KAAK,WAAW,EAAE;IACjC,IAAI,CAACC,QAAQ,CAACC,aAAa,CAAC,CAAC,MAAM,EAAEC,UAAwB,yBAAA,CAAC,CAAC,CAAC,CAAC,EAAE;QACjEhB,gBAAgB,GAAG,IAAM;YACvB,MAAMiB,KAAK,GAAGH,QAAQ,CAACI,aAAa,CAAC,OAAO,CAAC;YAC7CD,KAAK,CAACE,YAAY,CAACH,UAAwB,yBAAA,EAAE,EAAE,CAAC;YAChDC,KAAK,CAACG,SAAS,GAAGnB,mBAAmB;YAErCa,QAAQ,CAACO,IAAI,CAACC,WAAW,CAACL,KAAK,CAAC;YAChC,gEAAgE;YAChEjB,gBAAgB,GAAGS,MAAO,QAAA;QAC5B,CAAC;IACH,CAAC;AACH,CAAC;AAEM,MAAMP,gBAAgB,GAAG,kBAC9B,6BAACe,OAAK,eACA;QAAE,CAACD,UAAwB,yBAAA,CAAC,EAAE,IAAI;KAAE;QACxCO,uBAAuB,EAAE;YAAEC,MAAM,EAAEvB,mBAAmB;SAAE;OACxD,AACH"}
@@ -9,18 +9,25 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- themeScriptValue: ()=>themeScriptValue,
13
12
  updateGlobalTheme: ()=>updateGlobalTheme,
14
13
  initGlobalCookieTheme: ()=>initGlobalCookieTheme,
15
14
  ScriptThemeValue: ()=>ScriptThemeValue
16
15
  });
17
16
  const _interopRequireDefault = require("@swc/helpers/lib/_interop_require_default.js").default;
18
17
  const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
19
- const _globals = require("../globals");
20
- const _constants = require("../../../cookie-theme-toggler/src/constants");
21
18
  const _utils = require("../../../utils/src/index");
19
+ const _constants = require("../constants");
22
20
  /**
21
+ * What is happening here:
22
+ * We want to have React dehydrated HTML to be loaded after theme is initialized.
23
+ * That means that we need to have some code executed BEFORE main react components code,
24
+ * before even injected script itself, so we need to provide some CSS and JS in document head
25
+ * to read the theme from cookie and make global CSS follow preferred palette.
26
+ * This file is providing JS code that reads/writes cookie value, including <script> element to inject
27
+ * */ /**
23
28
  * this FN should be hermetic and has zero external items - it is inlined via .toString()
29
+ * __PURE__ annotation may throw an error on some external usage cases
30
+ * (with chances, but it is better than nothing)
24
31
  * */ /*#__PURE__*/ const themeScriptValueString = function(key) {
25
32
  if (!window.matchMedia) {
26
33
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -28,28 +35,34 @@ const _utils = require("../../../utils/src/index");
28
35
  }
29
36
  const match = window.matchMedia('(prefers-color-scheme: dark)');
30
37
  const setTheme = ()=>{
31
- const themeCookie = document.cookie.split(';').find((cookie)=>cookie.trim().startsWith(key + '='));
38
+ var ref;
39
+ const cookieMatcher = new RegExp(`(^| )${key}=([^;]+)`);
40
+ var ref1;
41
+ const themeCookie = (ref1 = (ref = document.cookie.match(cookieMatcher)) === null || ref === void 0 ? void 0 : ref[2]) !== null && ref1 !== void 0 ? ref1 : null;
32
42
  if (themeCookie) {
33
- document.documentElement.dataset.theme = themeCookie.split('=')[1];
43
+ document.documentElement.dataset.lidoTheme = themeCookie.split('=')[1];
34
44
  } else {
35
- delete document.documentElement.dataset.theme;
45
+ delete document.documentElement.dataset.lidoTheme;
36
46
  }
37
47
  };
38
48
  setTheme();
39
49
  match.addEventListener('change', setTheme);
40
50
  return setTheme;
41
51
  };
42
- const themeScriptValue = typeof window !== 'undefined' ? themeScriptValueString : ()=>_globals.VOID_FN;
43
- let updateGlobalTheme = _globals.VOID_FN;
44
- let initGlobalCookieTheme = typeof window === 'undefined' ? _globals.VOID_FN : ()=>{
45
- const setTheme = themeScriptValueString(_globals.STORAGE_THEME_MANUAL_KEY);
46
- initGlobalCookieTheme = _globals.VOID_FN;
52
+ let updateGlobalTheme = _utils.VOID_FN;
53
+ let initGlobalCookieTheme = typeof window === 'undefined' ? _utils.VOID_FN : ()=>{
54
+ const setTheme = themeScriptValueString(_constants.themeCookieKey);
55
+ initGlobalCookieTheme = _utils.VOID_FN;
47
56
  const topLevelDomain = (0, _utils.getTopLevelDomain)();
48
57
  updateGlobalTheme = (theme)=>{
49
- document.cookie = `${_constants.COOKIE_THEME_MANUAL_KEY}=${theme};expires=${_constants.COOKIES_THEME_EXPIRES_DAYS};path=/;domain=${topLevelDomain};samesite=None;secure;`;
58
+ document.cookie = `${_constants.themeCookieKey}=${theme};expires=${_constants.themeCookieExpire};path=/;domain=${topLevelDomain};samesite=None;secure;`;
50
59
  setTheme();
51
60
  };
52
61
  };
53
- const ScriptThemeValue = ()=>/*#__PURE__*/ _react.default.createElement("script", null, "`($", themeScriptValueString.toString(), ")($", _globals.STORAGE_THEME_MANUAL_KEY, ")`");
62
+ const ScriptThemeValue = ()=>/*#__PURE__*/ _react.default.createElement("script", {
63
+ dangerouslySetInnerHTML: {
64
+ __html: `(${themeScriptValueString.toString()})("${_constants.themeCookieKey}")`
65
+ }
66
+ });
54
67
 
55
68
  //# sourceMappingURL=element-theme-script.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-script.tsx"],"sourcesContent":["import React from 'react'\nimport { STORAGE_THEME_MANUAL_KEY, ThemeName, VOID_FN } from '../globals'\nimport {\n COOKIE_THEME_MANUAL_KEY,\n COOKIES_THEME_EXPIRES_DAYS,\n} from '../../../cookie-theme-toggler/src/constants'\nimport { getTopLevelDomain } from '@lidofinance/utils'\n\n/**\n * this FN should be hermetic and has zero external items - it is inlined via .toString()\n * */\n/*#__PURE__*/\nconst themeScriptValueString = function (key: string) {\n if (!window.matchMedia) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {}\n }\n const match = window.matchMedia('(prefers-color-scheme: dark)')\n const setTheme = () => {\n const themeCookie = document.cookie\n .split(';')\n .find((cookie) => cookie.trim().startsWith(key + '='))\n if (themeCookie) {\n document.documentElement.dataset.theme = themeCookie.split('=')[1]\n } else {\n delete document.documentElement.dataset.theme\n }\n }\n setTheme()\n match.addEventListener('change', setTheme)\n return setTheme\n}\n\nexport const themeScriptValue =\n typeof window !== 'undefined' ? themeScriptValueString : () => VOID_FN\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport let updateGlobalTheme: (theme: string) => void = VOID_FN\n\nexport let initGlobalCookieTheme =\n typeof window === 'undefined'\n ? VOID_FN\n : () => {\n const setTheme = themeScriptValueString(STORAGE_THEME_MANUAL_KEY)\n initGlobalCookieTheme = VOID_FN\n const topLevelDomain = getTopLevelDomain()\n updateGlobalTheme = (theme: ThemeName) => {\n document.cookie = `${COOKIE_THEME_MANUAL_KEY}=${theme};expires=${COOKIES_THEME_EXPIRES_DAYS};path=/;domain=${topLevelDomain};samesite=None;secure;`\n setTheme()\n }\n }\n\nexport const ScriptThemeValue = () => (\n <script>\n `(${themeScriptValueString.toString()})(${STORAGE_THEME_MANUAL_KEY})`\n </script>\n)\n"],"names":["themeScriptValue","updateGlobalTheme","initGlobalCookieTheme","ScriptThemeValue","themeScriptValueString","key","window","matchMedia","match","setTheme","themeCookie","document","cookie","split","find","trim","startsWith","documentElement","dataset","theme","addEventListener","VOID_FN","STORAGE_THEME_MANUAL_KEY","topLevelDomain","getTopLevelDomain","COOKIE_THEME_MANUAL_KEY","COOKIES_THEME_EXPIRES_DAYS","script","toString"],"mappings":"AAAA;;;;;;;;;;;IAiCaA,gBAAgB,MAAhBA,gBAAgB;IAGlBC,iBAAiB,MAAjBA,iBAAiB;IAEjBC,qBAAqB,MAArBA,qBAAqB;IAanBC,gBAAgB,MAAhBA,gBAAgB;;;4DAnDX,OAAO;yBACoC,YAAY;2BAIlE,6CAA6C;uBAClB,0BAAoB;AAEtD;;GAEG,GACH,WAAW,GACX,MAAMC,sBAAsB,GAAG,SAAUC,GAAW,EAAE;IACpD,IAAI,CAACC,MAAM,CAACC,UAAU,EAAE;QACtB,gEAAgE;QAChE,OAAO,IAAM,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,MAAMC,KAAK,GAAGF,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC;IAC/D,MAAME,QAAQ,GAAG,IAAM;QACrB,MAAMC,WAAW,GAAGC,QAAQ,CAACC,MAAM,CAChCC,KAAK,CAAC,GAAG,CAAC,CACVC,IAAI,CAAC,CAACF,MAAM,GAAKA,MAAM,CAACG,IAAI,EAAE,CAACC,UAAU,CAACX,GAAG,GAAG,GAAG,CAAC,CAAC;QACxD,IAAIK,WAAW,EAAE;YACfC,QAAQ,CAACM,eAAe,CAACC,OAAO,CAACC,KAAK,GAAGT,WAAW,CAACG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACpE,OAAO;YACL,OAAOF,QAAQ,CAACM,eAAe,CAACC,OAAO,CAACC,KAAK;QAC/C,CAAC;IACH,CAAC;IACDV,QAAQ,EAAE;IACVD,KAAK,CAACY,gBAAgB,CAAC,QAAQ,EAAEX,QAAQ,CAAC;IAC1C,OAAOA,QAAQ,CAAA;AACjB,CAAC;AAEM,MAAMT,gBAAgB,GAC3B,OAAOM,MAAM,KAAK,WAAW,GAAGF,sBAAsB,GAAG,IAAMiB,QAAO,QAAA;AAEjE,IAAIpB,iBAAiB,GAA4BoB,QAAO,QAAA;AAExD,IAAInB,qBAAqB,GAC9B,OAAOI,MAAM,KAAK,WAAW,GACzBe,QAAO,QAAA,GACP,IAAM;IACJ,MAAMZ,QAAQ,GAAGL,sBAAsB,CAACkB,QAAwB,yBAAA,CAAC;IACjEpB,qBAAqB,GAAGmB,QAAO,QAAA;IAC/B,MAAME,cAAc,GAAGC,IAAAA,MAAiB,kBAAA,GAAE;IAC1CvB,iBAAiB,GAAG,CAACkB,KAAgB,GAAK;QACxCR,QAAQ,CAACC,MAAM,GAAG,CAAC,EAAEa,UAAuB,wBAAA,CAAC,CAAC,EAAEN,KAAK,CAAC,SAAS,EAAEO,UAA0B,2BAAA,CAAC,eAAe,EAAEH,cAAc,CAAC,sBAAsB,CAAC;QACnJd,QAAQ,EAAE;IACZ,CAAC;AACH,CAAC;AAEA,MAAMN,gBAAgB,GAAG,kBAC9B,6BAACwB,QAAM,QAAC,KACH,EAACvB,sBAAsB,CAACwB,QAAQ,EAAE,EAAC,KAAG,EAACN,QAAwB,yBAAA,EAAC,IACrE,CAAS,AACV"}
1
+ {"version":3,"sources":["../../../../../packages/theme/src/document-head-contents/element-theme-script.tsx"],"sourcesContent":["import React from 'react'\nimport { getTopLevelDomain, VOID_FN } from '@lidofinance/utils'\nimport { themeCookieExpire, themeCookieKey, ThemeName } from '../constants'\n\n/**\n * What is happening here:\n * We want to have React dehydrated HTML to be loaded after theme is initialized.\n * That means that we need to have some code executed BEFORE main react components code,\n * before even injected script itself, so we need to provide some CSS and JS in document head\n * to read the theme from cookie and make global CSS follow preferred palette.\n * This file is providing JS code that reads/writes cookie value, including <script> element to inject\n * */\n\n/**\n * this FN should be hermetic and has zero external items - it is inlined via .toString()\n * __PURE__ annotation may throw an error on some external usage cases\n * (with chances, but it is better than nothing)\n * */\n/*#__PURE__*/\nconst themeScriptValueString = function (key: string) {\n if (!window.matchMedia) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {}\n }\n const match = window.matchMedia('(prefers-color-scheme: dark)')\n const setTheme = () => {\n const cookieMatcher = new RegExp(`(^| )${key}=([^;]+)`)\n const themeCookie =\n (document.cookie.match(cookieMatcher)?.[2] as ThemeName) ?? null\n if (themeCookie) {\n document.documentElement.dataset.lidoTheme = themeCookie.split('=')[1]\n } else {\n delete document.documentElement.dataset.lidoTheme\n }\n }\n setTheme()\n match.addEventListener('change', setTheme)\n return setTheme\n}\n\n// eslint-disable-next-line @typescript-eslint/no-empty-function\nexport let updateGlobalTheme: (theme: string) => void = VOID_FN\n\nexport let initGlobalCookieTheme =\n typeof window === 'undefined'\n ? VOID_FN\n : () => {\n const setTheme = themeScriptValueString(themeCookieKey)\n initGlobalCookieTheme = VOID_FN\n const topLevelDomain = getTopLevelDomain()\n updateGlobalTheme = (theme: ThemeName) => {\n document.cookie = `${themeCookieKey}=${theme};expires=${themeCookieExpire};path=/;domain=${topLevelDomain};samesite=None;secure;`\n setTheme()\n }\n }\n\nexport const ScriptThemeValue = () => (\n <script\n dangerouslySetInnerHTML={{\n __html: `(${themeScriptValueString.toString()})(\"${themeCookieKey}\")`,\n }}\n />\n)\n"],"names":["updateGlobalTheme","initGlobalCookieTheme","ScriptThemeValue","themeScriptValueString","key","window","matchMedia","match","setTheme","document","cookieMatcher","RegExp","themeCookie","cookie","documentElement","dataset","lidoTheme","split","addEventListener","VOID_FN","themeCookieKey","topLevelDomain","getTopLevelDomain","theme","themeCookieExpire","script","dangerouslySetInnerHTML","__html","toString"],"mappings":"AAAA;;;;;;;;;;;IAyCWA,iBAAiB,MAAjBA,iBAAiB;IAEjBC,qBAAqB,MAArBA,qBAAqB;IAanBC,gBAAgB,MAAhBA,gBAAgB;;;4DAxDX,OAAO;uBACkB,0BAAoB;2BACF,cAAc;AAE3E;;;;;;;GAOG,GAEH;;;;GAIG,GACH,WAAW,GACX,MAAMC,sBAAsB,GAAG,SAAUC,GAAW,EAAE;IACpD,IAAI,CAACC,MAAM,CAACC,UAAU,EAAE;QACtB,gEAAgE;QAChE,OAAO,IAAM,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,MAAMC,KAAK,GAAGF,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC;IAC/D,MAAME,QAAQ,GAAG,IAAM;YAGlBC,GAAoC;QAFvC,MAAMC,aAAa,GAAG,IAAIC,MAAM,CAAC,CAAC,KAAK,EAAEP,GAAG,CAAC,QAAQ,CAAC,CAAC;YAErD,IAAwD;QAD1D,MAAMQ,WAAW,GACf,CAAA,IAAwD,GAAvDH,CAAAA,GAAoC,GAApCA,QAAQ,CAACI,MAAM,CAACN,KAAK,CAACG,aAAa,CAAC,cAApCD,GAAoC,WAAK,GAAzCA,KAAAA,CAAyC,GAAzCA,GAAoC,AAAE,CAAC,CAAC,CAAC,cAA1C,IAAwD,cAAxD,IAAwD,GAAI,IAAI;QAClE,IAAIG,WAAW,EAAE;YACfH,QAAQ,CAACK,eAAe,CAACC,OAAO,CAACC,SAAS,GAAGJ,WAAW,CAACK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACxE,OAAO;YACL,OAAOR,QAAQ,CAACK,eAAe,CAACC,OAAO,CAACC,SAAS;QACnD,CAAC;IACH,CAAC;IACDR,QAAQ,EAAE;IACVD,KAAK,CAACW,gBAAgB,CAAC,QAAQ,EAAEV,QAAQ,CAAC;IAC1C,OAAOA,QAAQ,CAAA;AACjB,CAAC;AAGM,IAAIR,iBAAiB,GAA4BmB,MAAO,QAAA;AAExD,IAAIlB,qBAAqB,GAC9B,OAAOI,MAAM,KAAK,WAAW,GACzBc,MAAO,QAAA,GACP,IAAM;IACJ,MAAMX,QAAQ,GAAGL,sBAAsB,CAACiB,UAAc,eAAA,CAAC;IACvDnB,qBAAqB,GAAGkB,MAAO,QAAA;IAC/B,MAAME,cAAc,GAAGC,IAAAA,MAAiB,kBAAA,GAAE;IAC1CtB,iBAAiB,GAAG,CAACuB,KAAgB,GAAK;QACxCd,QAAQ,CAACI,MAAM,GAAG,CAAC,EAAEO,UAAc,eAAA,CAAC,CAAC,EAAEG,KAAK,CAAC,SAAS,EAAEC,UAAiB,kBAAA,CAAC,eAAe,EAAEH,cAAc,CAAC,sBAAsB,CAAC;QACjIb,QAAQ,EAAE;IACZ,CAAC;AACH,CAAC;AAEA,MAAMN,gBAAgB,GAAG,kBAC9B,6BAACuB,QAAM;QACLC,uBAAuB,EAAE;YACvBC,MAAM,EAAE,CAAC,CAAC,EAAExB,sBAAsB,CAACyB,QAAQ,EAAE,CAAC,GAAG,EAAER,UAAc,eAAA,CAAC,EAAE,CAAC;SACtE;MACD,AACH"}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../packages/theme/src/hooks.ts"],"sourcesContent":["import { useContext } from 'react'\nimport { ThemeToggleContext } from './cookie-theme-provider'\nimport { ThemeContext } from './types'\n\nexport const useThemeToggle = (): ThemeContext => {\n return useContext(ThemeToggleContext)\n}\n"],"names":["useThemeToggle","useContext","ThemeToggleContext"],"mappings":"AAAA;;;;+BAIaA,gBAAc;;aAAdA,cAAc;;uBAJA,OAAO;qCACC,yBAAyB;AAGrD,MAAMA,cAAc,GAAG,IAAoB;IAChD,OAAOC,IAAAA,MAAU,WAAA,EAACC,oBAAkB,mBAAA,CAAC,CAAA;AACvC,CAAC"}
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
- _exportStar(require("./provider"), exports);
6
+ _exportStar(require("./cookie-theme-provider"), exports);
7
+ _exportStar(require("./theme-provider"), exports);
7
8
  _exportStar(require("./document-head-contents/index"), exports);
8
9
  _exportStar(require("./constants"), exports);
9
10
  _exportStar(require("./themes"), exports);
11
+ _exportStar(require("./hooks"), exports);
10
12
  _exportStar(require("./types"), exports);
11
13
 
12
14
  //# sourceMappingURL=index.js.map