@object-ui/fields 6.2.3 → 7.1.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 (97) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/dist/complex-widgets.test.d.ts +1 -0
  3. package/dist/currency.d.ts +13 -0
  4. package/dist/datetime-widgets.test.d.ts +1 -0
  5. package/dist/field-type-coverage.test.d.ts +1 -0
  6. package/dist/index.cjs +4 -3
  7. package/dist/index.d.ts +300 -2
  8. package/dist/index.js +2460 -1274
  9. package/dist/standard-widgets.test.d.ts +0 -0
  10. package/dist/{packages/fields/src/widgets → widgets}/AddressField.d.ts +2 -1
  11. package/dist/{packages/fields/src/widgets → widgets}/AutoNumberField.d.ts +2 -1
  12. package/dist/{packages/fields/src/widgets → widgets}/AvatarField.d.ts +2 -1
  13. package/dist/{packages/fields/src/widgets → widgets}/BooleanField.d.ts +2 -1
  14. package/dist/widgets/CheckboxesField.d.ts +8 -0
  15. package/dist/{packages/fields/src/widgets → widgets}/CodeField.d.ts +2 -1
  16. package/dist/{packages/fields/src/widgets → widgets}/ColorField.d.ts +2 -1
  17. package/dist/{packages/fields/src/widgets → widgets}/CurrencyField.d.ts +2 -1
  18. package/dist/{packages/fields/src/widgets → widgets}/DateField.d.ts +2 -1
  19. package/dist/{packages/fields/src/widgets → widgets}/DateTimeField.d.ts +2 -1
  20. package/dist/{packages/fields/src/widgets → widgets}/EmailField.d.ts +2 -1
  21. package/dist/{packages/fields/src/widgets → widgets}/FileField.d.ts +2 -1
  22. package/dist/{packages/fields/src/widgets → widgets}/FormulaField.d.ts +2 -1
  23. package/dist/{packages/fields/src/widgets → widgets}/GeolocationField.d.ts +2 -1
  24. package/dist/widgets/GridField.d.ts +123 -0
  25. package/dist/widgets/GridField.test.d.ts +1 -0
  26. package/dist/{packages/fields/src/widgets → widgets}/ImageField.d.ts +2 -1
  27. package/dist/{packages/fields/src/widgets → widgets}/LocationField.d.ts +2 -1
  28. package/dist/{packages/fields/src/widgets → widgets}/LookupField.d.ts +2 -1
  29. package/dist/widgets/MarkdownContent.d.ts +9 -0
  30. package/dist/{packages/fields/src/widgets → widgets}/MasterDetailField.d.ts +2 -1
  31. package/dist/widgets/MultiSelectField.d.ts +9 -0
  32. package/dist/{packages/fields/src/widgets → widgets}/NumberField.d.ts +2 -1
  33. package/dist/{packages/fields/src/widgets → widgets}/ObjectField.d.ts +2 -1
  34. package/dist/{packages/fields/src/widgets → widgets}/PasswordField.d.ts +2 -1
  35. package/dist/{packages/fields/src/widgets → widgets}/PercentField.d.ts +2 -1
  36. package/dist/{packages/fields/src/widgets → widgets}/PhoneField.d.ts +2 -1
  37. package/dist/{packages/fields/src/widgets → widgets}/QRCodeField.d.ts +2 -1
  38. package/dist/widgets/RadioField.d.ts +8 -0
  39. package/dist/{packages/fields/src/widgets → widgets}/RatingField.d.ts +2 -1
  40. package/dist/{packages/fields/src/widgets → widgets}/RecordPickerDialog.d.ts +8 -2
  41. package/dist/{packages/fields/src/widgets → widgets}/RichTextField.d.ts +2 -1
  42. package/dist/{packages/fields/src/widgets → widgets}/SelectField.d.ts +2 -1
  43. package/dist/{packages/fields/src/widgets → widgets}/SignatureField.d.ts +2 -1
  44. package/dist/{packages/fields/src/widgets → widgets}/SliderField.d.ts +2 -1
  45. package/dist/{packages/fields/src/widgets → widgets}/SummaryField.d.ts +2 -1
  46. package/dist/widgets/TagsField.d.ts +8 -0
  47. package/dist/{packages/fields/src/widgets → widgets}/TextAreaField.d.ts +2 -1
  48. package/dist/{packages/fields/src/widgets → widgets}/TextField.d.ts +2 -1
  49. package/dist/{packages/fields/src/widgets → widgets}/TimeField.d.ts +2 -1
  50. package/dist/{packages/fields/src/widgets → widgets}/UrlField.d.ts +2 -1
  51. package/dist/{packages/fields/src/widgets → widgets}/UserField.d.ts +2 -1
  52. package/dist/{packages/fields/src/widgets → widgets}/VectorField.d.ts +2 -1
  53. package/dist/widgets/deriveLookupColumns.d.ts +36 -0
  54. package/dist/widgets/deriveLookupColumns.test.d.ts +1 -0
  55. package/dist/widgets/recentLookups.d.ts +13 -0
  56. package/dist/widgets/recentLookups.test.d.ts +1 -0
  57. package/dist/{packages/fields/src/widgets → widgets}/types.d.ts +1 -1
  58. package/package.json +14 -11
  59. package/src/__tests__/registry-collision.test.ts +91 -0
  60. package/src/__tests__/resolveFieldCurrency.test.ts +20 -0
  61. package/src/coerce-safe-value.test.ts +34 -0
  62. package/src/complex-widgets.test.tsx +58 -7
  63. package/src/currency.ts +14 -0
  64. package/src/field-type-coverage.test.ts +65 -0
  65. package/src/index.tsx +372 -57
  66. package/src/widgets/CheckboxesField.tsx +53 -0
  67. package/src/widgets/CurrencyField.tsx +5 -1
  68. package/src/widgets/GridField.test.tsx +309 -0
  69. package/src/widgets/GridField.tsx +907 -33
  70. package/src/widgets/LookupField.tsx +258 -107
  71. package/src/widgets/MarkdownContent.tsx +19 -0
  72. package/src/widgets/MultiSelectField.tsx +59 -0
  73. package/src/widgets/PercentField.tsx +19 -7
  74. package/src/widgets/RadioField.tsx +41 -0
  75. package/src/widgets/RecordPickerDialog.tsx +22 -18
  76. package/src/widgets/SelectField.tsx +23 -2
  77. package/src/widgets/TagsField.tsx +67 -0
  78. package/src/widgets/deriveLookupColumns.test.ts +74 -0
  79. package/src/widgets/deriveLookupColumns.ts +104 -0
  80. package/src/widgets/recentLookups.test.ts +45 -0
  81. package/src/widgets/recentLookups.ts +47 -0
  82. package/src/widgets/useFieldTranslation.ts +30 -0
  83. package/dist/packages/fields/src/fields-edge-cases.stories.d.ts +0 -45
  84. package/dist/packages/fields/src/fields.stories.d.ts +0 -56
  85. package/dist/packages/fields/src/index.d.ts +0 -286
  86. package/dist/packages/fields/src/record-picker-dialog.stories.d.ts +0 -25
  87. package/dist/packages/fields/src/widgets/GridField.d.ts +0 -7
  88. package/src/fields-edge-cases.stories.tsx +0 -407
  89. package/src/fields.stories.tsx +0 -566
  90. package/src/record-picker-dialog.stories.tsx +0 -160
  91. /package/dist/{packages/fields/src/__tests__/validation-feedback.test.d.ts → __tests__/registry-collision.test.d.ts} +0 -0
  92. /package/dist/{packages/fields/src/complex-widgets.test.d.ts → __tests__/resolveFieldCurrency.test.d.ts} +0 -0
  93. /package/dist/{packages/fields/src/standard-widgets.test.d.ts → __tests__/validation-feedback.test.d.ts} +0 -0
  94. /package/dist/{packages/fields/src/datetime-widgets.test.d.ts → coerce-safe-value.test.d.ts} +0 -0
  95. /package/dist/{packages/fields/src/widgets → widgets}/ImageCropperDialog.d.ts +0 -0
  96. /package/dist/{packages/fields/src/widgets → widgets}/_cell-renderer-bridge.d.ts +0 -0
  97. /package/dist/{packages/fields/src/widgets → widgets}/useFieldTranslation.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,208 @@
