@object-ui/react 17.5.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 (103) hide show
  1. package/CHANGELOG.md +4100 -0
  2. package/README.md +303 -46
  3. package/dist/LazyPluginLoader.d.ts +14 -7
  4. package/dist/LazyPluginLoader.js +14 -7
  5. package/dist/SchemaRenderer.d.ts +38 -7
  6. package/dist/SchemaRenderer.js +1603 -60
  7. package/dist/context/ActionContext.js +40 -1
  8. package/dist/context/DiscussionContext.d.ts +12 -0
  9. package/dist/context/DiscussionContext.js +2 -0
  10. package/dist/context/DrillNavigationContext.d.ts +13 -0
  11. package/dist/context/HostNavigationContext.d.ts +82 -0
  12. package/dist/context/HostNavigationContext.js +65 -0
  13. package/dist/context/InlineEditContext.d.ts +81 -1
  14. package/dist/context/InlineEditContext.js +8 -2
  15. package/dist/context/RecordContext.d.ts +48 -5
  16. package/dist/context/RecordContext.js +10 -1
  17. package/dist/context/RelatedRecordActionsContext.d.ts +20 -1
  18. package/dist/context/SchemaRendererContext.d.ts +54 -2
  19. package/dist/context/SchemaRendererContext.js +38 -5
  20. package/dist/context/ThemeContext.js +1 -1
  21. package/dist/context/actionRunnerTranslator.d.ts +27 -0
  22. package/dist/context/actionRunnerTranslator.js +37 -0
  23. package/dist/context/index.d.ts +13 -12
  24. package/dist/context/index.js +13 -12
  25. package/dist/element-data-source/ElementDataSourceGate.d.ts +163 -3
  26. package/dist/element-data-source/ElementDataSourceGate.js +407 -15
  27. package/dist/hooks/index.d.ts +37 -35
  28. package/dist/hooks/index.js +44 -35
  29. package/dist/hooks/useActionEngine.js +47 -4
  30. package/dist/hooks/useActionRunner.js +4 -0
  31. package/dist/hooks/useActionTextLocalizer.d.ts +21 -8
  32. package/dist/hooks/useActionTextLocalizer.js +33 -8
  33. package/dist/hooks/useCapabilityGate.js +6 -5
  34. package/dist/hooks/useConfigBagEvaluator.d.ts +30 -0
  35. package/dist/hooks/useConfigBagEvaluator.js +39 -0
  36. package/dist/hooks/useCrudShortcuts.js +1 -1
  37. package/dist/hooks/useDatasetDimensionLabels.js +1 -1
  38. package/dist/hooks/useDensityMode.d.ts +6 -2
  39. package/dist/hooks/useDensityMode.js +6 -2
  40. package/dist/hooks/useDiscovery.d.ts +1 -10
  41. package/dist/hooks/useDiscovery.js +1 -1
  42. package/dist/hooks/useETagCache.js +25 -4
  43. package/dist/hooks/useElementDataSource.d.ts +15 -2
  44. package/dist/hooks/useElementDataSource.js +29 -9
  45. package/dist/hooks/useExpression.d.ts +52 -38
  46. package/dist/hooks/useExpression.js +62 -42
  47. package/dist/hooks/useFilterScope.d.ts +22 -2
  48. package/dist/hooks/useFilterScope.js +29 -4
  49. package/dist/hooks/useGlobalUndo.d.ts +10 -0
  50. package/dist/hooks/useGlobalUndo.js +112 -46
  51. package/dist/hooks/useNavigationOverlay.d.ts +77 -12
  52. package/dist/hooks/useNavigationOverlay.js +119 -9
  53. package/dist/hooks/useOffline.js +65 -11
  54. package/dist/hooks/usePageAssignment.d.ts +8 -5
  55. package/dist/hooks/usePageAssignment.js +38 -17
  56. package/dist/hooks/usePageTransition.js +1 -1
  57. package/dist/hooks/usePageVariableActionBridge.js +2 -2
  58. package/dist/hooks/useRecordSearch.d.ts +34 -1
  59. package/dist/hooks/useRecordSearch.js +42 -7
  60. package/dist/hooks/useResolvedFilter.d.ts +46 -0
  61. package/dist/hooks/useResolvedFilter.js +130 -0
  62. package/dist/hooks/useSchemaPersistence.d.ts +7 -0
  63. package/dist/hooks/useSchemaPersistence.js +144 -5
  64. package/dist/hooks/useSettledSchema.d.ts +123 -0
  65. package/dist/hooks/useSettledSchema.js +186 -0
  66. package/dist/hooks/useViewData.d.ts +7 -2
  67. package/dist/hooks/useViewData.js +1 -1
  68. package/dist/hooks/useViewTransition.js +1 -1
  69. package/dist/index.d.ts +18 -11
  70. package/dist/index.js +54 -10
  71. package/dist/schema-input.d.ts +55 -14
  72. package/dist/schema-input.js +55 -12
  73. package/dist/utils/configBag.d.ts +68 -0
  74. package/dist/utils/configBag.js +70 -0
  75. package/dist/utils/error-message.d.ts +59 -0
  76. package/dist/utils/error-message.js +116 -1
  77. package/dist/utils/inlineAria.d.ts +61 -0
  78. package/dist/utils/inlineAria.js +70 -0
  79. package/dist/utils/nonGridRowCeiling.d.ts +44 -0
  80. package/dist/utils/nonGridRowCeiling.js +78 -0
  81. package/dist/utils/paramsBag.d.ts +28 -0
  82. package/dist/utils/paramsBag.js +146 -0
  83. package/dist/utils/propsBagDiagnostic.d.ts +196 -0
  84. package/dist/utils/propsBagDiagnostic.js +421 -0
  85. package/dist/utils/refusedDataPropDiagnostic.d.ts +44 -0
  86. package/dist/utils/refusedDataPropDiagnostic.js +94 -0
  87. package/dist/utils/unevaluatedExpression.d.ts +110 -0
  88. package/dist/utils/unevaluatedExpression.js +257 -0
  89. package/dist/utils/visibilityDiagnostic.d.ts +371 -0
  90. package/dist/utils/visibilityDiagnostic.js +551 -0
  91. package/package.json +10 -10
  92. package/dist/hooks/useClientNotifications.d.ts +0 -47
  93. package/dist/hooks/useClientNotifications.js +0 -162
  94. package/dist/spec-bridge/SpecBridge.d.ts +0 -28
  95. package/dist/spec-bridge/SpecBridge.js +0 -56
  96. package/dist/spec-bridge/bridges/form-view.d.ts +0 -82
  97. package/dist/spec-bridge/bridges/form-view.js +0 -126
  98. package/dist/spec-bridge/bridges/list-view.d.ts +0 -20
  99. package/dist/spec-bridge/bridges/list-view.js +0 -241
  100. package/dist/spec-bridge/index.d.ts +0 -11
  101. package/dist/spec-bridge/index.js +0 -10
  102. package/dist/spec-bridge/types.d.ts +0 -55
  103. package/dist/spec-bridge/types.js +0 -8
