@dxos/react-ui-form 0.7.5-main.9d2a38b → 0.7.5-main.e9bb01b

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 (66) hide show
  1. package/dist/lib/browser/index.mjs +703 -462
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node/index.cjs +730 -504
  5. package/dist/lib/node/index.cjs.map +4 -4
  6. package/dist/lib/node/meta.json +1 -1
  7. package/dist/lib/node-esm/index.mjs +703 -462
  8. package/dist/lib/node-esm/index.mjs.map +4 -4
  9. package/dist/lib/node-esm/meta.json +1 -1
  10. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  11. package/dist/types/src/components/Form/ArrayField.d.ts +16 -0
  12. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -0
  13. package/dist/types/src/components/Form/Defaults.d.ts +5 -6
  14. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/Form.d.ts +11 -20
  16. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Form.stories.d.ts +2 -1
  18. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/FormActions.d.ts +7 -0
  20. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -0
  21. package/dist/types/src/components/Form/FormContent.d.ts +26 -0
  22. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -0
  23. package/dist/types/src/components/Form/FormContext.d.ts +20 -0
  24. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -0
  25. package/dist/types/src/components/Form/Input.d.ts +5 -6
  26. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  27. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -2
  28. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  29. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +4 -0
  30. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -0
  31. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +7 -0
  32. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -0
  33. package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -2
  34. package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
  35. package/dist/types/src/components/Form/custom/index.d.ts +1 -0
  36. package/dist/types/src/components/Form/custom/index.d.ts.map +1 -1
  37. package/dist/types/src/components/Form/factory.d.ts +2 -2
  38. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  39. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  40. package/dist/types/src/components/deprecated/FormInput.d.ts +5 -0
  41. package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
  42. package/dist/types/src/hooks/useForm.d.ts +9 -10
  43. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  44. package/dist/types/src/translations.d.ts +6 -0
  45. package/dist/types/src/translations.d.ts.map +1 -1
  46. package/package.json +25 -24
  47. package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
  48. package/src/components/FieldEditor/FieldEditor.tsx +7 -6
  49. package/src/components/Form/ArrayField.tsx +111 -0
  50. package/src/components/Form/Defaults.tsx +18 -33
  51. package/src/components/Form/Form.stories.tsx +15 -5
  52. package/src/components/Form/Form.tsx +38 -358
  53. package/src/components/Form/FormActions.tsx +41 -0
  54. package/src/components/Form/FormContent.tsx +173 -0
  55. package/src/components/Form/FormContext.tsx +48 -0
  56. package/src/components/Form/Input.tsx +5 -6
  57. package/src/components/Form/custom/GeoPointInput.tsx +6 -15
  58. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +58 -0
  59. package/src/components/Form/custom/SelectOptionsInput.tsx +192 -0
  60. package/src/components/Form/custom/TupleInput.tsx +5 -9
  61. package/src/components/Form/custom/index.ts +1 -0
  62. package/src/components/Form/factory.tsx +2 -5
  63. package/src/components/ViewEditor/ViewEditor.tsx +5 -2
  64. package/src/components/deprecated/FormInput.tsx +19 -3
  65. package/src/hooks/useForm.ts +54 -47
  66. package/src/translations.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dxos/react-ui-form",
3
- "version": "0.7.5-main.9d2a38b",
3
+ "version": "0.7.5-main.e9bb01b",
4
4
  "description": "Data components.",
5
5
  "homepage": "https://dxos.org",
6
6
  "bugs": "https://github.com/dxos/dxos/issues",
@@ -25,24 +25,25 @@
25
25
  "@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
26
26
  "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
27
27
  "@effect/schema": "^0.75.5",
28
- "@radix-ui/react-context": "^1.0.0",
28
+ "@radix-ui/react-context": "1.1.1",
29
29
  "date-fns": "^3.3.1",
30
30
  "effect": "^3.12.1",
31
31
  "jsonpath": "^1.1.1",
