@object-ui/react 17.6.0 → 17.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 (89) hide show
  1. package/CHANGELOG.md +3766 -0
  2. package/README.md +294 -38
  3. package/dist/SchemaRenderer.d.ts +38 -7
  4. package/dist/SchemaRenderer.js +1218 -87
  5. package/dist/context/ActionContext.js +40 -1
  6. package/dist/context/DiscussionContext.d.ts +12 -0
  7. package/dist/context/DiscussionContext.js +2 -0
  8. package/dist/context/DrillNavigationContext.d.ts +13 -0
  9. package/dist/context/InlineEditContext.d.ts +81 -1
  10. package/dist/context/InlineEditContext.js +8 -2
  11. package/dist/context/RecordContext.d.ts +48 -5
  12. package/dist/context/RecordContext.js +10 -1
  13. package/dist/context/RelatedRecordActionsContext.d.ts +5 -1
  14. package/dist/context/SchemaRendererContext.d.ts +54 -2
  15. package/dist/context/SchemaRendererContext.js +38 -5
  16. package/dist/context/ThemeContext.js +1 -1
  17. package/dist/context/actionRunnerTranslator.d.ts +27 -0
  18. package/dist/context/actionRunnerTranslator.js +37 -0
  19. package/dist/element-data-source/ElementDataSourceGate.d.ts +88 -1
  20. package/dist/element-data-source/ElementDataSourceGate.js +326 -13
  21. package/dist/hooks/index.d.ts +3 -1
  22. package/dist/hooks/index.js +10 -1
  23. package/dist/hooks/useActionEngine.js +46 -3
  24. package/dist/hooks/useActionRunner.js +4 -0
  25. package/dist/hooks/useActionTextLocalizer.d.ts +21 -8
  26. package/dist/hooks/useActionTextLocalizer.js +33 -8
  27. package/dist/hooks/useConfigBagEvaluator.d.ts +30 -0
  28. package/dist/hooks/useConfigBagEvaluator.js +39 -0
  29. package/dist/hooks/useDensityMode.d.ts +6 -2
  30. package/dist/hooks/useDensityMode.js +6 -2
  31. package/dist/hooks/useDiscovery.d.ts +1 -10
  32. package/dist/hooks/useETagCache.js +25 -4
  33. package/dist/hooks/useElementDataSource.d.ts +15 -2
  34. package/dist/hooks/useElementDataSource.js +24 -7
  35. package/dist/hooks/useExpression.d.ts +52 -59
  36. package/dist/hooks/useExpression.js +58 -90
  37. package/dist/hooks/useFilterScope.d.ts +22 -2
  38. package/dist/hooks/useFilterScope.js +29 -4
  39. package/dist/hooks/useGlobalUndo.d.ts +10 -0
  40. package/dist/hooks/useGlobalUndo.js +112 -46
  41. package/dist/hooks/useNavigationOverlay.d.ts +76 -11
  42. package/dist/hooks/useNavigationOverlay.js +119 -9
  43. package/dist/hooks/useOffline.js +65 -11
  44. package/dist/hooks/usePageAssignment.d.ts +8 -5
  45. package/dist/hooks/usePageAssignment.js +37 -16
  46. package/dist/hooks/useRecordSearch.d.ts +34 -1
  47. package/dist/hooks/useRecordSearch.js +42 -7
  48. package/dist/hooks/useResolvedFilter.d.ts +46 -0
  49. package/dist/hooks/useResolvedFilter.js +130 -0
  50. package/dist/hooks/useSchemaPersistence.d.ts +7 -0
  51. package/dist/hooks/useSchemaPersistence.js +144 -5
  52. package/dist/hooks/useSettledSchema.d.ts +123 -0
  53. package/dist/hooks/useSettledSchema.js +186 -0
  54. package/dist/hooks/useViewData.d.ts +7 -2
  55. package/dist/index.d.ts +8 -1
  56. package/dist/index.js +45 -1
  57. package/dist/schema-input.d.ts +38 -8
  58. package/dist/schema-input.js +39 -7
  59. package/dist/utils/configBag.d.ts +68 -0
  60. package/dist/utils/configBag.js +70 -0
  61. package/dist/utils/error-message.d.ts +1 -1
  62. package/dist/utils/error-message.js +1 -1
  63. package/dist/utils/inlineAria.d.ts +61 -0
  64. package/dist/utils/inlineAria.js +70 -0
  65. package/dist/utils/nonGridRowCeiling.d.ts +44 -0
  66. package/dist/utils/nonGridRowCeiling.js +78 -0
  67. package/dist/utils/paramsBag.d.ts +28 -0
  68. package/dist/utils/paramsBag.js +146 -0
  69. package/dist/utils/propsBagDiagnostic.d.ts +196 -0
  70. package/dist/utils/propsBagDiagnostic.js +421 -0
  71. package/dist/utils/refusedDataPropDiagnostic.d.ts +44 -0
  72. package/dist/utils/refusedDataPropDiagnostic.js +94 -0
  73. package/dist/utils/unevaluatedExpression.d.ts +42 -1
  74. package/dist/utils/unevaluatedExpression.js +74 -11
  75. package/dist/utils/visibilityDiagnostic.d.ts +271 -19
  76. package/dist/utils/visibilityDiagnostic.js +311 -44
  77. package/package.json +10 -10
  78. package/dist/hooks/useClientNotifications.d.ts +0 -47
  79. package/dist/hooks/useClientNotifications.js +0 -162
  80. package/dist/spec-bridge/SpecBridge.d.ts +0 -28
  81. package/dist/spec-bridge/SpecBridge.js +0 -56
  82. package/dist/spec-bridge/bridges/form-view.d.ts +0 -158
  83. package/dist/spec-bridge/bridges/form-view.js +0 -170
  84. package/dist/spec-bridge/bridges/list-view.d.ts +0 -20
  85. package/dist/spec-bridge/bridges/list-view.js +0 -268
  86. package/dist/spec-bridge/index.d.ts +0 -11
  87. package/dist/spec-bridge/index.js +0 -10
  88. package/dist/spec-bridge/types.d.ts +0 -55
  89. package/dist/spec-bridge/types.js +0 -8