@@ -1,241 +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
- function mapColumn(col) {
9
- // Spec-legacy shorthand: a bare field name stands for a default column.
10
- if (typeof col === 'string') {
11
- return { accessorKey: col, header: col };
12
- }
13
- const mapped = {
14
- accessorKey: col.field,
15
- header: col.label ?? col.field,
16
- };
17
- if (col.width != null)
18
- mapped.width = col.width;
19
- if (col.align)
20
- mapped.align = col.align;
21
- if (col.hidden != null)
22
- mapped.hidden = col.hidden;
23
- if (col.sortable != null)
24
- mapped.sortable = col.sortable;
25
- if (col.resizable != null)
26
- mapped.resizable = col.resizable;
27
- if (col.wrap != null)
28
- mapped.wrap = col.wrap;
29
- if (col.type)
30
- mapped.type = col.type;
31
- if (col.pinned)
32
- mapped.pinned = col.pinned;
33
- if (col.summary)
34
- mapped.summary = col.summary;
35
- if (col.link)
36
- mapped.link = col.link;
37
- if (col.action)
38
- mapped.action = col.action;
39
- return mapped;
40
- }
41
- /**
42
- * The spec's five row heights collapsed onto the renderer's three densities.
43
- *
44
- * `Record<RowHeight, …>` on purpose (objectui#4352): the key set is the spec's,
45
- * so a row height added upstream fails the build here instead of silently
46
- * arriving with no density. The table used to carry four more keys —
47
- * `comfortable`, `spacious`, `small`, `large` — which `RowHeightSchema` does
48
- * not admit, so no spec-valid list view could ever reach them; they only
49
- * survived because the parameter was widened back to `string` and the fixture
50
- * asserting three of them compiled against nothing. Deleting them is AGENTS.md
51
- * #0.1: a renderer-side dialect for off-spec metadata is a second de-facto
52
- * contract, and one strict contract beats N. An off-spec `rowHeight` now falls
53
- * through to `undefined` — the producer is where it gets fixed.
54
- */
55
- const ROW_HEIGHT_TO_DENSITY = {
56
- compact: 'compact',
57
- short: 'compact',
58
- medium: 'comfortable',
59
- tall: 'spacious',
60
- extra_tall: 'spacious',
61
- };
62
- /**
63
- * Runtime reader for {@link ROW_HEIGHT_TO_DENSITY} — the five spec row heights
64
- * and **nothing else**.
65
- *
66
- * `hasOwnProperty`, not a bare index (objectui#4442): the table is a plain
67
- * object literal, so indexing it with an unchecked key reaches
68
- * `Object.prototype`. The parameter is typed `RowHeight`, but the boundary a
69
- * host's stored view definition actually crosses is `SpecBridge.transformListView`,
70
- * whose parameter is `any` — so `rowHeight: 'toString'` used to come back as
71
- * `Object.prototype.toString`, a FUNCTION returned from a signature that
72
- * promises three strings or nothing. `bridgeListView` then writes the key under
73
- * `if (density)`, and a function is truthy, so it landed on the SchemaNode.
74
- *
75
- * This is the same guard `@object-ui/core`'s `rowHeightToDensityMode` grew in
76
- * objectui#4440, and the repo's existing convention (`freeze-schema.ts:135`,
77
- * `metadata-admin/predicate.ts:305`, six more). Both rowHeight surfaces now
78
- * abstain identically on every off-spec spelling; the agreement is pinned by
79
- * `__tests__/RowHeightDensityAgreement.test.ts`.
80
- *
81
- * `typeof rowHeight !== 'string'`, not `!rowHeight` (objectui#4459): the
82
- * truthiness guard this replaces rejected only FALSY values, so every truthy
83
- * non-string walked past it into a lookup that coerces its key — both
84
- * `hasOwnProperty.call` and the index run `String(...)`. `['compact']`, a boxed
85
- * `String('compact')` and `{ toString: () => 'compact' }` therefore each
86
- * selected a real density, where core's twin abstained
87
- * (`packages/core/src/utils/normalize-list-view.ts:83`, which has opened with
88
- * the type guard since #4440). Note the direction against #4442: that leak produced a
89
- * FUNCTION, visibly wrong to everything downstream; this one produced a
90
- * legitimate-looking `'compact'` that nothing can tell apart from an authored
91
- * value. The type guard subsumes the old one — `undefined`, `null`, `0` and
92
- * `false` are all non-strings — and `''` keeps its answer while changing route:
93
- * a string, so it passes here and is refused by `hasOwnProperty` one line down.
94
- */
95
- function mapDensity(rowHeight) {
96
- if (typeof rowHeight !== 'string')
97
- return undefined;
98
- if (!Object.prototype.hasOwnProperty.call(ROW_HEIGHT_TO_DENSITY, rowHeight)) {
99
- return undefined;
100
- }
101
- return ROW_HEIGHT_TO_DENSITY[rowHeight];
102
- }
103
- /**
104
- * The spec's own parse-time lift, applied where `parse` cannot reach
105
- * (objectui#4585).
106
- *
107
- * `@objectstack/spec` accepts BOTH spellings of `view.exportOptions` and lifts
108
- * the legacy bare format array to the object form at parse (objectstack#8010,
109
- * `ui/view.zod.ts`):
110
- *
111
- * z.array(ListViewExportFormatSchema).transform((formats) => ({ formats }))
112
- *
113
- * That transform never runs on this path. The bridge's input is a TypeScript
114
- * type, not a parsed value — there is no `parse`/`safeParse` anywhere under
115
- * `spec-bridge/` — so a host that parses first hands over the object form while
116
- * a host that forwards raw stored metadata hands over whatever was authored,
117
- * and nothing here can tell them apart. The legacy array therefore used to
118
- * reach the `object-grid` node verbatim, where `ObjectGrid` reads
119
- * `exportOptions.formats` and only that: `.formats` on an array is `undefined`,
120
- * the renderer's `['csv', 'json']` default won, and the view's declared formats
121
- * were dropped with no error and no console line — the export button still
122
- * showed, because a non-empty array is truthy.
123
- *
124
- * This mirrors that transform and NOTHING more: the same contract applied one
125
- * layer out, not a second de-facto one (AGENTS.md #0.1 — the consumer-side
126
- * `Array.isArray` fallback in the renderer is what that rule forbids). Hence:
127
- *
128
- * - the object form passes through by reference, unread and unrewritten;
129
- * - an empty array lifts to `{ formats: [] }`, exactly as the spec's transform
130
- * does — its `z.array()` carries no `.min(1)`, so `[]` is a legal input that
131
- * wraps rather than defaults. ObjectGrid then offers no format and hides the
132
- * export button: "declared zero formats", read literally;
133
- * - a `'pdf'` stored before its retirement is carried, not filtered. The spec
134
- * REFUSES `'pdf'` at parse with a migration prescription (objectstack#8010;
135
- * PDF export itself was declined as objectstack#1301 NOT_PLANNED) — it does
136
- * not silently drop the value, so neither may this. Such a format dies
137
- * downstream in ObjectGrid's format-AGNOSTIC menu filter, kept deliberately
138
- * at objectui#4535 for metadata predating `os migrate meta --from 16`.
139
- */
140
- function liftExportOptions(exportOptions) {
141
- if (!Array.isArray(exportOptions))
142
- return exportOptions;
143
- // The pinned `@objectstack/spec@17.0.0-rc.6` still admits `'pdf'` as an array
144
- // member (the enum narrowing arrives with the pin bump), so the element type
145
- // here is wider than the renderer-side `ListViewExportFormat`. Narrowing it by
146
- // filtering would invent precisely the silent drop the spec declines to do.
147
- return { formats: exportOptions };
148
- }
149
- /** Transforms a ListView spec into a DataTable SchemaNode */
150
- export const bridgeListView = (spec, _context) => {
151
- const columns = (spec.columns ?? []).map(mapColumn);
152
- const density = mapDensity(spec.rowHeight);
153
- const node = {
154
- type: 'object-grid',
155
- id: spec.name,
156
- columns,
157
- data: spec.data,
158
- };
159
- if (spec.label)
160
- node.label = spec.label;
161
- if (spec.selection)
162
- node.selection = spec.selection;
163
- if (spec.pagination)
164
- node.pagination = spec.pagination;
165
- if (spec.sort)
166
- node.sort = spec.sort;
167
- if (spec.filter)
168
- node.filter = spec.filter;
169
- if (density)
170
- node.density = density;
171
- if (spec.grouping)
172
- node.grouping = spec.grouping;
173
- if (spec.rowColor)
174
- node.rowColor = spec.rowColor;
175
- if (spec.searchableFields)
176
- node.searchableFields = spec.searchableFields;
177
- if (spec.filterableFields)
178
- node.filterableFields = spec.filterableFields;
179
- if (spec.resizable != null)
180
- node.resizable = spec.resizable;
181
- if (spec.striped != null)
182
- node.striped = spec.striped;
183
- if (spec.bordered != null)
184
- node.bordered = spec.bordered;
185
- if (spec.navigation)
186
- node.navigation = spec.navigation;
187
- if (spec.kanban)
188
- node.kanban = spec.kanban;
189
- if (spec.calendar)
190
- node.calendar = spec.calendar;
191
- if (spec.gantt)
192
- node.gantt = spec.gantt;
193
- if (spec.gallery)
194
- node.gallery = spec.gallery;
195
- if (spec.timeline)
196
- node.timeline = spec.timeline;
197
- // P1.1 — Spec Protocol Alignment additions
198
- if (spec.rowActions)
199
- node.rowActions = spec.rowActions;
200
- if (spec.bulkActions)
201
- node.bulkActions = spec.bulkActions;
202
- if (spec.bulkActionDefs)
203
- node.bulkActionDefs = spec.bulkActionDefs;
204
- if (spec.virtualScroll != null)
205
- node.virtualScroll = spec.virtualScroll;
206
- if (spec.conditionalFormatting)
207
- node.conditionalFormatting = spec.conditionalFormatting;
208
- if (spec.inlineEdit != null)
209
- node.inlineEdit = spec.inlineEdit;
210
- if (spec.exportOptions)
211
- node.exportOptions = liftExportOptions(spec.exportOptions);
212
- if (spec.emptyState)
213
- node.emptyState = spec.emptyState;
214
- if (spec.userActions)
215
- node.userActions = spec.userActions;
216
- if (spec.appearance)
217
- node.appearance = spec.appearance;
218
- if (spec.compactToolbar != null)
219
- node.compactToolbar = spec.compactToolbar;
220
- if (spec.addRecord)
221
- node.addRecord = spec.addRecord;
222
- if (spec.showRecordCount != null)
223
- node.showRecordCount = spec.showRecordCount;
224
- if (spec.allowPrinting != null)
225
- node.allowPrinting = spec.allowPrinting;
226
- // P1.6 — i18n & ARIA
227
- if (spec.aria)
228
- node.aria = spec.aria;
229
- // `sharing` is already the spec's `ViewSharing` shape on both sides (#2890) —
230
- // this used to DOWNGRADE it here, inventing a legacy `visibility` audience and
231
- // an `enabled` flag that the renderer then had to fold back.
232
- if (spec.sharing)
233
- node.sharing = spec.sharing;
234
- if (spec.hiddenFields)
235
- node.hiddenFields = spec.hiddenFields;
236
- if (spec.fieldOrder)
237
- node.fieldOrder = spec.fieldOrder;
238
- if (spec.description)
239
- node.description = spec.description;
240
- return node;
241
- };
@@ -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';
9
- export type { BridgeContext, BridgeFn, ObjectDefLite } from './types';
10
- export { bridgeListView } from './bridges/list-view';
11
- export { bridgeFormView } from './bridges/form-view';
@@ -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';
9
- export { bridgeListView } from './bridges/list-view';
10
- export { bridgeFormView } from './bridges/form-view';
@@ -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 {};