@12-apps/ui 6.71.0 → 6.72.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.
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CardActionsProvider,
4
4
  useCardActions
5
- } from "../../../../chunk-N7KWWIF7.js";
5
+ } from "../../../../chunk-LY7PBZ3Z.js";
6
6
  import "../../../../chunk-NUGT7LMR.js";
7
7
  import "../../../../chunk-DQJFCVXW.js";
8
8
  import "../../../../chunk-JYAXTRNH.js";
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import {
3
3
  useRemoveConfirm
4
- } from "../../../../chunk-62BY4ZUQ.js";
5
- import "../../../../chunk-N7KWWIF7.js";
4
+ } from "../../../../chunk-7KAZ3B5B.js";
5
+ import "../../../../chunk-LY7PBZ3Z.js";
6
6
  import "../../../../chunk-XCBQXSTR.js";
7
7
  import "../../../../chunk-NJMAFII4.js";
8
8
  import "../../../../chunk-GICG3XJK.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCardActions
3
- } from "./chunk-N7KWWIF7.js";
3
+ } from "./chunk-LY7PBZ3Z.js";
4
4
  import {
5
5
  useConfirmAction
6
6
  } from "./chunk-EMYESBIT.js";
@@ -50,4 +50,4 @@ function useRemoveConfirm({
50
50
  export {
51
51
  useRemoveConfirm
52
52
  };
53
- //# sourceMappingURL=chunk-62BY4ZUQ.js.map
53
+ //# sourceMappingURL=chunk-7KAZ3B5B.js.map
@@ -13,13 +13,17 @@ function CardActionsProvider({
13
13
  errorTitle,
14
14
  errorDismissLabel,
15
15
  autoHideMs = 6e3,
16
+ onError,
16
17
  children
17
18
  }) {
18
19
  const [error, setError] = useState(null);
19
- const notifyError = useCallback((message) => setError(message), []);
20
+ const notifyError = useCallback(
21
+ (message) => onError ? onError(errorTitle, message) : setError(message),
22
+ [onError, errorTitle]
23
+ );
20
24
  return /* @__PURE__ */ jsxs(CardActionsContext.Provider, { value: { tenantSlug, onRefresh, notifyError }, children: [
21
25
  children,
22
- /* @__PURE__ */ jsx(
26
+ onError === void 0 && /* @__PURE__ */ jsx(
23
27
  Snackbar,
24
28
  {
25
29
  open: error !== null,
@@ -54,4 +58,4 @@ export {
54
58
  CardActionsProvider,
55
59
  useCardActions
56
60
  };
57
- //# sourceMappingURL=chunk-N7KWWIF7.js.map
61
+ //# sourceMappingURL=chunk-LY7PBZ3Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/data-display/CardKit/card-actions-context.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, useCallback, useContext, useState, type JSX, type ReactNode } from 'react';\n\nimport Snackbar from '@mui/material/Snackbar/index.js';\n\nimport { Alert } from '../Alert';\n\n/**\n * The ambient wiring a self-contained row/card menu needs, and nothing else.\n *\n * A menu that owns its own popups still needs three things it cannot know: the\n * tenant it is acting inside, what to do after a write lands, and somewhere to\n * put a failure. Passing those down through the grid, the layout and the card\n * is four props of drilling per entity; holding them in context is one.\n *\n * Kept deliberately SMALL — it is not an edit-dialog host. A menu that read its\n * dialogs from here would stop being portable, because the set of dialogs is\n * per-entity. What it may read is the three facts below.\n *\n * The provider renders ONE shared error snackbar, which is the whole reason the\n * error channel is here rather than per-menu: before it, every page carried its\n * own error alert and every menu had to find its page's.\n */\ninterface CardActionsValue {\n /** The tenant every action in this subtree acts inside. */\n tenantSlug: string;\n /** Re-read the list after a write. */\n onRefresh: () => void;\n /** Surface a failed action's message (the shared snackbar). */\n notifyError: (message: string) => void;\n}\n\nconst CardActionsContext = createContext<CardActionsValue | null>(null);\n\nexport function CardActionsProvider({\n tenantSlug,\n onRefresh,\n errorTitle,\n errorDismissLabel,\n autoHideMs = 6_000,\n onError,\n children,\n}: {\n tenantSlug: string;\n onRefresh: () => void;\n /**\n * The snackbar's heading — required, no default.\n *\n * It is the one sentence this provider renders on its own, and a default\n * would be the origin's language shipped as a finished-looking silence. The\n * MESSAGE beside it comes from whatever failed, which is already the host's.\n */\n errorTitle: string;\n /** The dismiss on that alert, which carries a glyph only. REQUIRED. */\n errorDismissLabel: string;\n /** How long the snackbar stays up. */\n autoHideMs?: number;\n /**\n * Hand a failure to the HOST's own toast channel instead of this provider's\n * snackbar. Given, the provider draws nothing of its own: an app with one\n * toast column (every toast in one place, in one look) passes its `toast`\n * here, so a card's failure lands with every other toast rather than in a\n * corner of its own. It receives the same heading and message the snackbar\n * would have shown.\n */\n onError?: (title: string, message: string) => void;\n children: ReactNode;\n}): JSX.Element {\n const [error, setError] = useState<string | null>(null);\n const notifyError = useCallback(\n (message: string) => (onError ? onError(errorTitle, message) : setError(message)),\n [onError, errorTitle],\n );\n\n return (\n <CardActionsContext.Provider value={{ tenantSlug, onRefresh, notifyError }}>\n {children}\n {onError === undefined && (\n <Snackbar\n open={error !== null}\n autoHideDuration={autoHideMs}\n onClose={() => setError(null)}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}\n >\n <span>\n <Alert\n variant=\"danger\"\n title={errorTitle}\n description={error ?? ''}\n closable\n closeLabel={errorDismissLabel}\n onClose={() => setError(null)}\n data-testid=\"card-action-error\"\n />\n </span>\n </Snackbar>\n )}\n </CardActionsContext.Provider>\n );\n}\n\n/**\n * Read the tenant + refresh + error wiring.\n *\n * THROWS outside a provider rather than answering a null object, deliberately:\n * a menu whose `onRefresh` silently did nothing would leave the operator\n * looking at a stale row after a delete that worked, which reads as the delete\n * having failed. Failing at mount says where the provider is missing.\n */\nexport function useCardActions(): CardActionsValue {\n const value = useContext(CardActionsContext);\n if (!value) {\n throw new Error('useCardActions must be used within a CardActionsProvider');\n }\n return value;\n}\n"],"mappings":";;;;;AAEA,SAAS,eAAe,aAAa,YAAY,gBAA0C;AAE3F,OAAO,cAAc;AAwEjB,SAUM,KAVN;AA3CJ,IAAM,qBAAqB,cAAuC,IAAI;AAE/D,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AACF,GAyBgB;AACd,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,QAAM,cAAc;AAAA,IAClB,CAAC,YAAqB,UAAU,QAAQ,YAAY,OAAO,IAAI,SAAS,OAAO;AAAA,IAC/E,CAAC,SAAS,UAAU;AAAA,EACtB;AAEA,SACE,qBAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,YAAY,WAAW,YAAY,GACtE;AAAA;AAAA,IACA,YAAY,UACb;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,UAAU;AAAA,QAChB,kBAAkB;AAAA,QAClB,SAAS,MAAM,SAAS,IAAI;AAAA,QAC5B,cAAc,EAAE,UAAU,UAAU,YAAY,SAAS;AAAA,QAEzD,8BAAC,UACC;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,OAAO;AAAA,YACP,aAAa,SAAS;AAAA,YACtB,UAAQ;AAAA,YACR,YAAY;AAAA,YACZ,SAAS,MAAM,SAAS,IAAI;AAAA,YAC5B,eAAY;AAAA;AAAA,QACd,GACF;AAAA;AAAA,IACF;AAAA,KAEF;AAEJ;AAUO,SAAS,iBAAmC;AACjD,QAAM,QAAQ,WAAW,kBAAkB;AAC3C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,SAAO;AACT;","names":[]}
@@ -6,11 +6,11 @@ import {
6
6
  } from "../chunk-6QOJEZDH.js";
7
7
  import {
8
8
  useRemoveConfirm
9
- } from "../chunk-62BY4ZUQ.js";
9
+ } from "../chunk-7KAZ3B5B.js";
10
10
  import {
11
11
  CardActionsProvider,
12
12
  useCardActions
13
- } from "../chunk-N7KWWIF7.js";
13
+ } from "../chunk-LY7PBZ3Z.js";
14
14
  import {
15
15
  rowActionsToMenuItems
16
16
  } from "../chunk-ZBXG6RVJ.js";
@@ -23,7 +23,7 @@ interface CardActionsValue {
23
23
  /** Surface a failed action's message (the shared snackbar). */
24
24
  notifyError: (message: string) => void;
25
25
  }
26
- export declare function CardActionsProvider({ tenantSlug, onRefresh, errorTitle, errorDismissLabel, autoHideMs, children, }: {
26
+ export declare function CardActionsProvider({ tenantSlug, onRefresh, errorTitle, errorDismissLabel, autoHideMs, onError, children, }: {
27
27
  tenantSlug: string;
28
28
  onRefresh: () => void;
29
29
  /**
@@ -38,6 +38,15 @@ export declare function CardActionsProvider({ tenantSlug, onRefresh, errorTitle,
38
38
  errorDismissLabel: string;
39
39
  /** How long the snackbar stays up. */
40
40
  autoHideMs?: number;
41
+ /**
42
+ * Hand a failure to the HOST's own toast channel instead of this provider's
43
+ * snackbar. Given, the provider draws nothing of its own: an app with one
44
+ * toast column (every toast in one place, in one look) passes its `toast`
45
+ * here, so a card's failure lands with every other toast rather than in a
46
+ * corner of its own. It receives the same heading and message the snackbar
47
+ * would have shown.
48
+ */
49
+ onError?: (title: string, message: string) => void;
41
50
  children: ReactNode;
42
51
  }): JSX.Element;
43
52
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"card-actions-context.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/CardKit/card-actions-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoD,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMnG;;;;;;;;;;;;;;;GAeG;AACH,UAAU,gBAAgB;IACxB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,+DAA+D;IAC/D,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAID,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAkB,EAClB,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CA2Bd;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAMjD"}
1
+ {"version":3,"file":"card-actions-context.d.ts","sourceRoot":"","sources":["../../../../../src/components/data-display/CardKit/card-actions-context.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAoD,KAAK,GAAG,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMnG;;;;;;;;;;;;;;;GAeG;AACH,UAAU,gBAAgB;IACxB,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,+DAA+D;IAC/D,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAID,wBAAgB,mBAAmB,CAAC,EAClC,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,UAAkB,EAClB,OAAO,EACP,QAAQ,GACT,EAAE;IACD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,QAAQ,EAAE,SAAS,CAAC;CACrB,GAAG,GAAG,CAAC,OAAO,CAgCd;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAMjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@12-apps/ui",
3
- "version": "6.71.0",
3
+ "version": "6.72.0",
4
4
  "license": "MIT",
5
5
  "packageManager": "pnpm@10.34.5",
6
6
  "type": "module",
@@ -33,6 +33,9 @@ language shipped as a finished-looking silence:
33
33
  verbatim by a screen reader.
34
34
  - `CardActionsProvider`'s **`errorTitle`** — the one sentence the provider
35
35
  renders on its own. The message beside it comes from whatever failed.
36
+ An app with one toast channel passes **`onError(title, message)`** instead of
37
+ living with the provider's bottom snackbar: given, the provider draws
38
+ nothing of its own and the failure lands with every other toast.
36
39
  - Both hooks' **`confirmText`** — the verb. `ConfirmOptions` already refuses to
37
40
  default one, for the same reason: a confirm button reading "OK" tells the
38
41
  operator nothing about what is about to happen.
@@ -39,6 +39,7 @@ export function CardActionsProvider({
39
39
  errorTitle,
40
40
  errorDismissLabel,
41
41
  autoHideMs = 6_000,
42
+ onError,
42
43
  children,
43
44
  }: {
44
45
  tenantSlug: string;
@@ -55,14 +56,27 @@ export function CardActionsProvider({
55
56
  errorDismissLabel: string;
56
57
  /** How long the snackbar stays up. */
57
58
  autoHideMs?: number;
59
+ /**
60
+ * Hand a failure to the HOST's own toast channel instead of this provider's
61
+ * snackbar. Given, the provider draws nothing of its own: an app with one
62
+ * toast column (every toast in one place, in one look) passes its `toast`
63
+ * here, so a card's failure lands with every other toast rather than in a
64
+ * corner of its own. It receives the same heading and message the snackbar
65
+ * would have shown.
66
+ */
67
+ onError?: (title: string, message: string) => void;
58
68
  children: ReactNode;
59
69
  }): JSX.Element {
60
70
  const [error, setError] = useState<string | null>(null);
61
- const notifyError = useCallback((message: string) => setError(message), []);
71
+ const notifyError = useCallback(
72
+ (message: string) => (onError ? onError(errorTitle, message) : setError(message)),
73
+ [onError, errorTitle],
74
+ );
62
75
 
63
76
  return (
64
77
  <CardActionsContext.Provider value={{ tenantSlug, onRefresh, notifyError }}>
65
78
  {children}
79
+ {onError === undefined && (
66
80
  <Snackbar
67
81
  open={error !== null}
68
82
  autoHideDuration={autoHideMs}
@@ -81,6 +95,7 @@ export function CardActionsProvider({
81
95
  />
82
96
  </span>
83
97
  </Snackbar>
98
+ )}
84
99
  </CardActionsContext.Provider>
85
100
  );
86
101
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/components/data-display/CardKit/card-actions-context.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, useCallback, useContext, useState, type JSX, type ReactNode } from 'react';\n\nimport Snackbar from '@mui/material/Snackbar/index.js';\n\nimport { Alert } from '../Alert';\n\n/**\n * The ambient wiring a self-contained row/card menu needs, and nothing else.\n *\n * A menu that owns its own popups still needs three things it cannot know: the\n * tenant it is acting inside, what to do after a write lands, and somewhere to\n * put a failure. Passing those down through the grid, the layout and the card\n * is four props of drilling per entity; holding them in context is one.\n *\n * Kept deliberately SMALL — it is not an edit-dialog host. A menu that read its\n * dialogs from here would stop being portable, because the set of dialogs is\n * per-entity. What it may read is the three facts below.\n *\n * The provider renders ONE shared error snackbar, which is the whole reason the\n * error channel is here rather than per-menu: before it, every page carried its\n * own error alert and every menu had to find its page's.\n */\ninterface CardActionsValue {\n /** The tenant every action in this subtree acts inside. */\n tenantSlug: string;\n /** Re-read the list after a write. */\n onRefresh: () => void;\n /** Surface a failed action's message (the shared snackbar). */\n notifyError: (message: string) => void;\n}\n\nconst CardActionsContext = createContext<CardActionsValue | null>(null);\n\nexport function CardActionsProvider({\n tenantSlug,\n onRefresh,\n errorTitle,\n errorDismissLabel,\n autoHideMs = 6_000,\n children,\n}: {\n tenantSlug: string;\n onRefresh: () => void;\n /**\n * The snackbar's heading — required, no default.\n *\n * It is the one sentence this provider renders on its own, and a default\n * would be the origin's language shipped as a finished-looking silence. The\n * MESSAGE beside it comes from whatever failed, which is already the host's.\n */\n errorTitle: string;\n /** The dismiss on that alert, which carries a glyph only. REQUIRED. */\n errorDismissLabel: string;\n /** How long the snackbar stays up. */\n autoHideMs?: number;\n children: ReactNode;\n}): JSX.Element {\n const [error, setError] = useState<string | null>(null);\n const notifyError = useCallback((message: string) => setError(message), []);\n\n return (\n <CardActionsContext.Provider value={{ tenantSlug, onRefresh, notifyError }}>\n {children}\n <Snackbar\n open={error !== null}\n autoHideDuration={autoHideMs}\n onClose={() => setError(null)}\n anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}\n >\n <span>\n <Alert\n variant=\"danger\"\n title={errorTitle}\n description={error ?? ''}\n closable\n closeLabel={errorDismissLabel}\n onClose={() => setError(null)}\n data-testid=\"card-action-error\"\n />\n </span>\n </Snackbar>\n </CardActionsContext.Provider>\n );\n}\n\n/**\n * Read the tenant + refresh + error wiring.\n *\n * THROWS outside a provider rather than answering a null object, deliberately:\n * a menu whose `onRefresh` silently did nothing would leave the operator\n * looking at a stale row after a delete that worked, which reads as the delete\n * having failed. Failing at mount says where the provider is missing.\n */\nexport function useCardActions(): CardActionsValue {\n const value = useContext(CardActionsContext);\n if (!value) {\n throw new Error('useCardActions must be used within a CardActionsProvider');\n }\n return value;\n}\n"],"mappings":";;;;;AAEA,SAAS,eAAe,aAAa,YAAY,gBAA0C;AAE3F,OAAO,cAAc;AA2DjB,SASM,KATN;AA9BJ,IAAM,qBAAqB,cAAuC,IAAI;AAE/D,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AACF,GAgBgB;AACd,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,QAAM,cAAc,YAAY,CAAC,YAAoB,SAAS,OAAO,GAAG,CAAC,CAAC;AAE1E,SACE,qBAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,YAAY,WAAW,YAAY,GACtE;AAAA;AAAA,IACD;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,UAAU;AAAA,QAChB,kBAAkB;AAAA,QAClB,SAAS,MAAM,SAAS,IAAI;AAAA,QAC5B,cAAc,EAAE,UAAU,UAAU,YAAY,SAAS;AAAA,QAEzD,8BAAC,UACC;AAAA,UAAC;AAAA;AAAA,YACC,SAAQ;AAAA,YACR,OAAO;AAAA,YACP,aAAa,SAAS;AAAA,YACtB,UAAQ;AAAA,YACR,YAAY;AAAA,YACZ,SAAS,MAAM,SAAS,IAAI;AAAA,YAC5B,eAAY;AAAA;AAAA,QACd,GACF;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;AAUO,SAAS,iBAAmC;AACjD,QAAM,QAAQ,WAAW,kBAAkB;AAC3C,MAAI,CAAC,OAAO;AACV,UAAM,IAAI,MAAM,0DAA0D;AAAA,EAC5E;AACA,SAAO;AACT;","names":[]}