@object-ui/fields 17.3.0 → 17.6.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 (265) hide show
  1. package/CHANGELOG.md +1655 -0
  2. package/README.md +1 -12
  3. package/dist/FieldEditWidget.d.ts +23 -3
  4. package/dist/currency.d.ts +46 -0
  5. package/dist/field-type-alias.d.ts +35 -1
  6. package/dist/index.cjs +4 -4
  7. package/dist/index.css +651 -0
  8. package/dist/index.d.ts +474 -85
  9. package/dist/index.js +5418 -5023
  10. package/dist/widgets/AddressField.d.ts +4 -12
  11. package/dist/widgets/AutoNumberField.d.ts +1 -1
  12. package/dist/widgets/AvatarField.d.ts +1 -1
  13. package/dist/widgets/BooleanField.d.ts +1 -1
  14. package/dist/widgets/CapabilityMultiSelectField.d.ts +1 -1
  15. package/dist/widgets/CheckboxesField.d.ts +1 -1
  16. package/dist/widgets/CodeField.d.ts +1 -1
  17. package/dist/widgets/ColorField.d.ts +1 -1
  18. package/dist/widgets/CurrencyField.d.ts +1 -1
  19. package/dist/widgets/DateField.d.ts +1 -1
  20. package/dist/widgets/DateTimeField.d.ts +1 -1
  21. package/dist/widgets/EmailField.d.ts +1 -1
  22. package/dist/widgets/FileField.d.ts +18 -2
  23. package/dist/widgets/FilterConditionField.d.ts +28 -1
  24. package/dist/widgets/FormulaField.d.ts +1 -1
  25. package/dist/widgets/FullscreenFieldEditor.d.ts +49 -152
  26. package/dist/widgets/GeolocationField.d.ts +1 -1
  27. package/dist/widgets/GridField.d.ts +68 -6
  28. package/dist/widgets/ImageField.d.ts +1 -1
  29. package/dist/widgets/LocationField.d.ts +1 -1
  30. package/dist/widgets/LookupField.d.ts +1 -1
  31. package/dist/widgets/MasterDetailField.d.ts +1 -1
  32. package/dist/widgets/MultiSelectField.d.ts +1 -1
  33. package/dist/widgets/NumberField.d.ts +1 -1
  34. package/dist/widgets/ObjectField.d.ts +1 -1
  35. package/dist/widgets/ObjectRefField.d.ts +1 -1
  36. package/dist/widgets/OptionsEmptyState.d.ts +21 -1
  37. package/dist/widgets/PasswordField.d.ts +1 -1
  38. package/dist/widgets/PercentField.d.ts +1 -1
  39. package/dist/widgets/PhoneField.d.ts +1 -1
  40. package/dist/widgets/QRCodeField.d.ts +1 -1
  41. package/dist/widgets/RadioField.d.ts +1 -1
  42. package/dist/widgets/RatingField.d.ts +1 -1
  43. package/dist/widgets/RecipientPickerField.d.ts +1 -1
  44. package/dist/widgets/RecordPickerDialog.d.ts +34 -10
  45. package/dist/widgets/RichTextField.d.ts +37 -1
  46. package/dist/widgets/SelectField.d.ts +26 -6
  47. package/dist/widgets/SignatureField.d.ts +32 -2
  48. package/dist/widgets/SliderField.d.ts +37 -2
  49. package/dist/widgets/SummaryField.d.ts +1 -1
  50. package/dist/widgets/TagsField.d.ts +1 -1
  51. package/dist/widgets/TextAreaField.d.ts +6 -2
  52. package/dist/widgets/TextField.d.ts +1 -1
  53. package/dist/widgets/TimeField.d.ts +1 -1
  54. package/dist/widgets/UrlField.d.ts +1 -1
  55. package/dist/widgets/UserField.d.ts +1 -1
  56. package/dist/widgets/VectorField.d.ts +1 -1
  57. package/dist/widgets/_cell-renderer-bridge.d.ts +1 -1
  58. package/dist/widgets/address-format.d.ts +88 -0
  59. package/dist/widgets/file-size-guard.d.ts +41 -0
  60. package/dist/widgets/lookupColumnDisplay.d.ts +93 -0
  61. package/dist/widgets/nativeDateValue.d.ts +37 -0
  62. package/dist/widgets/richTextDisplay.d.ts +80 -0
  63. package/dist/widgets/toDomProps.d.ts +30 -10
  64. package/dist/widgets/toHostGroupProps.d.ts +189 -0
  65. package/dist/widgets/types.d.ts +8 -3
  66. package/dist/widgets/useRecordQuery.d.ts +7 -1
  67. package/package.json +17 -14
  68. package/dist/FieldEditWidget.test.d.ts +0 -8
  69. package/dist/__tests__/DateCellRenderer.test.d.ts +0 -0
  70. package/dist/__tests__/NumberCellRenderer.test.d.ts +0 -0
  71. package/dist/__tests__/cell-truncation.test.d.ts +0 -0
  72. package/dist/__tests__/field-carrier-sdui.test.d.ts +0 -0
  73. package/dist/__tests__/lookupCellDisplayField.test.d.ts +0 -0
  74. package/dist/__tests__/lookupCellDisplayName.test.d.ts +0 -0
  75. package/dist/__tests__/lookupCellReferenceKey.test.d.ts +0 -0
  76. package/dist/__tests__/registry-collision.test.d.ts +0 -0
  77. package/dist/__tests__/resolveFieldCurrency.test.d.ts +0 -1
  78. package/dist/__tests__/spec-symbol-batch7.test.d.ts +0 -8
  79. package/dist/__tests__/validation-feedback.test.d.ts +0 -0
  80. package/dist/__tests__/widget-aria-invalid-e2e.test.d.ts +0 -0
  81. package/dist/__tests__/widget-aria-invalid-registry-e2e.test.d.ts +0 -0
  82. package/dist/__tests__/widget-dom-leak-e2e.test.d.ts +0 -0
  83. package/dist/__tests__/widget-props-contract.test.d.ts +0 -8
  84. package/dist/coerce-safe-value.test.d.ts +0 -1
  85. package/dist/complex-widgets.test.d.ts +0 -1
  86. package/dist/datetime-widgets.test.d.ts +0 -1
  87. package/dist/field-type-coverage.test.d.ts +0 -1
  88. package/dist/standard-widgets.test.d.ts +0 -0
  89. package/dist/widgets/AddressField.uniqueIds.test.d.ts +0 -0
  90. package/dist/widgets/CapabilityMultiSelectField.test.d.ts +0 -0
  91. package/dist/widgets/CharacterCount.d.ts +0 -56
  92. package/dist/widgets/CheckboxesField.cascade.test.d.ts +0 -0
  93. package/dist/widgets/GeolocationField.uniqueIds.test.d.ts +0 -0
  94. package/dist/widgets/GridField.test.d.ts +0 -1
  95. package/dist/widgets/ImageLightbox.test.d.ts +0 -1
  96. package/dist/widgets/LookupField.dependsOn.test.d.ts +0 -8
  97. package/dist/widgets/LookupField.gateHintLabel.test.d.ts +0 -8
  98. package/dist/widgets/LookupField.hydration.test.d.ts +0 -1
  99. package/dist/widgets/LookupField.idField.test.d.ts +0 -1
  100. package/dist/widgets/MultiSelectField.cascade.test.d.ts +0 -0
  101. package/dist/widgets/OptionsEmptyState.no-provider.test.d.ts +0 -0
  102. package/dist/widgets/OptionsEmptyState.test.d.ts +0 -0
  103. package/dist/widgets/PeoplePicker.test.d.ts +0 -8
  104. package/dist/widgets/PeoplePickerComponents.test.d.ts +0 -8
  105. package/dist/widgets/RadioField.cascade.test.d.ts +0 -0
  106. package/dist/widgets/RecipientPickerField.test.d.ts +0 -0
  107. package/dist/widgets/RecordPickerDialog.filterOptions.test.d.ts +0 -8
  108. package/dist/widgets/RecordPickerDialog.selectLabel.test.d.ts +0 -8
  109. package/dist/widgets/SelectField.cascade.test.d.ts +0 -0
  110. package/dist/widgets/TagsField.placeholder.no-provider.test.d.ts +0 -0
  111. package/dist/widgets/TagsField.placeholder.test.d.ts +0 -0
  112. package/dist/widgets/UserFieldPicker.test.d.ts +0 -8
  113. package/dist/widgets/__tests__/FilterConditionField.matchAll.test.d.ts +0 -8
  114. package/dist/widgets/__tests__/FilterConditionField.operators.test.d.ts +0 -8
  115. package/dist/widgets/__tests__/FullscreenFieldEditor.i18n.test.d.ts +0 -0
  116. package/dist/widgets/__tests__/FullscreenFieldEditor.no-provider.test.d.ts +0 -0
  117. package/dist/widgets/__tests__/RichTextField.fullscreenDisabled.test.d.ts +0 -0
  118. package/dist/widgets/__tests__/RichTextField.mobileFullscreen.test.d.ts +0 -0
  119. package/dist/widgets/__tests__/TextAreaField.characterCount.announcements.test.d.ts +0 -0
  120. package/dist/widgets/__tests__/TextAreaField.characterCount.i18n.test.d.ts +0 -0
  121. package/dist/widgets/__tests__/TextAreaField.characterCount.no-provider.test.d.ts +0 -0
  122. package/dist/widgets/__tests__/TextAreaField.fullscreenCharacterCount.i18n.test.d.ts +0 -0
  123. package/dist/widgets/__tests__/TextAreaField.fullscreenCharacterCount.test.d.ts +0 -0
  124. package/dist/widgets/__tests__/TextAreaField.fullscreenDisabled.test.d.ts +0 -0
  125. package/dist/widgets/__tests__/TextAreaField.mobileFullscreen.test.d.ts +0 -0
  126. package/dist/widgets/deriveLookupColumns.test.d.ts +0 -1
  127. package/dist/widgets/file-value.test.d.ts +0 -1
  128. package/dist/widgets/personDisplay.test.d.ts +0 -8
  129. package/dist/widgets/recentLookups.test.d.ts +0 -1
  130. package/dist/widgets/useRecordQuery.test.d.ts +0 -8
  131. package/dist/widgets/useUploadingSignal.test.d.ts +0 -1
  132. package/src/FieldEditWidget.test.ts +0 -133
  133. package/src/FieldEditWidget.tsx +0 -191
  134. package/src/__tests__/DateCellRenderer.test.tsx +0 -73
  135. package/src/__tests__/NumberCellRenderer.test.tsx +0 -60
  136. package/src/__tests__/cell-truncation.test.tsx +0 -96
  137. package/src/__tests__/field-carrier-sdui.test.tsx +0 -169
  138. package/src/__tests__/lookupCellDisplayField.test.tsx +0 -107
  139. package/src/__tests__/lookupCellDisplayName.test.tsx +0 -119
  140. package/src/__tests__/lookupCellReferenceKey.test.tsx +0 -57
  141. package/src/__tests__/registry-collision.test.ts +0 -91
  142. package/src/__tests__/resolveFieldCurrency.test.ts +0 -20
  143. package/src/__tests__/spec-symbol-batch7.test.ts +0 -126
  144. package/src/__tests__/validation-feedback.test.tsx +0 -361
  145. package/src/__tests__/widget-aria-invalid-e2e.test.tsx +0 -265
  146. package/src/__tests__/widget-aria-invalid-registry-e2e.test.tsx +0 -338
  147. package/src/__tests__/widget-dom-leak-e2e.test.tsx +0 -598
  148. package/src/__tests__/widget-props-contract.test.tsx +0 -142
  149. package/src/coerce-safe-value.test.ts +0 -34
  150. package/src/complex-widgets.test.tsx +0 -908
  151. package/src/currency.ts +0 -14
  152. package/src/datetime-widgets.test.tsx +0 -93
  153. package/src/field-type-alias.ts +0 -100
  154. package/src/field-type-coverage.test.ts +0 -67
  155. package/src/index.tsx +0 -2503
  156. package/src/standard-widgets.test.tsx +0 -357
  157. package/src/widgets/AddressField.tsx +0 -132
  158. package/src/widgets/AddressField.uniqueIds.test.tsx +0 -92
  159. package/src/widgets/AutoNumberField.tsx +0 -18
  160. package/src/widgets/AvatarField.tsx +0 -117
  161. package/src/widgets/BooleanField.tsx +0 -52
  162. package/src/widgets/CapabilityMultiSelectField.test.tsx +0 -168
  163. package/src/widgets/CapabilityMultiSelectField.tsx +0 -229
  164. package/src/widgets/CharacterCount.tsx +0 -263
  165. package/src/widgets/CheckboxesField.cascade.test.tsx +0 -143
  166. package/src/widgets/CheckboxesField.tsx +0 -136
  167. package/src/widgets/CodeField.tsx +0 -41
  168. package/src/widgets/ColorField.tsx +0 -53
  169. package/src/widgets/CurrencyField.tsx +0 -95
  170. package/src/widgets/DateField.tsx +0 -31
  171. package/src/widgets/DateTimeField.tsx +0 -37
  172. package/src/widgets/EmailField.tsx +0 -37
  173. package/src/widgets/FileField.tsx +0 -494
  174. package/src/widgets/FilterConditionField.tsx +0 -454
  175. package/src/widgets/FormulaField.tsx +0 -33
  176. package/src/widgets/FullscreenFieldEditor.tsx +0 -271
  177. package/src/widgets/GeolocationField.tsx +0 -167
  178. package/src/widgets/GeolocationField.uniqueIds.test.tsx +0 -88
  179. package/src/widgets/GridField.test.tsx +0 -406
  180. package/src/widgets/GridField.tsx +0 -966
  181. package/src/widgets/ImageCropperDialog.tsx +0 -245
  182. package/src/widgets/ImageField.tsx +0 -255
  183. package/src/widgets/ImageLightbox.test.tsx +0 -52
  184. package/src/widgets/ImageLightbox.tsx +0 -108
  185. package/src/widgets/LocationField.tsx +0 -57
  186. package/src/widgets/LookupField.dependsOn.test.tsx +0 -233
  187. package/src/widgets/LookupField.gateHintLabel.test.tsx +0 -135
  188. package/src/widgets/LookupField.hydration.test.tsx +0 -136
  189. package/src/widgets/LookupField.idField.test.tsx +0 -61
  190. package/src/widgets/LookupField.tsx +0 -1291
  191. package/src/widgets/MarkdownContent.tsx +0 -19
  192. package/src/widgets/MasterDetailField.tsx +0 -131
  193. package/src/widgets/MultiSelectField.cascade.test.tsx +0 -143
  194. package/src/widgets/MultiSelectField.tsx +0 -142
  195. package/src/widgets/NumberField.tsx +0 -49
  196. package/src/widgets/ObjectField.tsx +0 -94
  197. package/src/widgets/ObjectRefField.tsx +0 -121
  198. package/src/widgets/OptionsEmptyState.no-provider.test.tsx +0 -88
  199. package/src/widgets/OptionsEmptyState.test.tsx +0 -169
  200. package/src/widgets/OptionsEmptyState.tsx +0 -83
  201. package/src/widgets/PasswordField.tsx +0 -49
  202. package/src/widgets/PeoplePicker.test.tsx +0 -360
  203. package/src/widgets/PeoplePicker.tsx +0 -579
  204. package/src/widgets/PeoplePickerComponents.test.tsx +0 -104
  205. package/src/widgets/PercentField.tsx +0 -95
  206. package/src/widgets/PersonRow.tsx +0 -117
  207. package/src/widgets/PhoneField.tsx +0 -37
  208. package/src/widgets/QRCodeField.tsx +0 -103
  209. package/src/widgets/RadioField.cascade.test.tsx +0 -141
  210. package/src/widgets/RadioField.tsx +0 -111
  211. package/src/widgets/RatingField.tsx +0 -81
  212. package/src/widgets/RecipientPickerField.test.tsx +0 -157
  213. package/src/widgets/RecipientPickerField.tsx +0 -188
  214. package/src/widgets/RecordPickerDialog.filterOptions.test.tsx +0 -611
  215. package/src/widgets/RecordPickerDialog.selectLabel.test.tsx +0 -112
  216. package/src/widgets/RecordPickerDialog.tsx +0 -1316
  217. package/src/widgets/RichTextField.tsx +0 -176
  218. package/src/widgets/SelectField.cascade.test.tsx +0 -138
  219. package/src/widgets/SelectField.tsx +0 -162
  220. package/src/widgets/SelectionTray.tsx +0 -110
  221. package/src/widgets/SignatureField.tsx +0 -140
  222. package/src/widgets/SliderField.tsx +0 -39
  223. package/src/widgets/SummaryField.tsx +0 -31
  224. package/src/widgets/TagsField.placeholder.no-provider.test.tsx +0 -68
  225. package/src/widgets/TagsField.placeholder.test.tsx +0 -95
  226. package/src/widgets/TagsField.tsx +0 -88
  227. package/src/widgets/TextAreaField.tsx +0 -213
  228. package/src/widgets/TextField.tsx +0 -45
  229. package/src/widgets/TimeField.tsx +0 -31
  230. package/src/widgets/UrlField.tsx +0 -46
  231. package/src/widgets/UserField.tsx +0 -58
  232. package/src/widgets/UserFieldPicker.test.tsx +0 -78
  233. package/src/widgets/VectorField.tsx +0 -29
  234. package/src/widgets/__tests__/FilterConditionField.matchAll.test.ts +0 -66
  235. package/src/widgets/__tests__/FilterConditionField.operators.test.ts +0 -142
  236. package/src/widgets/__tests__/FullscreenFieldEditor.i18n.test.tsx +0 -248
  237. package/src/widgets/__tests__/FullscreenFieldEditor.no-provider.test.tsx +0 -116
  238. package/src/widgets/__tests__/RichTextField.fullscreenDisabled.test.tsx +0 -244
  239. package/src/widgets/__tests__/RichTextField.mobileFullscreen.test.tsx +0 -195
  240. package/src/widgets/__tests__/TextAreaField.characterCount.announcements.test.tsx +0 -417
  241. package/src/widgets/__tests__/TextAreaField.characterCount.i18n.test.tsx +0 -287
  242. package/src/widgets/__tests__/TextAreaField.characterCount.no-provider.test.tsx +0 -160
  243. package/src/widgets/__tests__/TextAreaField.fullscreenCharacterCount.i18n.test.tsx +0 -161
  244. package/src/widgets/__tests__/TextAreaField.fullscreenCharacterCount.test.tsx +0 -346
  245. package/src/widgets/__tests__/TextAreaField.fullscreenDisabled.test.tsx +0 -246
  246. package/src/widgets/__tests__/TextAreaField.mobileFullscreen.test.tsx +0 -175
  247. package/src/widgets/_cell-renderer-bridge.ts +0 -19
  248. package/src/widgets/deriveLookupColumns.test.ts +0 -112
  249. package/src/widgets/deriveLookupColumns.ts +0 -108
  250. package/src/widgets/file-value.test.ts +0 -230
  251. package/src/widgets/file-value.ts +0 -246
  252. package/src/widgets/openNativePicker.ts +0 -18
  253. package/src/widgets/personDisplay.test.ts +0 -113
  254. package/src/widgets/personDisplay.ts +0 -92
  255. package/src/widgets/recentLookups.test.ts +0 -45
  256. package/src/widgets/recentLookups.ts +0 -47
  257. package/src/widgets/toDomProps.ts +0 -175
  258. package/src/widgets/types.ts +0 -242
  259. package/src/widgets/useCascadingOptions.ts +0 -46
  260. package/src/widgets/useFieldTranslation.ts +0 -150
  261. package/src/widgets/useRecordQuery.test.ts +0 -174
  262. package/src/widgets/useRecordQuery.ts +0 -264
  263. package/src/widgets/useUploadingSignal.test.tsx +0 -62
  264. package/src/widgets/useUploadingSignal.ts +0 -20
  265. package/src/withFieldCarrier.tsx +0 -75
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import { Input, Textarea, EmptyValue } from '@object-ui/components';
3
- import { TextareaFieldMetadata } from '@object-ui/types';
4
- import { FieldWidgetComponentProps } from './types';
5
- import { toDomProps } from './toDomProps';
6
-
7
- /**
8
- * TextField - Standard single-line or multi-line text input
9
- * Automatically renders as a textarea when rows are configured in field metadata
10
- */
11
- export function TextField({ value, onChange, field, readonly, ...props }: FieldWidgetComponentProps<string>) {
12
- const fieldData = field;
13
-
14
- if (readonly) {
15
- return <span className="text-sm">{value || <EmptyValue />}</span>;
16
- }
17
-
18
- // Cast for rows property
19
- const rows = (fieldData as unknown as TextareaFieldMetadata)?.rows;
20
-
21
- const domProps = toDomProps(props);
22
-
23
- if (rows && rows > 1) {
24
- return (
25
- <Textarea
26
- {...domProps}
27
- value={value || ''}
28
- onChange={(e) => onChange(e.target.value)}
29
- placeholder={fieldData?.placeholder}
30
- disabled={readonly || domProps.disabled}
31
- />
32
- );
33
- }
34
-
35
- return (
36
- <Input
37
- {...domProps}
38
- type={fieldData?.type === 'password' ? 'password' : 'text'}
39
- value={value || ''}
40
- onChange={(e) => onChange(e.target.value)}
41
- placeholder={fieldData?.placeholder}
42
- disabled={readonly || domProps.disabled}
43
- />
44
- );
45
- }
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- import { Input, EmptyValue } from '@object-ui/components';
3
- import { FieldWidgetComponentProps } from './types';
4
- import { toDomProps } from './toDomProps';
5
- import { openNativePicker } from './openNativePicker';
6
-
7
- /**
8
- * TimeField - Time picker input widget
9
- * Uses native time input for hour and minute selection
10
- */
11
- export function TimeField({ value, onChange, field, readonly, ...props }: FieldWidgetComponentProps<string>) {
12
- if (readonly) {
13
- return <span className="text-sm">{value || <EmptyValue />}</span>;
14
- }
15
-
16
- const domProps = toDomProps(props);
17
-
18
- return (
19
- <Input
20
- {...domProps}
21
- type="time"
22
- value={value || ''}
23
- onChange={(e) => onChange(e.target.value)}
24
- onClick={(e) => {
25
- openNativePicker(e.currentTarget);
26
- domProps.onClick?.(e);
27
- }}
28
- disabled={readonly || domProps.disabled}
29
- />
30
- );
31
- }
@@ -1,46 +0,0 @@
1
- import React from 'react';
2
- import { Input, EmptyValue } from '@object-ui/components';
3
- import { FieldWidgetComponentProps } from './types';
4
- import { toDomProps } from './toDomProps';
5
-
6
- /**
7
- * UrlField - URL input with clickable link in readonly mode
8
- * Validates URLs to only render http/https links for security
9
- */
10
- export function UrlField({ value, onChange, field, readonly, error, ...props }: FieldWidgetComponentProps<string>) {
11
- const config = field;
12
- if (readonly) {
13
- if (!value) return <EmptyValue />;
14
-
15
- // Validate URL to prevent javascript: or data: URLs
16
- const isValidUrl = value.startsWith('http://') || value.startsWith('https://');
17
- if (!isValidUrl) {
18
- return <span className="text-sm">{value}</span>;
19
- }
20
-
21
- return (
22
- <a
23
- href={value}
24
- target="_blank"
25
- rel="noopener noreferrer"
26
- className="text-sm text-blue-600 hover:text-blue-800 hover:underline"
27
- >
28
- {value}
29
- </a>
30
- );
31
- }
32
-
33
- const domProps = toDomProps(props);
34
-
35
- return (
36
- <Input
37
- {...domProps}
38
- type="url"
39
- value={value || ''}
40
- onChange={(e) => onChange(e.target.value)}
41
- placeholder={config?.placeholder || 'https://example.com'}
42
- disabled={readonly || domProps.disabled}
43
- aria-invalid={!!error}
44
- />
45
- );
46
- }
@@ -1,58 +0,0 @@
1
- import React from 'react';
2
- import { FieldWidgetComponentProps } from './types';
3
- import { LookupField } from './LookupField';
4
-
5
- /**
6
- * UserField — person picker for the `user` field type.
7
- *
8
- * `user` is a lookup specialized to the `sys_user` system object (see framework
9
- * "lookup → sys_user" specialization). Rather than re-implement candidate search,
10
- * the searchable picker, the record-picker dialog and id resolution, this widget
11
- * **delegates to the shared {@link LookupField}** with the reference fixed to
12
- * `sys_user`. The author writes `Field.user({ multiple })`; we normalise the field
13
- * metadata so the lookup machinery targets users with a sensible display field.
14
- *
15
- * Table-cell display (avatars / initials) is handled separately by
16
- * `UserCellRenderer`; this is the form/editor widget.
17
- *
18
- * By default the user picker is the search-first {@link PeoplePicker}
19
- * (`picker: 'search'`) with a department·email subtitle, avatar, and banned
20
- * users excluded from candidates. Authors can override any of these, or opt
21
- * back to the classic table dialog with `picker: 'default'`.
22
- */
23
-
24
- /** Exclude deactivated (`banned`) users unless the author already filters on it. */
25
- function withBannedFilter(filters?: any[]): any[] {
26
- const base = Array.isArray(filters) ? filters : [];
27
- return base.some(f => f?.field === 'banned')
28
- ? base
29
- : [...base, { field: 'banned', operator: 'ne', value: true }];
30
- }
31
-
32
- export function UserField(props: FieldWidgetComponentProps<any>) {
33
- const raw = props.field as any;
34
-
35
- // The objectSchema field metadata may live directly on `field`, or nested at
36
- // `field.field` when rendered via the createFieldRenderer wrapper — mirror the
37
- // unwrap LookupField itself performs.
38
- const metaIsNested = raw?.field && typeof raw.field === 'object'
39
- && ('reference' in raw.field || 'reference_to' in raw.field || 'type' in raw.field);
40
- const meta = metaIsNested ? raw.field : raw;
41
-
42
- // Ensure the picker always targets sys_user (even if the author omitted an
43
- // explicit reference), presents user names by default, and defaults to the
44
- // search-first PeoplePicker with sensible person display + candidate hygiene.
45
- const normalized = {
46
- ...(meta || {}),
47
- reference: meta?.reference || meta?.reference_to || 'sys_user',
48
- display_field: meta?.display_field || meta?.displayField || meta?.reference_field || 'name',
49
- picker: meta?.picker ?? 'search',
50
- subtitle: meta?.subtitle ?? ['primary_business_unit_id.name', 'email'],
51
- avatar_field: meta?.avatar_field ?? meta?.avatarField ?? 'image',
52
- lookup_filters: withBannedFilter(meta?.lookup_filters ?? meta?.lookupFilters),
53
- };
54
-
55
- const fieldProp = metaIsNested ? { ...raw, field: normalized } : normalized;
56
-
57
- return <LookupField {...(props as any)} field={fieldProp} />;
58
- }
@@ -1,78 +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
- import { render, screen, fireEvent, waitFor } from '@testing-library/react';
10
- import { describe, it, expect, vi, beforeEach } from 'vitest';
11
- import { UserField } from './UserField';
12
-
13
- const USERS = [
14
- { id: 'u1', name: 'Amy Lin', email: 'amy@x.io', image: 'http://x/amy.png', primary_business_unit_id: { name: 'Sales' } },
15
- { id: 'u2', name: 'Bob Wu', email: 'bob@x.io', primary_business_unit_id: { name: 'Eng' } },
16
- ];
17
-
18
- function makeDataSource() {
19
- return {
20
- find: vi.fn(async (_obj: string, params: any = {}) => {
21
- const idIn = params?.$filter?.id?.$in as any[] | undefined;
22
- if (idIn) {
23
- const s = new Set(idIn.map(String));
24
- const data = USERS.filter(u => s.has(String(u.id)));
25
- return { data, total: data.length };
26
- }
27
- const search: string | undefined = params?.$search;
28
- const data = search
29
- ? USERS.filter(u => u.name.toLowerCase().includes(search.toLowerCase()))
30
- : USERS;
31
- return { data, total: data.length };
32
- }),
33
- } as any;
34
- }
35
-
36
- beforeEach(() => {
37
- Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 1280 });
38
- window.matchMedia = ((query: string) => ({
39
- matches: window.innerWidth < 768,
40
- media: query,
41
- onchange: null,
42
- addEventListener: () => {},
43
- removeEventListener: () => {},
44
- addListener: () => {},
45
- removeListener: () => {},
46
- dispatchEvent: () => false,
47
- })) as any;
48
- try {
49
- window.localStorage.clear();
50
- } catch {
51
- /* ignore */
52
- }
53
- });
54
-
55
- describe('UserField — search-first entry (P0)', () => {
56
- it('opens the PeoplePicker from the primary trigger (no separate browse-all button)', async () => {
57
- const ds = makeDataSource();
58
- render(<UserField field={{ type: 'user' } as any} dataSource={ds} value={null} onChange={vi.fn()} />);
59
-
60
- // The redundant "browse all" icon is not rendered for search-first fields.
61
- expect(screen.queryByTestId('browse-all-records')).toBeNull();
62
-
63
- // Primary click opens the rich PeoplePicker (its search box appears).
64
- fireEvent.click(screen.getByTestId('lookup-trigger'));
65
- await waitFor(() => expect(screen.getByTestId('people-picker-search')).toBeTruthy());
66
- });
67
-
68
- it('renders the current selection as avatar chips', async () => {
69
- const ds = makeDataSource();
70
- render(
71
- <UserField field={{ type: 'user', multiple: true } as any} dataSource={ds} value={['u1']} onChange={vi.fn()} />,
72
- );
73
- await waitFor(() => expect(screen.getByTestId('people-field-chip')).toBeTruthy());
74
- expect(screen.getByText('Amy Lin')).toBeTruthy();
75
- // Initials fallback renders (image does not load in jsdom).
76
- expect(screen.getByText('AL')).toBeTruthy();
77
- });
78
- });
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { EmptyValue } from '@object-ui/components';
3
- import { FieldWidgetComponentProps } from './types';
4
-
5
- /**
6
- * VectorField - Vector/embedding data display
7
- * Shows vector embeddings in a read-only format
8
- */
9
- export function VectorField({ value, field, ...props }: FieldWidgetComponentProps<number[]>) {
10
- const vectorField = field as any;
11
- const dimensions = vectorField?.dimensions || (Array.isArray(value) ? value.length : 0);
12
-
13
- if (!value || !Array.isArray(value)) {
14
- return <EmptyValue />;
15
- }
16
-
17
- // Show first few values and total dimensions
18
- const preview = value.slice(0, 3).map(v => {
19
- const num = Number(v);
20
- return isNaN(num) ? '0' : num.toFixed(4);
21
- }).join(', ');
22
-
23
- return (
24
- <div className={`text-sm ${props.className || ''}`}>
25
- <span className="font-mono text-gray-700">[{preview}...]</span>
26
- <span className="text-gray-500 ml-2">({dimensions}D)</span>
27
- </div>
28
- );
29
- }
@@ -1,66 +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
- /**
10
- * Empty-criteria guard for the sharing-rule criteria builder
11
- * (objectstack#3896).
12
- *
13
- * This widget used to tell an admin that an empty criteria meant "All
14
- * records" — the most dangerous thing it could say, because it was describing
15
- * a bug as a feature. A sharing rule with no predicate was stored as
16
- * `criteria_json: null` and then evaluated as `find(object, { filter: {} })`,
17
- * i.e. every record of the object granted to the recipient. `SharingRuleSchema`
18
- * had always forbidden that shape ("never seeded as a permissive match-all",
19
- * ADR-0049); the REST and data-API entries just never checked.
20
- *
21
- * The server now refuses to save such a rule and shares nothing for one
22
- * already stored. These tests pin the client-side mirror of that predicate, so
23
- * the widget warns while the admin is still looking at the empty builder
24
- * rather than after a rejected save.
25
- */
26
- import { describe, it, expect } from 'vitest';
27
- import { isMatchAllCriteria } from '../FilterConditionField';
28
-
29
- describe('isMatchAllCriteria — shapes that would share every record', () => {
30
- it('flags the empty and vacuous shapes', () => {
31
- for (const shape of [
32
- undefined,
33
- null,
34
- {}, // what a blank builder / blank textarea parses to
35
- [],
36
- true,
37
- 42,
38
- { $and: [] },
39
- { $or: [] },
40
- { $and: [{}] },
41
- { $or: [{ stage: 'won' }, {}] }, // one unconstrained branch opens the OR
42
- ]) {
43
- expect(isMatchAllCriteria(shape), `${JSON.stringify(shape) ?? String(shape)}`).toBe(true);
44
- }
45
- });
46
-
47
- it('passes anything that actually narrows the result set', () => {
48
- for (const shape of [
49
- { stage: 'won' },
50
- { amount: { $gte: 100000 } },
51
- [{ stage: 'won' }],
52
- { $and: [{ stage: 'won' }] },
53
- { $or: [{ a: 1 }, { b: 2 }] },
54
- { health: 'red', budget: { $gt: 1 } },
55
- ]) {
56
- expect(isMatchAllCriteria(shape), JSON.stringify(shape)).toBe(false);
57
- }
58
- });
59
-
60
- it('agrees with the server on the reported case: a rule saved with no criteria', () => {
61
- // The builder emits '' for an empty group, which the widget parses to {}.
62
- expect(isMatchAllCriteria({})).toBe(true);
63
- // …and one real condition is enough to clear the gate.
64
- expect(isMatchAllCriteria({ health: 'red' })).toBe(false);
65
- });
66
- });
@@ -1,142 +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
- /**
10
- * Operator spelling guard for the sharing-rule criteria builder (#2901).
11
- *
12
- * `condToMongo` emitted `$ncontains` — a token that appears nowhere in
13
- * `@objectstack/spec` and that objectui's own `convertFiltersToAST` throws on,
14
- * naming the correct spelling (`$notContains`) in its error message. So every
15
- * "does not contain" rule authored here validated in the UI and was then
16
- * rejected downstream. Nothing caught it because the builder's operator list is
17
- * hand-written and never compared against the spec vocabulary.
18
- *
19
- * These tests pin the emitted spellings against `FieldOperatorsSchema`'s keys
20
- * and pin the round-trip, including the pre-fix spelling that stored criteria
21
- * still carry.
22
- */
23
- import { describe, it, expect } from 'vitest';
24
- import { FieldOperatorsSchema } from '@objectstack/spec/data';
25
- import { condToMongo, kvToCondition } from '../FilterConditionField';
26
-
27
- /**
28
- * The `$`-prefixed operator keys of the spec's `FieldOperatorsSchema` —
29
- * DERIVED from the schema (#2942), so a 16th operator landing in the spec
30
- * fails the reachability test below instead of drifting unnoticed.
31
- */
32
- const SPEC_OPERATORS = new Set(
33
- Object.keys((FieldOperatorsSchema as unknown as { shape?: Record<string, unknown> }).shape ?? {}),
34
- );
35
-
36
- const noTypes = () => undefined;
37
-
38
- /** Pull the operator keys out of a `{ field: { $op: v } }` fragment. */
39
- function operatorsOf(frag: Record<string, any> | null): string[] {
40
- if (!frag) return [];
41
- return Object.values(frag).flatMap((v) =>
42
- v !== null && typeof v === 'object' && !Array.isArray(v) ? Object.keys(v) : [],
43
- );
44
- }
45
-
46
- describe('condToMongo emits only spec operator spellings', () => {
47
- const builderOperators = [
48
- 'equals', 'notEquals', 'contains', 'notContains', 'isEmpty', 'isNotEmpty',
49
- 'greaterThan', 'lessThan', 'greaterOrEqual', 'lessOrEqual', 'in', 'notIn',
50
- 'before', 'after',
51
- 'startsWith', 'endsWith', 'isNull', 'isNotNull', 'exists', 'notExists',
52
- ];
53
-
54
- it.each(builderOperators)('%s emits a spec-defined operator', (operator) => {
55
- const frag = condToMongo(
56
- { id: 'c1', field: 'name', operator, value: operator === 'in' || operator === 'notIn' ? ['a'] : 'a' } as any,
57
- noTypes,
58
- );
59
- const unknown = operatorsOf(frag).filter((op) => !SPEC_OPERATORS.has(op));
60
- expect(unknown, `${operator} emits an operator @objectstack/spec does not define`).toEqual([]);
61
- });
62
-
63
- it('notContains emits $notContains, not the pre-fix $ncontains', () => {
64
- const frag = condToMongo({ id: 'c1', field: 'name', operator: 'notContains', value: 'x' } as any, noTypes);
65
- expect(frag).toEqual({ name: { $notContains: 'x' } });
66
- });
67
-
68
- it('between emits a range the spec defines', () => {
69
- const frag = condToMongo({ id: 'c1', field: 'age', operator: 'between', value: [1, 5] } as any, noTypes);
70
- expect(operatorsOf(frag).every((op) => SPEC_OPERATORS.has(op))).toBe(true);
71
- });
72
- });
73
-
74
- describe('every spec field operator is reachable from the builder (#2942)', () => {
75
- it('reads a non-empty operator vocabulary from the spec', () => {
76
- expect([...SPEC_OPERATORS].length, 'could not read FieldOperatorsSchema.shape').toBeGreaterThan(0);
77
- });
78
-
79
- it('some builder operator emits every spec $-token', () => {
80
- const builderOperators = [
81
- 'equals', 'notEquals', 'contains', 'notContains', 'isEmpty', 'isNotEmpty',
82
- 'greaterThan', 'lessThan', 'greaterOrEqual', 'lessOrEqual', 'in', 'notIn',
83
- 'before', 'after', 'between',
84
- 'startsWith', 'endsWith', 'isNull', 'isNotNull', 'exists', 'notExists',
85
- ];
86
- const emitted = new Set<string>();
87
- for (const operator of builderOperators) {
88
- const value = operator === 'in' || operator === 'notIn' ? ['a'] : operator === 'between' ? [1, 5] : 'a';
89
- const frag = condToMongo({ id: 'c1', field: 'f', operator, value } as any, noTypes);
90
- for (const op of operatorsOf(frag)) emitted.add(op);
91
- }
92
- // `$eq` is the spec's IMPLICIT equality form — `equals` deliberately
93
- // emits the bare `{ field: value }` shape, never an explicit `$eq`.
94
- // `$between` stays covered by the `$gte`+`$lte` pair `between` emits
95
- // (kvToCondition reads that pair back as `between`).
96
- const unreachable = [...SPEC_OPERATORS].filter(
97
- (op) => op !== '$eq' && op !== '$between' && !emitted.has(op),
98
- );
99
- expect(
100
- unreachable,
101
- 'FieldOperatorsSchema accepts these but no builder operator can author them',
102
- ).toEqual([]);
103
- });
104
- });
105
-
106
- describe('kvToCondition round-trips what condToMongo writes', () => {
107
- const cases: Array<[string, unknown]> = [
108
- ['notEquals', 'a'],
109
- ['contains', 'a'],
110
- ['notContains', 'a'],
111
- ['greaterThan', 1],
112
- ['lessThan', 1],
113
- ['greaterOrEqual', 1],
114
- ['lessOrEqual', 1],
115
- ['startsWith', 'a'],
116
- ['endsWith', 'a'],
117
- ['isNull', ''],
118
- ['isNotNull', ''],
119
- ['exists', ''],
120
- ['notExists', ''],
121
- ];
122
-
123
- it.each(cases)('%s survives the round trip', (operator, value) => {
124
- const frag = condToMongo({ id: 'c1', field: 'f', operator, value } as any, noTypes)!;
125
- const [[field, v]] = Object.entries(frag);
126
- expect(kvToCondition(field, v, 0)).toMatchObject({ field: 'f', operator });
127
- });
128
-
129
- it('still reads the pre-fix $ncontains so stored criteria keep loading', () => {
130
- // Dropping this would make rules saved before the fix fail to load entirely
131
- // ("criteria can't be represented") rather than migrate.
132
- expect(kvToCondition('name', { $ncontains: 'x' }, 0)).toMatchObject({
133
- field: 'name',
134
- operator: 'notContains',
135
- value: 'x',
136
- });
137
- });
138
-
139
- it('rejects an operator it cannot represent rather than guessing', () => {
140
- expect(kvToCondition('name', { $nope: 'x' }, 0)).toBeNull();
141
- });
142
- });