@jsudc/react 0.5.1 → 0.7.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 (50) hide show
  1. package/README.md +124 -14
  2. package/dist/actions/useRowActionRunner.js +6 -0
  3. package/dist/actions/useRowActionRunner.js.map +1 -1
  4. package/dist/calendar/CalendarRenderer.js +5 -1
  5. package/dist/calendar/CalendarRenderer.js.map +1 -1
  6. package/dist/cards/CardRenderer.js +1 -0
  7. package/dist/cards/CardRenderer.js.map +1 -1
  8. package/dist/chart/ChartRenderer.js +2 -0
  9. package/dist/chart/ChartRenderer.js.map +1 -1
  10. package/dist/data-view/BulkBar.js +6 -0
  11. package/dist/data-view/BulkBar.js.map +1 -1
  12. package/dist/data-view/UdcDataView.d.ts +34 -4
  13. package/dist/data-view/UdcDataView.js +29 -15
  14. package/dist/data-view/UdcDataView.js.map +1 -1
  15. package/dist/data-view/liveView.d.ts +21 -4
  16. package/dist/data-view/liveView.js +31 -6
  17. package/dist/data-view/liveView.js.map +1 -1
  18. package/dist/data-view/useDataViewState.d.ts +30 -1
  19. package/dist/data-view/useDataViewState.js +47 -3
  20. package/dist/data-view/useDataViewState.js.map +1 -1
  21. package/dist/headless.js +3 -3
  22. package/dist/i18n/translations.js +8 -0
  23. package/dist/i18n/translations.js.map +1 -1
  24. package/dist/index.d.ts +1 -0
  25. package/dist/index.js +4 -3
  26. package/dist/kanban/KanbanRenderer.js +5 -1
  27. package/dist/kanban/KanbanRenderer.js.map +1 -1
  28. package/dist/map/MapRenderer.js +1 -0
  29. package/dist/map/MapRenderer.js.map +1 -1
  30. package/dist/table/TableRenderer.js +46 -19
  31. package/dist/table/TableRenderer.js.map +1 -1
  32. package/dist/table/columnLayout.d.ts +41 -0
  33. package/dist/table/columnLayout.js +86 -0
  34. package/dist/table/columnLayout.js.map +1 -0
  35. package/dist/table/index.d.ts +1 -0
  36. package/dist/table/states.d.ts +10 -2
  37. package/dist/table/states.js +15 -8
  38. package/dist/table/states.js.map +1 -1
  39. package/dist/table.js +2 -1
  40. package/dist/table.js.map +1 -1
  41. package/dist/tree/TreeRenderer.js +5 -1
  42. package/dist/tree/TreeRenderer.js.map +1 -1
  43. package/dist/udc/busy.d.ts +9 -0
  44. package/dist/udc/busy.js +20 -0
  45. package/dist/udc/busy.js.map +1 -0
  46. package/dist/udc/client.d.ts +2 -1
  47. package/dist/udc/client.js +4 -3
  48. package/dist/udc/client.js.map +1 -1
  49. package/dist/udc/hooks.d.ts +20 -5
  50. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- import { useI18n } from "../i18n/i18n.js";
1
+ import { tableSection, useI18n } from "../i18n/i18n.js";
2
2
  import { useUiKit } from "../ui-kit/context.js";
3
3
  import { isUnauthenticated } from "@jsudc/core";
4
4
  import { AlertTriangle, LogIn, RotateCw, SearchX, Table2 } from "lucide-react";
@@ -28,15 +28,22 @@ function Panel({ icon, title, body, action, testId, tone = "muted" }) {
28
28
  ]
29
29
  });
30
30
  }
