@memobit/libs 3.11.2 → 3.12.0

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 (38) hide show
  1. package/dist/components/Confetti/Confetti2.js +33 -33
  2. package/dist/components/ContextToast/ContextToast2.js +53 -57
  3. package/dist/components/ContextToast/useToast.js +12 -0
  4. package/dist/components/ControlPanel/ControlPanel2.js +41 -43
  5. package/dist/components/ControlPanel/ControlPanelContext.js +16 -21
  6. package/dist/components/ControlPanel/useControlPanel.js +11 -0
  7. package/dist/components/DataView/DataView.CardView.js +83 -109
  8. package/dist/components/DataView/DataView.MiniSort.js +1 -1
  9. package/dist/components/DataView/DataView.helpers.js +34 -0
  10. package/dist/components/DataView/DataView2.js +111 -108
  11. package/dist/components/Dropdown/Dropdown2.js +108 -106
  12. package/dist/components/InputEmail/InputEmail2.js +43 -43
  13. package/dist/components/InputEmail/validateEmail.js +7 -0
  14. package/dist/components/InputMask/InputMask2.js +40 -54
  15. package/dist/components/InputMask/InputMaskPresets.js +18 -0
  16. package/dist/components/Pagination/Pagination2.js +4 -4
  17. package/dist/components/QuickOptionUpdate/QuickOptionUpdate2.js +29 -28
  18. package/dist/components/Sidebar/Sidebar2.js +1 -1
  19. package/dist/components/Sidebar/SidebarContext.js +18 -23
  20. package/dist/components/Sidebar/useSidebar.js +11 -0
  21. package/dist/components/SuggestionsList/SuggestionsList2.js +27 -27
  22. package/dist/components/TimelineMarkers/TimelineMarkers2.js +31 -49
  23. package/dist/components/TimelineMarkers/calculateTimelineMarkers.js +28 -0
  24. package/dist/components/Toolbar/Toolbar2.js +6 -6
  25. package/dist/components/Tooltip/Tooltip2.js +35 -35
  26. package/dist/contexts/AuthContext/AuthContext.context.js +5 -0
  27. package/dist/contexts/AuthContext/AuthContext.js +59 -63
  28. package/dist/helpers/AppPersistenceStorage.js +25 -15
  29. package/dist/helpers/Http.js +76 -48
  30. package/dist/helpers/VersionInfo.js +1 -1
  31. package/dist/hooks/useAppPersistence.js +20 -20
  32. package/dist/hooks/useAuth/useAuth.js +1 -1
  33. package/dist/http.d.ts +4 -0
  34. package/dist/index.d.ts +13 -1
  35. package/dist/index.js +270 -262
  36. package/dist/version.js +2 -2
  37. package/dist/version.json +4 -4
  38. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- import { AppPersistenceStorage as o } from "../helpers/AppPersistenceStorage.js";
