@dxos/react-ui-form 0.8.4-main.bc674ce → 0.8.4-main.c351d160a8

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 (82) hide show
  1. package/README.md +0 -1
  2. package/dist/lib/browser/index.mjs +538 -458
  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 +538 -458
  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.map +1 -1
  11. package/dist/types/src/components/Form/Form.d.ts +13 -13
  12. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  13. package/dist/types/src/components/Form/Form.stories.d.ts +3 -3
  14. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
  16. package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -1
  17. package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
  18. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
  19. package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
  20. package/dist/types/src/components/Form/FormFieldSet.d.ts +9 -10
  21. package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
  22. package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/fields/RefField.d.ts +6 -4
  24. package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
  25. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
  26. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/Settings/Settings.d.ts +56 -0
  28. package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
  29. package/dist/types/src/components/{ControlSection/ControlSection.stories.d.ts → Settings/Settings.stories.d.ts} +2 -8
  30. package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
  31. package/dist/types/src/components/Settings/index.d.ts +2 -0
  32. package/dist/types/src/components/Settings/index.d.ts.map +1 -0
  33. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
  34. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  35. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +2 -1
  36. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  37. package/dist/types/src/components/index.d.ts +1 -1
  38. package/dist/types/src/components/index.d.ts.map +1 -1
  39. package/dist/types/src/components/testing.d.ts.map +1 -1
  40. package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
  41. package/dist/types/src/util/index.d.ts +0 -1
  42. package/dist/types/src/util/index.d.ts.map +1 -1
  43. package/dist/types/tsconfig.tsbuildinfo +1 -1
  44. package/package.json +35 -37
  45. package/src/components/FieldEditor/FieldEditor.stories.tsx +4 -6
  46. package/src/components/FieldEditor/FieldEditor.tsx +2 -3
  47. package/src/components/Form/Form.stories.tsx +8 -7
  48. package/src/components/Form/Form.tsx +82 -55
  49. package/src/components/Form/FormField.tsx +12 -4
  50. package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
  51. package/src/components/Form/FormFieldComponent.tsx +17 -20
  52. package/src/components/Form/FormFieldSet.tsx +106 -104
  53. package/src/components/Form/fields/ArrayField.tsx +6 -8
  54. package/src/components/Form/fields/MarkdownField.tsx +1 -1
  55. package/src/components/Form/fields/RefField.tsx +28 -15
  56. package/src/components/Form/fields/SelectField.tsx +1 -1
  57. package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -2
  58. package/src/components/Form/fields/SelectOptionField.tsx +4 -4
  59. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +9 -13
  60. package/src/components/Settings/Settings.stories.tsx +56 -0
  61. package/src/components/Settings/Settings.tsx +230 -0
  62. package/src/components/{ControlSection → Settings}/index.ts +1 -1
  63. package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -12
  64. package/src/components/ViewEditor/ViewEditor.test.tsx +3 -6
  65. package/src/components/ViewEditor/ViewEditor.tsx +92 -63
  66. package/src/components/index.ts +1 -1
  67. package/src/components/testing.tsx +9 -6
  68. package/src/hooks/useFormHandler.ts +42 -24
  69. package/src/util/index.ts +0 -1
  70. package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
  71. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
  72. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
  73. package/dist/types/src/components/ControlSection/index.d.ts +0 -2
  74. package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
  75. package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
  76. package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
  77. package/dist/types/src/util/echo.d.ts +0 -6
  78. package/dist/types/src/util/echo.d.ts.map +0 -1
  79. package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
  80. package/src/components/ControlSection/ControlSection.tsx +0 -153
  81. package/src/components/Form/Form-old.stories.tsx +0 -314
  82. package/src/util/echo.ts +0 -25
@@ -5,18 +5,17 @@
5
5
  import React, { type PropsWithChildren } from 'react';
6
6
 
7
7
  import { type ThemedClassName } from '@dxos/react-ui';