@@ -1,268 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- /**
9
- * A spec `ListColumn` in, the same column out — in the spelling the spec
10
- * declares (objectui#5068).
11
- *
12
- * This used to down-translate every column to the data-table adapter's
13
- * `{ accessorKey, header }` before handing it to an `object-grid` node, and
14
- * `ObjectGrid` translated it straight back through a tolerance branch that
15
- * sniffed `columns[0]`. A round trip whose input was ALREADY canonical: the
16
- * bridge's own parameter is `@objectstack/spec/ui`'s `ListColumn`, where
17
- * `field` is required and `accessorKey` / `header` are refused by name
18
- * (`ListColumnSchema` is a strict object). So the producer emitted a spelling
19
- * the contract rejects, and the renderer grew a second de-facto contract to
20
- * read it back — exactly the shape AGENTS.md #0.1 forbids, and the disposition
21
- * objectui#3951 already settled: unify at the producer, no consumer-side alias.
22
- *
23
- * `accessorKey` is not retired as a concept — it is the TanStack adapter key
24
- * `@object-ui/core` deliberately keeps OUT of the metadata identity fold
25
- * (`column-identity.ts`'s `TABLE_ADAPTER_COLUMN_KEY`). `ObjectGrid` still
26
- * applies it on the way OUT, at the one boundary that owns it. Metadata
27
- * vocabulary comes in; adapter vocabulary goes out; one translation, one place.
28
- *
29
- * Nothing is invented on the way through, which is the second half of the fix.
30
- * `header: col.label ?? col.field` used to turn "no label declared" into "the
31
- * machine name was declared as the label", and that synthesized value then
32
- * pre-empted `ObjectGrid`'s own header chain — `col.label` → the OBJECT
33
- * FIELD's label → the prettified name — whose whole purpose is a column
34
- * authored as a bare `{ field }`, and whose middle step exists so a localized
35
- * field label wins over the name-derived English one on a non-English app. A
36
- * bridged view therefore rendered raw machine names where a directly authored
37
- * `object-grid` rendered the field's real, localizable label. It now forwards
38
- * the declaration and lets the renderer resolve what was left unsaid.
39
- */
40
- function mapColumn(col) {
41
- // Spec shorthand: a bare field name stands for a default column.
42
- if (typeof col === 'string') {
43
- return { field: col };
44
- }
45
- const mapped = {
46
- field: col.field,
47
- };
48
- if (col.label != null)
49
- mapped.label = col.label;
50
- if (col.width != null)
51
- mapped.width = col.width;
52
- if (col.align)
53
- mapped.align = col.align;
54
- if (col.hidden != null)
55
- mapped.hidden = col.hidden;
56
- if (col.sortable != null)
57
- mapped.sortable = col.sortable;
58
- if (col.resizable != null)
59
- mapped.resizable = col.resizable;
60
- if (col.wrap != null)
61
- mapped.wrap = col.wrap;
62
- if (col.type)
63
- mapped.type = col.type;
64
- if (col.pinned)
65
- mapped.pinned = col.pinned;
66
- if (col.summary)
67
- mapped.summary = col.summary;
68
- if (col.link)
69
- mapped.link = col.link;
70
- if (col.action)
71
- mapped.action = col.action;
72
- return mapped;
73
- }
74
- /**
75
- * The spec's five row heights collapsed onto the renderer's three densities.
76
- *
77
- * `Record<RowHeight, …>` on purpose (objectui#4352): the key set is the spec's,
78
- * so a row height added upstream fails the build here instead of silently
79
- * arriving with no density. The table used to carry four more keys —
80
- * `comfortable`, `spacious`, `small`, `large` — which `RowHeightSchema` does
81
- * not admit, so no spec-valid list view could ever reach them; they only
82
- * survived because the parameter was widened back to `string` and the fixture
83
- * asserting three of them compiled against nothing. Deleting them is AGENTS.md
84
- * #0.1: a renderer-side dialect for off-spec metadata is a second de-facto
85
- * contract, and one strict contract beats N. An off-spec `rowHeight` now falls
86
- * through to `undefined` — the producer is where it gets fixed.
87
- */
88
- const ROW_HEIGHT_TO_DENSITY = {
89
- compact: 'compact',
90
- short: 'compact',
91
- medium: 'comfortable',
92
- tall: 'spacious',
93
- extra_tall: 'spacious',
94
- };
95
- /**
96
- * Runtime reader for {@link ROW_HEIGHT_TO_DENSITY} — the five spec row heights
97
- * and **nothing else**.
98
- *
99
- * `hasOwnProperty`, not a bare index (objectui#4442): the table is a plain
100
- * object literal, so indexing it with an unchecked key reaches
101
- * `Object.prototype`. The parameter is typed `RowHeight`, but the boundary a
102
- * host's stored view definition actually crosses is `SpecBridge.transformListView`,
103
- * whose parameter is `any` — so `rowHeight: 'toString'` used to come back as
104
- * `Object.prototype.toString`, a FUNCTION returned from a signature that
105
- * promises three strings or nothing. `bridgeListView` then writes the key under
106
- * `if (density)`, and a function is truthy, so it landed on the SchemaNode.
107
- *
108
- * This is the same guard `@object-ui/core`'s `rowHeightToDensityMode` grew in
109
- * objectui#4440, and the repo's existing convention (`freeze-schema.ts:135`,
110
- * `metadata-admin/predicate.ts:305`, six more). Both rowHeight surfaces now
111
- * abstain identically on every off-spec spelling; the agreement is pinned by
112
- * `__tests__/RowHeightDensityAgreement.test.ts`.
113
- *
114
- * `typeof rowHeight !== 'string'`, not `!rowHeight` (objectui#4459): the
115
- * truthiness guard this replaces rejected only FALSY values, so every truthy
116
- * non-string walked past it into a lookup that coerces its key — both
117
- * `hasOwnProperty.call` and the index run `String(...)`. `['compact']`, a boxed
118
- * `String('compact')` and `{ toString: () => 'compact' }` therefore each
119
- * selected a real density, where core's twin abstained
120
- * (`packages/core/src/utils/normalize-list-view.ts:83`, which has opened with
121
- * the type guard since #4440). Note the direction against #4442: that leak produced a
122
- * FUNCTION, visibly wrong to everything downstream; this one produced a
123
- * legitimate-looking `'compact'` that nothing can tell apart from an authored
124
- * value. The type guard subsumes the old one — `undefined`, `null`, `0` and
125
- * `false` are all non-strings — and `''` keeps its answer while changing route:
126
- * a string, so it passes here and is refused by `hasOwnProperty` one line down.
127
- */
128
- function mapDensity(rowHeight) {
129
- if (typeof rowHeight !== 'string')
130
- return undefined;
131
- if (!Object.prototype.hasOwnProperty.call(ROW_HEIGHT_TO_DENSITY, rowHeight)) {
132
- return undefined;
133
- }
134
- return ROW_HEIGHT_TO_DENSITY[rowHeight];
135
- }
136
- /**
137
- * The spec's own parse-time lift, applied where `parse` cannot reach
138
- * (objectui#4585).
139
- *
140
- * `@objectstack/spec` accepts BOTH spellings of `view.exportOptions` and lifts
141
- * the legacy bare format array to the object form at parse (objectstack#8010,
142
- * `ui/view.zod.ts`):
143
- *
144
- * z.array(ListViewExportFormatSchema).transform((formats) => ({ formats }))
145
- *
146
- * That transform never runs on this path. The bridge's input is a TypeScript
147
- * type, not a parsed value — there is no `parse`/`safeParse` anywhere under
148
- * `spec-bridge/` — so a host that parses first hands over the object form while
149
- * a host that forwards raw stored metadata hands over whatever was authored,
150
- * and nothing here can tell them apart. The legacy array therefore used to
151
- * reach the `object-grid` node verbatim, where `ObjectGrid` reads
152
- * `exportOptions.formats` and only that: `.formats` on an array is `undefined`,
153
- * the renderer's `['csv', 'json']` default won, and the view's declared formats
154
- * were dropped with no error and no console line — the export button still
155
- * showed, because a non-empty array is truthy.
156
- *
157
- * This mirrors that transform and NOTHING more: the same contract applied one
158
- * layer out, not a second de-facto one (AGENTS.md #0.1 — the consumer-side
159
- * `Array.isArray` fallback in the renderer is what that rule forbids). Hence:
160
- *
161
- * - the object form passes through by reference, unread and unrewritten;
162
- * - an empty array lifts to `{ formats: [] }`, exactly as the spec's transform
163
- * does — its `z.array()` carries no `.min(1)`, so `[]` is a legal input that
164
- * wraps rather than defaults. ObjectGrid then offers no format and hides the
165
- * export button: "declared zero formats", read literally;
166
- * - a `'pdf'` stored before its retirement is carried, not filtered. The spec
167
- * REFUSES `'pdf'` at parse with a migration prescription (objectstack#8010;
168
- * PDF export itself was declined as objectstack#1301 NOT_PLANNED) — it does
169
- * not silently drop the value, so neither may this. Such a format dies
170
- * downstream in ObjectGrid's format-AGNOSTIC menu filter, kept deliberately
171
- * at objectui#4535 for metadata predating `os migrate meta --from 16`.
172
- */
173
- function liftExportOptions(exportOptions) {
174
- if (!Array.isArray(exportOptions))
175
- return exportOptions;
176
- // The pinned `@objectstack/spec@17.0.0-rc.6` still admits `'pdf'` as an array
177
- // member (the enum narrowing arrives with the pin bump), so the element type
178
- // here is wider than the renderer-side `ListViewExportFormat`. Narrowing it by
179
- // filtering would invent precisely the silent drop the spec declines to do.
180
- return { formats: exportOptions };
181
- }
182
- /** Transforms a ListView spec into a DataTable SchemaNode */
183
- export const bridgeListView = (spec, _context) => {
184
- const columns = (spec.columns ?? []).map(mapColumn);
185
- const density = mapDensity(spec.rowHeight);
186
- const node = {
187
- type: 'object-grid',
188
- id: spec.name,
189
- columns,
190
- data: spec.data,
191
- };
192
- if (spec.label)
193
- node.label = spec.label;
194
- if (spec.selection)
195
- node.selection = spec.selection;
196
- if (spec.pagination)
197
- node.pagination = spec.pagination;
198
- if (spec.sort)
199
- node.sort = spec.sort;
200
- if (spec.filter)
201
- node.filter = spec.filter;
202
- if (density)
203
- node.density = density;
204
- if (spec.grouping)
205
- node.grouping = spec.grouping;
206
- if (spec.rowColor)
207
- node.rowColor = spec.rowColor;
208
- if (spec.searchableFields)
209
- node.searchableFields = spec.searchableFields;
210
- if (spec.filterableFields)
211
- node.filterableFields = spec.filterableFields;
212
- if (spec.resizable != null)
213
- node.resizable = spec.resizable;
214
- if (spec.navigation)
215
- node.navigation = spec.navigation;
216
- if (spec.kanban)
217
- node.kanban = spec.kanban;
218
- if (spec.calendar)
219
- node.calendar = spec.calendar;
220
- if (spec.gantt)
221
- node.gantt = spec.gantt;
222
- if (spec.gallery)
223
- node.gallery = spec.gallery;
224
- if (spec.timeline)
225
- node.timeline = spec.timeline;
226
- // P1.1 — Spec Protocol Alignment additions
227
- if (spec.rowActions)
228
- node.rowActions = spec.rowActions;
229
- if (spec.bulkActions)
230
- node.bulkActions = spec.bulkActions;
231
- if (spec.bulkActionDefs)
232
- node.bulkActionDefs = spec.bulkActionDefs;
233
- if (spec.conditionalFormatting)
234
- node.conditionalFormatting = spec.conditionalFormatting;
235
- if (spec.inlineEdit != null)
236
- node.inlineEdit = spec.inlineEdit;
237
- if (spec.exportOptions)
238
- node.exportOptions = liftExportOptions(spec.exportOptions);
239
- if (spec.emptyState)
240
- node.emptyState = spec.emptyState;
241
- if (spec.userActions)
242
- node.userActions = spec.userActions;
243
- if (spec.appearance)
244
- node.appearance = spec.appearance;
245
- if (spec.compactToolbar != null)
246
- node.compactToolbar = spec.compactToolbar;
247
- if (spec.addRecord)
248
- node.addRecord = spec.addRecord;
249
- if (spec.showRecordCount != null)
250
- node.showRecordCount = spec.showRecordCount;
251
- if (spec.allowPrinting != null)
252
- node.allowPrinting = spec.allowPrinting;
253
- // P1.6 — i18n & ARIA
254
- if (spec.aria)
255
- node.aria = spec.aria;
256
- // `sharing` is already the spec's `ViewSharing` shape on both sides (#2890) —
257
- // this used to DOWNGRADE it here, inventing a legacy `visibility` audience and
258
- // an `enabled` flag that the renderer then had to fold back.
259
- if (spec.sharing)
260
- node.sharing = spec.sharing;
261
- if (spec.hiddenFields)
262
- node.hiddenFields = spec.hiddenFields;
263
- if (spec.fieldOrder)
264
- node.fieldOrder = spec.fieldOrder;
265
- if (spec.description)
266
- node.description = spec.description;
267
- return node;
268
- };
@@ -1,11 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- export { SpecBridge } from './SpecBridge.js';
9
- export type { BridgeContext, BridgeFn, ObjectDefLite } from './types.js';
10
- export { bridgeListView } from './bridges/list-view.js';
11
- export { bridgeFormView } from './bridges/form-view.js';
@@ -1,10 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- export { SpecBridge } from './SpecBridge.js';
9
- export { bridgeListView } from './bridges/list-view.js';
10
- export { bridgeFormView } from './bridges/form-view.js';
@@ -1,55 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- import type { BaseSchema } from '@object-ui/types';
9
- /** Context passed to all bridge functions */
10
- export interface BridgeContext {
11
- /** Current user context for permission checks */
12
- user?: Record<string, any>;
13
- /** App-level variables */
14
- variables?: Record<string, any>;
15
- /** Registered object definitions for field metadata lookup */
16
- objectDefs?: Record<string, ObjectDefLite>;
17
- }
18
- /** Lightweight object definition for field metadata resolution */
19
- export interface ObjectDefLite {
20
- name: string;
21
- label?: string;
22
- fields: Array<{
23
- name: string;
24
- label?: string;
25
- type: string;
26
- required?: boolean;
27
- options?: Array<{
28
- label: string;
29
- value: string;
30
- }>;
31
- }>;
32
- }
33
- /**
34
- * A bridge function transforms a spec schema into a schema node tree.
35
- *
36
- * Returns **`BaseSchema`**, not `SchemaNode` (objectui#4580, ruling Q4-B).
37
- * Once core's `SchemaNode` became `@object-ui/types`' union
38
- * (`BaseSchema | string | number | boolean | null | undefined`), declaring the
39
- * return as `SchemaNode` made every caller re-ask a question no bridge has ever
40
- * answered "yes" to: *is this a bare string / null?* Both shipped bridges end
41
- * in a single `return node` on an object literal — `bridges/list-view.ts:226`
42
- * and `bridges/form-view.ts:195` — so the wider declaration described nothing
43
- * real while forcing a narrowing at every read.
44
- *
45
- * That cost was measured, not assumed: round 1 of this card recorded **272**
46
- * mechanical errors across five spec-bridge suites, all of them TS18049
47
- * (`'node' is possibly 'null' or 'undefined'`) and TS2339
48
- * (`Property 'formType' does not exist on type
49
- * 'string | number | boolean | BaseSchema'`) — the union being destructured by
50
- * tests reading properties off a node the bridge always produces.
51
- *
52
- * This is a type ANNOTATION only: no runtime behaviour changes, and the emitted
53
- * JavaScript is byte-identical (proven by bundle sha256 on this PR).
54
- */
55
- export type BridgeFn<T = any> = (spec: T, context: BridgeContext) => BaseSchema;
@@ -1,8 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- export {};