@jsudc/react 0.3.1 → 0.5.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 (144) hide show
  1. package/README.md +1137 -22
  2. package/dist/actions/RowActionsMenu.d.ts +45 -0
  3. package/dist/actions/RowActionsMenu.js +161 -0
  4. package/dist/actions/RowActionsMenu.js.map +1 -0
  5. package/dist/actions/bulk.d.ts +81 -0
  6. package/dist/actions/bulk.js +54 -0
  7. package/dist/actions/bulk.js.map +1 -0
  8. package/dist/actions/row.d.ts +50 -0
  9. package/dist/actions/row.js +34 -0
  10. package/dist/actions/row.js.map +1 -0
  11. package/dist/actions/useRowActionRunner.d.ts +26 -0
  12. package/dist/actions/useRowActionRunner.js +198 -0
  13. package/dist/actions/useRowActionRunner.js.map +1 -0
  14. package/dist/calendar/CalendarRenderer.js +5 -4
  15. package/dist/calendar/CalendarRenderer.js.map +1 -1
  16. package/dist/calendar/EventDetail.js +1 -1
  17. package/dist/calendar.js +1 -1
  18. package/dist/cards/CardRenderer.d.ts +8 -1
  19. package/dist/cards/CardRenderer.js +179 -110
  20. package/dist/cards/CardRenderer.js.map +1 -1
  21. package/dist/cells/registry.d.ts +60 -0
  22. package/dist/cells/registry.js +47 -0
  23. package/dist/cells/registry.js.map +1 -0
  24. package/dist/chart/ChartRenderer.js +6 -4
  25. package/dist/chart/ChartRenderer.js.map +1 -1
  26. package/dist/chart/ChartWindowControl.js +2 -2
  27. package/dist/components/ui/checkbox.js +1 -1
  28. package/dist/components/ui/dialog.js +4 -3
  29. package/dist/components/ui/dialog.js.map +1 -1
  30. package/dist/components/ui/dropdown-menu.js +2 -1
  31. package/dist/components/ui/dropdown-menu.js.map +1 -1
  32. package/dist/components/ui/popover.js +2 -1
  33. package/dist/components/ui/popover.js.map +1 -1
  34. package/dist/components/ui/select.js +2 -1
  35. package/dist/components/ui/select.js.map +1 -1
  36. package/dist/components/ui/toast.js +3 -2
  37. package/dist/components/ui/toast.js.map +1 -1
  38. package/dist/components/ui/tooltip.js +2 -1
  39. package/dist/components/ui/tooltip.js.map +1 -1
  40. package/dist/data-view/BulkBar.d.ts +36 -0
  41. package/dist/data-view/BulkBar.js +239 -0
  42. package/dist/data-view/BulkBar.js.map +1 -0
  43. package/dist/data-view/FilePreview.js +1 -1
  44. package/dist/data-view/FilterBuilder.js +2 -2
  45. package/dist/data-view/FilterChips.js +2 -2
  46. package/dist/data-view/Freshness.js +1 -1
  47. package/dist/data-view/LiveIndicator.d.ts +10 -0
  48. package/dist/data-view/LiveIndicator.js +33 -0
  49. package/dist/data-view/LiveIndicator.js.map +1 -0
  50. package/dist/data-view/SearchBox.js +1 -1
  51. package/dist/data-view/UdcDataView.d.ts +110 -1
  52. package/dist/data-view/UdcDataView.js +237 -90
  53. package/dist/data-view/UdcDataView.js.map +1 -1
  54. package/dist/data-view/useDataViewState.d.ts +8 -0
  55. package/dist/data-view/useDataViewState.js +2 -1
  56. package/dist/data-view/useDataViewState.js.map +1 -1
  57. package/dist/headless.d.ts +9 -0
  58. package/dist/headless.js +12 -2
  59. package/dist/i18n/translations.js +136 -0
  60. package/dist/i18n/translations.js.map +1 -1
  61. package/dist/index.d.ts +15 -4
  62. package/dist/index.js +17 -4
  63. package/dist/kanban/KanbanCard.js +1 -1
  64. package/dist/kanban/KanbanColumn.js +1 -1
  65. package/dist/kanban/KanbanRenderer.js +6 -5
  66. package/dist/kanban/KanbanRenderer.js.map +1 -1
  67. package/dist/lib/scope.d.ts +8 -0
  68. package/dist/lib/scope.js +12 -0
  69. package/dist/lib/scope.js.map +1 -0
  70. package/dist/lookup/LookupCombobox.js +1 -1
  71. package/dist/lookup/batch.js +1 -1
  72. package/dist/lookup/options.js +4 -1
  73. package/dist/lookup/options.js.map +1 -1
  74. package/dist/lookup/useUdcLookup.js +9 -3
  75. package/dist/lookup/useUdcLookup.js.map +1 -1
  76. package/dist/map/MapRenderer.js +4 -3
  77. package/dist/map/MapRenderer.js.map +1 -1
  78. package/dist/renderers/types.d.ts +44 -1
  79. package/dist/renderers/types.js.map +1 -1
  80. package/dist/rows/useRowActivation.d.ts +91 -0
  81. package/dist/rows/useRowActivation.js +257 -0
  82. package/dist/rows/useRowActivation.js.map +1 -0
  83. package/dist/rows/useRowSelection.d.ts +92 -0
  84. package/dist/rows/useRowSelection.js +156 -0
  85. package/dist/rows/useRowSelection.js.map +1 -0
  86. package/dist/schema-editor/DeleteFieldDialog.js +2 -2
  87. package/dist/schema-editor/FieldFormDialog.js +2 -2
  88. package/dist/schema-editor/TagInput.js +1 -1
  89. package/dist/styles.css +1 -1
  90. package/dist/styles.scoped.css +2 -0
  91. package/dist/table/CellEditor.js +2 -1
  92. package/dist/table/CellEditor.js.map +1 -1
  93. package/dist/table/SelectCheckbox.d.ts +15 -0
  94. package/dist/table/SelectCheckbox.js +37 -0
  95. package/dist/table/SelectCheckbox.js.map +1 -0
  96. package/dist/table/TableRenderer.d.ts +15 -1
  97. package/dist/table/TableRenderer.js +305 -114
  98. package/dist/table/TableRenderer.js.map +1 -1
  99. package/dist/table/cells.d.ts +13 -2
  100. package/dist/table/cells.js +15 -2
  101. package/dist/table/cells.js.map +1 -1
  102. package/dist/table/index.d.ts +1 -0
  103. package/dist/table/states.d.ts +6 -0
  104. package/dist/table/states.js +14 -1
  105. package/dist/table/states.js.map +1 -1
  106. package/dist/table/useRowWindow.d.ts +82 -0
  107. package/dist/table/useRowWindow.js +182 -0
  108. package/dist/table/useRowWindow.js.map +1 -0
  109. package/dist/table.js.map +1 -1
  110. package/dist/tree/TreeNode.js +1 -1
  111. package/dist/tree/TreeRenderer.d.ts +2 -0
  112. package/dist/tree/TreeRenderer.js +16 -10
  113. package/dist/tree/TreeRenderer.js.map +1 -1
  114. package/dist/udc/changeFeed.d.ts +94 -0
  115. package/dist/udc/changeFeed.js +250 -0
  116. package/dist/udc/changeFeed.js.map +1 -0
  117. package/dist/udc/changes.d.ts +34 -0
  118. package/dist/udc/changes.js +79 -0
  119. package/dist/udc/changes.js.map +1 -0
  120. package/dist/udc/client.d.ts +15 -1
  121. package/dist/udc/client.js +34 -10
  122. package/dist/udc/client.js.map +1 -1
  123. package/dist/udc/hooks.d.ts +94 -16
  124. package/dist/udc/hooks.js +113 -10
  125. package/dist/udc/hooks.js.map +1 -1
  126. package/dist/udc/keys.d.ts +2 -0
  127. package/dist/udc/keys.js.map +1 -1
  128. package/dist/udc/listCache.d.ts +11 -0
  129. package/dist/udc/listCache.js +38 -0
  130. package/dist/udc/listCache.js.map +1 -0
  131. package/dist/udc/provider.d.ts +21 -3
  132. package/dist/udc/provider.js +23 -2
  133. package/dist/udc/provider.js.map +1 -1
  134. package/dist/udc/unauthenticated.d.ts +4 -0
  135. package/dist/udc/unauthenticated.js +17 -0
  136. package/dist/udc/unauthenticated.js.map +1 -0
  137. package/dist/ui-kit/types.d.ts +14 -0
  138. package/dist/ui-kit/ui.d.ts +1 -0
  139. package/dist/ui.js +2 -1
  140. package/dist/url-state/adapters.d.ts +23 -0
  141. package/dist/url-state/adapters.js +57 -0
  142. package/dist/url-state/adapters.js.map +1 -0
  143. package/dist/url-state/index.d.ts +1 -0
  144. package/package.json +6 -4
