@dxos/react-ui-form 0.8.0 → 0.8.1-main.013e445
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.
- package/dist/lib/browser/index.mjs +571 -507
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +449 -384
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +571 -507
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/Form/ArrayField.d.ts +2 -1
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts +6 -5
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +2 -2
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +7 -7
- package/dist/types/src/components/Form/FormActions.d.ts +2 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +3 -2
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts +2 -2
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +2 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +2 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts +2 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts +1 -2
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts +2 -1
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +3 -2
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts +2 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts +2 -2
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +3 -3
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +2 -1
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/package.json +26 -28
- package/src/components/Form/index.ts +1 -3
- package/src/components/ViewEditor/ViewEditor.tsx +71 -2
- package/src/components/deprecated/Form.tsx +2 -2
- package/src/hooks/useForm.ts +12 -2
- package/src/translations.ts +1 -0
- package/src/util/field.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useForm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useForm.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useForm.ts"],"names":[],"mappings":"AAIA,OAAO,EAAoB,KAAK,MAAM,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAC;AAG5D,OAAO,EAAE,KAAK,UAAU,EAAsB,MAAM,mBAA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C,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAE/C;;;;OAIG;IAEH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,eAAe,EAAE,GAAG,SAAS,CAAC;IAE1D;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,KAAK,IAAI,CAAC;IAE5E;;OAEG;IACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE;QAAE,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;KAAE,KAAK,YAAY,CAAC,IAAI,CAAC,CAAC;CAC1F;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,GAAI,CAAC,SAAS,UAAU,4EAOzC,WAAW,CAAC,CAAC,CAAC,KAAG,WAAW,CAAC,CAAC,CAmLhC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,kBAAkB,CAAC
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../src/translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,kBAAkB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9C,wBA6DE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.d.ts","sourceRoot":"","sources":["../../../../src/util/field.ts"],"names":[],"mappings":"AA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D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-form",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-main.013e445",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,51 +25,49 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@atlaskit/pragmatic-drag-and-drop": "^1.4.0",
|
|
27
27
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
|
|
28
|
-
"@effect/schema": "^0.75.5",
|
|
29
28
|
"@radix-ui/react-context": "1.1.1",
|
|
30
29
|
"date-fns": "^3.3.1",
|
|
31
30
|
"jsonpath": "^1.1.1",
|
|
32
|
-
"@dxos/async": "0.8.
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/echo-
|
|
36
|
-
"@dxos/invariant": "0.8.
|
|
37
|
-
"@dxos/keys": "0.8.
|
|
38
|
-
"@dxos/live-object": "0.8.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/react-
|
|
42
|
-
"@dxos/react-
|
|
43
|
-
"@dxos/react-ui-
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/util": "0.8.
|
|
31
|
+
"@dxos/async": "0.8.1-main.013e445",
|
|
32
|
+
"@dxos/debug": "0.8.1-main.013e445",
|
|
33
|
+
"@dxos/echo-db": "0.8.1-main.013e445",
|
|
34
|
+
"@dxos/echo-schema": "0.8.1-main.013e445",
|
|
35
|
+
"@dxos/invariant": "0.8.1-main.013e445",
|
|
36
|
+
"@dxos/keys": "0.8.1-main.013e445",
|
|
37
|
+
"@dxos/live-object": "0.8.1-main.013e445",
|
|
38
|
+
"@dxos/effect": "0.8.1-main.013e445",
|
|
39
|
+
"@dxos/log": "0.8.1-main.013e445",
|
|
40
|
+
"@dxos/react-client": "0.8.1-main.013e445",
|
|
41
|
+
"@dxos/react-ui-pickers": "0.8.1-main.013e445",
|
|
42
|
+
"@dxos/react-ui-types": "0.8.1-main.013e445",
|
|
43
|
+
"@dxos/schema": "0.8.1-main.013e445",
|
|
44
|
+
"@dxos/react-ui-list": "0.8.1-main.013e445",
|
|
45
|
+
"@dxos/util": "0.8.1-main.013e445"
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@phosphor-icons/react": "^2.1.5",
|
|
50
49
|
"@types/jsonpath": "^0.2.4",
|
|
51
50
|
"@types/react": "~18.2.0",
|
|
52
51
|
"@types/react-dom": "~18.2.0",
|
|
53
|
-
"effect": "
|
|
52
|
+
"effect": "3.13.3",
|
|
54
53
|
"fast-check": "^3.19.0",
|
|
55
54
|
"react": "~18.2.0",
|
|
56
55
|
"react-dom": "~18.2.0",
|
|
57
56
|
"vite": "5.4.7",
|
|
58
|
-
"@dxos/echo-signals": "0.8.
|
|
59
|
-
"@dxos/random": "0.8.
|
|
60
|
-
"@dxos/react-ui-syntax-highlighter": "0.8.
|
|
61
|
-
"@dxos/react-ui": "0.8.
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
57
|
+
"@dxos/echo-signals": "0.8.1-main.013e445",
|
|
58
|
+
"@dxos/random": "0.8.1-main.013e445",
|
|
59
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.1-main.013e445",
|
|
60
|
+
"@dxos/react-ui-theme": "0.8.1-main.013e445",
|
|
61
|
+
"@dxos/react-ui": "0.8.1-main.013e445",
|
|
62
|
+
"@dxos/storybook-utils": "0.8.1-main.013e445"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
66
|
-
"@effect/schema": "^0.75.5",
|
|
67
65
|
"@phosphor-icons/react": "^2.1.5",
|
|
68
|
-
"effect": "
|
|
66
|
+
"effect": "3.13.3",
|
|
69
67
|
"react": "~18.2.0",
|
|
70
68
|
"react-dom": "~18.2.0",
|
|
71
|
-
"@dxos/react-ui": "0.8.
|
|
72
|
-
"@dxos/react-ui
|
|
69
|
+
"@dxos/react-ui-theme": "0.8.1-main.013e445",
|
|
70
|
+
"@dxos/react-ui": "0.8.1-main.013e445"
|
|
73
71
|
},
|
|
74
72
|
"publishConfig": {
|
|
75
73
|
"access": "public"
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { useFormValues } from './FormContext';
|
|
6
|
-
|
|
7
5
|
export * from './custom';
|
|
8
6
|
|
|
9
7
|
export * from './Defaults';
|
|
10
8
|
export * from './Form';
|
|
9
|
+
export * from './FormContext';
|
|
11
10
|
export * from './Input';
|
|
12
|
-
export { useFormValues };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type SchemaRegistry } from '@dxos/echo-db';
|
|
8
|
-
import { AST, Format, type EchoSchema, S } from '@dxos/echo-schema';
|
|
8
|
+
import { AST, Format, type EchoSchema, S, type JsonProp } from '@dxos/echo-schema';
|
|
9
9
|
import { IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { List } from '@dxos/react-ui-list';
|
|
11
11
|
import { ghostHover, inputTextLabel, mx } from '@dxos/react-ui-theme';
|
|
@@ -88,6 +88,16 @@ export const ViewEditor = ({
|
|
|
88
88
|
setField(field);
|
|
89
89
|
}, [view]);
|
|
90
90
|
|
|
91
|
+
const handleDelete = useCallback(
|
|
92
|
+
(fieldId: string) => {
|
|
93
|
+
if (fieldId === field?.id) {
|
|
94
|
+
setField(undefined);
|
|
95
|
+
}
|
|
96
|
+
onDelete(fieldId);
|
|
97
|
+
},
|
|
98
|
+
[onDelete, field],
|
|
99
|
+
);
|
|
100
|
+
|
|
91
101
|
const handleMove = useCallback(
|
|
92
102
|
(fromIndex: number, toIndex: number) => {
|
|
93
103
|
// NOTE(ZaymonFC): Using arrayMove here causes a race condition with the kanban model.
|
|
@@ -101,6 +111,24 @@ export const ViewEditor = ({
|
|
|
101
111
|
|
|
102
112
|
const handleClose = useCallback(() => setField(undefined), []);
|
|
103
113
|
|
|
114
|
+
const hiddenProperties = projection.getHiddenProperties();
|
|
115
|
+
|
|
116
|
+
const handleHide = useCallback(
|
|
117
|
+
(fieldId: string) => {
|
|
118
|
+
setField(undefined);
|
|
119
|
+
projection.hideFieldProjection(fieldId);
|
|
120
|
+
},
|
|
121
|
+
[projection],
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
const handleShow = useCallback(
|
|
125
|
+
(property: string) => {
|
|
126
|
+
setField(undefined);
|
|
127
|
+
projection.showFieldProjection(property as JsonProp);
|
|
128
|
+
},
|
|
129
|
+
[projection],
|
|
130
|
+
);
|
|
131
|
+
|
|
104
132
|
return (
|
|
105
133
|
<div role='none' className={mx('flex flex-col w-full divide-y divide-separator', classNames)}>
|
|
106
134
|
<Form<ViewMetaType> autoSave schema={ViewMetaSchema} values={viewValues} onSave={handleViewUpdate} />
|
|
@@ -131,13 +159,54 @@ export const ViewEditor = ({
|
|
|
131
159
|
<List.Item<FieldType> key={field.id} item={field} classNames={mx(grid, ghostHover, 'cursor-pointer')}>
|
|
132
160
|
<List.ItemDragHandle />
|
|
133
161
|
<List.ItemTitle onClick={() => handleSelect(field)}>{field.path}</List.ItemTitle>
|
|
134
|
-
<
|
|
162
|
+
<div className='flex items-center gap-2 -ml-4'>
|
|
163
|
+
<List.ItemButton
|
|
164
|
+
icon='ph--eye-slash--regular'
|
|
165
|
+
disabled={view.fields.length <= 1}
|
|
166
|
+
onClick={() => handleHide(field.id)}
|
|
167
|
+
/>
|
|
168
|
+
<List.ItemDeleteButton
|
|
169
|
+
icon='ph--trash--regular'
|
|
170
|
+
disabled={view.fields.length <= 1}
|
|
171
|
+
onClick={() => handleDelete(field.id)}
|
|
172
|
+
/>
|
|
173
|
+
</div>
|
|
135
174
|
</List.Item>
|
|
136
175
|
))}
|
|
137
176
|
</div>
|
|
138
177
|
</>
|
|
139
178
|
)}
|
|
140
179
|
</List.Root>
|
|
180
|
+
|
|
181
|
+
{hiddenProperties.length > 0 && (
|
|
182
|
+
<div>
|
|
183
|
+
<div role='none' className='p-2'>
|
|
184
|
+
<label className={mx(inputTextLabel)}>{t('hidden fields label')}</label>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
<List.Root<string>
|
|
188
|
+
items={hiddenProperties}
|
|
189
|
+
isItem={(item): item is string => typeof item === 'string'}
|
|
190
|
+
getId={(property) => property}
|
|
191
|
+
>
|
|
192
|
+
{({ items: properties }) => (
|
|
193
|
+
<div role='list' className='flex flex-col w-full'>
|
|
194
|
+
{properties?.map((property) => (
|
|
195
|
+
<List.Item<string>
|
|
196
|
+
key={property}
|
|
197
|
+
item={property}
|
|
198
|
+
classNames={mx(grid, ghostHover, 'cursor-pointer')}
|
|
199
|
+
>
|
|
200
|
+
<div />
|
|
201
|
+
<List.ItemTitle>{property}</List.ItemTitle>
|
|
202
|
+
<List.ItemButton icon='ph--eye--regular' onClick={() => handleShow(property)} />
|
|
203
|
+
</List.Item>
|
|
204
|
+
))}
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
</List.Root>
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
141
210
|
</div>
|
|
142
211
|
|
|
143
212
|
{field && (
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { Option, pipe } from 'effect';
|
|
5
|
+
import { SchemaAST as AST, type Schema as S, Option, pipe } from 'effect';
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { findProperty } from '@dxos/effect';
|
|
9
9
|
import { Input, type ThemedClassName, type TextInputProps as NativeTextInputProps } from '@dxos/react-ui';
|
|
10
10
|
import { mx } from '@dxos/react-ui-theme';
|
|
11
11
|
import { type ViewType, getFieldValue, setFieldValue } from '@dxos/schema';
|
package/src/hooks/useForm.ts
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { SchemaAST as AST, type Schema as S } from 'effect';
|
|
5
6
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
7
|
|
|
7
8
|
import { type BaseObject, getValue, setValue } from '@dxos/echo-schema';
|
|
8
|
-
import {
|
|
9
|
+
import { type SimpleType, type JsonPath, createJsonPath, fromEffectValidationPath } from '@dxos/effect';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
11
12
|
import { validateSchema, type ValidationError } from '@dxos/schema';
|
|
@@ -175,12 +176,21 @@ export const useForm = <T extends BaseObject>({
|
|
|
175
176
|
errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`),
|
|
176
177
|
);
|
|
177
178
|
|
|
179
|
+
// Only show errors for touched fields.
|
|
180
|
+
const isTouched = touched[jsonPath as JsonPath];
|
|
181
|
+
if (!isTouched) {
|
|
182
|
+
return {
|
|
183
|
+
status: undefined,
|
|
184
|
+
error: undefined,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
178
188
|
return {
|
|
179
189
|
status: matchingError ? 'error' : undefined,
|
|
180
190
|
error: matchingError ? matchingError[1] : undefined,
|
|
181
191
|
};
|
|
182
192
|
},
|
|
183
|
-
[errors],
|
|
193
|
+
[errors, touched],
|
|
184
194
|
);
|
|
185
195
|
|
|
186
196
|
const getFormValue = useCallback<FormHandler<T>['getValue']>(
|
package/src/translations.ts
CHANGED
package/src/util/field.ts
CHANGED