32
- "@dxos/async": "0.7.5-main.9d2a38b",
33
- "@dxos/debug": "0.7.5-main.9d2a38b",
34
- "@dxos/echo-db": "0.7.5-main.9d2a38b",
35
- "@dxos/echo-schema": "0.7.5-main.9d2a38b",
36
- "@dxos/effect": "0.7.5-main.9d2a38b",
37
- "@dxos/keys": "0.7.5-main.9d2a38b",
38
- "@dxos/invariant": "0.7.5-main.9d2a38b",
39
- "@dxos/live-object": "0.7.5-main.9d2a38b",
40
- "@dxos/log": "0.7.5-main.9d2a38b",
41
- "@dxos/react-client": "0.7.5-main.9d2a38b",
42
- "@dxos/react-ui-list": "0.7.5-main.9d2a38b",
43
- "@dxos/schema": "0.7.5-main.9d2a38b",
44
- "@dxos/react-ui-types": "0.7.5-main.9d2a38b",
45
- "@dxos/util": "0.7.5-main.9d2a38b"
32
+ "@dxos/async": "0.7.5-main.e9bb01b",
33
+ "@dxos/debug": "0.7.5-main.e9bb01b",
34
+ "@dxos/echo-db": "0.7.5-main.e9bb01b",
35
+ "@dxos/effect": "0.7.5-main.e9bb01b",
36
+ "@dxos/invariant": "0.7.5-main.e9bb01b",
37
+ "@dxos/keys": "0.7.5-main.e9bb01b",
38
+ "@dxos/echo-schema": "0.7.5-main.e9bb01b",
39
+ "@dxos/live-object": "0.7.5-main.e9bb01b",
40
+ "@dxos/log": "0.7.5-main.e9bb01b",
41
+ "@dxos/react-client": "0.7.5-main.e9bb01b",
42
+ "@dxos/react-ui-pickers": "0.7.5-main.e9bb01b",
43
+ "@dxos/react-ui-list": "0.7.5-main.e9bb01b",
44
+ "@dxos/react-ui-types": "0.7.5-main.e9bb01b",
45
+ "@dxos/util": "0.7.5-main.e9bb01b",
46
+ "@dxos/schema": "0.7.5-main.e9bb01b"
46
47
  },
47
48
  "devDependencies": {
48
49
  "@phosphor-icons/react": "^2.1.5",
@@ -53,12 +54,12 @@
53
54
  "react": "~18.2.0",
54
55
  "react-dom": "~18.2.0",
55
56
  "vite": "5.4.7",
56
- "@dxos/echo-signals": "0.7.5-main.9d2a38b",
57
- "@dxos/react-ui": "0.7.5-main.9d2a38b",
58
- "@dxos/random": "0.7.5-main.9d2a38b",
59
- "@dxos/react-ui-syntax-highlighter": "0.7.5-main.9d2a38b",
60
- "@dxos/react-ui-theme": "0.7.5-main.9d2a38b",
61
- "@dxos/storybook-utils": "0.7.5-main.9d2a38b"
57
+ "@dxos/echo-signals": "0.7.5-main.e9bb01b",
58
+ "@dxos/react-ui": "0.7.5-main.e9bb01b",
59
+ "@dxos/react-ui-syntax-highlighter": "0.7.5-main.e9bb01b",
60
+ "@dxos/react-ui-theme": "0.7.5-main.e9bb01b",
61
+ "@dxos/random": "0.7.5-main.e9bb01b",
62
+ "@dxos/storybook-utils": "0.7.5-main.e9bb01b"
62
63
  },
63
64
  "peerDependencies": {
64
65
  "@effect/schema": "^0.75.5",
@@ -66,8 +67,8 @@
66
67
  "effect": "^3.9.2",
67
68
  "react": "~18.2.0",
68
69
  "react-dom": "~18.2.0",
69
- "@dxos/react-ui": "0.7.5-main.9d2a38b",
70
- "@dxos/react-ui-theme": "0.7.5-main.9d2a38b"
70
+ "@dxos/react-ui": "0.7.5-main.e9bb01b",
71
+ "@dxos/react-ui-theme": "0.7.5-main.e9bb01b"
71
72
  },
