@dxos/react-ui-form 0.8.4-main.b97322e → 0.8.4-main.c4373fc

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 (117) hide show
  1. package/dist/lib/browser/index.mjs +810 -594
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +810 -594
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/ControlSection/ControlSection.d.ts +2 -2
  8. package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
  9. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +81 -5
  10. package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
  11. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
  12. package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
  13. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +76 -5
  14. package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
  15. package/dist/types/src/components/Form/ArrayField.d.ts +2 -2
  16. package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
  17. package/dist/types/src/components/Form/Defaults.d.ts +5 -5
  18. package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
  19. package/dist/types/src/components/Form/Form.d.ts +7 -6
  20. package/dist/types/src/components/Form/Form.d.ts.map +1 -1
  21. package/dist/types/src/components/Form/Form.stories.d.ts +129 -32
  22. package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
  23. package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
  24. package/dist/types/src/components/Form/FormContent.d.ts +17 -11
  25. package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
  26. package/dist/types/src/components/Form/FormContext.d.ts +3 -3
  27. package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
  28. package/dist/types/src/components/Form/Input.d.ts +5 -2
  29. package/dist/types/src/components/Form/Input.d.ts.map +1 -1
  30. package/dist/types/src/components/Form/RefField.d.ts +14 -5
  31. package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
  32. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +1 -1
  33. package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
  34. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +1 -1
  35. package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
  36. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +76 -4
  37. package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
  38. package/dist/types/src/components/Form/custom/TupleInput.d.ts +1 -1
  39. package/dist/types/src/components/Form/factory.d.ts +1 -1
  40. package/dist/types/src/components/Form/factory.d.ts.map +1 -1
  41. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +41 -0
  42. package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
  43. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +81 -0
  44. package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
  45. package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
  46. package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
  47. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +16 -4
  48. package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
  49. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +79 -7
  50. package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/index.d.ts +1 -1
  52. package/dist/types/src/components/index.d.ts.map +1 -1
  53. package/dist/types/src/components/testing.d.ts +6 -3
  54. package/dist/types/src/components/testing.d.ts.map +1 -1
  55. package/dist/types/src/hooks/useForm.d.ts +3 -3
  56. package/dist/types/src/hooks/useForm.d.ts.map +1 -1
  57. package/dist/types/src/hooks/useQueryRefOptions.d.ts +8 -3
  58. package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +1 -1
  59. package/dist/types/src/translations.d.ts +11 -5
  60. package/dist/types/src/translations.d.ts.map +1 -1
  61. package/dist/types/src/util/field.d.ts +1 -1
  62. package/dist/types/src/util/field.d.ts.map +1 -1
  63. package/dist/types/src/util/formatting.d.ts +1 -1
  64. package/dist/types/src/util/formatting.d.ts.map +1 -1
  65. package/dist/types/src/util/refs.d.ts +1 -1
  66. package/dist/types/src/util/refs.d.ts.map +1 -1
  67. package/dist/types/src/util/schema.d.ts +1 -1
  68. package/dist/types/src/util/schema.d.ts.map +1 -1
  69. package/dist/types/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +41 -36
  71. package/src/components/ControlSection/ControlSection.stories.tsx +11 -14
  72. package/src/components/ControlSection/ControlSection.tsx +26 -12
  73. package/src/components/FieldEditor/FieldEditor.stories.tsx +14 -14
  74. package/src/components/FieldEditor/FieldEditor.test.tsx +3 -2
  75. package/src/components/FieldEditor/FieldEditor.tsx +26 -18
  76. package/src/components/Form/ArrayField.tsx +12 -11
  77. package/src/components/Form/Defaults.tsx +22 -20
  78. package/src/components/Form/Form.stories.tsx +135 -99
  79. package/src/components/Form/Form.tsx +26 -15
  80. package/src/components/Form/FormActions.tsx +2 -1
  81. package/src/components/Form/FormContent.tsx +121 -39
  82. package/src/components/Form/FormContext.tsx +8 -8
  83. package/src/components/Form/Input.tsx +5 -2
  84. package/src/components/Form/RefField.tsx +97 -41
  85. package/src/components/Form/custom/GeoPointInput.tsx +29 -21
  86. package/src/components/Form/custom/SelectOptionsInput.stories.tsx +11 -11
  87. package/src/components/Form/custom/SelectOptionsInput.tsx +30 -31
  88. package/src/components/Form/custom/TupleInput.tsx +2 -2
  89. package/src/components/Form/factory.tsx +2 -2
  90. package/src/components/ObjectPicker/ObjectPicker.stories.tsx +207 -0
  91. package/src/components/ObjectPicker/ObjectPicker.tsx +161 -0
  92. package/src/components/ObjectPicker/index.ts +5 -0
  93. package/src/components/ViewEditor/ViewEditor.stories.tsx +102 -44
  94. package/src/components/ViewEditor/ViewEditor.test.tsx +9 -12
  95. package/src/components/ViewEditor/ViewEditor.tsx +328 -220
  96. package/src/components/index.ts +1 -2
  97. package/src/components/testing.tsx +15 -9
  98. package/src/hooks/useForm.ts +8 -4
  99. package/src/hooks/useQueryRefOptions.ts +9 -3
  100. package/src/hooks/useRefQueryLookupHandler.ts +1 -1
  101. package/src/translations.ts +13 -6
  102. package/src/util/field.ts +9 -19
  103. package/src/util/formatting.ts +1 -1
  104. package/src/util/refs.ts +2 -2
  105. package/src/util/schema.ts +2 -4
  106. package/dist/types/src/components/deprecated/Form.d.ts +0 -15
  107. package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
  108. package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
  109. package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
  110. package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
  111. package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
  112. package/dist/types/src/components/deprecated/index.d.ts +0 -2
  113. package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
  114. package/src/components/deprecated/Form.stories.tsx +0 -62
  115. package/src/components/deprecated/Form.tsx +0 -119
  116. package/src/components/deprecated/FormInput.tsx +0 -71
  117. package/src/components/deprecated/index.ts +0 -5
