@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.
- package/babel.config.json +11 -0
- package/build/cjs/Account/Account.js +104 -0
- package/build/cjs/Account/Account.test.js +40 -0
- package/build/cjs/Account/AccountPopoverFooter.js +18 -0
- package/build/cjs/Account/AccountPopoverHeader.js +12 -0
- package/build/cjs/Account/AccountPreview.js +96 -0
- package/build/cjs/Account/AccountPreview.test.js +52 -0
- package/build/cjs/Account/SignInButton.js +56 -0
- package/build/cjs/Account/SignOutButton.js +58 -0
- package/build/cjs/Account/index.js +22 -0
- package/build/cjs/AppProvider/AppProvider.js +40 -0
- package/build/cjs/AppProvider/AppProvider.test.js +18 -0
- package/build/cjs/AppProvider/AppProviderComponent.js +33 -0
- package/build/cjs/AppProvider/AppThemeProvider.js +111 -0
- package/build/cjs/AppProvider/index.js +17 -0
- package/build/cjs/DashboardLayout/DashboardLayout.js +230 -0
- package/build/cjs/DashboardLayout/DashboardLayout.test.js +296 -0
- package/build/cjs/DashboardLayout/DashboardSidebarSubNavigation.js +185 -0
- package/build/cjs/DashboardLayout/ThemeSwitcher.js +84 -0
- package/build/cjs/DashboardLayout/TitleBar.d.ts +2 -0
- package/build/cjs/DashboardLayout/TitleBar.js +57 -0
- package/build/cjs/DashboardLayout/ToolbarActions.js +11 -0
- package/build/cjs/DashboardLayout/index.js +19 -0
- package/build/cjs/DashboardLayout/utils.js +20 -0
- package/build/{PageContainer → cjs/PageContainer}/PageContainer.d.ts +4 -0
- package/build/cjs/PageContainer/PageContainer.js +133 -0
- package/build/cjs/PageContainer/PageContainer.test.js +128 -0
- package/build/cjs/PageContainer/PageContainerToolbar.js +26 -0
- package/build/cjs/PageContainer/PageContainerToolbar.test.js +15 -0
- package/build/cjs/PageContainer/index.js +18 -0
- package/build/cjs/index.js +24 -0
- package/build/cjs/nextjs/AppProvider.js +18 -0
- package/build/cjs/nextjs/AppProvider.test.js +71 -0
- package/build/cjs/nextjs/AppProviderNextApp.js +63 -0
- package/build/cjs/nextjs/AppProviderNextPages.js +73 -0
- package/build/cjs/nextjs/index.js +17 -0
- package/build/cjs/persistence/codec.js +60 -0
- package/build/cjs/persistence/index.js +17 -0
- package/build/cjs/persistence/useStorageState.js +153 -0
- package/build/cjs/persistence/useStorageState.test.js +63 -0
- package/build/cjs/react-router-dom/AppProvider.js +64 -0
- package/build/cjs/react-router-dom/AppProvider.test.js +14 -0
- package/build/cjs/react-router-dom/index.js +17 -0
- package/build/cjs/shared/Link.js +55 -0
- package/build/cjs/shared/components.js +30 -0
- package/build/cjs/shared/context.js +46 -0
- package/build/cjs/shared/locales/LocaleContext.js +71 -0
- package/build/cjs/shared/navigation.js +151 -0
- package/build/cjs/useActivePage/index.js +17 -0
- package/build/cjs/useActivePage/useActivePage.js +83 -0
- package/build/cjs/useLocalStorageState/index.js +17 -0
- package/build/cjs/useLocalStorageState/useLocalStorageState.js +17 -0
- package/build/cjs/useSessionStorageState/index.js +17 -0
- package/build/cjs/useSessionStorageState/useSessionStorageState.js +17 -0
- package/build/cjs/utils/collections.js +53 -0
- package/build/cjs/utils/describeConformance.js +6 -0
- package/build/cjs/utils/events.js +58 -0
- package/build/cjs/utils/hooks/index.js +10 -0
- package/build/cjs/utils/hooks/useBoolean.js +47 -0
- package/build/cjs/utils/hooks/useDebounced.js +64 -0
- package/build/cjs/utils/hooks/useDebouncedHandler.js +77 -0
- package/build/cjs/utils/hooks/useLatest.js +44 -0
- package/build/cjs/utils/hooks/usePageTitle.js +49 -0
- package/build/cjs/utils/hooks/useSsr.js +52 -0
- package/build/cjs/utils/hooks/useStorageState.js +86 -0
- package/build/cjs/utils/warnOnce.js +14 -0
- package/build/mjs/Account/Account.d.ts +63 -0
- package/build/mjs/Account/Account.test.d.ts +1 -0
- package/build/mjs/Account/AccountPopoverFooter.d.ts +6 -0
- package/build/mjs/Account/AccountPopoverHeader.d.ts +6 -0
- package/build/mjs/Account/AccountPreview.d.ts +64 -0
- package/build/mjs/Account/AccountPreview.test.d.ts +1 -0
- package/build/mjs/Account/SignInButton.d.ts +2 -0
- package/build/mjs/Account/SignOutButton.d.ts +3 -0
- package/build/mjs/Account/index.js +6 -0
- package/build/mjs/AppProvider/AppProvider.d.ts +105 -0
- package/build/mjs/AppProvider/AppProvider.test.d.ts +4 -0
- package/build/mjs/AppProvider/AppProviderComponent.d.ts +14 -0
- package/build/mjs/AppProvider/AppThemeProvider.d.ts +12 -0
- package/build/mjs/DashboardLayout/DashboardLayout.d.ts +91 -0
- package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.js +9 -10
- package/build/mjs/DashboardLayout/DashboardLayout.test.d.ts +1 -0
- package/build/mjs/DashboardLayout/DashboardSidebarSubNavigation.d.ts +16 -0
- package/build/mjs/DashboardLayout/ThemeSwitcher.d.ts +5 -0
- package/build/mjs/DashboardLayout/TitleBar.d.ts +2 -0
- package/build/mjs/DashboardLayout/ToolbarActions.d.ts +5 -0
- package/build/mjs/DashboardLayout/index.d.ts +2 -0
- package/build/mjs/DashboardLayout/utils.d.ts +8 -0
- package/build/mjs/PageContainer/PageContainer.d.ts +61 -0
- package/build/{PageContainer → mjs/PageContainer}/PageContainer.js +8 -4
- package/build/mjs/PageContainer/PageContainer.test.d.ts +1 -0
- package/build/mjs/PageContainer/PageContainerToolbar.d.ts +16 -0
- package/build/mjs/PageContainer/PageContainerToolbar.test.d.ts +1 -0
- package/build/mjs/PageContainer/index.js +2 -0
- package/build/mjs/index.js +8 -0
- package/build/mjs/nextjs/AppProvider.d.ts +6 -0
- package/build/mjs/nextjs/AppProvider.test.d.ts +1 -0
- package/build/mjs/nextjs/AppProviderNextApp.d.ts +5 -0
- package/build/mjs/nextjs/AppProviderNextPages.d.ts +5 -0
- package/build/mjs/nextjs/index.js +1 -0
- package/build/mjs/persistence/codec.d.ts +47 -0
- package/build/mjs/persistence/index.js +1 -0
- package/build/mjs/persistence/useStorageState.d.ts +50 -0
- package/build/mjs/persistence/useStorageState.test.d.ts +1 -0
- package/build/mjs/react-router-dom/AppProvider.d.ts +6 -0
- package/build/mjs/react-router-dom/AppProvider.test.d.ts +1 -0
- package/build/mjs/react-router-dom/index.d.ts +1 -0
- package/build/mjs/react-router-dom/index.js +1 -0
- package/build/mjs/shared/Link.d.ts +8 -0
- package/build/mjs/shared/components.d.ts +5 -0
- package/build/mjs/shared/context.d.ts +12 -0
- package/build/mjs/shared/locales/LocaleContext.d.ts +56 -0
- package/build/mjs/shared/navigation.d.ts +16 -0
- package/build/mjs/useActivePage/index.js +1 -0
- package/build/mjs/useActivePage/useActivePage.d.ts +8 -0
- package/build/mjs/useLocalStorageState/index.js +1 -0
- package/build/mjs/useLocalStorageState/useLocalStorageState.d.ts +2 -0
- package/build/mjs/useSessionStorageState/index.js +1 -0
- package/build/mjs/useSessionStorageState/useSessionStorageState.d.ts +2 -0
- package/build/mjs/utils/collections.d.ts +44 -0
- package/build/mjs/utils/describeConformance.d.ts +7 -0
- package/build/mjs/utils/events.d.ts +27 -0
- package/build/mjs/utils/hooks/index.js +2 -0
- package/build/mjs/utils/hooks/useBoolean.d.ts +11 -0
- package/build/mjs/utils/hooks/useDebounced.d.ts +8 -0
- package/build/mjs/utils/hooks/useDebouncedHandler.d.ts +12 -0
- package/build/mjs/utils/hooks/useLatest.d.ts +6 -0
- package/build/mjs/utils/hooks/usePageTitle.d.ts +4 -0
- package/build/mjs/utils/hooks/useSsr.d.ts +4 -0
- package/build/mjs/utils/hooks/useStorageState.d.ts +10 -0
- package/build/mjs/utils/warnOnce.d.ts +5 -0
- package/package.json +33 -23
- package/src/DashboardLayout/DashboardLayout.tsx +13 -12
- package/src/PageContainer/PageContainer.tsx +12 -4
- package/tsconfig.cjs.json +20 -0
- package/tsconfig.json +2 -2
- package/build/DashboardLayout/TitleBar.d.ts +0 -2
- /package/build/{Account → cjs/Account}/Account.d.ts +0 -0
- /package/build/{Account → cjs/Account}/Account.test.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPopoverFooter.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPopoverHeader.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPreview.d.ts +0 -0
- /package/build/{Account → cjs/Account}/AccountPreview.test.d.ts +0 -0
- /package/build/{Account → cjs/Account}/SignInButton.d.ts +0 -0
- /package/build/{Account → cjs/Account}/SignOutButton.d.ts +0 -0
- /package/build/{Account → cjs/Account}/index.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppProvider.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppProvider.test.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppProviderComponent.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/AppThemeProvider.d.ts +0 -0
- /package/build/{AppProvider → cjs/AppProvider}/index.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardLayout.test.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/DashboardSidebarSubNavigation.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/ThemeSwitcher.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/ToolbarActions.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/index.d.ts +0 -0
- /package/build/{DashboardLayout → cjs/DashboardLayout}/utils.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/PageContainer.test.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/PageContainerToolbar.test.d.ts +0 -0
- /package/build/{PageContainer → cjs/PageContainer}/index.d.ts +0 -0
- /package/build/{index.d.ts → cjs/index.d.ts} +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProvider.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProvider.test.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProviderNextApp.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/AppProviderNextPages.d.ts +0 -0
- /package/build/{nextjs → cjs/nextjs}/index.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/codec.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/index.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/useStorageState.d.ts +0 -0
- /package/build/{persistence → cjs/persistence}/useStorageState.test.d.ts +0 -0
- /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.d.ts +0 -0
- /package/build/{react-router-dom → cjs/react-router-dom}/AppProvider.test.d.ts +0 -0
- /package/build/{react-router-dom → cjs/react-router-dom}/index.d.ts +0 -0
- /package/build/{shared → cjs/shared}/Link.d.ts +0 -0
- /package/build/{shared → cjs/shared}/components.d.ts +0 -0
- /package/build/{shared → cjs/shared}/context.d.ts +0 -0
- /package/build/{shared → cjs/shared}/locales/LocaleContext.d.ts +0 -0
- /package/build/{shared → cjs/shared}/navigation.d.ts +0 -0
- /package/build/{useActivePage → cjs/useActivePage}/index.d.ts +0 -0
- /package/build/{useActivePage → cjs/useActivePage}/useActivePage.d.ts +0 -0
- /package/build/{useLocalStorageState → cjs/useLocalStorageState}/index.d.ts +0 -0
- /package/build/{useLocalStorageState → cjs/useLocalStorageState}/useLocalStorageState.d.ts +0 -0
- /package/build/{useSessionStorageState → cjs/useSessionStorageState}/index.d.ts +0 -0
- /package/build/{useSessionStorageState → cjs/useSessionStorageState}/useSessionStorageState.d.ts +0 -0
- /package/build/{utils → cjs/utils}/collections.d.ts +0 -0
- /package/build/{utils → cjs/utils}/describeConformance.d.ts +0 -0
- /package/build/{utils → cjs/utils}/events.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/index.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useBoolean.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useDebounced.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useDebouncedHandler.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useLatest.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/usePageTitle.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useSsr.d.ts +0 -0
- /package/build/{utils → cjs/utils}/hooks/useStorageState.d.ts +0 -0
- /package/build/{utils → cjs/utils}/warnOnce.d.ts +0 -0
- /package/build/{Account → mjs/Account}/Account.js +0 -0
- /package/build/{Account → mjs/Account}/Account.test.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPopoverFooter.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPopoverHeader.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPreview.js +0 -0
- /package/build/{Account → mjs/Account}/AccountPreview.test.js +0 -0
- /package/build/{Account → mjs/Account}/SignInButton.js +0 -0
- /package/build/{Account → mjs/Account}/SignOutButton.js +0 -0
- /package/build/{Account/index.js → mjs/Account/index.d.ts} +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppProvider.js +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppProvider.test.js +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppProviderComponent.js +0 -0
- /package/build/{AppProvider → mjs/AppProvider}/AppThemeProvider.js +0 -0
- /package/build/{AppProvider/index.js → mjs/AppProvider/index.d.ts} +0 -0
- /package/build/{nextjs → mjs/AppProvider}/index.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardLayout.test.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/DashboardSidebarSubNavigation.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/ThemeSwitcher.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/TitleBar.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/ToolbarActions.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/index.js +0 -0
- /package/build/{DashboardLayout → mjs/DashboardLayout}/utils.js +0 -0
- /package/build/{PageContainer → mjs/PageContainer}/PageContainer.test.js +0 -0
- /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.js +0 -0
- /package/build/{PageContainer → mjs/PageContainer}/PageContainerToolbar.test.js +0 -0
- /package/build/{PageContainer/index.js → mjs/PageContainer/index.d.ts} +0 -0
- /package/build/{index.js → mjs/index.d.ts} +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProvider.js +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProvider.test.js +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProviderNextApp.js +0 -0
- /package/build/{nextjs → mjs/nextjs}/AppProviderNextPages.js +0 -0
- /package/build/{react-router-dom/index.js → mjs/nextjs/index.d.ts} +0 -0
- /package/build/{persistence → mjs/persistence}/codec.js +0 -0
- /package/build/{persistence/index.js → mjs/persistence/index.d.ts} +0 -0
- /package/build/{persistence → mjs/persistence}/useStorageState.js +0 -0
- /package/build/{persistence → mjs/persistence}/useStorageState.test.js +0 -0
- /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.js +0 -0
- /package/build/{react-router-dom → mjs/react-router-dom}/AppProvider.test.js +0 -0
- /package/build/{shared → mjs/shared}/Link.js +0 -0
- /package/build/{shared → mjs/shared}/components.js +0 -0
- /package/build/{shared → mjs/shared}/context.js +0 -0
- /package/build/{shared → mjs/shared}/locales/LocaleContext.js +0 -0
- /package/build/{shared → mjs/shared}/navigation.js +0 -0
- /package/build/{useActivePage/index.js → mjs/useActivePage/index.d.ts} +0 -0
- /package/build/{useActivePage → mjs/useActivePage}/useActivePage.js +0 -0
- /package/build/{useLocalStorageState/index.js → mjs/useLocalStorageState/index.d.ts} +0 -0
- /package/build/{useLocalStorageState → mjs/useLocalStorageState}/useLocalStorageState.js +0 -0
- /package/build/{useSessionStorageState/index.js → mjs/useSessionStorageState/index.d.ts} +0 -0
- /package/build/{useSessionStorageState → mjs/useSessionStorageState}/useSessionStorageState.js +0 -0
- /package/build/{utils → mjs/utils}/collections.js +0 -0
- /package/build/{utils → mjs/utils}/describeConformance.js +0 -0
- /package/build/{utils → mjs/utils}/events.js +0 -0
- /package/build/{utils/hooks/index.js → mjs/utils/hooks/index.d.ts} +0 -0
- /package/build/{utils → mjs/utils}/hooks/useBoolean.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useDebounced.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useDebouncedHandler.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useLatest.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/usePageTitle.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useSsr.js +0 -0
- /package/build/{utils → mjs/utils}/hooks/useStorageState.js +0 -0
- /package/build/{utils → mjs/utils}/warnOnce.js +0 -0
- /package/{vite.config.ts → vite.config.mts} +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asArray = asArray;
|
|
4
|
+
exports.hasOwnProperty = hasOwnProperty;
|
|
5
|
+
exports.mapProperties = mapProperties;
|
|
6
|
+
exports.mapKeys = mapKeys;
|
|
7
|
+
exports.mapValues = mapValues;
|
|
8
|
+
exports.filterValues = filterValues;
|
|
9
|
+
exports.filterKeys = filterKeys;
|
|
10
|
+
exports.equalProperties = equalProperties;
|
|
11
|
+
function asArray(maybeArray) {
|
|
12
|
+
return Array.isArray(maybeArray) ? maybeArray : [maybeArray];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Type aware version of Object.protoype.hasOwnProperty.
|
|
16
|
+
* See https://fettblog.eu/typescript-hasownproperty/
|
|
17
|
+
*/
|
|
18
|
+
function hasOwnProperty(obj, prop) {
|
|
19
|
+
return obj.hasOwnProperty(prop);
|
|
20
|
+
}
|
|
21
|
+
function mapProperties(obj, mapper) {
|
|
22
|
+
return Object.fromEntries(Object.entries(obj).flatMap((entry) => {
|
|
23
|
+
const mapped = mapper(entry);
|
|
24
|
+
return mapped ? [mapped] : [];
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Maps an objects' property keys. The result is a new object with the mapped keys, but the same values.
|
|
29
|
+
*/
|
|
30
|
+
function mapKeys(obj, mapper) {
|
|
31
|
+
return mapProperties(obj, ([key, value]) => [mapper(key), value]);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Maps an objects' property values. The result is a new object with the same keys, but mapped values.
|
|
35
|
+
*/
|
|
36
|
+
function mapValues(obj, mapper) {
|
|
37
|
+
return mapProperties(obj, ([key, value]) => [key, mapper(value, key)]);
|
|
38
|
+
}
|
|
39
|
+
function filterValues(obj, filter) {
|
|
40
|
+
return mapProperties(obj, ([key, value]) => filter(value) ? [key, value] : null);
|
|
41
|
+
}
|
|
42
|
+
function filterKeys(obj, filter) {
|
|
43
|
+
return mapProperties(obj, ([key, value]) => filter(key) ? [key, value] : null);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Compares the properties of two objects. Returns `true` if all properties are strictly equal, `false`
|
|
47
|
+
* otherwise.
|
|
48
|
+
* Pass a subset of properties to only compare those.
|
|
49
|
+
*/
|
|
50
|
+
function equalProperties(obj1, obj2, subset) {
|
|
51
|
+
const keysToCheck = new Set(subset ?? [...Object.keys(obj1), ...Object.keys(obj2)]);
|
|
52
|
+
return Array.from(keysToCheck).every((key) => Object.is(obj1[key], obj2[key]));
|
|
53
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Emitter = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Lightweight event emitter
|
|
6
|
+
*/
|
|
7
|
+
class Emitter {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.handlers = new Map();
|
|
10
|
+
}
|
|
11
|
+
on(name, handler) {
|
|
12
|
+
let eventHandlers = this.handlers.get(name);
|
|
13
|
+
if (!eventHandlers) {
|
|
14
|
+
eventHandlers = new Set();
|
|
15
|
+
this.handlers.set(name, eventHandlers);
|
|
16
|
+
}
|
|
17
|
+
eventHandlers.add(handler);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Remove a listener from an event
|
|
21
|
+
*/
|
|
22
|
+
off(name, handler) {
|
|
23
|
+
const eventHandlers = this.handlers.get(name);
|
|
24
|
+
if (eventHandlers) {
|
|
25
|
+
eventHandlers.delete(handler);
|
|
26
|
+
if (eventHandlers.size <= 0) {
|
|
27
|
+
this.handlers.delete(name);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Subscribe to an event and return an unsubscribe function.
|
|
33
|
+
*/
|
|
34
|
+
subscribe(name, handler) {
|
|
35
|
+
this.on(name, handler);
|
|
36
|
+
return () => {
|
|
37
|
+
this.off(name, handler);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Emit an event.
|
|
42
|
+
*/
|
|
43
|
+
emit(name, event) {
|
|
44
|
+
const eventHandlers = this.handlers.get(name);
|
|
45
|
+
if (eventHandlers) {
|
|
46
|
+
for (const eventHandler of eventHandlers) {
|
|
47
|
+
eventHandler(event);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const allHandlers = this.handlers.get("*");
|
|
51
|
+
if (allHandlers) {
|
|
52
|
+
for (const eventHandler of allHandlers) {
|
|
53
|
+
eventHandler(name, event);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Emitter = Emitter;
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
+
exports.usePageTitle = exports.useBoolean = void 0;
|
|
7
|
+
var useBoolean_1 = require("./useBoolean");
|
|
8
|
+
Object.defineProperty(exports, "useBoolean", { enumerable: true, get: function () { return __importDefault(useBoolean_1).default; } });
|
|
9
|
+
var usePageTitle_1 = require("./usePageTitle");
|
|
10
|
+
Object.defineProperty(exports, "usePageTitle", { enumerable: true, get: function () { return __importDefault(usePageTitle_1).default; } });
|
|
@@ -0,0 +1,47 @@
|
|
|
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.default = useBoolean;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
/**
|
|
39
|
+
* A utility with shortcuts to manipulate boolean values.
|
|
40
|
+
*/
|
|
41
|
+
function useBoolean(initialValue) {
|
|
42
|
+
const [value, setValue] = React.useState(initialValue);
|
|
43
|
+
const toggle = React.useCallback(() => setValue((existing) => !existing), []);
|
|
44
|
+
const setTrue = React.useCallback(() => setValue(true), []);
|
|
45
|
+
const setFalse = React.useCallback(() => setValue(false), []);
|
|
46
|
+
return { value, setValue, toggle, setTrue, setFalse };
|
|
47
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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.default = useDebounced;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
/**
|
|
39
|
+
* This hook allows you to debounce any fast changing value. The debounced value will only
|
|
40
|
+
* reflect the latest value when the useDebounce hook has not been called for the specified
|
|
41
|
+
* time period.
|
|
42
|
+
*
|
|
43
|
+
* Inspired by https://usehooks.com/useDebounce/
|
|
44
|
+
*/
|
|
45
|
+
function useDebounced(value, delay) {
|
|
46
|
+
const [debouncedValue, setDebouncedValue] = React.useState(() => value);
|
|
47
|
+
const timeoutIdRef = React.useRef(null);
|
|
48
|
+
React.useEffect(() => () => {
|
|
49
|
+
if (timeoutIdRef.current) {
|
|
50
|
+
clearTimeout(timeoutIdRef.current);
|
|
51
|
+
timeoutIdRef.current = null;
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
timeoutIdRef.current = setTimeout(() => setDebouncedValue(() => value), delay);
|
|
56
|
+
return () => {
|
|
57
|
+
if (timeoutIdRef.current) {
|
|
58
|
+
clearTimeout(timeoutIdRef.current);
|
|
59
|
+
timeoutIdRef.current = null;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, [value, delay]);
|
|
63
|
+
return debouncedValue;
|
|
64
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.default = useDebouncedHandler;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
function defer(fn, params, delay) {
|
|
39
|
+
const timeout = setTimeout(() => {
|
|
40
|
+
fn.current(...params);
|
|
41
|
+
}, delay);
|
|
42
|
+
return { startTime: Date.now(), timeout, params };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a debounced version of the handler that is passed. The invocation of [fn] is
|
|
46
|
+
* delayed for [delay] milliseconds from the last invocation of the debounced function.
|
|
47
|
+
*
|
|
48
|
+
* This implementation adds on the lodash implementation in that it handles updates to the
|
|
49
|
+
* delay value.
|
|
50
|
+
*/
|
|
51
|
+
function useDebouncedHandler(fn, delay) {
|
|
52
|
+
const fnRef = React.useRef(fn);
|
|
53
|
+
React.useEffect(() => {
|
|
54
|
+
fnRef.current = fn;
|
|
55
|
+
}, [fn]);
|
|
56
|
+
const delayedInvocation = React.useRef(null);
|
|
57
|
+
const clearCurrent = React.useCallback(() => {
|
|
58
|
+
if (delayedInvocation.current) {
|
|
59
|
+
clearTimeout(delayedInvocation.current.timeout);
|
|
60
|
+
delayedInvocation.current = null;
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
React.useEffect(() => {
|
|
64
|
+
if (!delayedInvocation.current) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const { startTime, params } = delayedInvocation.current;
|
|
68
|
+
const elapsed = Date.now() - startTime;
|
|
69
|
+
const newDelay = Math.max(delay - elapsed, 0);
|
|
70
|
+
clearCurrent();
|
|
71
|
+
delayedInvocation.current = defer(fnRef, params, newDelay);
|
|
72
|
+
}, [delay, clearCurrent]);
|
|
73
|
+
return React.useCallback((...params) => {
|
|
74
|
+
clearCurrent();
|
|
75
|
+
delayedInvocation.current = defer(fnRef, params, delay);
|
|
76
|
+
}, [delay, clearCurrent]);
|
|
77
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 React = __importStar(require("react"));
|
|
37
|
+
function useLatest(value) {
|
|
38
|
+
const [latest, setLatest] = React.useState(value);
|
|
39
|
+
if (latest !== value && value !== null && value !== undefined) {
|
|
40
|
+
setLatest(value);
|
|
41
|
+
}
|
|
42
|
+
return value ?? latest;
|
|
43
|
+
}
|
|
44
|
+
exports.default = useLatest;
|
|
@@ -0,0 +1,49 @@
|
|
|
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.default = usePageTitle;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
/**
|
|
39
|
+
* Sets the current document title.
|
|
40
|
+
*/
|
|
41
|
+
function usePageTitle(title) {
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
const original = document.title;
|
|
44
|
+
document.title = title;
|
|
45
|
+
return () => {
|
|
46
|
+
document.title = original;
|
|
47
|
+
};
|
|
48
|
+
}, [title]);
|
|
49
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.default = useSsr;
|
|
37
|
+
const React = __importStar(require("react"));
|
|
38
|
+
function subscribe() {
|
|
39
|
+
return () => { };
|
|
40
|
+
}
|
|
41
|
+
function getSnapshot() {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function getServerSnapshot() {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns true when serverside rendering, or when hydrating.
|
|
49
|
+
*/
|
|
50
|
+
function useSsr() {
|
|
51
|
+
return React.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
52
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 React = __importStar(require("react"));
|
|
37
|
+
const events_1 = require("../events");
|
|
38
|
+
// storage events only work across windows, we'll use an event emitter to announce within the window
|
|
39
|
+
const emitter = new events_1.Emitter();
|
|
40
|
+
function subscribe(area, key, cb) {
|
|
41
|
+
const storageHandler = (event) => {
|
|
42
|
+
if (event.storageArea === area && event.key === key) {
|
|
43
|
+
cb();
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
window.addEventListener("storage", storageHandler);
|
|
47
|
+
emitter.on(key, cb);
|
|
48
|
+
return () => {
|
|
49
|
+
window.removeEventListener("storage", storageHandler);
|
|
50
|
+
emitter.off(key, cb);
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function getSnapshot(area, key) {
|
|
54
|
+
return area.getItem(key);
|
|
55
|
+
}
|
|
56
|
+
function setValue(area, key, value) {
|
|
57
|
+
if (typeof window !== "undefined") {
|
|
58
|
+
if (value === null) {
|
|
59
|
+
area.removeItem(key);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
area.setItem(key, String(value));
|
|
63
|
+
}
|
|
64
|
+
emitter.emit(key, null);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function useStorageStateServer(kind, key, initializer = null) {
|
|
68
|
+
const [initialValue] = React.useState(initializer);
|
|
69
|
+
return [initialValue, () => { }];
|
|
70
|
+
}
|
|
71
|
+
function useStorageStateBrowser(kind, key, initializer = null) {
|
|
72
|
+
const [initialValue] = React.useState(initializer);
|
|
73
|
+
const area = kind === "session" ? window.sessionStorage : window.localStorage;
|
|
74
|
+
const subscribeKey = React.useCallback((cb) => subscribe(area, key, cb), [area, key]);
|
|
75
|
+
const getKeySnapshot = React.useCallback(() => getSnapshot(area, key) ?? initialValue, [area, initialValue, key]);
|
|
76
|
+
const getKeyServerSnapshot = React.useCallback(() => initialValue, [initialValue]);
|
|
77
|
+
const storedValue = React.useSyncExternalStore(subscribeKey, getKeySnapshot, getKeyServerSnapshot);
|
|
78
|
+
const setStoredValue = React.useCallback((value) => {
|
|
79
|
+
const valueToStore = value instanceof Function ? value(storedValue) : value;
|
|
80
|
+
setValue(area, key, valueToStore);
|
|
81
|
+
}, [area, key, storedValue]);
|
|
82
|
+
return [storedValue, setStoredValue];
|
|
83
|
+
}
|
|
84
|
+
exports.default = typeof window === "undefined"
|
|
85
|
+
? useStorageStateServer
|
|
86
|
+
: useStorageStateBrowser;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = warnOnce;
|
|
4
|
+
const history = new Set();
|
|
5
|
+
/**
|
|
6
|
+
* Warns only once for a specific message.
|
|
7
|
+
* @param msg The message to warn.
|
|
8
|
+
*/
|
|
9
|
+
function warnOnce(msg) {
|
|
10
|
+
if (!history.has(msg)) {
|
|
11
|
+
history.add(msg);
|
|
12
|
+
console.warn(msg);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Button from "@mui/material/Button";
|
|
3
|
+
import Popover from "@mui/material/Popover";
|
|
4
|
+
import Stack from "@mui/material/Stack";
|
|
5
|
+
import { SignInButton } from "./SignInButton";
|
|
6
|
+
import { AccountPreviewProps } from "./AccountPreview";
|
|
7
|
+
export interface AccountSlots {
|
|
8
|
+
/**
|
|
9
|
+
* The component used for the account preview
|
|
10
|
+
* @default AccountPreview
|
|
11
|
+
*/
|
|
12
|
+
preview?: React.ElementType;
|
|
13
|
+
/**
|
|
14
|
+
* The component used for the account popover menu
|
|
15
|
+
* @default Popover
|
|
16
|
+
*/
|
|
17
|
+
popover?: React.ElementType;
|
|
18
|
+
/**
|
|
19
|
+
* The component used for the content of account popover
|
|
20
|
+
* @default Stack
|
|
21
|
+
*/
|
|
22
|
+
popoverContent?: React.ElementType;
|
|
23
|
+
/**
|
|
24
|
+
* The component used for the sign in button.
|
|
25
|
+
* @default Button
|
|
26
|
+
*/
|
|
27
|
+
signInButton?: React.ElementType;
|
|
28
|
+
/**
|
|
29
|
+
* The component used for the sign out button.
|
|
30
|
+
* @default Button
|
|
31
|
+
*/
|
|
32
|
+
signOutButton?: React.ElementType;
|
|
33
|
+
}
|
|
34
|
+
export interface AccountProps {
|
|
35
|
+
/**
|
|
36
|
+
* The components used for each slot inside.
|
|
37
|
+
*/
|
|
38
|
+
slots?: AccountSlots;
|
|
39
|
+
/**
|
|
40
|
+
* The props used for each slot inside.
|
|
41
|
+
*/
|
|
42
|
+
slotProps?: {
|
|
43
|
+
preview?: AccountPreviewProps;
|
|
44
|
+
popover?: React.ComponentProps<typeof Popover>;
|
|
45
|
+
popoverContent?: React.ComponentProps<typeof Stack>;
|
|
46
|
+
signInButton?: React.ComponentProps<typeof SignInButton>;
|
|
47
|
+
signOutButton?: React.ComponentProps<typeof Button>;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* Demos:
|
|
53
|
+
*
|
|
54
|
+
* - [Account](https://mui.com/toolpad/core/react-account/)
|
|
55
|
+
* - [Dashboard Layout](https://mui.com/toolpad/core/react-dashboard-layout/)
|
|
56
|
+
* - [Sign-in Page](https://mui.com/toolpad/core/react-sign-in-page/)
|
|
57
|
+
*
|
|
58
|
+
* API:
|
|
59
|
+
*
|
|
60
|
+
* - [Account API](https://mui.com/toolpad/core/api/account)
|
|
61
|
+
*/
|
|
62
|
+
declare function Account(props: AccountProps): import("react/jsx-runtime").JSX.Element | null;
|
|
63
|
+
export { Account };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { BoxProps } from "@mui/material/Box";
|
|
3
|
+
export interface AccountPopoverFooterProps extends BoxProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function AccountPopoverFooter(props: AccountPopoverFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StackProps } from "@mui/material/Stack";
|
|
3
|
+
export interface AccountPopoverHeaderProps extends StackProps {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function AccountPopoverHeader(props: AccountPopoverHeaderProps): import("react/jsx-runtime").JSX.Element;
|