72
73
  "publishConfig": {
73
74
  "access": "public"
@@ -37,7 +37,7 @@ const meta: Meta<StoryProps> = {
37
37
  title: 'ui/react-ui-form/FieldEditor',
38
38
  component: FieldEditor,
39
39
  render: DefaultStory,
40
- decorators: [withLayout({ fullscreen: true }), withTheme],
40
+ decorators: [withLayout({ fullscreen: true, tooltips: true }), withTheme],
41
41
  parameters: {
42
42
  translations,
43
43
  },
@@ -20,7 +20,7 @@ import {
20
20
  } from '@dxos/schema';
21
21
 
22
22
  import { translationKey } from '../../translations';
23
- import { Form, type FormProps, type InputComponent, SelectInput } from '../Form';
23
+ import { Form, type FormProps, type InputComponent, SelectInput, SelectOptionInput } from '../Form';
24
24
 
25
25
  export type FieldEditorProps = {
26
26
  view: ViewType;
@@ -95,7 +95,7 @@ export const FieldEditor = ({ view, projection, field, registry, onSave, onCance
95
95
  return { ...props, ..._props, type };
96
96
  }
97
97
 
98
- return props;
98
+ return _props as PropertyType;
99
99
  });
100
100
  },
101
101
  [schemas, props.format, props.referenceSchema],
@@ -129,10 +129,10 @@ export const FieldEditor = ({ view, projection, field, registry, onSave, onCance
129
129
  onSave();
130
130
  }, [onSave]);
131
131
 
132
- const Custom: Partial<Record<string, InputComponent<PropertyType>>> = useMemo(
132
+ const Custom: Partial<Record<string, InputComponent>> = useMemo(
133
133
  () => ({
134
134
  ['format' satisfies keyof PropertyType]: (props) => (
135
- <SelectInput<PropertyType>
135
+ <SelectInput
136
136
  {...props}
137
137
  options={FormatEnums.filter((value) => value !== FormatEnum.None).map((value) => ({
138
138
  value,
@@ -141,7 +141,7 @@ export const FieldEditor = ({ view, projection, field, registry, onSave, onCance
141
141
  />
142
142
  ),
143
143
  ['referenceSchema' satisfies keyof PropertyType]: (props) => (
144
- <SelectInput<PropertyType>
144
+ <SelectInput
145
145
  {...props}
146
146
  options={schemas.map((schema) => ({
147
147
  value: schema.typename,
@@ -149,7 +149,7 @@ export const FieldEditor = ({ view, projection, field, registry, onSave, onCance
149
149
  />
150
150
  ),
151
151
  ['referencePath' satisfies keyof PropertyType]: (props) => (
152
- <SelectInput<PropertyType>
152
+ <SelectInput
153
153
  {...props}
154
154
  options={
155
155
  referenceSchema
@@ -160,6 +160,7 @@ export const FieldEditor = ({ view, projection, field, registry, onSave, onCance
160
160
  }
161
161
  />
162
162
  ),
163
+ ['options' satisfies keyof PropertyType]: (props) => <SelectOptionInput {...props} />,
163
164
  }),
164
165
  [t, schemas, referenceSchema],
165
166
  );
@@ -0,0 +1,111 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { pipe } from 'effect';
6
+ import { capitalize } from 'effect/String';
7
+ import React, { useCallback, useMemo } from 'react';
8
+
9
+ import { AST } from '@dxos/echo-schema';
10
+ import { findNode, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from '@dxos/effect';
11
+ import { invariant } from '@dxos/invariant';
12
+ import { IconButton, useTranslation } from '@dxos/react-ui';
13
+ import { mx } from '@dxos/react-ui-theme';
14
+ import { getSchemaProperties, type SchemaProperty } from '@dxos/schema';
15
+
16
+ import { type ComponentLookup } from './Form';
17
+ import { FormField } from './FormContent';
18
+ import { useFormValues, type FormInputStateProps } from './FormContext';
19
+ import { InputHeader, type InputComponent } from './Input';
20
+ import { translationKey } from '../../translations';
21
+
22
+ const padding = 'px-2';
23
+
24
+ type ArrayFieldProps = {
25
+ property: SchemaProperty<any>;
26
+ readonly?: boolean;
27
+ inputProps: FormInputStateProps;
28
+ path?: (string | number)[];
29
+ Custom?: Partial<Record<string, InputComponent>>;
30
+ lookupComponent?: ComponentLookup;
31
+ };
32
+
33
+ export const ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }: ArrayFieldProps) => {
34
+ const { t } = useTranslation(translationKey);
35
+ const { ast, name, type, title } = property;
36
+ const values = useFormValues(path ?? []) as any[];
37
+ invariant(Array.isArray(values), `Values at path ${path?.join('.')} must be an array.`);
38
+ const label = title ?? pipe(name, capitalize);
39
+
40
+ const tupleType = findNode(ast, AST.isTupleType);
41
+ const elementType = (tupleType as AST.TupleType | undefined)?.rest[0]?.type;
42
+
43
+ const getDefaultObjectValue = (typeNode: AST.AST): any => {
44
+ const baseNode = findNode(typeNode, isDiscriminatedUnion);
45
+ const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode(typeNode, AST.isTypeLiteral);
46
+ if (!typeLiteral) {
47
+ return {};
48
+ }
49
+
50
+ return Object.fromEntries(getSchemaProperties(typeLiteral, {}).map((prop) => [prop.name, prop.defaultValue]));
51
+ };
52
+
53
+ const newValue = useMemo(() => {
54
+ if (type === 'object' && elementType) {
55
+ return getDefaultObjectValue(elementType);
56
+ } else {
57
+ return SimpleType.getDefaultValue(type);
58
+ }
59
+ }, [type, elementType]);
60
+
61
+ const handleAdd = useCallback(() => {
62
+ inputProps.onValueChange(type, [...values, newValue]);
63
+ }, [type, elementType, inputProps, newValue, values]);
64
+
65
+ const handleRemove = useCallback(
66
+ (index: number) => {
67
+ const newValues = values.filter((_, i) => i !== index);
68
+ inputProps.onValueChange(type, newValues);
69
+ },
70
+ [type, inputProps, values],
71
+ );
72
+
73
+ if (!elementType) {
74
+ return null;
75
+ }
76
+
77
+ return (
78
+ <div role='none' className={mx(padding)}>
79
+ <InputHeader>{label}</InputHeader>
80
+ <div role='none' className='flex flex-col gap-1'>
81
+ {values.map((_value, index) => (
82
+ <div key={index} role='none' className='flex items-center gap-1'>
83
+ <div role='none' className='flex-1'>
84
+ <FormField
85
+ property={{
86
+ ...property,
87
+ array: false, // NOTE(ZaymonFC): This breaks arrays of arrays but ¯\_(ツ)_/¯. Ping me if you need that.
88
+ ast: elementType,
89
+ }}
90
+ path={[...(path ?? []), index]}
91
+ readonly={readonly}
92
+ inline
93
+ Custom={Custom}
94
+ lookupComponent={lookupComponent}
95
+ />
96
+ </div>
97
+ <IconButton
98
+ icon='ph--trash--regular'
99
+ iconOnly
100
+ label={t('button remove')}
101
+ onClick={() => handleRemove(index)}
102
+ />
103
+ </div>
104
+ ))}
105
+ </div>
106
+ <div role='none' className='flex justify-between items-center plb-1'>
107
+ <IconButton icon='ph--plus--regular' iconOnly label={t('button add')} onClick={handleAdd} />
108
+ </div>
109
+ </div>
110
+ );
111
+ };
@@ -4,13 +4,11 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { type BaseObject } from '@dxos/echo-schema';
8
7
  import { Input, Select } from '@dxos/react-ui';
9
8
 
10
9
  import { type InputProps, InputHeader } from './Input';
11
10
 
12
- export const TextInput = <T extends BaseObject>({
13
- property,
11
+ export const TextInput = ({
14
12
  type,
15
13
  label,
16
14
  inputOnly,
@@ -20,8 +18,8 @@ export const TextInput = <T extends BaseObject>({
20
18
  getValue,
21
19
  onValueChange,
22
20
  onBlur,
23
- }: InputProps<T>) => {
24
- const { status, error } = getStatus?.(property);
21
+ }: InputProps) => {
22
+ const { status, error } = getStatus();
25
23
 
26
24
  return (
27
25
  <Input.Root validationValence={status}>
@@ -33,8 +31,8 @@ export const TextInput = <T extends BaseObject>({
33
31
  <Input.TextInput
34
32
  disabled={disabled}
35
33
  placeholder={placeholder}
36
- value={getValue(property) ?? ''}
37
- onChange={(event) => onValueChange(property, type, event.target.value)}
34
+ value={getValue() ?? ''}
35
+ onChange={(event) => onValueChange(type, event.target.value)}
38
36
  onBlur={onBlur}
39
37
  />
40
38
  {inputOnly && <Input.Validation>{error}</Input.Validation>}
@@ -42,8 +40,7 @@ export const TextInput = <T extends BaseObject>({
42
40
  );
43
41
  };
44
42
 
45
- export const NumberInput = <T extends BaseObject>({
46
- property,
43
+ export const NumberInput = ({
47
44
  type,
48
45
  label,
49
46
  inputOnly,
@@ -53,8 +50,8 @@ export const NumberInput = <T extends BaseObject>({
53
50
  getValue,
54
51
  onValueChange,
55
52
  onBlur,
56
- }: InputProps<T>) => {
57
- const { status, error } = getStatus?.(property);
53
+ }: InputProps) => {
54
+ const { status, error } = getStatus();
58
55
 
59
56
  return (
60
57
  <Input.Root validationValence={status}>
@@ -67,8 +64,8 @@ export const NumberInput = <T extends BaseObject>({
67
64
  type='number'
68
65
  disabled={disabled}
69
66
  placeholder={placeholder}
70
- value={getValue(property) ?? 0}
71
- onChange={(event) => onValueChange(property, type, event.target.value)}
67
+ value={getValue() ?? 0}
68
+ onChange={(event) => onValueChange(type, event.target.value)}
72
69
  onBlur={onBlur}
73
70
  />
74
71
  {inputOnly && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}
@@ -76,16 +73,8 @@ export const NumberInput = <T extends BaseObject>({
76
73
  );
77
74
  };
78
75
 
79
- export const BooleanInput = <T extends BaseObject>({
80
- property,
81
- type,
82
- label,
83
- inputOnly,
84
- getStatus,
85
- getValue,
86
- onValueChange,
87
- }: InputProps<T>) => {
88
- const { status, error } = getStatus?.(property);
76
+ export const BooleanInput = ({ type, label, inputOnly, getStatus, getValue, onValueChange }: InputProps) => {
77
+ const { status, error } = getStatus();
89
78
 
90
79
  return (
91
80
  <Input.Root validationValence={status}>
@@ -94,21 +83,17 @@ export const BooleanInput = <T extends BaseObject>({
94
83
  <Input.Label>{label}</Input.Label>
95
84
  </InputHeader>
96
85
  )}
97
- <Input.Switch
98
- checked={getValue<boolean>(property)}
99
- onCheckedChange={(value) => onValueChange(property, type, value)}
100
- />
86
+ <Input.Switch checked={getValue()} onCheckedChange={(value) => onValueChange(type, value)} />
101
87
  {inputOnly && <Input.DescriptionAndValidation>{error}</Input.DescriptionAndValidation>}
102
88
  </Input.Root>
103
89
  );
104
90
  };
105
91
 
106
- export type SelectInputOptions<T extends BaseObject> = InputProps<T> & {
92
+ export type SelectInputOptions = InputProps & {
107
93
  options?: Array<{ value: string | number; label?: string }>;
108
94
  };
109
95
 
110
- export const SelectInput = <T extends BaseObject>({
111
- property,
96
+ export const SelectInput = ({
112
97
  type,
113
98
  label,
114
99
  inputOnly,
@@ -118,8 +103,8 @@ export const SelectInput = <T extends BaseObject>({
118
103
  getStatus,
119
104
  getValue,
120
105
  onValueChange,
121
- }: SelectInputOptions<T>) => {
122
- const { status, error } = getStatus?.(property);
106
+ }: SelectInputOptions) => {
107
+ const { status, error } = getStatus();
123
108
 
124
109
  return (
125
110
  <Input.Root validationValence={status}>
@@ -128,7 +113,7 @@ export const SelectInput = <T extends BaseObject>({
128
113
  <Input.Label>{label}</Input.Label>
129
114
  </InputHeader>
130
115
  )}
131
- <Select.Root value={getValue(property)} onValueChange={(value) => onValueChange(property, type, value)}>
116
+ <Select.Root value={getValue()} onValueChange={(value) => onValueChange(type, value)}>
132
117
  {/* TODO(burdon): Placeholder not working? */}
133
118
  <Select.TriggerButton classNames='is-full' disabled={disabled} placeholder={placeholder} />
134
119
  <Select.Portal>
@@ -36,7 +36,7 @@ type TestType = S.Schema.Type<typeof TestSchema>;
36
36
 
37
37
  type StoryProps<T extends BaseObject> = { schema: S.Schema<T> } & FormProps<T>;
38
38
 
39
- const DefaultStory = <T extends BaseObject>({ schema, values: initialValues }: StoryProps<T>) => {
39
+ const DefaultStory = <T extends BaseObject>({ schema, values: initialValues, ...props }: StoryProps<T>) => {
40
40
  const [values, setValues] = useState(initialValues);
41
41
  const handleSave = useCallback<NonNullable<FormProps<T>['onSave']>>((values) => {
42
42
  setValues(values);
@@ -45,7 +45,7 @@ const DefaultStory = <T extends BaseObject>({ schema, values: initialValues }: S
45
45
  return (
46
46
  <TestLayout json={{ values, schema: schema.ast.toJSON() }}>
47
47
  <TestPanel>
48
- <Form<T> schema={schema} values={values} onSave={handleSave} />
48
+ <Form<T> schema={schema} values={values} onSave={handleSave} {...props} />
49
49
  </TestPanel>
50
50
  </TestLayout>
51
51
  );
@@ -78,7 +78,6 @@ export const Default: Story<TestType> = {
78
78
  },
79
79
  };
80
80
 
81
- // TODO(burdon): Should accept partial values.
82
81
  export const Org: Story<Testing.OrgSchemaType> = {
83
82
  args: {
84
83
  schema: Testing.OrgSchema,
@@ -89,6 +88,17 @@ export const Org: Story<Testing.OrgSchemaType> = {
89
88
  },
90
89
  };
91
90
 
91
+ export const OrgAutoSave: Story<Testing.OrgSchemaType> = {
92
+ args: {
93
+ schema: Testing.OrgSchema,
94
+ values: {
95
+ name: 'DXOS',
96
+ // website: 'https://dxos.org',
97
+ },
98
+ autoSave: true,
99
+ },
100
+ };
101
+
92
102
  // TODO(burdon): Type issue with employer reference.
93
103
  // TODO(burdon): Test table/form with compound values (e.g., address).
94
104
  // export const Contact: Story<Testing.ContactSchemaType> = {
@@ -114,7 +124,7 @@ const ShapeSchema = S.Struct({
114
124
  }),
115
125
  S.Struct({
116
126
  type: S.Literal('square').annotations({ [AST.TitleAnnotationId]: 'Type' }),
117
- size: S.optional(S.Number.annotations({ [AST.TitleAnnotationId]: 'Size' })),
127
+ size: S.optional(S.Number.pipe(S.nonNegative()).annotations({ [AST.TitleAnnotationId]: 'Size' })),
118
128
  }),
119
129
  ).annotations({ [AST.TitleAnnotationId]: 'Shape' }),
120
130
  ),
@@ -139,7 +149,7 @@ const DiscriminatedUnionStory = ({ values: initialValues }: DiscriminatedUnionSt
139
149
  onSave={handleSave}
140
150
  Custom={{
141
151
  ['shape.type' as const]: (props) => (
142
- <SelectInput<ShapeType>
152
+ <SelectInput
143
153
  {...props}
144
154
  options={['circle', 'square'].map((value) => ({
145
155
  value,