@@ -0,0 +1,239 @@
1
+ import { bulkActionEligible, planBulkAction, selectionTarget, useBulkActionHandlers } from "../actions/bulk.js";
2
+ import { useI18n } from "../i18n/i18n.js";
3
+ import { FALLBACK_ICON, resolveIcon } from "../icons/resolve.js";
4
+ import { humanize } from "../lib/storage.js";
5
+ import { useUdcClient } from "../udc/client.js";
6
+ import { callAction, useUdcMutateMany } from "../udc/hooks.js";
7
+ import { udcKeys } from "../udc/keys.js";
8
+ import { useUiKit } from "../ui-kit/context.js";
9
+ import { actionConfirms, isUdcError } from "@jsudc/core";
10
+ import { useState } from "react";
11
+ import { Archive, Check, Clock, Flag, FolderInput, Mail, MailOpen, Star, Tag, Trash2, X } from "lucide-react";
12
+ import { useQueryClient } from "@tanstack/react-query";
13
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
+ // src/data-view/BulkBar.tsx
15
+ var VARIANT = {
16
+ default: "primary",
17
+ outline: "outline",
18
+ destructive: "danger"
19
+ };
20
+ /** The icons a mailbox's bulk actions name most, beyond the bundled `LUCIDE_ICONS`. */
21
+ var ACTION_ICONS = {
22
+ archive: Archive,
23
+ check: Check,
24
+ clock: Clock,
25
+ flag: Flag,
26
+ "folder-input": FolderInput,
27
+ mail: Mail,
28
+ "mail-open": MailOpen,
29
+ star: Star,
30
+ tag: Tag,
31
+ "trash-2": Trash2
32
+ };
33
+ /** A def's `icon` (`lucide:<name>` or a bare name), or none when the name is not known. */
34
+ function actionIcon(name) {
35
+ if (!name) return null;
36
+ const bare = name.startsWith("lucide:") ? name.slice(7) : name;
37
+ const own = ACTION_ICONS[bare];
38
+ if (own) return own;
39
+ const icon = resolveIcon(`lucide:${bare}`);
40
+ return icon === FALLBACK_ICON ? null : icon;
41
+ }
42
+ /**
43
+ * The bar over the list while rows are selected: the count (or "all
44
+ * matching"), the offer to select every row that matches, one button per
45
+ * `view.bulk_actions` entry, and a clear button. Runs an action through the
46
+ * host's handler for its `kind`, else on the server (`planBulkAction`).
47
+ */
48
+ function BulkBar({ collection, section, defs, selection, filter, moreThanLoaded, total, handlers, allMatching = true }) {
49
+ const { Button, Dialog, DialogContent, DialogBody, DialogFooter, Spinner, useToast } = useUiKit();
50
+ const { toast } = useToast();
51
+ const { t, tMaybe, intlLocale } = useI18n();
52
+ const provided = useBulkActionHandlers();
53
+ const client = useUdcClient();
54
+ const qc = useQueryClient();
55
+ const mutateMany = useUdcMutateMany(collection);
56
+ const [pending, setPending] = useState(null);
57
+ const [running, setRunning] = useState(null);
58
+ const fmt = (n) => new Intl.NumberFormat(intlLocale).format(n);
59
+ const labelOf = (def) => tMaybe(section, `ACTION_${def.kind.toUpperCase()}`) ?? tMaybe("ACTIONS", def.kind) ?? def.label ?? (def.kind === "delete" ? t("APP", "BULK_DELETE") : humanize(def.kind));
60
+ const { count, mode } = selection;
61
+ const countText = mode === "ids" ? t("APP", "SELECTED_COUNT", { count: fmt(count ?? 0) }) : count === null ? t("APP", "SELECTED_ALL_MATCHING") : t("APP", "SELECTED_ALL_COUNT", { count: fmt(count) });
62
+ const couldOfferAll = mode === "ids" && selection.pageState === "all" && moreThanLoaded;
63
+ const offerAll = couldOfferAll && allMatching;
64
+ /** Report a `mutate_many`-shaped answer and settle the selection. */
65
+ const report = (def, label, res) => {
66
+ const failed = Array.isArray(res.failed) ? res.failed : [];
67
+ const updated = typeof res.updated === "number" ? res.updated : null;
68
+ const done = updated === null ? t("APP", "BULK_DONE", { action: label }) : def.kind === "delete" ? t("APP", "BULK_DELETED_COUNT", { count: fmt(updated) }) : t("APP", "BULK_DONE_COUNT", {
69
+ action: label,
70
+ count: fmt(updated)
71
+ });
72
+ if (failed.length > 0) {
73
+ toast({
74
+ variant: "warning",
75
+ title: t("APP", "BULK_FAILED_COUNT", { count: fmt(failed.length) }),
76
+ description: done
77
+ });
78
+ if (selection.mode === "ids") {
79
+ const chosen = new Set(selection.ids);
80
+ selection.setIds(failed.map((f) => f.id).filter((id) => chosen.has(id)));
81
+ } else selection.clear();
82
+ return;
83
+ }
84
+ toast({
85
+ variant: "success",
86
+ title: done
87
+ });
88
+ selection.clear();
89
+ };
90
+ const execute = async ({ def, plan, label }) => {
91
+ const target = selectionTarget(selection, filter);
92
+ setRunning(def.kind);
93
+ try {
94
+ if (plan.via === "host") await plan.handler({
95
+ kind: def.kind,
96
+ def,
97
+ collection,
98
+ ..."ids" in target ? { ids: target.ids } : {
99
+ filter: target.filter,
100
+ exceptIds: target.except_ids ?? []
101
+ },
102
+ rows: [...selection.rows],
103
+ clearSelection: selection.clear
104
+ });
105
+ else if (plan.via === "delete") report(def, label, await mutateMany.mutateAsync({
106
+ op: "delete",
107
+ ...target
108
+ }));
109
+ else if (plan.via === "set") report(def, label, await mutateMany.mutateAsync({
110
+ op: "update",
111
+ row: plan.patch,
112
+ ...target
113
+ }));
114
+ else try {
115
+ const answer = await callAction(client, plan.action, {
116
+ collection,
117
+ ...target
118
+ });
119
+ report(def, label, typeof answer === "object" && answer !== null ? answer : {});
120
+ } finally {
121
+ await Promise.all([qc.invalidateQueries({ queryKey: udcKeys.lists(collection) }), qc.invalidateQueries({ queryKey: udcKeys.lookups(collection) })]);
122
+ }
123
+ } catch (err) {
124
+ if (isUdcError(err) && err.code === "unsupported_op") toast({
125
+ variant: "danger",
126
+ title: t("APP", "BULK_UNSUPPORTED", { action: label }),
127
+ description: plan.via === "server" ? `udc.${plan.action}` : err.message
128
+ });
129
+ else toast({
130
+ variant: "danger",
131
+ title: t("APP", "BULK_FAILED", { action: label }),
132
+ description: err instanceof Error ? err.message : String(err)
133
+ });
134
+ } finally {
135
+ setRunning(null);
136
+ }
137
+ };
138
+ const run = (def) => {
139
+ const plan = planBulkAction(def, handlers, provided);
140
+ const job = {
141
+ def,
142
+ plan,
143
+ label: labelOf(def)
144
+ };
145
+ if (plan.via !== "host" && actionConfirms(def)) setPending(job);
146
+ else execute(job);
147
+ };
148
+ const confirmTitle = (p) => {
149
+ if (typeof p.def.confirm === "string") return p.def.confirm;
150
+ const n = selection.count;
151
+ if (p.plan.via === "delete") return n === null ? t("APP", "BULK_CONFIRM_DELETE_MATCHING") : t("APP", "BULK_CONFIRM_DELETE_COUNT", { count: fmt(n) });
152
+ return n === null ? t("APP", "BULK_CONFIRM_ACTION_MATCHING", { action: p.label }) : t("APP", "BULK_CONFIRM_ACTION_COUNT", {
153
+ action: p.label,
154
+ count: fmt(n)
155
+ });
156
+ };
157
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("div", {
158
+ role: "toolbar",
159
+ "aria-label": t("APP", "BULK_ACTIONS"),
160
+ "data-testid": "bulk-bar",
161
+ "data-mode": mode,
162
+ className: "udc-bulk-bar udc:flex udc:flex-wrap udc:items-center udc:gap-2 udc:border-b udc:border-border udc:bg-selected udc:px-3 udc:py-1.5 udc:text-[13px]",
163
+ children: [
164
+ /* @__PURE__ */ jsx("span", {
165
+ "data-testid": "bulk-count",
166
+ "data-count": count ?? void 0,
167
+ "aria-live": "polite",
168
+ className: "udc:font-medium udc:tabular-nums",
169
+ children: countText
170
+ }),
171
+ offerAll ? /* @__PURE__ */ jsx(Button, {
172
+ size: "sm",
173
+ variant: "ghost",
174
+ "data-testid": "select-all-matching",
175
+ className: "udc:text-primary",
176
+ onClick: selection.selectAllMatching,
177
+ children: total === null ? t("APP", "SELECT_ALL_MATCHING") : t("APP", "SELECT_ALL_MATCHING_COUNT", { count: fmt(total) })
178
+ }) : couldOfferAll ? /* @__PURE__ */ jsx("span", {
179
+ "data-testid": "select-all-matching-off",
180
+ className: "udc:text-muted-foreground",
181
+ children: t("APP", "SELECT_ALL_MATCHING_SEARCH")
182
+ }) : null,
183
+ /* @__PURE__ */ jsxs("div", {
184
+ className: "udc:ml-auto udc:flex udc:flex-wrap udc:items-center udc:gap-1.5",
185
+ children: [defs.map((def) => {
186
+ const label = labelOf(def);
187
+ const eligible = bulkActionEligible(def, selection);
188
+ const Icon = actionIcon(def.icon);
189
+ return /* @__PURE__ */ jsx("span", {
190
+ title: eligible ? void 0 : t("APP", "BULK_NOT_ELIGIBLE"),
191
+ children: /* @__PURE__ */ jsxs(Button, {
192
+ size: "sm",
193
+ variant: def.variant ? VARIANT[def.variant] : def.kind === "delete" ? "danger" : "outline",
194
+ "data-testid": `bulk-action-${def.kind}`,
195
+ disabled: !eligible || running !== null,
196
+ onClick: () => run(def),
197
+ children: [running === def.kind ? /* @__PURE__ */ jsx(Spinner, {}) : Icon ? /* @__PURE__ */ jsx(Icon, {}) : null, label]
198
+ })
199
+ }, def.kind);
200
+ }), /* @__PURE__ */ jsx(Button, {
201
+ size: "icon-sm",
202
+ variant: "ghost",
203
+ "data-testid": "bulk-clear",
204
+ "aria-label": t("APP", "SELECTION_CLEAR"),
205
+ onClick: selection.clear,
206
+ children: /* @__PURE__ */ jsx(X, {})
207
+ })]
208
+ })
209
+ ]
210
+ }), /* @__PURE__ */ jsx(Dialog, {
211
+ open: pending !== null,
212
+ onOpenChange: (open) => !open && setPending(null),
213
+ children: pending ? /* @__PURE__ */ jsxs(DialogContent, {
214
+ role: "alertdialog",
215
+ "data-testid": "bulk-confirm",
216
+ title: confirmTitle(pending),
217
+ children: [/* @__PURE__ */ jsx(DialogBody, {
218
+ className: "udc:text-[13px] udc:text-muted-foreground",
219
+ children: pending.plan.via === "delete" ? t("APP", "BULK_CONFIRM_DELETE_BODY") : pending.label
220
+ }), /* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(Button, {
221
+ variant: "ghost",
222
+ onClick: () => setPending(null),
223
+ children: t("APP", "CANCEL")
224
+ }), /* @__PURE__ */ jsx(Button, {
225
+ variant: pending.plan.via === "delete" ? "danger" : "primary",
226
+ "data-testid": "bulk-confirm-ok",
227
+ onClick: () => {
228
+ const job = pending;
229
+ setPending(null);
230
+ execute(job);
231
+ },
232
+ children: pending.plan.via === "delete" ? t("APP", "BULK_DELETE") : t("APP", "BULK_CONFIRM")
233
+ })] })]
234
+ }) : null
235
+ })] });
236
+ }
237
+ export { BulkBar, actionIcon };
238
+
239
+ //# sourceMappingURL=BulkBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BulkBar.js","names":["_Fragment"],"sources":["../../src/data-view/BulkBar.tsx"],"sourcesContent":["import {\n type ActionDef,\n actionConfirms,\n type FilterNode,\n isUdcError,\n type MutateManyResponse,\n} from \"@jsudc/core\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n Archive,\n Check,\n Clock,\n Flag,\n FolderInput,\n type LucideIcon,\n Mail,\n MailOpen,\n Star,\n Tag,\n Trash2,\n X,\n} from \"lucide-react\";\nimport { useState } from \"react\";\nimport {\n type BulkActionHandlers,\n type BulkActionPlan,\n bulkActionEligible,\n planBulkAction,\n selectionTarget,\n useBulkActionHandlers,\n} from \"../actions/bulk.js\";\nimport { useI18n } from \"../i18n/i18n.js\";\nimport { FALLBACK_ICON, resolveIcon } from \"../icons/resolve.js\";\nimport { humanize } from \"../lib/utils.js\";\nimport type { RowSelection } from \"../rows/useRowSelection.js\";\nimport { useUdcClient } from \"../udc/client.js\";\nimport { callAction, useUdcMutateMany } from \"../udc/hooks.js\";\nimport { udcKeys } from \"../udc/keys.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\nimport type { ButtonVariant } from \"../ui-kit/types.js\";\n\nexport interface BulkBarProps {\n collection: string;\n /** The collection's i18n section (`TBL_<COLLECTION>`). */\n section: string;\n /** `view.bulk_actions`; none: the bar only counts and clears. */\n defs: readonly ActionDef[];\n selection: RowSelection;\n /** The list's filter, composed: what \"all that match\" sends. */\n filter: FilterNode | undefined;\n /** More rows match than are loaded: \"select all that match\" is worth offering. */\n moreThanLoaded: boolean;\n /** The list's total; `null` when the source does not count. */\n total: number | null;\n /** The view's own handlers (`UdcDataView actions`), before the provider's. */\n handlers?: BulkActionHandlers | undefined;\n /**\n * `false`: \"select all that match\" is not offered, and a short hint says\n * why. `UdcDataView` sets it while the source answers the search (0.5.0):\n * `mutate_many` by filter cannot carry the search text, so it could not\n * name the same set. Default `true`.\n */\n allMatching?: boolean | undefined;\n}\n\nconst VARIANT: Record<NonNullable<ActionDef[\"variant\"]>, ButtonVariant> = {\n default: \"primary\",\n outline: \"outline\",\n destructive: \"danger\",\n};\n\n/** The icons a mailbox's bulk actions name most, beyond the bundled `LUCIDE_ICONS`. */\nconst ACTION_ICONS: Readonly<Record<string, LucideIcon>> = {\n archive: Archive,\n check: Check,\n clock: Clock,\n flag: Flag,\n \"folder-input\": FolderInput,\n mail: Mail,\n \"mail-open\": MailOpen,\n star: Star,\n tag: Tag,\n \"trash-2\": Trash2,\n};\n\n/** A def's `icon` (`lucide:<name>` or a bare name), or none when the name is not known. */\nexport function actionIcon(name: string | undefined): LucideIcon | null {\n if (!name) return null;\n const bare = name.startsWith(\"lucide:\") ? name.slice(\"lucide:\".length) : name;\n const own = ACTION_ICONS[bare];\n if (own) return own;\n const icon = resolveIcon(`lucide:${bare}`);\n return icon === FALLBACK_ICON ? null : icon;\n}\n\ntype Pending = { def: ActionDef; plan: BulkActionPlan; label: string };\n\n/**\n * The bar over the list while rows are selected: the count (or \"all\n * matching\"), the offer to select every row that matches, one button per\n * `view.bulk_actions` entry, and a clear button. Runs an action through the\n * host's handler for its `kind`, else on the server (`planBulkAction`).\n */\nexport function BulkBar({\n collection,\n section,\n defs,\n selection,\n filter,\n moreThanLoaded,\n total,\n handlers,\n allMatching = true,\n}: BulkBarProps) {\n const { Button, Dialog, DialogContent, DialogBody, DialogFooter, Spinner, useToast } = useUiKit();\n const { toast } = useToast();\n const { t, tMaybe, intlLocale } = useI18n();\n const provided = useBulkActionHandlers();\n const client = useUdcClient();\n const qc = useQueryClient();\n const mutateMany = useUdcMutateMany(collection);\n const [pending, setPending] = useState<Pending | null>(null);\n const [running, setRunning] = useState<string | null>(null);\n const fmt = (n: number) => new Intl.NumberFormat(intlLocale).format(n);\n\n const labelOf = (def: ActionDef) =>\n tMaybe(section, `ACTION_${def.kind.toUpperCase()}`) ??\n tMaybe(\"ACTIONS\", def.kind) ??\n def.label ??\n (def.kind === \"delete\" ? t(\"APP\", \"BULK_DELETE\") : humanize(def.kind));\n\n const { count, mode } = selection;\n const countText =\n mode === \"ids\"\n ? t(\"APP\", \"SELECTED_COUNT\", { count: fmt(count ?? 0) })\n : count === null\n ? t(\"APP\", \"SELECTED_ALL_MATCHING\")\n : t(\"APP\", \"SELECTED_ALL_COUNT\", { count: fmt(count) });\n const couldOfferAll = mode === \"ids\" && selection.pageState === \"all\" && moreThanLoaded;\n const offerAll = couldOfferAll && allMatching;\n\n /** Report a `mutate_many`-shaped answer and settle the selection. */\n const report = (def: ActionDef, label: string, res: Partial<MutateManyResponse>) => {\n const failed = Array.isArray(res.failed) ? res.failed : [];\n const updated = typeof res.updated === \"number\" ? res.updated : null;\n const done =\n updated === null\n ? t(\"APP\", \"BULK_DONE\", { action: label })\n : def.kind === \"delete\"\n ? t(\"APP\", \"BULK_DELETED_COUNT\", { count: fmt(updated) })\n : t(\"APP\", \"BULK_DONE_COUNT\", { action: label, count: fmt(updated) });\n if (failed.length > 0) {\n toast({\n variant: \"warning\",\n title: t(\"APP\", \"BULK_FAILED_COUNT\", { count: fmt(failed.length) }),\n description: done,\n });\n // The rows that did not change stay selected, to retry or look at.\n if (selection.mode === \"ids\") {\n const chosen = new Set(selection.ids);\n selection.setIds(failed.map((f) => f.id).filter((id) => chosen.has(id)));\n } else selection.clear();\n return;\n }\n toast({ variant: \"success\", title: done });\n selection.clear();\n };\n\n const execute = async ({ def, plan, label }: Pending) => {\n const target = selectionTarget(selection, filter);\n setRunning(def.kind);\n try {\n if (plan.via === \"host\") {\n await plan.handler({\n kind: def.kind,\n def,\n collection,\n ...(\"ids\" in target\n ? { ids: target.ids }\n : { filter: target.filter, exceptIds: target.except_ids ?? [] }),\n rows: [...selection.rows],\n clearSelection: selection.clear,\n });\n } else if (plan.via === \"delete\") {\n report(def, label, await mutateMany.mutateAsync({ op: \"delete\", ...target }));\n } else if (plan.via === \"set\") {\n report(\n def,\n label,\n await mutateMany.mutateAsync({ op: \"update\", row: plan.patch, ...target }),\n );\n } else {\n try {\n const answer = await callAction(client, plan.action, { collection, ...target });\n report(\n def,\n label,\n typeof answer === \"object\" && answer !== null\n ? (answer as Partial<MutateManyResponse>)\n : {},\n );\n } finally {\n await Promise.all([\n qc.invalidateQueries({ queryKey: udcKeys.lists(collection) }),\n qc.invalidateQueries({ queryKey: udcKeys.lookups(collection) }),\n ]);\n }\n }\n } catch (err) {\n if (isUdcError(err) && err.code === \"unsupported_op\") {\n toast({\n variant: \"danger\",\n title: t(\"APP\", \"BULK_UNSUPPORTED\", { action: label }),\n description: plan.via === \"server\" ? `udc.${plan.action}` : err.message,\n });\n } else {\n toast({\n variant: \"danger\",\n title: t(\"APP\", \"BULK_FAILED\", { action: label }),\n description: err instanceof Error ? err.message : String(err),\n });\n }\n } finally {\n setRunning(null);\n }\n };\n\n const run = (def: ActionDef) => {\n const plan = planBulkAction(def, handlers, provided);\n const job = { def, plan, label: labelOf(def) };\n // A host's handler asks its own questions; the built-in paths ask per `confirm`.\n if (plan.via !== \"host\" && actionConfirms(def)) setPending(job);\n else void execute(job);\n };\n\n const confirmTitle = (p: Pending) => {\n if (typeof p.def.confirm === \"string\") return p.def.confirm;\n const n = selection.count;\n if (p.plan.via === \"delete\") {\n return n === null\n ? t(\"APP\", \"BULK_CONFIRM_DELETE_MATCHING\")\n : t(\"APP\", \"BULK_CONFIRM_DELETE_COUNT\", { count: fmt(n) });\n }\n return n === null\n ? t(\"APP\", \"BULK_CONFIRM_ACTION_MATCHING\", { action: p.label })\n : t(\"APP\", \"BULK_CONFIRM_ACTION_COUNT\", { action: p.label, count: fmt(n) });\n };\n\n return (\n <>\n <div\n role=\"toolbar\"\n aria-label={t(\"APP\", \"BULK_ACTIONS\")}\n data-testid=\"bulk-bar\"\n data-mode={mode}\n className=\"udc-bulk-bar udc:flex udc:flex-wrap udc:items-center udc:gap-2 udc:border-b udc:border-border udc:bg-selected udc:px-3 udc:py-1.5 udc:text-[13px]\"\n >\n <span\n data-testid=\"bulk-count\"\n data-count={count ?? undefined}\n aria-live=\"polite\"\n className=\"udc:font-medium udc:tabular-nums\"\n >\n {countText}\n </span>\n {offerAll ? (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n data-testid=\"select-all-matching\"\n className=\"udc:text-primary\"\n onClick={selection.selectAllMatching}\n >\n {total === null\n ? t(\"APP\", \"SELECT_ALL_MATCHING\")\n : t(\"APP\", \"SELECT_ALL_MATCHING_COUNT\", { count: fmt(total) })}\n </Button>\n ) : couldOfferAll ? (\n <span data-testid=\"select-all-matching-off\" className=\"udc:text-muted-foreground\">\n {t(\"APP\", \"SELECT_ALL_MATCHING_SEARCH\")}\n </span>\n ) : null}\n <div className=\"udc:ml-auto udc:flex udc:flex-wrap udc:items-center udc:gap-1.5\">\n {defs.map((def) => {\n const label = labelOf(def);\n const eligible = bulkActionEligible(def, selection);\n const Icon = actionIcon(def.icon);\n return (\n <span key={def.kind} title={eligible ? undefined : t(\"APP\", \"BULK_NOT_ELIGIBLE\")}>\n <Button\n size=\"sm\"\n variant={\n def.variant\n ? VARIANT[def.variant]\n : def.kind === \"delete\"\n ? \"danger\"\n : \"outline\"\n }\n data-testid={`bulk-action-${def.kind}`}\n disabled={!eligible || running !== null}\n onClick={() => run(def)}\n >\n {running === def.kind ? <Spinner /> : Icon ? <Icon /> : null}\n {label}\n </Button>\n </span>\n );\n })}\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n data-testid=\"bulk-clear\"\n aria-label={t(\"APP\", \"SELECTION_CLEAR\")}\n onClick={selection.clear}\n >\n <X />\n </Button>\n </div>\n </div>\n <Dialog open={pending !== null} onOpenChange={(open) => !open && setPending(null)}>\n {pending ? (\n <DialogContent\n role=\"alertdialog\"\n data-testid=\"bulk-confirm\"\n title={confirmTitle(pending)}\n >\n <DialogBody className=\"udc:text-[13px] udc:text-muted-foreground\">\n {pending.plan.via === \"delete\" ? t(\"APP\", \"BULK_CONFIRM_DELETE_BODY\") : pending.label}\n </DialogBody>\n <DialogFooter>\n <Button variant=\"ghost\" onClick={() => setPending(null)}>\n {t(\"APP\", \"CANCEL\")}\n </Button>\n <Button\n variant={pending.plan.via === \"delete\" ? \"danger\" : \"primary\"}\n data-testid=\"bulk-confirm-ok\"\n onClick={() => {\n const job = pending;\n setPending(null);\n void execute(job);\n }}\n >\n {pending.plan.via === \"delete\" ? t(\"APP\", \"BULK_DELETE\") : t(\"APP\", \"BULK_CONFIRM\")}\n </Button>\n </DialogFooter>\n </DialogContent>\n ) : null}\n </Dialog>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiEA,IAAM,UAAoE;CACxE,SAAS;CACT,SAAS;CACT,aAAa;AACf;;AAGA,IAAM,eAAqD;CACzD,SAAS;CACT,OAAO;CACP,OAAO;CACP,MAAM;CACN,gBAAgB;CAChB,MAAM;CACN,aAAa;CACb,MAAM;C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
  import { useUiKit } from "../ui-kit/context.js";
