@dxos/react-ui-form 0.8.4-main.84f28bd → 0.8.4-main.937b3ca
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 +2203 -2067
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +2203 -2067
- 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.d.ts +4 -4
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +84 -5
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +8 -8
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +84 -7
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form-old.stories.d.ts +131 -0
- package/dist/types/src/components/Form/Form-old.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/Form.d.ts +81 -25
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +127 -55
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +37 -0
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +78 -0
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +9 -0
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/FormFieldSet.d.ts +19 -0
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/ArrayField.d.ts +18 -0
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/BooleanField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts +5 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/NumberField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/RefField.d.ts +14 -0
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectField.d.ts +10 -0
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +5 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +82 -0
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/TextField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/TupleField.d.ts +6 -0
- package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/index.d.ts +12 -0
- package/dist/types/src/components/Form/fields/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/index.d.ts +2 -4
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +46 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +85 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/index.d.ts +2 -0
- package/dist/types/src/components/ObjectPicker/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +21 -9
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +84 -9
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.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/components/testing.d.ts +4 -3
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -3
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts +82 -0
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -0
- package/dist/types/src/hooks/useKeyHandler.d.ts +6 -0
- package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +19 -10
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts +3 -3
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts +2 -2
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +1 -1
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/properties.d.ts +7 -0
- package/dist/types/src/util/properties.d.ts.map +1 -0
- package/dist/types/src/util/refs.d.ts +2 -3
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +51 -40
- package/src/components/ControlSection/ControlSection.stories.tsx +11 -14
- package/src/components/ControlSection/ControlSection.tsx +30 -16
- package/src/components/FieldEditor/FieldEditor.stories.tsx +53 -30
- package/src/components/FieldEditor/FieldEditor.test.tsx +14 -13
- package/src/components/FieldEditor/FieldEditor.tsx +87 -92
- package/src/components/Form/Form-old.stories.tsx +314 -0
- package/src/components/Form/Form.stories.tsx +155 -219
- package/src/components/Form/Form.tsx +319 -96
- package/src/components/Form/FormField.tsx +286 -0
- package/src/components/Form/FormFieldComponent.stories.tsx +65 -0
- package/src/components/Form/FormFieldComponent.tsx +174 -0
- package/src/components/Form/FormFieldSet.tsx +125 -0
- package/src/components/Form/README.md +3 -0
- package/src/components/Form/fields/ArrayField.tsx +151 -0
- package/src/components/Form/fields/BooleanField.tsx +22 -0
- package/src/components/Form/fields/GeoPointField.tsx +120 -0
- package/src/components/Form/fields/MarkdownField.tsx +78 -0
- package/src/components/Form/fields/NumberField.tsx +39 -0
- package/src/components/Form/fields/RefField.tsx +181 -0
- package/src/components/Form/fields/SelectField.tsx +65 -0
- package/src/components/Form/{custom/SelectOptionsInput.stories.tsx → fields/SelectOptionField.stories.tsx} +25 -22
- package/src/components/Form/{custom/SelectOptionsInput.tsx → fields/SelectOptionField.tsx} +47 -42
- package/src/components/Form/fields/TextAreaField.tsx +38 -0
- package/src/components/Form/fields/TextField.tsx +38 -0
- package/src/components/Form/{custom/TupleInput.tsx → fields/TupleField.tsx} +16 -9
- package/src/components/Form/fields/index.ts +15 -0
- package/src/components/Form/index.ts +3 -4
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +214 -0
- package/src/components/ObjectPicker/ObjectPicker.tsx +175 -0
- package/src/components/ObjectPicker/index.ts +5 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +141 -59
- package/src/components/ViewEditor/ViewEditor.test.tsx +25 -21
- package/src/components/ViewEditor/ViewEditor.tsx +317 -214
- package/src/components/index.ts +1 -2
- package/src/components/testing.tsx +19 -11
- package/src/hooks/index.ts +2 -3
- package/src/hooks/useFormHandler.ts +356 -0
- package/src/hooks/useKeyHandler.tsx +37 -0
- package/src/translations.ts +21 -12
- package/src/util/field.ts +33 -43
- package/src/util/formatting.ts +22 -22
- package/src/util/index.ts +1 -1
- package/src/util/properties.ts +18 -0
- package/src/util/refs.ts +12 -18
- package/dist/types/src/components/Form/ArrayField.d.ts +0 -16
- package/dist/types/src/components/Form/ArrayField.d.ts.map +0 -1
- package/dist/types/src/components/Form/Defaults.d.ts +0 -14
- package/dist/types/src/components/Form/Defaults.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormActions.d.ts +0 -9
- package/dist/types/src/components/Form/FormActions.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormContent.d.ts +0 -57
- package/dist/types/src/components/Form/FormContent.d.ts.map +0 -1
- package/dist/types/src/components/Form/FormContext.d.ts +0 -23
- package/dist/types/src/components/Form/FormContext.d.ts.map +0 -1
- package/dist/types/src/components/Form/Input.d.ts +0 -26
- package/dist/types/src/components/Form/Input.d.ts.map +0 -1
- package/dist/types/src/components/Form/RefField.d.ts +0 -12
- package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts +0 -4
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts +0 -4
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts +0 -7
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts +0 -6
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +0 -1
- package/dist/types/src/components/Form/custom/index.d.ts +0 -4
- package/dist/types/src/components/Form/custom/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/factory.d.ts +0 -8
- package/dist/types/src/components/Form/factory.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/Form.d.ts +0 -15
- package/dist/types/src/components/deprecated/Form.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts +0 -13
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts +0 -16
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +0 -1
- package/dist/types/src/components/deprecated/index.d.ts +0 -2
- package/dist/types/src/components/deprecated/index.d.ts.map +0 -1
- package/dist/types/src/hooks/useForm.d.ts +0 -67
- package/dist/types/src/hooks/useForm.d.ts.map +0 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +0 -23
- package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +0 -1
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
- package/dist/types/src/util/schema.d.ts +0 -3
- package/dist/types/src/util/schema.d.ts.map +0 -1
- package/src/components/Form/ArrayField.tsx +0 -124
- package/src/components/Form/Defaults.tsx +0 -203
- package/src/components/Form/FormActions.tsx +0 -53
- package/src/components/Form/FormContent.tsx +0 -240
- package/src/components/Form/FormContext.tsx +0 -110
- package/src/components/Form/Input.tsx +0 -51
- package/src/components/Form/RefField.tsx +0 -213
- package/src/components/Form/custom/GeoPointInput.tsx +0 -72
- package/src/components/Form/custom/index.ts +0 -7
- package/src/components/Form/factory.tsx +0 -31
- package/src/components/deprecated/Form.stories.tsx +0 -62
- package/src/components/deprecated/Form.tsx +0 -119
- package/src/components/deprecated/FormInput.tsx +0 -71
- package/src/components/deprecated/index.ts +0 -5
- package/src/hooks/useForm.ts +0 -291
- package/src/hooks/useQueryRefOptions.ts +0 -53
- package/src/hooks/useRefQueryLookupHandler.ts +0 -39
- package/src/util/schema.ts +0 -14
package/package.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-form",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.937b3ca",
|
|
4
4
|
"description": "Data components.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"type": "module",
|
|
10
14
|
"exports": {
|
|
11
15
|
".": {
|
|
16
|
+
"source": "./src/index.ts",
|
|
12
17
|
"types": "./dist/types/src/index.d.ts",
|
|
13
18
|
"browser": "./dist/lib/browser/index.mjs",
|
|
14
19
|
"node": "./dist/lib/node-esm/index.mjs"
|
|
@@ -23,54 +28,60 @@
|
|
|
23
28
|
"src"
|
|
24
29
|
],
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@atlaskit/pragmatic-drag-and-drop": "
|
|
27
|
-
"@atlaskit/pragmatic-drag-and-drop-hitbox": "
|
|
28
|
-
"@
|
|
31
|
+
"@atlaskit/pragmatic-drag-and-drop": "1.7.7",
|
|
32
|
+
"@atlaskit/pragmatic-drag-and-drop-hitbox": "1.1.0",
|
|
33
|
+
"@effect-atom/atom-react": "^0.4.6",
|
|
34
|
+
"@fluentui/react-tabster": "9.26.11",
|
|
29
35
|
"@radix-ui/react-context": "1.1.1",
|
|
36
|
+
"@radix-ui/react-use-controllable-state": "1.1.0",
|
|
30
37
|
"date-fns": "^3.3.1",
|
|
31
38
|
"jsonpath": "^1.1.1",
|
|
32
|
-
"
|
|
33
|
-
"@dxos/
|
|
34
|
-
"@dxos/
|
|
35
|
-
"@dxos/echo-
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/react-client": "0.8.4-main.
|
|
44
|
-
"@dxos/react-ui-
|
|
45
|
-
"@dxos/react-ui-
|
|
46
|
-
"@dxos/react-ui-
|
|
47
|
-
"@dxos/react-ui-
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
39
|
+
"tabster": "^8.5.5",
|
|
40
|
+
"@dxos/async": "0.8.4-main.937b3ca",
|
|
41
|
+
"@dxos/debug": "0.8.4-main.937b3ca",
|
|
42
|
+
"@dxos/echo-query": "0.8.4-main.937b3ca",
|
|
43
|
+
"@dxos/effect": "0.8.4-main.937b3ca",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.937b3ca",
|
|
45
|
+
"@dxos/echo-react": "0.8.4-main.937b3ca",
|
|
46
|
+
"@dxos/invariant": "0.8.4-main.937b3ca",
|
|
47
|
+
"@dxos/keys": "0.8.4-main.937b3ca",
|
|
48
|
+
"@dxos/log": "0.8.4-main.937b3ca",
|
|
49
|
+
"@dxos/lit-ui": "0.8.4-main.937b3ca",
|
|
50
|
+
"@dxos/react-client": "0.8.4-main.937b3ca",
|
|
51
|
+
"@dxos/react-ui-components": "0.8.4-main.937b3ca",
|
|
52
|
+
"@dxos/react-ui-editor": "0.8.4-main.937b3ca",
|
|
53
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.937b3ca",
|
|
54
|
+
"@dxos/react-ui-pickers": "0.8.4-main.937b3ca",
|
|
55
|
+
"@dxos/react-ui-list": "0.8.4-main.937b3ca",
|
|
56
|
+
"@dxos/react-ui-searchlist": "0.8.4-main.937b3ca",
|
|
57
|
+
"@dxos/react-ui-stack": "0.8.4-main.937b3ca",
|
|
58
|
+
"@dxos/schema": "0.8.4-main.937b3ca",
|
|
59
|
+
"@dxos/types": "0.8.4-main.937b3ca",
|
|
60
|
+
"@dxos/ui-types": "0.8.4-main.937b3ca",
|
|
61
|
+
"@dxos/util": "0.8.4-main.937b3ca"
|
|
51
62
|
},
|
|
52
63
|
"devDependencies": {
|
|
53
64
|
"@types/jsonpath": "^0.2.4",
|
|
54
|
-
"@types/react": "~
|
|
55
|
-
"@types/react-dom": "~
|
|
56
|
-
"effect": "3.
|
|
65
|
+
"@types/react": "~19.2.7",
|
|
66
|
+
"@types/react-dom": "~19.2.3",
|
|
67
|
+
"effect": "3.19.11",
|
|
57
68
|
"fast-check": "^3.19.0",
|
|
58
|
-
"react": "~
|
|
59
|
-
"react-dom": "~
|
|
60
|
-
"vite": "
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
69
|
+
"react": "~19.2.3",
|
|
70
|
+
"react-dom": "~19.2.3",
|
|
71
|
+
"vite": "7.1.9",
|
|
72
|
+
"@dxos/random": "0.8.4-main.937b3ca",
|
|
73
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca",
|
|
74
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.937b3ca",
|
|
75
|
+
"@dxos/storybook-utils": "0.8.4-main.937b3ca",
|
|
76
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca",
|
|
77
|
+
"@dxos/react-client": "0.8.4-main.937b3ca"
|
|
67
78
|
},
|
|
68
79
|
"peerDependencies": {
|
|
69
|
-
"effect": "
|
|
70
|
-
"react": "~
|
|
71
|
-
"react-dom": "~
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/react-ui
|
|
80
|
+
"effect": "3.19.11",
|
|
81
|
+
"react": "~19.2.3",
|
|
82
|
+
"react-dom": "~19.2.3",
|
|
83
|
+
"@dxos/ui-theme": "0.8.4-main.937b3ca",
|
|
84
|
+
"@dxos/react-ui": "0.8.4-main.937b3ca"
|
|
74
85
|
},
|
|
75
86
|
"publishConfig": {
|
|
76
87
|
"access": "public"
|
|
@@ -2,36 +2,33 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
import React from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
11
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
8
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
9
|
|
|
13
|
-
import { ControlPage, ControlSection, type ControlSectionProps } from './ControlSection';
|
|
14
10
|
import { translations } from '../../translations';
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
import { ControlPage, ControlSection } from './ControlSection';
|
|
13
|
+
|
|
14
|
+
const meta = {
|
|
17
15
|
title: 'ui/react-ui-form/ControlSection',
|
|
18
16
|
component: ControlSection,
|
|
19
17
|
render: (args) => (
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
</ControlPage>
|
|
24
|
-
</StackItem.Content>
|
|
18
|
+
<ControlPage classNames='is-[40rem]'>
|
|
19
|
+
<ControlSection {...args} />
|
|
20
|
+
</ControlPage>
|
|
25
21
|
),
|
|
26
|
-
decorators: [
|
|
22
|
+
decorators: [withTheme],
|
|
27
23
|
parameters: {
|
|
24
|
+
layout: 'centered',
|
|
28
25
|
translations,
|
|
29
26
|
},
|
|
30
|
-
}
|
|
27
|
+
} satisfies Meta<typeof ControlSection>;
|
|
31
28
|
|
|
32
29
|
export default meta;
|
|
33
30
|
|
|
34
|
-
type Story = StoryObj<
|
|
31
|
+
type Story = StoryObj<typeof meta>;
|
|
35
32
|
|
|
36
33
|
export const Default: Story = {
|
|
37
34
|
args: {
|
|
@@ -13,17 +13,20 @@ import {
|
|
|
13
13
|
toLocalizedString,
|
|
14
14
|
useTranslation,
|
|
15
15
|
} from '@dxos/react-ui';
|
|
16
|
-
import {
|
|
16
|
+
import { Layout } from '@dxos/react-ui-mosaic';
|
|
17
|
+
import { mx } from '@dxos/ui-theme';
|
|
17
18
|
|
|
18
19
|
import { translationKey } from '../../translations';
|
|
19
20
|
|
|
20
|
-
export type
|
|
21
|
+
export type ControlPageParams = ThemedClassName<ComponentPropsWithoutRef<'div'>>;
|
|
21
22
|
|
|
22
|
-
export const ControlPage = ({ children, classNames, ...props }:
|
|
23
|
+
export const ControlPage = ({ children, classNames, ...props }: ControlPageParams) => {
|
|
23
24
|
return (
|
|
24
|
-
<
|
|
25
|
-
{
|
|
26
|
-
|
|
25
|
+
<Layout.Container scrollable classNames='[--control-spacing:var(--dx-trimMd)]'>
|
|
26
|
+
<div role='none' className={mx('pli-cardSpacingInline pbe-trimMd', classNames)} {...props}>
|
|
27
|
+
{children}
|
|
28
|
+
</div>
|
|
29
|
+
</Layout.Container>
|
|
27
30
|
);
|
|
28
31
|
};
|
|
29
32
|
|
|
@@ -45,7 +48,7 @@ export const ControlSectionHeading = ({ title, description }: Omit<ControlSectio
|
|
|
45
48
|
const { t } = useTranslation(translationKey);
|
|
46
49
|
return (
|
|
47
50
|
<>
|
|
48
|
-
<h2 className='pli-trimMd container-max-width text-xl mbs-
|
|
51
|
+
<h2 className='pli-trimMd container-max-width text-xl mbs-trimMd mbe-trimMd'>{toLocalizedString(title, t)}</h2>
|
|
49
52
|
{description && (
|
|
50
53
|
<p className='pli-trimMd mlb-trimMd container-max-width text-description'>
|
|
51
54
|
{toLocalizedString(description, t)}
|
|
@@ -59,12 +62,16 @@ export const ControlGroupButton = ({ classNames, ...props }: ButtonProps) => {
|
|
|
59
62
|
return <Button {...props} classNames={['md:col-span-2', classNames]} />;
|
|
60
63
|
};
|
|
61
64
|
|
|
62
|
-
export type ControlGroupProps = ThemedClassName<PropsWithChildren
|
|
65
|
+
export type ControlGroupProps = ThemedClassName<PropsWithChildren>;
|
|
63
66
|
|
|
64
67
|
export const ControlGroup = ({ children, classNames }: ControlGroupProps) => (
|
|
65
68
|
<div
|
|
66
69
|
role='none'
|
|
67
|
-
className={mx(
|
|
70
|
+
className={mx(
|
|
71
|
+
'group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd',
|
|
72
|
+
'[--control-spacing:0px] [&_input]:justify-self-end [&_button]:justify-self-end',
|
|
73
|
+
classNames,
|
|
74
|
+
)}
|
|
68
75
|
>
|
|
69
76
|
{children}
|
|
70
77
|
</div>
|
|
@@ -73,23 +80,30 @@ export const ControlGroup = ({ children, classNames }: ControlGroupProps) => (
|
|
|
73
80
|
export const ControlFrame = ({ children }: ControlGroupProps) => (
|
|
74
81
|
<div
|
|
75
82
|
role='none'
|
|
76
|
-
className=
|
|
83
|
+
className={mx(
|
|
84
|
+
'container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd p-trimMd',
|
|
85
|
+
'border border-separator rounded-md',
|
|
86
|
+
)}
|
|
77
87
|
>
|
|
78
88
|
{children}
|
|
79
89
|
</div>
|
|
80
90
|
);
|
|
81
91
|
|
|
92
|
+
export const controlItemClasses = mx([
|
|
93
|
+
'container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center',
|
|
94
|
+
// TODO(burdon): Use grid gap consistently or apply margins consistently?
|
|
95
|
+
'mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd',
|
|
96
|
+
'border border-separator rounded-md',
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
const controlItemTitleClasses = 'mbe-0 text-lg text-baseText font-normal';
|
|
100
|
+
const controlItemDescriptionClasses = 'mlb-trimSm md:mbe-0 text-base text-description';
|
|
101
|
+
|
|
82
102
|
export type ControlItemProps = PropsWithChildren<{
|
|
83
103
|
title: Label;
|
|
84
104
|
description?: Label;
|
|
85
105
|
}>;
|
|
86
106
|
|
|
87
|
-
export const controlItemClasses =
|
|
88
|
-
'pli-trimMd plb-trimMd container-max-width grid md:col-span-2 grid-cols-subgrid items-center gap-trimSm border border-separator rounded-md *:first:!mbs-0 *:last:!mbe-0';
|
|
89
|
-
|
|
90
|
-
const controlItemTitleClasses = 'text-lg font-normal';
|
|
91
|
-
const controlItemDescriptionClasses = 'text-base mlb-trimSm md:mbe-0 text-description';
|
|
92
|
-
|
|
93
107
|
export const ControlItem = ({ title, description, children }: ControlItemProps) => {
|
|
94
108
|
const { t } = useTranslation(translationKey);
|
|
95
109
|
|
|
@@ -2,39 +2,66 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import React, {
|
|
6
|
+
import React, { useEffect, useMemo } from 'react';
|
|
9
7
|
|
|
10
|
-
import {
|
|
8
|
+
import { Filter, Query } from '@dxos/echo';
|
|
9
|
+
import { createEchoSchema } from '@dxos/echo/testing';
|
|
11
10
|
import { log } from '@dxos/log';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
11
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { ProjectionModel, View, createEchoChangeCallback } from '@dxos/schema';
|
|
13
|
+
import { Example } from '@dxos/schema/testing';
|
|
15
14
|
|
|
16
|
-
import { FieldEditor, type FieldEditorProps } from './FieldEditor';
|
|
17
15
|
import { translations } from '../../translations';
|
|
18
|
-
import {
|
|
16
|
+
import { FIELD_EDITOR_DEBUG_SYMBOL, TestLayout } from '../testing';
|
|
17
|
+
|
|
18
|
+
import { FieldEditor, type FieldEditorProps } from './FieldEditor';
|
|
19
19
|
|
|
20
20
|
// Type definition for debug objects exposed to tests.
|
|
21
21
|
export type FieldEditorDebugObjects = {
|
|
22
22
|
props: FieldEditorProps;
|
|
23
|
-
projection:
|
|
23
|
+
projection: ProjectionModel;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// TODO(wittjosiah): ECHO objects don't work when passed via Storybook args.
|
|
27
|
+
const useTestProjection = () => {
|
|
28
|
+
return useMemo(() => {
|
|
29
|
+
const schema = createEchoSchema(Example);
|
|
30
|
+
const view = View.make({
|
|
31
|
+
name: 'Test',
|
|
32
|
+
query: Query.select(Filter.type(Example)),
|
|
33
|
+
jsonSchema: schema.jsonSchema,
|
|
34
|
+
});
|
|
35
|
+
const projection = new ProjectionModel({
|
|
36
|
+
view,
|
|
37
|
+
baseSchema: schema.jsonSchema,
|
|
38
|
+
change: createEchoChangeCallback(view, schema),
|
|
39
|
+
});
|
|
40
|
+
projection.normalizeView();
|
|
41
|
+
return { view, projection };
|
|
42
|
+
}, []);
|
|
24
43
|
};
|
|
25
44
|
|
|
26
|
-
|
|
45
|
+
const DefaultStory = () => {
|
|
46
|
+
const { view, projection } = useTestProjection();
|
|
27
47
|
|
|
28
|
-
const DefaultStory = (props: FieldEditorProps) => {
|
|
29
|
-
const projection = useMemo(() => new ViewProjection(createEchoSchema(TestSchema).jsonSchema, testView), []);
|
|
30
48
|
const handleComplete: FieldEditorProps['onSave'] = () => {
|
|
31
|
-
log.info('onClose'
|
|
49
|
+
log.info('onClose');
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const props: FieldEditorProps = {
|
|
53
|
+
projection,
|
|
54
|
+
field: view.projection.fields[0],
|
|
55
|
+
onSave: handleComplete,
|
|
32
56
|
};
|
|
33
57
|
|
|
34
58
|
// Expose objects on window for test access.
|
|
35
59
|
useEffect(() => {
|
|
36
60
|
if (typeof window !== 'undefined') {
|
|
37
|
-
(window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = {
|
|
61
|
+
(window as any)[FIELD_EDITOR_DEBUG_SYMBOL] = {
|
|
62
|
+
props,
|
|
63
|
+
projection,
|
|
64
|
+
} satisfies FieldEditorDebugObjects;
|
|
38
65
|
}
|
|
39
66
|
}, [props, projection]);
|
|
40
67
|
|
|
@@ -46,31 +73,27 @@ const DefaultStory = (props: FieldEditorProps) => {
|
|
|
46
73
|
|
|
47
74
|
return (
|
|
48
75
|
<TestLayout json={json}>
|
|
49
|
-
<
|
|
50
|
-
<FieldEditor {...props} projection={projection} onSave={handleComplete} />
|
|
51
|
-
</TestPanel>
|
|
76
|
+
<FieldEditor {...props} />
|
|
52
77
|
</TestLayout>
|
|
53
78
|
);
|
|
54
79
|
};
|
|
55
80
|
|
|
56
|
-
const meta
|
|
81
|
+
const meta = {
|
|
57
82
|
title: 'ui/react-ui-form/FieldEditor',
|
|
58
|
-
component: FieldEditor,
|
|
83
|
+
component: FieldEditor as any,
|
|
59
84
|
render: DefaultStory,
|
|
60
|
-
decorators: [
|
|
85
|
+
decorators: [withTheme],
|
|
61
86
|
parameters: {
|
|
87
|
+
layout: 'fullscreen',
|
|
62
88
|
translations,
|
|
89
|
+
controls: {
|
|
90
|
+
disabled: true,
|
|
91
|
+
},
|
|
63
92
|
},
|
|
64
|
-
}
|
|
93
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
65
94
|
|
|
66
95
|
export default meta;
|
|
67
96
|
|
|
68
|
-
type Story = StoryObj<
|
|
97
|
+
type Story = StoryObj<typeof meta>;
|
|
69
98
|
|
|
70
|
-
export const Default: Story = {
|
|
71
|
-
args: {
|
|
72
|
-
view: testView,
|
|
73
|
-
field: testView.fields[0],
|
|
74
|
-
},
|
|
75
|
-
parameters: { controls: { disabled: true } },
|
|
76
|
-
};
|
|
99
|
+
export const Default: Story = {};
|
|
@@ -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
|
+
};
|