@etsoo/toolpad 1.0.48 → 1.0.50

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 (76) hide show
  1. package/build/cjs/Account/Account.d.ts +1 -1
  2. package/build/cjs/Account/AccountPopoverFooter.d.ts +1 -1
  3. package/build/cjs/Account/AccountPopoverHeader.d.ts +1 -1
  4. package/build/cjs/Account/AccountPreview.d.ts +1 -1
  5. package/build/cjs/Account/SignInButton.d.ts +2 -1
  6. package/build/cjs/Account/SignOutButton.d.ts +2 -1
  7. package/build/cjs/AppProvider/AppProviderComponent.d.ts +1 -1
  8. package/build/cjs/AppProvider/AppThemeProvider.d.ts +1 -1
  9. package/build/cjs/DashboardLayout/DashboardLayout.d.ts +1 -1
  10. package/build/cjs/DashboardLayout/DashboardSidebarSubNavigation.d.ts +2 -1
  11. package/build/cjs/DashboardLayout/ThemeSwitcher.d.ts +2 -1
  12. package/build/cjs/DashboardLayout/TitleBar.d.ts +1 -1
  13. package/build/cjs/PageContainer/PageContainer.d.ts +2 -2
  14. package/build/cjs/PageContainer/PageContainerToolbar.d.ts +1 -1
  15. package/build/cjs/react-router-dom/AppProvider.d.ts +2 -1
  16. package/build/cjs/shared/components.d.ts +2 -2
  17. package/build/cjs/shared/locales/LocaleContext.d.ts +1 -1
  18. package/build/mjs/Account/Account.d.ts +1 -1
  19. package/build/mjs/Account/AccountPopoverFooter.d.ts +1 -1
  20. package/build/mjs/Account/AccountPopoverHeader.d.ts +1 -1
  21. package/build/mjs/Account/AccountPreview.d.ts +1 -1
  22. package/build/mjs/Account/SignInButton.d.ts +2 -1
  23. package/build/mjs/Account/SignOutButton.d.ts +2 -1
  24. package/build/mjs/AppProvider/AppProviderComponent.d.ts +1 -1
  25. package/build/mjs/AppProvider/AppThemeProvider.d.ts +1 -1
  26. package/build/mjs/DashboardLayout/DashboardLayout.d.ts +1 -1
  27. package/build/mjs/DashboardLayout/DashboardSidebarSubNavigation.d.ts +2 -1
  28. package/build/mjs/DashboardLayout/ThemeSwitcher.d.ts +2 -1
  29. package/build/mjs/DashboardLayout/TitleBar.d.ts +1 -1
  30. package/build/mjs/PageContainer/PageContainer.d.ts +2 -2
  31. package/build/mjs/PageContainer/PageContainerToolbar.d.ts +1 -1
  32. package/build/mjs/react-router-dom/AppProvider.d.ts +2 -1
  33. package/build/mjs/shared/components.d.ts +2 -2
  34. package/build/mjs/shared/locales/LocaleContext.d.ts +1 -1
  35. package/package.json +19 -29
  36. package/vite.config.mts +15 -0
  37. package/build/cjs/nextjs/AppProvider.d.ts +0 -6
  38. package/build/cjs/nextjs/AppProvider.js +0 -18
  39. package/build/cjs/nextjs/AppProvider.test.d.ts +0 -1
  40. package/build/cjs/nextjs/AppProvider.test.js +0 -71
  41. package/build/cjs/nextjs/AppProviderNextApp.d.ts +0 -5
  42. package/build/cjs/nextjs/AppProviderNextApp.js +0 -63
  43. package/build/cjs/nextjs/AppProviderNextPages.d.ts +0 -5
  44. package/build/cjs/nextjs/AppProviderNextPages.js +0 -73
  45. package/build/cjs/nextjs/index.d.ts +0 -1
  46. package/build/cjs/nextjs/index.js +0 -17
  47. package/build/cjs/utils/hooks/useDebounced.d.ts +0 -8
  48. package/build/cjs/utils/hooks/useDebounced.js +0 -64
  49. package/build/cjs/utils/hooks/useDebouncedHandler.d.ts +0 -12
  50. package/build/cjs/utils/hooks/useDebouncedHandler.js +0 -77
  51. package/build/cjs/utils/hooks/useLatest.d.ts +0 -6
  52. package/build/cjs/utils/hooks/useLatest.js +0 -44
  53. package/build/mjs/nextjs/AppProvider.d.ts +0 -6
  54. package/build/mjs/nextjs/AppProvider.js +0 -16
  55. package/build/mjs/nextjs/AppProvider.test.d.ts +0 -1
  56. package/build/mjs/nextjs/AppProvider.test.js +0 -36
  57. package/build/mjs/nextjs/AppProviderNextApp.d.ts +0 -5
  58. package/build/mjs/nextjs/AppProviderNextApp.js +0 -27
  59. package/build/mjs/nextjs/AppProviderNextPages.d.ts +0 -5
  60. package/build/mjs/nextjs/AppProviderNextPages.js +0 -37
  61. package/build/mjs/nextjs/index.d.ts +0 -1
  62. package/build/mjs/nextjs/index.js +0 -1
  63. package/build/mjs/utils/hooks/useDebounced.d.ts +0 -8
  64. package/build/mjs/utils/hooks/useDebounced.js +0 -28
  65. package/build/mjs/utils/hooks/useDebouncedHandler.d.ts +0 -12
  66. package/build/mjs/utils/hooks/useDebouncedHandler.js +0 -41
  67. package/build/mjs/utils/hooks/useLatest.d.ts +0 -6
  68. package/build/mjs/utils/hooks/useLatest.js +0 -9
  69. package/src/nextjs/AppProvider.test.tsx +0 -48
  70. package/src/nextjs/AppProvider.tsx +0 -18
  71. package/src/nextjs/AppProviderNextApp.tsx +0 -37
  72. package/src/nextjs/AppProviderNextPages.tsx +0 -52
  73. package/src/nextjs/index.tsx +0 -1
  74. package/src/utils/hooks/useDebounced.ts +0 -39
  75. package/src/utils/hooks/useDebouncedHandler.ts +0 -71
  76. package/src/utils/hooks/useLatest.ts +0 -16