4
- import { jsx } from "react/jsx-runtime";
5
4
  import { useQuery } from "@tanstack/react-query";
5
+ import { jsx } from "react/jsx-runtime";
6
6
  // src/data-view/FilePreview.tsx
7
7
  var IMAGE = /\.(png|jpe?g|gif|webp|svg)$/i;
8
8
  /** The URL of one file of a filesystem collection (`GET /udc/files/blob`). */
@@ -3,9 +3,9 @@ import { cn } from "../lib/utils.js";
3
3
  import { useLookupLabels } from "../lookup/LookupValue.js";
4
4
  import { useUiKit } from "../ui-kit/context.js";
5
5
  import { conditionsToTree, treeToConditions } from "./compose.js";
6
- import { ListFilter, Plus, Trash2, X } from "lucide-react";
7
- import { useState } from "react";
8
6
  import { lookupOf } from "@jsudc/core";
7
+ import { useState } from "react";
8
+ import { ListFilter, Plus, Trash2, X } from "lucide-react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  // src/data-view/FilterBuilder.tsx
11
11
  /** Ops that take no value: the builder hides the value input for them. */
@@ -3,9 +3,9 @@ import { cn } from "../lib/utils.js";
3
3
  import { LookupSelectChip } from "../lookup/LookupSelectChip.js";