2
- import { useCallback as a, useState as A } from "react";
1
+ import { AppPersistenceStorage as r } from "../helpers/AppPersistenceStorage.js";
2
+ import { useCallback as c, useState as u } from "react";
3
3
  function S(e, g) {
4
- const c = {
4
+ const [o] = u(() => ({
5
5
  pages: g.pages ?? {},
6
6
  theme: g.theme
7
- }, [l, r] = A(() => o.load(e, c)), u = a((s, n) => {
8
- r((t) => {
7
+ })), [l, a] = u(() => r.load(e, o)), h = c((s, n) => {
8
+ a((t) => {
9
9
  const m = {
10
10
  ...t,
11
11
  pages: {
@@ -13,37 +13,37 @@ function S(e, g) {
13
13
  [s]: n
14
14
  }
15
15
  };
16
- return o.save(e, m), m;
16
+ return r.save(e, m), m;
17
17
  });
18
- }, [e]), h = a((s) => {
19
- r((n) => {
18
+ }, [e]), i = c((s) => {
19
+ a((n) => {
20
20
  const t = {
21
21
  ...n,
22
22
  theme: s
23
23
  };
24
- return o.save(e, t), t;
24
+ return r.save(e, t), t;
25
25
  });
26
- }, [e]), i = a((s) => {
27
- r((n) => {
26
+ }, [e]), x = c((s) => {
27
+ a((n) => {
28
28
  const t = {
29
29
  ...n,
30
30
  pages: {
31
31
  ...n.pages,
32
- [s]: c.pages[s]
32
+ [s]: o.pages[s]
33
33
  }
34
34
  };
35
- return o.save(e, t), t;
35
+ return r.save(e, t), t;
36
36
  });
37
- }, [e]), x = a(() => {
38
- r(c), o.clearAll(e);
39
- }, [e]);
37
+ }, [e, o]), A = c(() => {
38
+ a(o), r.clearAll(e);
39
+ }, [e, o]);
40
40
  return {
41
41
  pages: l.pages,
42
42
  theme: l.theme,
43
- setPage: u,
44
- setTheme: h,
45
- clearPage: i,
46
- clearAll: x
43
+ setPage: h,
44
+ setTheme: i,
45
+ clearPage: x,
46
+ clearAll: A
47
47
  };
48
48
  }
49
49
  export {
@@ -1,4 +1,4 @@
1
- import { AuthContext as r } from "../../contexts/AuthContext/AuthContext.js";
1
+ import { AuthContext as r } from "../../contexts/AuthContext/AuthContext.context.js";
2
2
  import { useContext as o } from "react";
3
3
  var n = () => {
4
4
  const t = o(r);
package/dist/http.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare interface ApiClientConfig {
12
12
  loginPath?: string;
13
13
  }
14
14
 
15
+ /** A failed API request. `status` is the HTTP status, or 0 when the server could not be reached. */
15
16
  export declare class ApiError extends Error {
16
17
  readonly status: number;
17
18
  constructor(message: string, status: number);
@@ -24,6 +25,9 @@ export declare const buildRequestHeaders: (method: HttpMethod, json?: boolean) =
24
25
  * header on mutating requests, surfaces the server's `error` message, and on 401 navigates
25
26
  * to the login page. The 401 path returns a promise that never settles so callers don't
26
27
  * flash an error toast while the browser is already leaving the page.
28
+ *
29
+ * It reports unreachable-server, gateway and invalid-JSON failures to the hub, so callers
30
+ * only show a toast for API errors and don't log them again.
27
31
  */
28
32
  export declare const createApiClient: ({ baseUrl, loginPath }: ApiClientConfig) => ApiClient;
29
33
 
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import { Context } from 'react';
4
4
  import { CSSProperties } from 'react';
5
5
  import { default as default_2 } from 'react';
6
6
  import { ErrorInfo } from 'react';
7
+ import { ErrorReportContext } from '@memobit/core';
7
8
  import { FC } from 'react';
8
9
  import { FocusEvent as FocusEvent_2 } from 'react';
9
10
  import { ForwardRefExoticComponent } from 'react';
@@ -125,6 +126,7 @@ export declare interface ApiClientConfig {
125
126
  loginPath?: string;
126
127
  }
127
128
 
129
+ /** A failed API request. `status` is the HTTP status, or 0 when the server could not be reached. */
128
130
  export declare class ApiError extends Error {
129
131
  readonly status: number;
130
132
  constructor(message: string, status: number);
@@ -176,7 +178,7 @@ export declare interface AuthConfig {
176
178
  appName?: string;
177
179
  }
178
180
 
179
- export declare const AuthContext: default_2.Context<AuthContextValue | undefined>;
181
+ export declare const AuthContext: Context<AuthContextValue | undefined>;
180
182
 
181
183
  export declare interface AuthContextValue {
182
184
  user: User | null;
@@ -1027,6 +1029,9 @@ declare interface CountryWithFlagProps {
1027
1029
  * header on mutating requests, surfaces the server's `error` message, and on 401 navigates
1028
1030
  * to the login page. The 401 path returns a promise that never settles so callers don't
1029
1031
  * flash an error toast while the browser is already leaving the page.
1032
+ *
1033
+ * It reports unreachable-server, gateway and invalid-JSON failures to the hub, so callers
1034
+ * only show a toast for API errors and don't log them again.
1030
1035
  */
1031
1036
  export declare const createApiClient: ({ baseUrl, loginPath }: ApiClientConfig) => ApiClient;
1032
1037
 
@@ -2387,6 +2392,13 @@ export declare interface LoginResponse {
2387
2392
  method?: MfaMethod;
2388
2393
  }
2389
2394
 
2395
+ /**
2396
+ * For the catch around an API call: reports `error` unless it is an `ApiError` (the client and
2397
+ * the backend already report those that matter) or an aborted request. What is left is a bug in
2398
+ * the code around the call, e.g. mapping the response.
2399
+ */
2400
+ export declare const logUnexpectedError: (message: string, error: unknown, context?: ErrorReportContext) => void;
2401
+
2390
2402
  export declare const matchStringsByLogicalOperator: (searchItems: string[], targetString: string, operator: LogicalOperator) => boolean;
2391
2403
 
2392
2404
  export declare const MenuHamburger: FC<MenuHamburgerProps>;