@@ -1,37 +0,0 @@
1
- import * as React from "react";
2
- import { usePathname, useSearchParams, useRouter } from "next/navigation";
3
- import type { AppProviderProps, Navigate, Router } from "../AppProvider";
4
- import { AppProvider } from "../AppProvider/AppProviderComponent";
5
-
6
- /**
7
- * @ignore - internal component.
8
- */
9
- export function AppProviderNextApp(props: AppProviderProps) {
10
- const pathname = usePathname();
11
- const searchParams = useSearchParams();
12
- const { push, replace } = useRouter();
13
-
14
- const navigate = React.useCallback<Navigate>(
15
- (url, { history = "auto" } = {}) => {
16
- if (history === "auto" || history === "push") {
17
- return push(String(url));
18
- }
19
- if (history === "replace") {
20
- return replace(String(url));
21
- }
22
- throw new Error(`Invalid history option: ${history}`);
23
- },
24
- [push, replace]
25
- );
26
-
27
- const routerImpl = React.useMemo<Router>(
28
- () => ({
29
- pathname,
30
- searchParams,
31
- navigate
32
- }),
33
- [pathname, navigate, searchParams]
34
- );
35
-
36
- return <AppProvider router={routerImpl} {...props} />;
37
- }
@@ -1,52 +0,0 @@
1
- import * as React from "react";
2
- import { useRouter } from "next/router";
3
- import type { AppProviderProps, Navigate, Router } from "../AppProvider";
4
- import { asArray } from "../utils/collections";
5
- import { AppProvider } from "../AppProvider/AppProviderComponent";
6
-
7
- /**
8
- * @ignore - internal component.
9
- */
10
- export function AppProviderNextPages(props: AppProviderProps) {
11
- const { push, replace, asPath, query } = useRouter();
12
-
13
- const search = React.useMemo(() => {
14
- const params = new URLSearchParams();
15
- Object.entries(query ?? {}).forEach(([key, value]) => {
16
- asArray(value ?? []).forEach((v) => {
17
- params.append(key, v.toString());
18
- });
19
- });
20
- return params.toString();
21
- }, [query]);
22
-
23
- // Stable search params object
24
- const searchParams = React.useMemo(
25
- () => new URLSearchParams(search),
26
- [search]
27
- );
28
-
29
- const navigate = React.useCallback<Navigate>(
30
- (url, { history = "auto" } = {}) => {
31
- if (history === "auto" || history === "push") {
32
- return push(String(url));
33
- }
34
- if (history === "replace") {
35
- return replace(String(url));
36
- }
37
- throw new Error(`Invalid history option: ${history}`);
38
- },
39
- [push, replace]
40
- );
41
-
42
- const routerImpl = React.useMemo<Router>(
43
- () => ({
44
- pathname: asPath,
45
- searchParams,
46
- navigate
47
- }),
48
- [asPath, navigate, searchParams]
49
- );
50
-
51
- return <AppProvider router={routerImpl} {...props} />;
52
- }
@@ -1 +0,0 @@
1
- export * from "./AppProvider";
@@ -1,39 +0,0 @@
1
- import * as React from "react";
2
-
3
- /**
4
- * This hook allows you to debounce any fast changing value. The debounced value will only
5
- * reflect the latest value when the useDebounce hook has not been called for the specified
6
- * time period.
7
- *
8
- * Inspired by https://usehooks.com/useDebounce/
9
- */
10
- export default function useDebounced<T>(value: T, delay: number): T {
11
- const [debouncedValue, setDebouncedValue] = React.useState(() => value);
12
- const timeoutIdRef = React.useRef<NodeJS.Timeout | null>(null);
13
-
14
- React.useEffect(
15
- () => () => {
16
- if (timeoutIdRef.current) {
17
- clearTimeout(timeoutIdRef.current);
18
- timeoutIdRef.current = null;
19
- }
20
- },
21
- []
22
- );
23
-
24
- React.useEffect(() => {
25
- timeoutIdRef.current = setTimeout(
26
- () => setDebouncedValue(() => value),
27
- delay
28
- );
29
-
30
- return () => {
31
- if (timeoutIdRef.current) {
32
- clearTimeout(timeoutIdRef.current);
33
- timeoutIdRef.current = null;
34
- }
35
- };
36
- }, [value, delay]);
37
-
38
- return debouncedValue;
39
- }
@@ -1,71 +0,0 @@
1
- import * as React from "react";
2
-
3
- interface Handler<P extends unknown[]> {
4
- (...params: P): void;
5
- }
6
-
7
- interface DelayedInvocation<P extends unknown[]> {
8
- startTime: number;
9
- timeout: NodeJS.Timeout;
10
- params: P;
11
- }
12
-
13
- function defer<P extends unknown[]>(
14
- fn: React.MutableRefObject<Handler<P>>,
15
- params: P,
16
- delay: number
17
- ) {
18
- const timeout = setTimeout(() => {
19
- fn.current(...params);
20
- }, delay);
21
-
22
- return { startTime: Date.now(), timeout, params };
23
- }
24
-
25
- /**
26
- * Creates a debounced version of the handler that is passed. The invocation of [fn] is
27
- * delayed for [delay] milliseconds from the last invocation of the debounced function.
28
- *
29
- * This implementation adds on the lodash implementation in that it handles updates to the
30
- * delay value.
31
- */
32
- export default function useDebouncedHandler<P extends unknown[]>(
33
- fn: Handler<P>,
34
- delay: number
35
- ): Handler<P> {
36
- const fnRef = React.useRef(fn);
37
- React.useEffect(() => {
38
- fnRef.current = fn;
39
- }, [fn]);
40
-
41
- const delayedInvocation = React.useRef<DelayedInvocation<P> | null>(null);
42
-
43
- const clearCurrent = React.useCallback(() => {
44
- if (delayedInvocation.current) {
45
- clearTimeout(delayedInvocation.current.timeout);
46
- delayedInvocation.current = null;
47
- }
48
- }, []);
49
-
50
- React.useEffect(() => {
51
- if (!delayedInvocation.current) {
52
- return;
53
- }
54
-
55
- const { startTime, params } = delayedInvocation.current;
56
-
57
- const elapsed = Date.now() - startTime;
58
- const newDelay = Math.max(delay - elapsed, 0);
59
-
60
- clearCurrent();
61
- delayedInvocation.current = defer(fnRef, params, newDelay);
62
- }, [delay, clearCurrent]);
63
-
64
- return React.useCallback(
65
- (...params: P) => {
66
- clearCurrent();
67
- delayedInvocation.current = defer(fnRef, params, delay);
68
- },
69
- [delay, clearCurrent]
70
- );
71
- }
@@ -1,16 +0,0 @@
1
- import * as React from "react";
2
-
3
- /**
4
- * Returns the latest non-null, non-undefined value that has been passed to it.
5
- */
6
- function useLatest<T>(value: T): T;
7
- function useLatest<T>(value: T | null | undefined): T | null | undefined;
8
- function useLatest<T>(value: T | null | undefined): T | null | undefined {
9
- const [latest, setLatest] = React.useState<T | null | undefined>(value);
10
- if (latest !== value && value !== null && value !== undefined) {
11
- setLatest(value);
12
- }
13
- return value ?? latest;
14
- }
15
-
16
- export default useLatest;