1
1
  # @object-ui/fields
2
2
 
3
+ ## 7.1.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [677f7ed]
8
+ - Updated dependencies [08c47da]
9
+ - Updated dependencies [a71be60]
10
+ - Updated dependencies [cb03bc3]
11
+ - @object-ui/types@7.1.0
12
+ - @object-ui/core@7.1.0
13
+ - @object-ui/react@7.1.0
14
+ - @object-ui/components@7.1.0
15
+ - @object-ui/providers@7.1.0
16
+ - @object-ui/i18n@7.1.0
17
+
18
+ ## 7.0.0
19
+
20
+ ### Minor Changes
21
+
22
+ - 5332639: feat(app-shell): render full object forms (incl. master-detail) in screen-flow wizard steps
23
+
24
+ `FlowRunner` now renders an `object-form` screen step: when the paused screen
25
+ carries `kind: 'object-form'`, it mounts the real `<ObjectForm>` for the named
26
+ object (auto-routing to `MasterDetailForm` for inline child collections),
27
+ prefilled from the step's `defaults`. The form persists itself (atomic
28
+ master-detail batch), then resumes the run with the saved record id bound to the
29
+ step's `idVariable`. `dataSource`/`objects` are threaded through all three
30
+ `FlowRunner` mount points.
31
+
32
+ Also fixes three pre-existing bugs this surfaced (each affects normal forms too):
33
+
34
+ - **plugin-form**: `ObjectForm` now forwards `initialValues`/`initialData` when
35
+ routing to `MasterDetailForm`, so prefilled header values are no longer
36
+ dropped on master-detail create forms.
37
+ - **fields**: `PercentField` treated values as `0–1` fractions (`value × 100`),
38
+ so a `0–100` field (e.g. `probability` default `50`) rendered as `5000%` —
39
+ exceeding `max=100`, which makes HTML5 constraint validation mark the field
40
+ `:invalid` and silently block the whole form's submit. It now treats a field
41
+ declaring `max > 1` as the `0–100` whole-number convention, matching the
42
+ read-side formatter.
43
+ - **data-objectstack**: `ObjectStackAdapter.batchTransaction` now sends
44
+ `credentials: 'include'`, so master-detail batch saves authenticate under the
45
+ console's cookie session (previously every batch save 401'd).
46
+
47
+ - 66ed3ad: Line-item grid: item-typeahead auto-fill from a lookup column.
48
+
49
+ When a lookup cell's record is picked, `GridField` now copies any of the chosen record's fields whose names match a sibling column (e.g. a product's `unit_price` / `description` drop into the row), then recomputes computed columns — the catalog-typeahead behaviour of QuickBooks / Stripe / NetSuite. Opt out per column with `autofill: false`. `LookupField` gains an optional `onSelectRecord(record)` callback that surfaces the full selected record (not just its id). New pure export `lookupAutofillPatch(columns, col, record)`.
50
+
51
+ - c6445b6: Line-item grid: inline validation, duplicate, and drag-to-reorder.
52
+
53
+ - **Inline per-cell validation** — a required, non-computed cell that's empty on a real (non-ghost) row flags red in place (`aria-invalid` + ring), so errors are visible without submitting.
54
+ - **Duplicate row** — a hover Copy action clones a line (id stripped) directly below it, for near-identical lines.
55
+ - **Drag-to-reorder** — a hover grip handle reorders rows via native drag-and-drop. Set `sort_field` on the grid config to persist order (`row[sortField] = index` stamped on every change); otherwise reorder is order-of-entry.
56
+
57
+ - 80c133c: Spreadsheet-style line-item grid editor.
58
+
59
+ `GridField`'s editable grid mode is reworked into an enterprise line-item editor (the QuickBooks / Stripe / NetSuite pattern), generalised across every inline grid:
60
+
61
+ - **Computed read-only columns** — a child field with an arithmetic `expression` (e.g. `amount = quantity * unit_price`) renders read-only, recomputes live as its inputs change, and writes the result back into the row so it persists and the running total reflects it. A small safe arithmetic evaluator (`+ - * / %`, parens, `record.<field>` refs; no `eval`) powers it.
62
+ - **Trailing "ghost" row** — start-with-one + auto-append: typing in the ghost materialises a real row (index-stable, so focus/caret survive), so you keep entering lines without clicking "Add".
63
+ - **Borderless click-to-focus cells** + role-based column widths (description flexes; qty/price/amount stay narrow).
64
+ - **Keyboard navigation** — Enter / ArrowUp / ArrowDown move between rows in the same column.
65
+ - Per-row "expand to full form" is gated to grids that omit fields (no redundant expand on thin lines).
66
+ - `deriveColumns` surfaces a field `expression` as a computed column; the running-total column prefers the computed/last-currency column. Blank/ghost rows are filtered from the persisted batch (`isBlankRow`).
67
+
68
+ - 5e1b838: Lookup cells in line-item grids. `LineItemsField` columns now support `type: 'lookup'` (with `reference` / `displayField` / `idField`), rendering a real lookup picker per cell that resolves display labels and stores the foreign-key id — so master-detail line grids can reference other objects (category, account, assignee, …) instead of only plain selects.
69
+ - 90acb7f: Master-detail subform + lightweight list primitives (SDUI).
70
+
71
+ - `MasterDetailForm` (`object-master-detail-form`): enter a parent record and its child line items together; client-orchestrated transactional create (parent → FK → bulk children → rollup → cleanup). Enterprise-convention layout (header on top, line grid, single Save bar at the bottom).
72
+ - `LineItemsField` editable child grid (line numbers, right-aligned numerics, running total) and `LineItemsPanel` (`record:line_items`) for detail-page inline edit.
73
+ - `element:definition-list` and `element:repeater` — lightweight, low-chrome list primitives for simple data.
74
+
75
+ - 18728c1: Master-detail entry: lighter layout, compact lookup cells, persisted line order.
76
+
77
+ - **De-framed line-item section** — the subform no longer double-frames the grid in a `Card` (border + `p-6`); it renders as a light label + the grid's own bordered table, reclaiming the width the line table needs.
78
+ - **Compact lookup cells** — `LookupField` gains a `compact` mode (used by grid cells): the selected value shows inline in a borderless single-line trigger instead of a chip stacked above a separate "Select…" button.
79
+ - **Persisted drag-reorder** — `deriveMasterDetail` detects a sort field (`position`/`sort_order`/…), excludes it from the editable columns/row-form, and threads it as the grid's `sort_field` so reordering stamps `row[position] = index` and survives a reload.
80
+
81
+ ### Patch Changes
82
+
83
+ - 2d47e94: B2 follow-ups (A): field conditional rules in inline grids + submit-time enforcement.
84
+
85
+ - **Grids**: a line-item column's `readonlyWhen` / `requiredWhen` CEL rule is now honored per row — `deriveMasterDetail` carries the props onto the `GridColumn` and `GridField` evaluates them against each row via `resolveFieldRuleState` (a `readonlyWhen`-TRUE cell locks; a `requiredWhen`-TRUE empty cell flags inline-invalid). Rules are row-scoped (`record.*`); the core helpers gained an optional `scope` (and `GridField` a `contextRecord` prop) so a future header-driven lock can bind `parent.*` — that wiring is deferred (it needs the master-detail header's re-renders isolated).
86
+ - **Submit enforcement**: `requiredWhen` already drove react-hook-form's `required` rule, so submit is blocked with a field error when the predicate is TRUE and the value is empty. Added a reactive cleanup so a stale _required_ error clears when the predicate flips FALSE (and all errors clear when a field is hidden by `visibleWhen`).
87
+
88
+ - bd398df: Render reference/lookup cells as labels, not raw JSON
89
+
90
+ A `lookup` / `master_detail` value can arrive as a JSON-encoded object string —
91
+ e.g. an unresolved external-id reference `{"externalId":"Website Relaunch"}`.
92
+ `LookupCellRenderer` treated the whole JSON string as an opaque id, failed to
93
+ resolve it, and fell through to `String(value)`, leaking raw JSON into the grid
94
+ cell (and detail/kanban surfaces).
95
+
96
+ - `LookupCellRenderer` now parses a JSON-object-looking string value and renders
97
+ a human label (`name` → `label` → `externalId` → `id`).
98
+ - `coerceToSafeValue` (the shared safe-render helper used by 8 cell renderers)
99
+ gains the same JSON-string parsing, and `externalId` is added to the
100
+ reference-label precedence for plain object values and arrays.
101
+
102
+ Verified in the browser (showcase task grid: Project column shows "Website
103
+ Relaunch" instead of `{"externalId":"Website Relaunch"}`) and by unit tests.
104
+
105
+ - 514f426: fix(master-detail): reliable submit + stable e2e hooks
106
+
107
+ Fixes the "click Create, nothing happens" report, surfaced by a new live browser
108
+ e2e harness that drives the form with real input.
109
+
110
+ - **MasterDetailForm `handleSave`** now triggers the button-less parent form's
111
+ submit from a deferred macrotask and re-queries the live `<form>` inside it.
112
+ Calling `requestSubmit()` synchronously inside the click handler (right after
113
+ the `setSaving` state update) intermittently dropped the nested submit event,
114
+ so react-hook-form's `onSubmit` never ran and the click appeared to do nothing
115
+ — only the occasional click got through. Deferring makes it fire every time.
116
+ - **Stable `data-testid`s** so automation/e2e can drive the widgets
117
+ deterministically (Radix Select + react-hook-form cannot be driven by
118
+ synthetic DOM events): `select-trigger-{field}` / `select-option-{value}`
119
+ (SelectField), `lookup-trigger-{field}` (LookupField), `line-items-add`
120
+ (GridField), `md-form-submit` / `md-form-cancel` (MasterDetailForm).
121
+
122
+ - bd8b054: fix(currency): resolve the tenant default currency across the long-tail renderers
123
+
124
+ Phase 2b of the currency-resolution work (ADR-0053). The cell/field renderers
125
+ already funnelled through `resolveFieldCurrency` + `useLocalization` (#1856),
126
+ but the rest of the renderers still hard-coded `USD` or read only one of
127
+ `currency`/`defaultCurrency`. They now share the same resolution chain — explicit
128
+ field currency -> `currencyConfig.defaultCurrency` -> legacy `defaultCurrency` ->
129
+ tenant `localization.currency` -> plain number:
130
+
131
+ - `plugin-dashboard` `ObjectMetricWidget` (inferred currency), `ObjectDataTable`
132
+ (symbol-format fallback).
133
+ - `plugin-grid` `useColumnSummary` (footer agrees with the cells) and
134
+ `ObjectGrid` (compact amount + name-inferred currency cells).
135
+ - `plugin-detail` `DetailView` summary metrics.
136
+ - `plugin-gantt` `ObjectGantt` currency tooltips.
137
+ - `components` `element:number` (`format: 'currency'`) — tenant default instead
138
+ of a baked-in `USD`, and renders with the tenant locale.
139
+
140
+ `resolveFieldCurrency` now lives in `@object-ui/i18n` (co-located with
141
+ `useLocalization`, which supplies the tenant default); `@object-ui/fields`
142
+ re-exports it, so the existing import path is unchanged. No behavior change when
143
+ no tenant currency is configured — a field that declares its own currency, or a
144
+ deployment with no `localization.currency`, renders exactly as before.
145
+
146
+ - db8cd00: feat(app-shell): global settle signal (window.\_\_objectui) + region aria-busy (ADR-0054 Phase 3)
147
+
148
+ Adds a single machine-readable "is the app idle?" predicate (ADR-0054 C5). The
149
+ data layer wraps the adapter's `fetch` to count in-flight requests, mirrored onto
150
+ `window.__objectui` with live `idle` / `pendingRequests` getters plus `whenIdle()`
151
+ and `subscribe()`. New `useSettleSignal()` React hook and lower-level exports
152
+ (`getPendingRequests`, `subscribeSettle`, `whenIdle`, `withSettleSignal`,
153
+ `installSettleSignalGlobal`). The list view and record-picker results regions now
154
+ set `aria-busy` while fetching and `data-state="loading|idle"` for region-level
155
+ waiting. Lets an automated (AI) driver wait for settle instead of hardcoding
156
+ timeouts.
157
+
158
+ - Updated dependencies [5976ba3]
159
+ - Updated dependencies [a00e16d]
160
+ - Updated dependencies [eaccefd]
161
+ - Updated dependencies [f7f325d]
162
+ - Updated dependencies [c12986e]
163
+ - Updated dependencies [71d7ce0]
164
+ - Updated dependencies [053c948]
165
+ - Updated dependencies [89e113c]
166
+ - Updated dependencies [ddbe4a2]
167
+ - Updated dependencies [2d47e94]
168
+ - Updated dependencies [9049bbe]
169
+ - Updated dependencies [77cc6bb]
170
+ - Updated dependencies [6c0c92c]
171
+ - Updated dependencies [97c6831]
172
+ - Updated dependencies [cb2fdb1]
173
+ - Updated dependencies [c3749eb]
174
+ - Updated dependencies [c09f44e]
175
+ - Updated dependencies [6cfa330]
176
+ - Updated dependencies [ad8ade6]
177
+ - Updated dependencies [d54346c]
178
+ - Updated dependencies [3870c20]
179
+ - Updated dependencies [2eb3096]
180
+ - Updated dependencies [b88c560]
181
+ - Updated dependencies [0ad72a6]
182
+ - Updated dependencies [3fa23a7]
183
+ - Updated dependencies [18d0339]
184
+ - Updated dependencies [59b6bbb]
185
+ - Updated dependencies [d16566f]
186
+ - Updated dependencies [90acb7f]
187
+ - Updated dependencies [7913390]
188
+ - Updated dependencies [1394e34]
189
+ - Updated dependencies [e95cc25]
190
+ - Updated dependencies [abe8ebc]
191
+ - Updated dependencies [300d755]
192
+ - Updated dependencies [bd8b054]
193
+ - Updated dependencies [4eb9cb6]
194
+ - Updated dependencies [7c239fd]
195
+ - Updated dependencies [858ad94]
196
+ - Updated dependencies [2270239]
197
+ - Updated dependencies [2f31406]
198
+ - Updated dependencies [8d1195d]
199
+ - @object-ui/core@7.0.0
200
+ - @object-ui/components@7.0.0
201
+ - @object-ui/react@7.0.0
202
+ - @object-ui/i18n@7.0.0
203
+ - @object-ui/types@7.0.0
204
+ - @object-ui/providers@7.0.0
205
+
3
206
  ## 6.2.3
4
207
 
5
208
  ### Patch Changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * ObjectUI
3
+ * Copyright (c) 2024-present ObjectStack Inc.
4
+ *
5
+ * Licensed under the MIT license found in the LICENSE file.
6
+ */
7
+ /**
8
+ * `resolveFieldCurrency` now lives in `@object-ui/i18n` (co-located with
9
+ * `useLocalization`, which supplies the tenant default). This module re-exports
10
+ * it so the long-standing `@object-ui/fields` import path keeps working for
11
+ * every field/cell renderer that already depends on it.
12
+ */
13
+ export { resolveFieldCurrency } from '@object-ui/i18n';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};