@dxos/react-ui-form 0.8.4-main.9735255 → 0.8.4-main.9be5663bfe

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 (119) hide show
  1. package/README.md +0 -1
  2. package/dist/lib/browser/index.mjs +989 -674
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +989 -674
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
  9. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +62 -61
  11. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  12. package/dist/types/src/components/Form/Form.d.ts +23 -18
  13. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  14. package/dist/types/src/components/Form/Form.stories.d.ts +68 -67
  15. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/FormField.d.ts +7 -1
  17. package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -1
  19. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
  21. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/FormFieldSet.d.ts +9 -10
  23. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
  25. package/dist/types/src/components/Form/fields/RefField.d.ts +8 -6
  26. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
  27. package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
  28. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +62 -61
  29. package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
  30. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +9 -0
  31. package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -0
  32. package/dist/types/src/components/ObjectForm/index.d.ts +2 -0
  33. package/dist/types/src/components/ObjectForm/index.d.ts.map +1 -0
  34. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +10 -2
  35. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  36. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +62 -61
  37. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +9 -0
  39. package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -0
  40. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +83 -0
  41. package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -0
  42. package/dist/types/src/components/ObjectProperties/index.d.ts +2 -0
  43. package/dist/types/src/components/ObjectProperties/index.d.ts.map +1 -0
  44. package/dist/types/src/components/Settings/Settings.d.ts +35 -0
  45. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
  46. package/dist/types/src/components/Settings/Settings.stories.d.ts +82 -0
  47. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
  48. package/dist/types/src/components/Settings/index.d.ts +2 -0
  49. package/dist/types/src/components/Settings/index.d.ts.map +1 -0
  50. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
  51. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  52. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +66 -64
  53. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  54. package/dist/types/src/components/index.d.ts +3 -1
  55. package/dist/types/src/components/index.d.ts.map +1 -1
  56. package/dist/types/src/components/testing.d.ts.map +1 -1
  57. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
  58. package/dist/types/src/hooks/useKeyHandler.d.ts +2 -1
  59. package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -1
  60. package/dist/types/src/translations.d.ts +62 -61
  61. package/dist/types/src/translations.d.ts.map +1 -1
  62. package/dist/types/src/util/index.d.ts +0 -1
  63. package/dist/types/src/util/index.d.ts.map +1 -1
  64. package/dist/types/src/util/refs.d.ts +1 -0
  65. package/dist/types/src/util/refs.d.ts.map +1 -1
  66. package/dist/types/tsconfig.tsbuildinfo +1 -1
  67. package/package.json +37 -38
  68. package/src/components/FieldEditor/FieldEditor.stories.tsx +7 -8
  69. package/src/components/FieldEditor/FieldEditor.test.tsx +0 -1
  70. package/src/components/FieldEditor/FieldEditor.tsx +3 -4
  71. package/src/components/Form/AUDIT.md +17 -0
  72. package/src/components/Form/Form.stories.tsx +25 -26
  73. package/src/components/Form/Form.tsx +100 -66
  74. package/src/components/Form/FormField.tsx +32 -14
  75. package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
  76. package/src/components/Form/FormFieldComponent.tsx +17 -20
  77. package/src/components/Form/FormFieldSet.tsx +126 -105
  78. package/src/components/Form/fields/ArrayField.tsx +11 -8
  79. package/src/components/Form/fields/GeoPointField.tsx +6 -6
  80. package/src/components/Form/fields/MarkdownField.tsx +1 -1
  81. package/src/components/Form/fields/RefField.tsx +37 -20
  82. package/src/components/Form/fields/SelectField.tsx +1 -1
  83. package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -3
  84. package/src/components/Form/fields/SelectOptionField.tsx +9 -10
  85. package/src/components/Form/fields/TupleField.tsx +1 -1
  86. package/src/components/ObjectForm/ObjectForm.tsx +113 -0
  87. package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
  88. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +13 -18
  89. package/src/components/ObjectPicker/ObjectPicker.tsx +71 -60
  90. package/src/components/ObjectProperties/ObjectProperties.stories.tsx +63 -0
  91. package/src/components/ObjectProperties/ObjectProperties.tsx +129 -0
  92. package/src/components/ObjectProperties/index.ts +5 -0
  93. package/src/components/Settings/Settings.stories.tsx +55 -0
  94. package/src/components/Settings/Settings.tsx +129 -0
  95. package/src/components/Settings/index.ts +5 -0
  96. package/src/components/ViewEditor/ViewEditor.stories.tsx +36 -33
  97. package/src/components/ViewEditor/ViewEditor.test.tsx +3 -7
  98. package/src/components/ViewEditor/ViewEditor.tsx +99 -70
  99. package/src/components/index.ts +3 -1
  100. package/src/components/testing.tsx +20 -8
  101. package/src/hooks/useFormHandler.ts +42 -24
  102. package/src/hooks/useKeyHandler.tsx +7 -7
  103. package/src/translations.ts +63 -63
  104. package/src/util/index.ts +0 -1
  105. package/src/util/refs.ts +7 -3
  106. package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
  107. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
  108. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +0 -87
  109. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
  110. package/dist/types/src/components/ControlSection/index.d.ts +0 -2
  111. package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
  112. package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
  113. package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
  114. package/dist/types/src/util/echo.d.ts +0 -6
  115. package/dist/types/src/util/echo.d.ts.map +0 -1
  116. package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
  117. package/src/components/ControlSection/ControlSection.tsx +0 -153
  118. package/src/components/Form/Form-old.stories.tsx +0 -314
  119. package/src/util/echo.ts +0 -25