8
- import { Card } from '@dxos/react-ui-mosaic';
9
8
  import { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
10
- import { textBlockWidth } from '@dxos/ui-theme';
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='w-full h-full grid grid-cols-[1fr_1fr] p-4 gap-4 overflow-hidden'>
16
+ <TestPanel classNames={['flex flex-col h-full overflow-y-auto', classNames]}>{children}</TestPanel>
18
17
  <TestPanel classNames={'overflow-hidden'}>
19
- <JsonFilter testId='debug' data={json} classNames='bs-full text-xs' />
18
+ <JsonFilter testId='debug' data={json} classNames='h-full text-xs' />
20
19
  </TestPanel>
21
20
  </div>
22
21
  );
@@ -25,7 +24,11 @@ export const TestLayout = ({ classNames, children, json }: TestLayoutProps) => {
25
24
  type TestPanelProps = ThemedClassName<PropsWithChildren>;
26
25
 
27
26
  const TestPanel = ({ classNames, children }: TestPanelProps) => {
28
- return <Card.Root classNames={['bs-full overflow-y-auto', textBlockWidth, classNames]}>{children}</Card.Root>;
27
+ return (
28
+ <div role='none' className={mx(['dx-document h-full bg-modal-surface rounded-md', classNames])}>
29
+ {children}
30
+ </div>
31
+ );
29
32
  };
30
33
 
31
34
  // 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 }) => {
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';
@@ -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 +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"}
@@ -1,131 +0,0 @@
1
- import { type StoryObj } from '@storybook/react-vite';
2
- import * as Schema from 'effect/Schema';
3
- import React from 'react';
4
- import { type AnyProperties } from '@dxos/echo/internal';
5
- import { type FormRootProps } from './Form';
6
- type StoryProps<T extends AnyProperties> = {
7
- debug?: boolean;
8
- schema: Schema.Schema.AnyNoContext;
9
- } & FormRootProps<T>;
10
- declare const meta: {
11
- title: string;
12
- component: any;
13
- render: <T extends AnyProperties = any>({ debug, schema, values: valuesProp, ...props }: StoryProps<T>) => React.JSX.Element;
14
- decorators: import("@storybook/react").Decorator[];
15
- parameters: {
16
- layout: string;
17
- translations: [{
18
- readonly 'en-US': {
19
- readonly "@dxos/react-ui-form": {
20
- readonly 'fields label': "Fields";
21
- readonly 'hidden fields label': "Hidden Fields";
22
- readonly 'empty readonly ref field label': "(none)";
23
- readonly 'add property button label': "Add property";
24
- readonly 'field property label': "Property";
25
- readonly 'field property placeholder': "Property name";
26
- readonly 'field format label': "Type";
27
- readonly 'field path label': "Field path";
28
- readonly 'add field': "Add field";
29
- readonly 'delete field': "Delete field";
30
- readonly 'field limit reached': "Maximum number of fields reached";
31
- readonly 'boolean input true value': "Yes";
32
- readonly 'boolean input false value': "No";
33
- readonly 'show field label': "Show field";
34
- readonly 'hide field label': "Hide field";
35
- readonly 'delete field label': "Delete field";
36
- readonly 'ref field combobox input placeholder': "Search…";
37
- readonly 'ref field placeholder_one': "Select…";
38
- readonly 'ref field placeholder_other': "Select items…";
39
- readonly 'example placeholder': "Example";
40
- readonly 'latitude placeholder': "Latitude (e.g., 40.7128)";
41
- readonly 'longitude placeholder': "Longitude (e.g., -74.0060)";
42
- readonly 'cancel button label': "Cancel";
43
- readonly 'save button label': "Save";
44
- readonly 'format boolean': "Boolean";
45
- readonly 'format currency': "Currency";
46
- readonly 'format date': "Date";
47
- readonly 'format date-time': "DateTime";
48
- readonly 'format did': "DID";
49
- readonly 'format duration': "Duration";
50
- readonly 'format dxn': "DXN";
51
- readonly 'format email': "Email";
52
- readonly 'format formula': "Formula";
53
- readonly 'format hostname': "Hostname";
54
- readonly 'format integer': "Integer";
55
- readonly 'format json': "JSON";
56
- readonly 'format lnglat': "Geopoint";
57
- readonly 'format markdown': "Markdown";
58
- readonly 'format percent': "Percent";
59
- readonly 'format ref': "Reference";
60
- readonly 'format regex': "RegExp";
61
- readonly 'format string': "String";
62
- readonly 'format single-select': "Select";
63
- readonly 'format multi-select': "Multi-select";
64
- readonly 'format text': "Long text";
65
- readonly 'format time': "Time";
66
- readonly 'format timestamp': "Timestamp";
67
- readonly 'format user': "User";
68
- readonly 'format number': "Number";
69
- readonly 'format uri': "URI";
70
- readonly 'format url': "URL";
71
- readonly 'format uuid': "UUID";
72
- readonly 'latitude label': "Latitude";
73
- readonly 'longitude label': "Longitude";
74
- readonly 'select option label': "Label";
75
- readonly 'select option label placeholder': "Option label";
76
- readonly 'select option color': "Color";
77
- readonly 'select option delete': "Delete";
78
- readonly 'select option add': "Add option";
79
- readonly 'system schema title': "System type";
80
- readonly 'system schema description': "System type: cannot add or remove fields.";
81
- };
82
- };
83
- }];
84
- };
85
- argTypes: {
86
- readonly: {
87
- control: "boolean";
88
- description: string;
89
- };
90
- };
91
- };
92
- export default meta;
93
- type Story = StoryObj<typeof meta>;
94
- export declare const Default: Story;
95
- export declare const Organization: Story;
96
- export declare const OrganizationAutoSave: Story;
97
- export declare const Person: Story;
98
- declare const ShapeSchema: Schema.mutable<Schema.Struct<{
99
- shape: Schema.optional<Schema.Union<[Schema.Struct<{
100
- type: Schema.Literal<["circle"]>;
101
- radius: Schema.optional<Schema.SchemaClass<number, number, never>>;
102
- }>, Schema.Struct<{
103
- type: Schema.Literal<["square"]>;
104
- size: Schema.optional<Schema.refine<number, typeof Schema.Number>>;
105
- }>]>>;
106
- }>>;
107
- type ShapeSchema = Schema.Schema.Type<typeof ShapeSchema>;
108
- export declare const DiscriminatedShape: StoryObj<StoryProps<ShapeSchema>>;
109
- declare const ArraysSchema: Schema.mutable<Schema.Struct<{
110
- names: Schema.Array$<Schema.filter<typeof Schema.String>>;
111
- addresses: Schema.Array$<Schema.Struct<{
112
- street: Schema.optional<Schema.SchemaClass<string, string, never>>;
113
- city: Schema.optional<Schema.SchemaClass<string, string, never>>;
114
- zip: Schema.optional<Schema.refine<string, typeof Schema.String>>;
115
- location: Schema.optional<Schema.Tuple<[Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.Element<typeof Schema.Number, "?">]>>;
116
- }>>;
117
- }>>;
118
- type ArraysSchema = Schema.Schema.Type<typeof ArraysSchema>;
119
- export declare const Arrays: StoryObj<StoryProps<ArraysSchema>>;
120
- declare const TupleSchema: Schema.mutable<Schema.Struct<{
121
- tuple: Schema.Tuple<[typeof Schema.Number, typeof Schema.String, typeof Schema.Boolean]>;
122
- geopoint: Schema.Tuple<[Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.filter<Schema.transform<Schema.SchemaClass<number, number, never>, Schema.filter<Schema.SchemaClass<number, number, never>>>>, Schema.Element<typeof Schema.Number, "?">]>;
123
- }>>;
124
- type TupleSchema = Schema.Schema.Type<typeof TupleSchema>;
125
- export declare const Tuple: StoryObj<StoryProps<TupleSchema>>;
126
- declare const ColorSchema: Schema.mutable<Schema.Struct<{
127
- color: Schema.Union<[Schema.Literal<["red"]>, Schema.Literal<["green"]>, Schema.Literal<["blue"]>]>;
128
- }>>;
129
- type ColorType = Schema.Schema.Type<typeof ColorSchema>;
130
- export declare const Enum: StoryObj<StoryProps<ColorType>>;
131
- //# sourceMappingURL=Form-old.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Form-old.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Form-old.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAgC,MAAM,OAAO,CAAC;AAGrD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,OAAO,EAAQ,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIlD,KAAK,UAAU,CAAC,CAAC,SAAS,aAAa,IAAI;IACzC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;CACpC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAuErB,QAAA,MAAM,IAAI;;eAEgB,GAAG;aAvEP,CAAC,SAAS,aAAa,yDAK1C,UAAU,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+EiB,CAAC;AAElC,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAYrB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAU1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAWlC,CAAC;AAKF,eAAO,MAAM,MAAM,EAAE,KAQpB,CAAC;AAMF,QAAA,MAAM,WAAW;;;;;;;;GAaM,CAAC;AAExB,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAE1D,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAuBhE,CAAC;AAMF,QAAA,MAAM,YAAY;;;;;;;;GAGK,CAAC;AAExB,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,CAUrD,CAAC;AAOF,QAAA,MAAM,WAAW;;;GAGM,CAAC;AAExB,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAE1D,eAAO,MAAM,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,CAAC,CAUnD,CAAC;AAMF,QAAA,MAAM,WAAW;;GAIM,CAAC;AAExB,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;AAExD,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAShD,CAAC"}
@@ -1,6 +0,0 @@
1
- import { type JsonPath } from '@dxos/effect';
2
- /**
3
- * Sets a value on an object, using Obj.change() if it's an ECHO object.
4
- */
5
- export declare const setValueEchoAware: <T extends object>(obj: T, path: JsonPath, value: any) => T;
6
- //# sourceMappingURL=echo.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"echo.d.ts","sourceRoot":"","sources":["../../../../src/util/echo.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,QAAQ,EAA4C,MAAM,cAAc,CAAC;AAEvF;;GAEG;AAOH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QAAQ,EAAE,OAAO,GAAG,KAAG,CAQxF,CAAC"}
@@ -1,38 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Meta, type StoryObj } from '@storybook/react-vite';
6
- import React from 'react';
7
-
8
- import { withTheme } from '@dxos/react-ui/testing';
9
-
10
- import { translations } from '../../translations';
11
-
12
- import { ControlPage, ControlSection } from './ControlSection';
13
-
14
- const meta = {
15
- title: 'ui/react-ui-form/ControlSection',
16
- component: ControlSection,
17
- render: (args) => (
18
- <ControlPage classNames='is-[40rem]'>
19
- <ControlSection {...args} />
20
- </ControlPage>
21
- ),
22
- decorators: [withTheme],
23
- parameters: {
24
- layout: 'centered',
25
- translations,
26
- },
27
- } satisfies Meta<typeof ControlSection>;
28
-
29
- export default meta;
30
-
31
- type Story = StoryObj<typeof meta>;
32
-
33
- export const Default: Story = {
34
- args: {
35
- title: 'Control Section',
36
- description: 'This is a control section',
37
- },
38
- };
@@ -1,153 +0,0 @@
1
- //
2
- // Copyright 2025 DXOS.org
3
- //
4
-
5
- import React, { type ComponentPropsWithoutRef, type PropsWithChildren } from 'react';
6
-
7
- import {
8
- Button,
9
- type ButtonProps,
10
- Input,
11
- type Label,
12
- type ThemedClassName,
13
- toLocalizedString,
14
- useTranslation,
15
- } from '@dxos/react-ui';
16
- import { Layout } from '@dxos/react-ui-mosaic';
17
- import { mx } from '@dxos/ui-theme';
18
-
19
- import { translationKey } from '../../translations';
20
-
21
- export type ControlPageParams = ThemedClassName<ComponentPropsWithoutRef<'div'>>;
22
-
23
- export const ControlPage = ({ children, classNames, ...props }: ControlPageParams) => {
24
- return (
25
- <Layout.Container scrollable classNames='[--control-spacing:var(--dx-trimMd)]'>
26
- <div role='none' className={mx('pli-cardSpacingInline pbe-trimMd', classNames)} {...props}>
27
- {children}
28
- </div>
29
- </Layout.Container>
30
- );
31
- };
32
-
33
- export type ControlSectionProps = PropsWithChildren<{
34
- title: Label;
35
- description?: Label;
36
- }>;
37
-
38
- export const ControlSection = ({ title, description, children }: ControlSectionProps) => {
39
- return (
40
- <>
41
- <ControlSectionHeading title={title} description={description} />
42
- {children}
43
- </>
44
- );
45
- };
46
-
47
- export const ControlSectionHeading = ({ title, description }: Omit<ControlSectionProps, 'children'>) => {
48
- const { t } = useTranslation(translationKey);
49
- return (
50
- <>
51
- <h2 className='pli-trimMd container-max-width text-xl mbs-trimMd mbe-trimMd'>{toLocalizedString(title, t)}</h2>
52
- {description && (
53
- <p className='pli-trimMd mlb-trimMd container-max-width text-description'>
54
- {toLocalizedString(description, t)}
55
- </p>
56
- )}
57
- </>
58
- );
59
- };
60
-
61
- export const ControlGroupButton = ({ classNames, ...props }: ButtonProps) => {
62
- return <Button {...props} classNames={['md:col-span-2', classNames]} />;
63
- };
64
-
65
- export type ControlGroupProps = ThemedClassName<PropsWithChildren>;
66
-
67
- export const ControlGroup = ({ children, classNames }: ControlGroupProps) => (
68
- <div
69
- role='none'
70
- className={mx(
71
- 'group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd',
72
- '[--control-spacing:0px] [&_input]:justify-self-end [&_button]:justify-self-end',
73
- classNames,
74
- )}
75
- >
76
- {children}
77
- </div>
78
- );
79
-
80
- export const ControlFrame = ({ children }: ControlGroupProps) => (
81
- <div
82
- role='none'
83
- className={mx(
84
- 'container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd p-trimMd',
85
- 'border border-separator rounded-md',
86
- )}
87
- >
88
- {children}
89
- </div>
90
- );
91
-
92
- export const controlItemClasses = mx([
93
- 'container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center',
94
- // TODO(burdon): Use grid gap consistently or apply margins consistently?
95
- 'mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd',
96
- 'border border-separator rounded-md',
97
- ]);
98
-
99
- const controlItemTitleClasses = 'mbe-0 text-lg text-baseText font-normal';
100
- const controlItemDescriptionClasses = 'mlb-trimSm md:mbe-0 text-base text-description';
101
-
102
- export type ControlItemProps = PropsWithChildren<{
103
- title: Label;
104
- description?: Label;
105
- }>;
106
-
107
- export const ControlItem = ({ title, description, children }: ControlItemProps) => {
108
- const { t } = useTranslation(translationKey);
109
-
110
- return (
111
- <div className={controlItemClasses}>
112
- <div role='none'>
113
- <h3 className={controlItemTitleClasses}>{toLocalizedString(title, t)}</h3>
114
- {description && <p className={controlItemDescriptionClasses}>{toLocalizedString(description, t)}</p>}
115
- </div>
116
- {children}
117
- </div>
118
- );
119
- };
120
-
121
- export const ControlItemInput = ({ title, description, children }: ControlItemProps) => {
122
- const { t } = useTranslation(translationKey);
123
-
124
- return (
125
- <Input.Root>
126
- <div className={controlItemClasses}>
127
- <div role='none'>
128
- <Input.Label classNames={controlItemTitleClasses}>{toLocalizedString(title, t)}</Input.Label>
129
- {description && (
130
- <Input.DescriptionAndValidation>
131
- <Input.Description classNames={controlItemDescriptionClasses}>
132
- {toLocalizedString(description, t)}
133
- </Input.Description>
134
- </Input.DescriptionAndValidation>
135
- )}
136
- </div>
137
- {children}
138
- </div>
139
- </Input.Root>
140
- );
141
- };
142
-
143
- export const ControlFrameItem = ({ title, description, children }: ControlItemProps) => {
144
- const { t } = useTranslation(translationKey);
145
-
146
- return (
147
- <div role='group' className='min-is-0'>
148
- <h3 className='text-lg mbe-2'>{toLocalizedString(title, t)}</h3>
149
- {description && <p className='mlb-trimSm md:mbe-0 text-description'>{toLocalizedString(description, t)}</p>}
150
- {children}
151
- </div>
152
- );
153
- };