@@ -2,14 +2,15 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { SchemaAST, type Schema } from 'effect';
5
+ import type * as Schema from 'effect/Schema';
6
+ import * as SchemaAST from 'effect/SchemaAST';
6
7
  import { useCallback, useEffect, useMemo, useState } from 'react';
7
8
 
8
- import { type BaseObject, getValue, setValue } from '@dxos/echo-schema';
9
- import { type SimpleType, type JsonPath, createJsonPath, fromEffectValidationPath } from '@dxos/effect';
9
+ import { type BaseObject, getValue, setValue } from '@dxos/echo/internal';
10
+ import { type JsonPath, type SimpleType, createJsonPath, fromEffectValidationPath } from '@dxos/effect';
10
11
  import { invariant } from '@dxos/invariant';
11
12
  import { log } from '@dxos/log';
12
- import { validateSchema, type ValidationError } from '@dxos/schema';
13
+ import { type ValidationError, validateSchema } from '@dxos/schema';
13
14
  import { type MaybePromise } from '@dxos/util';
14
15
 
15
16
  /**
@@ -26,6 +27,8 @@ export type FormHandler<T extends BaseObject> = {
26
27
  changed: Record<JsonPath, boolean>;
27
28
  canSave: boolean;
28
29
  formIsValid: boolean;
30
+
31
+ // TODO(burdon): Return onSave.
29
32
  handleSave: () => void;
30
33
 
31
34
  //
@@ -201,6 +204,7 @@ export const useForm = <T extends BaseObject>({
201
204
  [values],
202
205
  );
203
206
 
207
+ // TODO(wittjosiah): This is causing the entire form to re-render on every change.
204
208
  const onValueChange = useCallback<FormHandler<T>['onValueChange']>(
205
209
  (path: (string | number)[], type: SimpleType, value: any) => {
206
210
  const jsonPath = createJsonPath(path);
@@ -4,15 +4,21 @@
4
4
 
5
5
  import { useEffect, useState } from 'react';
6
6
 
7
- import { type TypeAnnotation } from '@dxos/echo-schema';
7
+ import { type TypeAnnotation } from '@dxos/echo/internal';
8
8
  import { type DXN } from '@dxos/keys';
9
9
  import { log } from '@dxos/log';
10
- import { type TagPickerItemData } from '@dxos/react-ui-tag-picker';
10
+ import { type Palette } from '@dxos/react-ui-types';
11
11
  import { type MaybePromise } from '@dxos/util';
12
12
 
13
13
  export type RefOption = { dxn: DXN; label?: string };
14
14
  export type QueryRefOptions = (type: TypeAnnotation) => MaybePromise<RefOption[]>;
15
15
 
16
+ export type QueryTag = {
17
+ id: string;
18
+ label: string;
19
+ hue?: Palette;
20
+ };
21
+
16
22
  type UseQueryRefOptionsProps = { refTypeInfo: TypeAnnotation | undefined; onQueryRefOptions?: QueryRefOptions };
17
23
 
18
24
  /**
@@ -20,7 +26,7 @@ type UseQueryRefOptionsProps = { refTypeInfo: TypeAnnotation | undefined; onQuer
20
26
  * Used internally within forms to fetch and format reference options for reference fields.
21
27
  */