@@ -4,19 +4,27 @@
4
4
 
5
5
  import React, { type PropsWithChildren } from 'react';
6
6
 
7
- import { type ThemedClassName } from '@dxos/react-ui';
8
- import { Card } from '@dxos/react-ui-mosaic';
9
- import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
10
- import { textBlockWidth } from '@dxos/ui-theme';
7
+ import { Column, type ThemedClassName } from '@dxos/react-ui';
8
+ import { Json } from '@dxos/react-ui-syntax-highlighter';
9
+ import { mx } from '@dxos/ui-theme';
11
10
 
12
11
  type TestLayoutProps = ThemedClassName<PropsWithChildren<{ json?: any }>>;
13
12
 
14
13
  export const TestLayout = ({ classNames, children, json }: TestLayoutProps) => {
15
14
  return (
16
- <div className='is-full bs-full grid grid-cols-[1fr_1fr] p-4 gap-4 overflow-hidden'>
17
- <TestPanel classNames={['flex flex-col bs-full overflow-y-auto', classNames]}>{children}</TestPanel>
15
+ <div className='h-full w-full grid grid-cols-[1fr_1fr] p-4 gap-4 overflow-hidden'>
16
+ <TestPanel classNames={['dx-container', classNames]}>
17
+ <Column.Root classNames='dx-container' gutter='sm'>
18
+ {children}
19
+ </Column.Root>
20
+ </TestPanel>
18
21
  <TestPanel classNames={'overflow-hidden'}>
19
- <JsonFilter testId='debug' data={json} classNames='bs-full text-xs' />
22
+ <Json.Root data={json}>
23
+ <Json.Content classNames='h-full'>
24
+ <Json.Filter />
25
+ <Json.Data testId='debug' classNames='text-xs' />
26
+ </Json.Content>
27
+ </Json.Root>
20
28
  </TestPanel>
21
29
  </div>
22
30
  );
@@ -25,7 +33,11 @@ export const TestLayout = ({ classNames, children, json }: TestLayoutProps) => {
25
33
  type TestPanelProps = ThemedClassName<PropsWithChildren>;
26
34
 
27
35
  const TestPanel = ({ classNames, children }: TestPanelProps) => {
28
- return <Card.Root classNames={['bs-full overflow-y-auto', textBlockWidth, classNames]}>{children}</Card.Root>;
36
+ return (
37
+ <div role='none' className={mx(['dx-document h-full bg-modal-surface rounded-md', classNames])}>
38
+ {children}
39
+ </div>
40
+ );
29
41
  };
30
42
 
31
43
  // Symbol for accessing debug objects in tests.
@@ -7,22 +7,13 @@ import type * as Schema from 'effect/Schema';
7
7
  import type * as SchemaAST from 'effect/SchemaAST';
8
8
  import { useCallback, useEffect, useMemo, useState } from 'react';
9
9
 
10
- import { Obj } from '@dxos/echo';
11
10
  import { type AnyProperties } from '@dxos/echo/internal';
12
- import {
13
- type JsonPath,
14
- createJsonPath,
15
- fromEffectValidationPath,
16
- getValue as getValue$,
17
- setValue as setValue$,
18
- } from '@dxos/effect';
11
+ import { type JsonPath, createJsonPath, fromEffectValidationPath, getValue as getValue$ } from '@dxos/effect';
19
12
  import { log } from '@dxos/log';
20
13
  import { useDefaultValue } from '@dxos/react-ui';
21
14
  import { type ValidationError, validateSchema } from '@dxos/schema';
22
15
  import { type MaybePromise } from '@dxos/util';
23
16
 
24
- import { setValueEchoAware } from '../util';
25
-
26
17
  export type FormFieldStatus = {
27
18
  status?: 'error';
28
19
  error?: string;
@@ -139,11 +130,15 @@ export const useFormHandler = <T extends AnyProperties>({
139
130
  prop: valuesProp,
140
131
  defaultProp: defaultValues,
141
132
  onChange: () => {
142
- setValues(valuesProp ?? defaultValues);
143
- setChanged({});
144
- setTouched({});
145
- setErrors({});
146
- setSaving(false);
133
+ // Only reset when controlled: parent passed new values.
134
+ // Uncontrolled updates come from setValues in onValueChange.
135
+ if (valuesProp !== undefined) {
136
+ setValues(valuesProp ?? defaultValues);
137
+ setChanged({});
138
+ setTouched({});
139
+ setErrors({});
140
+ setSaving(false);
141
+ }
147
142
  },
148
143
  });
149
144
  // TODO(wittjosiah): Upgrade @radix-ui/react-use-controllable-state.
@@ -259,6 +254,7 @@ export const useFormHandler = <T extends AnyProperties>({
259
254
  log('onValueChange', { path, value });
260
255
 
261
256
  const jsonPath = createJsonPath(path);
257
+ const pathArray = path;
262
258
  let parsedValue = value as any;
263
259
  try {
264
260
  if (type._tag === 'NumberKeyword') {
@@ -269,24 +265,25 @@ export const useFormHandler = <T extends AnyProperties>({
269
265
  parsedValue = undefined;
270
266
  }
271
267
 
272
- // Update.
273
- // For ECHO objects, mutate in place via Obj.change(); for plain objects, spread to create new reference.
274
- const newValues = Obj.isObject(values)
275
- ? (setValueEchoAware(values, jsonPath, parsedValue), values)
276
- : { ...setValue$(values, jsonPath, parsedValue) };
277
- setValues(newValues);
268
+ // Create merged values for validation and callback. Form never mutates; parent applies via onValuesChanged.
269
+ const newValues = mergeAtPath(values, pathArray as (string | number)[], parsedValue) as Partial<T>;
278
270
 
279
271
  // TODO(burdon): Check value has changed from original.
280
272
  const newChanged = { [jsonPath]: true };
281
- setChanged({ ...changed, ...newChanged });
273
+ setChanged((prev) => ({ ...prev, ...newChanged }));
282
274
 
283
275
  // Validate.
284
276
  const isValid = validate(newValues);
285
277
 
286
- // Callback.
278
+ // Notify parent; parent is responsible for applying the change.
287
279
  onValuesChanged?.(newValues, { isValid, changed: newChanged });
280
+
281
+ // For uncontrolled mode, update internal state. Controlled mode relies on parent to pass new values.
282
+ if (valuesProp === undefined) {
283
+ setValues(newValues);
284
+ }
288
285
  },
289
- [values, changed, validate, onValuesChanged],
286
+ [values, validate, onValuesChanged, valuesProp],
290
287
  );
291
288
 
292
289
  const onBlur = useCallback(
@@ -347,6 +344,27 @@ export const useFormHandler = <T extends AnyProperties>({
347
344
  );
348
345
  };
349
346
 
347
+ /**
348
+ * Creates a new object with value at path. Does not mutate source.
349
+ * Preserves arrays when path segments are numeric indices.
350
+ */
351
+ const mergeAtPath = (obj: any, path: readonly (string | number)[], value: any): any => {
352
+ if (path.length === 0) {
353
+ return value;
354
+ }
355
+
356
+ const [head, ...rest] = path;
357
+ const child = rest.length === 0 ? value : mergeAtPath(obj?.[head], rest, value);
358
+
359
+ if (Array.isArray(obj)) {
360
+ const copy = [...obj];
361
+ copy[head as number] = child;
362
+ return copy;
363
+ }
364
+
365
+ return { ...obj, [head]: child };
366
+ };
367
+
350
368
  const flatMap = (errors: ValidationError[]) => {
351
369
  return errors.reduce(
352
370
  (result, { path, message }) => {
@@ -2,7 +2,7 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useCallback, useEffect } from 'react';
5
+ import { type RefObject, useCallback, useLayoutEffect } from 'react';
6
6
 
7
7
  import { addEventListener } from '@dxos/async';
8
8
 
@@ -11,7 +11,7 @@ import { type FormHandler } from './useFormHandler';
11
11
  /**
12
12
  * Key handler.
13
13
  */
14
- export const useKeyHandler = (formElement: HTMLDivElement | null, form: FormHandler<any>) => {
14
+ export const useKeyHandler = (elRef: RefObject<HTMLDivElement | null>, form: FormHandler<any>) => {
15
15
  const handleKeyDown = useCallback(
16
16
  (event: KeyboardEvent) => {
17
17
  switch (event.key) {
@@ -26,12 +26,12 @@ export const useKeyHandler = (formElement: HTMLDivElement | null, form: FormHand
26
26
  [form.isValid, form.canSave, form.onSave, form.autoSave],
27
27
  );
28
28
 
29
- useEffect(() => {
30
- if (!formElement) {
29
+ useLayoutEffect(() => {
30
+ const el = elRef.current;
31
+ if (!el) {
31
32
  return;
32
33
  }
33
34
 
34
- // TODO(burdon): Move to @dxos/dom-util.
35
- return addEventListener(formElement, 'keydown', handleKeyDown);
36
- }, [formElement, handleKeyDown]);
35
+ return addEventListener(el, 'keydown', handleKeyDown);
36
+ }, [elRef, handleKeyDown]);
37
37
  };
@@ -10,79 +10,79 @@ export const translations = [
10
10
  {
11
11
  'en-US': {
12
12
  [translationKey]: {
13
- 'fields label': 'Fields',
14
- 'hidden fields label': 'Hidden Fields',
15
- 'empty readonly ref field label': '(none)',
13
+ 'fields.label': 'Fields',
14
+ 'hidden-fields.label': 'Hidden Fields',
15
+ 'empty-readonly-ref-field.label': '(none)',
16
16
 
17
- // TODO(burdon): Standardize field/property.
18
- 'add property button label': 'Add property',
19
- 'field property label': 'Property',
20
- 'field property placeholder': 'Property name',
21
- 'field format label': 'Type',
22
- 'field path label': 'Field path',
23
- 'add field': 'Add field',
24
- 'delete field': 'Delete field',
25
- 'field limit reached': 'Maximum number of fields reached',
26
- 'boolean input true value': 'Yes',
27
- 'boolean input false value': 'No',
28
- 'show field label': 'Show field',
29
- 'hide field label': 'Hide field',
30
- 'delete field label': 'Delete field',
31
- 'ref field combobox input placeholder': 'Search…',
32
- 'ref field placeholder_one': 'Select…',
33
- 'ref field placeholder_other': 'Select items…',
17
+ 'add-property-button.label': 'Add property',
18
+ 'field-property.label': 'Property',
19
+ 'field-property.placeholder': 'Property name',
20
+ 'field-format.label': 'Type',
21
+ 'field-path.label': 'Field path',
22
+ 'add-field.button': 'Add field',
23
+ 'boolean-input-true.value': 'Yes',
24
+ 'boolean-input-false.value': 'No',
25
+ 'show-field.label': 'Show field',
26
+ 'hide-field.label': 'Hide field',
27
+ 'delete-field.label': 'Delete field',
28
+ 'ref-field-combobox-input.placeholder': 'Search…',
29
+ 'ref-field.placeholder': 'Select…',
30
+ 'ref-field.placeholder_one': 'Select…',
31
+ 'ref-field.placeholder_other': 'Select items…',
32
+ 'create-option.label': 'Create',
33
+ 'add-tag.label': 'Add tag',
34
34
 
35
- 'example placeholder': 'Example',
36
- 'latitude placeholder': 'Latitude (e.g., 40.7128)',
37
- 'longitude placeholder': 'Longitude (e.g., -74.0060)',
35
+ 'example.placeholder': 'Example',
36
+ 'latitude.placeholder': 'Latitude (e.g., 40.7128)',
37
+ 'longitude.placeholder': 'Longitude (e.g., -74.0060)',
38
38
 
39
- 'cancel button label': 'Cancel',
40
- 'save button label': 'Save',
39
+ 'cancel-button.label': 'Cancel',
40
+ 'save-button.label': 'Save',
41
41
 
42
- // FormatEnum
43
- 'format boolean': 'Boolean',
44
- 'format currency': 'Currency',
45
- 'format date': 'Date',
46
- 'format date-time': 'DateTime',
47
- 'format did': 'DID',
48
- 'format duration': 'Duration',
49
- 'format dxn': 'DXN',
50
- 'format email': 'Email',
51
- 'format formula': 'Formula',
52
- 'format hostname': 'Hostname',
53
- 'format integer': 'Integer',
54
- 'format json': 'JSON',
55
- 'format lnglat': 'Geopoint',
56
- 'format markdown': 'Markdown',
57
- 'format percent': 'Percent',
58
- 'format ref': 'Reference',
59
- 'format regex': 'RegExp',
60
- 'format string': 'String',
61
- 'format single-select': 'Select',
62
- 'format multi-select': 'Multi-select',
63
- 'format text': 'Long text',
64
- 'format time': 'Time',
65
- 'format timestamp': 'Timestamp',
66
- 'format user': 'User',
67
- 'format number': 'Number',
68
- 'format uri': 'URI',
69
- 'format url': 'URL',
70
- 'format uuid': 'UUID',
42
+ // TypeFormat
43
+ 'format.boolean.label': 'Boolean',
44
+ 'format.currency.label': 'Currency',
45
+ 'format.date.label': 'Date',
46
+ 'format.date-time.label': 'DateTime',
47
+ 'format.did.label': 'DID',
48
+ 'format.duration.label': 'Duration',
49
+ 'format.dxn.label': 'DXN',
50
+ 'format.email.label': 'Email',
51
+ 'format.formula.label': 'Formula',
52
+ 'format.hostname.label': 'Hostname',
53
+ 'format.integer.label': 'Integer',
54
+ 'format.json.label': 'JSON',
55
+ 'format.lnglat.label': 'Geopoint',
56
+ 'format.markdown.label': 'Markdown',
57
+ 'format.percent.label': 'Percent',
58
+ 'format.ref.label': 'Reference',
59
+ 'format.regex.label': 'RegExp',
60
+ 'format.string.label': 'String',
61
+ 'format.single-select.label': 'Select',
62
+ 'format.multi-select.label': 'Multi-select',
63
+ 'format.text.label': 'Long text',
64
+ 'format.time.label': 'Time',
65
+ 'format.timestamp.label': 'Timestamp',
66
+ 'format.user.label': 'User',
67
+ 'format.number.label': 'Number',
68
+ 'format.uri.label': 'URI',
69
+ 'format.url.label': 'URL',
70
+ 'format.uuid.label': 'UUID',
71
71
 
72
72
  // GeoPointField.
73
- 'latitude label': 'Latitude',
74
- 'longitude label': 'Longitude',
73
+ 'latitude.label': 'Latitude',
74
+ 'longitude.label': 'Longitude',
75
75
 
76
76
  // SelectOptionsField.
77
- 'select option label': 'Label',
78
- 'select option label placeholder': 'Option label',
79
- 'select option color': 'Color',
80
- 'select option delete': 'Delete',
81
- 'select option add': 'Add option',
77
+ 'select-option.label': 'Label',
78
+ 'select-option-label.placeholder': 'Option label',
79
+ 'select-option-delete.button': 'Delete',
80
+ 'select-option-add.button': 'Add option',
82
81
 
83
82
  // System schema message.
84
- 'system schema title': 'System type',
85
- 'system schema description': 'System type: cannot add or remove fields.',
83
+ 'system-schema.title': 'System type',
84
+ 'system-schema.description': 'System type: cannot add or remove fields.',
85
+ 'remove.button': 'Remove',
86
86
  },
87
87
  },
88
88
  },
package/src/util/index.ts CHANGED
@@ -2,7 +2,6 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './echo';
6
5
  export * from './field';
7
6
  export * from './formatting';
8
7
  export * from './properties';
package/src/util/refs.ts CHANGED
@@ -5,11 +5,13 @@
5
5
  import type * as SchemaAST from 'effect/SchemaAST';
6
6
 
7
7
  import { Ref } from '@dxos/echo';
8
- import { getArrayElementType, isArrayType } from '@dxos/effect';
8
+ import { type ReferenceAnnotationValue, ReferenceAnnotationId } from '@dxos/echo/internal';
9
+ import { findAnnotation, getArrayElementType, isArrayType } from '@dxos/effect';
9
10
 
10
11
  type RefProps = {
11
12
  ast: SchemaAST.AST;
12
13
  isArray: boolean;
14
+ typename?: string;
13
15
  };
14
16
 
15
17
  export const getRefProps = (ast: SchemaAST.AST): RefProps | undefined => {
@@ -18,14 +20,16 @@ export const getRefProps = (ast: SchemaAST.AST): RefProps | undefined => {
18
20
  const elementType = getArrayElementType(ast);
19
21
  if (elementType) {
20
22
  if (Ref.isRefType(elementType)) {
21
- return { ast: elementType, isArray: true };
23
+ const typename = findAnnotation<ReferenceAnnotationValue>(elementType, ReferenceAnnotationId)?.typename;
24
+ return { ast: elementType, isArray: true, typename };
22
25
  }
23
26
  }
24
27
  }
25
28
 
26
29
  // Direct reference.
27
30
  if (Ref.isRefType(ast)) {
28
- return { ast, isArray: false };
31
+ const typename = findAnnotation<ReferenceAnnotationValue>(ast, ReferenceAnnotationId)?.typename;
32
+ return { ast, isArray: false, typename };
29
33
  }
30
34
 
31
35
  return undefined;
@@ -1,23 +0,0 @@
1
- import React, { type ComponentPropsWithoutRef, type PropsWithChildren } from 'react';
2
- import { type ButtonProps, type Label, type ThemedClassName } from '@dxos/react-ui';
3
- export type ControlPageParams = ThemedClassName<ComponentPropsWithoutRef<'div'>>;
4
- export declare const ControlPage: ({ children, classNames, ...props }: ControlPageParams) => React.JSX.Element;
5
- export type ControlSectionProps = PropsWithChildren<{
6
- title: Label;
7
- description?: Label;
8
- }>;
9
- export declare const ControlSection: ({ title, description, children }: ControlSectionProps) => React.JSX.Element;
10
- export declare const ControlSectionHeading: ({ title, description }: Omit<ControlSectionProps, "children">) => React.JSX.Element;
11
- export declare const ControlGroupButton: ({ classNames, ...props }: ButtonProps) => React.JSX.Element;
12
- export type ControlGroupProps = ThemedClassName<PropsWithChildren>;
13
- export declare const ControlGroup: ({ children, classNames }: ControlGroupProps) => React.JSX.Element;
14
- export declare const ControlFrame: ({ children }: ControlGroupProps) => React.JSX.Element;
15
- export declare const controlItemClasses: string;
16
- export type ControlItemProps = PropsWithChildren<{
17
- title: Label;
18
- description?: Label;
19
- }>;
20
- export declare const ControlItem: ({ title, description, children }: ControlItemProps) => React.JSX.Element;
21
- export declare const ControlItemInput: ({ title, description, children }: ControlItemProps) => React.JSX.Element;
22
- export declare const ControlFrameItem: ({ title, description, children }: ControlItemProps) => React.JSX.Element;
23
- //# sourceMappingURL=ControlSection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ControlSection.d.ts","sourceRoot":"","sources":["../../../../../src/components/ControlSection/ControlSection.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,wBAAwB,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAErF,OAAO,EAEL,KAAK,WAAW,EAEhB,KAAK,KAAK,EACV,KAAK,eAAe,EAGrB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;AAEjF,eAAO,MAAM,WAAW,GAAI,oCAAoC,iBAAiB,sBAQhF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;IAClD,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,cAAc,GAAI,kCAAkC,mBAAmB,sBAOnF,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAAI,wBAAwB,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,sBAYlG,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,0BAA0B,WAAW,sBAEvE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC,iBAAiB,CAAC,CAAC;AAEnE,eAAO,MAAM,YAAY,GAAI,0BAA0B,iBAAiB,sBAWvE,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,cAAc,iBAAiB,sBAU3D,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAK7B,CAAC;AAKH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;IAC/C,KAAK,EAAE,KAAK,CAAC;IACb,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,CAAC,CAAC;AAEH,eAAO,MAAM,WAAW,GAAI,kCAAkC,gBAAgB,sBAY7E,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,kCAAkC,gBAAgB,sBAoBlF,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,kCAAkC,gBAAgB,sBAUlF,CAAC"}
@@ -1,87 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import React from 'react';
3
- declare const meta: {
4
- title: string;
5
- component: ({ title, description, children }: import("./ControlSection").ControlSectionProps) => React.JSX.Element;
6
- render: (args: {
7
- title: import("@dxos/ui-types").Label;
8
- description?: import("@dxos/ui-types").Label;
9
- } & {
10
- children?: React.ReactNode | undefined;
11
- }) => React.JSX.Element;
12
- decorators: import("@storybook/react").Decorator[];
13
- parameters: {
14
- layout: string;
15
- translations: [{
16
- readonly 'en-US': {
17
- readonly "@dxos/react-ui-form": {
18
- readonly 'fields label': "Fields";
19
- readonly 'hidden fields label': "Hidden Fields";
20
- readonly 'empty readonly ref field label': "(none)";
21
- readonly 'add property button label': "Add property";
22
- readonly 'field property label': "Property";
23
- readonly 'field property placeholder': "Property name";
24
- readonly 'field format label': "Type";
25
- readonly 'field path label': "Field path";
26
- readonly 'add field': "Add field";
27
- readonly 'delete field': "Delete field";
28
- readonly 'field limit reached': "Maximum number of fields reached";
29
- readonly 'boolean input true value': "Yes";
30
- readonly 'boolean input false value': "No";
31
- readonly 'show field label': "Show field";
32
- readonly 'hide field label': "Hide field";
33
- readonly 'delete field label': "Delete field";
34
- readonly 'ref field combobox input placeholder': "Search…";
35
- readonly 'ref field placeholder_one': "Select…";
36
- readonly 'ref field placeholder_other': "Select items…";
37
- readonly 'example placeholder': "Example";
38
- readonly 'latitude placeholder': "Latitude (e.g., 40.7128)";
39
- readonly 'longitude placeholder': "Longitude (e.g., -74.0060)";
40
- readonly 'cancel button label': "Cancel";
41
- readonly 'save button label': "Save";
42
- readonly 'format boolean': "Boolean";
43
- readonly 'format currency': "Currency";
44
- readonly 'format date': "Date";
45
- readonly 'format date-time': "DateTime";
46
- readonly 'format did': "DID";
47
- readonly 'format duration': "Duration";
48
- readonly 'format dxn': "DXN";
49
- readonly 'format email': "Email";
50
- readonly 'format formula': "Formula";
51
- readonly 'format hostname': "Hostname";
52
- readonly 'format integer': "Integer";
53
- readonly 'format json': "JSON";
54
- readonly 'format lnglat': "Geopoint";
55
- readonly 'format markdown': "Markdown";
56
- readonly 'format percent': "Percent";
57
- readonly 'format ref': "Reference";
58
- readonly 'format regex': "RegExp";
59
- readonly 'format string': "String";
60
- readonly 'format single-select': "Select";
61
- readonly 'format multi-select': "Multi-select";
62
- readonly 'format text': "Long text";
63
- readonly 'format time': "Time";
64
- readonly 'format timestamp': "Timestamp";
65
- readonly 'format user': "User";
66
- readonly 'format number': "Number";
67
- readonly 'format uri': "URI";
68
- readonly 'format url': "URL";
69
- readonly 'format uuid': "UUID";
70
- readonly 'latitude label': "Latitude";
71
- readonly 'longitude label': "Longitude";
72
- readonly 'select option label': "Label";
73
- readonly 'select option label placeholder': "Option label";
74
- readonly 'select option color': "Color";
75
- readonly 'select option delete': "Delete";
76
- readonly 'select option add': "Add option";
77
- readonly 'system schema title': "System type";
78
- readonly 'system schema description': "System type: cannot add or remove fields.";
79
- };
80
- };
81
- }];
82
- };
83
- };
84
- export default meta;
85
- type Story = StoryObj<typeof meta>;
86
- export declare const Default: Story;
87
- //# sourceMappingURL=ControlSection.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ControlSection.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/ControlSection/ControlSection.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAa6B,CAAC;AAExC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAKrB,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './ControlSection';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ControlSection/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC"}