@dxos/react-ui-form 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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/README.md +0 -1
- package/dist/lib/browser/index.mjs +1003 -668
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1003 -668
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +3 -3
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +62 -61
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +23 -18
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +68 -67
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +7 -1
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +0 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts +2 -2
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +9 -10
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +8 -6
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +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 +62 -61
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +9 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -0
- package/dist/types/src/components/ObjectForm/index.d.ts +2 -0
- package/dist/types/src/components/ObjectForm/index.d.ts.map +1 -0
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +10 -2
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +62 -61
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +9 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +83 -0
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectProperties/index.d.ts +2 -0
- package/dist/types/src/components/ObjectProperties/index.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.d.ts +35 -0
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts +82 -0
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -0
- package/dist/types/src/components/Settings/index.d.ts +2 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -0
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +5 -5
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +66 -64
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useKeyHandler.d.ts +2 -1
- package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +62 -61
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/refs.d.ts +1 -0
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +37 -38
- package/src/components/FieldEditor/FieldEditor.stories.tsx +7 -8
- package/src/components/FieldEditor/FieldEditor.test.tsx +0 -1
- package/src/components/FieldEditor/FieldEditor.tsx +3 -4
- package/src/components/Form/AUDIT.md +17 -0
- package/src/components/Form/Form.stories.tsx +25 -26
- package/src/components/Form/Form.tsx +101 -66
- package/src/components/Form/FormField.tsx +32 -14
- package/src/components/Form/FormFieldComponent.stories.tsx +5 -5
- package/src/components/Form/FormFieldComponent.tsx +17 -20
- package/src/components/Form/FormFieldSet.tsx +126 -105
- package/src/components/Form/fields/ArrayField.tsx +11 -8
- package/src/components/Form/fields/GeoPointField.tsx +6 -6
- package/src/components/Form/fields/MarkdownField.tsx +1 -1
- package/src/components/Form/fields/RefField.tsx +37 -20
- package/src/components/Form/fields/SelectField.tsx +1 -1
- package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -3
- package/src/components/Form/fields/SelectOptionField.tsx +9 -10
- package/src/components/Form/fields/TupleField.tsx +1 -1
- package/src/components/ObjectForm/ObjectForm.tsx +113 -0
- package/src/components/{ControlSection → ObjectForm}/index.ts +1 -1
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +13 -18
- package/src/components/ObjectPicker/ObjectPicker.tsx +71 -60
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +63 -0
- package/src/components/ObjectProperties/ObjectProperties.tsx +129 -0
- package/src/components/ObjectProperties/index.ts +5 -0
- package/src/components/Settings/Settings.stories.tsx +55 -0
- package/src/components/Settings/Settings.tsx +129 -0
- package/src/components/Settings/index.ts +5 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +36 -33
- package/src/components/ViewEditor/ViewEditor.test.tsx +3 -7
- package/src/components/ViewEditor/ViewEditor.tsx +117 -85
- package/src/components/index.ts +3 -1
- package/src/components/testing.tsx +20 -8
- package/src/hooks/useFormHandler.ts +42 -18
- package/src/hooks/useKeyHandler.tsx +7 -7
- package/src/translations.ts +63 -63
- package/src/util/refs.ts +7 -3
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +0 -23
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +0 -87
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/index.d.ts +0 -2
- package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/Form-old.stories.d.ts +0 -131
- package/dist/types/src/components/Form/Form-old.stories.d.ts.map +0 -1
- package/src/components/ControlSection/ControlSection.stories.tsx +0 -38
- package/src/components/ControlSection/ControlSection.tsx +0 -153
- package/src/components/Form/Form-old.stories.tsx +0 -314
|
@@ -4,173 +4,83 @@ var translations = [
|
|
|
4
4
|
{
|
|
5
5
|
"en-US": {
|
|
6
6
|
[translationKey]: {
|
|
7
|
-
"fields
|
|
8
|
-
"hidden
|
|
9
|
-
"empty
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"field
|
|
13
|
-
"field
|
|
14
|
-
"field
|
|
15
|
-
"field
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"field
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"ref
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"example
|
|
28
|
-
"latitude
|
|
29
|
-
"longitude
|
|
30
|
-
"cancel
|
|
31
|
-
"save
|
|
32
|
-
//
|
|
33
|
-
"format
|
|
34
|
-
"format
|
|
35
|
-
"format
|
|
36
|
-
"format
|
|
37
|
-
"format
|
|
38
|
-
"format
|
|
39
|
-
"format
|
|
40
|
-
"format
|
|
41
|
-
"format
|
|
42
|
-
"format
|
|
43
|
-
"format
|
|
44
|
-
"format
|
|
45
|
-
"format
|
|
46
|
-
"format
|
|
47
|
-
"format
|
|
48
|
-
"format
|
|
49
|
-
"format
|
|
50
|
-
"format
|
|
51
|
-
"format
|
|
52
|
-
"format
|
|
53
|
-
"format
|
|
54
|
-
"format
|
|
55
|
-
"format
|
|
56
|
-
"format
|
|
57
|
-
"format
|
|
58
|
-
"format
|
|
59
|
-
"format
|
|
60
|
-
"format
|
|
7
|
+
"fields.label": "Fields",
|
|
8
|
+
"hidden-fields.label": "Hidden Fields",
|
|
9
|
+
"empty-readonly-ref-field.label": "(none)",
|
|
10
|
+
"add-property-button.label": "Add property",
|
|
11
|
+
"field-property.label": "Property",
|
|
12
|
+
"field-property.placeholder": "Property name",
|
|
13
|
+
"field-format.label": "Type",
|
|
14
|
+
"field-path.label": "Field path",
|
|
15
|
+
"add-field.button": "Add field",
|
|
16
|
+
"boolean-input-true.value": "Yes",
|
|
17
|
+
"boolean-input-false.value": "No",
|
|
18
|
+
"show-field.label": "Show field",
|
|
19
|
+
"hide-field.label": "Hide field",
|
|
20
|
+
"delete-field.label": "Delete field",
|
|
21
|
+
"ref-field-combobox-input.placeholder": "Search\u2026",
|
|
22
|
+
"ref-field.placeholder": "Select\u2026",
|
|
23
|
+
"ref-field.placeholder_one": "Select\u2026",
|
|
24
|
+
"ref-field.placeholder_other": "Select items\u2026",
|
|
25
|
+
"create-option.label": "Create",
|
|
26
|
+
"add-tag.label": "Add tag",
|
|
27
|
+
"example.placeholder": "Example",
|
|
28
|
+
"latitude.placeholder": "Latitude (e.g., 40.7128)",
|
|
29
|
+
"longitude.placeholder": "Longitude (e.g., -74.0060)",
|
|
30
|
+
"cancel-button.label": "Cancel",
|
|
31
|
+
"save-button.label": "Save",
|
|
32
|
+
// TypeFormat
|
|
33
|
+
"format.boolean.label": "Boolean",
|
|
34
|
+
"format.currency.label": "Currency",
|
|
35
|
+
"format.date.label": "Date",
|
|
36
|
+
"format.date-time.label": "DateTime",
|
|
37
|
+
"format.did.label": "DID",
|
|
38
|
+
"format.duration.label": "Duration",
|
|
39
|
+
"format.dxn.label": "DXN",
|
|
40
|
+
"format.email.label": "Email",
|
|
41
|
+
"format.formula.label": "Formula",
|
|
42
|
+
"format.hostname.label": "Hostname",
|
|
43
|
+
"format.integer.label": "Integer",
|
|
44
|
+
"format.json.label": "JSON",
|
|
45
|
+
"format.lnglat.label": "Geopoint",
|
|
46
|
+
"format.markdown.label": "Markdown",
|
|
47
|
+
"format.percent.label": "Percent",
|
|
48
|
+
"format.ref.label": "Reference",
|
|
49
|
+
"format.regex.label": "RegExp",
|
|
50
|
+
"format.string.label": "String",
|
|
51
|
+
"format.single-select.label": "Select",
|
|
52
|
+
"format.multi-select.label": "Multi-select",
|
|
53
|
+
"format.text.label": "Long text",
|
|
54
|
+
"format.time.label": "Time",
|
|
55
|
+
"format.timestamp.label": "Timestamp",
|
|
56
|
+
"format.user.label": "User",
|
|
57
|
+
"format.number.label": "Number",
|
|
58
|
+
"format.uri.label": "URI",
|
|
59
|
+
"format.url.label": "URL",
|
|
60
|
+
"format.uuid.label": "UUID",
|
|
61
61
|
// GeoPointField.
|
|
62
|
-
"latitude
|
|
63
|
-
"longitude
|
|
62
|
+
"latitude.label": "Latitude",
|
|
63
|
+
"longitude.label": "Longitude",
|
|
64
64
|
// SelectOptionsField.
|
|
65
|
-
"select
|
|
66
|
-
"select
|
|
67
|
-
"select
|
|
68
|
-
"select
|
|
69
|
-
"select option add": "Add option",
|
|
65
|
+
"select-option.label": "Label",
|
|
66
|
+
"select-option-label.placeholder": "Option label",
|
|
67
|
+
"select-option-delete.button": "Delete",
|
|
68
|
+
"select-option-add.button": "Add option",
|
|
70
69
|
// System schema message.
|
|
71
|
-
"system
|
|
72
|
-
"system
|
|
70
|
+
"system-schema.title": "System type",
|
|
71
|
+
"system-schema.description": "System type: cannot add or remove fields.",
|
|
72
|
+
"remove.button": "Remove"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
];
|
|
77
77
|
|
|
78
|
-
// src/components/ControlSection/ControlSection.tsx
|
|
79
|
-
import React from "react";
|
|
80
|
-
import { Button, Input, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
81
|
-
import { Layout } from "@dxos/react-ui-mosaic";
|
|
82
|
-
import { mx } from "@dxos/ui-theme";
|
|
83
|
-
var ControlPage = ({ children, classNames, ...props }) => {
|
|
84
|
-
return /* @__PURE__ */ React.createElement(Layout.Container, {
|
|
85
|
-
scrollable: true,
|
|
86
|
-
classNames: "[--control-spacing:var(--dx-trimMd)]"
|
|
87
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
88
|
-
role: "none",
|
|
89
|
-
className: mx("pli-cardSpacingInline pbe-trimMd", classNames),
|
|
90
|
-
...props
|
|
91
|
-
}, children));
|
|
92
|
-
};
|
|
93
|
-
var ControlSection = ({ title, description, children }) => {
|
|
94
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ControlSectionHeading, {
|
|
95
|
-
title,
|
|
96
|
-
description
|
|
97
|
-
}), children);
|
|
98
|
-
};
|
|
99
|
-
var ControlSectionHeading = ({ title, description }) => {
|
|
100
|
-
const { t } = useTranslation(translationKey);
|
|
101
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", {
|
|
102
|
-
className: "pli-trimMd container-max-width text-xl mbs-trimMd mbe-trimMd"
|
|
103
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
104
|
-
className: "pli-trimMd mlb-trimMd container-max-width text-description"
|
|
105
|
-
}, toLocalizedString(description, t)));
|
|
106
|
-
};
|
|
107
|
-
var ControlGroupButton = ({ classNames, ...props }) => {
|
|
108
|
-
return /* @__PURE__ */ React.createElement(Button, {
|
|
109
|
-
...props,
|
|
110
|
-
classNames: [
|
|
111
|
-
"md:col-span-2",
|
|
112
|
-
classNames
|
|
113
|
-
]
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
var ControlGroup = ({ children, classNames }) => /* @__PURE__ */ React.createElement("div", {
|
|
117
|
-
role: "none",
|
|
118
|
-
className: mx("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-trimMd", "[--control-spacing:0px] [&_input]:justify-self-end [&_button]:justify-self-end", classNames)
|
|
119
|
-
}, children);
|
|
120
|
-
var ControlFrame = ({ children }) => /* @__PURE__ */ React.createElement("div", {
|
|
121
|
-
role: "none",
|
|
122
|
-
className: mx("container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-trimSm md:gap-trimMd p-trimMd", "border border-separator rounded-md")
|
|
123
|
-
}, children);
|
|
124
|
-
var controlItemClasses = mx([
|
|
125
|
-
"container-max-width grid md:col-span-2 grid-cols-subgrid gap-trimSm items-center",
|
|
126
|
-
// TODO(burdon): Use grid gap consistently or apply margins consistently?
|
|
127
|
-
"mlb-[--control-spacing] *:first:!mbs-0 *:last:!mbe-0 pli-trimMd plb-trimMd",
|
|
128
|
-
"border border-separator rounded-md"
|
|
129
|
-
]);
|
|
130
|
-
var controlItemTitleClasses = "mbe-0 text-lg text-baseText font-normal";
|
|
131
|
-
var controlItemDescriptionClasses = "mlb-trimSm md:mbe-0 text-base text-description";
|
|
132
|
-
var ControlItem = ({ title, description, children }) => {
|
|
133
|
-
const { t } = useTranslation(translationKey);
|
|
134
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
135
|
-
className: controlItemClasses
|
|
136
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
137
|
-
role: "none"
|
|
138
|
-
}, /* @__PURE__ */ React.createElement("h3", {
|
|
139
|
-
className: controlItemTitleClasses
|
|
140
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
141
|
-
className: controlItemDescriptionClasses
|
|
142
|
-
}, toLocalizedString(description, t))), children);
|
|
143
|
-
};
|
|
144
|
-
var ControlItemInput = ({ title, description, children }) => {
|
|
145
|
-
const { t } = useTranslation(translationKey);
|
|
146
|
-
return /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement("div", {
|
|
147
|
-
className: controlItemClasses
|
|
148
|
-
}, /* @__PURE__ */ React.createElement("div", {
|
|
149
|
-
role: "none"
|
|
150
|
-
}, /* @__PURE__ */ React.createElement(Input.Label, {
|
|
151
|
-
classNames: controlItemTitleClasses
|
|
152
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Description, {
|
|
153
|
-
classNames: controlItemDescriptionClasses
|
|
154
|
-
}, toLocalizedString(description, t)))), children));
|
|
155
|
-
};
|
|
156
|
-
var ControlFrameItem = ({ title, description, children }) => {
|
|
157
|
-
const { t } = useTranslation(translationKey);
|
|
158
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
159
|
-
role: "group",
|
|
160
|
-
className: "min-is-0"
|
|
161
|
-
}, /* @__PURE__ */ React.createElement("h3", {
|
|
162
|
-
className: "text-lg mbe-2"
|
|
163
|
-
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React.createElement("p", {
|
|
164
|
-
className: "mlb-trimSm md:mbe-0 text-description"
|
|
165
|
-
}, toLocalizedString(description, t)), children);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
78
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
169
|
-
import
|
|
170
|
-
import { Obj } from "@dxos/echo";
|
|
79
|
+
import React17, { useCallback as useCallback14, useEffect as useEffect6, useMemo as useMemo7, useState as useState5 } from "react";
|
|
80
|
+
import { Obj as Obj2 } from "@dxos/echo";
|
|
171
81
|
import { Format as Format4, FormatEnums, formatToType } from "@dxos/echo/internal";
|
|
172
82
|
import { log as log2 } from "@dxos/log";
|
|
173
|
-
import { useAsyncEffect, useTranslation as
|
|
83
|
+
import { useAsyncEffect, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
174
84
|
import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
|
|
175
85
|
|
|
176
86
|
// src/util/field.ts
|
|
@@ -442,23 +352,28 @@ var getFormProperties = (ast) => {
|
|
|
442
352
|
|
|
443
353
|
// src/util/refs.ts
|
|
444
354
|
import { Ref } from "@dxos/echo";
|
|
445
|
-
import {
|
|
355
|
+
import { ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
356
|
+
import { findAnnotation, getArrayElementType, isArrayType } from "@dxos/effect";
|
|
446
357
|
var getRefProps = (ast) => {
|
|
447
358
|
if (isArrayType(ast)) {
|
|
448
359
|
const elementType = getArrayElementType(ast);
|
|
449
360
|
if (elementType) {
|
|
450
361
|
if (Ref.isRefType(elementType)) {
|
|
362
|
+
const typename = findAnnotation(elementType, ReferenceAnnotationId)?.typename;
|
|
451
363
|
return {
|
|
452
364
|
ast: elementType,
|
|
453
|
-
isArray: true
|
|
365
|
+
isArray: true,
|
|
366
|
+
typename
|
|
454
367
|
};
|
|
455
368
|
}
|
|
456
369
|
}
|
|
457
370
|
}
|
|
458
371
|
if (Ref.isRefType(ast)) {
|
|
372
|
+
const typename = findAnnotation(ast, ReferenceAnnotationId)?.typename;
|
|
459
373
|
return {
|
|
460
374
|
ast,
|
|
461
|
-
isArray: false
|
|
375
|
+
isArray: false,
|
|
376
|
+
typename
|
|
462
377
|
};
|
|
463
378
|
}
|
|
464
379
|
return void 0;
|
|
@@ -466,23 +381,24 @@ var getRefProps = (ast) => {
|
|
|
466
381
|
|
|
467
382
|
// src/components/Form/fields/ArrayField.tsx
|
|
468
383
|
import * as Option3 from "effect/Option";
|
|
469
|
-
import * as
|
|
470
|
-
import
|
|
384
|
+
import * as SchemaAST3 from "effect/SchemaAST";
|
|
385
|
+
import React5, { useCallback as useCallback3 } from "react";
|
|
471
386
|
import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
|
|
472
|
-
import { IconButton as IconButton2, useTranslation as
|
|
387
|
+
import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
473
388
|
|
|
474
389
|
// src/components/Form/Form.tsx
|
|
475
390
|
import { createContext } from "@radix-ui/react-context";
|
|
476
391
|
import * as Schema2 from "effect/Schema";
|
|
477
|
-
import
|
|
478
|
-
import {
|
|
479
|
-
import {
|
|
480
|
-
import {
|
|
392
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
393
|
+
import React4, { useEffect as useEffect2, useMemo as useMemo4, useRef } from "react";
|
|
394
|
+
import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
|
|
395
|
+
import { IconButton, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
396
|
+
import { composable, composableProps, mx } from "@dxos/ui-theme";
|
|
481
397
|
|
|
482
398
|
// src/hooks/useFormHandler.ts
|
|
483
399
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
484
400
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
485
|
-
import { createJsonPath, fromEffectValidationPath, getValue as getValue
|
|
401
|
+
import { createJsonPath, fromEffectValidationPath, getValue as getValue$ } from "@dxos/effect";
|
|
486
402
|
import { log } from "@dxos/log";
|
|
487
403
|
import { useDefaultValue } from "@dxos/react-ui";
|
|
488
404
|
import { validateSchema } from "@dxos/schema";
|
|
@@ -497,11 +413,13 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
497
413
|
prop: valuesProp,
|
|
498
414
|
defaultProp: defaultValues,
|
|
499
415
|
onChange: () => {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
416
|
+
if (valuesProp !== void 0) {
|
|
417
|
+
setValues(valuesProp ?? defaultValues);
|
|
418
|
+
setChanged({});
|
|
419
|
+
setTouched({});
|
|
420
|
+
setErrors({});
|
|
421
|
+
setSaving(false);
|
|
422
|
+
}
|
|
505
423
|
}
|
|
506
424
|
});
|
|
507
425
|
const values = values$;
|
|
@@ -515,7 +433,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
515
433
|
errors: errors2
|
|
516
434
|
}, {
|
|
517
435
|
F: __dxlog_file,
|
|
518
|
-
L:
|
|
436
|
+
L: 155,
|
|
519
437
|
S: void 0,
|
|
520
438
|
C: (f, a) => f(...a)
|
|
521
439
|
});
|
|
@@ -608,11 +526,12 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
608
526
|
value: value3
|
|
609
527
|
}, {
|
|
610
528
|
F: __dxlog_file,
|
|
611
|
-
L:
|
|
529
|
+
L: 254,
|
|
612
530
|
S: void 0,
|
|
613
531
|
C: (f, a) => f(...a)
|
|
614
532
|
});
|
|
615
533
|
const jsonPath = createJsonPath(path);
|
|
534
|
+
const pathArray = path;
|
|
616
535
|
let parsedValue = value3;
|
|
617
536
|
try {
|
|
618
537
|
if (type._tag === "NumberKeyword") {
|
|
@@ -621,33 +540,33 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
621
540
|
} catch (err) {
|
|
622
541
|
log.catch(err, void 0, {
|
|
623
542
|
F: __dxlog_file,
|
|
624
|
-
L:
|
|
543
|
+
L: 264,
|
|
625
544
|
S: void 0,
|
|
626
545
|
C: (f, a) => f(...a)
|
|
627
546
|
});
|
|
628
547
|
parsedValue = void 0;
|
|
629
548
|
}
|
|
630
|
-
const newValues =
|
|
631
|
-
...setValue$(values, jsonPath, parsedValue)
|
|
632
|
-
};
|
|
633
|
-
setValues(newValues);
|
|
549
|
+
const newValues = mergeAtPath(values, pathArray, parsedValue);
|
|
634
550
|
const newChanged = {
|
|
635
551
|
[jsonPath]: true
|
|
636
552
|
};
|
|
637
|
-
setChanged({
|
|
638
|
-
...
|
|
553
|
+
setChanged((prev) => ({
|
|
554
|
+
...prev,
|
|
639
555
|
...newChanged
|
|
640
|
-
});
|
|
556
|
+
}));
|
|
641
557
|
const isValid2 = validate(newValues);
|
|
642
558
|
onValuesChanged?.(newValues, {
|
|
643
559
|
isValid: isValid2,
|
|
644
560
|
changed: newChanged
|
|
645
561
|
});
|
|
562
|
+
if (valuesProp === void 0) {
|
|
563
|
+
setValues(newValues);
|
|
564
|
+
}
|
|
646
565
|
}, [
|
|
647
566
|
values,
|
|
648
|
-
changed,
|
|
649
567
|
validate,
|
|
650
|
-
onValuesChanged
|
|
568
|
+
onValuesChanged,
|
|
569
|
+
valuesProp
|
|
651
570
|
]);
|
|
652
571
|
const onBlur = useCallback(async (path) => {
|
|
653
572
|
const jsonPath = createJsonPath(path);
|
|
@@ -704,6 +623,24 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
704
623
|
onCancel
|
|
705
624
|
]);
|
|
706
625
|
};
|
|
626
|
+
var mergeAtPath = (obj, path, value3) => {
|
|
627
|
+
if (path.length === 0) {
|
|
628
|
+
return value3;
|
|
629
|
+
}
|
|
630
|
+
const [head2, ...rest] = path;
|
|
631
|
+
const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[head2], rest, value3);
|
|
632
|
+
if (Array.isArray(obj)) {
|
|
633
|
+
const copy = [
|
|
634
|
+
...obj
|
|
635
|
+
];
|
|
636
|
+
copy[head2] = child;
|
|
637
|
+
return copy;
|
|
638
|
+
}
|
|
639
|
+
return {
|
|
640
|
+
...obj,
|
|
641
|
+
[head2]: child
|
|
642
|
+
};
|
|
643
|
+
};
|
|
707
644
|
var flatMap = (errors) => {
|
|
708
645
|
return errors.reduce((result, { path, message }) => {
|
|
709
646
|
const jsonPath = fromEffectValidationPath(path);
|
|
@@ -715,9 +652,9 @@ var flatMap = (errors) => {
|
|
|
715
652
|
};
|
|
716
653
|
|
|
717
654
|
// src/hooks/useKeyHandler.tsx
|
|
718
|
-
import { useCallback as useCallback2,
|
|
655
|
+
import { useCallback as useCallback2, useLayoutEffect } from "react";
|
|
719
656
|
import { addEventListener } from "@dxos/async";
|
|
720
|
-
var useKeyHandler = (
|
|
657
|
+
var useKeyHandler = (elRef, form) => {
|
|
721
658
|
const handleKeyDown = useCallback2((event) => {
|
|
722
659
|
switch (event.key) {
|
|
723
660
|
case "Enter": {
|
|
@@ -733,40 +670,37 @@ var useKeyHandler = (formElement, form) => {
|
|
|
733
670
|
form.onSave,
|
|
734
671
|
form.autoSave
|
|
735
672
|
]);
|
|
736
|
-
|
|
737
|
-
|
|
673
|
+
useLayoutEffect(() => {
|
|
674
|
+
const el = elRef.current;
|
|
675
|
+
if (!el) {
|
|
738
676
|
return;
|
|
739
677
|
}
|
|
740
|
-
return addEventListener(
|
|
678
|
+
return addEventListener(el, "keydown", handleKeyDown);
|
|
741
679
|
}, [
|
|
742
|
-
|
|
680
|
+
elRef,
|
|
743
681
|
handleKeyDown
|
|
744
682
|
]);
|
|
745
683
|
};
|
|
746
684
|
|
|
747
685
|
// src/components/Form/FormFieldComponent.tsx
|
|
748
|
-
import
|
|
749
|
-
import { Icon, Input
|
|
750
|
-
import {
|
|
751
|
-
var labelSpacing = "mbs-inputSpacingBlock mbe-labelSpacingBlock";
|
|
686
|
+
import React, { Component } from "react";
|
|
687
|
+
import { Icon, Input, Tooltip } from "@dxos/react-ui";
|
|
688
|
+
import { inputTextLabel } from "@dxos/ui-theme";
|
|
752
689
|
var FormFieldLabel = ({ label, error, readonly, asChild }) => {
|
|
753
|
-
const Label = readonly || asChild ? "span" :
|
|
754
|
-
|
|
755
|
-
className: "text-description text-sm"
|
|
756
|
-
} : {
|
|
757
|
-
classNames: "!mlb-0 text-sm"
|
|
758
|
-
};
|
|
759
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
690
|
+
const Label = readonly || asChild ? "span" : Input.Label;
|
|
691
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
760
692
|
role: "none",
|
|
761
|
-
className:
|
|
762
|
-
}, /* @__PURE__ */
|
|
693
|
+
className: "flex items-center justify-between"
|
|
694
|
+
}, /* @__PURE__ */ React.createElement(Label, {
|
|
695
|
+
className: inputTextLabel
|
|
696
|
+
}, label), error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
763
697
|
asChild: true,
|
|
764
698
|
content: error,
|
|
765
699
|
side: "bottom"
|
|
766
|
-
}, /* @__PURE__ */
|
|
700
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
767
701
|
icon: "ph--warning--regular",
|
|
768
702
|
size: 4,
|
|
769
|
-
classNames:
|
|
703
|
+
classNames: "text-error-text"
|
|
770
704
|
})));
|
|
771
705
|
};
|
|
772
706
|
FormFieldLabel.displayName = "Form.FieldLabel";
|
|
@@ -778,15 +712,18 @@ var FormFieldWrapper = (props) => {
|
|
|
778
712
|
return null;
|
|
779
713
|
}
|
|
780
714
|
const str = String(value3 ?? "");
|
|
781
|
-
return /* @__PURE__ */
|
|
715
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
716
|
+
role: "none",
|
|
717
|
+
className: "contents"
|
|
718
|
+
}, /* @__PURE__ */ React.createElement(Input.Root, {
|
|
782
719
|
validationValence: status
|
|
783
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
720
|
+
}, layout !== "inline" && /* @__PURE__ */ React.createElement(FormFieldLabel, {
|
|
784
721
|
error,
|
|
785
722
|
readonly,
|
|
786
723
|
label
|
|
787
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
724
|
+
}), layout === "static" ? /* @__PURE__ */ React.createElement("p", null, str) : children ? children({
|
|
788
725
|
value: value3
|
|
789
|
-
}) : null, layout === "full" && /* @__PURE__ */
|
|
726
|
+
}) : null, layout === "full" && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
|
|
790
727
|
};
|
|
791
728
|
var FormFieldErrorBoundary = class extends Component {
|
|
792
729
|
static getDerivedStateFromError(error) {
|
|
@@ -804,10 +741,10 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
804
741
|
}
|
|
805
742
|
render() {
|
|
806
743
|
if (this.state.error) {
|
|
807
|
-
return /* @__PURE__ */
|
|
808
|
-
className: "flex gap-2 border border-
|
|
809
|
-
}, /* @__PURE__ */
|
|
810
|
-
className: "bg-
|
|
744
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
745
|
+
className: "flex gap-2 border border-rose-fill font-mono text-sm"
|
|
746
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
747
|
+
className: "bg-rose-fill text-surface-text px-1 font-thin"
|
|
811
748
|
}, "ERROR"), String(this.props.path?.join(".")));
|
|
812
749
|
}
|
|
813
750
|
return this.props.children;
|
|
@@ -820,9 +757,7 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
820
757
|
};
|
|
821
758
|
|
|
822
759
|
// src/components/Form/FormFieldSet.tsx
|
|
823
|
-
import
|
|
824
|
-
import { mx as mx3 } from "@dxos/ui-theme";
|
|
825
|
-
import { isTruthy } from "@dxos/util";
|
|
760
|
+
import React3, { useMemo as useMemo3 } from "react";
|
|
826
761
|
|
|
827
762
|
// src/components/Form/FormField.tsx
|
|
828
763
|
import * as Match from "effect/Match";
|
|
@@ -830,10 +765,10 @@ import * as Option2 from "effect/Option";
|
|
|
830
765
|
import * as Schema from "effect/Schema";
|
|
831
766
|
import * as SchemaAST from "effect/SchemaAST";
|
|
832
767
|
import * as String2 from "effect/String";
|
|
833
|
-
import
|
|
768
|
+
import React2, { useMemo as useMemo2 } from "react";
|
|
834
769
|
import { Format as Format3 } from "@dxos/echo";
|
|
835
770
|
import { createJsonPath as createJsonPath2, findNode, getAnnotation, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion, isNestedType } from "@dxos/effect";
|
|
836
|
-
import { useTranslation
|
|
771
|
+
import { useTranslation } from "@dxos/react-ui";
|
|
837
772
|
var FormField = (props) => {
|
|
838
773
|
const {
|
|
839
774
|
type,
|
|
@@ -845,15 +780,17 @@ var FormField = (props) => {
|
|
|
845
780
|
readonly,
|
|
846
781
|
layout,
|
|
847
782
|
// RefFieldProps
|
|
783
|
+
createTypename,
|
|
848
784
|
createOptionLabel,
|
|
849
785
|
createOptionIcon,
|
|
850
786
|
createInitialValuePath,
|
|
787
|
+
createFieldMap: createFieldMap3,
|
|
851
788
|
db,
|
|
852
789
|
schemaHook,
|
|
853
|
-
getOptions
|
|
790
|
+
getOptions,
|
|
854
791
|
onCreate
|
|
855
792
|
} = props;
|
|
856
|
-
const { t } =
|
|
793
|
+
const { t } = useTranslation(translationKey);
|
|
857
794
|
const title = getAnnotation(SchemaAST.TitleAnnotationId)(type);
|
|
858
795
|
const description = getAnnotation(SchemaAST.DescriptionAnnotationId)(type);
|
|
859
796
|
const examples = getAnnotation(SchemaAST.ExamplesAnnotationId)(type);
|
|
@@ -861,7 +798,7 @@ var FormField = (props) => {
|
|
|
861
798
|
title,
|
|
862
799
|
name
|
|
863
800
|
]);
|
|
864
|
-
const placeholder = useMemo2(() => examples?.length ? `${t("example
|
|
801
|
+
const placeholder = useMemo2(() => examples?.length ? `${t("example.placeholder")}: ${examples[0]}` : description ?? label, [
|
|
865
802
|
examples,
|
|
866
803
|
description,
|
|
867
804
|
label
|
|
@@ -879,7 +816,7 @@ var FormField = (props) => {
|
|
|
879
816
|
const jsonPath = createJsonPath2(path ?? []);
|
|
880
817
|
const CustomField = fieldMap?.[jsonPath];
|
|
881
818
|
if (CustomField) {
|
|
882
|
-
return /* @__PURE__ */
|
|
819
|
+
return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
|
|
883
820
|
}
|
|
884
821
|
const component = fieldProvider?.({
|
|
885
822
|
schema: Schema.make(type),
|
|
@@ -890,7 +827,7 @@ var FormField = (props) => {
|
|
|
890
827
|
return component;
|
|
891
828
|
}
|
|
892
829
|
if (isArrayType2(type)) {
|
|
893
|
-
return /* @__PURE__ */
|
|
830
|
+
return /* @__PURE__ */ React2.createElement(ArrayField, {
|
|
894
831
|
fieldProps: fieldState,
|
|
895
832
|
label,
|
|
896
833
|
...props
|
|
@@ -898,29 +835,37 @@ var FormField = (props) => {
|
|
|
898
835
|
}
|
|
899
836
|
const Field = getFormField(fieldProps);
|
|
900
837
|
if (Field) {
|
|
901
|
-
return /* @__PURE__ */
|
|
838
|
+
return /* @__PURE__ */ React2.createElement(Field, fieldProps);
|
|
902
839
|
}
|
|
903
|
-
const options =
|
|
840
|
+
const options = getSelectOptions(type);
|
|
904
841
|
if (options) {
|
|
905
|
-
|
|
842
|
+
const fieldProjections = projection?.getFieldProjections();
|
|
843
|
+
const fieldProjection = fieldProjections?.find((fp) => fp.field.path === name);
|
|
844
|
+
const selectOptions = fieldProjection?.props.options;
|
|
845
|
+
return /* @__PURE__ */ React2.createElement(SelectField, {
|
|
906
846
|
...fieldProps,
|
|
907
|
-
options: options.map((option) =>
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
847
|
+
options: options.map((option) => {
|
|
848
|
+
const selectOption = selectOptions?.find((so) => so.id === globalThis.String(option));
|
|
849
|
+
return {
|
|
850
|
+
value: option,
|
|
851
|
+
label: selectOption?.title ?? option.toString()
|
|
852
|
+
};
|
|
853
|
+
})
|
|
911
854
|
});
|
|
912
855
|
}
|
|
913
856
|
const refProps = getRefProps(type);
|
|
914
857
|
if (refProps) {
|
|
915
|
-
|
|
858
|
+
const isCreateTarget = !createTypename || refProps.typename === createTypename;
|
|
859
|
+
return /* @__PURE__ */ React2.createElement(RefField, {
|
|
916
860
|
...fieldProps,
|
|
917
861
|
...refProps,
|
|
918
|
-
createOptionLabel,
|
|
919
|
-
createOptionIcon,
|
|
920
|
-
createInitialValuePath,
|
|
862
|
+
createOptionLabel: isCreateTarget ? createOptionLabel : void 0,
|
|
863
|
+
createOptionIcon: isCreateTarget ? createOptionIcon : void 0,
|
|
864
|
+
createInitialValuePath: isCreateTarget ? createInitialValuePath : void 0,
|
|
865
|
+
createFieldMap: isCreateTarget ? createFieldMap3 : void 0,
|
|
921
866
|
db,
|
|
922
867
|
schemaHook,
|
|
923
|
-
getOptions
|
|
868
|
+
getOptions,
|
|
924
869
|
onCreate
|
|
925
870
|
});
|
|
926
871
|
}
|
|
@@ -929,7 +874,7 @@ var FormField = (props) => {
|
|
|
929
874
|
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST.isTypeLiteral);
|
|
930
875
|
if (typeLiteral) {
|
|
931
876
|
const schema = Schema.make(typeLiteral);
|
|
932
|
-
return /* @__PURE__ */
|
|
877
|
+
return /* @__PURE__ */ React2.createElement(FormFieldSet, {
|
|
933
878
|
schema,
|
|
934
879
|
path,
|
|
935
880
|
readonly,
|
|
@@ -943,7 +888,7 @@ var FormField = (props) => {
|
|
|
943
888
|
createInitialValuePath,
|
|
944
889
|
db,
|
|
945
890
|
schemaHook,
|
|
946
|
-
getOptions
|
|
891
|
+
getOptions,
|
|
947
892
|
onCreate
|
|
948
893
|
});
|
|
949
894
|
}
|
|
@@ -967,7 +912,7 @@ var getFormField = ({ type, format }) => {
|
|
|
967
912
|
return BooleanField;
|
|
968
913
|
}
|
|
969
914
|
};
|
|
970
|
-
var
|
|
915
|
+
var getSelectOptions = (ast) => {
|
|
971
916
|
if (isLiteralUnion(ast)) {
|
|
972
917
|
return ast.types.map((type) => type.literal).filter((v) => v !== null);
|
|
973
918
|
}
|
|
@@ -975,58 +920,31 @@ var getOptions = (ast) => {
|
|
|
975
920
|
};
|
|
976
921
|
|
|
977
922
|
// src/components/Form/FormFieldSet.tsx
|
|
978
|
-
var
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
return [];
|
|
983
|
-
}
|
|
984
|
-
const props2 = getFormProperties(schema.ast);
|
|
985
|
-
if (projection) {
|
|
986
|
-
const fieldProjections = projection.getFieldProjections();
|
|
987
|
-
const hiddenProperties = new Set(projection.getHiddenProperties());
|
|
988
|
-
const visibleProps = props2.filter((prop) => !hiddenProperties.has(prop.name.toString()));
|
|
989
|
-
const orderedProps = [];
|
|
990
|
-
for (const fieldProjection of fieldProjections) {
|
|
991
|
-
const fieldPath = String(fieldProjection.field.path);
|
|
992
|
-
const prop = visibleProps.find((p) => p.name === fieldPath);
|
|
993
|
-
if (prop) {
|
|
994
|
-
orderedProps.push(prop);
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
const projectionPaths = new Set(fieldProjections.map((projection2) => String(projection2.field.path)));
|
|
998
|
-
const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name.toString()));
|
|
999
|
-
orderedProps.push(...remainingProps);
|
|
1000
|
-
return orderedProps;
|
|
1001
|
-
}
|
|
1002
|
-
const filtered = exclude ? exclude(props2) : props2;
|
|
1003
|
-
return sort ? filtered.sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString())) : filtered;
|
|
1004
|
-
}, [
|
|
923
|
+
var FORM_FIELDSET_NAME = "Form.FieldSet";
|
|
924
|
+
var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, ...props }) => {
|
|
925
|
+
const values = useFormValues(FORM_FIELDSET_NAME, path);
|
|
926
|
+
const properties = useFormFieldSetProperties({
|
|
1005
927
|
schema,
|
|
1006
928
|
values,
|
|
1007
929
|
exclude,
|
|
1008
930
|
sort,
|
|
1009
|
-
projection
|
|
1010
|
-
|
|
931
|
+
projection
|
|
932
|
+
});
|
|
1011
933
|
if ((readonly || layout === "static") && values == null) {
|
|
1012
934
|
return null;
|
|
1013
935
|
}
|
|
1014
|
-
return /* @__PURE__ */
|
|
1015
|
-
role: "form",
|
|
1016
|
-
className: mx3("is-full", layout === "inline" && "flex flex-col gap-2", classNames),
|
|
1017
|
-
ref: forwardRef4
|
|
1018
|
-
}, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
|
|
936
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
|
|
1019
937
|
label,
|
|
1020
938
|
asChild: true
|
|
1021
939
|
}), properties.map((property) => {
|
|
1022
940
|
const name = property.name.toString();
|
|
1023
|
-
return /* @__PURE__ */
|
|
941
|
+
return /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
|
|
1024
942
|
key: name,
|
|
1025
943
|
path: [
|
|
1026
944
|
...path ?? [],
|
|
1027
945
|
name
|
|
1028
946
|
]
|
|
1029
|
-
}, /* @__PURE__ */
|
|
947
|
+
}, /* @__PURE__ */ React3.createElement(FormField, {
|
|
1030
948
|
type: property.type,
|
|
1031
949
|
name,
|
|
1032
950
|
path: [
|
|
@@ -1038,24 +956,67 @@ var FormFieldSet = /* @__PURE__ */ forwardRef(({ classNames, label, schema, read
|
|
|
1038
956
|
projection,
|
|
1039
957
|
...props
|
|
1040
958
|
}));
|
|
1041
|
-
})
|
|
1042
|
-
}
|
|
1043
|
-
FormFieldSet.displayName =
|
|
959
|
+
}));
|
|
960
|
+
};
|
|
961
|
+
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
962
|
+
var useFormFieldSetProperties = ({ schema, exclude, projection, values, sort }) => {
|
|
963
|
+
return useMemo3(() => {
|
|
964
|
+
if (!schema) {
|
|
965
|
+
return [];
|
|
966
|
+
}
|
|
967
|
+
const schemaProps = getFormProperties(schema.ast);
|
|
968
|
+
const filteredProps = exclude ? exclude(schemaProps) : schemaProps;
|
|
969
|
+
if (projection) {
|
|
970
|
+
const fieldProjections = projection.getFieldProjections();
|
|
971
|
+
const hiddenProperties = new Set(projection.getHiddenProperties());
|
|
972
|
+
const visibleProps = filteredProps.filter((prop) => !hiddenProperties.has(prop.name.toString()));
|
|
973
|
+
const orderedProps = [];
|
|
974
|
+
for (const fieldProjection of fieldProjections) {
|
|
975
|
+
const fieldPath = String(fieldProjection.field.path);
|
|
976
|
+
const prop = visibleProps.find((prop2) => prop2.name === fieldPath);
|
|
977
|
+
if (prop) {
|
|
978
|
+
orderedProps.push(prop);
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
const projectionPaths = new Set(fieldProjections.map((projection2) => String(projection2.field.path)));
|
|
982
|
+
const remainingProps = visibleProps.filter((prop) => !projectionPaths.has(prop.name.toString()));
|
|
983
|
+
orderedProps.push(...remainingProps);
|
|
984
|
+
return orderedProps;
|
|
985
|
+
}
|
|
986
|
+
return sort ? [
|
|
987
|
+
...filteredProps
|
|
988
|
+
].sort(({ name: a }, { name: b }) => sort.indexOf(a.toString()) - sort.indexOf(b.toString())) : filteredProps;
|
|
989
|
+
}, [
|
|
990
|
+
schema,
|
|
991
|
+
values,
|
|
992
|
+
exclude,
|
|
993
|
+
sort,
|
|
994
|
+
projection
|
|
995
|
+
]);
|
|
996
|
+
};
|
|
1044
997
|
|
|
1045
998
|
// src/components/Form/Form.tsx
|
|
1046
999
|
var omitId = (schema) => schema.pipe(Schema2.omit("id"));
|
|
1047
1000
|
var [FormContextProvider, useFormContext] = createContext("Form");
|
|
1048
|
-
var useFormValues = (componentName, path
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1001
|
+
var useFormValues = (componentName, path, defaultValue) => {
|
|
1002
|
+
const stablePath = useMemo4(() => path ?? [], [
|
|
1003
|
+
path ? path.join(".") : void 0
|
|
1004
|
+
]);
|
|
1005
|
+
const jsonPath = createJsonPath3(stablePath);
|
|
1006
|
+
const { form: { values, onValueChange } } = useFormContext(componentName);
|
|
1051
1007
|
const value3 = getValue$2(values, jsonPath);
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1008
|
+
const lastAppliedPathRef = useRef(null);
|
|
1009
|
+
useEffect2(() => {
|
|
1010
|
+
if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
|
|
1011
|
+
lastAppliedPathRef.current = jsonPath;
|
|
1012
|
+
onValueChange(stablePath, SchemaAST2.stringKeyword, defaultValue());
|
|
1055
1013
|
}
|
|
1056
1014
|
}, [
|
|
1057
1015
|
value3,
|
|
1058
|
-
defaultValue
|
|
1016
|
+
defaultValue,
|
|
1017
|
+
onValueChange,
|
|
1018
|
+
stablePath,
|
|
1019
|
+
jsonPath
|
|
1059
1020
|
]);
|
|
1060
1021
|
return value3;
|
|
1061
1022
|
};
|
|
@@ -1085,116 +1046,142 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
|
|
|
1085
1046
|
onCancel,
|
|
1086
1047
|
...props
|
|
1087
1048
|
});
|
|
1088
|
-
return /* @__PURE__ */
|
|
1049
|
+
return /* @__PURE__ */ React4.createElement(FormContextProvider, {
|
|
1089
1050
|
form,
|
|
1090
1051
|
...props
|
|
1091
1052
|
}, children);
|
|
1092
1053
|
};
|
|
1093
1054
|
FormRoot.displayName = "Form.Root";
|
|
1094
|
-
var
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
};
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1055
|
+
var FORM_VIEWPORT_NAME = "Form.Viewport";
|
|
1056
|
+
var FormViewport = composable(({ children, ...props }, forwardedRef) => {
|
|
1057
|
+
return /* @__PURE__ */ React4.createElement(ScrollArea.Root, {
|
|
1058
|
+
...composableProps(props),
|
|
1059
|
+
orientation: "vertical",
|
|
1060
|
+
centered: true,
|
|
1061
|
+
padding: true,
|
|
1062
|
+
thin: true,
|
|
1063
|
+
ref: forwardedRef
|
|
1064
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, children));
|
|
1065
|
+
});
|
|
1066
|
+
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
1067
|
+
var FORM_CONTENT_NAME = "Form.Content";
|
|
1068
|
+
var FormContent = composable(({ children, ...props }, forwardedRef) => {
|
|
1069
|
+
const { form, testId } = useFormContext(FORM_CONTENT_NAME);
|
|
1070
|
+
const localRef = useRef(null);
|
|
1071
|
+
const mergedRef = useMergeRefs([
|
|
1072
|
+
forwardedRef,
|
|
1073
|
+
localRef
|
|
1074
|
+
]);
|
|
1075
|
+
useKeyHandler(localRef, form);
|
|
1076
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1077
|
+
...composableProps(props, {
|
|
1078
|
+
role: "form",
|
|
1079
|
+
classNames: "flex flex-col w-full pb-form-gap"
|
|
1080
|
+
}),
|
|
1081
|
+
"data-testid": testId,
|
|
1082
|
+
ref: mergedRef
|
|
1114
1083
|
}, children);
|
|
1115
|
-
};
|
|
1116
|
-
FormContent.displayName =
|
|
1117
|
-
var
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1084
|
+
});
|
|
1085
|
+
FormContent.displayName = FORM_CONTENT_NAME;
|
|
1086
|
+
var FORM_FIELDSET_NAME2 = "Form.FieldSet";
|
|
1087
|
+
var FormFieldSet2 = (props) => {
|
|
1088
|
+
const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME2);
|
|
1089
|
+
return /* @__PURE__ */ React4.createElement(FormFieldSet, {
|
|
1121
1090
|
schema: form.schema,
|
|
1091
|
+
...contextProps,
|
|
1122
1092
|
...props
|
|
1123
1093
|
});
|
|
1124
1094
|
};
|
|
1125
|
-
FormFieldSet2.displayName =
|
|
1095
|
+
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1096
|
+
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1126
1097
|
var FormActions = ({ classNames }) => {
|
|
1127
|
-
const { t } =
|
|
1128
|
-
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(
|
|
1098
|
+
const { t } = useTranslation2(translationKey);
|
|
1099
|
+
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1129
1100
|
if (readonly || layout === "static") {
|
|
1130
1101
|
return null;
|
|
1131
1102
|
}
|
|
1132
|
-
return /* @__PURE__ */
|
|
1103
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1133
1104
|
role: "none",
|
|
1134
|
-
className:
|
|
1135
|
-
}, onCancel && /* @__PURE__ */
|
|
1105
|
+
className: mx("grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
|
|
1106
|
+
}, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1136
1107
|
icon: "ph--x--regular",
|
|
1137
1108
|
iconEnd: true,
|
|
1138
|
-
label: t("cancel
|
|
1109
|
+
label: t("cancel-button.label"),
|
|
1139
1110
|
onClick: onCancel,
|
|
1140
1111
|
"data-testid": "cancel-button"
|
|
1141
|
-
}), onSave && /* @__PURE__ */
|
|
1112
|
+
}), onSave && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1142
1113
|
type: "submit",
|
|
1143
1114
|
variant: "primary",
|
|
1144
1115
|
disabled: !canSave,
|
|
1145
1116
|
icon: "ph--check--regular",
|
|
1146
1117
|
iconEnd: true,
|
|
1147
|
-
label: t("save
|
|
1118
|
+
label: t("save-button.label"),
|
|
1148
1119
|
onClick: onSave,
|
|
1149
1120
|
"data-testid": "save-button"
|
|
1150
1121
|
}));
|
|
1151
1122
|
};
|
|
1152
|
-
FormActions.displayName =
|
|
1153
|
-
var
|
|
1154
|
-
|
|
1155
|
-
|
|
1123
|
+
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
1124
|
+
var FORM_SECTION_NAME = "Form.Section";
|
|
1125
|
+
var FormSection = composable(({ children, label, description, ...props }, forwardedRef) => {
|
|
1126
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1127
|
+
...composableProps(props, {
|
|
1128
|
+
classNames: "flex flex-col pt-form-section-gap first:pt-0"
|
|
1129
|
+
}),
|
|
1130
|
+
ref: forwardedRef
|
|
1131
|
+
}, /* @__PURE__ */ React4.createElement("h2", {
|
|
1132
|
+
className: "text-lg"
|
|
1133
|
+
}, label), description && /* @__PURE__ */ React4.createElement("p", {
|
|
1134
|
+
className: "text-description"
|
|
1135
|
+
}, description), children);
|
|
1136
|
+
});
|
|
1137
|
+
FormSection.displayName = FORM_SECTION_NAME;
|
|
1138
|
+
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1139
|
+
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1140
|
+
const { t } = useTranslation2(translationKey);
|
|
1141
|
+
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1156
1142
|
if (readonly || layout === "static") {
|
|
1157
1143
|
return null;
|
|
1158
1144
|
}
|
|
1159
|
-
return /* @__PURE__ */
|
|
1145
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
1160
1146
|
role: "none",
|
|
1161
|
-
className:
|
|
1162
|
-
}, /* @__PURE__ */
|
|
1163
|
-
classNames: "
|
|
1147
|
+
className: mx("flex w-full pt-form-padding", classNames)
|
|
1148
|
+
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1149
|
+
classNames: "w-full",
|
|
1164
1150
|
type: "submit",
|
|
1165
1151
|
variant: "primary",
|
|
1166
|
-
disabled: !canSave,
|
|
1152
|
+
disabled: disabled ?? !canSave,
|
|
1167
1153
|
icon: icon ?? "ph--check--regular",
|
|
1168
|
-
label: label ?? t("save
|
|
1154
|
+
label: label ?? t("save-button.label"),
|
|
1169
1155
|
onClick: onSave,
|
|
1170
1156
|
"data-testid": "save-button"
|
|
1171
1157
|
}));
|
|
1172
1158
|
};
|
|
1173
|
-
FormSubmit.displayName =
|
|
1159
|
+
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
1174
1160
|
var Form = {
|
|
1175
1161
|
Root: FormRoot,
|
|
1176
1162
|
Viewport: FormViewport,
|
|
1177
1163
|
Content: FormContent,
|
|
1164
|
+
Section: FormSection,
|
|
1178
1165
|
FieldSet: FormFieldSet2,
|
|
1166
|
+
Label: FormFieldLabel,
|
|
1179
1167
|
Actions: FormActions,
|
|
1180
|
-
Submit: FormSubmit
|
|
1181
|
-
Label: FormFieldLabel
|
|
1168
|
+
Submit: FormSubmit
|
|
1182
1169
|
};
|
|
1183
1170
|
|
|
1184
1171
|
// src/components/Form/fields/ArrayField.tsx
|
|
1185
1172
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1186
|
-
const { t } =
|
|
1173
|
+
const { t } = useTranslation3(translationKey);
|
|
1187
1174
|
const elementType = getArrayElementType2(type);
|
|
1188
1175
|
const { onValueChange } = inputProps;
|
|
1189
1176
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
1190
1177
|
const getDefaultObjectValue = (typeNode) => {
|
|
1191
1178
|
const baseNode = findNode2(typeNode, isDiscriminatedUnion2);
|
|
1192
|
-
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode,
|
|
1179
|
+
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode2(typeNode, SchemaAST3.isTypeLiteral);
|
|
1193
1180
|
if (!typeLiteral) {
|
|
1194
1181
|
return {};
|
|
1195
1182
|
}
|
|
1196
1183
|
return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
|
|
1197
|
-
const defaultValue =
|
|
1184
|
+
const defaultValue = SchemaAST3.getDefaultAnnotation(prop.type).pipe((annotation) => Option3.getOrUndefined(annotation));
|
|
1198
1185
|
return [
|
|
1199
1186
|
prop.name,
|
|
1200
1187
|
defaultValue
|
|
@@ -1223,19 +1210,19 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1223
1210
|
if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
|
|
1224
1211
|
return null;
|
|
1225
1212
|
}
|
|
1226
|
-
return /* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React5.createElement(FormFieldLabel, {
|
|
1227
1214
|
readonly,
|
|
1228
1215
|
label,
|
|
1229
1216
|
asChild: true
|
|
1230
|
-
}), /* @__PURE__ */
|
|
1217
|
+
}), /* @__PURE__ */ React5.createElement("div", {
|
|
1231
1218
|
role: "none",
|
|
1232
|
-
className: "flex flex-col gap-
|
|
1219
|
+
className: "flex flex-col gap-form-gap"
|
|
1233
1220
|
}, values?.map((_, index) => {
|
|
1234
|
-
return /* @__PURE__ */
|
|
1221
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1235
1222
|
role: "none",
|
|
1236
1223
|
key: index,
|
|
1237
|
-
className: "
|
|
1238
|
-
}, /* @__PURE__ */
|
|
1224
|
+
className: "flex gap-form-gap last:mb-form-gap items-center"
|
|
1225
|
+
}, /* @__PURE__ */ React5.createElement(FormField, {
|
|
1239
1226
|
autoFocus: index === values.length - 1,
|
|
1240
1227
|
type: elementType,
|
|
1241
1228
|
path: [
|
|
@@ -1245,23 +1232,23 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1245
1232
|
readonly: readonly || layout === "static",
|
|
1246
1233
|
layout: "inline",
|
|
1247
1234
|
...props
|
|
1248
|
-
}), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1235
|
+
}), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
|
|
1249
1236
|
role: "none",
|
|
1250
|
-
className: "flex flex-col
|
|
1251
|
-
}, /* @__PURE__ */
|
|
1237
|
+
className: "flex flex-col h-full justify-end"
|
|
1238
|
+
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1252
1239
|
role: "none",
|
|
1253
|
-
className: "flex items-center
|
|
1254
|
-
}, /* @__PURE__ */
|
|
1240
|
+
className: "flex items-center h-[2rem]"
|
|
1241
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1255
1242
|
icon: "ph--x--regular",
|
|
1256
1243
|
iconOnly: true,
|
|
1257
|
-
label: t("button
|
|
1244
|
+
label: t("remove.button"),
|
|
1258
1245
|
onClick: () => handleDelete(index),
|
|
1259
1246
|
classNames: "self-center"
|
|
1260
1247
|
}))));
|
|
1261
|
-
})), !readonly && layout !== "static" && /* @__PURE__ */
|
|
1262
|
-
classNames: "flex
|
|
1248
|
+
})), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1249
|
+
classNames: "flex w-full",
|
|
1263
1250
|
icon: "ph--plus--regular",
|
|
1264
|
-
label: t("add
|
|
1251
|
+
label: t("add-field.button"),
|
|
1265
1252
|
onClick: handleAdd
|
|
1266
1253
|
}));
|
|
1267
1254
|
};
|
|
@@ -1277,6 +1264,9 @@ var getDefaultValue = (ast) => {
|
|
|
1277
1264
|
case "BooleanKeyword": {
|
|
1278
1265
|
return false;
|
|
1279
1266
|
}
|
|
1267
|
+
case "Suspend": {
|
|
1268
|
+
return getDefaultValue(ast.f());
|
|
1269
|
+
}
|
|
1280
1270
|
default: {
|
|
1281
1271
|
if (ast && isNestedType2(ast)) {
|
|
1282
1272
|
return {};
|
|
@@ -1288,17 +1278,17 @@ var getDefaultValue = (ast) => {
|
|
|
1288
1278
|
};
|
|
1289
1279
|
|
|
1290
1280
|
// src/components/Form/fields/BooleanField.tsx
|
|
1291
|
-
import
|
|
1292
|
-
import { Input as
|
|
1281
|
+
import React6, { useCallback as useCallback4 } from "react";
|
|
1282
|
+
import { Input as Input2 } from "@dxos/react-ui";
|
|
1293
1283
|
var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
1294
1284
|
const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
|
|
1295
1285
|
type,
|
|
1296
1286
|
onValueChange
|
|
1297
1287
|
]);
|
|
1298
|
-
return /* @__PURE__ */
|
|
1288
|
+
return /* @__PURE__ */ React6.createElement(FormFieldWrapper, {
|
|
1299
1289
|
readonly,
|
|
1300
1290
|
...props
|
|
1301
|
-
}, ({ value: value3 }) => /* @__PURE__ */
|
|
1291
|
+
}, ({ value: value3 }) => /* @__PURE__ */ React6.createElement(Input2.Switch, {
|
|
1302
1292
|
disabled: !!readonly,
|
|
1303
1293
|
checked: value3,
|
|
1304
1294
|
onCheckedChange: handleChange
|
|
@@ -1306,12 +1296,12 @@ var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
|
1306
1296
|
};
|
|
1307
1297
|
|
|
1308
1298
|
// src/components/Form/fields/GeoPointField.tsx
|
|
1309
|
-
import
|
|
1299
|
+
import React7, { useCallback as useCallback5, useEffect as useEffect3, useMemo as useMemo5, useState as useState2 } from "react";
|
|
1310
1300
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1311
|
-
import { Input as
|
|
1301
|
+
import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1312
1302
|
import { safeParseFloat } from "@dxos/util";
|
|
1313
1303
|
var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1314
|
-
const { t } =
|
|
1304
|
+
const { t } = useTranslation4(translationKey);
|
|
1315
1305
|
const { status, error } = getStatus();
|
|
1316
1306
|
const geoPoint = useMemo5(() => getValue() ?? [
|
|
1317
1307
|
0,
|
|
@@ -1324,7 +1314,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1324
1314
|
]);
|
|
1325
1315
|
const [longitudeText, setLongitudeText] = useState2(value3.longitude?.toString());
|
|
1326
1316
|
const [latitudeText, setLatitudeText] = useState2(value3.latitude?.toString());
|
|
1327
|
-
|
|
1317
|
+
useEffect3(() => {
|
|
1328
1318
|
const location = GeoLocation3.fromGeoPoint(geoPoint);
|
|
1329
1319
|
setLongitudeText(location.longitude?.toString());
|
|
1330
1320
|
setLatitudeText(location.latitude?.toString());
|
|
@@ -1357,33 +1347,33 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1357
1347
|
if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
|
|
1358
1348
|
return null;
|
|
1359
1349
|
}
|
|
1360
|
-
return /* @__PURE__ */
|
|
1350
|
+
return /* @__PURE__ */ React7.createElement(Input3.Root, {
|
|
1361
1351
|
validationValence: status
|
|
1362
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1352
|
+
}, layout !== "inline" && /* @__PURE__ */ React7.createElement(FormFieldLabel, {
|
|
1363
1353
|
error,
|
|
1364
1354
|
readonly,
|
|
1365
1355
|
label,
|
|
1366
1356
|
asChild: true
|
|
1367
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1357
|
+
}), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
|
|
1368
1358
|
role: "none",
|
|
1369
|
-
className: "grid grid-cols-2 gap-
|
|
1370
|
-
}, /* @__PURE__ */
|
|
1359
|
+
className: "grid grid-cols-2 gap-form-gap"
|
|
1360
|
+
}, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("latitude.label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
|
|
1371
1361
|
type: "number",
|
|
1372
1362
|
step: "0.00001",
|
|
1373
1363
|
min: "-90",
|
|
1374
1364
|
max: "90",
|
|
1375
1365
|
disabled: !!readonly,
|
|
1376
|
-
placeholder: t("latitude
|
|
1366
|
+
placeholder: t("latitude.placeholder"),
|
|
1377
1367
|
value: latitudeText ?? "",
|
|
1378
1368
|
onChange: handleChange("latitude", setLatitudeText),
|
|
1379
1369
|
onBlur
|
|
1380
|
-
}))), /* @__PURE__ */
|
|
1370
|
+
}))), /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("longitude.label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
|
|
1381
1371
|
type: "number",
|
|
1382
1372
|
step: "0.00001",
|
|
1383
1373
|
min: "-180",
|
|
1384
1374
|
max: "180",
|
|
1385
1375
|
disabled: !!readonly,
|
|
1386
|
-
placeholder: t("longitude
|
|
1376
|
+
placeholder: t("longitude.placeholder"),
|
|
1387
1377
|
value: longitudeText ?? "",
|
|
1388
1378
|
onChange: handleChange("longitude", setLongitudeText),
|
|
1389
1379
|
onBlur
|
|
@@ -1392,18 +1382,18 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1392
1382
|
var LatLng = ({ latitude = 0, longitude = 0 }) => {
|
|
1393
1383
|
const latHem = latitude >= 0 ? "N" : "S";
|
|
1394
1384
|
const lngHem = longitude >= 0 ? "E" : "W";
|
|
1395
|
-
return /* @__PURE__ */
|
|
1396
|
-
className: "inline-flex items-center gap-
|
|
1397
|
-
}, /* @__PURE__ */
|
|
1385
|
+
return /* @__PURE__ */ React7.createElement("span", {
|
|
1386
|
+
className: "inline-flex items-center gap-form-gap"
|
|
1387
|
+
}, /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1398
1388
|
className: "text-subdued"
|
|
1399
|
-
}, "\xB0", latHem)), /* @__PURE__ */
|
|
1389
|
+
}, "\xB0", latHem)), /* @__PURE__ */ React7.createElement("span", null, /* @__PURE__ */ React7.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React7.createElement("span", {
|
|
1400
1390
|
className: "text-subdued"
|
|
1401
1391
|
}, "\xB0", lngHem)));
|
|
1402
1392
|
};
|
|
1403
1393
|
|
|
1404
1394
|
// src/components/Form/fields/MarkdownField.tsx
|
|
1405
|
-
import
|
|
1406
|
-
import { Input as
|
|
1395
|
+
import React8, { useCallback as useCallback6, useEffect as useEffect4, useRef as useRef2 } from "react";
|
|
1396
|
+
import { Input as Input4 } from "@dxos/react-ui";
|
|
1407
1397
|
var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1408
1398
|
const { status, error } = getStatus();
|
|
1409
1399
|
const textareaRef = useRef2(null);
|
|
@@ -1414,12 +1404,12 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
|
|
|
1414
1404
|
textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
|
|
1415
1405
|
}
|
|
1416
1406
|
}, []);
|
|
1417
|
-
|
|
1407
|
+
useEffect4(() => {
|
|
1418
1408
|
adjustHeight();
|
|
1419
1409
|
}, [
|
|
1420
1410
|
adjustHeight
|
|
1421
1411
|
]);
|
|
1422
|
-
|
|
1412
|
+
useEffect4(() => {
|
|
1423
1413
|
adjustHeight();
|
|
1424
1414
|
}, [
|
|
1425
1415
|
getValue(),
|
|
@@ -1433,40 +1423,40 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, getStatus, ge
|
|
|
1433
1423
|
if ((readonly || layout === "static") && !value3) {
|
|
1434
1424
|
return null;
|
|
1435
1425
|
}
|
|
1436
|
-
return /* @__PURE__ */
|
|
1426
|
+
return /* @__PURE__ */ React8.createElement(Input4.Root, {
|
|
1437
1427
|
validationValence: status
|
|
1438
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1428
|
+
}, layout !== "inline" && /* @__PURE__ */ React8.createElement(FormFieldLabel, {
|
|
1439
1429
|
error,
|
|
1440
1430
|
readonly,
|
|
1441
1431
|
label
|
|
1442
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1432
|
+
}), layout === "static" ? /* @__PURE__ */ React8.createElement("p", null, value3) : /* @__PURE__ */ React8.createElement(Input4.TextArea, {
|
|
1443
1433
|
ref: textareaRef,
|
|
1444
1434
|
disabled: !!readonly,
|
|
1445
1435
|
placeholder,
|
|
1446
1436
|
value: value3 ?? "",
|
|
1447
|
-
classNames: "min-
|
|
1437
|
+
classNames: "min-h-auto max-h-40 overflow-auto",
|
|
1448
1438
|
onChange: handleChange,
|
|
1449
1439
|
onBlur,
|
|
1450
1440
|
style: {
|
|
1451
1441
|
resize: "none"
|
|
1452
1442
|
},
|
|
1453
1443
|
spellCheck: false
|
|
1454
|
-
}), layout === "full" && /* @__PURE__ */
|
|
1444
|
+
}), layout === "full" && /* @__PURE__ */ React8.createElement(Input4.Validation, null, error));
|
|
1455
1445
|
};
|
|
1456
1446
|
|
|
1457
1447
|
// src/components/Form/fields/NumberField.tsx
|
|
1458
|
-
import
|
|
1459
|
-
import { Input as
|
|
1448
|
+
import React9, { useCallback as useCallback7 } from "react";
|
|
1449
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
1460
1450
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
1461
1451
|
var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1462
1452
|
const handleChange = useCallback7((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
|
|
1463
1453
|
type,
|
|
1464
1454
|
onValueChange
|
|
1465
1455
|
]);
|
|
1466
|
-
return /* @__PURE__ */
|
|
1456
|
+
return /* @__PURE__ */ React9.createElement(FormFieldWrapper, {
|
|
1467
1457
|
readonly,
|
|
1468
1458
|
...props
|
|
1469
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1459
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React9.createElement(Input5.TextInput, {
|
|
1470
1460
|
type: "number",
|
|
1471
1461
|
disabled: !!readonly,
|
|
1472
1462
|
placeholder,
|
|
@@ -1477,40 +1467,24 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
|
|
|
1477
1467
|
};
|
|
1478
1468
|
|
|
1479
1469
|
// src/components/Form/fields/RefField.tsx
|
|
1470
|
+
import React11, { useCallback as useCallback9, useMemo as useMemo6 } from "react";
|
|
1480
1471
|
import "@dxos/lit-ui/dx-tag-picker.pcss";
|
|
1481
|
-
import
|
|
1482
|
-
import { Entity, Filter, Ref as Ref2 } from "@dxos/echo";
|
|
1483
|
-
import { ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
1472
|
+
import { Entity, Filter, Obj, Ref as Ref2, Type } from "@dxos/echo";
|
|
1484
1473
|
import { useQuery, useSchema as useSchema$ } from "@dxos/echo-react";
|
|
1485
|
-
import {
|
|
1474
|
+
import { ReferenceAnnotationId as ReferenceAnnotationId2 } from "@dxos/echo/internal";
|
|
1475
|
+
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
1486
1476
|
import { DXN } from "@dxos/keys";
|
|
1487
1477
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1488
|
-
import { Button
|
|
1489
|
-
import {
|
|
1478
|
+
import { Button, Icon as Icon2, Input as Input6, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1479
|
+
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
1480
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1490
1481
|
|
|
1491
1482
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1492
|
-
import
|
|
1493
|
-
import { Popover, useTranslation as
|
|
1494
|
-
import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-
|
|
1495
|
-
var
|
|
1496
|
-
const { t } =
|
|
1497
|
-
const { query } = useSearchListInput();
|
|
1498
|
-
return /* @__PURE__ */ React11.createElement(Combobox.Item, {
|
|
1499
|
-
value: "__create__",
|
|
1500
|
-
label: t(createOptionLabel[0], {
|
|
1501
|
-
ns: createOptionLabel[1].ns,
|
|
1502
|
-
text: query
|
|
1503
|
-
}),
|
|
1504
|
-
icon: createOptionIcon,
|
|
1505
|
-
classNames: "flex items-center gap-2",
|
|
1506
|
-
closeOnSelect: false,
|
|
1507
|
-
onSelect: () => {
|
|
1508
|
-
onCreateItemSelect(query);
|
|
1509
|
-
}
|
|
1510
|
-
});
|
|
1511
|
-
};
|
|
1512
|
-
var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, onSelect, onCreate, ...props }, ref) => {
|
|
1513
|
-
const { t } = useTranslation6(translationKey);
|
|
1483
|
+
import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
|
|
1484
|
+
import { Popover, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1485
|
+
import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-search";
|
|
1486
|
+
var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, onSelect, onCreate, ...props }, forwardedRef) => {
|
|
1487
|
+
const { t } = useTranslation5(translationKey);
|
|
1514
1488
|
const [showForm, setShowForm] = useState3(false);
|
|
1515
1489
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1516
1490
|
const { results, handleSearch } = useSearchListResults({
|
|
@@ -1539,39 +1513,66 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef2(({ options, selectedIds, c
|
|
|
1539
1513
|
}, [
|
|
1540
1514
|
createSchema
|
|
1541
1515
|
]);
|
|
1542
|
-
|
|
1516
|
+
if (showForm && createSchema) {
|
|
1517
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1518
|
+
...props,
|
|
1519
|
+
onSearch: handleSearch,
|
|
1520
|
+
onKeyDownCapture: handleKeyDown,
|
|
1521
|
+
ref: forwardedRef
|
|
1522
|
+
}, /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
|
|
1523
|
+
testId: "create-referenced-object-form",
|
|
1524
|
+
schema: createSchema,
|
|
1525
|
+
defaultValues: createInitialValuePath ? {
|
|
1526
|
+
[createInitialValuePath]: formInitialValue
|
|
1527
|
+
} : {},
|
|
1528
|
+
fieldMap: createFieldMap3,
|
|
1529
|
+
onSave: handleFormSave,
|
|
1530
|
+
onCancel: handleFormCancel
|
|
1531
|
+
}, /* @__PURE__ */ React10.createElement(Form.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Content, null, /* @__PURE__ */ React10.createElement(Form.FieldSet, null), /* @__PURE__ */ React10.createElement(Form.Actions, null))))), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1532
|
+
}
|
|
1533
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1543
1534
|
...props,
|
|
1544
|
-
ref,
|
|
1545
1535
|
onSearch: handleSearch,
|
|
1546
|
-
onKeyDownCapture: handleKeyDown
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
values: createInitialValuePath ? {
|
|
1551
|
-
[createInitialValuePath]: formInitialValue
|
|
1552
|
-
} : {},
|
|
1553
|
-
onSave: handleFormSave,
|
|
1554
|
-
onCancel: handleFormCancel
|
|
1555
|
-
}, /* @__PURE__ */ React11.createElement(Form.Viewport, null, /* @__PURE__ */ React11.createElement(Form.Content, null, /* @__PURE__ */ React11.createElement(Form.FieldSet, null), /* @__PURE__ */ React11.createElement(Form.Actions, null))))) : /* @__PURE__ */ React11.createElement(React11.Fragment, null, /* @__PURE__ */ React11.createElement(Combobox.Input, {
|
|
1556
|
-
placeholder: t("ref field combobox input placeholder"),
|
|
1536
|
+
onKeyDownCapture: handleKeyDown,
|
|
1537
|
+
ref: forwardedRef
|
|
1538
|
+
}, /* @__PURE__ */ React10.createElement(Combobox.Input, {
|
|
1539
|
+
placeholder: t("ref-field-combobox-input.placeholder"),
|
|
1557
1540
|
autoFocus: true
|
|
1558
|
-
}), /* @__PURE__ */
|
|
1541
|
+
}), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1559
1542
|
key: option.id,
|
|
1560
1543
|
value: option.id,
|
|
1561
1544
|
label: option.label,
|
|
1562
1545
|
checked: selectedIds?.includes(option.id),
|
|
1563
1546
|
onSelect: () => onSelect(option.id),
|
|
1564
1547
|
classNames: "flex items-center gap-2"
|
|
1565
|
-
})),
|
|
1548
|
+
})), createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
|
|
1566
1549
|
createOptionLabel,
|
|
1567
|
-
createOptionIcon,
|
|
1550
|
+
createOptionIcon: createOptionIcon ?? "ph--plus--regular",
|
|
1568
1551
|
onCreateItemSelect: (query) => {
|
|
1569
1552
|
setFormInitialValue(query);
|
|
1570
1553
|
setShowForm(true);
|
|
1571
1554
|
}
|
|
1572
|
-
}))
|
|
1555
|
+
})), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1573
1556
|
});
|
|
1574
|
-
|
|
1557
|
+
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1558
|
+
const { t } = useTranslation5(translationKey);
|
|
1559
|
+
const { query } = useSearchListInput();
|
|
1560
|
+
const label = createOptionLabel ? t(createOptionLabel[0], {
|
|
1561
|
+
ns: createOptionLabel[1].ns,
|
|
1562
|
+
text: query
|
|
1563
|
+
}) : t("create-option.label");
|
|
1564
|
+
return /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1565
|
+
value: "__create__",
|
|
1566
|
+
label,
|
|
1567
|
+
icon: createOptionIcon,
|
|
1568
|
+
classNames: "flex items-center gap-2",
|
|
1569
|
+
closeOnSelect: false,
|
|
1570
|
+
onSelect: () => {
|
|
1571
|
+
onCreateItemSelect(query);
|
|
1572
|
+
}
|
|
1573
|
+
});
|
|
1574
|
+
};
|
|
1575
|
+
ObjectPickerContent.displayName = "ObjectPicker.Content";
|
|
1575
1576
|
var ObjectPicker = {
|
|
1576
1577
|
Root: Combobox.Root,
|
|
1577
1578
|
Portal: Combobox.Portal,
|
|
@@ -1584,26 +1585,33 @@ var ObjectPicker = {
|
|
|
1584
1585
|
var isRefSnapshot = (val) => {
|
|
1585
1586
|
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1586
1587
|
};
|
|
1587
|
-
var defaultGetOptions = (results) => results.map((result) => {
|
|
1588
|
+
var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
|
|
1588
1589
|
const id = Entity.getDXN(result).toString();
|
|
1589
|
-
const
|
|
1590
|
+
const parent = parentLabel ? Obj.getParent(result) : void 0;
|
|
1591
|
+
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
|
|
1590
1592
|
return {
|
|
1591
1593
|
id,
|
|
1592
1594
|
label: label ?? id
|
|
1593
1595
|
};
|
|
1594
1596
|
});
|
|
1595
|
-
var defaultResultsHook = (db, typename) => useQuery(db, typename ? Filter.typename(typename) : Filter.nothing());
|
|
1597
|
+
var defaultResultsHook = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1596
1598
|
var RefField = (props) => {
|
|
1597
|
-
const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, db, resultsHook: useResults = defaultResultsHook, schemaHook: useSchema = useSchema$, getOptions
|
|
1598
|
-
const { t } =
|
|
1599
|
+
const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, resultsHook: useResults = defaultResultsHook, schemaHook: useSchema = useSchema$, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
|
|
1600
|
+
const { t } = useTranslation6(translationKey);
|
|
1599
1601
|
const { status, error } = getStatus();
|
|
1600
|
-
const typename = useMemo6(() => type ?
|
|
1602
|
+
const typename = useMemo6(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
|
|
1601
1603
|
type
|
|
1602
1604
|
]);
|
|
1603
1605
|
const results = useResults(db, typename);
|
|
1604
|
-
const options = useMemo6(() =>
|
|
1606
|
+
const options = useMemo6(() => {
|
|
1607
|
+
const parentLabel = type ? findAnnotation2(type, ParentLabelAnnotationId) === true : false;
|
|
1608
|
+
return getOptions(results, {
|
|
1609
|
+
parentLabel
|
|
1610
|
+
});
|
|
1611
|
+
}, [
|
|
1605
1612
|
results,
|
|
1606
|
-
|
|
1613
|
+
getOptions,
|
|
1614
|
+
type
|
|
1607
1615
|
]);
|
|
1608
1616
|
const handleGetValue = useCallback9(() => {
|
|
1609
1617
|
const formValue = getValue();
|
|
@@ -1660,55 +1668,56 @@ var RefField = (props) => {
|
|
|
1660
1668
|
if (!typename || (readonly || layout === "static") && !item) {
|
|
1661
1669
|
return null;
|
|
1662
1670
|
}
|
|
1663
|
-
return /* @__PURE__ */
|
|
1671
|
+
return /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1664
1672
|
validationValence: status
|
|
1665
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1673
|
+
}, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
|
|
1666
1674
|
error,
|
|
1667
1675
|
readonly,
|
|
1668
1676
|
label
|
|
1669
|
-
}), /* @__PURE__ */
|
|
1670
|
-
className:
|
|
1671
|
-
}, t("empty
|
|
1677
|
+
}), /* @__PURE__ */ React11.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React11.createElement("p", {
|
|
1678
|
+
className: mx2("text-description", "mb-2")
|
|
1679
|
+
}, t("empty-readonly-ref-field.label")) : /* @__PURE__ */ React11.createElement(DxAnchor, {
|
|
1672
1680
|
key: item.id,
|
|
1673
|
-
|
|
1674
|
-
rootclassname: "
|
|
1675
|
-
}, item.label) : /* @__PURE__ */
|
|
1681
|
+
dxn: item.id,
|
|
1682
|
+
rootclassname: "me-1"
|
|
1683
|
+
}, item.label) : /* @__PURE__ */ React11.createElement(ObjectPicker.Root, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Trigger, {
|
|
1676
1684
|
asChild: true,
|
|
1677
1685
|
classNames: "p-0"
|
|
1678
|
-
}, item ? /* @__PURE__ */
|
|
1679
|
-
className: "flex gap-
|
|
1680
|
-
}, /* @__PURE__ */
|
|
1686
|
+
}, item ? /* @__PURE__ */ React11.createElement("div", {
|
|
1687
|
+
className: "flex gap-form-gap w-full"
|
|
1688
|
+
}, /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1681
1689
|
key: item.id
|
|
1682
|
-
}, /* @__PURE__ */
|
|
1690
|
+
}, /* @__PURE__ */ React11.createElement(Input6.TextInput, {
|
|
1683
1691
|
value: item.label,
|
|
1684
1692
|
readOnly: true,
|
|
1685
|
-
classNames: "
|
|
1686
|
-
}))) : /* @__PURE__ */
|
|
1687
|
-
classNames: "
|
|
1688
|
-
}, /* @__PURE__ */
|
|
1693
|
+
classNames: "w-full"
|
|
1694
|
+
}))) : /* @__PURE__ */ React11.createElement(Button, {
|
|
1695
|
+
classNames: "w-full text-start gap-form-gap"
|
|
1696
|
+
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1689
1697
|
role: "none",
|
|
1690
1698
|
className: "grow overflow-hidden"
|
|
1691
|
-
}, /* @__PURE__ */
|
|
1699
|
+
}, /* @__PURE__ */ React11.createElement("span", {
|
|
1692
1700
|
className: "flex truncate text-description"
|
|
1693
|
-
}, placeholder ?? t("ref
|
|
1701
|
+
}, placeholder ?? t("ref-field.placeholder"))), /* @__PURE__ */ React11.createElement(Icon2, {
|
|
1694
1702
|
size: 3,
|
|
1695
1703
|
icon: "ph--caret-down--bold"
|
|
1696
|
-
}))), /* @__PURE__ */
|
|
1697
|
-
classNames: "
|
|
1704
|
+
}))), /* @__PURE__ */ React11.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React11.createElement(ObjectPicker.Content, {
|
|
1705
|
+
classNames: "dx-card-popover-width",
|
|
1698
1706
|
options,
|
|
1699
1707
|
selectedIds,
|
|
1700
1708
|
createSchema: createSchema && omitId(createSchema),
|
|
1701
1709
|
createOptionLabel,
|
|
1702
1710
|
createOptionIcon,
|
|
1703
1711
|
createInitialValuePath,
|
|
1712
|
+
createFieldMap: createFieldMap3,
|
|
1704
1713
|
onCreate: handleCreate,
|
|
1705
1714
|
onSelect: handleSelect
|
|
1706
|
-
})))), layout === "full" && /* @__PURE__ */
|
|
1715
|
+
})))), layout === "full" && /* @__PURE__ */ React11.createElement(Input6.DescriptionAndValidation, null, error));
|
|
1707
1716
|
};
|
|
1708
1717
|
|
|
1709
1718
|
// src/components/Form/fields/SelectField.tsx
|
|
1710
|
-
import
|
|
1711
|
-
import { Input as
|
|
1719
|
+
import React12, { useCallback as useCallback10 } from "react";
|
|
1720
|
+
import { Input as Input7, Select } from "@dxos/react-ui";
|
|
1712
1721
|
var SelectField = ({ type, readonly, label, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
|
|
1713
1722
|
const { status, error } = getStatus();
|
|
1714
1723
|
const value3 = getValue();
|
|
@@ -1719,43 +1728,43 @@ var SelectField = ({ type, readonly, label, layout, placeholder, options, getSta
|
|
|
1719
1728
|
if ((readonly || layout === "static") && value3 == null) {
|
|
1720
1729
|
return null;
|
|
1721
1730
|
}
|
|
1722
|
-
return /* @__PURE__ */
|
|
1731
|
+
return /* @__PURE__ */ React12.createElement(Input7.Root, {
|
|
1723
1732
|
validationValence: status
|
|
1724
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1733
|
+
}, layout !== "inline" && /* @__PURE__ */ React12.createElement(FormFieldLabel, {
|
|
1725
1734
|
error,
|
|
1726
1735
|
readonly,
|
|
1727
1736
|
label
|
|
1728
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1737
|
+
}), layout === "static" ? /* @__PURE__ */ React12.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React12.createElement(Select.Root, {
|
|
1729
1738
|
value: value3,
|
|
1730
1739
|
onValueChange: handleValueChange
|
|
1731
|
-
}, /* @__PURE__ */
|
|
1732
|
-
classNames: "
|
|
1740
|
+
}, /* @__PURE__ */ React12.createElement(Select.TriggerButton, {
|
|
1741
|
+
classNames: "w-full",
|
|
1733
1742
|
disabled: !!readonly,
|
|
1734
1743
|
placeholder
|
|
1735
|
-
}), /* @__PURE__ */
|
|
1744
|
+
}), /* @__PURE__ */ React12.createElement(Select.Portal, null, /* @__PURE__ */ React12.createElement(Select.Content, null, /* @__PURE__ */ React12.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2 }) => (
|
|
1736
1745
|
// NOTE: Numeric values are converted to and from strings.
|
|
1737
|
-
/* @__PURE__ */
|
|
1746
|
+
/* @__PURE__ */ React12.createElement(Select.Option, {
|
|
1738
1747
|
key: String(value4),
|
|
1739
1748
|
value: String(value4)
|
|
1740
1749
|
}, label2 ?? String(value4))
|
|
1741
|
-
))), /* @__PURE__ */
|
|
1750
|
+
))), /* @__PURE__ */ React12.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React12.createElement(Input7.DescriptionAndValidation, null, error));
|
|
1742
1751
|
};
|
|
1743
1752
|
|
|
1744
1753
|
// src/components/Form/fields/SelectOptionField.tsx
|
|
1745
|
-
import
|
|
1754
|
+
import React13, { useCallback as useCallback11, useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
|
|
1746
1755
|
import { PublicKey } from "@dxos/keys";
|
|
1747
|
-
import { IconButton as IconButton3, Input as
|
|
1756
|
+
import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1748
1757
|
import { List } from "@dxos/react-ui-list";
|
|
1749
1758
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1750
1759
|
import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
|
|
1751
1760
|
var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
|
|
1752
|
-
const { t } =
|
|
1761
|
+
const { t } = useTranslation7(translationKey);
|
|
1753
1762
|
const { status, error } = getStatus();
|
|
1754
1763
|
const [selected, setSelectedId] = useState4(null);
|
|
1755
1764
|
const [isNewOption, setIsNewOption] = useState4(false);
|
|
1756
1765
|
const inputRef = useRef3(null);
|
|
1757
1766
|
const options = getValue();
|
|
1758
|
-
|
|
1767
|
+
useEffect5(() => {
|
|
1759
1768
|
if (options === void 0) {
|
|
1760
1769
|
onValueChange(type, []);
|
|
1761
1770
|
}
|
|
@@ -1846,7 +1855,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1846
1855
|
type,
|
|
1847
1856
|
onValueChange
|
|
1848
1857
|
]);
|
|
1849
|
-
|
|
1858
|
+
useEffect5(() => {
|
|
1850
1859
|
if (selected && isNewOption && inputRef.current) {
|
|
1851
1860
|
inputRef.current.focus();
|
|
1852
1861
|
setIsNewOption(false);
|
|
@@ -1855,42 +1864,42 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1855
1864
|
selected,
|
|
1856
1865
|
isNewOption
|
|
1857
1866
|
]);
|
|
1858
|
-
return /* @__PURE__ */
|
|
1867
|
+
return /* @__PURE__ */ React13.createElement(Input8.Root, {
|
|
1859
1868
|
validationValence: status
|
|
1860
|
-
}, /* @__PURE__ */
|
|
1869
|
+
}, /* @__PURE__ */ React13.createElement(FormFieldLabel, {
|
|
1861
1870
|
error,
|
|
1862
1871
|
readonly,
|
|
1863
1872
|
label
|
|
1864
|
-
}), /* @__PURE__ */
|
|
1873
|
+
}), /* @__PURE__ */ React13.createElement("div", {
|
|
1865
1874
|
role: "none"
|
|
1866
|
-
}, options && /* @__PURE__ */
|
|
1875
|
+
}, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
1867
1876
|
items: options,
|
|
1868
1877
|
isItem: (_item) => true,
|
|
1869
1878
|
onMove: readonly ? void 0 : handleMove,
|
|
1870
1879
|
readonly: !!readonly
|
|
1871
|
-
}, ({ items }) => /* @__PURE__ */
|
|
1880
|
+
}, ({ items }) => /* @__PURE__ */ React13.createElement("div", {
|
|
1872
1881
|
role: "list",
|
|
1873
|
-
className: "
|
|
1874
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
1882
|
+
className: "w-full overflow-auto"
|
|
1883
|
+
}, items?.map((item) => /* @__PURE__ */ React13.createElement("div", {
|
|
1875
1884
|
key: item.id
|
|
1876
|
-
}, /* @__PURE__ */
|
|
1885
|
+
}, /* @__PURE__ */ React13.createElement(List.Item, {
|
|
1877
1886
|
role: "button",
|
|
1878
1887
|
item,
|
|
1879
1888
|
classNames: [
|
|
1880
1889
|
subtleHover,
|
|
1881
|
-
"flex flex-col cursor-pointer rounded-
|
|
1890
|
+
"flex flex-col cursor-pointer rounded-xs"
|
|
1882
1891
|
],
|
|
1883
1892
|
"aria-expanded": selected === item.id
|
|
1884
|
-
}, /* @__PURE__ */
|
|
1893
|
+
}, /* @__PURE__ */ React13.createElement("div", {
|
|
1885
1894
|
className: "flex items-center"
|
|
1886
|
-
}, /* @__PURE__ */
|
|
1895
|
+
}, /* @__PURE__ */ React13.createElement(List.ItemDragHandle, {
|
|
1887
1896
|
disabled: !!readonly
|
|
1888
|
-
}), /* @__PURE__ */
|
|
1897
|
+
}), /* @__PURE__ */ React13.createElement(List.ItemTitle, {
|
|
1889
1898
|
onClick: () => handleClick(item.id),
|
|
1890
1899
|
classNames: "flex-1"
|
|
1891
|
-
}, /* @__PURE__ */
|
|
1900
|
+
}, /* @__PURE__ */ React13.createElement(Tag, {
|
|
1892
1901
|
palette: item.color
|
|
1893
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
1902
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1894
1903
|
iconOnly: true,
|
|
1895
1904
|
variant: "ghost",
|
|
1896
1905
|
label: t(selected === item.id ? "collapse label" : "expand label", {
|
|
@@ -1898,52 +1907,52 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1898
1907
|
}),
|
|
1899
1908
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
1900
1909
|
onClick: () => handleClick(item.id)
|
|
1901
|
-
})), selected === item.id && /* @__PURE__ */
|
|
1902
|
-
className: "
|
|
1903
|
-
}, /* @__PURE__ */
|
|
1910
|
+
})), selected === item.id && /* @__PURE__ */ React13.createElement("div", {
|
|
1911
|
+
className: "flex flex-col p-form-padding gap-form-gap dx-density-fine"
|
|
1912
|
+
}, /* @__PURE__ */ React13.createElement(Input8.Label, {
|
|
1904
1913
|
classNames: "text-xs"
|
|
1905
|
-
}, t("select
|
|
1906
|
-
className: "grid grid-cols-[1fr_min-content_min-content] gap-
|
|
1907
|
-
}, /* @__PURE__ */
|
|
1914
|
+
}, t("select-option.label")), /* @__PURE__ */ React13.createElement("div", {
|
|
1915
|
+
className: "grid grid-cols-[1fr_min-content_min-content] gap-form-gap"
|
|
1916
|
+
}, /* @__PURE__ */ React13.createElement(Input8.TextInput, {
|
|
1908
1917
|
disabled: !!readonly,
|
|
1909
|
-
placeholder: t("select
|
|
1918
|
+
placeholder: t("select-option-label.placeholder"),
|
|
1910
1919
|
ref: selected === item.id ? inputRef : void 0,
|
|
1911
1920
|
value: item.title,
|
|
1912
1921
|
onChange: handleTitleChange(item.id),
|
|
1913
1922
|
onKeyDown: handleKeyDown,
|
|
1914
1923
|
classNames: "flex-1"
|
|
1915
|
-
}), /* @__PURE__ */
|
|
1924
|
+
}), /* @__PURE__ */ React13.createElement(HuePicker, {
|
|
1916
1925
|
disabled: !!readonly,
|
|
1917
1926
|
value: item.color,
|
|
1918
1927
|
onChange: handleColorChange(item.id)
|
|
1919
|
-
}), /* @__PURE__ */
|
|
1928
|
+
}), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1920
1929
|
disabled: !!readonly,
|
|
1921
1930
|
icon: "ph--trash--fill",
|
|
1922
1931
|
iconOnly: true,
|
|
1923
|
-
label: t("select
|
|
1932
|
+
label: t("select-option-delete.button"),
|
|
1924
1933
|
onClick: () => handleDelete(item.id)
|
|
1925
|
-
})))))), /* @__PURE__ */
|
|
1934
|
+
})))))), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
1926
1935
|
variant: "ghost",
|
|
1927
1936
|
icon: "ph--plus--regular",
|
|
1928
|
-
label: t("select
|
|
1937
|
+
label: t("select-option-add.button"),
|
|
1929
1938
|
onClick: handleAdd,
|
|
1930
1939
|
disabled: !!readonly,
|
|
1931
|
-
classNames: "
|
|
1940
|
+
classNames: "w-full"
|
|
1932
1941
|
})))));
|
|
1933
1942
|
};
|
|
1934
1943
|
|
|
1935
1944
|
// src/components/Form/fields/TextField.tsx
|
|
1936
|
-
import
|
|
1937
|
-
import { Input as
|
|
1945
|
+
import React14, { useCallback as useCallback12 } from "react";
|
|
1946
|
+
import { Input as Input9 } from "@dxos/react-ui";
|
|
1938
1947
|
var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1939
1948
|
const handleChange = useCallback12((event) => onValueChange(type, event.target.value), [
|
|
1940
1949
|
type,
|
|
1941
1950
|
onValueChange
|
|
1942
1951
|
]);
|
|
1943
|
-
return /* @__PURE__ */
|
|
1952
|
+
return /* @__PURE__ */ React14.createElement(FormFieldWrapper, {
|
|
1944
1953
|
readonly,
|
|
1945
1954
|
...props
|
|
1946
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1955
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React14.createElement(Input9.TextInput, {
|
|
1947
1956
|
noAutoFill: true,
|
|
1948
1957
|
disabled: !!readonly,
|
|
1949
1958
|
placeholder,
|
|
@@ -1954,17 +1963,17 @@ var TextField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props
|
|
|
1954
1963
|
};
|
|
1955
1964
|
|
|
1956
1965
|
// src/components/Form/fields/TextAreaField.tsx
|
|
1957
|
-
import
|
|
1958
|
-
import { Input as
|
|
1966
|
+
import React15, { useCallback as useCallback13 } from "react";
|
|
1967
|
+
import { Input as Input10 } from "@dxos/react-ui";
|
|
1959
1968
|
var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1960
1969
|
const handleChange = useCallback13((event) => onValueChange(type, event.target.value), [
|
|
1961
1970
|
type,
|
|
1962
1971
|
onValueChange
|
|
1963
1972
|
]);
|
|
1964
|
-
return /* @__PURE__ */
|
|
1973
|
+
return /* @__PURE__ */ React15.createElement(FormFieldWrapper, {
|
|
1965
1974
|
readonly,
|
|
1966
1975
|
...props
|
|
1967
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
1976
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React15.createElement(Input10.TextArea, {
|
|
1968
1977
|
rows: 3,
|
|
1969
1978
|
disabled: !!readonly,
|
|
1970
1979
|
placeholder,
|
|
@@ -1975,9 +1984,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
|
|
|
1975
1984
|
};
|
|
1976
1985
|
|
|
1977
1986
|
// src/components/Form/fields/TupleField.tsx
|
|
1978
|
-
import
|
|
1979
|
-
import { Input as
|
|
1980
|
-
import { mx as
|
|
1987
|
+
import React16 from "react";
|
|
1988
|
+
import { Input as Input11 } from "@dxos/react-ui";
|
|
1989
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
1981
1990
|
import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
|
|
1982
1991
|
var gridCols = [
|
|
1983
1992
|
"grid-cols-1",
|
|
@@ -1988,15 +1997,15 @@ var gridCols = [
|
|
|
1988
1997
|
var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1989
1998
|
const { status, error } = getStatus();
|
|
1990
1999
|
const values = getValue() ?? {};
|
|
1991
|
-
return /* @__PURE__ */
|
|
2000
|
+
return /* @__PURE__ */ React16.createElement(Input11.Root, {
|
|
1992
2001
|
validationValence: status
|
|
1993
|
-
}, /* @__PURE__ */
|
|
2002
|
+
}, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
|
|
1994
2003
|
error,
|
|
1995
2004
|
readonly,
|
|
1996
2005
|
label
|
|
1997
|
-
}), /* @__PURE__ */
|
|
1998
|
-
className:
|
|
1999
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
2006
|
+
}), /* @__PURE__ */ React16.createElement("div", {
|
|
2007
|
+
className: mx3("grid gap-form-gap", gridCols[binding.length - 1])
|
|
2008
|
+
}, binding.map((prop) => /* @__PURE__ */ React16.createElement(Input11.TextInput, {
|
|
2000
2009
|
key: prop,
|
|
2001
2010
|
type: "number",
|
|
2002
2011
|
disabled: !!readonly,
|
|
@@ -2014,9 +2023,9 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2014
2023
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2015
2024
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2016
2025
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2017
|
-
const { t } =
|
|
2026
|
+
const { t } = useTranslation8(translationKey);
|
|
2018
2027
|
const [props, setProps] = useState5(projection.getFieldProjection(field.id).props);
|
|
2019
|
-
|
|
2028
|
+
useEffect6(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2020
2029
|
field,
|
|
2021
2030
|
projection
|
|
2022
2031
|
]);
|
|
@@ -2035,7 +2044,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2035
2044
|
registry
|
|
2036
2045
|
]);
|
|
2037
2046
|
const [referenceSchema, setReferenceSchema] = useState5();
|
|
2038
|
-
|
|
2047
|
+
useEffect6(() => {
|
|
2039
2048
|
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
2040
2049
|
}, [
|
|
2041
2050
|
schemas,
|
|
@@ -2045,26 +2054,26 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2045
2054
|
fieldSchema: getFormatSchema(props?.format)
|
|
2046
2055
|
});
|
|
2047
2056
|
const fieldMap = useMemo7(() => ({
|
|
2048
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
2057
|
+
["format"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2049
2058
|
...props2,
|
|
2050
2059
|
options: FormatEnums.filter((value3) => value3 !== Format4.TypeFormat.None).map((value3) => ({
|
|
2051
2060
|
value: value3,
|
|
2052
|
-
label: t(`format
|
|
2061
|
+
label: t(`format.${value3}.label`)
|
|
2053
2062
|
}))
|
|
2054
2063
|
}),
|
|
2055
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
2064
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2056
2065
|
...props2,
|
|
2057
2066
|
options: schemas.map((schema) => ({
|
|
2058
2067
|
value: schema.typename
|
|
2059
2068
|
}))
|
|
2060
2069
|
}),
|
|
2061
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
2070
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React17.createElement(SelectField, {
|
|
2062
2071
|
...props2,
|
|
2063
2072
|
options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
|
|
2064
2073
|
value: p.name.toString()
|
|
2065
2074
|
})) : []
|
|
2066
2075
|
}),
|
|
2067
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
2076
|
+
["options"]: (props2) => /* @__PURE__ */ React17.createElement(SelectOptionField, props2)
|
|
2068
2077
|
}), [
|
|
2069
2078
|
t,
|
|
2070
2079
|
schemas,
|
|
@@ -2123,7 +2132,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2123
2132
|
]);
|
|
2124
2133
|
const handleSave = useCallback14((props2) => {
|
|
2125
2134
|
if (view) {
|
|
2126
|
-
|
|
2135
|
+
Obj2.change(view, () => {
|
|
2127
2136
|
projection.setFieldProjection({
|
|
2128
2137
|
field,
|
|
2129
2138
|
props: props2
|
|
@@ -2153,13 +2162,13 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2153
2162
|
props
|
|
2154
2163
|
}, {
|
|
2155
2164
|
F: __dxlog_file2,
|
|
2156
|
-
L:
|
|
2165
|
+
L: 172,
|
|
2157
2166
|
S: void 0,
|
|
2158
2167
|
C: (f, a) => f(...a)
|
|
2159
2168
|
});
|
|
2160
2169
|
return null;
|
|
2161
2170
|
}
|
|
2162
|
-
return /* @__PURE__ */
|
|
2171
|
+
return /* @__PURE__ */ React17.createElement(Form.Root, {
|
|
2163
2172
|
key: field.id,
|
|
2164
2173
|
fieldMap,
|
|
2165
2174
|
autoFocus: true,
|
|
@@ -2175,34 +2184,348 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2175
2184
|
onValidate: handleValidate,
|
|
2176
2185
|
onSave: handleSave,
|
|
2177
2186
|
onCancel: handleCancel
|
|
2178
|
-
}, /* @__PURE__ */
|
|
2187
|
+
}, /* @__PURE__ */ React17.createElement(Form.Content, null, /* @__PURE__ */ React17.createElement(Form.FieldSet, null), /* @__PURE__ */ React17.createElement(Form.Actions, null)));
|
|
2188
|
+
};
|
|
2189
|
+
|
|
2190
|
+
// src/components/ObjectForm/ObjectForm.tsx
|
|
2191
|
+
import * as Schema3 from "effect/Schema";
|
|
2192
|
+
import React18, { useCallback as useCallback15, useMemo as useMemo8 } from "react";
|
|
2193
|
+
import { DXN as DXN2, Obj as Obj3, Ref as Ref3, Tag as Tag2, Type as Type2 } from "@dxos/echo";
|
|
2194
|
+
import { splitJsonPath } from "@dxos/echo/internal";
|
|
2195
|
+
import { invariant } from "@dxos/invariant";
|
|
2196
|
+
import { HuePicker as HuePicker2 } from "@dxos/react-ui-pickers";
|
|
2197
|
+
import { isNonNullable } from "@dxos/util";
|
|
2198
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectForm/ObjectForm.tsx";
|
|
2199
|
+
var createFieldMap = {
|
|
2200
|
+
hue: ({ type, label, layout, getValue, onValueChange }) => {
|
|
2201
|
+
const handleChange = useCallback15((nextHue) => onValueChange(type, nextHue), [
|
|
2202
|
+
onValueChange,
|
|
2203
|
+
type
|
|
2204
|
+
]);
|
|
2205
|
+
const handleReset = useCallback15(() => onValueChange(type, void 0), [
|
|
2206
|
+
onValueChange,
|
|
2207
|
+
type
|
|
2208
|
+
]);
|
|
2209
|
+
return /* @__PURE__ */ React18.createElement(React18.Fragment, null, layout !== "inline" && /* @__PURE__ */ React18.createElement(Form.Label, {
|
|
2210
|
+
label
|
|
2211
|
+
}), /* @__PURE__ */ React18.createElement(HuePicker2, {
|
|
2212
|
+
value: getValue(),
|
|
2213
|
+
onChange: handleChange,
|
|
2214
|
+
onReset: handleReset
|
|
2215
|
+
}));
|
|
2216
|
+
}
|
|
2217
|
+
};
|
|
2218
|
+
var ObjectForm = ({ object, schema }) => {
|
|
2219
|
+
const db = Obj3.getDatabase(object);
|
|
2220
|
+
const meta = Obj3.getMeta(object);
|
|
2221
|
+
const tags = (meta.tags ?? []).map((tag) => db?.makeRef(DXN2.parse(tag))).filter(isNonNullable);
|
|
2222
|
+
const values = useMemo8(() => ({
|
|
2223
|
+
tags,
|
|
2224
|
+
...object
|
|
2225
|
+
}), [
|
|
2226
|
+
object,
|
|
2227
|
+
tags
|
|
2228
|
+
]);
|
|
2229
|
+
const formSchema = useMemo8(() => omitId(Schema3.Struct({
|
|
2230
|
+
tags: Schema3.Array(Ref3.Ref(Tag2.Tag)).pipe(Schema3.optional)
|
|
2231
|
+
}).pipe(Schema3.extend(schema))), [
|
|
2232
|
+
schema
|
|
2233
|
+
]);
|
|
2234
|
+
const handleCreate = useCallback15((schema2, values2) => {
|
|
2235
|
+
invariant(db, void 0, {
|
|
2236
|
+
F: __dxlog_file3,
|
|
2237
|
+
L: 51,
|
|
2238
|
+
S: void 0,
|
|
2239
|
+
A: [
|
|
2240
|
+
"db",
|
|
2241
|
+
""
|
|
2242
|
+
]
|
|
2243
|
+
});
|
|
2244
|
+
invariant(Type2.isObjectSchema(schema2), void 0, {
|
|
2245
|
+
F: __dxlog_file3,
|
|
2246
|
+
L: 52,
|
|
2247
|
+
S: void 0,
|
|
2248
|
+
A: [
|
|
2249
|
+
"Type.isObjectSchema(schema)",
|
|
2250
|
+
""
|
|
2251
|
+
]
|
|
2252
|
+
});
|
|
2253
|
+
const newObject = db.add(Obj3.make(schema2, values2));
|
|
2254
|
+
if (Obj3.instanceOf(Tag2.Tag, newObject)) {
|
|
2255
|
+
Obj3.change(object, (object2) => {
|
|
2256
|
+
Obj3.getMeta(object2).tags = [
|
|
2257
|
+
...Obj3.getMeta(object2).tags ?? [],
|
|
2258
|
+
Obj3.getDXN(newObject).toString()
|
|
2259
|
+
];
|
|
2260
|
+
});
|
|
2261
|
+
}
|
|
2262
|
+
}, []);
|
|
2263
|
+
const handleChange = useCallback15(({ tags: tags2, ...values2 }, { isValid, changed }) => {
|
|
2264
|
+
if (!isValid) {
|
|
2265
|
+
return;
|
|
2266
|
+
}
|
|
2267
|
+
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2268
|
+
const hasTagsChange = changedPaths.some((path) => splitJsonPath(path)[0] === "tags");
|
|
2269
|
+
if (hasTagsChange) {
|
|
2270
|
+
Obj3.change(object, (object2) => {
|
|
2271
|
+
Obj3.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
|
|
2272
|
+
});
|
|
2273
|
+
}
|
|
2274
|
+
const nonTagPaths = changedPaths.filter((path) => splitJsonPath(path)[0] !== "tags");
|
|
2275
|
+
if (nonTagPaths.length > 0) {
|
|
2276
|
+
Obj3.change(object, () => {
|
|
2277
|
+
for (const path of nonTagPaths) {
|
|
2278
|
+
const parts = splitJsonPath(path);
|
|
2279
|
+
const value3 = Obj3.getValue(values2, parts);
|
|
2280
|
+
Obj3.setValue(object, parts, value3);
|
|
2281
|
+
}
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
}, [
|
|
2285
|
+
object
|
|
2286
|
+
]);
|
|
2287
|
+
return /* @__PURE__ */ React18.createElement(Form.Root, {
|
|
2288
|
+
schema: formSchema,
|
|
2289
|
+
defaultValues: values,
|
|
2290
|
+
createTypename: Type2.getTypename(Tag2.Tag),
|
|
2291
|
+
createOptionIcon: "ph--plus--regular",
|
|
2292
|
+
createOptionLabel: [
|
|
2293
|
+
"add-tag.label",
|
|
2294
|
+
{
|
|
2295
|
+
ns: translationKey
|
|
2296
|
+
}
|
|
2297
|
+
],
|
|
2298
|
+
createInitialValuePath: "label",
|
|
2299
|
+
createFieldMap,
|
|
2300
|
+
db,
|
|
2301
|
+
onValuesChanged: handleChange,
|
|
2302
|
+
onCreate: handleCreate
|
|
2303
|
+
}, /* @__PURE__ */ React18.createElement(Form.Viewport, null, /* @__PURE__ */ React18.createElement(Form.Content, null, /* @__PURE__ */ React18.createElement(Form.FieldSet, null))));
|
|
2304
|
+
};
|
|
2305
|
+
|
|
2306
|
+
// src/components/ObjectProperties/ObjectProperties.tsx
|
|
2307
|
+
import * as Function from "effect/Function";
|
|
2308
|
+
import * as Option4 from "effect/Option";
|
|
2309
|
+
import * as Schema4 from "effect/Schema";
|
|
2310
|
+
import React19, { useCallback as useCallback16, useMemo as useMemo9 } from "react";
|
|
2311
|
+
import { DXN as DXN3, Obj as Obj4, Ref as Ref4, Tag as Tag3, Type as Type3 } from "@dxos/echo";
|
|
2312
|
+
import { splitJsonPath as splitJsonPath2 } from "@dxos/echo/internal";
|
|
2313
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
2314
|
+
import { HuePicker as HuePicker3 } from "@dxos/react-ui-pickers";
|
|
2315
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
2316
|
+
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2317
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectProperties/ObjectProperties.tsx";
|
|
2318
|
+
var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef) => {
|
|
2319
|
+
const db = Obj4.getDatabase(object);
|
|
2320
|
+
const meta = Obj4.getMeta(object);
|
|
2321
|
+
const tags = (meta.tags ?? []).map((tag) => db?.makeRef(DXN3.parse(tag))).filter(isNonNullable2);
|
|
2322
|
+
const values = useMemo9(() => ({
|
|
2323
|
+
tags,
|
|
2324
|
+
...object
|
|
2325
|
+
}), [
|
|
2326
|
+
object,
|
|
2327
|
+
tags
|
|
2328
|
+
]);
|
|
2329
|
+
const formSchema = useMemo9(() => {
|
|
2330
|
+
return Function.pipe(Obj4.getSchema(object), Option4.fromNullable, Option4.map((schema) => omitId(BaseSchema.pipe(Schema4.extend(schema)))), Option4.getOrUndefined);
|
|
2331
|
+
}, [
|
|
2332
|
+
object
|
|
2333
|
+
]);
|
|
2334
|
+
const handleCreate = useCallback16((schema, values2) => {
|
|
2335
|
+
invariant2(db, void 0, {
|
|
2336
|
+
F: __dxlog_file4,
|
|
2337
|
+
L: 40,
|
|
2338
|
+
S: void 0,
|
|
2339
|
+
A: [
|
|
2340
|
+
"db",
|
|
2341
|
+
""
|
|
2342
|
+
]
|
|
2343
|
+
});
|
|
2344
|
+
invariant2(Type3.isObjectSchema(schema), void 0, {
|
|
2345
|
+
F: __dxlog_file4,
|
|
2346
|
+
L: 41,
|
|
2347
|
+
S: void 0,
|
|
2348
|
+
A: [
|
|
2349
|
+
"Type.isObjectSchema(schema)",
|
|
2350
|
+
""
|
|
2351
|
+
]
|
|
2352
|
+
});
|
|
2353
|
+
const newObject = db.add(Obj4.make(schema, values2));
|
|
2354
|
+
if (Obj4.instanceOf(Tag3.Tag, newObject)) {
|
|
2355
|
+
Obj4.change(object, (object2) => {
|
|
2356
|
+
Obj4.getMeta(object2).tags = [
|
|
2357
|
+
...Obj4.getMeta(object2).tags ?? [],
|
|
2358
|
+
Obj4.getDXN(newObject).toString()
|
|
2359
|
+
];
|
|
2360
|
+
});
|
|
2361
|
+
}
|
|
2362
|
+
}, []);
|
|
2363
|
+
const handleChange = useCallback16(({ tags: tags2, ...values2 }, { isValid, changed }) => {
|
|
2364
|
+
if (!isValid) {
|
|
2365
|
+
return;
|
|
2366
|
+
}
|
|
2367
|
+
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2368
|
+
const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === "tags");
|
|
2369
|
+
if (hasTagsChange) {
|
|
2370
|
+
Obj4.change(object, (object2) => {
|
|
2371
|
+
Obj4.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== "tags");
|
|
2375
|
+
if (nonTagPaths.length > 0) {
|
|
2376
|
+
Obj4.change(object, () => {
|
|
2377
|
+
for (const path of nonTagPaths) {
|
|
2378
|
+
const parts = splitJsonPath2(path);
|
|
2379
|
+
const value3 = Obj4.getValue(values2, parts);
|
|
2380
|
+
Obj4.setValue(object, parts, value3);
|
|
2381
|
+
}
|
|
2382
|
+
});
|
|
2383
|
+
}
|
|
2384
|
+
}, [
|
|
2385
|
+
object
|
|
2386
|
+
]);
|
|
2387
|
+
if (!formSchema) {
|
|
2388
|
+
return null;
|
|
2389
|
+
}
|
|
2390
|
+
return /* @__PURE__ */ React19.createElement(Form.Root, {
|
|
2391
|
+
schema: formSchema,
|
|
2392
|
+
defaultValues: values,
|
|
2393
|
+
createTypename: Type3.getTypename(Tag3.Tag),
|
|
2394
|
+
createOptionIcon: "ph--plus--regular",
|
|
2395
|
+
createOptionLabel: [
|
|
2396
|
+
"add-tag.label",
|
|
2397
|
+
{
|
|
2398
|
+
ns: translationKey
|
|
2399
|
+
}
|
|
2400
|
+
],
|
|
2401
|
+
createInitialValuePath: "label",
|
|
2402
|
+
createFieldMap: createFieldMap2,
|
|
2403
|
+
db,
|
|
2404
|
+
onValuesChanged: handleChange,
|
|
2405
|
+
onCreate: handleCreate
|
|
2406
|
+
}, /* @__PURE__ */ React19.createElement(Form.Viewport, {
|
|
2407
|
+
...composableProps2(props),
|
|
2408
|
+
ref: forwardedRef
|
|
2409
|
+
}, /* @__PURE__ */ React19.createElement(Form.Content, null, /* @__PURE__ */ React19.createElement(Form.FieldSet, null), children)));
|
|
2410
|
+
});
|
|
2411
|
+
var createFieldMap2 = {
|
|
2412
|
+
hue: ({ type, label, layout, getValue, onValueChange }) => {
|
|
2413
|
+
const handleChange = useCallback16((nextHue) => onValueChange(type, nextHue), [
|
|
2414
|
+
onValueChange,
|
|
2415
|
+
type
|
|
2416
|
+
]);
|
|
2417
|
+
const handleReset = useCallback16(() => onValueChange(type, void 0), [
|
|
2418
|
+
onValueChange,
|
|
2419
|
+
type
|
|
2420
|
+
]);
|
|
2421
|
+
return /* @__PURE__ */ React19.createElement(React19.Fragment, null, layout !== "inline" && /* @__PURE__ */ React19.createElement(Form.Label, {
|
|
2422
|
+
label
|
|
2423
|
+
}), /* @__PURE__ */ React19.createElement(HuePicker3, {
|
|
2424
|
+
value: getValue(),
|
|
2425
|
+
onChange: handleChange,
|
|
2426
|
+
onReset: handleReset
|
|
2427
|
+
}));
|
|
2428
|
+
}
|
|
2429
|
+
};
|
|
2430
|
+
var BaseSchema = Schema4.Struct({
|
|
2431
|
+
tags: Schema4.Array(Ref4.Ref(Tag3.Tag)).pipe(Schema4.optional)
|
|
2432
|
+
});
|
|
2433
|
+
|
|
2434
|
+
// src/components/Settings/Settings.tsx
|
|
2435
|
+
import React20 from "react";
|
|
2436
|
+
import { Input as Input12, ScrollArea as ScrollArea2, toLocalizedString, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
2437
|
+
import { composable as composable3, composableProps as composableProps3, mx as mx4 } from "@dxos/ui-theme";
|
|
2438
|
+
var SETTINGS_ROOT_NAME = "Settings.Root";
|
|
2439
|
+
var SETTINGS_VIEWPORT_NAME = "Settings.Viewport";
|
|
2440
|
+
var SETTINGS_SECTION_NAME = "Settings.Section";
|
|
2441
|
+
var SETTINGS_PANEL_NAME = "Settings.Panel";
|
|
2442
|
+
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2443
|
+
var SettingsRoot = ({ children, classNames }) => {
|
|
2444
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
2445
|
+
className: mx4("flex flex-col gap-2", classNames)
|
|
2446
|
+
}, children);
|
|
2447
|
+
};
|
|
2448
|
+
SettingsRoot.displayName = SETTINGS_ROOT_NAME;
|
|
2449
|
+
var SettingsViewport = composable3(({ children, ...props }, forwardedRef) => {
|
|
2450
|
+
return /* @__PURE__ */ React20.createElement(ScrollArea2.Root, {
|
|
2451
|
+
...composableProps3(props),
|
|
2452
|
+
orientation: "vertical",
|
|
2453
|
+
centered: true,
|
|
2454
|
+
thin: true,
|
|
2455
|
+
ref: forwardedRef
|
|
2456
|
+
}, /* @__PURE__ */ React20.createElement(ScrollArea2.Viewport, {
|
|
2457
|
+
classNames: "px-4 pointer-coarse:px-2"
|
|
2458
|
+
}, /* @__PURE__ */ React20.createElement("div", {
|
|
2459
|
+
role: "none",
|
|
2460
|
+
className: "dx-document flex flex-col gap-2 py-4"
|
|
2461
|
+
}, children)));
|
|
2462
|
+
});
|
|
2463
|
+
SettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;
|
|
2464
|
+
var SettingsSection = ({ title, description, children }) => {
|
|
2465
|
+
const { t } = useTranslation9(translationKey);
|
|
2466
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement("h2", {
|
|
2467
|
+
className: "px-trim-md mt-trim-md text-xl"
|
|
2468
|
+
}, toLocalizedString(title, t)), description && /* @__PURE__ */ React20.createElement("p", {
|
|
2469
|
+
className: "px-trim-md text-description"
|
|
2470
|
+
}, toLocalizedString(description, t)), /* @__PURE__ */ React20.createElement("div", {
|
|
2471
|
+
className: "w-full pt-trim-md space-y-trim-md"
|
|
2472
|
+
}, children));
|
|
2473
|
+
};
|
|
2474
|
+
SettingsSection.displayName = SETTINGS_SECTION_NAME;
|
|
2475
|
+
var SettingsPanel = ({ classNames, children }) => {
|
|
2476
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
2477
|
+
role: "none",
|
|
2478
|
+
className: mx4("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
|
|
2479
|
+
}, children);
|
|
2480
|
+
};
|
|
2481
|
+
SettingsPanel.displayName = SETTINGS_PANEL_NAME;
|
|
2482
|
+
var SettingsItem = ({ title, description = "", children }) => {
|
|
2483
|
+
const { t } = useTranslation9(translationKey);
|
|
2484
|
+
return /* @__PURE__ */ React20.createElement(Input12.Root, null, /* @__PURE__ */ React20.createElement(SettingsPanel, {
|
|
2485
|
+
classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
|
|
2486
|
+
}, /* @__PURE__ */ React20.createElement(Input12.Label, {
|
|
2487
|
+
classNames: "pb-trim-md text-base-surface-text text-lg md:col-span-2"
|
|
2488
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React20.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React20.createElement(Input12.Description, {
|
|
2489
|
+
classNames: "text-base text-description"
|
|
2490
|
+
}, toLocalizedString(description, t))), /* @__PURE__ */ React20.createElement("div", {
|
|
2491
|
+
role: "none",
|
|
2492
|
+
className: "text-end py-1"
|
|
2493
|
+
}, children)));
|
|
2494
|
+
};
|
|
2495
|
+
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2496
|
+
var Settings = {
|
|
2497
|
+
Root: SettingsRoot,
|
|
2498
|
+
Viewport: SettingsViewport,
|
|
2499
|
+
Section: SettingsSection,
|
|
2500
|
+
Panel: SettingsPanel,
|
|
2501
|
+
Item: SettingsItem
|
|
2179
2502
|
};
|
|
2180
2503
|
|
|
2181
2504
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
2182
2505
|
import { RegistryContext } from "@effect-atom/atom-react";
|
|
2183
|
-
import * as
|
|
2506
|
+
import * as Array4 from "effect/Array";
|
|
2184
2507
|
import * as Match2 from "effect/Match";
|
|
2185
|
-
import * as
|
|
2186
|
-
import * as
|
|
2187
|
-
import
|
|
2188
|
-
import { Filter as Filter2, Format as Format5, Obj as
|
|
2508
|
+
import * as Option5 from "effect/Option";
|
|
2509
|
+
import * as Schema5 from "effect/Schema";
|
|
2510
|
+
import React21, { forwardRef as forwardRef2, useCallback as useCallback17, useContext, useImperativeHandle, useMemo as useMemo10, useState as useState6 } from "react";
|
|
2511
|
+
import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj5, Query, QueryAST, Ref as Ref5 } from "@dxos/echo";
|
|
2512
|
+
import { View } from "@dxos/echo";
|
|
2189
2513
|
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
2190
|
-
import { invariant } from "@dxos/invariant";
|
|
2191
|
-
import {
|
|
2514
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2515
|
+
import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
2516
|
+
import { IconButton as IconButton4, Input as Input13, Message, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2192
2517
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2193
2518
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2194
|
-
import {
|
|
2195
|
-
import { mx as
|
|
2196
|
-
var
|
|
2197
|
-
var
|
|
2198
|
-
var listItemGrid = "grid grid-cols-subgrid col-span-5";
|
|
2199
|
-
var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode = "schema", registry, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2519
|
+
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2520
|
+
import { mx as mx5, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
|
|
2521
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2522
|
+
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2200
2523
|
const atomRegistry = useContext(RegistryContext);
|
|
2201
2524
|
const schemaReadonly = !isMutable(schema);
|
|
2202
2525
|
const { t } = useTranslation10(translationKey);
|
|
2203
|
-
const projectionModel =
|
|
2526
|
+
const projectionModel = useMemo10(() => {
|
|
2204
2527
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2205
|
-
const change = schema instanceof EchoSchema ?
|
|
2528
|
+
const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
|
|
2206
2529
|
const model = new ProjectionModel({
|
|
2207
2530
|
registry: atomRegistry,
|
|
2208
2531
|
view,
|
|
@@ -2218,14 +2541,27 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2218
2541
|
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
2219
2542
|
projectionModel
|
|
2220
2543
|
]);
|
|
2221
|
-
const [expandedField, setExpandedField] = useState6();
|
|
2222
2544
|
const queueTarget = Match2.value(view.query.ast).pipe(Match2.when({
|
|
2223
|
-
type: "
|
|
2224
|
-
}, ({
|
|
2225
|
-
|
|
2545
|
+
type: "from"
|
|
2546
|
+
}, ({ from }) => {
|
|
2547
|
+
if (from._tag !== "scope") {
|
|
2548
|
+
return void 0;
|
|
2549
|
+
}
|
|
2550
|
+
return Option5.fromNullable(from.scope.queues).pipe(Option5.flatMap((queues) => Array4.head(queues)), Option5.map(String), Option5.getOrUndefined);
|
|
2226
2551
|
}), Match2.orElse(() => void 0));
|
|
2227
|
-
const
|
|
2228
|
-
|
|
2552
|
+
const feeds = useQuery2(db, Filter2.type(Feed.Feed));
|
|
2553
|
+
const targetRef = useMemo10(() => {
|
|
2554
|
+
if (!queueTarget) {
|
|
2555
|
+
return void 0;
|
|
2556
|
+
}
|
|
2557
|
+
const feed = feeds.find((feed2) => Feed.getQueueDxn(feed2)?.toString() === queueTarget);
|
|
2558
|
+
return feed ? Ref5.fromDXN(Entity2.getDXN(feed)) : void 0;
|
|
2559
|
+
}, [
|
|
2560
|
+
queueTarget,
|
|
2561
|
+
feeds
|
|
2562
|
+
]);
|
|
2563
|
+
const viewSchema = useMemo10(() => {
|
|
2564
|
+
const base = Schema5.Struct({
|
|
2229
2565
|
query: mode === "schema" ? Format5.URL.annotations({
|
|
2230
2566
|
title: "Record type"
|
|
2231
2567
|
}) : QueryAST.Query.annotations({
|
|
@@ -2233,26 +2569,27 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2233
2569
|
})
|
|
2234
2570
|
});
|
|
2235
2571
|
if (mode === "tag") {
|
|
2236
|
-
return
|
|
2572
|
+
return Schema5.Struct({
|
|
2237
2573
|
...base.fields,
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2574
|
+
// TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
|
|
2575
|
+
target: Ref5.Ref(Feed.Feed).pipe(Schema5.annotations({
|
|
2576
|
+
title: "Target Feed"
|
|
2577
|
+
}), ParentLabelAnnotation.set(true), Schema5.optional)
|
|
2578
|
+
}).pipe(Schema5.mutable);
|
|
2242
2579
|
}
|
|
2243
|
-
return base.pipe(
|
|
2580
|
+
return base.pipe(Schema5.mutable);
|
|
2244
2581
|
}, [
|
|
2245
2582
|
mode
|
|
2246
2583
|
]);
|
|
2247
|
-
const viewValues =
|
|
2584
|
+
const viewValues = useMemo10(() => ({
|
|
2248
2585
|
query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
|
|
2249
|
-
target:
|
|
2586
|
+
target: targetRef
|
|
2250
2587
|
}), [
|
|
2251
2588
|
mode,
|
|
2252
2589
|
view.query.ast,
|
|
2253
|
-
|
|
2590
|
+
targetRef
|
|
2254
2591
|
]);
|
|
2255
|
-
const fieldMap =
|
|
2592
|
+
const fieldMap = useMemo10(() => mode === "tag" ? customFields({
|
|
2256
2593
|
types,
|
|
2257
2594
|
tags
|
|
2258
2595
|
}) : void 0, [
|
|
@@ -2260,93 +2597,70 @@ var ViewEditor = /* @__PURE__ */ forwardRef3(({ classNames, schema, view, mode =
|
|
|
2260
2597
|
types,
|
|
2261
2598
|
tags
|
|
2262
2599
|
]);
|
|
2263
|
-
const
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
}
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2275
|
-
}, [
|
|
2276
|
-
projectionModel,
|
|
2277
|
-
readonly
|
|
2278
|
-
]);
|
|
2279
|
-
const handleUpdate = useCallback15((values) => {
|
|
2280
|
-
requestAnimationFrame(() => {
|
|
2281
|
-
const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : values.query;
|
|
2282
|
-
onQueryChanged?.(query, values.target);
|
|
2283
|
-
});
|
|
2600
|
+
const handleUpdate = useCallback17((values) => {
|
|
2601
|
+
const targetValue = values.target;
|
|
2602
|
+
let queueDxn;
|
|
2603
|
+
if (Ref5.isRef(targetValue)) {
|
|
2604
|
+
const feedDxn = targetValue.dxn.toString();
|
|
2605
|
+
const feed = feeds.find((feed2) => Obj5.getDXN(feed2).toString() === feedDxn);
|
|
2606
|
+
if (feed) {
|
|
2607
|
+
queueDxn = Feed.getQueueDxn(feed)?.toString();
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
|
|
2611
|
+
onQueryChanged?.(query, queueDxn);
|
|
2284
2612
|
}, [
|
|
2285
2613
|
onQueryChanged,
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
mode
|
|
2614
|
+
mode,
|
|
2615
|
+
feeds
|
|
2289
2616
|
]);
|
|
2290
|
-
const handleDelete =
|
|
2291
|
-
|
|
2292
|
-
F:
|
|
2293
|
-
L:
|
|
2617
|
+
const handleDelete = useCallback17((fieldId) => {
|
|
2618
|
+
invariant3(!readonly, void 0, {
|
|
2619
|
+
F: __dxlog_file5,
|
|
2620
|
+
L: 185,
|
|
2294
2621
|
S: void 0,
|
|
2295
2622
|
A: [
|
|
2296
2623
|
"!readonly",
|
|
2297
2624
|
""
|
|
2298
2625
|
]
|
|
2299
2626
|
});
|
|
2300
|
-
if (fieldId === expandedField) {
|
|
2301
|
-
setExpandedField(void 0);
|
|
2302
|
-
}
|
|
2303
2627
|
onDelete?.(fieldId);
|
|
2304
2628
|
}, [
|
|
2305
|
-
expandedField,
|
|
2306
2629
|
onDelete,
|
|
2307
2630
|
readonly
|
|
2308
2631
|
]);
|
|
2309
|
-
return /* @__PURE__ */
|
|
2632
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
2310
2633
|
role: "none",
|
|
2311
|
-
className:
|
|
2312
|
-
}, schemaReadonly && !readonly && /* @__PURE__ */
|
|
2634
|
+
className: mx5(classNames)
|
|
2635
|
+
}, schemaReadonly && !readonly && /* @__PURE__ */ React21.createElement(Message.Root, {
|
|
2313
2636
|
valence: "info",
|
|
2314
|
-
classNames: "
|
|
2315
|
-
}, /* @__PURE__ */
|
|
2637
|
+
classNames: "my-form-padding"
|
|
2638
|
+
}, /* @__PURE__ */ React21.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React21.createElement(Form.Root, {
|
|
2316
2639
|
schema: viewSchema,
|
|
2317
2640
|
values: viewValues,
|
|
2318
2641
|
fieldMap,
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
}, /* @__PURE__ */
|
|
2322
|
-
label: t("fields
|
|
2642
|
+
db,
|
|
2643
|
+
onValuesChanged: handleUpdate
|
|
2644
|
+
}, /* @__PURE__ */ React21.createElement(Form.FieldSet, null), /* @__PURE__ */ React21.createElement(FormFieldLabel, {
|
|
2645
|
+
label: t("fields.label"),
|
|
2323
2646
|
asChild: true
|
|
2324
|
-
}), /* @__PURE__ */
|
|
2647
|
+
}), /* @__PURE__ */ React21.createElement(FieldList, {
|
|
2325
2648
|
schema,
|
|
2326
2649
|
view,
|
|
2327
2650
|
registry,
|
|
2328
2651
|
readonly,
|
|
2329
2652
|
showHeading,
|
|
2330
2653
|
onDelete: handleDelete
|
|
2331
|
-
})), !readonly && !expandedField && /* @__PURE__ */ React19.createElement("div", {
|
|
2332
|
-
role: "none",
|
|
2333
|
-
className: "mlb-cardSpacingBlock"
|
|
2334
|
-
}, /* @__PURE__ */ React19.createElement(IconButton4, {
|
|
2335
|
-
icon: "ph--plus--regular",
|
|
2336
|
-
label: t("add property button label"),
|
|
2337
|
-
onClick: readonly ? void 0 : handleAdd,
|
|
2338
|
-
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2339
|
-
disabled: view.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2340
|
-
classNames: "is-full"
|
|
2341
2654
|
})));
|
|
2342
2655
|
});
|
|
2343
2656
|
var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
2344
2657
|
const atomRegistry = useContext(RegistryContext);
|
|
2345
2658
|
const schemaReadonly = !isMutable(schema);
|
|
2346
2659
|
const { t } = useTranslation10(translationKey);
|
|
2347
|
-
const
|
|
2660
|
+
const [viewSnapshot] = useObject(view);
|
|
2661
|
+
const projectionModel = useMemo10(() => {
|
|
2348
2662
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2349
|
-
const change = schema instanceof EchoSchema ?
|
|
2663
|
+
const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
|
|
2350
2664
|
const model = new ProjectionModel({
|
|
2351
2665
|
registry: atomRegistry,
|
|
2352
2666
|
view,
|
|
@@ -2360,15 +2674,31 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2360
2674
|
view
|
|
2361
2675
|
]);
|
|
2362
2676
|
const [expandedField, setExpandedField] = useState6();
|
|
2363
|
-
const
|
|
2677
|
+
const handleAdd = useCallback17(() => {
|
|
2678
|
+
invariant3(!readonly, void 0, {
|
|
2679
|
+
F: __dxlog_file5,
|
|
2680
|
+
L: 250,
|
|
2681
|
+
S: void 0,
|
|
2682
|
+
A: [
|
|
2683
|
+
"!readonly",
|
|
2684
|
+
""
|
|
2685
|
+
]
|
|
2686
|
+
});
|
|
2687
|
+
const field = projectionModel.createFieldProjection();
|
|
2688
|
+
setExpandedField(field.id);
|
|
2689
|
+
}, [
|
|
2690
|
+
projectionModel,
|
|
2691
|
+
readonly
|
|
2692
|
+
]);
|
|
2693
|
+
const handleToggleField = useCallback17((field) => {
|
|
2364
2694
|
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2365
2695
|
}, [
|
|
2366
2696
|
readonly
|
|
2367
2697
|
]);
|
|
2368
|
-
const handleDelete =
|
|
2369
|
-
|
|
2370
|
-
F:
|
|
2371
|
-
L:
|
|
2698
|
+
const handleDelete = useCallback17((fieldId) => {
|
|
2699
|
+
invariant3(!readonly, void 0, {
|
|
2700
|
+
F: __dxlog_file5,
|
|
2701
|
+
L: 264,
|
|
2372
2702
|
S: void 0,
|
|
2373
2703
|
A: [
|
|
2374
2704
|
"!readonly",
|
|
@@ -2384,110 +2714,122 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2384
2714
|
onDelete,
|
|
2385
2715
|
readonly
|
|
2386
2716
|
]);
|
|
2387
|
-
const handleMove =
|
|
2388
|
-
|
|
2389
|
-
F:
|
|
2390
|
-
L:
|
|
2717
|
+
const handleMove = useCallback17((fromIndex, toIndex) => {
|
|
2718
|
+
invariant3(!readonly, void 0, {
|
|
2719
|
+
F: __dxlog_file5,
|
|
2720
|
+
L: 276,
|
|
2391
2721
|
S: void 0,
|
|
2392
2722
|
A: [
|
|
2393
2723
|
"!readonly",
|
|
2394
2724
|
""
|
|
2395
2725
|
]
|
|
2396
2726
|
});
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2727
|
+
Obj5.change(view, (view2) => {
|
|
2728
|
+
const fields = [
|
|
2729
|
+
...view2.projection.fields
|
|
2730
|
+
];
|
|
2731
|
+
const [moved] = fields.splice(fromIndex, 1);
|
|
2732
|
+
fields.splice(toIndex, 0, moved);
|
|
2733
|
+
view2.projection.fields = fields;
|
|
2404
2734
|
});
|
|
2405
2735
|
}, [
|
|
2406
|
-
view
|
|
2736
|
+
view,
|
|
2407
2737
|
readonly
|
|
2408
2738
|
]);
|
|
2409
|
-
const handleClose =
|
|
2410
|
-
const handleHide =
|
|
2739
|
+
const handleClose = useCallback17(() => setExpandedField(void 0), []);
|
|
2740
|
+
const handleHide = useCallback17((fieldId) => {
|
|
2411
2741
|
setExpandedField(void 0);
|
|
2412
2742
|
projectionModel.hideFieldProjection(fieldId);
|
|
2413
2743
|
}, [
|
|
2414
2744
|
projectionModel
|
|
2415
2745
|
]);
|
|
2416
|
-
const handleShow =
|
|
2746
|
+
const handleShow = useCallback17((property) => {
|
|
2417
2747
|
setExpandedField(void 0);
|
|
2418
2748
|
projectionModel.showFieldProjection(property);
|
|
2419
2749
|
}, [
|
|
2420
2750
|
projectionModel
|
|
2421
2751
|
]);
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2752
|
+
if (!viewSnapshot) {
|
|
2753
|
+
return null;
|
|
2754
|
+
}
|
|
2755
|
+
return /* @__PURE__ */ React21.createElement(List2.Root, {
|
|
2756
|
+
items: viewSnapshot.projection.fields,
|
|
2757
|
+
isItem: Schema5.is(View.FieldSchema),
|
|
2425
2758
|
getId: (field) => field.id,
|
|
2426
2759
|
onMove: readonly ? void 0 : handleMove,
|
|
2427
2760
|
readonly
|
|
2428
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
2761
|
+
}, ({ items: fields }) => /* @__PURE__ */ React21.createElement(React21.Fragment, null, showHeading && /* @__PURE__ */ React21.createElement("h3", {
|
|
2429
2762
|
className: "text-sm"
|
|
2430
|
-
}, t("field
|
|
2763
|
+
}, t("field-path.label")), /* @__PURE__ */ React21.createElement("div", {
|
|
2431
2764
|
role: "list",
|
|
2432
|
-
className:
|
|
2765
|
+
className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
|
|
2433
2766
|
}, fields?.map((field) => {
|
|
2434
2767
|
const hidden = field.visible === false;
|
|
2435
|
-
return /* @__PURE__ */
|
|
2768
|
+
return /* @__PURE__ */ React21.createElement(List2.Item, {
|
|
2436
2769
|
key: field.id,
|
|
2437
2770
|
item: field,
|
|
2438
|
-
classNames:
|
|
2771
|
+
classNames: "grid grid-cols-subgrid col-span-5",
|
|
2439
2772
|
"aria-expanded": expandedField === field.id
|
|
2440
|
-
}, /* @__PURE__ */
|
|
2773
|
+
}, /* @__PURE__ */ React21.createElement("div", {
|
|
2441
2774
|
role: "none",
|
|
2442
|
-
className:
|
|
2443
|
-
}, /* @__PURE__ */
|
|
2775
|
+
className: mx5(subtleHover2, "grid grid-cols-subgrid col-span-5", "rounded-xs cursor-pointer min-h-10")
|
|
2776
|
+
}, /* @__PURE__ */ React21.createElement(List2.ItemDragHandle, {
|
|
2444
2777
|
disabled: readonly || schemaReadonly
|
|
2445
|
-
}), /* @__PURE__ */
|
|
2778
|
+
}), /* @__PURE__ */ React21.createElement(List2.ItemTitle, {
|
|
2446
2779
|
classNames: hidden && "text-subdued",
|
|
2447
2780
|
onClick: () => handleToggleField(field)
|
|
2448
|
-
}, field.path), /* @__PURE__ */
|
|
2781
|
+
}, field.path), /* @__PURE__ */ React21.createElement(List2.ItemIconButton, {
|
|
2449
2782
|
label: t(hidden ? "show field label" : "hide field label"),
|
|
2450
2783
|
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
2451
2784
|
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
2452
2785
|
autoHide: false,
|
|
2453
2786
|
disabled: readonly || !hidden && projectionModel.getFields().length <= 1,
|
|
2454
2787
|
onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
|
|
2455
|
-
}), !readonly && /* @__PURE__ */
|
|
2456
|
-
label: t("delete
|
|
2788
|
+
}), !readonly && /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(List2.ItemDeleteButton, {
|
|
2789
|
+
label: t("delete-field.label"),
|
|
2457
2790
|
autoHide: false,
|
|
2458
|
-
disabled: readonly || schemaReadonly ||
|
|
2791
|
+
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
2459
2792
|
onClick: () => handleDelete(field.id),
|
|
2460
2793
|
"data-testid": "field.delete"
|
|
2461
|
-
}), /* @__PURE__ */
|
|
2794
|
+
}), /* @__PURE__ */ React21.createElement(List2.ItemIconButton, {
|
|
2462
2795
|
iconOnly: true,
|
|
2463
2796
|
variant: "ghost",
|
|
2464
|
-
label: t("toggle
|
|
2797
|
+
label: t("toggle-expand.label", {
|
|
2465
2798
|
ns: osTranslations2
|
|
2466
2799
|
}),
|
|
2467
2800
|
icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
2468
2801
|
onClick: () => handleToggleField(field),
|
|
2469
2802
|
"data-testid": "field.toggle"
|
|
2470
|
-
}))), expandedField === field.id && !readonly && /* @__PURE__ */
|
|
2803
|
+
}))), expandedField === field.id && !readonly && /* @__PURE__ */ React21.createElement("div", {
|
|
2471
2804
|
role: "none",
|
|
2472
|
-
className: "col-span-
|
|
2473
|
-
}, /* @__PURE__ */
|
|
2805
|
+
className: "col-span-full mt-1 mb-1 border border-separator rounded-md"
|
|
2806
|
+
}, /* @__PURE__ */ React21.createElement(FieldEditor, {
|
|
2474
2807
|
readonly: readonly || schemaReadonly,
|
|
2475
2808
|
registry,
|
|
2476
2809
|
projection: projectionModel,
|
|
2477
2810
|
field,
|
|
2478
2811
|
onSave: handleClose
|
|
2479
2812
|
})));
|
|
2813
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React21.createElement("div", {
|
|
2814
|
+
role: "none",
|
|
2815
|
+
className: "my-form-padding"
|
|
2816
|
+
}, /* @__PURE__ */ React21.createElement(IconButton4, {
|
|
2817
|
+
icon: "ph--plus--regular",
|
|
2818
|
+
label: t("add-property-button.label"),
|
|
2819
|
+
onClick: handleAdd,
|
|
2820
|
+
disabled: viewSnapshot.projection.fields.length >= VIEW_FIELD_LIMIT,
|
|
2821
|
+
classNames: "w-full"
|
|
2480
2822
|
}))));
|
|
2481
2823
|
};
|
|
2482
2824
|
var customFields = ({ types, tags }) => ({
|
|
2483
2825
|
query: ({ type, readonly, label, getValue, onValueChange }) => {
|
|
2484
|
-
const handleChange =
|
|
2826
|
+
const handleChange = useCallback17((query) => onValueChange(type, query.ast), [
|
|
2485
2827
|
onValueChange
|
|
2486
2828
|
]);
|
|
2487
|
-
return /* @__PURE__ */
|
|
2829
|
+
return /* @__PURE__ */ React21.createElement(Input13.Root, null, /* @__PURE__ */ React21.createElement(FormFieldLabel, {
|
|
2488
2830
|
readonly,
|
|
2489
2831
|
label
|
|
2490
|
-
}), /* @__PURE__ */
|
|
2832
|
+
}), /* @__PURE__ */ React21.createElement(QueryForm, {
|
|
2491
2833
|
initialQuery: getValue(),
|
|
2492
2834
|
types,
|
|
2493
2835
|
tags,
|
|
@@ -2498,15 +2840,6 @@ var customFields = ({ types, tags }) => ({
|
|
|
2498
2840
|
export {
|
|
2499
2841
|
ArrayField,
|
|
2500
2842
|
BooleanField,
|
|
2501
|
-
ControlFrame,
|
|
2502
|
-
ControlFrameItem,
|
|
2503
|
-
ControlGroup,
|
|
2504
|
-
ControlGroupButton,
|
|
2505
|
-
ControlItem,
|
|
2506
|
-
ControlItemInput,
|
|
2507
|
-
ControlPage,
|
|
2508
|
-
ControlSection,
|
|
2509
|
-
ControlSectionHeading,
|
|
2510
2843
|
FieldEditor,
|
|
2511
2844
|
Form,
|
|
2512
2845
|
FormFieldErrorBoundary,
|
|
@@ -2515,16 +2848,18 @@ export {
|
|
|
2515
2848
|
GeoPointField,
|
|
2516
2849
|
MarkdownField,
|
|
2517
2850
|
NumberField,
|
|
2851
|
+
ObjectForm,
|
|
2518
2852
|
ObjectPicker,
|
|
2853
|
+
ObjectProperties,
|
|
2519
2854
|
RefField,
|
|
2520
2855
|
SelectField,
|
|
2521
2856
|
SelectOptionField,
|
|
2857
|
+
Settings,
|
|
2522
2858
|
TextAreaField,
|
|
2523
2859
|
TextField,
|
|
2524
2860
|
TupleField,
|
|
2525
2861
|
ViewEditor,
|
|
2526
2862
|
cellClassesForFieldType,
|
|
2527
|
-
controlItemClasses,
|
|
2528
2863
|
formatForDisplay,
|
|
2529
2864
|
formatForEditing,
|
|
2530
2865
|
getDefaultValue,
|