4
4
  import { useUiKit } from "../ui-kit/context.js";
5
5
  import { isEmptyChip } from "./urlState.js";
6
- import { Check, ChevronDown, PlusCircle, X } from "lucide-react";
7
- import { useEffect, useState } from "react";
8
6
  import { lookupOf } from "@jsudc/core";
7
+ import { useEffect, useState } from "react";
8
+ import { Check, ChevronDown, PlusCircle, X } from "lucide-react";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  // src/data-view/FilterChips.tsx
11
11
  /** The chip bar: one popover per `view.filters` entry. */
@@ -1,8 +1,8 @@
1
1
  import { useI18n } from "../i18n/i18n.js";
2
2
  import { cn } from "../lib/utils.js";
3
3
  import { useUiKit } from "../ui-kit/context.js";
4
- import { CloudOff, RefreshCw } from "lucide-react";
5
4
  import { useEffect, useState } from "react";
5
+ import { CloudOff, RefreshCw } from "lucide-react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  // src/data-view/Freshness.tsx
8
8
  /** "12 s ago", "3 min ago", "pre 12 s": the age of a fetched copy. */
@@ -0,0 +1,10 @@
1
+ import type { UdcChangeFeedStatus } from "../udc/changeFeed.js";
2
+ /**
3
+ * The change feed's state beside the freshness pill: a green "live" while the
4
+ * stream carries the collection, an amber "reconnecting" while it is being
5
+ * reopened (the view polls meanwhile). Nothing otherwise: no feed, the
6
+ * collection does not offer one, still connecting, or refused.
7
+ */
8
+ export declare function LiveIndicator({ status }: {
9
+ status: UdcChangeFeedStatus;
10
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,33 @@
1
+ import { useI18n } from "../i18n/i18n.js";
2
+ import { cn } from "../lib/utils.js";
3
+ import { useUiKit } from "../ui-kit/context.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ // src/data-view/LiveIndicator.tsx
6
+ /**
7
+ * The change feed's state beside the freshness pill: a green "live" while the
8
+ * stream carries the collection, an amber "reconnecting" while it is being
9
+ * reopened (the view polls meanwhile). Nothing otherwise: no feed, the
10
+ * collection does not offer one, still connecting, or refused.
11
+ */
12
+ function LiveIndicator({ status }) {
13
+ const { Tip } = useUiKit();
14
+ const { t } = useI18n();
15
+ if (status !== "live" && status !== "reconnecting") return null;
16
+ const live = status === "live";
17
+ return /* @__PURE__ */ jsx(Tip, {
18
+ label: t("APP", live ? "FEED_LIVE_HINT" : "FEED_RECONNECTING_HINT"),
19
+ children: /* @__PURE__ */ jsxs("span", {
20
+ "data-testid": "feed-status",
21
+ "data-status": status,
22
+ tabIndex: 0,
23
+ className: cn("udc:inline-flex udc:h-5 udc:items-center udc:gap-1 udc:rounded-full udc:px-2 udc:text-[11px] udc:font-medium udc:whitespace-nowrap udc:outline-none udc:focus-visible:ring-2 udc:focus-visible:ring-ring", live ? "udc:bg-sem-success-bg udc:text-sem-success" : "udc:bg-sem-warning-bg udc:text-sem-warning"),
24
+ children: [/* @__PURE__ */ jsx("span", {
25
+ "aria-hidden": true,
26
+ className: cn("udc:size-1.5 udc:rounded-full", live ? "udc:bg-sem-success" : "udc:bg-sem-warning udc:animate-pulse")
27
+ }), t("APP", live ? "FEED_LIVE" : "FEED_RECONNECTING")]
28
+ })
29
+ });
30
+ }
31
+ export { LiveIndicator };
32
+
33
+ //# sourceMappingURL=LiveIndicator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveIndicator.js","names":[],"sources":["../../src/data-view/LiveIndicator.tsx"],"sourcesContent":["import { useI18n } from \"../i18n/i18n.js\";\nimport { cn } from \"../lib/utils.js\";\nimport type { UdcChangeFeedStatus } from \"../udc/changeFeed.js\";\nimport { useUiKit } from \"../ui-kit/context.js\";\n\n/**\n * The change feed's state beside the freshness pill: a green \"live\" while the\n * stream carries the collection, an amber \"reconnecting\" while it is being\n * reopened (the view polls meanwhile). Nothing otherwise: no feed, the\n * collection does not offer one, still connecting, or refused.\n */\nexport function LiveIndicator({ status }: { status: UdcChangeFeedStatus }) {\n const { Tip } = useUiKit();\n const { t } = useI18n();\n if (status !== \"live\" && status !== \"reconnecting\") return null;\n const live = status === \"live\";\n return (\n <Tip label={t(\"APP\", live ? \"FEED_LIVE_HINT\" : \"FEED_RECONNECTING_HINT\")}>\n <span\n data-testid=\"feed-status\"\n data-status={status}\n // biome-ignore lint/a11y/noNoninteractiveTabindex: the tooltip opens on focus too\n tabIndex={0}\n className={cn(\n \"udc:inline-flex udc:h-5 udc:items-center udc:gap-1 udc:rounded-full udc:px-2 udc:text-[11px] udc:font-medium udc:whitespace-nowrap udc:outline-none udc:focus-visible:ring-2 udc:focus-visible:ring-ring\",\n live\n ? \"udc:bg-sem-success-bg udc:text-sem-success\"\n : \"udc:bg-sem-warning-bg udc:text-sem-warning\",\n )}\n >\n <span\n aria-hidden\n className={cn(\n \"udc:size-1.5 udc:rounded-full\",\n live ? \"udc:bg-sem-success\" : \"udc:bg-sem-warning udc:animate-pulse\",\n )}\n />\n {t(\"APP\", live ? \"FEED_LIVE\" : \"FEED_RECONNECTING\")}\n </span>\n </Tip>\n );\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,cAAc,EAAE,UAA2C;CACzE,MAAM,EAAE,QAAQ,SAAS;CACzB,MAAM,EAAE,MAAM,QAAQ;CACtB,IAAI,WAAW,UAAU,WAAW,gBAAgB,OAAO;CAC3D,MAAM,OAAO,WAAW;CACxB,OACE,oBAAC,KAAD;EAAK,OAAO,EAAE,OAAO,OAAO,mBAAmB,wBAAwB;EACrE,UAAA,qBAAC,QAAD;GACE,eAAY;GACZ,eAAa;GAEb,UAAU;GACV,WAAW,GACT,4MACA,OACI,+CACA,4CACN;GAVF,UAAA,CAYE,oBAAC,QAAD;IACE,eAAA;IACA,WAAW,GACT,iCACA,OAAO,uBAAuB,sCAChC;GACD,CAAA,GACA,EAAE,OAAO,OAAO,cAAc,mBAAmB,CAC9C;;CACH,CAAA;AAET"}
@@ -1,7 +1,7 @@
1
1
  import { useI18n } from "../i18n/i18n.js";
2
2
  import { useUiKit } from "../ui-kit/context.js";
3
- import { Search, X } from "lucide-react";
4
3
  import { useEffect, useRef, useState } from "react";
4
+ import { Search, X } from "lucide-react";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  /** The search input; reports the text upwards 300 ms after the last keystroke. */
7
7
  function SearchBox({ value, onChange, placeholder }) {
@@ -1,4 +1,11 @@
1
+ import { type FilterNode, type Row } from "@jsudc/core";
2
+ import { type ReactNode } from "react";
3
+ import type { BulkActionHandlers } from "../actions/bulk.js";
4
+ import { type CellRegistry } from "../cells/registry.js";
1
5
  import type { RendererRegistry } from "../renderers/types.js";
6
+ import type { TableVirtualizeProp } from "../table/useRowWindow.js";
7
+ import type { PagingMode } from "../udc/keys.js";
8
+ import type { UrlStateAdapter } from "../url-state/adapter.js";
2
9
  /**
3
10
  * One collection: toolbar (search, chips, filter builder, paging mode, count,
4
11
  * renderer tabs) over the active renderer. Everything the user picks lives
@@ -8,5 +15,107 @@ export interface UdcDataViewProps {
8
15
  collection: string;
9
16
  /** The renderers this view draws its tabs with; the provider's registry when absent. */
10
17
  renderers?: RendererRegistry;
18
+ /**
19
+ * A filter of the host's (the open folder of a mail client): ANDed into every
20
+ * list the view and its renderers load, counted in "of M", but not shown as a
21
+ * chip or pill, not written to the URL, not removed by "clear filters" and not
22
+ * "the user filtered" for the empty state.
23
+ */
24
+ filter?: FilterNode | undefined;
25
+ /** Which parts of the view's frame are drawn: everything by default. See `UdcDataViewChrome`. */
26
+ chrome?: UdcDataViewChromePreset | UdcDataViewChrome | undefined;
27
+ /** The paging mode to open in, instead of the view's `pagination`. */
28
+ pagingMode?: PagingMode | undefined;
29
+ /** Host content at the start of the toolbar, before the search box. */
30
+ toolbarStart?: ReactNode;
31
+ /** Host content at the end of the toolbar, after the row count. */
32
+ toolbarEnd?: ReactNode;
33
+ /**
34
+ * Where the view keeps its state (search, chips, filter, sort, paging, tab, and
35
+ * the kanban board, chart window and calendar range of its renderers):
36
+ * `"url"` (default) the adapter in effect (`UdcUrlStateProvider`, else the
37
+ * address bar); `"memory"` a store of this view's own that never touches the
38
+ * address bar; or any `UrlStateAdapter`.
39
+ */
40
+ urlState?: "url" | "memory" | UrlStateAdapter | undefined;
41
+ /**
42
+ * A prefix for every parameter the view and its renderers read and write
43
+ * (`inbox.` → `?inbox.q=…&inbox.sort=…`): other parameters are neither read
44
+ * nor removed, so two views, or a view and a host route with a `q` of its
45
+ * own, share one query string. End it with a separator.
46
+ */
47
+ urlPrefix?: string | undefined;
48
+ /**
49
+ * The cell components a column's `render` may name, for this view: added to
50
+ * the provider's (`UdcProvider cells`), a name of this registry winning.
51
+ */
52
+ cells?: CellRegistry | undefined;
53
+ /**
54
+ * A row was activated: Enter on it, or a plain click. With a `row_link` view
55
+ * a plain click then activates, and Cmd / Ctrl-click or the middle button
56
+ * follow the link. Passing this, `activeRowId` or `onActiveRowChange` turns
57
+ * on row activation: one tab stop for the rows, ArrowUp / ArrowDown, `j` /
58
+ * `k`, Home / End move the active row, Enter activates it.
59
+ */
60
+ onRowActivate?: ((row: Row) => void) | undefined;
61
+ /**
62
+ * The row drawn as active (`aria-selected`, `data-active`, `--selected`).
63
+ * Passed: controlled (`null` for none; follow `onActiveRowChange`). Left out
64
+ * while activation is on: the view keeps it itself.
65
+ */
66
+ activeRowId?: string | null | undefined;
67
+ /** The active row changed by the user: the keys (no Enter needed) or a click on another row. */
68
+ onActiveRowChange?: ((row: Row | null) => void) | undefined;
69
+ /**
70
+ * Row selection (checkboxes in the table and the cards, the bulk bar):
71
+ * `true` or `false` forces it on or off. Left out, it is on when the view
72
+ * says `multiselect: true` or declares `bulk_actions`.
73
+ */
74
+ selectable?: boolean | undefined;
75
+ /**
76
+ * Handlers of the view's `bulk_actions`, by `kind`, before the provider's
77
+ * (`UdcProvider actions`). An action without one goes to the server: see
78
+ * README "Selection and bulk actions".
79
+ */
80
+ actions?: BulkActionHandlers | undefined;
81
+ /**
82
+ * The change feed's state ("live" / "reconnecting") beside the freshness
83
+ * pill, when the provider has a feed (`UdcProvider changes`) and the
84
+ * collection offers it. Default `true`; `false` hides it.
85
+ */
86
+ liveIndicator?: boolean | undefined;
87
+ /**
88
+ * Long lists (0.5.0): the table's infinite mode mounts only the rows near the viewport.
89
+ * Left out: once more than 200 rows are loaded. `true` / `false` force it on or off;
90
+ * `{ enabled, threshold, overscan }` sets each. Pages mode is never windowed. See README
91
+ * "Long lists".
92
+ */
93
+ virtualize?: TableVirtualizeProp | undefined;
11
94
  }
12
- export declare function UdcDataView({ collection, renderers }: UdcDataViewProps): import("react").JSX.Element;
95
+ /** `full`: today's view, every part drawn. `embedded`: one pane of a host's screen, no part drawn. */
96
+ export type UdcDataViewChromePreset = "full" | "embedded";
97
+ /**
98
+ * The view's frame, part by part: `true` draws the part. A flag left out takes
99
+ * the preset's value (`full`: all `true`; `embedded`: all `false`).
100
+ */
101
+ export interface UdcDataViewChrome {
102
+ preset?: UdcDataViewChromePreset;
103
+ /** The title and description above the toolbar. */
104
+ header?: boolean;
105
+ /** The renderer tabs (table, cards, kanban, …). */
106
+ tabs?: boolean;
107
+ /**
108
+ * The pages / infinite toggle. Without it the mode is the `pagingMode` prop,
109
+ * else the view's `pagination`, never a choice stored by an earlier session.
110
+ */
111
+ pagingToggle?: boolean;
112
+ /** The Doc pseudo-tab (the collection's README). */
113
+ docTab?: boolean;
114
+ /** The Source pseudo-tab (the collection's source file). */
115
+ sourceTab?: boolean;
116
+ /** The card around the toolbar and rows: its border, shadow, rounding and outer margins. */
117
+ frame?: boolean;
118
+ }
119
+ /** Every flag of `chrome` resolved against its preset. */
120
+ export declare function resolveChrome(chrome: UdcDataViewChromePreset | UdcDataViewChrome | undefined): Required<Omit<UdcDataViewChrome, "preset">>;
121
+ export declare function UdcDataView(props: UdcDataViewProps): import("react").JSX.Element;