22
28
  export const useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }: UseQueryRefOptionsProps) => {
23
- const [options, setOptions] = useState<TagPickerItemData[]>([]);
29
+ const [options, setOptions] = useState<QueryTag[]>([]);
24
30
  const [loading, setLoading] = useState(false);
25
31
 
26
32
  useEffect(() => {
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { useCallback } from 'react';
6
6
 
7
- import { getObjectDXN, type TypeAnnotation } from '@dxos/echo-schema';
7
+ import { type TypeAnnotation, getObjectDXN } from '@dxos/echo/internal';
8
8
  import { Filter, type Space } from '@dxos/react-client/echo';
9
9
  import { isNonNullable } from '@dxos/util';
10
10
 
@@ -25,6 +25,12 @@ export const translations = [
25
25
  'field limit reached': 'Maximum number of fields reached',
26
26
  'boolean input true value': 'Yes',
27
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…',
28
34
 
29
35
  // TODO(burdon): Factor out?
30
36
  'button cancel': 'Cancel',
@@ -43,7 +49,7 @@ export const translations = [
43
49
  'format hostname': 'Hostname',
44
50
  'format integer': 'Integer',
45
51
  'format json': 'JSON',
46
- 'format latlng': 'Geopoint',
52
+ 'format lnglat': 'Geopoint',
47
53
  'format markdown': 'Markdown',
48
54
  'format percent': 'Percent',
49
55
  'format ref': 'Reference',
@@ -60,9 +66,9 @@ export const translations = [
60
66
  'format url': 'URL',
61
67
  'format uuid': 'UUID',
62
68
 
63
- // Placeholders.
64
- 'placeholder latitude': 'Latitude',
65
- 'placeholder longitude': 'Longitude',
69
+ // GeoPointInput.
70
+ 'latitude label': 'Latitude',
71
+ 'longitude label': 'Longitude',
66
72
 
67
73
  // SelectOptionsInput.
68
74
  'select option label': 'Label',
@@ -72,8 +78,9 @@ export const translations = [
72
78
  'select option add': 'Add option',
73
79
 
74
80
  // System schema message.
75
- 'system schema title': 'System Schema',
76
- 'system schema description': 'This is a system schema and cannot be modified.',
81
+ 'system schema title': 'System record type',
82
+ 'system schema description':
83
+ 'This is a system record type and cannot be modified, though the view can still be configured.',
77
84
  },
78
85
  },
79
86
  },
package/src/util/field.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { FormatEnum, GeoLocation, TypeEnum } from '@dxos/echo-schema';
5
+ import { FormatEnum, GeoLocation, TypeEnum } from '@dxos/echo/internal';
6
6
  import { type ValidationError } from '@dxos/schema';
7
7
 
8
8
  /**
@@ -112,24 +112,7 @@ export type CellClassesForFieldTypeProps = {
112
112
  };
113
113
 
114
114
  export const cellClassesForFieldType = ({ type, format }: CellClassesForFieldTypeProps): string[] | undefined => {
115
- if (!format) {
116
- switch (type) {
117
- case TypeEnum.Number:
118
- return ['text-right', 'font-mono'];
119
- case TypeEnum.Boolean:
120
- return ['text-right', 'font-mono'];
121
- case TypeEnum.String:
122
- return undefined;
123
- case TypeEnum.Ref:
124
- return undefined;
125
-
126
- default: {
127
- return undefined;
128
- }
129
- }
130
- }
131
-
132
- switch (format) {
115
+ switch (format || type) {
133
116
  case FormatEnum.Markdown:
134
117
  return undefined;
135
118
  case FormatEnum.Time:
@@ -143,6 +126,13 @@ export const cellClassesForFieldType = ({ type, format }: CellClassesForFieldTyp
143
126
  case FormatEnum.JSON:
144
127
  case FormatEnum.DID:
145
128
  return ['font-mono'];
129
+ case TypeEnum.Number:
130
+ case TypeEnum.Boolean:
131
+ return ['text-right', 'font-mono'];
132
+ case TypeEnum.String:
133
+ return undefined;
134
+ case TypeEnum.Ref:
135
+ return undefined;
146
136
  default:
147
137
  return undefined;
148
138
  }
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { format as formatDate } from 'date-fns/format';
6
6
 
7
- import { FormatEnum, GeoLocation, TypeEnum } from '@dxos/echo-schema';
7
+ import { FormatEnum, GeoLocation, TypeEnum } from '@dxos/echo/internal';
8
8
 
9
9
  type ValueFormatProps = {
10
10
  type: TypeEnum;
package/src/util/refs.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { type SchemaAST } from 'effect';
5
+ import type * as SchemaAST from 'effect/SchemaAST';
6
6
 
7
- import { FormatEnum, ReferenceAnnotationId } from '@dxos/echo-schema';
7
+ import { FormatEnum, ReferenceAnnotationId } from '@dxos/echo/internal';
8
8
  import { findAnnotation } from '@dxos/effect';
9
9
  import { type SchemaProperty } from '@dxos/schema';
10
10
 
@@ -2,13 +2,11 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { SchemaAST } from 'effect';
5
+ import * as SchemaAST from 'effect/SchemaAST';
6
6
 
7
7
  import { findNode } from '@dxos/effect';
8
8
 
9
9
  export const findArrayElementType = (ast: SchemaAST.AST) => {
10
10
  const tupleType = findNode(ast, SchemaAST.isTupleType);
11
- const elementType = (tupleType as SchemaAST.TupleType | undefined)?.rest[0]?.type;
12
-
13
- return elementType;
11
+ return (tupleType as SchemaAST.TupleType | undefined)?.rest[0]?.type;
14
12
  };
@@ -1,15 +0,0 @@
1
- import { type Schema } from 'effect';
2
- import React from 'react';
3
- import { type ThemedClassName } from '@dxos/react-ui';
4
- import { type Projection } from '@dxos/schema';
5
- export type DeprecatedFormProps<T extends {} = {}> = ThemedClassName<{
6
- projection: Projection;
7
- object: T;
8
- schema?: Schema.Schema<T>;
9
- readonly?: boolean;
10
- }>;
11
- /**
12
- * Schema-based object form.
13
- */
14
- export declare const DeprecatedForm: <T extends {} = {}>({ classNames, projection, object, schema, readonly, }: DeprecatedFormProps<T>) => React.JSX.Element;
15
- //# sourceMappingURL=Form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/Form.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,MAAM,EAAgB,MAAM,QAAQ,CAAC;AAC9D,OAAO,KAAmB,MAAM,OAAO,CAAC;AAGxC,OAAO,EAAS,KAAK,eAAe,EAA+C,MAAM,gBAAgB,CAAC;AAE1G,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7E,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,eAAe,CAAC;IACnE,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,EAAE,CAAC,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,EAAE,GAAG,EAAE,EAAE,uDAM/C,mBAAmB,CAAC,CAAC,CAAC,sBA0DxB,CAAC"}
@@ -1,13 +0,0 @@
1
- import '@dxos-theme';
2
- import { type Meta, type StoryObj } from '@storybook/react-vite';
3
- import React from 'react';
4
- import { type TestType } from '@dxos/schema/testing';
5
- import { type DeprecatedFormProps } from './Form';
6
- declare const DefaultStory: (props: DeprecatedFormProps) => React.JSX.Element;
7
- declare const meta: Meta<typeof DefaultStory>;
8
- export default meta;
9
- type Story = StoryObj<DeprecatedFormProps<TestType>>;
10
- export declare const Default: Story;
11
- export declare const Empty: Story;
12
- export declare const Readonly: Story;
13
- //# sourceMappingURL=Form.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Form.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/Form.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAkC,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGrF,OAAO,EAAkB,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAIlE,QAAA,MAAM,YAAY,GAAI,OAAO,mBAAmB,sBAM/C,CAAC;AAEF,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,YAAY,CAQnC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAErD,eAAO,MAAM,OAAO,EAAE,KAMrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAKnB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAOtB,CAAC"}
@@ -1,16 +0,0 @@
1
- import { type JSX, type PropsWithChildren } from 'react';
2
- import { type ThemedClassName } from '@dxos/react-ui';
3
- /**
4
- * @deprecated
5
- */
6
- export declare const DeprecatedFormContainer: ({ children, classNames }: ThemedClassName<PropsWithChildren>) => JSX.Element;
7
- export type DeprecatedFormInputProps = {
8
- label: string;
9
- description?: JSX.Element;
10
- secondary?: JSX.Element;
11
- };
12
- /**
13
- * @deprecated
14
- */
15
- export declare const DeprecatedFormInput: ({ label, description, secondary, children, }: PropsWithChildren<DeprecatedFormInputProps>) => JSX.Element;
16
- //# sourceMappingURL=FormInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"FormInput.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/FormInput.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,GAAG,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAS,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG7D;;GAEG;AACH,eAAO,MAAM,uBAAuB,GAAI,0BAA0B,eAAe,CAAC,iBAAiB,CAAC,gBAQnG,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,8CAKjC,iBAAiB,CAAC,wBAAwB,CAAC,gBAkC7C,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './FormInput';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/deprecated/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC"}
@@ -1,62 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import '@dxos-theme';
6
-
7
- import { type Meta, type StoryObj } from '@storybook/react-vite';
8
- import React from 'react';
9
-
10
- import { live } from '@dxos/live-object';
11
- import { testData, TestSchema, testView, type TestType } from '@dxos/schema/testing';
12
- import { withLayout, withTheme } from '@dxos/storybook-utils';
13
-
14
- import { DeprecatedForm, type DeprecatedFormProps } from './Form';
15
- import { translations } from '../../translations';
16
- import { TestLayout, TestPanel } from '../testing';
17
-
18
- const DefaultStory = (props: DeprecatedFormProps) => (
19
- <TestLayout json={{ props }}>
20
- <TestPanel>
21
- <DeprecatedForm {...props} />
22
- </TestPanel>
23
- </TestLayout>
24
- );
25
-
26
- const meta: Meta<typeof DefaultStory> = {
27
- title: 'ui/react-ui-form/DeprecatedForm',
28
- component: DeprecatedForm,
29
- render: DefaultStory,
30
- decorators: [withLayout({ fullscreen: true }), withTheme],
31
- parameters: {
32
- translations,
33
- },
34
- };
35
-
36
- export default meta;
37
-
38
- type Story = StoryObj<DeprecatedFormProps<TestType>>;
39
-
40
- export const Default: Story = {
41
- args: {
42
- object: live(testData),
43
- projection: live(testView).projection,
44
- schema: TestSchema,
45
- },
46
- };
47
-
48
- export const Empty: Story = {
49
- args: {
50
- projection: live(testView).projection,
51
- schema: TestSchema,
52
- },
53
- };
54
-
55
- export const Readonly: Story = {
56
- args: {
57
- object: live(testData),
58
- projection: live(testView).projection,
59
- schema: TestSchema,
60
- readonly: true,
61
- },
62
- };
@@ -1,119 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { SchemaAST, type Schema, Option, pipe } from 'effect';
6
- import React, { useState } from 'react';
7
-
8
- import { findProperty } from '@dxos/effect';
9
- import { Input, type ThemedClassName, type TextInputProps as NativeTextInputProps } from '@dxos/react-ui';
10
- import { mx } from '@dxos/react-ui-theme';
11
- import { getFieldValue, setFieldValue, type Projection } from '@dxos/schema';
12
-
13
- export type DeprecatedFormProps<T extends {} = {}> = ThemedClassName<{
14
- projection: Projection;
15
- object: T;
16
- schema?: Schema.Schema<T>;
17
- readonly?: boolean;
18
- }>;
19
-
20
- /**
21
- * Schema-based object form.
22
- */
23
- export const DeprecatedForm = <T extends {} = {}>({
24
- classNames,
25
- projection,
26
- object,
27
- schema,
28
- readonly,
29
- }: DeprecatedFormProps<T>) => {
30
- return (
31
- <div role='none' className={mx('flex flex-col w-full gap-2 p-2', classNames)}>
32
- {projection.fields.map((field) => {
33
- const prop = schema && findProperty(schema, field.path);
34
- const title = (prop && pipe(SchemaAST.getTitleAnnotation(prop), Option.getOrUndefined)) ?? '';
35
- const description = (prop && pipe(SchemaAST.getDescriptionAnnotation(prop), Option.getOrUndefined)) ?? title;
36
- // const format =
37
- // (prop && (getPatternAnnotation(prop) ?? (SchemaAST.isNumberKeyword(prop) && RealNumberFormat))) || undefined;
38
-
39
- //
40
- // Boolean
41
- //
42
-
43
- if (prop && SchemaAST.isBooleanKeyword(prop)) {
44
- const value = object && getFieldValue(object, field);
45
- const onChange = (checked: boolean) => {
46
- setFieldValue(object, field, checked);
47
- };
48
-
49
- return (
50
- <div key={field.path} className='flex flex-col w-full gap-1'>
51
- <Input.Root>
52
- <Input.Label classNames='px-1'>{title}</Input.Label>
53
- <Input.Switch disabled={readonly} checked={!!value} onCheckedChange={(checked) => onChange(checked)} />
54
- </Input.Root>
55
- </div>
56
- );
57
- }
58
-
59
- //
60
- // Strings
61
- // TODO(burdon): Other types:
62
- // - RichText editor
63
- // - Numbers (with formatting: commas, currency, etc.)
64
- // - Date (https://ark-ui.com/react/docs/components/date-picker)
65
- // - Enum (single/multi-select)
66
- //
67
-
68
- const value = object ? getFieldValue(object, field) : undefined;
69
-
70
- return (
71
- <div key={field.path} className='flex flex-col w-full gap-1'>
72
- <Input.Root>
73
- <Input.Label classNames='px-1'>{title}</Input.Label>
74
- <TextInput
75
- disabled={readonly}
76
- placeholder={description}
77
- // format={format}
78
- value={value ? String(value) : ''}
79
- onChange={(event) => setFieldValue(object, field, event.target.value)}
80
- />
81
- </Input.Root>
82
- </div>
83
- );
84
- })}
85
- </div>
86
- );
87
- };
88
-
89
- type TextInputProps = {
90
- // format?: PatternAnnotation;
91
- } & Omit<NativeTextInputProps, 'style'>;
92
-
93
- /**
94
- * @deprecated
95
- */
96
- // TODO(burdon): Remove.
97
- // TODO(burdon): Use schema validation directly.
98
- const TextInput = ({ onChange, ...props }: TextInputProps) => {
99
- const [valid, _setValid] = useState(true);
100
-
101
- const handleChange: NativeTextInputProps['onChange'] = (ev) => {
102
- // const text = ev.target.value;
103
- // if (!format?.filter || text.match(format.filter)) {
104
- onChange?.(ev);
105
- // if (format?.valid) {
106
- // setValid(format.valid.test(text));
107
- // }
108
- // }
109
- };
110
-
111
- return (
112
- <Input.TextInput
113
- {...props}
114
- // TODO(burdon): validationValence on Input.
115
- style={valid ? {} : ({ '--tw-ring-color': 'red' } as any)}
116
- onChange={handleChange}
117
- />
118
- );
119
- };
@@ -1,71 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type JSX, type PropsWithChildren } from 'react';
6
-
7
- import { Input, type ThemedClassName } from '@dxos/react-ui';
8
- import { mx, textBlockWidth } from '@dxos/react-ui-theme';
9
-
10
- /**
11
- * @deprecated
12
- */
13
- export const DeprecatedFormContainer = ({ children, classNames }: ThemedClassName<PropsWithChildren>) => {
14
- return (
15
- <div role='none' className='container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto'>
16
- <div role='form' className={mx('flex flex-col', textBlockWidth, classNames)}>
17
- {children}
18
- </div>
19
- </div>
20
- );
21
- };
22
-
23
- export type DeprecatedFormInputProps = {
24
- label: string;
25
- description?: JSX.Element;
26
- secondary?: JSX.Element;
27
- };
28
-
29
- /**
30
- * @deprecated
31
- */
32
- export const DeprecatedFormInput = ({
33
- label,
34
- description,
35
- secondary,
36
- children,
37
- }: PropsWithChildren<DeprecatedFormInputProps>) => {
38
- const primary = (
39
- <div role='none' className='flex w-full gap-4 py-1'>
40
- <Input.Root>
41
- <div role='none' className='flex flex-col w-full'>
42
- <Input.Label classNames='flex min-bs-[--rail-action] items-center' style={{ fontSize: 'unset' }}>
43
- {label}
44
- </Input.Label>
45
- {description && (
46
- <Input.DescriptionAndValidation classNames='mbs-0.5'>
47
- <Input.Description>{description}</Input.Description>
48
- </Input.DescriptionAndValidation>
49
- )}
50
- </div>
51
-
52
- <div role='none'>
53
- <div role='none' className='flex min-bs-[--rail-action] items-center'>
54
- {children}
55
- </div>
56
- </div>
57
- </Input.Root>
58
- </div>
59
- );
60
-
61
- if (secondary) {
62
- return (
63
- <div role='none'>
64
- {primary}
65
- {secondary}
66
- </div>
67
- );
68
- }
69
-
70
- return primary;
71
- };
@@ -1,5 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- export * from './FormInput';