@dxos/react-ui-form 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
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 +400 -357
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +400 -357
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Form/Form.d.ts +5 -5
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/Settings/Settings.d.ts +56 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
- package/dist/types/src/components/{ControlSection/ControlSection.stories.d.ts → Settings/Settings.stories.d.ts} +2 -8
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
- package/dist/types/src/components/Settings/index.d.ts +2 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/util/echo.d.ts +6 -0
- package/dist/types/src/util/echo.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +1 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +34 -34
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/Form/Form-old.stories.tsx +1 -1
- package/src/components/Form/Form.stories.tsx +5 -2
- package/src/components/Form/Form.tsx +31 -21
- package/src/components/Form/FormFieldComponent.stories.tsx +1 -1
- package/src/components/Form/FormFieldComponent.tsx +15 -15
- package/src/components/Form/FormFieldSet.tsx +4 -2
- package/src/components/Form/fields/ArrayField.tsx +3 -0
- package/src/components/Form/fields/RefField.tsx +11 -3
- package/src/components/Form/fields/SelectOptionField.stories.tsx +1 -1
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +1 -1
- package/src/components/Settings/Settings.stories.tsx +56 -0
- package/src/components/Settings/Settings.tsx +234 -0
- package/src/components/{ControlSection → Settings}/index.ts +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +3 -3
- package/src/components/ViewEditor/ViewEditor.test.tsx +1 -5
- package/src/components/ViewEditor/ViewEditor.tsx +39 -44
- package/src/components/index.ts +1 -1
- package/src/hooks/useFormHandler.ts +7 -1
- package/src/util/echo.ts +25 -0
- package/src/util/index.ts +1 -0
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/index.d.ts +0 -2
- package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
- package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
- package/src/components/ControlSection/ControlSection.tsx +0 -153
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-form",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.2244d791bb",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -30,58 +30,58 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/pragmatic-drag-and-drop": "1.7.7",
|
|
32
32
|
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
33
|
-
"@effect-atom/atom-react": "^0.
|
|
33
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
34
34
|
"@fluentui/react-tabster": "9.26.11",
|
|
35
35
|
"@radix-ui/react-context": "1.1.1",
|
|
36
36
|
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
37
37
|
"date-fns": "^3.3.1",
|
|
38
38
|
"jsonpath": "^1.1.1",
|
|
39
39
|
"tabster": "^8.5.5",
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/echo
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/echo-react": "0.8.4-main.
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/react-client": "0.8.4-main.
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/react-ui-
|
|
53
|
-
"@dxos/react-ui-
|
|
54
|
-
"@dxos/react-ui-
|
|
55
|
-
"@dxos/react-ui-
|
|
56
|
-
"@dxos/react-ui-searchlist": "0.8.4-main.
|
|
57
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/
|
|
40
|
+
"@dxos/async": "0.8.4-main.2244d791bb",
|
|
41
|
+
"@dxos/debug": "0.8.4-main.2244d791bb",
|
|
42
|
+
"@dxos/echo": "0.8.4-main.2244d791bb",
|
|
43
|
+
"@dxos/echo-query": "0.8.4-main.2244d791bb",
|
|
44
|
+
"@dxos/echo-react": "0.8.4-main.2244d791bb",
|
|
45
|
+
"@dxos/invariant": "0.8.4-main.2244d791bb",
|
|
46
|
+
"@dxos/effect": "0.8.4-main.2244d791bb",
|
|
47
|
+
"@dxos/log": "0.8.4-main.2244d791bb",
|
|
48
|
+
"@dxos/keys": "0.8.4-main.2244d791bb",
|
|
49
|
+
"@dxos/react-ui-components": "0.8.4-main.2244d791bb",
|
|
50
|
+
"@dxos/react-client": "0.8.4-main.2244d791bb",
|
|
51
|
+
"@dxos/lit-ui": "0.8.4-main.2244d791bb",
|
|
52
|
+
"@dxos/react-ui-editor": "0.8.4-main.2244d791bb",
|
|
53
|
+
"@dxos/react-ui-list": "0.8.4-main.2244d791bb",
|
|
54
|
+
"@dxos/react-ui-pickers": "0.8.4-main.2244d791bb",
|
|
55
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.2244d791bb",
|
|
56
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.2244d791bb",
|
|
57
|
+
"@dxos/react-ui-stack": "0.8.4-main.2244d791bb",
|
|
58
|
+
"@dxos/schema": "0.8.4-main.2244d791bb",
|
|
59
|
+
"@dxos/types": "0.8.4-main.2244d791bb",
|
|
60
|
+
"@dxos/ui-types": "0.8.4-main.2244d791bb",
|
|
61
|
+
"@dxos/util": "0.8.4-main.2244d791bb"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/jsonpath": "^0.2.4",
|
|
65
65
|
"@types/react": "~19.2.7",
|
|
66
66
|
"@types/react-dom": "~19.2.3",
|
|
67
|
-
"effect": "3.19.
|
|
67
|
+
"effect": "3.19.16",
|
|
68
68
|
"fast-check": "^3.19.0",
|
|
69
69
|
"react": "~19.2.3",
|
|
70
70
|
"react-dom": "~19.2.3",
|
|
71
71
|
"vite": "7.1.9",
|
|
72
|
-
"@dxos/react-
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/react-ui
|
|
76
|
-
"@dxos/
|
|
77
|
-
"@dxos/
|
|
72
|
+
"@dxos/react-client": "0.8.4-main.2244d791bb",
|
|
73
|
+
"@dxos/random": "0.8.4-main.2244d791bb",
|
|
74
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.2244d791bb",
|
|
75
|
+
"@dxos/react-ui": "0.8.4-main.2244d791bb",
|
|
76
|
+
"@dxos/storybook-utils": "0.8.4-main.2244d791bb",
|
|
77
|
+
"@dxos/ui-theme": "0.8.4-main.2244d791bb"
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"effect": "3.19.
|
|
80
|
+
"effect": "3.19.16",
|
|
81
81
|
"react": "~19.2.3",
|
|
82
82
|
"react-dom": "~19.2.3",
|
|
83
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
84
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.2244d791bb",
|
|
84
|
+
"@dxos/ui-theme": "0.8.4-main.2244d791bb"
|
|
85
85
|
},
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
@@ -98,7 +98,7 @@ const meta = {
|
|
|
98
98
|
title: 'ui/react-ui-form/Form-Old',
|
|
99
99
|
component: Form.Root as any,
|
|
100
100
|
render: DefaultStory,
|
|
101
|
-
decorators: [withTheme, withLayoutVariants()],
|
|
101
|
+
decorators: [withTheme(), withLayoutVariants()],
|
|
102
102
|
parameters: {
|
|
103
103
|
layout: 'fullscreen',
|
|
104
104
|
translations,
|
|
@@ -12,7 +12,7 @@ import { log } from '@dxos/log';
|
|
|
12
12
|
import { useClient } from '@dxos/react-client';
|
|
13
13
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
14
14
|
import { Tooltip } from '@dxos/react-ui';
|
|
15
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
15
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
16
|
|
|
17
17
|
import { translations } from '../../translations';
|
|
18
18
|
import { TestLayout } from '../testing';
|
|
@@ -127,7 +127,10 @@ const meta = {
|
|
|
127
127
|
render: DefaultStory,
|
|
128
128
|
|
|
129
129
|
decorators: [
|
|
130
|
-
withTheme,
|
|
130
|
+
withTheme(),
|
|
131
|
+
withLayout({
|
|
132
|
+
layout: 'fullscreen',
|
|
133
|
+
}),
|
|
131
134
|
withClientProvider({
|
|
132
135
|
createIdentity: true,
|
|
133
136
|
createSpace: true,
|
|
@@ -8,7 +8,7 @@ import type * as SchemaAST from 'effect/SchemaAST';
|
|
|
8
8
|
import React, { type PropsWithChildren, useEffect, useMemo, useRef } from 'react';
|
|
9
9
|
|
|
10
10
|
import { type AnyProperties } from '@dxos/echo/internal';
|
|
11
|
-
import { createJsonPath, getValue as getValue
|
|
11
|
+
import { createJsonPath, getValue as getValue$ } from '@dxos/effect';
|
|
12
12
|
import { IconButton, type IconButtonProps, ScrollArea, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
13
13
|
import { mx } from '@dxos/ui-theme';
|
|
14
14
|
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
useKeyHandler,
|
|
21
21
|
} from '../../hooks';
|
|
22
22
|
import { translationKey } from '../../translations';
|
|
23
|
+
import { setValueEchoAware } from '../../util';
|
|
23
24
|
|
|
24
25
|
import { FormFieldLabel, type FormFieldLabelProps, type FormFieldStateProps } from './FormFieldComponent';
|
|
25
26
|
import {
|
|
@@ -93,7 +94,7 @@ const useFormValues: {
|
|
|
93
94
|
|
|
94
95
|
useEffect(() => {
|
|
95
96
|
if (!value && defaultValue) {
|
|
96
|
-
|
|
97
|
+
setValueEchoAware(values, jsonPath, defaultValue());
|
|
97
98
|
}
|
|
98
99
|
}, [value, defaultValue]);
|
|
99
100
|
|
|
@@ -163,30 +164,32 @@ FormRoot.displayName = 'Form.Root';
|
|
|
163
164
|
// Viewport
|
|
164
165
|
//
|
|
165
166
|
|
|
166
|
-
|
|
167
|
+
const FORM_VIEWPORT_NAME = 'Form.Viewport';
|
|
167
168
|
|
|
168
|
-
|
|
169
|
+
type FormViewportProps = PropsWithChildren<{}>;
|
|
170
|
+
|
|
171
|
+
// TODO(burdon): Ref and props (allow asChild).
|
|
172
|
+
const FormViewport = ({ children }: FormViewportProps) => {
|
|
169
173
|
return (
|
|
170
|
-
<ScrollArea.Root>
|
|
171
|
-
<ScrollArea.Viewport
|
|
172
|
-
<ScrollArea.Scrollbar orientation='vertical'>
|
|
173
|
-
<ScrollArea.Thumb />
|
|
174
|
-
</ScrollArea.Scrollbar>
|
|
174
|
+
<ScrollArea.Root orientation='vertical'>
|
|
175
|
+
<ScrollArea.Viewport>{children}</ScrollArea.Viewport>
|
|
175
176
|
</ScrollArea.Root>
|
|
176
177
|
);
|
|
177
178
|
};
|
|
178
179
|
|
|
179
|
-
FormViewport.displayName =
|
|
180
|
+
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
180
181
|
|
|
181
182
|
//
|
|
182
183
|
// Content
|
|
183
184
|
//
|
|
184
185
|
|
|
186
|
+
const FORM_CONTENT_NAME = 'Form.Content';
|
|
187
|
+
|
|
185
188
|
type FormContentProps = ThemedClassName<PropsWithChildren<{}>>;
|
|
186
189
|
|
|
187
190
|
// TOOD(burdon): Figure out nesting (indent and testId).
|
|
188
191
|
const FormContent = ({ classNames, children }: FormContentProps) => {
|
|
189
|
-
const { form, testId } = useFormContext(
|
|
192
|
+
const { form, testId } = useFormContext(FORM_CONTENT_NAME);
|
|
190
193
|
const ref = useRef<HTMLDivElement>(null);
|
|
191
194
|
useKeyHandler(ref.current, form);
|
|
192
195
|
|
|
@@ -202,26 +205,30 @@ const FormContent = ({ classNames, children }: FormContentProps) => {
|
|
|
202
205
|
);
|
|
203
206
|
};
|
|
204
207
|
|
|
205
|
-
FormContent.displayName =
|
|
208
|
+
FormContent.displayName = FORM_CONTENT_NAME;
|
|
206
209
|
|
|
207
210
|
//
|
|
208
211
|
// FieldSet
|
|
209
212
|
//
|
|
210
213
|
|
|
214
|
+
const FORM_FIELDSET_NAME = 'Form.FieldSet';
|
|
215
|
+
|
|
211
216
|
type FormFieldSetProps = ThemedClassName<{}>;
|
|
212
217
|
|
|
213
218
|
const FormFieldSet = ({ classNames }: FormFieldSetProps) => {
|
|
214
|
-
const { form, ...props } = useFormContext(
|
|
219
|
+
const { form, ...props } = useFormContext(FORM_FIELDSET_NAME);
|
|
215
220
|
|
|
216
221
|
return <NaturalFormFieldSet classNames={classNames} schema={form.schema} {...props} />;
|
|
217
222
|
};
|
|
218
223
|
|
|
219
|
-
FormFieldSet.displayName =
|
|
224
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
220
225
|
|
|
221
226
|
//
|
|
222
227
|
// Actions
|
|
223
228
|
//
|
|
224
229
|
|
|
230
|
+
const FORM_ACTIONS_NAME = 'Form.Actions';
|
|
231
|
+
|
|
225
232
|
type FormActionsProps = ThemedClassName<{}>;
|
|
226
233
|
|
|
227
234
|
const FormActions = ({ classNames }: FormActionsProps) => {
|
|
@@ -230,7 +237,7 @@ const FormActions = ({ classNames }: FormActionsProps) => {
|
|
|
230
237
|
form: { canSave, onSave, onCancel },
|
|
231
238
|
readonly,
|
|
232
239
|
layout,
|
|
233
|
-
} = useFormContext(
|
|
240
|
+
} = useFormContext(FORM_ACTIONS_NAME);
|
|
234
241
|
|
|
235
242
|
if (readonly || layout === 'static') {
|
|
236
243
|
return null;
|
|
@@ -266,21 +273,23 @@ const FormActions = ({ classNames }: FormActionsProps) => {
|
|
|
266
273
|
);
|
|
267
274
|
};
|
|
268
275
|
|
|
269
|
-
FormActions.displayName =
|
|
276
|
+
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
270
277
|
|
|
271
278
|
//
|
|
272
279
|
// Submit
|
|
273
280
|
//
|
|
274
281
|
|
|
275
|
-
|
|
282
|
+
const FORM_SUBMIT_NAME = 'Form.Submit';
|
|
283
|
+
|
|
284
|
+
type FormSubmitProps = ThemedClassName<Partial<Pick<IconButtonProps, 'icon' | 'label' | 'disabled'>>>;
|
|
276
285
|
|
|
277
|
-
const FormSubmit = ({ classNames, label, icon }: FormSubmitProps) => {
|
|
286
|
+
const FormSubmit = ({ classNames, label, icon, disabled }: FormSubmitProps) => {
|
|
278
287
|
const { t } = useTranslation(translationKey);
|
|
279
288
|
const {
|
|
280
289
|
form: { canSave, onSave },
|
|
281
290
|
readonly,
|
|
282
291
|
layout,
|
|
283
|
-
} = useFormContext(
|
|
292
|
+
} = useFormContext(FORM_SUBMIT_NAME);
|
|
284
293
|
|
|
285
294
|
if (readonly || layout === 'static') {
|
|
286
295
|
return null;
|
|
@@ -292,7 +301,7 @@ const FormSubmit = ({ classNames, label, icon }: FormSubmitProps) => {
|
|
|
292
301
|
classNames='is-full'
|
|
293
302
|
type='submit'
|
|
294
303
|
variant='primary'
|
|
295
|
-
disabled={!canSave}
|
|
304
|
+
disabled={disabled ?? !canSave}
|
|
296
305
|
icon={icon ?? 'ph--check--regular'}
|
|
297
306
|
label={label ?? t('save button label')}
|
|
298
307
|
onClick={onSave}
|
|
@@ -302,7 +311,7 @@ const FormSubmit = ({ classNames, label, icon }: FormSubmitProps) => {
|
|
|
302
311
|
);
|
|
303
312
|
};
|
|
304
313
|
|
|
305
|
-
FormSubmit.displayName =
|
|
314
|
+
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
306
315
|
|
|
307
316
|
//
|
|
308
317
|
// Form
|
|
@@ -327,5 +336,6 @@ export type {
|
|
|
327
336
|
FormContentProps,
|
|
328
337
|
FormFieldSetProps,
|
|
329
338
|
FormActionsProps,
|
|
339
|
+
FormSubmitProps,
|
|
330
340
|
FormFieldLabelProps as LabelProps,
|
|
331
341
|
};
|
|
@@ -44,7 +44,7 @@ const Component = ({
|
|
|
44
44
|
const meta: Meta<typeof Component> = {
|
|
45
45
|
title: 'ui/react-ui-form/FormFieldComponent',
|
|
46
46
|
component: Component,
|
|
47
|
-
decorators: [withTheme, withLayout({ layout: 'column' })],
|
|
47
|
+
decorators: [withTheme(), withLayout({ layout: 'column' })],
|
|
48
48
|
parameters: {
|
|
49
49
|
layout: 'fullscreen',
|
|
50
50
|
},
|
|
@@ -15,7 +15,7 @@ import React, {
|
|
|
15
15
|
|
|
16
16
|
import { type Format } from '@dxos/echo/internal';
|
|
17
17
|
import { Icon, Input, Tooltip } from '@dxos/react-ui';
|
|
18
|
-
import { errorText
|
|
18
|
+
import { errorText } from '@dxos/ui-theme';
|
|
19
19
|
|
|
20
20
|
import { type FormFieldStatus } from '../../hooks';
|
|
21
21
|
|
|
@@ -79,17 +79,15 @@ export type FormFieldLabelProps = {
|
|
|
79
79
|
|
|
80
80
|
export const FormFieldLabel = ({ label, error, readonly, asChild }: FormFieldLabelProps) => {
|
|
81
81
|
const Label = readonly || asChild ? 'span' : Input.Label;
|
|
82
|
-
const labelProps = readonly || asChild ? { className: 'text-description text-sm' } : { classNames: '!mlb-0 text-sm' };
|
|
83
|
-
|
|
84
82
|
return (
|
|
85
|
-
|
|
86
|
-
<Label
|
|
83
|
+
<>
|
|
84
|
+
<Label>{label}</Label>
|
|
87
85
|
{error && (
|
|
88
86
|
<Tooltip.Trigger asChild content={error} side='bottom'>
|
|
89
87
|
<Icon icon='ph--warning--regular' size={4} classNames={errorText} />
|
|
90
88
|
</Tooltip.Trigger>
|
|
91
89
|
)}
|
|
92
|
-
|
|
90
|
+
</>
|
|
93
91
|
);
|
|
94
92
|
};
|
|
95
93
|
|
|
@@ -118,15 +116,17 @@ export const FormFieldWrapper = <T,>(props: FormFieldWrapperProps<T>) => {
|
|
|
118
116
|
const str = String(value ?? '');
|
|
119
117
|
|
|
120
118
|
return (
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<Input.
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
<div role='none' className='contents'>
|
|
120
|
+
<Input.Root validationValence={status}>
|
|
121
|
+
{layout !== 'inline' && <FormFieldLabel error={error} readonly={readonly} label={label} />}
|
|
122
|
+
{layout === 'static' ? <p>{str}</p> : children ? children({ value }) : null}
|
|
123
|
+
{layout === 'full' && (
|
|
124
|
+
<Input.DescriptionAndValidation>
|
|
125
|
+
<Input.Validation>{error}</Input.Validation>
|
|
126
|
+
</Input.DescriptionAndValidation>
|
|
127
|
+
)}
|
|
128
|
+
</Input.Root>
|
|
129
|
+
</div>
|
|
130
130
|
);
|
|
131
131
|
};
|
|
132
132
|
|
|
@@ -42,9 +42,11 @@ export type FormFieldSetProps<T extends AnyProperties> = ThemedClassName<
|
|
|
42
42
|
>
|
|
43
43
|
>;
|
|
44
44
|
|
|
45
|
+
const FORM_FIELDSET_NAME = 'Form.FieldSet';
|
|
46
|
+
|
|
45
47
|
export const FormFieldSet = forwardRef<HTMLDivElement, FormFieldSetProps<any>>(
|
|
46
48
|
({ classNames, label, schema, readonly, path, exclude, sort, projection, layout, ...props }, forwardRef) => {
|
|
47
|
-
const values = useFormValues(
|
|
49
|
+
const values = useFormValues(FORM_FIELDSET_NAME, path);
|
|
48
50
|
|
|
49
51
|
// TODO(burdon): Updates on every value change.
|
|
50
52
|
// Remove values dep if can remove from getSchemaProperties.
|
|
@@ -122,4 +124,4 @@ export const FormFieldSet = forwardRef<HTMLDivElement, FormFieldSetProps<any>>(
|
|
|
122
124
|
},
|
|
123
125
|
);
|
|
124
126
|
|
|
125
|
-
FormFieldSet.displayName =
|
|
127
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
@@ -6,7 +6,7 @@ import '@dxos/lit-ui/dx-tag-picker.pcss';
|
|
|
6
6
|
|
|
7
7
|
import React, { useCallback, useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
import { type Database, Entity, Filter, Ref,
|
|
9
|
+
import { type Database, Entity, Filter, Ref, Type } from '@dxos/echo';
|
|
10
10
|
import { ReferenceAnnotationId, type ReferenceAnnotationValue } from '@dxos/echo/internal';
|
|
11
11
|
import { useQuery, useSchema as useSchema$ } from '@dxos/echo-react';
|
|
12
12
|
import { findAnnotation } from '@dxos/effect';
|
|
@@ -33,7 +33,15 @@ const defaultGetOptions: NonNullable<RefFieldProps['getOptions']> = (results) =>
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
const defaultResultsHook: NonNullable<RefFieldProps['resultsHook']> = (db, typename) =>
|
|
36
|
-
useQuery(
|
|
36
|
+
useQuery(
|
|
37
|
+
db,
|
|
38
|
+
typename
|
|
39
|
+
? // For Type.Ref(Type.Obj) we want to show all objects.
|
|
40
|
+
typename === Type.getTypename(Type.Obj)
|
|
41
|
+
? Filter.everything()
|
|
42
|
+
: Filter.typename(typename)
|
|
43
|
+
: Filter.nothing(),
|
|
44
|
+
);
|
|
37
45
|
|
|
38
46
|
export type RefFieldProps = FormFieldComponentProps &
|
|
39
47
|
Pick<ObjectPickerContentProps, 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath'> & {
|
|
@@ -137,7 +145,7 @@ export const RefField = (props: RefFieldProps) => {
|
|
|
137
145
|
!item ? (
|
|
138
146
|
<p className={mx(descriptionText, 'mbe-2')}>{t('empty readonly ref field label')}</p>
|
|
139
147
|
) : (
|
|
140
|
-
<DxAnchor key={item.id}
|
|
148
|
+
<DxAnchor key={item.id} dxn={item.id} rootclassname='mie-1'>
|
|
141
149
|
{item.label}
|
|
142
150
|
</DxAnchor>
|
|
143
151
|
)
|
|
@@ -0,0 +1,56 @@
|
|
|
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 { faker } from '@dxos/random';
|
|
9
|
+
import { Button, Input } from '@dxos/react-ui';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { translations } from '../../translations';
|
|
13
|
+
|
|
14
|
+
import { Settings } from './Settings';
|
|
15
|
+
|
|
16
|
+
faker.seed(132);
|
|
17
|
+
|
|
18
|
+
const DefaultStory = () => {
|
|
19
|
+
return (
|
|
20
|
+
<Settings.Root>
|
|
21
|
+
<Settings.Section title='Settings' description={faker.lorem.paragraphs(1)}>
|
|
22
|
+
<Settings.Group>
|
|
23
|
+
<Settings.ItemInput title={faker.lorem.sentence(2)} description={faker.lorem.paragraphs(1)}>
|
|
24
|
+
<Input.Root>
|
|
25
|
+
<Input.TextInput placeholder='Input' />
|
|
26
|
+
</Input.Root>
|
|
27
|
+
</Settings.ItemInput>
|
|
28
|
+
<Settings.ItemInput title={faker.lorem.sentence(2)} description={faker.lorem.paragraphs(2)}>
|
|
29
|
+
<Input.Root>
|
|
30
|
+
<Input.Switch />
|
|
31
|
+
</Input.Root>
|
|
32
|
+
</Settings.ItemInput>
|
|
33
|
+
<Settings.ItemInput title={faker.lorem.sentence(3)} description={faker.lorem.paragraphs(2)}>
|
|
34
|
+
<Button>Test</Button>
|
|
35
|
+
</Settings.ItemInput>
|
|
36
|
+
</Settings.Group>
|
|
37
|
+
</Settings.Section>
|
|
38
|
+
</Settings.Root>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const meta = {
|
|
43
|
+
title: 'ui/react-ui-form/Settings',
|
|
44
|
+
render: DefaultStory,
|
|
45
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' })],
|
|
46
|
+
parameters: {
|
|
47
|
+
layout: 'fullscreen',
|
|
48
|
+
translations,
|
|
49
|
+
},
|
|
50
|
+
} satisfies Meta;
|
|
51
|
+
|
|
52
|
+
export default meta;
|
|
53
|
+
|
|
54
|
+
type Story = StoryObj<typeof meta>;
|
|
55
|
+
|
|
56
|
+
export const Default: Story = {};
|