@etsoo/toolpad 1.0.12 → 1.0.13

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 (260) hide show
  1. package/babel.config.json +11 -0
  2. package/build/cjs/Account/Account.js +104 -0
  3. package/build/cjs/Account/Account.test.js +40 -0
  4. package/build/cjs/Account/AccountPopoverFooter.js +18 -0
  5. package/build/cjs/Account/AccountPopoverHeader.js +12 -0
  6. package/build/cjs/Account/AccountPreview.js +96 -0
  7. package/build/cjs/Account/AccountPreview.test.js +52 -0
  8. package/build/cjs/Account/SignInButton.js +56 -0
  9. package/build/cjs/Account/SignOutButton.js +58 -0
  10. package/build/cjs/Account/index.js +22 -0
  11. package/build/cjs/AppProvider/AppProvider.js +40 -0
  12. package/build/cjs/AppProvider/AppProvider.test.js +18 -0
  13. package/build/cjs/AppProvider/AppProviderComponent.js +33 -0
  14. package/build/cjs/AppProvider/AppThemeProvider.js +111 -0
  15. package/build/cjs/AppProvider/index.js +17 -0
  16. package/build/cjs/DashboardLayout/DashboardLayout.js +230 -0
  17. package/build/cjs/DashboardLayout/DashboardLayout.test.js +296 -0
  18. package/build/cjs/DashboardLayout/DashboardSidebarSubNavigation.js +185 -0
  19. package/build/cjs/DashboardLayout/ThemeSwitcher.js +84 -0
  20. package/build/cjs/DashboardLayout/TitleBar.d.ts +2 -0
  21. package/build/cjs/DashboardLayout/TitleBar.js +57 -0
  22. package/build/cjs/DashboardLayout/ToolbarActions.js +11 -0
  23. package/build/cjs/DashboardLayout/index.js +19 -0
  24. package/build/cjs/DashboardLayout/utils.js +20 -0
  25. package/build/{PageContainer → cjs/PageContainer}/PageContainer.d.ts +4 -0
  26. package/build/cjs/PageContainer/PageContainer.js +133 -0
  27. package/build/cjs/PageContainer/PageContainer.test.js +128 -0
  28. package/build/cjs/PageContainer/PageContainerToolbar.js +26 -0
  29. package/build/cjs/PageContainer/PageContainerToolbar.test.js +15 -0
  30. package/build/cjs/PageContainer/index.js +18 -0
  31. package/build/cjs/index.js +24 -0
  32. package/build/cjs/nextjs/AppProvider.js +18 -0
  33. package/build/cjs/nextjs/AppProvider.test.js +71 -0
  34. package/build/cjs/nextjs/AppProviderNextApp.js +63 -0
  35. package/build/cjs/nextjs/AppProviderNextPages.js +73 -0
  36. package/build/cjs/nextjs/index.js +17 -0
  37. package/build/cjs/persistence/codec.js +60 -0
  38. package/build/cjs/persistence/index.js +17 -0
  39. package/build/cjs/persistence/useStorageState.js +153 -0
  40. package/build/cjs/persistence/useStorageState.test.js +63 -0
  41. package/build/cjs/react-router-dom/AppProvider.js +64 -0
  42. package/build/cjs/react-router-dom/AppProvider.test.js +14 -0
  43. package/build/cjs/react-router-dom/index.js +17 -0
  44. package/build/cjs/shared/Link.js +55 -0
  45. package/build/cjs/shared/components.js +30 -0
  46. package/build/cjs/shared/context.js +46 -0
  47. package/build/cjs/shared/locales/LocaleContext.js +71 -0
  48. package/build/cjs/shared/navigation.js +151 -0
  49. package/build/cjs/useActivePage/index.js +17 -0
  50. package/build/cjs/useActivePage/useActivePage.js +83 -0
  51. package/build/cjs/useLocalStorageState/index.js +17 -0
  52. package/build/cjs/useLocalStorageState/useLocalStorageState.js +17 -0
  53. package/build/cjs/useSessionStorageState/index.js +17 -0
  54. package/build/cjs/useSessionStorageState/useSessionStorageState.js +17 -0
  55. package/build/cjs/utils/collections.js +53 -0
  56. package/build/cjs/utils/describeConformance.js +6 -0
  57. package/build/cjs/utils/events.js +58 -0
  58. package/build/cjs/utils/hooks/index.js +10 -0
  59. package/build/cjs/utils/hooks/useBoolean.js +47 -0
  60. package/build/cjs/utils/hooks/useDebounced.js +64 -0
  61. package/build/cjs/utils/hooks/useDebouncedHandler.js +77 -0
  62. package/build/cjs/utils/hooks/useLatest.js +44 -0
  63. package/build/cjs/utils/hooks/usePageTitle.js +49 -0
  64. package/build/cjs/utils/hooks/useSsr.js +52 -0
  65. package/build/cjs/utils/hooks/useStorageState.js +86 -0
  66. package/build/cjs/utils/warnOnce.js +14 -0
  67. package/build/mjs/Account/Account.d.ts +63 -0
  68. package/build/mjs/Account/Account.test.d.ts +1 -0
  69. package/build/mjs/Account/AccountPopoverFooter.d.ts +6 -0
  70. package/build/mjs/Account/AccountPopoverHeader.d.ts +6 -0
  71. package/build/mjs/Account/AccountPreview.d.ts +64 -0
  72. package/build/mjs/Account/AccountPreview.test.d.ts +1 -0
  73. package/build/mjs/Account/SignInButton.d.ts +2 -0
  74. package/build/mjs/Account/SignOutButton.d.ts +3 -0
  75. package/build/mjs/Account/index.js +6 -0
  76. package/build/mjs/AppProvider/AppProvider.d.ts +105 -0
  77. package/build/mjs/AppProvider/AppProvider.test.d.ts +4 -0
  78. package/build/mjs/AppProvider/AppProviderComponent.d.ts +14 -0
  79. package/build/mjs/AppProvider/AppThemeProvider.d.ts +12 -0
  80. package/build/mjs/DashboardLayout/DashboardLayout.d.ts +91 -0
  81. package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.js +9 -10
  82. package/build/mjs/DashboardLayout/DashboardLayout.test.d.ts +1 -0
  83. package/build/mjs/DashboardLayout/DashboardSidebarSubNavigation.d.ts +16 -0
  84. package/build/mjs/DashboardLayout/ThemeSwitcher.d.ts +5 -0
  85. package/build/mjs/DashboardLayout/TitleBar.d.ts +2 -0
  86. package/build/mjs/DashboardLayout/ToolbarActions.d.ts +5 -0
  87. package/build/mjs/DashboardLayout/index.d.ts +2 -0
  88. package/build/mjs/DashboardLayout/utils.d.ts +8 -0
  89. package/build/mjs/PageContainer/PageContainer.d.ts +61 -0
  90. package/build/{PageContainer → mjs/PageContainer}/PageContainer.js +8 -4
  91. package/build/mjs/PageContainer/PageContainer.test.d.ts +1 -0
  92. package/build/mjs/PageContainer/PageContainerToolbar.d.ts +16 -0
  93. package/build/mjs/PageContainer/PageContainerToolbar.test.d.ts +1 -0
  94. package/build/mjs/PageContainer/index.js +2 -0
  95. package/build/mjs/index.js +8 -0
  96. package/build/mjs/nextjs/AppProvider.d.ts +6 -0
  97. package/build/mjs/nextjs/AppProvider.test.d.ts +1 -0
  98. package/build/mjs/nextjs/AppProviderNextApp.d.ts +5 -0
  99. package/build/mjs/nextjs/AppProviderNextPages.d.ts +5 -0
  100. package/build/mjs/nextjs/index.js +1 -0
  101. package/build/mjs/persistence/codec.d.ts +47 -0
  102. package/build/mjs/persistence/index.js +1 -0
  103. package/build/mjs/persistence/useStorageState.d.ts +50 -0
  104. package/build/mjs/persistence/useStorageState.test.d.ts +1 -0
  105. package/build/mjs/react-router-dom/AppProvider.d.ts +6 -0
  106. package/build/mjs/react-router-dom/AppProvider.test.d.ts +1 -0
  107. package/build/mjs/react-router-dom/index.d.ts +1 -0
  108. package/build/mjs/react-router-dom/index.js +1 -0
  109. package/build/mjs/shared/Link.d.ts +8 -0
  110. package/build/mjs/shared/components.d.ts +5 -0
  111. package/build/mjs/shared/context.d.ts +12 -0
  112. package/build/mjs/shared/locales/LocaleContext.d.ts +56 -0
  113. package/build/mjs/shared/navigation.d.ts +16 -0
  114. package/build/mjs/useActivePage/index.js +1 -0
  115. package/build/mjs/useActivePage/useActivePage.d.ts +8 -0
  116. package/build/mjs/useLocalStorageState/index.js +1 -0
  117. package/build/mjs/useLocalStorageState/useLocalStorageState.d.ts +2 -0
  118. package/build/mjs/useSessionStorageState/index.js +1 -0
  119. package/build/mjs/useSessionStorageState/useSessionStorageState.d.ts +2 -0
  120. package/build/mjs/utils/collections.d.ts +44 -0
  121. package/build/mjs/utils/describeConformance.d.ts +7 -0
  122. package/build/mjs/utils/events.d.ts +27 -0
  123. package/build/mjs/utils/hooks/index.js +2 -0
  124. package/build/mjs/utils/hooks/useBoolean.d.ts +11 -0
  125. package/build/mjs/utils/hooks/useDebounced.d.ts +8 -0
  126. package/build/mjs/utils/hooks/useDebouncedHandler.d.ts +12 -0
  127. package/build/mjs/utils/hooks/useLatest.d.ts +6 -0
  128. package/build/mjs/utils/hooks/usePageTitle.d.ts +4 -0
  129. package/build/mjs/utils/hooks/useSsr.d.ts +4 -0
  130. package/build/mjs/utils/hooks/useStorageState.d.ts +10 -0
  131. package/build/mjs/utils/warnOnce.d.ts +5 -0
  132. package/package.json +33 -23
  133. package/src/DashboardLayout/DashboardLayout.tsx +13 -12
  134. package/src/PageContainer/PageContainer.tsx +12 -4
  135. package/tsconfig.cjs.json +20 -0
  136. package/tsconfig.json +2 -2
  137. package/build/DashboardLayout/TitleBar.d.ts +0 -2
  138. /package/build/{Account → cjs/Account}/Account.d.ts +0 -0
  139. /package/build/{Account → cjs/Account}/Account.test.d.ts +0 -0
  140. /package/build/{Account → cjs/Account}/AccountPopoverFooter.d.ts +0 -0
  141. /package/build/{Account → cjs/Account}/AccountPopoverHeader.d.ts +0 -0
  142. /package/build/{Account → cjs/Account}/AccountPreview.d.ts +0 -0
  143. /package/build/{Account → cjs/Account}/AccountPreview.test.d.ts +0 -0
  144. /package/build/{Account → cjs/Account}/SignInButton.d.ts +0 -0
  145. /package/build/{Account → cjs/Account}/SignOutButton.d.ts +0 -0
  146. /package/build/{Account → cjs/Account}/index.d.ts +0 -0
  147. /package/build/{AppProvider → cjs/AppProvider}/AppProvider.d.ts +0 -0
  148. /package/build/{AppProvider → cjs/AppProvider}/AppProvider.test.d.ts +0 -0
  149. /package/build/{AppProvider → cjs/AppProvider}/AppProviderComponent.d.ts +0 -0
  150. /package/build/{AppProvider → cjs/AppProvider}/AppThemeProvider.d.ts +0 -0
  151. /package/build/{AppProvider → cjs/AppProvider}/index.d.ts +0 -0
  152. /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.d.ts +0 -0
  153. /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.test.d.ts +0 -0
  154. /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardSidebarSubNavigation.d.ts +0 -0
  155. /package/build/{DashboardLayout → cjs/DashboardLayout}/ThemeSwitcher.d.ts +0 -0
  156. /package/build/{DashboardLayout → cjs/DashboardLayout}/ToolbarActions.d.ts +0 -0
  157. /package/build/{DashboardLayout → cjs/DashboardLayout}/index.d.ts +0 -0
  158. /package/build/{DashboardLayout → cjs/DashboardLayout}/utils.d.ts +0 -0
  159. /package/build/{PageContainer → cjs/PageContainer}/PageContainer.test.d.ts +0 -0
  160. /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.d.ts +0 -0
  161. /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.test.d.ts +0 -0
  162. /package/build/{PageContainer → cjs/PageContainer}/index.d.ts +0 -0
  163. /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
  164. /package/build/{nextjs → cjs/nextjs}/AppProvider.d.ts +0 -0
  165. /package/build/{nextjs → cjs/nextjs}/AppProvider.test.d.ts +0 -0
  166. /package/build/{nextjs → cjs/nextjs}/AppProviderNextApp.d.ts +0 -0
  167. /package/build/{nextjs → cjs/nextjs}/AppProviderNextPages.d.ts +0 -0
  168. /package/build/{nextjs → cjs/nextjs}/index.d.ts +0 -0
  169. /package/build/{persistence → cjs/persistence}/codec.d.ts +0 -0
  170. /package/build/{persistence → cjs/persistence}/index.d.ts +0 -0
  171. /package/build/{persistence → cjs/persistence}/useStorageState.d.ts +0 -0
  172. /package/build/{persistence → cjs/persistence}/useStorageState.test.d.ts +0 -0
  173. /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.d.ts +0 -0
  174. /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.test.d.ts +0 -0
  175. /package/build/{react-router-dom → cjs/react-router-dom}/index.d.ts +0 -0
  176. /package/build/{shared → cjs/shared}/Link.d.ts +0 -0
  177. /package/build/{shared → cjs/shared}/components.d.ts +0 -0
  178. /package/build/{shared → cjs/shared}/context.d.ts +0 -0
  179. /package/build/{shared → cjs/shared}/locales/LocaleContext.d.ts +0 -0
  180. /package/build/{shared → cjs/shared}/navigation.d.ts +0 -0
  181. /package/build/{useActivePage → cjs/useActivePage}/index.d.ts +0 -0
  182. /package/build/{useActivePage → cjs/useActivePage}/useActivePage.d.ts +0 -0
  183. /package/build/{useLocalStorageState → cjs/useLocalStorageState}/index.d.ts +0 -0
  184. /package/build/{useLocalStorageState → cjs/useLocalStorageState}/useLocalStorageState.d.ts +0 -0
  185. /package/build/{useSessionStorageState → cjs/useSessionStorageState}/index.d.ts +0 -0
  186. /package/build/{useSessionStorageState → cjs/useSessionStorageState}/useSessionStorageState.d.ts +0 -0
  187. /package/build/{utils → cjs/utils}/collections.d.ts +0 -0
  188. /package/build/{utils → cjs/utils}/describeConformance.d.ts +0 -0
  189. /package/build/{utils → cjs/utils}/events.d.ts +0 -0
  190. /package/build/{utils → cjs/utils}/hooks/index.d.ts +0 -0
  191. /package/build/{utils → cjs/utils}/hooks/useBoolean.d.ts +0 -0
  192. /package/build/{utils → cjs/utils}/hooks/useDebounced.d.ts +0 -0
  193. /package/build/{utils → cjs/utils}/hooks/useDebouncedHandler.d.ts +0 -0
  194. /package/build/{utils → cjs/utils}/hooks/useLatest.d.ts +0 -0
  195. /package/build/{utils → cjs/utils}/hooks/usePageTitle.d.ts +0 -0
  196. /package/build/{utils → cjs/utils}/hooks/useSsr.d.ts +0 -0
  197. /package/build/{utils → cjs/utils}/hooks/useStorageState.d.ts +0 -0
  198. /package/build/{utils → cjs/utils}/warnOnce.d.ts +0 -0
  199. /package/build/{Account → mjs/Account}/Account.js +0 -0
  200. /package/build/{Account → mjs/Account}/Account.test.js +0 -0
  201. /package/build/{Account → mjs/Account}/AccountPopoverFooter.js +0 -0
  202. /package/build/{Account → mjs/Account}/AccountPopoverHeader.js +0 -0
  203. /package/build/{Account → mjs/Account}/AccountPreview.js +0 -0
  204. /package/build/{Account → mjs/Account}/AccountPreview.test.js +0 -0
  205. /package/build/{Account → mjs/Account}/SignInButton.js +0 -0
  206. /package/build/{Account → mjs/Account}/SignOutButton.js +0 -0
  207. /package/build/{Account/index.js → mjs/Account/index.d.ts} +0 -0
  208. /package/build/{AppProvider → mjs/AppProvider}/AppProvider.js +0 -0
  209. /package/build/{AppProvider → mjs/AppProvider}/AppProvider.test.js +0 -0
  210. /package/build/{AppProvider → mjs/AppProvider}/AppProviderComponent.js +0 -0
  211. /package/build/{AppProvider → mjs/AppProvider}/AppThemeProvider.js +0 -0
  212. /package/build/{AppProvider/index.js → mjs/AppProvider/index.d.ts} +0 -0
  213. /package/build/{nextjs → mjs/AppProvider}/index.js +0 -0
  214. /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.test.js +0 -0
  215. /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardSidebarSubNavigation.js +0 -0
  216. /package/build/{DashboardLayout → mjs/DashboardLayout}/ThemeSwitcher.js +0 -0
  217. /package/build/{DashboardLayout → mjs/DashboardLayout}/TitleBar.js +0 -0
  218. /package/build/{DashboardLayout → mjs/DashboardLayout}/ToolbarActions.js +0 -0
  219. /package/build/{DashboardLayout → mjs/DashboardLayout}/index.js +0 -0
  220. /package/build/{DashboardLayout → mjs/DashboardLayout}/utils.js +0 -0
  221. /package/build/{PageContainer → mjs/PageContainer}/PageContainer.test.js +0 -0
  222. /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.js +0 -0
  223. /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.test.js +0 -0
  224. /package/build/{PageContainer/index.js → mjs/PageContainer/index.d.ts} +0 -0
  225. /package/build/{index.js → mjs/index.d.ts} +0 -0
  226. /package/build/{nextjs → mjs/nextjs}/AppProvider.js +0 -0
  227. /package/build/{nextjs → mjs/nextjs}/AppProvider.test.js +0 -0
  228. /package/build/{nextjs → mjs/nextjs}/AppProviderNextApp.js +0 -0
  229. /package/build/{nextjs → mjs/nextjs}/AppProviderNextPages.js +0 -0
  230. /package/build/{react-router-dom/index.js → mjs/nextjs/index.d.ts} +0 -0
  231. /package/build/{persistence → mjs/persistence}/codec.js +0 -0
  232. /package/build/{persistence/index.js → mjs/persistence/index.d.ts} +0 -0
  233. /package/build/{persistence → mjs/persistence}/useStorageState.js +0 -0
  234. /package/build/{persistence → mjs/persistence}/useStorageState.test.js +0 -0
  235. /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.js +0 -0
  236. /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.test.js +0 -0
  237. /package/build/{shared → mjs/shared}/Link.js +0 -0
  238. /package/build/{shared → mjs/shared}/components.js +0 -0
  239. /package/build/{shared → mjs/shared}/context.js +0 -0
  240. /package/build/{shared → mjs/shared}/locales/LocaleContext.js +0 -0
  241. /package/build/{shared → mjs/shared}/navigation.js +0 -0
  242. /package/build/{useActivePage/index.js → mjs/useActivePage/index.d.ts} +0 -0
  243. /package/build/{useActivePage → mjs/useActivePage}/useActivePage.js +0 -0
  244. /package/build/{useLocalStorageState/index.js → mjs/useLocalStorageState/index.d.ts} +0 -0
  245. /package/build/{useLocalStorageState → mjs/useLocalStorageState}/useLocalStorageState.js +0 -0
  246. /package/build/{useSessionStorageState/index.js → mjs/useSessionStorageState/index.d.ts} +0 -0
  247. /package/build/{useSessionStorageState → mjs/useSessionStorageState}/useSessionStorageState.js +0 -0
  248. /package/build/{utils → mjs/utils}/collections.js +0 -0
  249. /package/build/{utils → mjs/utils}/describeConformance.js +0 -0
  250. /package/build/{utils → mjs/utils}/events.js +0 -0
  251. /package/build/{utils/hooks/index.js → mjs/utils/hooks/index.d.ts} +0 -0
  252. /package/build/{utils → mjs/utils}/hooks/useBoolean.js +0 -0
  253. /package/build/{utils → mjs/utils}/hooks/useDebounced.js +0 -0
  254. /package/build/{utils → mjs/utils}/hooks/useDebouncedHandler.js +0 -0
  255. /package/build/{utils → mjs/utils}/hooks/useLatest.js +0 -0
  256. /package/build/{utils → mjs/utils}/hooks/usePageTitle.js +0 -0
  257. /package/build/{utils → mjs/utils}/hooks/useSsr.js +0 -0
  258. /package/build/{utils → mjs/utils}/hooks/useStorageState.js +0 -0
  259. /package/build/{utils → mjs/utils}/warnOnce.js +0 -0
  260. /package/{vite.config.ts → vite.config.mts} +0 -0
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.PageContainerToolbar = PageContainerToolbar;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const material_1 = require("@mui/material");
7
+ const PageContainerToolbarRoot = (0, material_1.styled)("div")(({ theme }) => ({
8
+ display: "flex",
9
+ flexDirection: "row",
10
+ gap: theme.spacing(1),
11
+ // Ensure the toolbar is always on the right side, even after wrapping
12
+ marginLeft: "auto"
13
+ }));
14
+ /**
15
+ *
16
+ * Demos:
17
+ *
18
+ * - [Page Container](https://mui.com/toolpad/core/react-page-container/)
19
+ *
20
+ * API:
21
+ *
22
+ * - [PageContainerToolbar API](https://mui.com/toolpad/core/api/page-container-toolbar)
23
+ */
24
+ function PageContainerToolbar(props) {
25
+ return (0, jsx_runtime_1.jsx)(PageContainerToolbarRoot, { ...props });
26
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const vitest_1 = require("vitest");
8
+ const PageContainerToolbar_1 = require("./PageContainerToolbar");
9
+ const describeConformance_1 = __importDefault(require("../utils/describeConformance"));
10
+ (0, vitest_1.describe)("PageContainerToolbar", () => {
11
+ (0, describeConformance_1.default)((0, jsx_runtime_1.jsx)(PageContainerToolbar_1.PageContainerToolbar, {}), () => ({
12
+ skip: ["themeDefaultProps"]
13
+ }));
14
+ (0, vitest_1.test)("dummy test", () => { });
15
+ });
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./PageContainer"), exports);
18
+ __exportStar(require("./PageContainerToolbar"), exports);
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AppProvider"), exports);
18
+ __exportStar(require("./DashboardLayout"), exports);
19
+ __exportStar(require("./Account"), exports);
20
+ __exportStar(require("./PageContainer"), exports);
21
+ __exportStar(require("./useActivePage"), exports);
22
+ __exportStar(require("./useLocalStorageState"), exports);
23
+ __exportStar(require("./useSessionStorageState"), exports);
24
+ __exportStar(require("./persistence/codec"), exports);
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.AppProvider = AppProvider;
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const router_1 = require("next/compat/router");
7
+ const AppProviderNextApp_1 = require("./AppProviderNextApp");
8
+ const AppProviderNextPages_1 = require("./AppProviderNextPages");
9
+ /**
10
+ * @ignore - internal component.
11
+ */
12
+ function AppProvider(props) {
13
+ const router = (0, router_1.useRouter)();
14
+ const AppProviderComponent = router
15
+ ? AppProviderNextPages_1.AppProviderNextPages
16
+ : AppProviderNextApp_1.AppProviderNextApp;
17
+ return (0, jsx_runtime_1.jsx)(AppProviderComponent, { ...props });
18
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const jsx_runtime_1 = require("react/jsx-runtime");
37
+ const React = __importStar(require("react"));
38
+ const vitest_1 = require("vitest");
39
+ const react_1 = require("@testing-library/react");
40
+ const AppProvider_1 = require("./AppProvider");
41
+ vitest_1.vi.mock("next/navigation", () => {
42
+ const searchParams = new URLSearchParams();
43
+ const push = () => { };
44
+ const replace = () => { };
45
+ const router = { push, replace };
46
+ return {
47
+ usePathname: () => "/",
48
+ useSearchParams: () => searchParams,
49
+ useRouter: () => router
50
+ };
51
+ });
52
+ vitest_1.vi.mock("next/router", () => ({ useRouter: () => null }));
53
+ vitest_1.vi.mock("next/compat/router", () => ({ useRouter: () => null }));
54
+ function RouterTest({ children }) {
55
+ const [pathname, setPathname] = React.useState("/page");
56
+ const router = React.useMemo(() => {
57
+ return {
58
+ pathname,
59
+ searchParams: new URLSearchParams(),
60
+ navigate: (path) => setPathname(String(path))
61
+ };
62
+ }, [pathname]);
63
+ return (0, jsx_runtime_1.jsx)(AppProvider_1.AppProvider, { router: router, children: children });
64
+ }
65
+ (0, vitest_1.describe)("Nextjs AppProvider", () => {
66
+ (0, vitest_1.test)("renders content correctly", async () => {
67
+ // placeholder test
68
+ (0, react_1.render)((0, jsx_runtime_1.jsx)(RouterTest, { children: "Hello" }));
69
+ (0, vitest_1.expect)(react_1.screen.getByText("Hello")).toBeTruthy();
70
+ });
71
+ });
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AppProviderNextApp = AppProviderNextApp;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const React = __importStar(require("react"));
39
+ const navigation_1 = require("next/navigation");
40
+ const AppProviderComponent_1 = require("../AppProvider/AppProviderComponent");
41
+ /**
42
+ * @ignore - internal component.
43
+ */
44
+ function AppProviderNextApp(props) {
45
+ const pathname = (0, navigation_1.usePathname)();
46
+ const searchParams = (0, navigation_1.useSearchParams)();
47
+ const { push, replace } = (0, navigation_1.useRouter)();
48
+ const navigate = React.useCallback((url, { history = "auto" } = {}) => {
49
+ if (history === "auto" || history === "push") {
50
+ return push(String(url));
51
+ }
52
+ if (history === "replace") {
53
+ return replace(String(url));
54
+ }
55
+ throw new Error(`Invalid history option: ${history}`);
56
+ }, [push, replace]);
57
+ const routerImpl = React.useMemo(() => ({
58
+ pathname,
59
+ searchParams,
60
+ navigate
61
+ }), [pathname, navigate, searchParams]);
62
+ return (0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { router: routerImpl, ...props });
63
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.AppProviderNextPages = AppProviderNextPages;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const React = __importStar(require("react"));
39
+ const router_1 = require("next/router");
40
+ const collections_1 = require("../utils/collections");
41
+ const AppProviderComponent_1 = require("../AppProvider/AppProviderComponent");
42
+ /**
43
+ * @ignore - internal component.
44
+ */
45
+ function AppProviderNextPages(props) {
46
+ const { push, replace, asPath, query } = (0, router_1.useRouter)();
47
+ const search = React.useMemo(() => {
48
+ const params = new URLSearchParams();
49
+ Object.entries(query ?? {}).forEach(([key, value]) => {
50
+ (0, collections_1.asArray)(value ?? []).forEach((v) => {
51
+ params.append(key, v);
52
+ });
53
+ });
54
+ return params.toString();
55
+ }, [query]);
56
+ // Stable search params object
57
+ const searchParams = React.useMemo(() => new URLSearchParams(search), [search]);
58
+ const navigate = React.useCallback((url, { history = "auto" } = {}) => {
59
+ if (history === "auto" || history === "push") {
60
+ return push(String(url));
61
+ }
62
+ if (history === "replace") {
63
+ return replace(String(url));
64
+ }
65
+ throw new Error(`Invalid history option: ${history}`);
66
+ }, [push, replace]);
67
+ const routerImpl = React.useMemo(() => ({
68
+ pathname: asPath,
69
+ searchParams,
70
+ navigate
71
+ }), [asPath, navigate, searchParams]);
72
+ return (0, jsx_runtime_1.jsx)(AppProviderComponent_1.AppProvider, { router: routerImpl, ...props });
73
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AppProvider"), exports);
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CODEC_STRING = exports.CODEC_JSON_STRICT = exports.CODEC_JSON = exports.CODE_BOOLEAN = exports.CODEC_NUMBER = exports.CODEC_DATE_ONLY = exports.CODEC_DATE = void 0;
4
+ /**
5
+ * A codec that can encode and decode Date objects to and from strings.
6
+ */
7
+ exports.CODEC_DATE = {
8
+ parse: (value) => new Date(value),
9
+ stringify: (value) => value.toISOString()
10
+ };
11
+ /**
12
+ * A codec that can encode and decode Date objects to and from strings, but only the date part.
13
+ */
14
+ exports.CODEC_DATE_ONLY = {
15
+ parse: (value) => new Date(value),
16
+ stringify: (value) => value.toISOString().split("T")[0]
17
+ };
18
+ /**
19
+ * A codec that can encode and decode numbers to and from strings.
20
+ */
21
+ exports.CODEC_NUMBER = {
22
+ parse: (value) => Number(value),
23
+ stringify: (value) => String(value)
24
+ };
25
+ /**
26
+ * A codec that can encode and decode boolean values to and from strings.
27
+ */
28
+ exports.CODE_BOOLEAN = {
29
+ parse: (value) => value === "true",
30
+ stringify: (value) => String(value)
31
+ };
32
+ /**
33
+ * A codec that can encode and decode JSON values to and from strings.
34
+ */
35
+ exports.CODEC_JSON = {
36
+ parse: (value) => {
37
+ try {
38
+ return JSON.parse(value);
39
+ }
40
+ catch {
41
+ return null;
42
+ }
43
+ },
44
+ stringify: (value) => JSON.stringify(value)
45
+ };
46
+ /**
47
+ * A codec that can encode and decode JSON values to and from strings.
48
+ * If the JSON value is invalid, parsing will fail.
49
+ */
50
+ exports.CODEC_JSON_STRICT = {
51
+ parse: (value) => JSON.parse(value),
52
+ stringify: (value) => JSON.stringify(value)
53
+ };
54
+ /**
55
+ * A codec that can encode and decode strings to and from strings.
56
+ */
57
+ exports.CODEC_STRING = {
58
+ parse: (value) => value,
59
+ stringify: (value) => value
60
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useStorageState"), exports);
@@ -0,0 +1,153 @@
1
+ "use client";
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.useStorageStateServer = useStorageStateServer;
38
+ exports.useStorageState = useStorageState;
39
+ const React = __importStar(require("react"));
40
+ const codec_1 = require("./codec");
41
+ // storage events only work across tabs, we'll use an event emitter to announce within the current tab
42
+ const currentTabChangeListeners = new Map();
43
+ function onCurrentTabStorageChange(key, handler) {
44
+ let listeners = currentTabChangeListeners.get(key);
45
+ if (!listeners) {
46
+ listeners = new Set();
47
+ currentTabChangeListeners.set(key, listeners);
48
+ }
49
+ listeners.add(handler);
50
+ }
51
+ function offCurrentTabStorageChange(key, handler) {
52
+ const listeners = currentTabChangeListeners.get(key);
53
+ if (!listeners) {
54
+ return;
55
+ }
56
+ listeners.delete(handler);
57
+ if (listeners.size === 0) {
58
+ currentTabChangeListeners.delete(key);
59
+ }
60
+ }
61
+ function emitCurrentTabStorageChange(key) {
62
+ const listeners = currentTabChangeListeners.get(key);
63
+ if (listeners) {
64
+ listeners.forEach((listener) => listener());
65
+ }
66
+ }
67
+ if (typeof window !== "undefined") {
68
+ const origSetItem = window.localStorage.setItem;
69
+ window.localStorage.setItem = function setItem(key, value) {
70
+ const result = origSetItem.call(this, key, value);
71
+ emitCurrentTabStorageChange(key);
72
+ return result;
73
+ };
74
+ }
75
+ function subscribe(area, key, callback) {
76
+ if (!key) {
77
+ return () => { };
78
+ }
79
+ const storageHandler = (event) => {
80
+ if (event.storageArea === area && event.key === key) {
81
+ callback();
82
+ }
83
+ };
84
+ window.addEventListener("storage", storageHandler);
85
+ onCurrentTabStorageChange(key, callback);
86
+ return () => {
87
+ window.removeEventListener("storage", storageHandler);
88
+ offCurrentTabStorageChange(key, callback);
89
+ };
90
+ }
91
+ function getSnapshot(area, key) {
92
+ if (!key) {
93
+ return null;
94
+ }
95
+ try {
96
+ return area.getItem(key);
97
+ }
98
+ catch {
99
+ // ignore
100
+ // See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage
101
+ return null;
102
+ }
103
+ }
104
+ function setValue(area, key, value) {
105
+ if (!key) {
106
+ return;
107
+ }
108
+ try {
109
+ if (value === null) {
110
+ area.removeItem(key);
111
+ }
112
+ else {
113
+ area.setItem(key, String(value));
114
+ }
115
+ }
116
+ catch {
117
+ // ignore
118
+ // See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API#feature-detecting_localstorage
119
+ return;
120
+ }
121
+ emitCurrentTabStorageChange(key);
122
+ }
123
+ const serverValue = [null, () => { }];
124
+ function useStorageStateServer() {
125
+ return serverValue;
126
+ }
127
+ function encode(codec, value) {
128
+ return value === null ? null : codec.stringify(value);
129
+ }
130
+ function decode(codec, value) {
131
+ return value === null ? null : codec.parse(value);
132
+ }
133
+ // Start with null for the hydration, and then switch to the actual value.
134
+ const getKeyServerSnapshot = () => null;
135
+ function useStorageState(area, key, initializer = null, options) {
136
+ const codec = (options?.codec ?? codec_1.CODEC_STRING);
137
+ const [initialValue] = React.useState(initializer);
138
+ const encodedInitialValue = React.useMemo(() => encode(codec, initialValue), [codec, initialValue]);
139
+ const subscribeKey = React.useCallback((callback) => subscribe(area, key, callback), [area, key]);
140
+ const getKeySnapshot = React.useCallback(() => getSnapshot(area, key) ?? encodedInitialValue, [area, encodedInitialValue, key]);
141
+ const encodedStoredValue = React.useSyncExternalStore(subscribeKey, getKeySnapshot, getKeyServerSnapshot);
142
+ const storedValue = React.useMemo(() => decode(codec, encodedStoredValue), [codec, encodedStoredValue]);
143
+ const setStoredValue = React.useCallback((value) => {
144
+ const valueToStore = value instanceof Function ? value(storedValue) : value;
145
+ const encodedValueToStore = encode(codec, valueToStore);
146
+ setValue(area, key, encodedValueToStore);
147
+ }, [area, codec, storedValue, key]);
148
+ const [nonStoredValue, setNonStoredValue] = React.useState(initialValue);
149
+ if (!key) {
150
+ return [nonStoredValue, setNonStoredValue];
151
+ }
152
+ return [storedValue, setStoredValue];
153
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ const react_1 = require("@testing-library/react");
5
+ const useStorageState_1 = require("./useStorageState");
6
+ (0, vitest_1.describe)("useStorageState", () => {
7
+ (0, vitest_1.beforeEach)(() => {
8
+ window.localStorage.clear();
9
+ });
10
+ (0, vitest_1.test)("can do basic local storage with initial value", async () => {
11
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, useStorageState_1.useStorageState)(window.localStorage, "foo", "bar"));
12
+ (0, vitest_1.expect)(result.current[0]).toBe("bar");
13
+ (0, react_1.act)(() => {
14
+ result.current[1]("baz");
15
+ });
16
+ rerender();
17
+ (0, vitest_1.expect)(result.current[0]).toBe("baz");
18
+ });
19
+ (0, vitest_1.test)("can do basic local storage without initial value", async () => {
20
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, useStorageState_1.useStorageState)(window.localStorage, "foo"));
21
+ (0, vitest_1.expect)(result.current[0]).toBe(null);
22
+ (0, react_1.act)(() => {
23
+ result.current[1]("baz");
24
+ });
25
+ rerender();
26
+ (0, vitest_1.expect)(result.current[0]).toBe("baz");
27
+ });
28
+ (0, vitest_1.test)("can clear storage value, and reset to intiial value", async () => {
29
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, useStorageState_1.useStorageState)(window.localStorage, "foo", "bar"));
30
+ (0, react_1.act)(() => {
31
+ result.current[1]("baz");
32
+ });
33
+ rerender();
34
+ (0, vitest_1.expect)(result.current[0]).toBe("baz");
35
+ (0, react_1.act)(() => {
36
+ result.current[1](null);
37
+ });
38
+ rerender();
39
+ (0, vitest_1.expect)(result.current[0]).toBe("bar");
40
+ });
41
+ (0, vitest_1.test)("can clear storage value", async () => {
42
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, useStorageState_1.useStorageState)(window.localStorage, "foo"));
43
+ (0, react_1.act)(() => {
44
+ result.current[1]("baz");
45
+ });
46
+ rerender();
47
+ (0, vitest_1.expect)(result.current[0]).toBe("baz");
48
+ (0, react_1.act)(() => {
49
+ result.current[1](null);
50
+ });
51
+ rerender();
52
+ (0, vitest_1.expect)(result.current[0]).toBe(null);
53
+ });
54
+ (0, vitest_1.test)("can handle complex types", async () => {
55
+ const { result, rerender } = (0, react_1.renderHook)(() => (0, useStorageState_1.useStorageState)(window.localStorage, "foo", { a: 1 }, { codec: JSON }));
56
+ (0, vitest_1.expect)(result.current[0]).toEqual({ a: 1 });
57
+ (0, react_1.act)(() => {
58
+ result.current[1]({ b: 2 });
59
+ });
60
+ rerender();
61
+ (0, vitest_1.expect)(result.current[0]).toEqual({ b: 2 });
62
+ });
63
+ });