31
- /** `body` replaces the default text (a view's `empty_label`). */
32
- function EmptyState({ filtered, onClear, body }) {
31
+ /**
32
+ * No rows. Its strings are looked up in the collection's own section first
33
+ * (`TBL_<COLLECTION>.EMPTY_TITLE` / `EMPTY_BODY` / `EMPTY_PLAIN`, as
34
+ * `SEARCH_PLACEHOLDER` is), then in `APP`: an empty mail folder can say "No
35
+ * messages here." without every other view of the app saying it too. `body`
36
+ * replaces the default text (a view's `empty_label`) and wins over both.
37
+ */
38
+ function EmptyState({ filtered, onClear, body, collection }) {
33
39
  const { Button } = useUiKit();
34
- const { t } = useI18n();
40
+ const { t, tMaybe } = useI18n();
41
+ const term = (key) => (collection ? tMaybe(tableSection(collection), key) : null) ?? t("APP", key);
35
42
  return filtered ? /* @__PURE__ */ jsx(Panel, {
36
43
  testId: "table-empty",
37
44
  icon: /* @__PURE__ */ jsx(SearchX, { className: "udc:size-5" }),
38
- title: t("APP", "EMPTY_TITLE"),
39
- body: body ?? t("APP", "EMPTY_BODY"),
45
+ title: term("EMPTY_TITLE"),
46
+ body: body ?? term("EMPTY_BODY"),
40
47
  action: /* @__PURE__ */ jsx(Button, {
41
48
  size: "sm",
42
49
  onClick: onClear,
@@ -45,8 +52,8 @@ function EmptyState({ filtered, onClear, body }) {
45
52
  }) : /* @__PURE__ */ jsx(Panel, {
46
53
  testId: "table-empty",
47
54
  icon: /* @__PURE__ */ jsx(Table2, { className: "udc:size-5" }),
48
- title: t("APP", "EMPTY_TITLE"),
49
- body: body ?? t("APP", "EMPTY_PLAIN")
55
+ title: term("EMPTY_TITLE"),
56
+ body: body ?? term("EMPTY_PLAIN")
50
57
  });
51
58
  }
52
59
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"states.js","names":[],"sources":["../../src/table/states.tsx"],"sourcesContent":["import { isUnauthenticated } from \"@jsudc/core\";\nimport { AlertTriangle, LogIn, RotateCw, SearchX, Table2 } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { useI18n } from \"../i18n/i18n.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\n\nfunction Panel({\n icon,\n title,\n body,\n action,\n testId,\n tone = \"muted\",\n}: {\n icon: ReactNode;\n title: string;\n body?: ReactNode;\n action?: ReactNode;\n testId: string;\n tone?: \"muted\" | \"danger\";\n}) {\n return (\n <div\n data-testid={testId}\n className=\"udc:flex udc:flex-col udc:items-center udc:px-6 udc:py-16 udc:text-center\"\n >\n <div\n className={\n tone === \"danger\"\n ? \"udc:mb-4 udc:grid udc:size-12 udc:place-items-center udc:rounded-xl udc:bg-sem-danger-bg udc:text-sem-danger\"\n : \"udc:mb-4 udc:grid udc:size-12 udc:place-items-center udc:rounded-xl udc:border udc:border-border udc:bg-muted udc:text-muted-foreground\"\n }\n >\n {icon}\n </div>\n <div className=\"udc:text-sm udc:font-semibold\">{title}</div>\n {body ? (\n <div className=\"udc:mt-1 udc:max-w-sm udc:text-[13px] udc:text-muted-foreground\">\n {body}\n </div>\n ) : null}\n {action ? <div className=\"udc:mt-4\">{action}</div> : null}\n </div>\n );\n}\n\n/** `body` replaces the default text (a view's `empty_label`). */\nexport function EmptyState({\n filtered,\n onClear,\n body,\n}: {\n filtered: boolean;\n onClear: () => void;\n body?: string | undefined;\n}) {\n const { Button } = useUiKit();\n const { t } = useI18n();\n return filtered ? (\n <Panel\n testId=\"table-empty\"\n icon={<SearchX className=\"udc:size-5\" />}\n title={t(\"APP\", \"EMPTY_TITLE\")}\n body={body ?? t(\"APP\", \"EMPTY_BODY\")}\n action={\n <Button size=\"sm\" onClick={onClear}>\n {t(\"APP\", \"CLEAR_FILTERS\")}\n </Button>\n }\n />\n ) : (\n <Panel\n testId=\"table-empty\"\n icon={<Table2 className=\"udc:size-5\" />}\n title={t(\"APP\", \"EMPTY_TITLE\")}\n body={body ?? t(\"APP\", \"EMPTY_PLAIN\")}\n />\n );\n}\n\n/**\n * A failed load. \"Not signed in\" (`isUnauthenticated`: an HTTP 401, or the\n * server's in-protocol refusal) is a state of the session, not of the data:\n * it says so (`APP.SIGNED_OUT_TITLE` / `SIGNED_OUT_BODY`) and offers no Retry,\n * which would only be refused again. Anything else shows its message and Retry.\n */\nexport function ErrorState({ error, onRetry }: { error: Error; onRetry: () => void }) {\n const { Button } = useUiKit();\n const { t } = useI18n();\n if (isUnauthenticated(error)) {\n return (\n <Panel\n testId=\"signed-out\"\n icon={<LogIn className=\"udc:size-5\" />}\n title={t(\"APP\", \"SIGNED_OUT_TITLE\")}\n body={t(\"APP\", \"SIGNED_OUT_BODY\")}\n />\n );\n }\n return (\n <Panel\n testId=\"table-error\"\n tone=\"danger\"\n icon={<AlertTriangle className=\"udc:size-5\" />}\n title={t(\"APP\", \"ERROR_TITLE\")}\n body={<span className=\"udc:font-mono udc:text-xs\">{error.message}</span>}\n action={\n <Button size=\"sm\" onClick={onRetry} data-testid=\"retry\">\n <RotateCw className=\"udc:size-3.5!\" />\n {t(\"APP\", \"RETRY\")}\n </Button>\n }\n />\n );\n}\n\n/**\n * A tab whose renderer the host did not register: the registry is explicit\n * (`UdcProvider renderers={…}`), so this is a setup error, not missing data.\n */\nexport function NoRendererState({ name }: { name: string }) {\n const { t } = useI18n();\n return (\n <Panel\n testId=\"no-renderer\"\n icon={<Table2 className=\"udc:size-5\" />}\n title={t(\"APP\", \"NO_RENDERER_TITLE\", { name })}\n body={t(\"APP\", \"NO_RENDERER_BODY\")}\n />\n );\n}\n"],"mappings":";;;;;;AAMA,SAAS,MAAM,EACb,MACA,OACA,MACA,QACA,QACA,OAAO,WAQN;CACD,OACE,qBAAC,OAAD;EACE,eAAa;EACb,WAAU;EAFZ,UAAA;GAIE,oBAAC,OAAD;IACE,WACE,SAAS,WACL,iHACA;IAGL,UAAA;GACE,CAAA;GACL,oBAAC,OAAD;IAAK,WAAU;IAAiC,UAAA;GAAW,CAAA;GAC1D,OACC,oBAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA,IACH;GACH,SAAS,oBAAC,OAAD;IAAK,WAAU;IAAY,UAAA;GAAY,CAAA,IAAI;EAClD;;AAET;;AAGA,SAAgB,WAAW,EACzB,UACA,SACA,QAKC;CACD,MAAM,EAAE,WAAW,SAAS;CAC5B,MAAM,EAAE,MAAM,QAAQ;CACtB,OAAO,WACL,oBAAC,OAAD;EACE,QAAO;EACP,MAAM,oBAAC,SAAD,EAAS,WAAU,aAAc,CAAA;EACvC,OAAO,EAAE,OAAO,aAAa;EAC7B,MAAM,QAAQ,EAAE,OAAO,YAAY;EACnC,QACE,oBAAC,QAAD;GAAQ,MAAK;GAAK,SAAS;GACxB,UAAA,EAAE,OAAO,eAAe;EACnB,CAAA;CAEX,CAAA,IAED,oBAAC,OAAD;EACE,QAAO;EACP,MAAM,oBAAC,QAAD,EAAQ,WAAU,aAAc,CAAA;EACtC,OAAO,EAAE,OAAO,aAAa;EAC7B,MAAM,QAAQ,EAAE,OAAO,aAAa;CACrC,CAAA;AAEL;;;;;;;AAQA,SAAgB,WAAW,EAAE,OAAO,WAAkD;CACpF,MAAM,EAAE,WAAW,SAAS;CAC5B,MAAM,EAAE,MAAM,QAAQ;CACtB,IAAI,kBAAkB,KAAK,GACzB,OACE,oBAAC,OAAD;EACE,QAAO;EACP,MAAM,oBAAC,OAAD,EAAO,WAAU,aAAc,CAAA;EACrC,OAAO,EAAE,OAAO,kBAAkB;EAClC,MAAM,EAAE,OAAO,iBAAiB;CACjC,CAAA;CAGL,OACE,oBAAC,OAAD;EACE,QAAO;EACP,MAAK;EACL,MAAM,oBAAC,eAAD,EAAe,WAAU,aAAc,CAAA;EAC7C,OAAO,EAAE,OAAO,aAAa;EAC7B,MAAM,oBAAC,QAAD;GAAM,WAAU;GAA6B,UAAA,MAAM;EAAc,CAAA;EACvE,QACE,qBAAC,QAAD;GAAQ,MAAK;GAAK,SAAS;GAAS,eAAY;GAAhD,UAAA,CACE,oBAAC,UAAD,EAAU,WAAU,gBAAiB,CAAA,GACpC,EAAE,OAAO,OAAO,CACX;;CAEX,CAAA;AAEL;;;;;AAMA,SAAgB,gBAAgB,EAAE,QAA0B;CAC1D,MAAM,EAAE,MAAM,QAAQ;CACtB,OACE,oBAAC,OAAD;EACE,QAAO;EACP,MAAM,oBAAC,QAAD,EAAQ,WAAU,aAAc,CAAA;EACtC,OAAO,EAAE,OAAO,qBAAqB,EAAE,KAAK,CAAC;EAC7C,MAAM,EAAE,OAAO,kBAAkB;CAClC,CAAA;AAEL"}
1
+ {"version":3,"file":"states.js","names":[],"sources":["../../src/table/states.tsx"],"sourcesContent":["import { isUnauthenticated } from \"@jsudc/core\";\nimport { AlertTriangle, LogIn, RotateCw, SearchX, Table2 } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { tableSection, useI18n } from \"../i18n/i18n.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\n\nfunction Panel({\n icon,\n title,\n body,\n action,\n testId,\n tone = \"muted\",\n}: {\n icon: ReactNode;\n title: string;\n body?: ReactNode;\n action?: ReactNode;\n testId: string;\n tone?: \"muted\" | \"danger\";\n}) {\n return (\n <div\n data-testid={testId}\n className=\"udc:flex udc:flex-col udc:items-center udc:px-6 udc:py-16 udc:text-center\"\n >\n <div\n className={\n tone === \"danger\"\n ? \"udc:mb-4 udc:grid udc:size-12 udc:place-items-center udc:rounded-xl udc:bg-sem-danger-bg udc:text-sem-danger\"\n : \"udc:mb-4 udc:grid udc:size-12 udc:place-items-center udc:rounded-xl udc:border udc:border-border udc:bg-muted udc:text-muted-foreground\"\n }\n >\n {icon}\n </div>\n <div className=\"udc:text-sm udc:font-semibold\">{title}</div>\n {body ? (\n <div className=\"udc:mt-1 udc:max-w-sm udc:text-[13px] udc:text-muted-foreground\">\n {body}\n </div>\n ) : null}\n {action ? <div className=\"udc:mt-4\">{action}</div> : null}\n </div>\n );\n}\n\n/**\n * No rows. Its strings are looked up in the collection's own section first\n * (`TBL_<COLLECTION>.EMPTY_TITLE` / `EMPTY_BODY` / `EMPTY_PLAIN`, as\n * `SEARCH_PLACEHOLDER` is), then in `APP`: an empty mail folder can say \"No\n * messages here.\" without every other view of the app saying it too. `body`\n * replaces the default text (a view's `empty_label`) and wins over both.\n */\nexport function EmptyState({\n filtered,\n onClear,\n body,\n collection,\n}: {\n filtered: boolean;\n onClear: () => void;\n body?: string | undefined;\n /** The collection whose `TBL_<COLLECTION>` section is asked first. */\n collection?: string | undefined;\n}) {\n const { Button } = useUiKit();\n const { t, tMaybe } = useI18n();\n const term = (key: string) =>\n (collection ? tMaybe(tableSection(collection), key) : null) ?? t(\"APP\", key);\n return filtered ? (\n <Panel\n testId=\"table-empty\"\n icon={<SearchX className=\"udc:size-5\" />}\n title={term(\"EMPTY_TITLE\")}\n body={body ?? term(\"EMPTY_BODY\")}\n action={\n <Button size=\"sm\" onClick={onClear}>\n {t(\"APP\", \"CLEAR_FILTERS\")}\n </Button>\n }\n />\n ) : (\n <Panel\n testId=\"table-empty\"\n icon={<Table2 className=\"udc:size-5\" />}\n title={term(\"EMPTY_TITLE\")}\n body={body ?? term(\"EMPTY_PLAIN\")}\n />\n );\n}\n\n/**\n * A failed load. \"Not signed in\" (`isUnauthenticated`: an HTTP 401, or the\n * server's in-protocol refusal) is a state of the session, not of the data:\n * it says so (`APP.SIGNED_OUT_TITLE` / `SIGNED_OUT_BODY`) and offers no Retry,\n * which would only be refused again. Anything else shows its message and Retry.\n */\nexport function ErrorState({ error, onRetry }: { error: Error; onRetry: () => void }) {\n const { Button } = useUiKit();\n const { t } = useI18n();\n if (isUnauthenticated(error)) {\n return (\n <Panel\n testId=\"signed-out\"\n icon={<LogIn className=\"udc:size-5\" />}\n title={t(\"APP\", \"SIGNED_OUT_TITLE\")}\n body={t(\"APP\", \"SIGNED_OUT_BODY\")}\n />\n );\n }\n return (\n <Panel\n testId=\"table-error\"\n tone=\"danger\"\n icon={<AlertTriangle className=\"udc:size-5\" />}\n title={t(\"APP\", \"ERROR_TITLE\")}\n body={<span className=\"udc:font-mono udc:text-xs\">{error.message}</span>}\n action={\n <Button size=\"sm\" onClick={onRetry} data-testid=\"retry\">\n <RotateCw className=\"udc:size-3.5!\" />\n {t(\"APP\", \"RETRY\")}\n </Button>\n }\n />\n );\n}\n\n/**\n * A tab whose renderer the host did not register: the registry is explicit\n * (`UdcProvider renderers={…}`), so this is a setup error, not missing data.\n */\nexport function NoRendererState({ name }: { name: string }) {\n const { t } = useI18n();\n return (\n <Panel\n testId=\"no-renderer\"\n icon={<Table2 className=\"udc:size-5\" />}\n title={t(\"APP\", \"NO_RENDERER_TITLE\", { name })}\n body={t(\"APP\", \"NO_RENDERER_BODY\")}\n />\n );\n}\n"],"mappings":";;;;;;AAMA,SAAS,MAAM,EACb,MACA,OACA,MACA,QACA,QACA,OAAO,WAQN;CACD,OACE,qBAAC,OAAD;EACE,eAAa;EACb,WAAU;EAFZ,UAAA;GAIE,oBAAC,OAAD;IACE,WACE,SAAS,WACL,iHACA;IAGL,UAAA;GACE,CAAA;GACL,oBAAC,OAAD;IAAK,WAAU;IAAiC,UAAA;GAAW,CAAA;GAC1D,OACC,oBAAC,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,QACE,qBAAC,QAAD;GAAQ,MAAK;GAAK,SAAS;GAAS,eAAY;GAAhD,UAAA,CACE,oBAAC,UAAD,EAAU,WAAU,gBAAiB,CAAA,GACpC,EAAE,OAAO,OAAO,CACX;;CAEX,CAAA;AAEL;;;;;AAMA,SAAgB,gBAAgB,EAAE,QAA0B;CAC1D,MAAM,EAAE,MAAM,QAAQ;CACtB,OACE,oBAAC,OAAD;EACE,QAAO;EACP,MAAM,oBAAC,QAAD,EAAQ,WAAU,aAAc,CAAA;EACtC,OAAO,EAAE,OAAO,qBAAqB,EAAE,KAAK,CAAC;EAC7C,MAAM,EAAE,OAAO,kBAAkB;CAClC,CAAA;AAEL"}
package/dist/table.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { displayText, renderKind } from "./table/format.js";
2
2
  import { TableRenderer } from "./table/TableRenderer.js";
3
3
  import { CellValue } from "./table/cells.js";
4
+ import { hiddenAtWidth, isFillWidth, layoutColumnWidths, usePaneWidth } from "./table/columnLayout.js";
4
5
  import { Pager } from "./table/Pager.js";
5
6
  import { Table2 } from "lucide-react";
6
7
  // src/table/index.ts
@@ -13,6 +14,6 @@ var tableRenderer = {
13
14
  paging: true,
14
15
  editMode: true
15
16
  };
16
- export { CellValue, Pager, TableRenderer, displayText, renderKind, tableRenderer };
17
+ export { CellValue, Pager, TableRenderer, displayText, hiddenAtWidth, isFillWidth, layoutColumnWidths, renderKind, tableRenderer, usePaneWidth };
17
18
 
18
19
  //# sourceMappingURL=table.js.map
package/dist/table.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"table.js","names":[],"sources":["../src/table/index.ts"],"sourcesContent":["// @jsudc/react/table: the table renderer. Needs the `@tanstack/react-table` peer.\nimport { Table2 } from \"lucide-react\";\nimport type { RendererDefinition } from \"../renderers/types.js\";\nimport { TableRenderer } from \"./TableRenderer.js\";\n\nexport { CellValue, displayText, renderKind } from \"./cells.js\";\nexport { Pager } from \"./Pager.js\";\nexport { TableRenderer, type TableRendererProps } from \"./TableRenderer.js\";\nexport type { TableVirtualization, TableVirtualizeProp } from \"./useRowWindow.js\";\n\n/** `createRendererRegistry(tableRenderer, …)`: the `table` tab, paged, with the schema editor. */\nexport const tableRenderer: RendererDefinition = {\n name: \"table\",\n component: TableRenderer,\n icon: Table2,\n labelKey: \"TAB_TABLE\",\n paging: true,\n editMode: true,\n};\n"],"mappings":";;;;;;;AAWA,IAAa,gBAAoC;CAC/C,MAAM;CACN,WAAW;CACX,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;AACZ"}
1
+ {"version":3,"file":"table.js","names":[],"sources":["../src/table/index.ts"],"sourcesContent":["// @jsudc/react/table: the table renderer. Needs the `@tanstack/react-table` peer.\nimport { Table2 } from \"lucide-react\";\nimport type { RendererDefinition } from \"../renderers/types.js\";\nimport { TableRenderer } from \"./TableRenderer.js\";\n\nexport { CellValue, displayText, renderKind } from \"./cells.js\";\nexport {\n type ColumnSizing,\n hiddenAtWidth,\n isFillWidth,\n type LayoutInput,\n type LayoutOptions,\n layoutColumnWidths,\n usePaneWidth,\n} from \"./columnLayout.js\";\nexport { Pager } from \"./Pager.js\";\nexport { TableRenderer, type TableRendererProps } from \"./TableRenderer.js\";\nexport type { TableVirtualization, TableVirtualizeProp } from \"./useRowWindow.js\";\n\n/** `createRendererRegistry(tableRenderer, …)`: the `table` tab, paged, with the schema editor. */\nexport const tableRenderer: RendererDefinition = {\n name: \"table\",\n component: TableRenderer,\n icon: Table2,\n labelKey: \"TAB_TABLE\",\n paging: true,\n editMode: true,\n};\n"],"mappings":";;;;;;;;AAoBA,IAAa,gBAAoC;CAC/C,MAAM;CACN,WAAW;CACX,MAAM;CACN,UAAU;CACV,QAAQ;CACR,UAAU;AACZ"}
@@ -2,6 +2,7 @@ import { useI18n } from "../i18n/i18n.js";
2
2
  import { CardDetailDialog } from "../kanban/CardDetailDialog.js";
3
3
  import { AllRowsStatus } from "../renderers/AllRowsStatus.js";
4
4
  import { EmptyState, ErrorState } from "../table/states.js";
5
+ import { busyToast } from "../udc/busy.js";
5
6
  import { useUdcAllRows, useUdcCollection, useUdcMutate } from "../udc/hooks.js";
6
7
  import { udcKeys } from "../udc/keys.js";
7
8
  import { useUdcClient } from "../udc/client.js";
@@ -182,7 +183,9 @@ function Tree({ collection, describe, filter, baseFilter, search, listSearch, fi
182
183
  };
183
184
  const mutate = useUdcMutate(collection);
184
185
  const fail = useCallback((err, title) => {
185
- if (isVersionConflict(err)) toast({
186
+ const busy = busyToast(err, t);
187
+ if (busy) toast(busy);
188
+ else if (isVersionConflict(err)) toast({
186
189
  variant: "warning",
187
190
  title: t("APP", "TREE_CONFLICT_TITLE"),
188
191
  description: t("APP", "TREE_CONFLICT_BODY")
@@ -368,6 +371,7 @@ function Tree({ collection, describe, filter, baseFilter, search, listSearch, fi
368
371
  style: { marginLeft: i % 3 * 20 }
369
372
  }, k))
370
373
  }) : topRows.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
374
+ collection,
371
375
  filtered,
372
376
  onClear: onClearFilters
373
377
  }) : /* @__PURE__ */ jsxs(DndContext, {
@@ -1 +1 @@
1
- {"version":3,"file":"TreeRenderer.js","names":[],"sources":["../../src/tree/TreeRenderer.tsx"],"sourcesContent":["import {\n type CollisionDetection,\n DndContext,\n type DragEndEvent,\n DragOverlay,\n type DragStartEvent,\n PointerSensor,\n pointerWithin,\n TouchSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n type FilterNode,\n isVersionConflict,\n type Row,\n type TreeOptions,\n UdcError,\n} from \"@jsudc/core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { ChevronsDownUp, ChevronsUpDown, ListTree } from \"lucide-react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useI18n } from \"../i18n/i18n.js\";\nimport { CardDetailDialog } from \"../kanban/CardDetailDialog.js\";\nimport { AllRowsStatus } from \"../renderers/AllRowsStatus.js\";\nimport type { RendererProps } from \"../renderers/types.js\";\nimport { EmptyState, ErrorState } from \"../table/states.js\";\nimport { useUdcAllRows, useUdcCollection, useUdcMutate } from \"../udc/hooks.js\";\nimport { udcKeys } from \"../udc/keys.js\";\nimport { useUdcClient } from \"../udc/provider.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\nimport { type TreeExpand, useTreeExpand } from \"./expand.js\";\nimport {\n type BuiltTree,\n buildTree,\n canDrop,\n type DropTarget,\n dropParent,\n idOf,\n lazyChildrenQuery,\n lazyRootsQuery,\n numberOf,\n parentOf,\n parseDropId,\n planDrop,\n reparentRequest,\n replyRow,\n searchExpansion,\n siblingsQuery,\n sortSiblings,\n} from \"./model.js\";\nimport { TreeNode, TreeNodeLabel } from \"./TreeNode.js\";\n\n/** A node moved in this session, drawn at its new place until the lists are read again. */\ninterface Moved {\n row: Row;\n parent: string | null;\n order: number;\n}\n\nexport interface TreeCtx {\n collection: string;\n opts: TreeOptions;\n describe: RendererProps[\"describe\"];\n lazy: boolean;\n /** What every lazy branch adds to its own condition: the data view's filter. */\n dataFilter: FilterNode | undefined;\n /** The text sent as `search` with every list (a source that answers search); absent otherwise. */\n dataSearch?: string | undefined;\n /** The highlighted search term (\"\" when none). */\n term: string;\n isOpen: (id: string, depth: number) => boolean;\n setOpen: (id: string, open: boolean) => void;\n /** Non-lazy: the children of a node as built from the loaded rows. */\n childrenOf: (id: string) => Row[];\n /** Rows moved in this session, by id. */\n moved: ReadonlyMap<string, Moved>;\n orphans: ReadonlySet<string>;\n can: { rename: boolean; reply: boolean; reparent: boolean };\n /** The id being dragged, and the loaded rows the drop targets are checked against. */\n drag: { id: string; rowsById: ReadonlyMap<string, Row> } | null;\n /** Lazy branches report the rows they loaded (for drop gating). */\n report: (parent: string, rows: Row[]) => void;\n onOpenDetail: (row: Row) => void;\n onRename: (row: Row, label: string) => Promise<void>;\n onReply: (parent: Row, text: string) => Promise<void>;\n}\n\nconst Ctx = createContext<TreeCtx | null>(null);\n\nexport function useTree(): TreeCtx {\n const ctx = useContext(Ctx);\n if (!ctx) throw new Error(\"useTree needs a <TreeRenderer> above it\");\n return ctx;\n}\n\n/** Rows as drawn under `parent`: the loaded ones minus those moved away, plus those moved here. */\nexport function withMoves(\n rows: readonly Row[],\n parent: string | null,\n moved: ReadonlyMap<string, Moved>,\n ctx: Pick<TreeCtx, \"opts\">,\n): Row[] {\n const { opts } = ctx;\n const stay = rows.filter((r) => {\n const m = moved.get(idOf(r));\n return !m || m.parent === parent;\n });\n const here = [...moved.values()]\n .filter((m) => m.parent === parent && !stay.some((r) => idOf(r) === idOf(m.row)))\n .map((m) => m.row);\n const patched = [...stay, ...here].map((r) => {\n const m = moved.get(idOf(r));\n return m ? { ...r, [opts.parent_field]: m.parent, [opts.order_field]: m.order } : r;\n });\n return sortSiblings(patched, opts.sibling_sort);\n}\n\nexport function TreeRenderer(props: RendererProps) {\n const { t } = useI18n();\n const opts = props.describe.view.tree_options;\n if (!opts) {\n return (\n <div className=\"udc:p-6 udc:text-sm udc:text-muted-foreground\" data-testid=\"tree-no-options\">\n {t(\"APP\", \"TREE_NO_OPTIONS\")}\n </div>\n );\n }\n return <Tree {...props} opts={opts} />;\n}\n\nconst SKELETON = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"];\n\nfunction Tree({\n collection,\n describe,\n filter,\n baseFilter,\n search,\n listSearch,\n filtered,\n onClearFilters,\n onCount,\n opts,\n}: RendererProps & { opts: TreeOptions }) {\n const { Button, Skeleton, useToast } = useUiKit();\n const { t } = useI18n();\n const { toast } = useToast();\n const client = useUdcClient();\n const qc = useQueryClient();\n const { capabilities, schema, view } = describe;\n const lazy = opts.lazy;\n const term = search.trim();\n // highlight_and_expand on a loaded tree searches in the browser; anything else asks the server.\n const clientSearch = !lazy && opts.on_search.mode === \"highlight_and_expand\";\n // A source that answers search gets the text, unless the tree searches what it loaded.\n const serverSearch = clientSearch ? undefined : listSearch;\n // A lazy tree lists the matches of a filter flat; a source search alone is such a filter too.\n const dataFilter: FilterNode | undefined = clientSearch\n ? baseFilter\n : (filter ?? (serverSearch === undefined ? undefined : { and: [] }));\n const highlight = opts.on_search.mode === \"highlight_and_expand\" ? term : \"\";\n\n // --- rows ----------------------------------------------------------------------\n const all = useUdcAllRows({\n collection,\n filter: dataFilter,\n sort: opts.sibling_sort,\n capabilities,\n enabled: !lazy,\n refetchInterval: describe.view.refresh_interval_ms,\n search: serverSearch,\n });\n const rootsQ = lazyRootsQuery(opts, dataFilter);\n const roots = useUdcCollection({\n collection,\n filter: rootsQ.filter,\n sort: rootsQ.sort ?? [],\n mode: \"pages\",\n pageLimit: rootsQ.limit,\n enabled: lazy,\n search: serverSearch,\n });\n const totalQ = useUdcCollection({\n collection,\n filter: dataFilter,\n mode: \"pages\",\n pageLimit: 1,\n enabled: lazy,\n search: serverSearch,\n });\n\n const [moved, setMoved] = useState<ReadonlyMap<string, Moved>>(new Map());\n const tree: BuiltTree = useMemo(\n () =>\n buildTree(\n all.rows.map((r) => {\n const m = moved.get(idOf(r));\n return m ? { ...r, [opts.parent_field]: m.parent, [opts.order_field]: m.order } : r;\n }),\n opts,\n ),\n [all.rows, moved, opts],\n );\n\n // A filtered lazy tree lists every match; those under a listed parent show when it opens.\n const lazyRoots = useMemo(() => {\n const ids = new Set(roots.rows.map(idOf));\n const top = roots.rows.filter((r) => {\n const p = parentOf(r, opts);\n return p === null || !ids.has(p);\n });\n return withMoves(top, null, moved, { opts });\n }, [roots.rows, moved, opts]);\n const lazyOrphans = useMemo(\n () => new Set(lazyRoots.filter((r) => parentOf(r, opts) !== null).map(idOf)),\n [lazyRoots, opts],\n );\n\n useEffect(() => {\n onCount(\n lazy\n ? totalQ.total === null\n ? null\n : { shown: lazyRoots.length, total: totalQ.total, unit: \"nodes\" }\n : all.total === null\n ? null\n : { shown: all.rows.length, total: all.rows.length, unit: \"nodes\" },\n );\n }, [onCount, lazy, lazyRoots.length, totalQ.total, all.rows.length, all.total]);\n useEffect(() => () => onCount(null), [onCount]);\n\n // --- expand state (with the search's own, while there is a term) ---------------------\n const expand: TreeExpand = useTreeExpand(opts, collection);\n const expansion = useMemo(\n () =>\n clientSearch && term\n ? searchExpansion(tree, term, view.search?.fields ?? [opts.label_field], opts)\n : null,\n [clientSearch, term, tree, view.search?.fields, opts],\n );\n const [searchToggles, setSearchToggles] = useState<ReadonlyMap<string, boolean>>(new Map());\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new term starts from its own expansion\n useEffect(() => setSearchToggles(new Map()), [term]);\n // A filtered lazy tree lists matches at every depth: none is opened by default.\n const defaultsOn = !(lazy && dataFilter !== undefined);\n\n const isOpen = useCallback(\n (id: string, depth: number) => {\n if (expansion) {\n const toggled = searchToggles.get(id);\n if (toggled !== undefined) return toggled;\n if (expansion.open.has(id)) return true;\n return !opts.on_search.collapse_others && expand.isOpen(id, depth);\n }\n return expand.isOpen(id, defaultsOn ? depth : Number.POSITIVE_INFINITY);\n },\n [expansion, searchToggles, opts.on_search.collapse_others, expand, defaultsOn],\n );\n const setOpen = useCallback(\n (id: string, open: boolean) => {\n if (expansion) setSearchToggles((m) => new Map(m).set(id, open));\n else expand.set(id, open);\n },\n [expansion, expand],\n );\n\n // --- writes -------------------------------------------------------------------------\n const can = {\n rename: opts.interactive.rename && capabilities.mutate,\n reply: opts.interactive.reply && capabilities.mutate,\n reparent: opts.interactive.reparent && capabilities.mutate && capabilities.tree_reparent,\n };\n const mutate = useUdcMutate(collection);\n const fail = useCallback(\n (err: unknown, title: string) => {\n if (isVersionConflict(err)) {\n toast({\n variant: \"warning\",\n title: t(\"APP\", \"TREE_CONFLICT_TITLE\"),\n description: t(\"APP\", \"TREE_CONFLICT_BODY\"),\n });\n } else {\n toast({ variant: \"danger\", title, description: (err as Error).message });\n }\n },\n [toast, t],\n );\n\n const onRename = async (row: Row, label: string) => {\n try {\n await mutate.mutateAsync({\n op: \"update\",\n id: idOf(row),\n row: { [opts.label_field]: label },\n expected_version: row.__meta.version,\n });\n } catch (err) {\n fail(err, t(\"APP\", \"TREE_RENAME_FAILED\"));\n }\n };\n\n const onReply = async (parent: Row, text: string) => {\n try {\n await mutate.mutateAsync({\n op: \"insert\",\n row: replyRow(\n opts,\n schema,\n parent,\n tree.children.get(idOf(parent)) ?? [],\n text,\n new Date(),\n ),\n });\n setOpen(idOf(parent), true);\n } catch (err) {\n fail(err, t(\"APP\", \"TREE_REPLY_FAILED\"));\n throw err;\n }\n };\n\n // --- drag and drop ---------------------------------------------------------------------\n const branches = useRef(new Map<string, Row[]>());\n const report = useCallback((parent: string, rows: Row[]) => {\n branches.current.set(parent, rows);\n }, []);\n const loadedRows = (): Map<string, Row> => {\n if (!lazy) return new Map(tree.byId);\n const map = new Map<string, Row>();\n for (const r of roots.rows) map.set(idOf(r), r);\n for (const rows of branches.current.values()) for (const r of rows) map.set(idOf(r), r);\n for (const m of moved.values()) {\n map.set(idOf(m.row), {\n ...m.row,\n [opts.parent_field]: m.parent,\n [opts.order_field]: m.order,\n });\n }\n return map;\n };\n const [drag, setDrag] = useState<TreeCtx[\"drag\"]>(null);\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),\n useSensor(TouchSensor, { activationConstraint: { delay: 180, tolerance: 6 } }),\n );\n // The gap strip above a row wins over the row it overlaps.\n const collision: CollisionDetection = (args) =>\n pointerWithin(args).sort(\n (a, b) =>\n Number(String(b.id).startsWith(\"before:\")) - Number(String(a.id).startsWith(\"before:\")),\n );\n\n const onDragStart = (e: DragStartEvent) =>\n setDrag({ id: String(e.active.id), rowsById: loadedRows() });\n\n const siblingOrders = async (parent: string | null) => {\n const q = siblingsQuery(opts, parent);\n const res = await client.list({ collection, ...q, page: { limit: q.limit } });\n return res.rows.map((r) => ({ id: idOf(r), order: numberOf(r, opts.order_field), row: r }));\n };\n\n const move = async (dragId: string, target: DropTarget, rowsById: ReadonlyMap<string, Row>) => {\n const parent = dropParent(target, rowsById, opts);\n const row = rowsById.get(dragId);\n if (parent === undefined || !row) return;\n // Drawn at once: last under the new parent, or just above the target.\n const above = numberOf(rowsById.get(target.id), opts.order_field);\n const provisional =\n target.kind === \"before\" && above !== null ? above - 0.5 : Number.MAX_SAFE_INTEGER;\n setMoved((m) => new Map(m).set(dragId, { row, parent, order: provisional }));\n if (parent !== null) setOpen(parent, true);\n try {\n let siblings = await siblingOrders(parent);\n let plan = planDrop(dragId, target, parent, siblings);\n let version = row.__meta.version;\n if (plan.collision) {\n if (parent === null) throw new UdcError(\"internal\", t(\"APP\", \"TREE_NO_ROOM\"));\n await client.reindex({\n collection,\n scope: { [opts.parent_field]: parent },\n order_field: opts.order_field,\n });\n siblings = await siblingOrders(parent);\n plan = planDrop(dragId, target, parent, siblings);\n if (plan.collision) throw new UdcError(\"internal\", t(\"APP\", \"TREE_NO_ROOM\"));\n // A reindex of the node's own siblings bumped its version too.\n version = siblings.find((s) => s.id === dragId)?.row.__meta.version ?? version;\n }\n await client.treeReparent(reparentRequest(collection, opts, plan, version));\n } catch (err) {\n fail(err, t(\"APP\", \"TREE_MOVE_FAILED\"));\n } finally {\n await qc.invalidateQueries({ queryKey: udcKeys.lists(collection) });\n setMoved((m) => {\n const next = new Map(m);\n next.delete(dragId);\n return next;\n });\n }\n };\n\n const onDragEnd = (e: DragEndEvent) => {\n const current = drag;\n setDrag(null);\n const target = e.over ? parseDropId(String(e.over.id)) : null;\n if (!current || !target || !canDrop(current.id, target, current.rowsById, opts)) return;\n void move(current.id, target, current.rowsById);\n };\n\n // --- detail -------------------------------------------------------------------------------\n const [detail, setDetail] = useState<Row | null>(null);\n\n const ctx: TreeCtx = {\n collection,\n opts,\n describe,\n lazy,\n dataFilter,\n dataSearch: serverSearch,\n term: highlight,\n isOpen,\n setOpen,\n childrenOf: (id) => tree.children.get(id) ?? [],\n moved,\n orphans: lazy ? lazyOrphans : tree.orphans,\n can,\n drag,\n report,\n onOpenDetail: setDetail,\n onRename,\n onReply,\n };\n\n const topRows = lazy ? lazyRoots : tree.roots;\n const loading = lazy ? roots.isLoading : all.isLoading;\n const error = lazy ? roots.error : all.error;\n const allIds = () => [...tree.children.keys()];\n const dragRow = drag ? drag.rowsById.get(drag.id) : undefined;\n\n return (\n <Ctx.Provider value={ctx}>\n <div\n className=\"udc-tree udc:flex udc:min-h-0 udc:flex-1 udc:flex-col\"\n data-testid=\"tree\"\n data-lazy={lazy || undefined}\n data-searching={expansion ? true : undefined}\n >\n {lazy ? null : <AllRowsStatus result={all} />}\n <div className=\"udc:flex udc:items-center udc:gap-1 udc:border-b udc:border-border udc:bg-muted/30 udc:px-3 udc:py-1.5\">\n {lazy ? null : (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n data-testid=\"tree-expand-all\"\n onClick={() => expand.expandAll(allIds())}\n >\n <ChevronsUpDown />\n {t(\"APP\", \"TREE_EXPAND_ALL\")}\n </Button>\n )}\n <Button\n size=\"sm\"\n variant=\"ghost\"\n data-testid=\"tree-collapse-all\"\n onClick={() => {\n setSearchToggles(new Map([...tree.children.keys()].map((id) => [id, false])));\n expand.collapseAll();\n }}\n >\n <ChevronsDownUp />\n {t(\"APP\", \"TREE_COLLAPSE_ALL\")}\n </Button>\n </div>\n <div className=\"udc-scroll-thin udc:min-h-0 udc:flex-1 udc:overflow-auto udc:py-1\">\n {error ? (\n <ErrorState\n error={error}\n onRetry={() => void (lazy ? roots.refetch() : all.refetch())}\n />\n ) : loading ? (\n <div className=\"udc:flex udc:flex-col udc:gap-2 udc:p-4\">\n {SKELETON.map((k, i) => (\n <Skeleton key={k} className=\"udc:h-6\" style={{ marginLeft: (i % 3) * 20 }} />\n ))}\n </div>\n ) : topRows.length === 0 ? (\n <EmptyState filtered={filtered} onClear={onClearFilters} />\n ) : (\n <DndContext\n sensors={sensors}\n collisionDetection={collision}\n onDragStart={onDragStart}\n onDragEnd={onDragEnd}\n onDragCancel={() => setDrag(null)}\n >\n <div role=\"tree\" aria-label={t(\"COLLECTIONS\", collection)} data-testid=\"tree-root\">\n <NodeList rows={topRows} depth={0} />\n </div>\n <DragOverlay dropAnimation={null}>\n {dragRow ? (\n <div className=\"udc:flex udc:max-w-md udc:items-center udc:gap-2 udc:rounded-md udc:border udc:border-border udc:bg-surface udc:px-3 udc:py-1.5 udc:text-[13px] udc:shadow-lg udc:shadow-black/15\">\n <ListTree className=\"udc:size-3.5 udc:text-muted-foreground\" />\n <TreeNodeLabel row={dragRow} />\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n )}\n </div>\n </div>\n <CardDetailDialog\n row={detail ?? undefined}\n describe={describe}\n collection={collection}\n labels={{}}\n titleField={opts.label_field}\n bodyField={undefined}\n testId=\"tree-detail\"\n onClose={() => setDetail(null)}\n />\n </Ctx.Provider>\n );\n}\n\nexport function NodeList({ rows, depth }: { rows: readonly Row[]; depth: number }) {\n return (\n // biome-ignore lint/a11y/useSemanticElements: an ARIA tree group has no native element\n <div role=\"group\">\n {rows.map((row) => (\n <TreeNode key={idOf(row)} row={row} depth={depth} />\n ))}\n </div>\n );\n}\n\n/** One level of a lazy tree, read when its parent opens. */\nexport function LazyChildren({ parent, depth }: { parent: string; depth: number }) {\n const { Spinner } = useUiKit();\n const { t } = useI18n();\n const ctx = useTree();\n const { opts, collection, moved, report, dataFilter, dataSearch } = ctx;\n const q = lazyChildrenQuery(opts, parent, dataFilter);\n const res = useUdcCollection({\n collection,\n filter: q.filter,\n sort: q.sort ?? [],\n mode: \"pages\",\n pageLimit: q.limit,\n search: dataSearch,\n });\n useEffect(() => report(parent, res.rows), [report, parent, res.rows]);\n const rows = withMoves(res.rows, parent, moved, ctx);\n if (res.isLoading) {\n return (\n <div\n className=\"udc:flex udc:items-center udc:gap-2 udc:py-1 udc:text-xs udc:text-muted-foreground\"\n style={{ paddingLeft: 12 + (depth + 1) * 20 }}\n data-testid=\"tree-branch-loading\"\n >\n <Spinner className=\"udc:size-3.5\" />\n {t(\"APP\", \"TREE_LOADING\")}\n </div>\n );\n }\n return <NodeList rows={rows} depth={depth + 1} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgGA,IAAM,MAAM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CAAI,CAAC;CACpE,MAAM,OAAO,UAAU,IAAI,MAAM,QAAQ,OAAO,GAAG;CACnD,IAAI,IAAI,WACN,OACE,qBAAC,OAAD;EACE,WAAU;EACV,OAAO,EAAE,aAAa,MAAM,QAAQ,KAAK,GAAG;EAC5C,eAAY;EAHd,UAAA,CAKE,oBAAC,SAAD,EAAS,WAAU,eAAgB,CAAA,GAClC,EAAE,OAAO,cAAc,CACrB;;CAGT,OAAO,oBAAC,UAAD;EAAgB;EAAM,OAAO,QAAQ;CAAI,CAAA;AAClD"}
1
+ {"version":3,"file":"TreeRenderer.js","names":[],"sources":["../../src/tree/TreeRenderer.tsx"],"sourcesContent":["import {\n type CollisionDetection,\n DndContext,\n type DragEndEvent,\n DragOverlay,\n type DragStartEvent,\n PointerSensor,\n pointerWithin,\n TouchSensor,\n useSensor,\n useSensors,\n} from \"@dnd-kit/core\";\nimport {\n type FilterNode,\n isVersionConflict,\n type Row,\n type TreeOptions,\n UdcError,\n} from \"@jsudc/core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport { ChevronsDownUp, ChevronsUpDown, ListTree } from \"lucide-react\";\nimport {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { useI18n } from \"../i18n/i18n.js\";\nimport { CardDetailDialog } from \"../kanban/CardDetailDialog.js\";\nimport { AllRowsStatus } from \"../renderers/AllRowsStatus.js\";\nimport type { RendererProps } from \"../renderers/types.js\";\nimport { EmptyState, ErrorState } from \"../table/states.js\";\nimport { busyToast } from \"../udc/busy.js\";\nimport { useUdcAllRows, useUdcCollection, useUdcMutate } from \"../udc/hooks.js\";\nimport { udcKeys } from \"../udc/keys.js\";\nimport { useUdcClient } from \"../udc/provider.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\nimport { type TreeExpand, useTreeExpand } from \"./expand.js\";\nimport {\n type BuiltTree,\n buildTree,\n canDrop,\n type DropTarget,\n dropParent,\n idOf,\n lazyChildrenQuery,\n lazyRootsQuery,\n numberOf,\n parentOf,\n parseDropId,\n planDrop,\n reparentRequest,\n replyRow,\n searchExpansion,\n siblingsQuery,\n sortSiblings,\n} from \"./model.js\";\nimport { TreeNode, TreeNodeLabel } from \"./TreeNode.js\";\n\n/** A node moved in this session, drawn at its new place until the lists are read again. */\ninterface Moved {\n row: Row;\n parent: string | null;\n order: number;\n}\n\nexport interface TreeCtx {\n collection: string;\n opts: TreeOptions;\n describe: RendererProps[\"describe\"];\n lazy: boolean;\n /** What every lazy branch adds to its own condition: the data view's filter. */\n dataFilter: FilterNode | undefined;\n /** The text sent as `search` with every list (a source that answers search); absent otherwise. */\n dataSearch?: string | undefined;\n /** The highlighted search term (\"\" when none). */\n term: string;\n isOpen: (id: string, depth: number) => boolean;\n setOpen: (id: string, open: boolean) => void;\n /** Non-lazy: the children of a node as built from the loaded rows. */\n childrenOf: (id: string) => Row[];\n /** Rows moved in this session, by id. */\n moved: ReadonlyMap<string, Moved>;\n orphans: ReadonlySet<string>;\n can: { rename: boolean; reply: boolean; reparent: boolean };\n /** The id being dragged, and the loaded rows the drop targets are checked against. */\n drag: { id: string; rowsById: ReadonlyMap<string, Row> } | null;\n /** Lazy branches report the rows they loaded (for drop gating). */\n report: (parent: string, rows: Row[]) => void;\n onOpenDetail: (row: Row) => void;\n onRename: (row: Row, label: string) => Promise<void>;\n onReply: (parent: Row, text: string) => Promise<void>;\n}\n\nconst Ctx = createContext<TreeCtx | null>(null);\n\nexport function useTree(): TreeCtx {\n const ctx = useContext(Ctx);\n if (!ctx) throw new Error(\"useTree needs a <TreeRenderer> above it\");\n return ctx;\n}\n\n/** Rows as drawn under `parent`: the loaded ones minus those moved away, plus those moved here. */\nexport function withMoves(\n rows: readonly Row[],\n parent: string | null,\n moved: ReadonlyMap<string, Moved>,\n ctx: Pick<TreeCtx, \"opts\">,\n): Row[] {\n const { opts } = ctx;\n const stay = rows.filter((r) => {\n const m = moved.get(idOf(r));\n return !m || m.parent === parent;\n });\n const here = [...moved.values()]\n .filter((m) => m.parent === parent && !stay.some((r) => idOf(r) === idOf(m.row)))\n .map((m) => m.row);\n const patched = [...stay, ...here].map((r) => {\n const m = moved.get(idOf(r));\n return m ? { ...r, [opts.parent_field]: m.parent, [opts.order_field]: m.order } : r;\n });\n return sortSiblings(patched, opts.sibling_sort);\n}\n\nexport function TreeRenderer(props: RendererProps) {\n const { t } = useI18n();\n const opts = props.describe.view.tree_options;\n if (!opts) {\n return (\n <div className=\"udc:p-6 udc:text-sm udc:text-muted-foreground\" data-testid=\"tree-no-options\">\n {t(\"APP\", \"TREE_NO_OPTIONS\")}\n </div>\n );\n }\n return <Tree {...props} opts={opts} />;\n}\n\nconst SKELETON = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"];\n\nfunction Tree({\n collection,\n describe,\n filter,\n baseFilter,\n search,\n listSearch,\n filtered,\n onClearFilters,\n onCount,\n opts,\n}: RendererProps & { opts: TreeOptions }) {\n const { Button, Skeleton, useToast } = useUiKit();\n const { t } = useI18n();\n const { toast } = useToast();\n const client = useUdcClient();\n const qc = useQueryClient();\n const { capabilities, schema, view } = describe;\n const lazy = opts.lazy;\n const term = search.trim();\n // highlight_and_expand on a loaded tree searches in the browser; anything else asks the server.\n const clientSearch = !lazy && opts.on_search.mode === \"highlight_and_expand\";\n // A source that answers search gets the text, unless the tree searches what it loaded.\n const serverSearch = clientSearch ? undefined : listSearch;\n // A lazy tree lists the matches of a filter flat; a source search alone is such a filter too.\n const dataFilter: FilterNode | undefined = clientSearch\n ? baseFilter\n : (filter ?? (serverSearch === undefined ? undefined : { and: [] }));\n const highlight = opts.on_search.mode === \"highlight_and_expand\" ? term : \"\";\n\n // --- rows ----------------------------------------------------------------------\n const all = useUdcAllRows({\n collection,\n filter: dataFilter,\n sort: opts.sibling_sort,\n capabilities,\n enabled: !lazy,\n refetchInterval: describe.view.refresh_interval_ms,\n search: serverSearch,\n });\n const rootsQ = lazyRootsQuery(opts, dataFilter);\n const roots = useUdcCollection({\n collection,\n filter: rootsQ.filter,\n sort: rootsQ.sort ?? [],\n mode: \"pages\",\n pageLimit: rootsQ.limit,\n enabled: lazy,\n search: serverSearch,\n });\n const totalQ = useUdcCollection({\n collection,\n filter: dataFilter,\n mode: \"pages\",\n pageLimit: 1,\n enabled: lazy,\n search: serverSearch,\n });\n\n const [moved, setMoved] = useState<ReadonlyMap<string, Moved>>(new Map());\n const tree: BuiltTree = useMemo(\n () =>\n buildTree(\n all.rows.map((r) => {\n const m = moved.get(idOf(r));\n return m ? { ...r, [opts.parent_field]: m.parent, [opts.order_field]: m.order } : r;\n }),\n opts,\n ),\n [all.rows, moved, opts],\n );\n\n // A filtered lazy tree lists every match; those under a listed parent show when it opens.\n const lazyRoots = useMemo(() => {\n const ids = new Set(roots.rows.map(idOf));\n const top = roots.rows.filter((r) => {\n const p = parentOf(r, opts);\n return p === null || !ids.has(p);\n });\n return withMoves(top, null, moved, { opts });\n }, [roots.rows, moved, opts]);\n const lazyOrphans = useMemo(\n () => new Set(lazyRoots.filter((r) => parentOf(r, opts) !== null).map(idOf)),\n [lazyRoots, opts],\n );\n\n useEffect(() => {\n onCount(\n lazy\n ? totalQ.total === null\n ? null\n : { shown: lazyRoots.length, total: totalQ.total, unit: \"nodes\" }\n : all.total === null\n ? null\n : { shown: all.rows.length, total: all.rows.length, unit: \"nodes\" },\n );\n }, [onCount, lazy, lazyRoots.length, totalQ.total, all.rows.length, all.total]);\n useEffect(() => () => onCount(null), [onCount]);\n\n // --- expand state (with the search's own, while there is a term) ---------------------\n const expand: TreeExpand = useTreeExpand(opts, collection);\n const expansion = useMemo(\n () =>\n clientSearch && term\n ? searchExpansion(tree, term, view.search?.fields ?? [opts.label_field], opts)\n : null,\n [clientSearch, term, tree, view.search?.fields, opts],\n );\n const [searchToggles, setSearchToggles] = useState<ReadonlyMap<string, boolean>>(new Map());\n // biome-ignore lint/correctness/useExhaustiveDependencies: a new term starts from its own expansion\n useEffect(() => setSearchToggles(new Map()), [term]);\n // A filtered lazy tree lists matches at every depth: none is opened by default.\n const defaultsOn = !(lazy && dataFilter !== undefined);\n\n const isOpen = useCallback(\n (id: string, depth: number) => {\n if (expansion) {\n const toggled = searchToggles.get(id);\n if (toggled !== undefined) return toggled;\n if (expansion.open.has(id)) return true;\n return !opts.on_search.collapse_others && expand.isOpen(id, depth);\n }\n return expand.isOpen(id, defaultsOn ? depth : Number.POSITIVE_INFINITY);\n },\n [expansion, searchToggles, opts.on_search.collapse_others, expand, defaultsOn],\n );\n const setOpen = useCallback(\n (id: string, open: boolean) => {\n if (expansion) setSearchToggles((m) => new Map(m).set(id, open));\n else expand.set(id, open);\n },\n [expansion, expand],\n );\n\n // --- writes -------------------------------------------------------------------------\n const can = {\n rename: opts.interactive.rename && capabilities.mutate,\n reply: opts.interactive.reply && capabilities.mutate,\n reparent: opts.interactive.reparent && capabilities.mutate && capabilities.tree_reparent,\n };\n const mutate = useUdcMutate(collection);\n const fail = useCallback(\n (err: unknown, title: string) => {\n const busy = busyToast(err, t);\n if (busy) {\n toast(busy);\n } else if (isVersionConflict(err)) {\n toast({\n variant: \"warning\",\n title: t(\"APP\", \"TREE_CONFLICT_TITLE\"),\n description: t(\"APP\", \"TREE_CONFLICT_BODY\"),\n });\n } else {\n toast({ variant: \"danger\", title, description: (err as Error).message });\n }\n },\n [toast, t],\n );\n\n const onRename = async (row: Row, label: string) => {\n try {\n await mutate.mutateAsync({\n op: \"update\",\n id: idOf(row),\n row: { [opts.label_field]: label },\n expected_version: row.__meta.version,\n });\n } catch (err) {\n fail(err, t(\"APP\", \"TREE_RENAME_FAILED\"));\n }\n };\n\n const onReply = async (parent: Row, text: string) => {\n try {\n await mutate.mutateAsync({\n op: \"insert\",\n row: replyRow(\n opts,\n schema,\n parent,\n tree.children.get(idOf(parent)) ?? [],\n text,\n new Date(),\n ),\n });\n setOpen(idOf(parent), true);\n } catch (err) {\n fail(err, t(\"APP\", \"TREE_REPLY_FAILED\"));\n throw err;\n }\n };\n\n // --- drag and drop ---------------------------------------------------------------------\n const branches = useRef(new Map<string, Row[]>());\n const report = useCallback((parent: string, rows: Row[]) => {\n branches.current.set(parent, rows);\n }, []);\n const loadedRows = (): Map<string, Row> => {\n if (!lazy) return new Map(tree.byId);\n const map = new Map<string, Row>();\n for (const r of roots.rows) map.set(idOf(r), r);\n for (const rows of branches.current.values()) for (const r of rows) map.set(idOf(r), r);\n for (const m of moved.values()) {\n map.set(idOf(m.row), {\n ...m.row,\n [opts.parent_field]: m.parent,\n [opts.order_field]: m.order,\n });\n }\n return map;\n };\n const [drag, setDrag] = useState<TreeCtx[\"drag\"]>(null);\n const sensors = useSensors(\n useSensor(PointerSensor, { activationConstraint: { distance: 5 } }),\n useSensor(TouchSensor, { activationConstraint: { delay: 180, tolerance: 6 } }),\n );\n // The gap strip above a row wins over the row it overlaps.\n const collision: CollisionDetection = (args) =>\n pointerWithin(args).sort(\n (a, b) =>\n Number(String(b.id).startsWith(\"before:\")) - Number(String(a.id).startsWith(\"before:\")),\n );\n\n const onDragStart = (e: DragStartEvent) =>\n setDrag({ id: String(e.active.id), rowsById: loadedRows() });\n\n const siblingOrders = async (parent: string | null) => {\n const q = siblingsQuery(opts, parent);\n const res = await client.list({ collection, ...q, page: { limit: q.limit } });\n return res.rows.map((r) => ({ id: idOf(r), order: numberOf(r, opts.order_field), row: r }));\n };\n\n const move = async (dragId: string, target: DropTarget, rowsById: ReadonlyMap<string, Row>) => {\n const parent = dropParent(target, rowsById, opts);\n const row = rowsById.get(dragId);\n if (parent === undefined || !row) return;\n // Drawn at once: last under the new parent, or just above the target.\n const above = numberOf(rowsById.get(target.id), opts.order_field);\n const provisional =\n target.kind === \"before\" && above !== null ? above - 0.5 : Number.MAX_SAFE_INTEGER;\n setMoved((m) => new Map(m).set(dragId, { row, parent, order: provisional }));\n if (parent !== null) setOpen(parent, true);\n try {\n let siblings = await siblingOrders(parent);\n let plan = planDrop(dragId, target, parent, siblings);\n let version = row.__meta.version;\n if (plan.collision) {\n if (parent === null) throw new UdcError(\"internal\", t(\"APP\", \"TREE_NO_ROOM\"));\n await client.reindex({\n collection,\n scope: { [opts.parent_field]: parent },\n order_field: opts.order_field,\n });\n siblings = await siblingOrders(parent);\n plan = planDrop(dragId, target, parent, siblings);\n if (plan.collision) throw new UdcError(\"internal\", t(\"APP\", \"TREE_NO_ROOM\"));\n // A reindex of the node's own siblings bumped its version too.\n version = siblings.find((s) => s.id === dragId)?.row.__meta.version ?? version;\n }\n await client.treeReparent(reparentRequest(collection, opts, plan, version));\n } catch (err) {\n fail(err, t(\"APP\", \"TREE_MOVE_FAILED\"));\n } finally {\n await qc.invalidateQueries({ queryKey: udcKeys.lists(collection) });\n setMoved((m) => {\n const next = new Map(m);\n next.delete(dragId);\n return next;\n });\n }\n };\n\n const onDragEnd = (e: DragEndEvent) => {\n const current = drag;\n setDrag(null);\n const target = e.over ? parseDropId(String(e.over.id)) : null;\n if (!current || !target || !canDrop(current.id, target, current.rowsById, opts)) return;\n void move(current.id, target, current.rowsById);\n };\n\n // --- detail -------------------------------------------------------------------------------\n const [detail, setDetail] = useState<Row | null>(null);\n\n const ctx: TreeCtx = {\n collection,\n opts,\n describe,\n lazy,\n dataFilter,\n dataSearch: serverSearch,\n term: highlight,\n isOpen,\n setOpen,\n childrenOf: (id) => tree.children.get(id) ?? [],\n moved,\n orphans: lazy ? lazyOrphans : tree.orphans,\n can,\n drag,\n report,\n onOpenDetail: setDetail,\n onRename,\n onReply,\n };\n\n const topRows = lazy ? lazyRoots : tree.roots;\n const loading = lazy ? roots.isLoading : all.isLoading;\n const error = lazy ? roots.error : all.error;\n const allIds = () => [...tree.children.keys()];\n const dragRow = drag ? drag.rowsById.get(drag.id) : undefined;\n\n return (\n <Ctx.Provider value={ctx}>\n <div\n className=\"udc-tree udc:flex udc:min-h-0 udc:flex-1 udc:flex-col\"\n data-testid=\"tree\"\n data-lazy={lazy || undefined}\n data-searching={expansion ? true : undefined}\n >\n {lazy ? null : <AllRowsStatus result={all} />}\n <div className=\"udc:flex udc:items-center udc:gap-1 udc:border-b udc:border-border udc:bg-muted/30 udc:px-3 udc:py-1.5\">\n {lazy ? null : (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n data-testid=\"tree-expand-all\"\n onClick={() => expand.expandAll(allIds())}\n >\n <ChevronsUpDown />\n {t(\"APP\", \"TREE_EXPAND_ALL\")}\n </Button>\n )}\n <Button\n size=\"sm\"\n variant=\"ghost\"\n data-testid=\"tree-collapse-all\"\n onClick={() => {\n setSearchToggles(new Map([...tree.children.keys()].map((id) => [id, false])));\n expand.collapseAll();\n }}\n >\n <ChevronsDownUp />\n {t(\"APP\", \"TREE_COLLAPSE_ALL\")}\n </Button>\n </div>\n <div className=\"udc-scroll-thin udc:min-h-0 udc:flex-1 udc:overflow-auto udc:py-1\">\n {error ? (\n <ErrorState\n error={error}\n onRetry={() => void (lazy ? roots.refetch() : all.refetch())}\n />\n ) : loading ? (\n <div className=\"udc:flex udc:flex-col udc:gap-2 udc:p-4\">\n {SKELETON.map((k, i) => (\n <Skeleton key={k} className=\"udc:h-6\" style={{ marginLeft: (i % 3) * 20 }} />\n ))}\n </div>\n ) : topRows.length === 0 ? (\n <EmptyState collection={collection} filtered={filtered} onClear={onClearFilters} />\n ) : (\n <DndContext\n sensors={sensors}\n collisionDetection={collision}\n onDragStart={onDragStart}\n onDragEnd={onDragEnd}\n onDragCancel={() => setDrag(null)}\n >\n <div role=\"tree\" aria-label={t(\"COLLECTIONS\", collection)} data-testid=\"tree-root\">\n <NodeList rows={topRows} depth={0} />\n </div>\n <DragOverlay dropAnimation={null}>\n {dragRow ? (\n <div className=\"udc:flex udc:max-w-md udc:items-center udc:gap-2 udc:rounded-md udc:border udc:border-border udc:bg-surface udc:px-3 udc:py-1.5 udc:text-[13px] udc:shadow-lg udc:shadow-black/15\">\n <ListTree className=\"udc:size-3.5 udc:text-muted-foreground\" />\n <TreeNodeLabel row={dragRow} />\n </div>\n ) : null}\n </DragOverlay>\n </DndContext>\n )}\n </div>\n </div>\n <CardDetailDialog\n row={detail ?? undefined}\n describe={describe}\n collection={collection}\n labels={{}}\n titleField={opts.label_field}\n bodyField={undefined}\n testId=\"tree-detail\"\n onClose={() => setDetail(null)}\n />\n </Ctx.Provider>\n );\n}\n\nexport function NodeList({ rows, depth }: { rows: readonly Row[]; depth: number }) {\n return (\n // biome-ignore lint/a11y/useSemanticElements: an ARIA tree group has no native element\n <div role=\"group\">\n {rows.map((row) => (\n <TreeNode key={idOf(row)} row={row} depth={depth} />\n ))}\n </div>\n );\n}\n\n/** One level of a lazy tree, read when its parent opens. */\nexport function LazyChildren({ parent, depth }: { parent: string; depth: number }) {\n const { Spinner } = useUiKit();\n const { t } = useI18n();\n const ctx = useTree();\n const { opts, collection, moved, report, dataFilter, dataSearch } = ctx;\n const q = lazyChildrenQuery(opts, parent, dataFilter);\n const res = useUdcCollection({\n collection,\n filter: q.filter,\n sort: q.sort ?? [],\n mode: \"pages\",\n pageLimit: q.limit,\n search: dataSearch,\n });\n useEffect(() => report(parent, res.rows), [report, parent, res.rows]);\n const rows = withMoves(res.rows, parent, moved, ctx);\n if (res.isLoading) {\n return (\n <div\n className=\"udc:flex udc:items-center udc:gap-2 udc:py-1 udc:text-xs udc:text-muted-foreground\"\n style={{ paddingLeft: 12 + (depth + 1) * 20 }}\n data-testid=\"tree-branch-loading\"\n >\n <Spinner className=\"udc:size-3.5\" />\n {t(\"APP\", \"TREE_LOADING\")}\n </div>\n );\n }\n return <NodeList rows={rows} depth={depth + 1} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiGA,IAAM,MAAM,cAA8B,IAAI;AAE9C,SAAgB,UAAmB;CACjC,MAAM,MAAM,WAAW,GAAG;CAC1B,IAAI,CAAC,KAAK,MAAM,IAAI,MAAM,yCAAyC;CACnE,OAAO;AACT;;AAGA,SAAgB,UACd,MACA,QACA,OACA,KACO;CACP,MAAM,EAAE,SAAS;CACjB,MAAM,OAAO,KAAK,QAAQ,MAAM;EAC9B,MAAM,IAAI,MAAM,IAA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A,CAKE,oBAAC,SAAD,EAAS,WAAU,eAAgB,CAAA,GAClC,EAAE,OAAO,cAAc,CACrB;;CAGT,OAAO,oBAAC,UAAD;EAAgB;EAAM,OAAO,QAAQ;CAAI,CAAA;AAClD"}
@@ -0,0 +1,9 @@
1
+ import type { ToastInput } from "../ui-kit/types.js";
2
+ /**
3
+ * The toast for a write the server refused with `busy` (@jsudc/core 0.7.0):
4
+ * another writer held the data's lock longer than the server waits — another
5
+ * process writing the same SQLite file, say. Nothing was written and the same
6
+ * write may simply be tried again, so it is a warning that says so, not a
7
+ * failure carrying the server's text. `null` for any other error.
8
+ */
9
+ export declare function busyToast(err: unknown, t: (section: string, term: string) => string): ToastInput | null;
@@ -0,0 +1,20 @@
1
+ import { isBusy } from "@jsudc/core";
2
+ // src/udc/busy.ts
3
+ /**
4
+ * The toast for a write the server refused with `busy` (@jsudc/core 0.7.0):
5
+ * another writer held the data's lock longer than the server waits — another
6
+ * process writing the same SQLite file, say. Nothing was written and the same
7
+ * write may simply be tried again, so it is a warning that says so, not a
8
+ * failure carrying the server's text. `null` for any other error.
9
+ */
10
+ function busyToast(err, t) {
11
+ if (!isBusy(err)) return null;
12
+ return {
13
+ variant: "warning",
14
+ title: t("APP", "BUSY_TITLE"),
15
+ description: t("APP", "BUSY_BODY")
16
+ };
17
+ }
18
+ export { busyToast };
19
+
20
+ //# sourceMappingURL=busy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"busy.js","names":[],"sources":["../../src/udc/busy.ts"],"sourcesContent":["import { isBusy } from \"@jsudc/core\";\nimport type { ToastInput } from \"../ui-kit/types.js\";\n\n/**\n * The toast for a write the server refused with `busy` (@jsudc/core 0.7.0):\n * another writer held the data's lock longer than the server waits — another\n * process writing the same SQLite file, say. Nothing was written and the same\n * write may simply be tried again, so it is a warning that says so, not a\n * failure carrying the server's text. `null` for any other error.\n */\nexport function busyToast(\n err: unknown,\n t: (section: string, term: string) => string,\n): ToastInput | null {\n if (!isBusy(err)) return null;\n return { variant: \"warning\", title: t(\"APP\", \"BUSY_TITLE\"), description: t(\"APP\", \"BUSY_BODY\") };\n}\n"],"mappings":";;;;;;;;;AAUA,SAAgB,UACd,KACA,GACmB;CACnB,IAAI,CAAC,OAAO,GAAG,GAAG,OAAO;CACzB,OAAO;EAAE,SAAS;EAAW,OAAO,EAAE,OAAO,YAAY;EAAG,aAAa,EAAE,OAAO,WAAW;CAAE;AACjG"}
@@ -6,7 +6,8 @@ export declare const UdcClientContext: import("react").Context<UdcClient | null>
6
6
  export declare function useUdcClient(): UdcClient;
7
7
  /**
8
8
  * A protocol error is the server's answer, not a hiccup: asking again gives
9
- * the same answer. Only transport failures are retried, twice.
9
+ * the same answer. Only transport failures and `busy` (another writer held the
10
+ * lock past the server's wait; @jsudc/core 0.7.0) are retried, twice.
10
11
  */
11
12
  export declare function shouldRetry(failureCount: number, error: unknown): boolean;
12
13
  export interface UdcQueryClientOptions {
@@ -1,5 +1,5 @@
1
1
  import { registerUnauthenticated } from "./unauthenticated.js";
2
- import { isUdcError, isUnauthenticated } from "@jsudc/core";
2
+ import { isBusy, isUdcError, isUnauthenticated } from "@jsudc/core";
3
3
  import { createContext, useContext } from "react";
4
4
  import { MutationCache, QueryCache, QueryClient } from "@tanstack/react-query";
5
5
  // src/udc/client.ts
@@ -12,10 +12,11 @@ function useUdcClient() {
12
12
  }
13
13
  /**
14
14
  * A protocol error is the server's answer, not a hiccup: asking again gives
15
- * the same answer. Only transport failures are retried, twice.
15
+ * the same answer. Only transport failures and `busy` (another writer held the
16
+ * lock past the server's wait; @jsudc/core 0.7.0) are retried, twice.
16
17
  */
17
18
  function shouldRetry(failureCount, error) {
18
- return !isUdcError(error) && failureCount < 2;
19
+ return (!isUdcError(error) || isBusy(error)) && failureCount < 2;
19
20
  }
20
21
  /**
21
22
  * Calls `fn` on the first unauthenticated error and swallows the rest until
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":[],"sources":["../../src/udc/client.ts"],"sourcesContent":["import { isUdcError, isUnauthenticated, type UdcError } from \"@jsudc/core\";\nimport type { UdcClient } from \"@jsudc/core/client\";\nimport { MutationCache, QueryCache, QueryClient } from \"@tanstack/react-query\";\nimport { createContext, useContext } from \"react\";\nimport { registerUnauthenticated } from \"./unauthenticated.js\";\n\n/** The client every hook talks to; `UdcProvider` sets it. */\nexport const UdcClientContext = createContext<UdcClient | null>(null);\n\nexport function useUdcClient(): UdcClient {\n const client = useContext(UdcClientContext);\n if (!client) throw new Error(\"useUdcClient needs a <UdcProvider client={...}> above it\");\n return client;\n}\n\n/**\n * A protocol error is the server's answer, not a hiccup: asking again gives\n * the same answer. Only transport failures are retried, twice.\n */\nexport function shouldRetry(failureCount: number, error: unknown): boolean {\n return !isUdcError(error) && failureCount < 2;\n}\n\nexport interface UdcQueryClientOptions {\n /**\n * Called when a query or a mutation fails because the user is not signed in\n * (`isUnauthenticated`: an HTTP 401 in front of `/udc`, or the server's\n * in-protocol refusal) — the place to send the user to the host's login.\n * Once per burst: the failures that arrive together (every query of a page,\n * say) make one call; it fires again only after `unauthenticatedQuietMs`\n * without such a failure.\n */\n onUnauthenticated?: (error: UdcError) => void;\n /** The quiet time, in ms, that ends a burst of unauthenticated failures. Default 2000. */\n unauthenticatedQuietMs?: number;\n}\n\n/**\n * Calls `fn` on the first unauthenticated error and swallows the rest until\n * `quietMs` pass without one (each further error restarts that wait).\n */\nfunction unauthenticatedNotifier(\n fn: (error: UdcError) => void,\n quietMs: number,\n): (error: unknown) => void {\n let lastAt: number | null = null;\n return (error) => {\n if (!isUnauthenticated(error)) return;\n const now = Date.now();\n const inBurst = lastAt !== null && now - lastAt < quietMs;\n lastAt = now;\n if (!inBurst) fn(error as UdcError);\n };\n}\n\nexport function createUdcQueryClient(options: UdcQueryClientOptions = {}): QueryClient {\n const notify = options.onUnauthenticated\n ? unauthenticatedNotifier(options.onUnauthenticated, options.unauthenticatedQuietMs ?? 2000)\n : undefined;\n const qc = new QueryClient({\n ...(notify\n ? {\n queryCache: new QueryCache({ onError: notify }),\n mutationCache: new MutationCache({ onError: notify }),\n }\n : {}),\n defaultOptions: {\n queries: { retry: shouldRetry, refetchOnWindowFocus: false },\n mutations: { retry: false },\n },\n });\n // The change feed's unauthenticated error takes the same path (and the same burst).\n if (notify) registerUnauthenticated(qc, notify);\n return qc;\n}\n"],"mappings":";;;;;;AAOA,IAAa,mBAAmB,cAAgC,IAAI;AAEpE,SAAgB,eAA0B;CACxC,MAAM,SAAS,WAAW,gBAAgB;CAC1C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,0DAA0D;CACvF,OAAO;AACT;;;;;AAMA,SAAgB,YAAY,cAAsB,OAAyB;CACzE,OAAO,CAAC,WAAW,KAAK,KAAK,eAAe;AAC9C;;;;;AAoBA,SAAS,wBACP,IACA,SAC0B;CAC1B,IAAI,SAAwB;CAC5B,QAAQ,UAAU;EAChB,IAAI,CAAC,kBAAkB,KAAK,GAAG;EAC/B,MAAM,MAAM,KAAK,IAAI;EACrB,MAAM,UAAU,WAAW,QAAQ,MAAM,SAAS;EAClD,SAAS;EACT,IAAI,CAAC,SAAS,GAAG,KAAiB;CACpC;AACF;AAEA,SAAgB,qBAAqB,UAAiC,CAAC,GAAgB;CACrF,MAAM,SAAS,QAAQ,oBACnB,wBAAwB,QAAQ,mBAAmB,QAAQ,0BAA0B,GAAI,IACzF,KAAA;CACJ,MAAM,KAAK,IAAI,YAAY;EACzB,GAAI,SACA;GACE,YAAY,IAAI,WAAW,EAAE,SAAS,OAAO,CAAC;GAC9C,eAAe,IAAI,cAAc,EAAE,SAAS,OAAO,CAAC;EACtD,IACA,CAAC;EACL,gBAAgB;GACd,SAAS;IAAE,OAAO;IAAa,sBAAsB;GAAM;GAC3D,WAAW,EAAE,OAAO,MAAM;EAC5B;CACF,CAAC;CAED,IAAI,QAAQ,wBAAwB,IAAI,MAAM;CAC9C,OAAO;AACT"}
1
+ {"version":3,"file":"client.js","names":[],"sources":["../../src/udc/client.ts"],"sourcesContent":["import { isBusy, isUdcError, isUnauthenticated, type UdcError } from \"@jsudc/core\";\nimport type { UdcClient } from \"@jsudc/core/client\";\nimport { MutationCache, QueryCache, QueryClient } from \"@tanstack/react-query\";\nimport { createContext, useContext } from \"react\";\nimport { registerUnauthenticated } from \"./unauthenticated.js\";\n\n/** The client every hook talks to; `UdcProvider` sets it. */\nexport const UdcClientContext = createContext<UdcClient | null>(null);\n\nexport function useUdcClient(): UdcClient {\n const client = useContext(UdcClientContext);\n if (!client) throw new Error(\"useUdcClient needs a <UdcProvider client={...}> above it\");\n return client;\n}\n\n/**\n * A protocol error is the server's answer, not a hiccup: asking again gives\n * the same answer. Only transport failures and `busy` (another writer held the\n * lock past the server's wait; @jsudc/core 0.7.0) are retried, twice.\n */\nexport function shouldRetry(failureCount: number, error: unknown): boolean {\n return (!isUdcError(error) || isBusy(error)) && failureCount < 2;\n}\n\nexport interface UdcQueryClientOptions {\n /**\n * Called when a query or a mutation fails because the user is not signed in\n * (`isUnauthenticated`: an HTTP 401 in front of `/udc`, or the server's\n * in-protocol refusal) — the place to send the user to the host's login.\n * Once per burst: the failures that arrive together (every query of a page,\n * say) make one call; it fires again only after `unauthenticatedQuietMs`\n * without such a failure.\n */\n onUnauthenticated?: (error: UdcError) => void;\n /** The quiet time, in ms, that ends a burst of unauthenticated failures. Default 2000. */\n unauthenticatedQuietMs?: number;\n}\n\n/**\n * Calls `fn` on the first unauthenticated error and swallows the rest until\n * `quietMs` pass without one (each further error restarts that wait).\n */\nfunction unauthenticatedNotifier(\n fn: (error: UdcError) => void,\n quietMs: number,\n): (error: unknown) => void {\n let lastAt: number | null = null;\n return (error) => {\n if (!isUnauthenticated(error)) return;\n const now = Date.now();\n const inBurst = lastAt !== null && now - lastAt < quietMs;\n lastAt = now;\n if (!inBurst) fn(error as UdcError);\n };\n}\n\nexport function createUdcQueryClient(options: UdcQueryClientOptions = {}): QueryClient {\n const notify = options.onUnauthenticated\n ? unauthenticatedNotifier(options.onUnauthenticated, options.unauthenticatedQuietMs ?? 2000)\n : undefined;\n const qc = new QueryClient({\n ...(notify\n ? {\n queryCache: new QueryCache({ onError: notify }),\n mutationCache: new MutationCache({ onError: notify }),\n }\n : {}),\n defaultOptions: {\n queries: { retry: shouldRetry, refetchOnWindowFocus: false },\n mutations: { retry: false },\n },\n });\n // The change feed's unauthenticated error takes the same path (and the same burst).\n if (notify) registerUnauthenticated(qc, notify);\n return qc;\n}\n"],"mappings":";;;;;;AAOA,IAAa,mBAAmB,cAAgC,IAAI;AAEpE,SAAgB,eAA0B;CACxC,MAAM,SAAS,WAAW,gBAAgB;CAC1C,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,0DAA0D;CACvF,OAAO;AACT;;;;;;AAOA,SAAgB,YAAY,cAAsB,OAAyB;CACzE,QAAQ,CAAC,WAAW,KAAK,KAAK,OAAO,KAAK,MAAM,eAAe;AACjE;;;;;AAoBA,SAAS,wBACP,IACA,SAC0B;CAC1B,IAAI,SAAwB;CAC5B,QAAQ,UAAU;EAChB,IAAI,CAAC,kBAAkB,KAAK,GAAG;EAC/B,MAAM,MAAM,KAAK,IAAI;EACrB,MAAM,UAAU,WAAW,QAAQ,MAAM,SAAS;EAClD,SAAS;EACT,IAAI,CAAC,SAAS,GAAG,KAAiB;CACpC;AACF;AAEA,SAAgB,qBAAqB,UAAiC,CAAC,GAAgB;CACrF,MAAM,SAAS,QAAQ,oBACnB,wBAAwB,QAAQ,mBAAmB,QAAQ,0BAA0B,GAAI,IACzF,KAAA;CACJ,MAAM,KAAK,IAAI,YAAY;EACzB,GAAI,SACA;GACE,YAAY,IAAI,WAAW,EAAE,SAAS,OAAO,CAAC;GAC9C,eAAe,IAAI,cAAc,EAAE,SAAS,OAAO,CAAC;EACtD,IACA,CAAC;EACL,gBAAgB;GACd,SAAS;IAAE,OAAO;IAAa,sBAAsB;GAAM;GAC3D,WAAW,EAAE,OAAO,MAAM;EAC5B;CACF,CAAC;CAED,IAAI,QAAQ,wBAAwB,IAAI,MAAM;CAC9C,OAAO;AACT"}
@@ -25,7 +25,7 @@ export declare function useUdcCollections(): import("@tanstack/react-query").Use
25
25
  search?: "source" | undefined;
26
26
  changes?: boolean | undefined;
27
27
  };
28
- source_kind: "postgres_jsonb" | "memory" | "filesystem" | "http_api" | "yaml_menu" | "postgres_table";
28
+ source_kind: "postgres_jsonb" | "memory" | "filesystem" | "http_api" | "yaml_menu" | "postgres_table" | "sqlite_table";
29
29
  label?: string | undefined;
30
30
  group?: "database" | "files" | "internet" | undefined;
31
31
  }[];
@@ -50,7 +50,7 @@ export declare function useUdcDescribe(collection: string, opts?: {
50
50
  search?: "source" | undefined;
51
51
  changes?: boolean | undefined;
52
52
  };
53
- source_kind: "postgres_jsonb" | "memory" | "filesystem" | "http_api" | "yaml_menu" | "postgres_table";
53
+ source_kind: "postgres_jsonb" | "memory" | "filesystem" | "http_api" | "yaml_menu" | "postgres_table" | "sqlite_table";
54
54
  schema: {
55
55
  field_order: string[];
56
56
  version: string;
@@ -87,25 +87,37 @@ export declare function useUdcDescribe(collection: string, opts?: {
87
87
  id?: string | undefined;
88
88
  pin?: "left" | "right" | null | undefined;
89
89
  editable?: boolean | undefined;
90
- width?: number | undefined;
90
+ width?: number | "fill" | undefined;
91
+ grow?: number | undefined;
92
+ min_width?: number | undefined;
93
+ hide_below?: number | undefined;
91
94
  render?: string | undefined;
92
95
  render_options?: Record<string, unknown> | undefined;
93
96
  align?: "left" | "right" | "center" | undefined;
94
97
  transform?: string | string[] | undefined;
95
98
  color?: "success" | "default" | "accent" | "warning" | "danger" | "info" | "muted" | undefined;
96
99
  bg?: "success" | "default" | "accent" | "warning" | "danger" | "info" | "muted" | undefined;
100
+ hidden?: boolean | undefined;
101
+ sortable?: boolean | undefined;
97
102
  }[];
98
103
  page_size_default: number;
99
104
  pagination: "infinite" | "pages";
100
105
  default_column_width: number;
101
106
  row_actions: string[];
107
+ columns_mode?: "all" | "listed" | undefined;
102
108
  row_height?: number | undefined;
103
109
  search?: {
104
110
  [x: string]: unknown;
105
111
  fields: string[];
106
112
  case_insensitive: boolean;
107
- placeholder?: string | undefined;
113
+ placeholder
114
+ /** From `describe`: whether the source pages by cursor, and offers the change feed. */
115
+ ? /** From `describe`: whether the source pages by cursor, and offers the change feed. */: string | undefined;
108
116
  } | undefined;
117
+ default_sort?: {
118
+ field: string;
119
+ dir?: "asc" | "desc" | undefined;
120
+ }[] | undefined;
109
121
  filters?: {
110
122
  [x: string]: unknown;
111
123
  field: string;
@@ -426,6 +438,9 @@ export declare function useUdcDescribe(collection: string, opts?: {
426
438
  en?: string | undefined;
427
439
  sr?: string | undefined;
428
440
  } | undefined;
441
+ sortable?: {
442
+ fields: string[];
443
+ } | undefined;
429
444
  }, Error>;
430
445
  /** The file a `source_yaml` collection is read from (`source.read`); fetched again on every mount. */
431
446
  export declare function useUdcSource(collection: string, opts?: {
@@ -749,7 +764,7 @@ export declare function useUdcMutateMany(collection: string): UseMutationResult<
749
764
  updated: number;
750
765
  failed: {
751
766
  id: string;
752
- code: "not_found" | "validation_error" | "version_conflict" | "forbidden" | "unsupported_op" | "internal";
767
+ code: "not_found" | "validation_error" | "version_conflict" | "forbidden" | "unsupported_op" | "busy" | "internal";
753
768
  message?: string | undefined;
754
769
  }[];
755
770
  }, Error, UdcMutateManyVars, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsudc/react",
3
- "version": "0.5.1",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "React components for UDC collections: the data view, its table, cards, kanban, calendar, tree, map and chart renderers (one subpath each), the schema editor, headless hooks and models, i18n, theme and a compiled, udc:-prefixed stylesheet.",
@@ -120,7 +120,7 @@
120
120
  "@dnd-kit/core": "^6.3.1",
121
121
  "@dnd-kit/sortable": "^10.0.0",
122
122
  "@dnd-kit/utilities": "^3.2.2",
123
- "@jsudc/core": "^0.5.0",
123
+ "@jsudc/core": "^0.7.0",
124
124
  "@tanstack/react-query": "^5.104.4",
125
125
  "@tanstack/react-table": "^8.21.3",
126
126
  "leaflet": "^1.9.4",
@@ -159,7 +159,7 @@
159
159
  "@dnd-kit/core": "^6.3.1",
160
160
  "@dnd-kit/sortable": "^10.0.0",
161
161
  "@dnd-kit/utilities": "^3.2.2",
162
- "@jsudc/core": "^0.5.0",
162
+ "@jsudc/core": "^0.7.0",
163
163
  "@tailwindcss/cli": "^4.3.3",
164
164
  "@tanstack/react-query": "^5.104.4",
165
165
  "@tanstack/react-table": "^8.21.3",