@dxos/react-ui-form 0.8.3-staging.0fa589b → 0.8.4-main.28f8d3d
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 +222 -209
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +222 -209
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +4 -4
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +3 -3
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- 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 +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +1 -1
- 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/RefField.d.ts +1 -1
- package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/factory.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +4 -4
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +3 -3
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts +1 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +1 -1
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +57 -57
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +31 -32
- package/src/components/ControlSection/ControlSection.stories.tsx +3 -2
- package/src/components/FieldEditor/FieldEditor.stories.tsx +17 -14
- package/src/components/FieldEditor/FieldEditor.test.tsx +14 -13
- package/src/components/FieldEditor/FieldEditor.tsx +11 -11
- package/src/components/Form/ArrayField.tsx +8 -7
- package/src/components/Form/Defaults.tsx +2 -1
- package/src/components/Form/Form.stories.tsx +5 -4
- package/src/components/Form/Form.tsx +4 -3
- package/src/components/Form/FormActions.tsx +2 -1
- package/src/components/Form/FormContent.tsx +6 -5
- package/src/components/Form/FormContext.tsx +5 -5
- package/src/components/Form/RefField.tsx +7 -6
- package/src/components/Form/custom/GeoPointInput.tsx +2 -2
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +5 -4
- package/src/components/Form/custom/SelectOptionsInput.tsx +28 -29
- package/src/components/Form/factory.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +21 -14
- package/src/components/ViewEditor/ViewEditor.test.tsx +41 -38
- package/src/components/ViewEditor/ViewEditor.tsx +81 -81
- package/src/components/deprecated/Form.stories.tsx +8 -7
- package/src/components/deprecated/Form.tsx +6 -6
- package/src/components/testing.tsx +1 -1
- package/src/hooks/useForm.ts +5 -3
- package/src/hooks/useRefQueryLookupHandler.ts +1 -1
- package/src/index.ts +1 -1
- package/src/translations.ts +7 -4
- package/dist/lib/node/index.cjs +0 -2416
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts +0 -10
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +0 -1
- package/src/components/ViewEditor/Test.stories.tsx +0 -45
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.4-main.28f8d3d",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"source": "./src/index.ts",
|
|
12
13
|
"types": "./dist/types/src/index.d.ts",
|
|
13
14
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
15
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -29,50 +30,48 @@
|
|
|
29
30
|
"@radix-ui/react-context": "1.1.1",
|
|
30
31
|
"date-fns": "^3.3.1",
|
|
31
32
|
"jsonpath": "^1.1.1",
|
|
32
|
-
"@dxos/
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/echo": "0.8.
|
|
36
|
-
"@dxos/echo-schema": "0.8.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/lit-ui": "0.8.
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/react-ui-list": "0.8.
|
|
45
|
-
"@dxos/react-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/schema": "0.8.
|
|
50
|
-
"@dxos/util": "0.8.
|
|
33
|
+
"@dxos/async": "0.8.4-main.28f8d3d",
|
|
34
|
+
"@dxos/debug": "0.8.4-main.28f8d3d",
|
|
35
|
+
"@dxos/echo": "0.8.4-main.28f8d3d",
|
|
36
|
+
"@dxos/echo-db": "0.8.4-main.28f8d3d",
|
|
37
|
+
"@dxos/echo-schema": "0.8.4-main.28f8d3d",
|
|
38
|
+
"@dxos/invariant": "0.8.4-main.28f8d3d",
|
|
39
|
+
"@dxos/keys": "0.8.4-main.28f8d3d",
|
|
40
|
+
"@dxos/effect": "0.8.4-main.28f8d3d",
|
|
41
|
+
"@dxos/lit-ui": "0.8.4-main.28f8d3d",
|
|
42
|
+
"@dxos/log": "0.8.4-main.28f8d3d",
|
|
43
|
+
"@dxos/react-client": "0.8.4-main.28f8d3d",
|
|
44
|
+
"@dxos/live-object": "0.8.4-main.28f8d3d",
|
|
45
|
+
"@dxos/react-ui-list": "0.8.4-main.28f8d3d",
|
|
46
|
+
"@dxos/react-ui-pickers": "0.8.4-main.28f8d3d",
|
|
47
|
+
"@dxos/react-ui-tag-picker": "0.8.4-main.28f8d3d",
|
|
48
|
+
"@dxos/react-ui-types": "0.8.4-main.28f8d3d",
|
|
49
|
+
"@dxos/react-ui-stack": "0.8.4-main.28f8d3d",
|
|
50
|
+
"@dxos/schema": "0.8.4-main.28f8d3d",
|
|
51
|
+
"@dxos/util": "0.8.4-main.28f8d3d"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@phosphor-icons/react": "^2.1.5",
|
|
54
54
|
"@types/jsonpath": "^0.2.4",
|
|
55
55
|
"@types/react": "~18.2.0",
|
|
56
56
|
"@types/react-dom": "~18.2.0",
|
|
57
|
-
"effect": "3.
|
|
57
|
+
"effect": "3.17.7",
|
|
58
58
|
"fast-check": "^3.19.0",
|
|
59
59
|
"react": "~18.2.0",
|
|
60
60
|
"react-dom": "~18.2.0",
|
|
61
61
|
"vite": "5.4.7",
|
|
62
|
-
"@dxos/echo-signals": "0.8.
|
|
63
|
-
"@dxos/random": "0.8.
|
|
64
|
-
"@dxos/react-ui
|
|
65
|
-
"@dxos/react-ui": "0.8.
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
62
|
+
"@dxos/echo-signals": "0.8.4-main.28f8d3d",
|
|
63
|
+
"@dxos/random": "0.8.4-main.28f8d3d",
|
|
64
|
+
"@dxos/react-ui": "0.8.4-main.28f8d3d",
|
|
65
|
+
"@dxos/react-ui-theme": "0.8.4-main.28f8d3d",
|
|
66
|
+
"@dxos/storybook-utils": "0.8.4-main.28f8d3d",
|
|
67
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.28f8d3d"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"
|
|
71
|
-
"effect": "3.13.3",
|
|
70
|
+
"effect": "^3.13.3",
|
|
72
71
|
"react": "~18.2.0",
|
|
73
72
|
"react-dom": "~18.2.0",
|
|
74
|
-
"@dxos/react-ui
|
|
75
|
-
"@dxos/react-ui": "0.8.
|
|
73
|
+
"@dxos/react-ui": "0.8.4-main.28f8d3d",
|
|
74
|
+
"@dxos/react-ui-theme": "0.8.4-main.28f8d3d"
|
|
76
75
|
},
|
|
77
76
|
"publishConfig": {
|
|
78
77
|
"access": "public"
|
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
10
10
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
11
11
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
12
12
|
|
|
13
|
+
import { translations } from '../../translations';
|
|
14
|
+
|
|
13
15
|
import { ControlPage, ControlSection, type ControlSectionProps } from './ControlSection';
|
|
14
|
-
import translations from '../../translations';
|
|
15
16
|
|
|
16
17
|
const meta: Meta<ControlSectionProps> = {
|
|
17
18
|
title: 'ui/react-ui-form/ControlSection',
|
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react';
|
|
8
|
-
import React, {
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
+
import React, { useEffect, useMemo } from 'react';
|
|
9
9
|
|
|
10
10
|
import { createEchoSchema } from '@dxos/live-object/testing';
|
|
11
11
|
import { log } from '@dxos/log';
|
|
12
|
-
import {
|
|
12
|
+
import { ProjectionModel } from '@dxos/schema';
|
|
13
13
|
import { TestSchema, testView } from '@dxos/schema/testing';
|
|
14
14
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
15
15
|
|
|
16
|
+
import { translations } from '../../translations';
|
|
17
|
+
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout, TestPanel } from '../testing';
|
|
18
|
+
|
|
16
19
|
import { FieldEditor, type FieldEditorProps } from './FieldEditor';
|
|
17
|
-
import translations from '../../translations';
|
|
18
|
-
import { TestLayout, TestPanel, FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
|
|
19
20
|
|
|
20
21
|
// Type definition for debug objects exposed to tests.
|
|
21
22
|
export type FieldEditorDebugObjects = {
|
|
22
23
|
props: FieldEditorProps;
|
|
23
|
-
projection:
|
|
24
|
+
projection: ProjectionModel;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
type StoryProps = FieldEditorProps;
|
|
27
28
|
|
|
28
29
|
const DefaultStory = (props: FieldEditorProps) => {
|
|
29
|
-
const projection = useMemo(() => new ViewProjection(createEchoSchema(TestSchema).jsonSchema, testView), []);
|
|
30
30
|
const handleComplete: FieldEditorProps['onSave'] = () => {
|
|
31
31
|
log.info('onClose', { props });
|
|
32
32
|
};
|
|
@@ -34,20 +34,23 @@ const DefaultStory = (props: FieldEditorProps) => {
|
|
|
34
34
|
// Expose objects on window for test access.
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
if (typeof window !== 'undefined') {
|
|
37
|
-
(window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = {
|
|
37
|
+
(window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = {
|
|
38
|
+
props,
|
|
39
|
+
projection: props.projection,
|
|
40
|
+
} satisfies FieldEditorDebugObjects;
|
|
38
41
|
}
|
|
39
|
-
}, [props, projection]);
|
|
42
|
+
}, [props, props.projection]);
|
|
40
43
|
|
|
41
44
|
// NOTE(ZaymonFC): This looks awkward but it resolves an infinite parsing issue with sb.
|
|
42
45
|
const json = useMemo(
|
|
43
|
-
() => JSON.parse(JSON.stringify({ props, projection })),
|
|
44
|
-
[JSON.stringify(props), JSON.stringify(projection)],
|
|
46
|
+
() => JSON.parse(JSON.stringify({ props, projection: props.projection })),
|
|
47
|
+
[JSON.stringify(props), JSON.stringify(props.projection)],
|
|
45
48
|
);
|
|
46
49
|
|
|
47
50
|
return (
|
|
48
51
|
<TestLayout json={json}>
|
|
49
52
|
<TestPanel>
|
|
50
|
-
<FieldEditor {...props}
|
|
53
|
+
<FieldEditor {...props} onSave={handleComplete} />
|
|
51
54
|
</TestPanel>
|
|
52
55
|
</TestLayout>
|
|
53
56
|
);
|
|
@@ -69,8 +72,8 @@ type Story = StoryObj<StoryProps>;
|
|
|
69
72
|
|
|
70
73
|
export const Default: Story = {
|
|
71
74
|
args: {
|
|
72
|
-
|
|
73
|
-
field: testView.fields[0],
|
|
75
|
+
projection: new ProjectionModel(createEchoSchema(TestSchema).jsonSchema, testView.projection),
|
|
76
|
+
field: testView.projection.fields[0],
|
|
74
77
|
},
|
|
75
78
|
parameters: { controls: { disabled: true } },
|
|
76
79
|
};
|
|
@@ -3,25 +3,18 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { composeStories } from '@storybook/react';
|
|
6
|
-
import {
|
|
6
|
+
import { act, cleanup, fireEvent, screen } from '@testing-library/react';
|
|
7
7
|
import { afterEach, describe, expect, test } from 'vitest';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { ProjectionModel } from '@dxos/schema';
|
|
10
|
+
|
|
11
|
+
import { FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
|
|
10
12
|
|
|
11
13
|
import * as stories from './FieldEditor.stories';
|
|
12
14
|
import { type FieldEditorDebugObjects } from './FieldEditor.stories';
|
|
13
|
-
import { FIELD_EDITOR_DEBUG_SYMBOL } from '../testing';
|
|
14
15
|
|
|
15
16
|
const { Default } = composeStories(stories);
|
|
16
17
|
|
|
17
|
-
const getFieldEditorDebugObjects = (): FieldEditorDebugObjects => {
|
|
18
|
-
const debugObjects = (window as any)[FIELD_EDITOR_DEBUG_SYMBOL] as FieldEditorDebugObjects;
|
|
19
|
-
expect(debugObjects).toBeDefined();
|
|
20
|
-
expect(debugObjects.props).toBeInstanceOf(Object); // Props object
|
|
21
|
-
expect(debugObjects.projection).toBeInstanceOf(ViewProjection);
|
|
22
|
-
return debugObjects;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
18
|
describe('FieldEditor', () => {
|
|
26
19
|
afterEach(() => {
|
|
27
20
|
cleanup();
|
|
@@ -33,7 +26,7 @@ describe('FieldEditor', () => {
|
|
|
33
26
|
expect(screen.getByText('Type format')).toBeInTheDocument();
|
|
34
27
|
expect(screen.getByText('String')).toBeInTheDocument();
|
|
35
28
|
|
|
36
|
-
// Verify the initial field shows as String type
|
|
29
|
+
// Verify the initial field shows as String type.
|
|
37
30
|
expect(screen.getByText('String')).toBeInTheDocument();
|
|
38
31
|
|
|
39
32
|
fireEvent.click(screen.getByRole('combobox'));
|
|
@@ -49,9 +42,17 @@ describe('FieldEditor', () => {
|
|
|
49
42
|
// Access the live objects directly from window using symbol.
|
|
50
43
|
const debugObjects = getFieldEditorDebugObjects();
|
|
51
44
|
|
|
52
|
-
const name = debugObjects.projection.
|
|
45
|
+
const name = debugObjects.projection.baseSchema.properties!.name;
|
|
53
46
|
expect(name.type).toBe('number');
|
|
54
47
|
expect(name.format).toBe('number');
|
|
55
48
|
expect(name.description).toBe('Full name.');
|
|
56
49
|
});
|
|
57
50
|
});
|
|
51
|
+
|
|
52
|
+
const getFieldEditorDebugObjects = (): FieldEditorDebugObjects => {
|
|
53
|
+
const debugObjects = (window as any)[FIELD_EDITOR_DEBUG_SYMBOL] as FieldEditorDebugObjects;
|
|
54
|
+
expect(debugObjects).toBeDefined();
|
|
55
|
+
expect(debugObjects.props).toBeInstanceOf(Object); // Props object
|
|
56
|
+
expect(debugObjects.projection).toBeInstanceOf(ProjectionModel);
|
|
57
|
+
return debugObjects;
|
|
58
|
+
};
|
|
@@ -5,26 +5,25 @@
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type SchemaRegistry } from '@dxos/echo-db';
|
|
8
|
-
import { FormatEnum, FormatEnums, formatToType
|
|
8
|
+
import { type EchoSchema, FormatEnum, FormatEnums, formatToType } from '@dxos/echo-schema';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
11
11
|
import {
|
|
12
|
-
getFormatSchema,
|
|
13
|
-
getSchemaProperties,
|
|
14
|
-
sortProperties,
|
|
15
12
|
type FieldType,
|
|
13
|
+
type ProjectionModel,
|
|
16
14
|
type PropertyType,
|
|
17
|
-
type ViewType,
|
|
18
|
-
type ViewProjection,
|
|
19
15
|
type SchemaProperty,
|
|
16
|
+
getFormatSchema,
|
|
17
|
+
getSchemaProperties,
|
|
18
|
+
sortProperties,
|
|
20
19
|
} from '@dxos/schema';
|
|
21
20
|
|
|
22
21
|
import { translationKey } from '../../translations';
|
|
23
22
|
import { Form, type FormProps, type InputComponent, SelectInput, SelectOptionInput } from '../Form';
|
|
24
23
|
|
|
25
24
|
export type FieldEditorProps = {
|
|
26
|
-
|
|
27
|
-
projection:
|
|
25
|
+
readonly?: boolean;
|
|
26
|
+
projection: ProjectionModel;
|
|
28
27
|
field: FieldType;
|
|
29
28
|
registry?: SchemaRegistry;
|
|
30
29
|
onSave: () => void;
|
|
@@ -35,7 +34,7 @@ export type FieldEditorProps = {
|
|
|
35
34
|
* Displays a Form representing the metadata for a given `Field` and `View`.
|
|
36
35
|
*/
|
|
37
36
|
export const FieldEditor = ({
|
|
38
|
-
|
|
37
|
+
readonly,
|
|
39
38
|
projection,
|
|
40
39
|
field,
|
|
41
40
|
registry,
|
|
@@ -112,7 +111,7 @@ export const FieldEditor = ({
|
|
|
112
111
|
|
|
113
112
|
const handleValidate = useCallback<NonNullable<FormProps<PropertyType>['onValidate']>>(
|
|
114
113
|
({ property }) => {
|
|
115
|
-
if (property &&
|
|
114
|
+
if (property && projection.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
116
115
|
return [
|
|
117
116
|
{
|
|
118
117
|
path: 'property',
|
|
@@ -121,7 +120,7 @@ export const FieldEditor = ({
|
|
|
121
120
|
];
|
|
122
121
|
}
|
|
123
122
|
},
|
|
124
|
-
[
|
|
123
|
+
[projection.fields, field],
|
|
125
124
|
);
|
|
126
125
|
|
|
127
126
|
const handleSave = useCallback<NonNullable<FormProps<PropertyType>['onSave']>>(
|
|
@@ -188,6 +187,7 @@ export const FieldEditor = ({
|
|
|
188
187
|
<Form<PropertyType>
|
|
189
188
|
key={field.id}
|
|
190
189
|
autoFocus
|
|
190
|
+
readonly={readonly}
|
|
191
191
|
values={props}
|
|
192
192
|
schema={fieldSchema}
|
|
193
193
|
filter={propIsNotType}
|
|
@@ -6,18 +6,19 @@ import { SchemaAST, pipe } from 'effect';
|
|
|
6
6
|
import { capitalize } from 'effect/String';
|
|
7
7
|
import React, { Fragment, useCallback } from 'react';
|
|
8
8
|
|
|
9
|
-
import { findNode, getDiscriminatedType, isDiscriminatedUnion
|
|
9
|
+
import { SimpleType, findNode, getDiscriminatedType, isDiscriminatedUnion } from '@dxos/effect';
|
|
10
10
|
import { invariant } from '@dxos/invariant';
|
|
11
11
|
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
12
|
-
import {
|
|
12
|
+
import { type SchemaProperty, getSchemaProperties } from '@dxos/schema';
|
|
13
13
|
|
|
14
|
-
import { type ComponentLookup } from './Form';
|
|
15
|
-
import { FormField } from './FormContent';
|
|
16
|
-
import { useFormValues, type FormInputStateProps } from './FormContext';
|
|
17
|
-
import { InputHeader, type InputComponent } from './Input';
|
|
18
14
|
import { translationKey } from '../../translations';
|
|
19
15
|
import { findArrayElementType } from '../../util';
|
|
20
16
|
|
|
17
|
+
import { type ComponentLookup } from './Form';
|
|
18
|
+
import { FormField } from './FormContent';
|
|
19
|
+
import { type FormInputStateProps, useFormValues } from './FormContext';
|
|
20
|
+
import { type InputComponent, InputHeader } from './Input';
|
|
21
|
+
|
|
21
22
|
type ArrayFieldProps = {
|
|
22
23
|
property: SchemaProperty<any>;
|
|
23
24
|
readonly?: boolean;
|
|
@@ -113,7 +114,7 @@ export const ArrayField = ({ property, readonly, path, inputProps, Custom, looku
|
|
|
113
114
|
</div>
|
|
114
115
|
{!readonly && (
|
|
115
116
|
<IconButton
|
|
116
|
-
classNames='is-full mlb-
|
|
117
|
+
classNames='is-full mlb-cardSpacingBlock flex'
|
|
117
118
|
icon='ph--plus--regular'
|
|
118
119
|
label={t('add field')}
|
|
119
120
|
onClick={handleAdd}
|
|
@@ -6,9 +6,10 @@ import React, { useCallback, useEffect, useRef } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
-
import { type InputProps, InputHeader } from './Input';
|
|
10
9
|
import { translationKey } from '../../translations';
|
|
11
10
|
|
|
11
|
+
import { InputHeader, type InputProps } from './Input';
|
|
12
|
+
|
|
12
13
|
export const TextInput = ({
|
|
13
14
|
type,
|
|
14
15
|
label,
|
|
@@ -4,21 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
9
|
import React, { useCallback, useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import { ContactType } from '@dxos/client/testing';
|
|
12
|
-
import { type BaseObject, Expando, Format,
|
|
12
|
+
import { type BaseObject, Expando, Format, Ref, type TypeAnnotation, getObjectDXN } from '@dxos/echo-schema';
|
|
13
13
|
import { live } from '@dxos/live-object';
|
|
14
14
|
import { withSurfaceVariantsLayout } from '@dxos/react-ui/testing';
|
|
15
15
|
import { Testing } from '@dxos/schema/testing';
|
|
16
16
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
17
17
|
|
|
18
|
+
import { translations } from '../../translations';
|
|
19
|
+
import { TestLayout, TestPanel } from '../testing';
|
|
20
|
+
|
|
18
21
|
import { SelectInput } from './Defaults';
|
|
19
22
|
import { Form, type FormProps } from './Form';
|
|
20
|
-
import translations from '../../translations';
|
|
21
|
-
import { TestLayout, TestPanel } from '../testing';
|
|
22
23
|
|
|
23
24
|
const AddressSchema = Schema.Struct({
|
|
24
25
|
street: Schema.optional(Schema.String.annotations({ title: 'Street' })),
|
|
@@ -10,11 +10,12 @@ import { type ThemedClassName } from '@dxos/react-ui';
|
|
|
10
10
|
import { cardDialogOverflow, cardSpacing } from '@dxos/react-ui-stack';
|
|
11
11
|
import { type SchemaProperty } from '@dxos/schema';
|
|
12
12
|
|
|
13
|
+
import { type FormOptions } from '../../hooks';
|
|
14
|
+
|
|
13
15
|
import { FormActions, type FormOuterSpacing } from './FormActions';
|
|
14
16
|
import { FormFields, type FormFieldsProps } from './FormContent';
|
|
15
17
|
import { FormProvider } from './FormContext';
|
|
16
|
-
import { type
|
|
17
|
-
import { type FormOptions } from '../../hooks';
|
|
18
|
+
import { type InputComponent, type InputProps } from './Input';
|
|
18
19
|
|
|
19
20
|
export type PropsFilter<T extends BaseObject> = (props: SchemaProperty<T>[]) => SchemaProperty<T>[];
|
|
20
21
|
|
|
@@ -99,7 +100,7 @@ export const Form = <T extends BaseObject>({
|
|
|
99
100
|
readonly={readonly}
|
|
100
101
|
schema={schema}
|
|
101
102
|
/>
|
|
102
|
-
{(onCancel || onSave) && !autoSave && (
|
|
103
|
+
{(onCancel || onSave) && !autoSave && !readonly && (
|
|
103
104
|
<FormActions readonly={readonly} onCancel={onCancel} outerSpacing={outerSpacing} />
|
|
104
105
|
)}
|
|
105
106
|
</div>
|
|
@@ -8,9 +8,10 @@ import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
|
8
8
|
import { cardSpacing } from '@dxos/react-ui-stack';
|
|
9
9
|
import { mx } from '@dxos/react-ui-theme';
|
|
10
10
|
|
|
11
|
-
import { useFormContext } from './FormContext';
|
|
12
11
|
import { translationKey } from '../../translations';
|
|
13
12
|
|
|
13
|
+
import { useFormContext } from './FormContext';
|
|
14
|
+
|
|
14
15
|
export type FormOuterSpacing = boolean | 'blockStart-0' | 'scroll-fields';
|
|
15
16
|
|
|
16
17
|
export type FormActionsProps = {
|
|
@@ -9,18 +9,19 @@ import React, { forwardRef, useMemo } from 'react';
|
|
|
9
9
|
import { createJsonPath, findNode, getDiscriminatedType, isDiscriminatedUnion } from '@dxos/effect';
|
|
10
10
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
11
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
12
|
-
import {
|
|
12
|
+
import { type SchemaProperty, getSchemaProperties } from '@dxos/schema';
|
|
13
13
|
import { isNotFalsy } from '@dxos/util';
|
|
14
14
|
|
|
15
|
+
import { type QueryRefOptions } from '../../hooks';
|
|
16
|
+
import { getRefProps } from '../../util';
|
|
17
|
+
|
|
15
18
|
import { ArrayField } from './ArrayField';
|
|
16
19
|
import { SelectInput } from './Defaults';
|
|
20
|
+
import { getInputComponent } from './factory';
|
|
17
21
|
import { type ComponentLookup } from './Form';
|
|
18
|
-
import {
|
|
22
|
+
import { useFormValues, useInputProps } from './FormContext';
|
|
19
23
|
import { type InputComponent } from './Input';
|
|
20
24
|
import { RefField } from './RefField';
|
|
21
|
-
import { getInputComponent } from './factory';
|
|
22
|
-
import { type QueryRefOptions } from '../../hooks';
|
|
23
|
-
import { getRefProps } from '../../util';
|
|
24
25
|
|
|
25
26
|
export type FormFieldProps = {
|
|
26
27
|
property: SchemaProperty<any>;
|
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import React, {
|
|
6
|
-
|
|
6
|
+
type FocusEvent,
|
|
7
|
+
type PropsWithChildren,
|
|
7
8
|
type RefObject,
|
|
9
|
+
createContext,
|
|
10
|
+
useCallback,
|
|
8
11
|
useContext,
|
|
9
12
|
useEffect,
|
|
10
13
|
useMemo,
|
|
11
|
-
type FocusEvent,
|
|
12
|
-
type PropsWithChildren,
|
|
13
|
-
useCallback,
|
|
14
14
|
} from 'react';
|
|
15
15
|
|
|
16
16
|
import { raise } from '@dxos/debug';
|
|
17
17
|
import { type BaseObject, getValue } from '@dxos/echo-schema';
|
|
18
|
-
import {
|
|
18
|
+
import { type SimpleType, createJsonPath } from '@dxos/effect';
|
|
19
19
|
|
|
20
20
|
import { type FormHandler, type FormOptions, useForm } from '../../hooks';
|
|
21
21
|
|
|
@@ -3,28 +3,29 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type SchemaAST } from 'effect';
|
|
6
|
-
import React, { useCallback, useMemo
|
|
6
|
+
import React, { type FocusEvent, useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
Expando,
|
|
10
|
-
getTypeAnnotation,
|
|
11
10
|
Ref,
|
|
12
11
|
ReferenceAnnotationId,
|
|
13
12
|
type ReferenceAnnotationValue,
|
|
13
|
+
getTypeAnnotation,
|
|
14
14
|
} from '@dxos/echo-schema';
|
|
15
15
|
import { findAnnotation } from '@dxos/effect';
|
|
16
16
|
import { DXN } from '@dxos/keys';
|
|
17
17
|
import { DxRefTag } from '@dxos/lit-ui/react';
|
|
18
18
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
19
|
-
import { TagPicker, type
|
|
19
|
+
import { TagPicker, type TagPickerItemData, type TagPickerMode } from '@dxos/react-ui-tag-picker';
|
|
20
20
|
import { descriptionText, mx } from '@dxos/react-ui-theme';
|
|
21
21
|
import { isNonNullable } from '@dxos/util';
|
|
22
22
|
|
|
23
|
-
import { TextInput } from './Defaults';
|
|
24
|
-
import { InputHeader, type InputProps } from './Input';
|
|
25
23
|
import { type QueryRefOptions, useQueryRefOptions } from '../../hooks';
|
|
26
24
|
import { translationKey } from '../../translations';
|
|
27
25
|
|
|
26
|
+
import { TextInput } from './Defaults';
|
|
27
|
+
import { InputHeader, type InputProps } from './Input';
|
|
28
|
+
|
|
28
29
|
type RefFieldProps = InputProps & {
|
|
29
30
|
ast?: SchemaAST.AST;
|
|
30
31
|
array?: boolean;
|
|
@@ -156,7 +157,7 @@ export const RefField = ({
|
|
|
156
157
|
onBlur={(event) => onBlur(event as unknown as FocusEvent<HTMLElement>)}
|
|
157
158
|
onUpdate={handleUpdate}
|
|
158
159
|
onSearch={handleSearch}
|
|
159
|
-
classNames='
|
|
160
|
+
classNames='bg-inputSurface p-1.5 rounded-sm'
|
|
160
161
|
/>
|
|
161
162
|
)}
|
|
162
163
|
</div>
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { type ChangeEvent, useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type GeoPoint
|
|
7
|
+
import { GeoLocation, type GeoPoint } from '@dxos/echo-schema';
|
|
8
8
|
import { Input, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { safeParseFloat } from '@dxos/util';
|
|
10
10
|
|
|
@@ -4,18 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import { Schema } from 'effect';
|
|
9
9
|
import React, { useState } from 'react';
|
|
10
10
|
|
|
11
|
-
import {
|
|
11
|
+
import { type SelectOption, SelectOptionSchema } from '@dxos/echo-schema';
|
|
12
12
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import translations from '../../../translations';
|
|
14
|
+
import { translations } from '../../../translations';
|
|
16
15
|
import { TestLayout, TestPanel } from '../../testing';
|
|
17
16
|
import { Form } from '../Form';
|
|
18
17
|
|
|
18
|
+
import { SelectOptionInput } from './SelectOptionsInput';
|
|
19
|
+
|
|
19
20
|
const schema = Schema.Struct({
|
|
20
21
|
options: Schema.Array(SelectOptionSchema).pipe(Schema.mutable),
|
|
21
22
|
}).pipe(Schema.mutable);
|