@dxos/react-ui-form 0.8.4-main.d05539e30a → 0.8.4-main.d9fc60f731
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 +1335 -561
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +2 -1
- package/dist/lib/browser/translations.mjs.map +2 -2
- package/dist/lib/node-esm/index.mjs +1335 -561
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +2 -1
- package/dist/lib/node-esm/translations.mjs.map +2 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +2 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +35 -9
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +76 -16
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +14 -4
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +22 -10
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +8 -2
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts +19 -0
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts +50 -0
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts +119 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/annotation.d.ts +30 -0
- package/dist/types/src/components/Form/Layout/annotation.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/index.d.ts +4 -0
- package/dist/types/src/components/Form/Layout/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/parser.d.ts +31 -0
- package/dist/types/src/components/Form/Layout/parser.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/parser.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/DateField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/DateField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts +13 -0
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +2 -1
- package/dist/types/src/components/Form/fields/MarkdownField.stories.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/Form/fields/SelectField.d.ts +4 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +2 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TupleField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/index.d.ts +2 -0
- package/dist/types/src/components/Form/fields/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts +3 -0
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/meta-tags.d.ts +30 -0
- package/dist/types/src/components/Form/meta-tags.d.ts.map +1 -0
- package/dist/types/src/components/Form/meta-tags.test.d.ts +2 -0
- package/dist/types/src/components/Form/meta-tags.test.d.ts.map +1 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +3 -4
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +2 -2
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +2 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +2 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectTree/ObjectTree.d.ts +9 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.d.ts.map +1 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +87 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectTree/index.d.ts +2 -0
- package/dist/types/src/components/ObjectTree/index.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/Settings.stories.d.ts +2 -1
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +7 -8
- 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/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +9 -0
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/properties.d.ts +11 -0
- package/dist/types/src/util/properties.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -32
- package/src/components/FieldEditor/FieldEditor.stories.tsx +2 -2
- package/src/components/FieldEditor/FieldEditor.test.tsx +4 -1
- package/src/components/FieldEditor/FieldEditor.tsx +19 -14
- package/src/components/Form/Form.stories.tsx +21 -27
- package/src/components/Form/Form.tsx +106 -19
- package/src/components/Form/FormField.tsx +85 -28
- package/src/components/Form/FormFieldComponent.tsx +75 -20
- package/src/components/Form/FormFieldSet.tsx +32 -3
- package/src/components/Form/FormTooltipsContext.ts +25 -0
- package/src/components/Form/Layout/FormLayout.stories.test.tsx +51 -0
- package/src/components/Form/Layout/FormLayout.stories.tsx +422 -0
- package/src/components/Form/Layout/FormLayout.test.ts +59 -0
- package/src/components/Form/Layout/FormLayout.tsx +251 -0
- package/src/components/Form/Layout/annotation.ts +38 -0
- package/src/components/Form/Layout/index.ts +7 -0
- package/src/components/Form/Layout/parser.test.ts +120 -0
- package/src/components/Form/Layout/parser.ts +167 -0
- package/src/components/Form/fields/ArrayField.tsx +61 -38
- package/src/components/Form/fields/DateField.tsx +101 -0
- package/src/components/Form/fields/GeoPointField.tsx +4 -1
- package/src/components/Form/fields/InlineRefField.tsx +146 -0
- package/src/components/Form/fields/MarkdownField.tsx +3 -3
- package/src/components/Form/fields/RefField.tsx +29 -23
- package/src/components/Form/fields/SelectField.tsx +17 -5
- package/src/components/Form/fields/SelectOptionField.tsx +4 -3
- package/src/components/Form/fields/TextAreaField.tsx +1 -1
- package/src/components/Form/fields/TupleField.tsx +2 -1
- package/src/components/Form/fields/index.ts +2 -0
- package/src/components/Form/index.ts +3 -0
- package/src/components/Form/meta-tags.test.ts +47 -0
- package/src/components/Form/meta-tags.ts +33 -0
- package/src/components/ObjectForm/ObjectForm.tsx +21 -26
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +2 -2
- package/src/components/ObjectPicker/ObjectPicker.tsx +2 -2
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +14 -26
- package/src/components/ObjectProperties/ObjectProperties.test.tsx +20 -10
- package/src/components/ObjectProperties/ObjectProperties.tsx +26 -30
- package/src/components/ObjectTree/ObjectTree.stories.tsx +134 -0
- package/src/components/ObjectTree/ObjectTree.tsx +190 -0
- package/src/components/ObjectTree/index.ts +5 -0
- package/src/components/Settings/Settings.tsx +2 -1
- package/src/components/Settings/SettingsItem.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +35 -40
- package/src/components/ViewEditor/ViewEditor.test.tsx +11 -8
- package/src/components/ViewEditor/ViewEditor.tsx +29 -32
- package/src/components/index.ts +1 -0
- package/src/components/testing.tsx +4 -4
- package/src/translations.ts +2 -1
- package/src/util/properties.test.ts +67 -9
- package/src/util/properties.ts +36 -4
- package/src/vite-env.d.ts +10 -0
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { type StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import * as Schema from 'effect/Schema';
|
|
3
3
|
import React from 'react';
|
|
4
|
-
import { Type } from '@dxos/echo';
|
|
4
|
+
import { Obj, Type } from '@dxos/echo';
|
|
5
5
|
import { type AnyProperties } from '@dxos/echo/internal';
|
|
6
6
|
import { type ExcludeId, type FormRootProps } from './Form';
|
|
7
7
|
declare const Organization: Type.Obj<{
|
|
8
8
|
readonly name: string;
|
|
9
9
|
}, Schema.Struct.Fields>;
|
|
10
|
-
export
|
|
11
|
-
}
|
|
10
|
+
export type Organization = Type.InstanceType<typeof Organization>;
|
|
12
11
|
declare const Person: Type.Obj<{
|
|
13
12
|
readonly name: string;
|
|
14
13
|
readonly ignore?: string | undefined;
|
|
@@ -19,16 +18,19 @@ declare const Person: Type.Obj<{
|
|
|
19
18
|
readonly state: string;
|
|
20
19
|
readonly zip: number;
|
|
21
20
|
} | undefined;
|
|
22
|
-
readonly employer?: import("@dxos/echo/internal").Ref<
|
|
21
|
+
readonly employer?: import("@dxos/echo/internal").Ref<{
|
|
23
22
|
readonly name: string;
|
|
24
|
-
}> | undefined;
|
|
25
|
-
readonly tags?: readonly import("@dxos/echo/internal").Ref<
|
|
23
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
|
|
24
|
+
readonly tags?: readonly import("@dxos/echo/internal").Ref<{
|
|
26
25
|
readonly label: string;
|
|
27
26
|
readonly hue?: string | undefined;
|
|
28
|
-
}>[] | undefined;
|
|
27
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
|
|
29
28
|
readonly status?: "active" | "inactive" | undefined;
|
|
30
29
|
readonly notes?: string | undefined;
|
|
31
30
|
readonly location?: readonly [number, number, (number | undefined)?] | undefined;
|
|
31
|
+
readonly birthday?: string | undefined;
|
|
32
|
+
readonly meetingAt?: string | undefined;
|
|
33
|
+
readonly reminderAt?: string | undefined;
|
|
32
34
|
readonly tasks?: readonly string[] | undefined;
|
|
33
35
|
readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
|
|
34
36
|
readonly identities?: readonly {
|
|
@@ -36,11 +38,9 @@ declare const Person: Type.Obj<{
|
|
|
36
38
|
readonly value: string;
|
|
37
39
|
}[] | undefined;
|
|
38
40
|
}, Schema.Struct.Fields>;
|
|
39
|
-
export
|
|
40
|
-
}
|
|
41
|
+
export type Person = Type.InstanceType<typeof Person>;
|
|
41
42
|
type DefaultStoryProps<T extends AnyProperties> = {
|
|
42
43
|
schema?: Schema.Schema<T>;
|
|
43
|
-
debug?: boolean;
|
|
44
44
|
} & FormRootProps<T>;
|
|
45
45
|
declare const meta: {
|
|
46
46
|
title: string;
|
|
@@ -48,7 +48,7 @@ declare const meta: {
|
|
|
48
48
|
<T extends AnyProperties = AnyProperties>({ children, schema, values, onSave, onCancel, ...props }: FormRootProps<T>): React.JSX.Element;
|
|
49
49
|
displayName: string;
|
|
50
50
|
};
|
|
51
|
-
render: <T extends AnyProperties = AnyProperties>({
|
|
51
|
+
render: <T extends AnyProperties = AnyProperties>({ schema, values: valuesProp, ...props }: DefaultStoryProps<T>) => React.JSX.Element;
|
|
52
52
|
decorators: import("@storybook/react").Decorator[];
|
|
53
53
|
parameters: {
|
|
54
54
|
layout: string;
|
|
@@ -62,6 +62,7 @@ declare const meta: {
|
|
|
62
62
|
readonly 'field-property.placeholder': 'Property name';
|
|
63
63
|
readonly 'field-format.label': 'Type';
|
|
64
64
|
readonly 'field-path.label': 'Field path';
|
|
65
|
+
readonly 'remove-item.button': 'Delete item';
|
|
65
66
|
readonly 'add-item.button': 'Add item';
|
|
66
67
|
readonly 'add-property-button.label': 'Add property';
|
|
67
68
|
readonly 'boolean-input-true.value': 'Yes';
|
|
@@ -117,7 +118,7 @@ declare const meta: {
|
|
|
117
118
|
readonly 'select-option-add.button': 'Add option';
|
|
118
119
|
readonly 'system-schema.title': 'System type';
|
|
119
120
|
readonly 'system-schema.description': 'System type: cannot add or remove fields.';
|
|
120
|
-
readonly 'remove.button': '
|
|
121
|
+
readonly 'remove.button': 'Delete';
|
|
121
122
|
};
|
|
122
123
|
};
|
|
123
124
|
}];
|
|
@@ -125,8 +126,67 @@ declare const meta: {
|
|
|
125
126
|
};
|
|
126
127
|
export default meta;
|
|
127
128
|
type Story<T extends AnyProperties> = StoryObj<DefaultStoryProps<T>>;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
declare const PersonSchema: Schema.Schema<{
|
|
130
|
+
readonly name: string;
|
|
131
|
+
readonly ignore?: string | undefined;
|
|
132
|
+
readonly active?: boolean | undefined;
|
|
133
|
+
readonly address?: {
|
|
134
|
+
readonly street: string;
|
|
135
|
+
readonly city: string;
|
|
136
|
+
readonly state: string;
|
|
137
|
+
readonly zip: number;
|
|
138
|
+
} | undefined;
|
|
139
|
+
readonly employer?: import("@dxos/echo/internal").Ref<{
|
|
140
|
+
readonly name: string;
|
|
141
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
|
|
142
|
+
readonly tags?: readonly import("@dxos/echo/internal").Ref<{
|
|
143
|
+
readonly label: string;
|
|
144
|
+
readonly hue?: string | undefined;
|
|
145
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
|
|
146
|
+
readonly status?: "active" | "inactive" | undefined;
|
|
147
|
+
readonly notes?: string | undefined;
|
|
148
|
+
readonly location?: readonly [number, number, (number | undefined)?] | undefined;
|
|
149
|
+
readonly birthday?: string | undefined;
|
|
150
|
+
readonly meetingAt?: string | undefined;
|
|
151
|
+
readonly reminderAt?: string | undefined;
|
|
152
|
+
readonly tasks?: readonly string[] | undefined;
|
|
153
|
+
readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
|
|
154
|
+
readonly identities?: readonly {
|
|
155
|
+
readonly type: string;
|
|
156
|
+
readonly value: string;
|
|
157
|
+
}[] | undefined;
|
|
158
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>, {
|
|
159
|
+
readonly name: string;
|
|
160
|
+
readonly ignore?: string | undefined;
|
|
161
|
+
readonly active?: boolean | undefined;
|
|
162
|
+
readonly address?: {
|
|
163
|
+
readonly street: string;
|
|
164
|
+
readonly city: string;
|
|
165
|
+
readonly state: string;
|
|
166
|
+
readonly zip: number;
|
|
167
|
+
} | undefined;
|
|
168
|
+
readonly employer?: import("@dxos/echo/internal").Ref<{
|
|
169
|
+
readonly name: string;
|
|
170
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown> | undefined;
|
|
171
|
+
readonly tags?: readonly import("@dxos/echo/internal").Ref<{
|
|
172
|
+
readonly label: string;
|
|
173
|
+
readonly hue?: string | undefined;
|
|
174
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object> & Obj.Unknown>[] | undefined;
|
|
175
|
+
readonly status?: "active" | "inactive" | undefined;
|
|
176
|
+
readonly notes?: string | undefined;
|
|
177
|
+
readonly location?: readonly [number, number, (number | undefined)?] | undefined;
|
|
178
|
+
readonly birthday?: string | undefined;
|
|
179
|
+
readonly meetingAt?: string | undefined;
|
|
180
|
+
readonly reminderAt?: string | undefined;
|
|
181
|
+
readonly tasks?: readonly string[] | undefined;
|
|
182
|
+
readonly locations?: readonly (readonly [number, number, (number | undefined)?])[] | undefined;
|
|
183
|
+
readonly identities?: readonly {
|
|
184
|
+
readonly type: string;
|
|
185
|
+
readonly value: string;
|
|
186
|
+
}[] | undefined;
|
|
187
|
+
} & import("@dxos/echo/Entity").OfKind<import("@dxos/echo/internal").EntityKind.Object>, never>;
|
|
188
|
+
export declare const Default: Story<ExcludeId<typeof PersonSchema>>;
|
|
189
|
+
export declare const Readonly: Story<ExcludeId<typeof PersonSchema>>;
|
|
190
|
+
export declare const Static: Story<ExcludeId<typeof PersonSchema>>;
|
|
191
|
+
export declare const Empty: Story<ExcludeId<typeof PersonSchema>>;
|
|
132
192
|
//# sourceMappingURL=Form.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Form.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAgC,MAAM,OAAO,CAAC;AAErD,OAAO,
|
|
1
|
+
{"version":3,"file":"Form.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/Form.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAgC,MAAM,OAAO,CAAC;AAErD,OAAO,EAA2B,GAAG,EAAY,IAAI,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAUzD,OAAO,EAAE,KAAK,SAAS,EAAQ,KAAK,aAAa,EAAU,MAAM,QAAQ,CAAC;AAE1E,QAAA,MAAM,YAAY;;wBAE0D,CAAC;AAE7E,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,YAAY,CAAC,CAAC;AAElE,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAoCuD,CAAC;AAEpE,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC;AAEtD,KAAK,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI;IAChD,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAC3B,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAgDrB,QAAA,MAAM,IAAI;;;;;;aA9CY,CAAC,SAAS,aAAa,4DAI1C,iBAAiB,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEiB,CAAC;eAE1B,IAAI;AAEnB,KAAK,KAAK,CAAC,CAAC,SAAS,aAAa,IAAI,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+FAAyB,CAAC;AAW5C,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAMzD,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAM1D,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAMxD,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,YAAY,CAAC,CAEvD,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as SchemaAST from 'effect/SchemaAST';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { PropsWithChildren } from 'react';
|
|
3
|
+
import { IconButtonProps } from '@dxos/react-ui';
|
|
3
4
|
import { type ProjectionModel } from '@dxos/schema';
|
|
4
5
|
import { type RefFieldProps } from './fields';
|
|
5
6
|
import { type FormFieldComponentProps, type FormFieldMap, type FormFieldProvider } from './FormFieldComponent';
|
|
@@ -9,9 +10,14 @@ export type FormFieldProps = {
|
|
|
9
10
|
*/
|
|
10
11
|
type: SchemaAST.AST;
|
|
11
12
|
/**
|
|
12
|
-
* Name of the property.
|
|
13
|
+
* Name of the property. Used to derive a default label
|
|
14
|
+
* (`title ?? capitalize(name)`) and as the projection lookup key. Pass
|
|
15
|
+
* `null` to suppress the header label entirely -- the form still renders
|
|
16
|
+
* the field/struct, but `FormFieldSet`'s top-level `<FormFieldLabel>` is
|
|
17
|
+
* skipped. Used by `ArrayField` for object-array items, where every item
|
|
18
|
+
* would otherwise repeat the array's parent name.
|
|
13
19
|
*/
|
|
14
|
-
name: string;
|
|
20
|
+
name: string | null;
|
|
15
21
|
/**
|
|
16
22
|
* Path to the current object from the root. Used with nested forms.
|
|
17
23
|
*/
|
|
@@ -35,9 +41,13 @@ export type FormFieldProps = {
|
|
|
35
41
|
* are only passed to ref fields whose typename matches.
|
|
36
42
|
*/
|
|
37
43
|
createTypename?: string;
|
|
38
|
-
} & Pick<FormFieldComponentProps, 'autoFocus' | 'readonly' | 'layout'> & Pick<RefFieldProps, 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap' | 'db' | '
|
|
44
|
+
} & Pick<FormFieldComponentProps, 'autoFocus' | 'readonly' | 'layout'> & Pick<RefFieldProps, 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap' | 'db' | 'useType' | 'getOptions' | 'onCreate'>;
|
|
39
45
|
export declare function FormField(props: FormFieldProps): React.JSX.Element | null;
|
|
40
46
|
export declare namespace FormField {
|
|
41
47
|
var displayName: string;
|
|
42
48
|
}
|
|
49
|
+
export declare const Nesting: ({ children }: PropsWithChildren) => React.JSX.Element;
|
|
50
|
+
export declare const IconBlock: ({ inline, ...props }: IconButtonProps & {
|
|
51
|
+
inline?: boolean;
|
|
52
|
+
}) => React.JSX.Element;
|
|
43
53
|
//# sourceMappingURL=FormField.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormField.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAE9C,OAAO,
|
|
1
|
+
{"version":3,"file":"FormField.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormField.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAAK,EAAE,EA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
|
3
3
|
import React, { Component, type FC, type FocusEvent, type PropsWithChildren, type ReactElement, type ReactNode } from 'react';
|
|
4
|
-
import { type Database } from '@dxos/echo';
|
|
5
|
-
import { type Format } from '@dxos/echo/internal';
|
|
4
|
+
import { type Database, Format } from '@dxos/echo';
|
|
6
5
|
import { type FormFieldStatus } from '../../hooks';
|
|
7
6
|
/**
|
|
8
7
|
* Dynamic props passed to input components.
|
|
@@ -25,35 +24,48 @@ export type Presentation = 'full' | 'compact' | 'inline' | 'static';
|
|
|
25
24
|
* Props passed to input components.
|
|
26
25
|
*/
|
|
27
26
|
export type FormFieldComponentProps<T = any> = {
|
|
27
|
+
/** Database the form is editing against; populated for fields whose value is an ECHO object/Ref. */
|
|
28
|
+
db?: Database.Database;
|
|
28
29
|
type: SchemaAST.AST;
|
|
29
30
|
format?: Format.TypeFormat;
|
|
30
31
|
readonly?: boolean;
|
|
31
32
|
label: string;
|
|
33
|
+
/**
|
|
34
|
+
* Dotted JSON path of this field within the form values (e.g.
|
|
35
|
+
* `runtime.client.storage.persistent`). Forwarded to `FormFieldLabel` so
|
|
36
|
+
* that it can render the path as a debug hint when the enclosing
|
|
37
|
+
* `Form.Root` has `debug` enabled.
|
|
38
|
+
*/
|
|
39
|
+
jsonPath?: string;
|
|
32
40
|
placeholder?: string;
|
|
33
41
|
autoFocus?: boolean;
|
|
34
42
|
layout?: Presentation;
|
|
35
|
-
/** Database the form is editing against; populated for fields whose value is an ECHO object/Ref. */
|
|
36
|
-
db?: Database.Database;
|
|
37
43
|
} & FormFieldStateProps<T>;
|
|
38
|
-
/**
|
|
39
|
-
* Form field component.
|
|
40
|
-
*/
|
|
41
44
|
export type FormFieldComponent = FC<FormFieldComponentProps>;
|
|
42
45
|
export type FormFieldMap = Record<string, FormFieldComponent>;
|
|
43
46
|
export type FormFieldProvider = (props: {
|
|
44
47
|
prop: string;
|
|
45
48
|
schema: Schema.Schema<any>;
|
|
46
49
|
fieldProps: FormFieldComponentProps;
|
|
47
|
-
}) => ReactElement | undefined;
|
|
50
|
+
}) => ReactElement | null | undefined;
|
|
48
51
|
export type FormFieldLabelProps = {
|
|
49
52
|
asChild?: boolean;
|
|
50
53
|
error?: string;
|
|
54
|
+
/**
|
|
55
|
+
* JSON path of the field this label describes (e.g. `runtime.client.storage.persistent`).
|
|
56
|
+
* Surfaced as a hover tooltip on the label when the enclosing `Form.Root`
|
|
57
|
+
* has `tooltips` enabled (the default) -- useful for spotting which field
|
|
58
|
+
* maps to which path when authoring schemas or filing bugs against a form.
|
|
59
|
+
* Callers can supply the path unconditionally; the label suppresses the
|
|
60
|
+
* tooltip when `Form.Root tooltips={false}`.
|
|
61
|
+
*/
|
|
62
|
+
path?: string;
|
|
51
63
|
} & Pick<FormFieldComponentProps, 'label' | 'readonly'>;
|
|
52
|
-
export declare function FormFieldLabel({ label, error, readonly, asChild }: FormFieldLabelProps): React.JSX.Element;
|
|
64
|
+
export declare function FormFieldLabel({ label, error, readonly, asChild, path }: FormFieldLabelProps): React.JSX.Element;
|
|
53
65
|
export declare namespace FormFieldLabel {
|
|
54
66
|
var displayName: string;
|
|
55
67
|
}
|
|
56
|
-
export type FormFieldWrapperProps<T = any> = Pick<FormFieldComponentProps, 'readonly' | 'label' | 'layout' | 'getStatus' | 'getValue'> & {
|
|
68
|
+
export type FormFieldWrapperProps<T = any> = Pick<FormFieldComponentProps, 'readonly' | 'label' | 'layout' | 'getStatus' | 'getValue' | 'jsonPath' | 'format'> & {
|
|
57
69
|
children?: (props: {
|
|
58
70
|
value: T;
|
|
59
71
|
}) => ReactNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldComponent.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormFieldComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormFieldComponent.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormFieldComponent.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe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I,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC5B,CAAC,CAAC;AAEH,qBAAa,sBAAuB,SAAQ,SAAS,CAAC,2BAA2B,EAAE,mBAAmB,CAAC;IACrG,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,CAE9D;IAEQ,KAAK;QAAK,KAAK;MAAc;IAE7B,kBAAkB,CAAC,SAAS,EAAE,2BAA2B,QAIjE;IAEQ,MAAM,kRAWd;IAED,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -7,8 +7,14 @@ export type FormFieldSetProps<T extends AnyProperties> = {
|
|
|
7
7
|
label?: string;
|
|
8
8
|
sort?: string[];
|
|
9
9
|
exclude?: (props: SchemaProperty[]) => SchemaProperty[];
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Picks a named layout out of `FormLayoutAnnotation` when present.
|
|
12
|
+
* Falls back to `'default'`. Ignored when the schema has no annotation
|
|
13
|
+
* (linear rendering then takes over).
|
|
14
|
+
*/
|
|
15
|
+
layoutName?: string;
|
|
16
|
+
} & Pick<FormHandlerProps<T>, 'schema'> & Pick<FormFieldProps, 'path' | 'autoFocus' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider' | 'createTypename' | 'createOptionLabel' | 'createOptionIcon' | 'createInitialValuePath' | 'createFieldMap' | 'db' | 'useType' | 'getOptions' | 'onCreate'>;
|
|
17
|
+
export declare function FormFieldSet({ label, schema, readonly, path, sort, exclude, projection, layout, layoutName, ...props }: FormFieldSetProps<any>): React.JSX.Element | null;
|
|
12
18
|
export declare namespace FormFieldSet {
|
|
13
19
|
var displayName: string;
|
|
14
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormFieldSet.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormFieldSet.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FormFieldSet.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormFieldSet.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGpD,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAM7D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,aAAa,IAAI;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,CAAC;IACxD;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GACrC,IAAI,CACF,cAAc,EACZ,MAAM,GACN,WAAW,GACX,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,GAClB,wBAAwB,GACxB,gBAAgB,GAChB,IAAI,GACJ,SAAS,GACT,YAAY,GACZ,UAAU,CACb,CAAC;qCAKyB,EAC3B,KAAK,EACL,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,EACV,MAAM,EACN,UAAgC,EAChC,GAAG,KAAK,EACT,EAAE,iBAAiB,CAAC,GAAG,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A standalone context for the `tooltips` flag (Form.Root's only label
|
|
3
|
+
* decoration today: a JSON-path hover tooltip rendered by
|
|
4
|
+
* `FormFieldLabel`).
|
|
5
|
+
*
|
|
6
|
+
* Lives in its own module so that `FormFieldComponent.tsx` -- imported at
|
|
7
|
+
* the top of `Form.tsx` -- can read the flag without re-importing from
|
|
8
|
+
* `Form.tsx`. That round-trip used to create a circular module-eval
|
|
9
|
+
* dependency that intermittently hit a TDZ ("Cannot access 'FormFieldLabel'
|
|
10
|
+
* before initialization") in browser-mode storybook tests.
|
|
11
|
+
*
|
|
12
|
+
* Defaults to `true` both when `Form.Root` doesn't pass an explicit value
|
|
13
|
+
* AND when there is no enclosing `Form.Root` (e.g. `FormFieldWrapper`
|
|
14
|
+
* stories that render an input without a Form provider).
|
|
15
|
+
*/
|
|
16
|
+
export declare const FormTooltipsContext: import("react").Context<boolean>;
|
|
17
|
+
/** Returns whether the enclosing `Form.Root` has field tooltips enabled. */
|
|
18
|
+
export declare const useFormTooltips: () => boolean;
|
|
19
|
+
//# sourceMappingURL=FormTooltipsContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormTooltipsContext.d.ts","sourceRoot":"","sources":["../../../../../src/components/Form/FormTooltipsContext.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mBAAmB,kCAA+B,CAAC;AAEhE,4EAA4E;AAC5E,eAAO,MAAM,eAAe,QAAO,OAA0C,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as Schema from 'effect/Schema';
|
|
2
|
+
import * as SchemaAST from 'effect/SchemaAST';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { type AnyProperties } from '@dxos/echo/internal';
|
|
5
|
+
import { type FormFieldProps } from '../FormField';
|
|
6
|
+
export type FormLayoutProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Template string in the FormLayout DSL (`<grid cols=…><field name=…/></grid>`).
|
|
9
|
+
* If omitted, the layout is read from the schema's `FormLayoutAnnotation` —
|
|
10
|
+
* the entry named by `name` (default: `'default'`).
|
|
11
|
+
*/
|
|
12
|
+
template?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Picks a named layout out of `FormLayoutAnnotation`'s map when no
|
|
15
|
+
* explicit `template` is supplied. Defaults to `'default'`.
|
|
16
|
+
*/
|
|
17
|
+
name?: string;
|
|
18
|
+
} & Pick<FormFieldSetSubset, 'schema' | 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'>;
|
|
19
|
+
type FormFieldSetSubset = Pick<FormFieldProps, 'path' | 'readonly' | 'layout' | 'projection' | 'fieldMap' | 'fieldProvider'> & {
|
|
20
|
+
schema: Schema.Schema<AnyProperties>;
|
|
21
|
+
};
|
|
22
|
+
export declare function FormLayout({ schema, template, name, path, readonly, layout, projection, ...props }: FormLayoutProps): React.JSX.Element;
|
|
23
|
+
export declare namespace FormLayout {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export type ResolvedLayoutField = {
|
|
27
|
+
/** Resolved leaf AST node for the field. */
|
|
28
|
+
type: SchemaAST.AST;
|
|
29
|
+
/** Path segments (dotted names split on `.`). */
|
|
30
|
+
segments: string[];
|
|
31
|
+
/** Last path segment; used to derive the field label when there is no `title` annotation. */
|
|
32
|
+
leafName: string;
|
|
33
|
+
/** Resolved `title` annotation for the field, if any. */
|
|
34
|
+
title?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Set when the field resolves to a nested struct carrying a `LabelAnnotation` —
|
|
37
|
+
* the type literal whose computed label should render in place of the struct's
|
|
38
|
+
* sub-fields. Undefined for ordinary (non-auto-labelled) fields.
|
|
39
|
+
*/
|
|
40
|
+
labelType?: SchemaAST.AST;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Resolves a (possibly dotted) layout field name against a schema.
|
|
44
|
+
* - `origin.code` drills through nested structs to the leaf field.
|
|
45
|
+
* - A name resolving to a nested struct with a `LabelAnnotation` is flagged via
|
|
46
|
+
* `labelType` so the layout can auto-convert it to a single read-only label.
|
|
47
|
+
* Returns `undefined` when the name does not resolve to a property.
|
|
48
|
+
*/
|
|
49
|
+
export declare const resolveLayoutField: (schema: Schema.Schema<any>, name: string) => ResolvedLayoutField | undefined;
|
|
50
|
+
//# sourceMappingURL=FormLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/FormLayout.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAC;AAE9C,OAAO,KAA4B,MAAM,OAAO,CAAC;AAGjD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD,OAAO,EAAa,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAO9D,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAAC,kBAAkB,EAAE,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,CAAC,CAAC;AAEtH,KAAK,kBAAkB,GAAG,IAAI,CAC5B,cAAc,EACd,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,CAC7E,GAAG;IACF,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;CACtC,CAAC;mCAcyB,EACzB,MAAM,EACN,QAAQ,EACR,IAA0B,EAC1B,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,UAAU,EACV,GAAG,KAAK,EACT,EAAE,eAAe;;;;AAyElB,MAAM,MAAM,mBAAmB,GAAG;IAChC,4CAA4C;IAC5C,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC;IACpB,iDAAiD;IACjD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,6FAA6F;IAC7F,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC,GAAG,CAAC;CAC3B,CAAC;AA4BF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,WAAY,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,MAAM,KAAG,mBAAmB,GAAG,SA8BnG,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import * as Schema from 'effect/Schema';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { Type } from '@dxos/echo';
|
|
5
|
+
/**
|
|
6
|
+
* Sample schema: a Flight booking carries airline, flight number, route, dates,
|
|
7
|
+
* cabin class. Without an annotation `<Form.FieldSet/>` renders one field per
|
|
8
|
+
* row (see the `Linear` story). The `FormLayoutAnnotation` on this schema
|
|
9
|
+
* arranges the same fields in a 2-column grid with selective spans.
|
|
10
|
+
*/
|
|
11
|
+
declare const Flight: Type.Obj<{
|
|
12
|
+
readonly airline?: string | undefined;
|
|
13
|
+
readonly flightNumber?: string | undefined;
|
|
14
|
+
readonly origin?: string | undefined;
|
|
15
|
+
readonly destination?: string | undefined;
|
|
16
|
+
readonly departAt?: string | undefined;
|
|
17
|
+
readonly arriveAt?: string | undefined;
|
|
18
|
+
readonly cabin?: "business" | "economy" | "first" | "premium" | undefined;
|
|
19
|
+
readonly notes?: string | undefined;
|
|
20
|
+
}, Schema.Struct.Fields>;
|
|
21
|
+
export type Flight = Type.InstanceType<typeof Flight>;
|
|
22
|
+
type StoryProps = {
|
|
23
|
+
schema: Schema.Schema<any>;
|
|
24
|
+
template?: string;
|
|
25
|
+
};
|
|
26
|
+
declare const meta: {
|
|
27
|
+
title: string;
|
|
28
|
+
render: ({ schema, template }: StoryProps) => React.JSX.Element;
|
|
29
|
+
decorators: import("@storybook/react").Decorator[];
|
|
30
|
+
parameters: {
|
|
31
|
+
layout: string;
|
|
32
|
+
translations: [{
|
|
33
|
+
readonly 'en-US': {
|
|
34
|
+
readonly "@dxos/react-ui-form": {
|
|
35
|
+
readonly 'fields.label': 'Fields';
|
|
36
|
+
readonly 'hidden-fields.label': 'Hidden Fields';
|
|
37
|
+
readonly 'empty-readonly-ref-field.label': '(none)';
|
|
38
|
+
readonly 'field-property.label': 'Property';
|
|
39
|
+
readonly 'field-property.placeholder': 'Property name';
|
|
40
|
+
readonly 'field-format.label': 'Type';
|
|
41
|
+
readonly 'field-path.label': 'Field path';
|
|
42
|
+
readonly 'remove-item.button': 'Delete item';
|
|
43
|
+
readonly 'add-item.button': 'Add item';
|
|
44
|
+
readonly 'add-property-button.label': 'Add property';
|
|
45
|
+
readonly 'boolean-input-true.value': 'Yes';
|
|
46
|
+
readonly 'boolean-input-false.value': 'No';
|
|
47
|
+
readonly 'show-field.label': 'Show field';
|
|
48
|
+
readonly 'hide-field.label': 'Hide field';
|
|
49
|
+
readonly 'delete-field.label': 'Delete field';
|
|
50
|
+
readonly 'create-option.label': 'Create';
|
|
51
|
+
readonly 'add-tag.label': 'Add tag';
|
|
52
|
+
readonly 'ref-field-combobox-input.placeholder': 'Search\u2026';
|
|
53
|
+
readonly 'ref-field.placeholder': 'Select\u2026';
|
|
54
|
+
readonly 'ref-field.placeholder_one': 'Select\u2026';
|
|
55
|
+
readonly 'ref-field.placeholder_other': 'Select items\u2026';
|
|
56
|
+
readonly 'example.placeholder': 'Example';
|
|
57
|
+
readonly 'latitude.placeholder': 'Latitude (e.g., 40.7128)';
|
|
58
|
+
readonly 'longitude.placeholder': 'Longitude (e.g., -74.0060)';
|
|
59
|
+
readonly 'cancel-button.label': 'Cancel';
|
|
60
|
+
readonly 'save-button.label': 'Save';
|
|
61
|
+
readonly 'create-text.label': 'Create text';
|
|
62
|
+
readonly 'format.boolean.label': 'Boolean';
|
|
63
|
+
readonly 'format.currency.label': 'Currency';
|
|
64
|
+
readonly 'format.date.label': 'Date';
|
|
65
|
+
readonly 'format.date-time.label': 'DateTime';
|
|
66
|
+
readonly 'format.did.label': 'DID';
|
|
67
|
+
readonly 'format.duration.label': 'Duration';
|
|
68
|
+
readonly 'format.dxn.label': 'DXN';
|
|
69
|
+
readonly 'format.email.label': 'Email';
|
|
70
|
+
readonly 'format.formula.label': 'Formula';
|
|
71
|
+
readonly 'format.hostname.label': 'Hostname';
|
|
72
|
+
readonly 'format.integer.label': 'Integer';
|
|
73
|
+
readonly 'format.json.label': 'JSON';
|
|
74
|
+
readonly 'format.lnglat.label': 'Geopoint';
|
|
75
|
+
readonly 'format.markdown.label': 'Markdown';
|
|
76
|
+
readonly 'format.percent.label': 'Percent';
|
|
77
|
+
readonly 'format.ref.label': 'Reference';
|
|
78
|
+
readonly 'format.regex.label': 'RegExp';
|
|
79
|
+
readonly 'format.string.label': 'String';
|
|
80
|
+
readonly 'format.single-select.label': 'Select';
|
|
81
|
+
readonly 'format.multi-select.label': 'Multi-select';
|
|
82
|
+
readonly 'format.text.label': 'Long text';
|
|
83
|
+
readonly 'format.time.label': 'Time';
|
|
84
|
+
readonly 'format.timestamp.label': 'Timestamp';
|
|
85
|
+
readonly 'format.user.label': 'User';
|
|
86
|
+
readonly 'format.number.label': 'Number';
|
|
87
|
+
readonly 'format.uri.label': 'URI';
|
|
88
|
+
readonly 'format.url.label': 'URL';
|
|
89
|
+
readonly 'format.uuid.label': 'UUID';
|
|
90
|
+
readonly 'latitude.label': 'Latitude';
|
|
91
|
+
readonly 'longitude.label': 'Longitude';
|
|
92
|
+
readonly 'select-option.label': 'Label';
|
|
93
|
+
readonly 'select-option-label.placeholder': 'Option label';
|
|
94
|
+
readonly 'select-option-delete.button': 'Delete';
|
|
95
|
+
readonly 'select-option-add.button': 'Add option';
|
|
96
|
+
readonly 'system-schema.title': 'System type';
|
|
97
|
+
readonly 'system-schema.description': 'System type: cannot add or remove fields.';
|
|
98
|
+
readonly 'remove.button': 'Delete';
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
}];
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export default meta;
|
|
105
|
+
type Story = StoryObj<StoryProps>;
|
|
106
|
+
/** Baseline: no annotation, no override — `Form.FieldSet` renders linearly (one field per row). */
|
|
107
|
+
export declare const Linear: Story;
|
|
108
|
+
/** `Form.Layout` invoked directly with a `template` prop, bypassing any annotation. */
|
|
109
|
+
export declare const TemplateProp: Story;
|
|
110
|
+
/** Schema carries `FormLayoutAnnotation`; `Form.FieldSet` auto-detects and delegates. */
|
|
111
|
+
export declare const SchemaAnnotation: Story;
|
|
112
|
+
export declare const NamedAnnotation: Story;
|
|
113
|
+
export declare const NestedLabel: Story;
|
|
114
|
+
/** Read-only static presentation: dates render human-readable; nested structs as labels. */
|
|
115
|
+
export declare const NestedLabelStatic: Story;
|
|
116
|
+
export declare const FormPlayground: Story;
|
|
117
|
+
/** Same playground, but the form is rendered inside a `Card.Root` / `Card.Body`. */
|
|
118
|
+
export declare const CardPlayground: Story;
|
|
119
|
+
//# sourceMappingURL=FormLayout.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout.stories.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/FormLayout.stories.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAoD,MAAM,OAAO,CAAC;AAEzE,OAAO,EAA2B,IAAI,EAAE,MAAM,YAAY,CAAC;AAiB3D;;;;;GAKG;AACH,QAAA,MAAM,MAAM;;;;;;;;;wBAS0D,CAAC;AAEvE,MAAM,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,MAAM,CAAC,CAAC;AAoFtD,KAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAwBF,QAAA,MAAM,IAAI;;mCAtBkC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkC1B,CAAC;eAEd,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;AAElC,mGAAmG;AACnG,eAAO,MAAM,MAAM,EAAE,KAIpB,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAC;AAEF,yFAAyF;AACzF,eAAO,MAAM,gBAAgB,EAAE,KAI9B,CAAC;AAwCF,eAAO,MAAM,eAAe,EAAE,KAE7B,CAAC;AAqCF,eAAO,MAAM,WAAW,EAAE,KAEzB,CAAC;AAEF,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,EAAE,KAE/B,CAAC;AAwIF,eAAO,MAAM,cAAc,EAAE,KAE5B,CAAC;AAEF,oFAAoF;AACpF,eAAO,MAAM,cAAc,EAAE,KAE5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout.stories.test.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/FormLayout.stories.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormLayout.test.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/FormLayout.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Annotation carrying one or more named `FormLayout` DSL templates that
|
|
3
|
+
* control how `Form.FieldSet` / `Form.Layout` arrange a schema's fields.
|
|
4
|
+
* Callers select a variant via the `name` prop; the implicit name is
|
|
5
|
+
* `DEFAULT_LAYOUT_NAME` (`'default'`).
|
|
6
|
+
*
|
|
7
|
+
* Templates use a minimal XML grammar — see `parser.ts`. Example:
|
|
8
|
+
*
|
|
9
|
+
* FormLayoutAnnotation.set({
|
|
10
|
+
* default: `
|
|
11
|
+
* <grid cols="2">
|
|
12
|
+
* <field name="origin"/>
|
|
13
|
+
* <field name="destination"/>
|
|
14
|
+
* <field name="provider" span="2"/>
|
|
15
|
+
* </grid>
|
|
16
|
+
* `,
|
|
17
|
+
* card: `
|
|
18
|
+
* <grid cols="1">
|
|
19
|
+
* <field name="provider"/>
|
|
20
|
+
* <field name="number"/>
|
|
21
|
+
* </grid>
|
|
22
|
+
* `,
|
|
23
|
+
* })
|
|
24
|
+
*/
|
|
25
|
+
export declare const FormLayoutAnnotationId: unique symbol;
|
|
26
|
+
export type FormLayoutMap = Record<string, string>;
|
|
27
|
+
export declare const FormLayoutAnnotation: import("@dxos/echo/internal").AnnotationHelper<FormLayoutMap>;
|
|
28
|
+
/** Name used when no explicit variant is requested. */
|
|
29
|
+
export declare const DEFAULT_LAYOUT_NAME = "default";
|
|
30
|
+
//# sourceMappingURL=annotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/annotation.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,sBAAsB,eAAsD,CAAC;AAE1F,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnD,eAAO,MAAM,oBAAoB,+DAAgE,CAAC;AAElG,uDAAuD;AACvD,eAAO,MAAM,mBAAmB,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/index.ts"],"names":[],"mappings":"AAIA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal XML-style DSL for laying out schema fields in a grid.
|
|
3
|
+
*
|
|
4
|
+
* Grammar:
|
|
5
|
+
* <grid cols="N"> ...children... </grid>
|
|
6
|
+
* <field name="x" span="N"/>
|
|
7
|
+
*
|
|
8
|
+
* - Attributes accept `"…"`, `'…'`, or unquoted integers.
|
|
9
|
+
* - Whitespace between tags is ignored. Text content (between tags) is forbidden.
|
|
10
|
+
* - Self-closing form (`<field … />`) is required for `field`; `grid` must use a closing tag.
|
|
11
|
+
*
|
|
12
|
+
* The parser is hand-rolled (no HTML parser) because the grammar is tiny.
|
|
13
|
+
*/
|
|
14
|
+
/** Node type for the parsed layout tree. */
|
|
15
|
+
export type LayoutNode = {
|
|
16
|
+
readonly kind: 'grid';
|
|
17
|
+
readonly cols: number;
|
|
18
|
+
readonly children: readonly LayoutNode[];
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'field';
|
|
21
|
+
readonly name: string;
|
|
22
|
+
readonly span?: number;
|
|
23
|
+
};
|
|
24
|
+
export declare class LayoutParseError extends Error {
|
|
25
|
+
readonly position?: number | undefined;
|
|
26
|
+
readonly _tag = "LayoutParseError";
|
|
27
|
+
constructor(message: string, position?: number | undefined);
|
|
28
|
+
}
|
|
29
|
+
/** Parses a layout template string into a single root node. The root must be `<grid>`. */
|
|
30
|
+
export declare const parseLayout: (template: string) => LayoutNode;
|
|
31
|
+
//# sourceMappingURL=parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Form/Layout/parser.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,4CAA4C;AAC5C,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,GAC1F;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9E,qBAAa,gBAAiB,SAAQ,KAAK;IAIvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM;IAH5B,QAAQ,CAAC,IAAI,sBAAsB;IACnC,YACE,OAAO,EAAE,MAAM,EACN,QAAQ,CAAC,EAAE,MAAM,YAAA,EAG3B;CACF;AAuED,0FAA0F;AAC1F,eAAO,MAAM,WAAW,aAAc,MAAM,KAAG,UA+D9C,CAAC"}
|