@dxos/react-ui-form 0.8.4-main.422d1c7879 → 0.8.4-main.43cb759274
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/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +1410 -755
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +83 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +1410 -755
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +85 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts +2 -2
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +64 -63
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +55 -13
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +145 -85
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +18 -8
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +26 -15
- package/dist/types/src/components/Form/FormFieldComponent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldSet.d.ts +11 -8
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts +19 -0
- package/dist/types/src/components/Form/FormTooltipsContext.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts +50 -0
- package/dist/types/src/components/Form/Layout/FormLayout.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts +119 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/FormLayout.stories.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/FormLayout.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/annotation.d.ts +30 -0
- package/dist/types/src/components/Form/Layout/annotation.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/index.d.ts +4 -0
- package/dist/types/src/components/Form/Layout/index.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/parser.d.ts +31 -0
- package/dist/types/src/components/Form/Layout/parser.d.ts.map +1 -0
- package/dist/types/src/components/Form/Layout/parser.test.d.ts +2 -0
- package/dist/types/src/components/Form/Layout/parser.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/ArrayField.d.ts +4 -4
- package/dist/types/src/components/Form/fields/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/BooleanField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/DateField.d.ts +4 -0
- package/dist/types/src/components/Form/fields/DateField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/GeoPointField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts +13 -0
- package/dist/types/src/components/Form/fields/InlineRefField.d.ts.map +1 -0
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/MarkdownField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts +65 -63
- package/dist/types/src/components/Form/fields/MarkdownField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/NumberField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts +4 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +64 -63
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TextAreaField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TextField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/TupleField.d.ts +1 -1
- package/dist/types/src/components/Form/fields/TupleField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/index.d.ts +2 -0
- package/dist/types/src/components/Form/fields/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts +3 -0
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/Form/meta-tags.d.ts +30 -0
- package/dist/types/src/components/Form/meta-tags.d.ts.map +1 -0
- package/dist/types/src/components/Form/meta-tags.test.d.ts +2 -0
- package/dist/types/src/components/Form/meta-tags.test.d.ts.map +1 -0
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts +3 -4
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts +3 -3
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +64 -63
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.d.ts.map +1 -1
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts +64 -63
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -1
- package/dist/types/src/components/ObjectTree/ObjectTree.d.ts +9 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.d.ts.map +1 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts +87 -0
- package/dist/types/src/components/ObjectTree/ObjectTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/ObjectTree/index.d.ts +2 -0
- package/dist/types/src/components/ObjectTree/index.d.ts.map +1 -0
- package/dist/types/src/components/Settings/Settings.d.ts +10 -2
- package/dist/types/src/components/Settings/Settings.d.ts.map +1 -1
- package/dist/types/src/components/Settings/Settings.stories.d.ts +64 -63
- package/dist/types/src/components/Settings/Settings.stories.d.ts.map +1 -1
- package/dist/types/src/components/Settings/SettingsFieldSet.d.ts +15 -10
- package/dist/types/src/components/Settings/SettingsFieldSet.d.ts.map +1 -1
- package/dist/types/src/components/Settings/SettingsItem.d.ts +8 -9
- package/dist/types/src/components/Settings/SettingsItem.d.ts.map +1 -1
- package/dist/types/src/components/Settings/SettingsSelectField.d.ts +18 -0
- package/dist/types/src/components/Settings/SettingsSelectField.d.ts.map +1 -0
- package/dist/types/src/components/Settings/index.d.ts +1 -0
- package/dist/types/src/components/Settings/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +9 -11
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +66 -66
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts +9 -0
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useKeyHandler.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +64 -63
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/field-type.d.ts +1 -1
- package/dist/types/src/util/field-type.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/properties.d.ts +18 -1
- package/dist/types/src/util/properties.d.ts.map +1 -1
- package/dist/types/src/util/properties.test.d.ts +2 -0
- package/dist/types/src/util/properties.test.d.ts.map +1 -0
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -33
- package/src/components/FieldEditor/FieldEditor.stories.tsx +4 -3
- package/src/components/FieldEditor/FieldEditor.test.tsx +4 -1
- package/src/components/FieldEditor/FieldEditor.tsx +22 -16
- package/src/components/Form/Form.stories.tsx +23 -28
- package/src/components/Form/Form.tsx +111 -24
- package/src/components/Form/FormField.tsx +87 -29
- package/src/components/Form/FormFieldComponent.tsx +77 -22
- package/src/components/Form/FormFieldSet.tsx +32 -3
- package/src/components/Form/FormTooltipsContext.ts +25 -0
- package/src/components/Form/Layout/FormLayout.stories.test.tsx +51 -0
- package/src/components/Form/Layout/FormLayout.stories.tsx +422 -0
- package/src/components/Form/Layout/FormLayout.test.ts +59 -0
- package/src/components/Form/Layout/FormLayout.tsx +251 -0
- package/src/components/Form/Layout/annotation.ts +38 -0
- package/src/components/Form/Layout/index.ts +7 -0
- package/src/components/Form/Layout/parser.test.ts +120 -0
- package/src/components/Form/Layout/parser.ts +167 -0
- package/src/components/Form/fields/ArrayField.tsx +63 -43
- package/src/components/Form/fields/DateField.tsx +101 -0
- package/src/components/Form/fields/GeoPointField.tsx +7 -3
- package/src/components/Form/fields/InlineRefField.tsx +146 -0
- package/src/components/Form/fields/MarkdownField.stories.tsx +56 -1
- package/src/components/Form/fields/MarkdownField.tsx +5 -4
- package/src/components/Form/fields/RefField.tsx +33 -26
- package/src/components/Form/fields/SelectField.tsx +17 -5
- package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -1
- package/src/components/Form/fields/SelectOptionField.tsx +10 -8
- package/src/components/Form/fields/TextAreaField.tsx +1 -1
- package/src/components/Form/fields/TupleField.tsx +2 -1
- package/src/components/Form/fields/index.ts +2 -0
- package/src/components/Form/index.ts +3 -0
- package/src/components/Form/meta-tags.test.ts +47 -0
- package/src/components/Form/meta-tags.ts +33 -0
- package/src/components/ObjectForm/ObjectForm.tsx +26 -30
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +10 -7
- package/src/components/ObjectPicker/ObjectPicker.tsx +20 -11
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +16 -27
- package/src/components/ObjectProperties/ObjectProperties.test.tsx +20 -10
- package/src/components/ObjectProperties/ObjectProperties.tsx +32 -28
- package/src/components/ObjectTree/ObjectTree.stories.tsx +134 -0
- package/src/components/ObjectTree/ObjectTree.tsx +190 -0
- package/src/components/ObjectTree/index.ts +5 -0
- package/src/components/Settings/AUDIT.md +51 -0
- package/src/components/Settings/Settings.stories.tsx +2 -1
- package/src/components/Settings/Settings.tsx +5 -5
- package/src/components/Settings/SettingsFieldSet.tsx +55 -9
- package/src/components/Settings/SettingsItem.tsx +4 -8
- package/src/components/Settings/SettingsSelectField.tsx +59 -0
- package/src/components/Settings/index.ts +1 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +40 -45
- package/src/components/ViewEditor/ViewEditor.test.tsx +11 -8
- package/src/components/ViewEditor/ViewEditor.tsx +37 -47
- package/src/components/index.ts +1 -0
- package/src/components/testing.tsx +5 -5
- package/src/index.ts +0 -4
- package/src/translations.ts +2 -1
- package/src/util/field-type.ts +4 -1
- package/src/util/properties.test.ts +121 -0
- package/src/util/properties.ts +47 -4
- package/src/vite-env.d.ts +10 -0
|
@@ -1,88 +1,11 @@
|
|
|
1
|
-
// src/translations.ts
|
|
2
|
-
var translationKey = "@dxos/react-ui-form";
|
|
3
|
-
var translations = [
|
|
4
|
-
{
|
|
5
|
-
"en-US": {
|
|
6
|
-
[translationKey]: {
|
|
7
|
-
"fields.label": "Fields",
|
|
8
|
-
"hidden-fields.label": "Hidden Fields",
|
|
9
|
-
"empty-readonly-ref-field.label": "(none)",
|
|
10
|
-
"field-property.label": "Property",
|
|
11
|
-
"field-property.placeholder": "Property name",
|
|
12
|
-
"field-format.label": "Type",
|
|
13
|
-
"field-path.label": "Field path",
|
|
14
|
-
"add-item.button": "Add item",
|
|
15
|
-
"add-property-button.label": "Add property",
|
|
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
|
-
"create-option.label": "Create",
|
|
22
|
-
"add-tag.label": "Add tag",
|
|
23
|
-
"ref-field-combobox-input.placeholder": "Search\u2026",
|
|
24
|
-
"ref-field.placeholder": "Select\u2026",
|
|
25
|
-
"ref-field.placeholder_one": "Select\u2026",
|
|
26
|
-
"ref-field.placeholder_other": "Select items\u2026",
|
|
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
|
-
"create-text.label": "Create text",
|
|
33
|
-
// TypeFormat
|
|
34
|
-
"format.boolean.label": "Boolean",
|
|
35
|
-
"format.currency.label": "Currency",
|
|
36
|
-
"format.date.label": "Date",
|
|
37
|
-
"format.date-time.label": "DateTime",
|
|
38
|
-
"format.did.label": "DID",
|
|
39
|
-
"format.duration.label": "Duration",
|
|
40
|
-
"format.dxn.label": "DXN",
|
|
41
|
-
"format.email.label": "Email",
|
|
42
|
-
"format.formula.label": "Formula",
|
|
43
|
-
"format.hostname.label": "Hostname",
|
|
44
|
-
"format.integer.label": "Integer",
|
|
45
|
-
"format.json.label": "JSON",
|
|
46
|
-
"format.lnglat.label": "Geopoint",
|
|
47
|
-
"format.markdown.label": "Markdown",
|
|
48
|
-
"format.percent.label": "Percent",
|
|
49
|
-
"format.ref.label": "Reference",
|
|
50
|
-
"format.regex.label": "RegExp",
|
|
51
|
-
"format.string.label": "String",
|
|
52
|
-
"format.single-select.label": "Select",
|
|
53
|
-
"format.multi-select.label": "Multi-select",
|
|
54
|
-
"format.text.label": "Long text",
|
|
55
|
-
"format.time.label": "Time",
|
|
56
|
-
"format.timestamp.label": "Timestamp",
|
|
57
|
-
"format.user.label": "User",
|
|
58
|
-
"format.number.label": "Number",
|
|
59
|
-
"format.uri.label": "URI",
|
|
60
|
-
"format.url.label": "URL",
|
|
61
|
-
"format.uuid.label": "UUID",
|
|
62
|
-
// GeoPointField.
|
|
63
|
-
"latitude.label": "Latitude",
|
|
64
|
-
"longitude.label": "Longitude",
|
|
65
|
-
// SelectOptionsField.
|
|
66
|
-
"select-option.label": "Label",
|
|
67
|
-
"select-option-label.placeholder": "Option label",
|
|
68
|
-
"select-option-delete.button": "Delete",
|
|
69
|
-
"select-option-add.button": "Add option",
|
|
70
|
-
// System schema message.
|
|
71
|
-
"system-schema.title": "System type",
|
|
72
|
-
"system-schema.description": "System type: cannot add or remove fields.",
|
|
73
|
-
"remove.button": "Remove"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
];
|
|
78
|
-
|
|
79
1
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
80
|
-
import
|
|
81
|
-
import { Obj as
|
|
82
|
-
import { Format as
|
|
2
|
+
import React20, { useCallback as useCallback16, useEffect as useEffect5, useMemo as useMemo10, useState as useState6 } from "react";
|
|
3
|
+
import { Filter as Filter2, Obj as Obj4, Type as Type4 } from "@dxos/echo";
|
|
4
|
+
import { Format as Format6, FormatEnums, formatToType } from "@dxos/echo/internal";
|
|
83
5
|
import { log as log2 } from "@dxos/log";
|
|
84
|
-
import { useAsyncEffect, useTranslation as
|
|
6
|
+
import { useAsyncEffect, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
85
7
|
import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
|
|
8
|
+
import { translationKey as translationKey10 } from "#translations";
|
|
86
9
|
|
|
87
10
|
// src/util/field.ts
|
|
88
11
|
import { Format, GeoLocation, TypeEnum } from "@dxos/echo/internal";
|
|
@@ -212,6 +135,9 @@ var detectFieldType = (ast) => {
|
|
|
212
135
|
if (isLiteralUnion(ast)) {
|
|
213
136
|
return "select";
|
|
214
137
|
}
|
|
138
|
+
if (SchemaAST.isTypeLiteral(ast)) {
|
|
139
|
+
return "struct";
|
|
140
|
+
}
|
|
215
141
|
switch (ast._tag) {
|
|
216
142
|
case "BooleanKeyword":
|
|
217
143
|
return "boolean";
|
|
@@ -382,18 +308,41 @@ var formatForEditing = ({ type, format, value: value3, locale = void 0 }) => {
|
|
|
382
308
|
|
|
383
309
|
// src/util/properties.ts
|
|
384
310
|
import * as Option from "effect/Option";
|
|
311
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
385
312
|
import { Annotation } from "@dxos/echo";
|
|
386
|
-
import { getProperties } from "@dxos/effect";
|
|
313
|
+
import { getProperties, isArrayType, isNestedType } from "@dxos/effect";
|
|
314
|
+
var unwrapOptional = (prop) => {
|
|
315
|
+
if (!prop.isOptional || !SchemaAST2.isUnion(prop.type)) {
|
|
316
|
+
return prop.type;
|
|
317
|
+
}
|
|
318
|
+
const defined = prop.type.types.filter((type) => type._tag !== "UndefinedKeyword");
|
|
319
|
+
if (defined.length === 0) {
|
|
320
|
+
return prop.type;
|
|
321
|
+
}
|
|
322
|
+
return defined.length === 1 ? defined[0] : SchemaAST2.Union.make(defined, prop.type.annotations);
|
|
323
|
+
};
|
|
387
324
|
var getFormProperties = (ast) => {
|
|
388
|
-
|
|
325
|
+
const signatures = SchemaAST2.getPropertySignatures(ast);
|
|
326
|
+
const rawByName = new Map(signatures.map((prop) => [
|
|
327
|
+
prop.name,
|
|
328
|
+
unwrapOptional(prop)
|
|
329
|
+
]));
|
|
330
|
+
const hidden = new Set(signatures.filter((prop) => Annotation.FormInputAnnotation.getFromAst(unwrapOptional(prop)).pipe(Option.getOrElse(() => true)) === false).map((prop) => prop.name));
|
|
331
|
+
return getProperties(ast).filter((prop) => !hidden.has(prop.name)).map((prop) => {
|
|
332
|
+
const raw = rawByName.get(prop.name);
|
|
333
|
+
return raw && (isNestedType(raw) || isArrayType(raw)) ? {
|
|
334
|
+
...prop,
|
|
335
|
+
type: raw
|
|
336
|
+
} : prop;
|
|
337
|
+
});
|
|
389
338
|
};
|
|
390
339
|
|
|
391
340
|
// src/util/refs.ts
|
|
392
341
|
import { Ref } from "@dxos/echo";
|
|
393
342
|
import { ReferenceAnnotationId } from "@dxos/echo/internal";
|
|
394
|
-
import { findAnnotation, getArrayElementType, isArrayType } from "@dxos/effect";
|
|
343
|
+
import { findAnnotation, getArrayElementType, isArrayType as isArrayType2 } from "@dxos/effect";
|
|
395
344
|
var getRefProps = (ast) => {
|
|
396
|
-
if (
|
|
345
|
+
if (isArrayType2(ast)) {
|
|
397
346
|
const elementType = getArrayElementType(ast);
|
|
398
347
|
if (elementType) {
|
|
399
348
|
if (Ref.isRefType(elementType)) {
|
|
@@ -418,22 +367,26 @@ var getRefProps = (ast) => {
|
|
|
418
367
|
};
|
|
419
368
|
|
|
420
369
|
// src/components/Form/fields/ArrayField.tsx
|
|
421
|
-
import * as
|
|
422
|
-
import * as
|
|
423
|
-
import
|
|
424
|
-
import {
|
|
425
|
-
import {
|
|
370
|
+
import * as Option6 from "effect/Option";
|
|
371
|
+
import * as SchemaAST6 from "effect/SchemaAST";
|
|
372
|
+
import React6, { useCallback as useCallback3 } from "react";
|
|
373
|
+
import { Ref as Ref2 } from "@dxos/echo";
|
|
374
|
+
import { createJsonPath as createJsonPath6, findNode as findNode3, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType3 } from "@dxos/effect";
|
|
375
|
+
import { useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
376
|
+
import { translationKey as translationKey3 } from "#translations";
|
|
426
377
|
|
|
427
378
|
// src/components/Form/Form.tsx
|
|
428
|
-
import { createContext } from "@radix-ui/react-context";
|
|
429
|
-
import * as
|
|
430
|
-
import * as
|
|
431
|
-
import * as
|
|
432
|
-
import
|
|
433
|
-
import { Annotation as EchoAnnotation } from "@dxos/echo";
|
|
434
|
-
import { createJsonPath as
|
|
435
|
-
import { IconButton, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
436
|
-
import { composable, composableProps,
|
|
379
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
380
|
+
import * as Option5 from "effect/Option";
|
|
381
|
+
import * as Schema3 from "effect/Schema";
|
|
382
|
+
import * as SchemaAST5 from "effect/SchemaAST";
|
|
383
|
+
import React5, { useEffect as useEffect2, useMemo as useMemo5, useRef } from "react";
|
|
384
|
+
import { Annotation as EchoAnnotation, Type } from "@dxos/echo";
|
|
385
|
+
import { createJsonPath as createJsonPath5, getValue as getValue$2 } from "@dxos/effect";
|
|
386
|
+
import { Column, IconButton as IconButton2, Input as Input3, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
387
|
+
import { composable, composableProps, withColumn } from "@dxos/react-ui";
|
|
388
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
389
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
437
390
|
|
|
438
391
|
// src/hooks/useFormHandler.ts
|
|
439
392
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
@@ -471,12 +424,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
471
424
|
log("validate", {
|
|
472
425
|
values: values2,
|
|
473
426
|
errors: errors2
|
|
474
|
-
}, {
|
|
475
|
-
F: __dxlog_file,
|
|
476
|
-
L: 155,
|
|
477
|
-
S: void 0,
|
|
478
|
-
C: (f, a) => f(...a)
|
|
479
|
-
});
|
|
427
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 42, S: void 0 });
|
|
480
428
|
if (errors2.length === 0 && onValidate) {
|
|
481
429
|
const validatedValues = values2;
|
|
482
430
|
errors2 = onValidate(validatedValues) ?? [];
|
|
@@ -564,12 +512,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
564
512
|
log("onValueChange", {
|
|
565
513
|
path,
|
|
566
514
|
value: value3
|
|
567
|
-
}, {
|
|
568
|
-
F: __dxlog_file,
|
|
569
|
-
L: 254,
|
|
570
|
-
S: void 0,
|
|
571
|
-
C: (f, a) => f(...a)
|
|
572
|
-
});
|
|
515
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 138, S: void 0 });
|
|
573
516
|
const jsonPath = createJsonPath(path);
|
|
574
517
|
const pathArray = path;
|
|
575
518
|
let parsedValue = value3;
|
|
@@ -578,12 +521,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
578
521
|
parsedValue = parseFloat(value3) || 0;
|
|
579
522
|
}
|
|
580
523
|
} catch (err) {
|
|
581
|
-
log.catch(err, void 0, {
|
|
582
|
-
F: __dxlog_file,
|
|
583
|
-
L: 264,
|
|
584
|
-
S: void 0,
|
|
585
|
-
C: (f, a) => f(...a)
|
|
586
|
-
});
|
|
524
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 150, S: void 0 });
|
|
587
525
|
parsedValue = void 0;
|
|
588
526
|
}
|
|
589
527
|
const newValues = mergeAtPath(values, pathArray, parsedValue);
|
|
@@ -667,18 +605,18 @@ var mergeAtPath = (obj, path, value3) => {
|
|
|
667
605
|
if (path.length === 0) {
|
|
668
606
|
return value3;
|
|
669
607
|
}
|
|
670
|
-
const [
|
|
671
|
-
const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[
|
|
608
|
+
const [head, ...rest] = path;
|
|
609
|
+
const child = rest.length === 0 ? value3 : mergeAtPath(obj?.[head], rest, value3);
|
|
672
610
|
if (Array.isArray(obj)) {
|
|
673
611
|
const copy = [
|
|
674
612
|
...obj
|
|
675
613
|
];
|
|
676
|
-
copy[
|
|
614
|
+
copy[head] = child;
|
|
677
615
|
return copy;
|
|
678
616
|
}
|
|
679
617
|
return {
|
|
680
618
|
...obj,
|
|
681
|
-
[
|
|
619
|
+
[head]: child
|
|
682
620
|
};
|
|
683
621
|
};
|
|
684
622
|
var flatMap = (errors) => {
|
|
@@ -723,17 +661,32 @@ var useKeyHandler = (elRef, form) => {
|
|
|
723
661
|
};
|
|
724
662
|
|
|
725
663
|
// src/components/Form/FormFieldComponent.tsx
|
|
664
|
+
import { format as formatDate2 } from "date-fns";
|
|
726
665
|
import React, { Component } from "react";
|
|
666
|
+
import { Format as Format3 } from "@dxos/echo";
|
|
727
667
|
import { Icon, Input, Tooltip } from "@dxos/react-ui";
|
|
728
|
-
import { inputTextLabel } from "@dxos/ui
|
|
729
|
-
|
|
668
|
+
import { inputTextLabel } from "@dxos/react-ui";
|
|
669
|
+
import { mx } from "@dxos/ui-theme";
|
|
670
|
+
|
|
671
|
+
// src/components/Form/FormTooltipsContext.ts
|
|
672
|
+
import { createContext, useContext } from "react";
|
|
673
|
+
var FormTooltipsContext = createContext(true);
|
|
674
|
+
var useFormTooltips = () => useContext(FormTooltipsContext);
|
|
675
|
+
|
|
676
|
+
// src/components/Form/FormFieldComponent.tsx
|
|
677
|
+
var FormFieldLabel = ({ label, error, readonly, asChild, path }) => {
|
|
678
|
+
const tooltips = useFormTooltips();
|
|
730
679
|
const Label = readonly || asChild ? "span" : Input.Label;
|
|
680
|
+
const labelNode = /* @__PURE__ */ React.createElement(Label, {
|
|
681
|
+
className: mx(inputTextLabel, "text-sm")
|
|
682
|
+
}, label);
|
|
731
683
|
return /* @__PURE__ */ React.createElement("div", {
|
|
732
|
-
role: "none",
|
|
733
684
|
className: "flex items-center justify-between"
|
|
734
|
-
}, /* @__PURE__ */ React.createElement(
|
|
735
|
-
|
|
736
|
-
|
|
685
|
+
}, tooltips && path ? /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
686
|
+
asChild: true,
|
|
687
|
+
content: path,
|
|
688
|
+
side: "bottom"
|
|
689
|
+
}, labelNode) : labelNode, error && /* @__PURE__ */ React.createElement(Tooltip.Trigger, {
|
|
737
690
|
asChild: true,
|
|
738
691
|
content: error,
|
|
739
692
|
side: "bottom"
|
|
@@ -744,26 +697,48 @@ var FormFieldLabel = ({ label, error, readonly, asChild }) => {
|
|
|
744
697
|
})));
|
|
745
698
|
};
|
|
746
699
|
FormFieldLabel.displayName = "Form.FieldLabel";
|
|
700
|
+
var formatStaticValue = (value3, format) => {
|
|
701
|
+
if (value3 == null) {
|
|
702
|
+
return "";
|
|
703
|
+
}
|
|
704
|
+
switch (format) {
|
|
705
|
+
case Format3.TypeFormat.DateTime:
|
|
706
|
+
case Format3.TypeFormat.Date:
|
|
707
|
+
case Format3.TypeFormat.Time: {
|
|
708
|
+
const date = new Date(value3);
|
|
709
|
+
if (Number.isNaN(date.getTime())) {
|
|
710
|
+
return String(value3);
|
|
711
|
+
}
|
|
712
|
+
const pattern = format === Format3.TypeFormat.DateTime ? "PPp" : format === Format3.TypeFormat.Date ? "PP" : "p";
|
|
713
|
+
return formatDate2(date, pattern);
|
|
714
|
+
}
|
|
715
|
+
default:
|
|
716
|
+
return String(value3);
|
|
717
|
+
}
|
|
718
|
+
};
|
|
747
719
|
var FormFieldWrapper = (props) => {
|
|
748
|
-
const { children, readonly, layout, label, getStatus, getValue } = props;
|
|
720
|
+
const { children, readonly, layout, label, jsonPath, format, getStatus, getValue } = props;
|
|
749
721
|
const { status, error } = getStatus();
|
|
750
722
|
const value3 = getValue();
|
|
751
723
|
if (layout === "static" && value3 == null) {
|
|
752
724
|
return null;
|
|
753
725
|
}
|
|
754
|
-
const str =
|
|
726
|
+
const str = formatStaticValue(value3, format);
|
|
755
727
|
return /* @__PURE__ */ React.createElement("div", {
|
|
756
|
-
role: "none",
|
|
757
728
|
className: "contents"
|
|
758
729
|
}, /* @__PURE__ */ React.createElement(Input.Root, {
|
|
759
730
|
validationValence: status
|
|
760
731
|
}, layout !== "inline" && /* @__PURE__ */ React.createElement(FormFieldLabel, {
|
|
761
732
|
error,
|
|
762
733
|
readonly,
|
|
763
|
-
label
|
|
764
|
-
|
|
734
|
+
label,
|
|
735
|
+
path: jsonPath
|
|
736
|
+
}), layout === "static" ? /* @__PURE__ */ React.createElement("p", {
|
|
737
|
+
className: "truncate min-w-0",
|
|
738
|
+
title: str
|
|
739
|
+
}, str) : children ? children({
|
|
765
740
|
value: value3
|
|
766
|
-
}) : null, layout === "full" && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
|
|
741
|
+
}) : null, layout === "full" && error && /* @__PURE__ */ React.createElement(Input.DescriptionAndValidation, null, /* @__PURE__ */ React.createElement(Input.Validation, null, error))));
|
|
767
742
|
};
|
|
768
743
|
var FormFieldErrorBoundary = class extends Component {
|
|
769
744
|
static getDerivedStateFromError(error) {
|
|
@@ -782,9 +757,9 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
782
757
|
render() {
|
|
783
758
|
if (this.state.error) {
|
|
784
759
|
return /* @__PURE__ */ React.createElement("div", {
|
|
785
|
-
className: "flex gap-2 border border-rose-
|
|
760
|
+
className: "flex gap-2 border border-rose-bg font-mono text-sm"
|
|
786
761
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
787
|
-
className: "bg-rose-
|
|
762
|
+
className: "bg-rose-bg text-base-fg px-1 font-thin"
|
|
788
763
|
}, "ERROR"), String(this.props.path?.join(".")));
|
|
789
764
|
}
|
|
790
765
|
return this.props.children;
|
|
@@ -797,18 +772,22 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
797
772
|
};
|
|
798
773
|
|
|
799
774
|
// src/components/Form/FormFieldSet.tsx
|
|
800
|
-
import
|
|
775
|
+
import * as Option4 from "effect/Option";
|
|
776
|
+
import React4, { useMemo as useMemo4 } from "react";
|
|
777
|
+
import { createJsonPath as createJsonPath4 } from "@dxos/effect";
|
|
801
778
|
|
|
802
779
|
// src/components/Form/FormField.tsx
|
|
803
780
|
import * as Match from "effect/Match";
|
|
804
781
|
import * as Option2 from "effect/Option";
|
|
805
782
|
import * as Schema from "effect/Schema";
|
|
806
|
-
import * as
|
|
783
|
+
import * as SchemaAST3 from "effect/SchemaAST";
|
|
807
784
|
import * as String2 from "effect/String";
|
|
808
785
|
import React2, { useMemo as useMemo2 } from "react";
|
|
809
|
-
import { Format as
|
|
810
|
-
import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as
|
|
811
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
786
|
+
import { Annotation as Annotation2, Format as Format4 } from "@dxos/echo";
|
|
787
|
+
import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as isArrayType3, isDiscriminatedUnion, isLiteralUnion as isLiteralUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
|
|
788
|
+
import { IconButton, useTranslation } from "@dxos/react-ui";
|
|
789
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
790
|
+
import { translationKey } from "#translations";
|
|
812
791
|
var FormField = (props) => {
|
|
813
792
|
const {
|
|
814
793
|
type,
|
|
@@ -826,15 +805,15 @@ var FormField = (props) => {
|
|
|
826
805
|
createInitialValuePath,
|
|
827
806
|
createFieldMap: createFieldMap3,
|
|
828
807
|
db,
|
|
829
|
-
|
|
808
|
+
useType: schemaHook,
|
|
830
809
|
getOptions,
|
|
831
810
|
onCreate
|
|
832
811
|
} = props;
|
|
833
812
|
const { t } = useTranslation(translationKey);
|
|
834
|
-
const title = getAnnotation2(
|
|
835
|
-
const description = getAnnotation2(
|
|
836
|
-
const examples = getAnnotation2(
|
|
837
|
-
const label = useMemo2(() => title ?? String2.capitalize(name), [
|
|
813
|
+
const title = getAnnotation2(SchemaAST3.TitleAnnotationId)(type);
|
|
814
|
+
const description = getAnnotation2(SchemaAST3.DescriptionAnnotationId)(type);
|
|
815
|
+
const examples = getAnnotation2(SchemaAST3.ExamplesAnnotationId)(type);
|
|
816
|
+
const label = useMemo2(() => title ?? (name == null ? "" : String2.capitalize(name)), [
|
|
838
817
|
title,
|
|
839
818
|
name
|
|
840
819
|
]);
|
|
@@ -844,30 +823,34 @@ var FormField = (props) => {
|
|
|
844
823
|
label
|
|
845
824
|
]);
|
|
846
825
|
const fieldState = useFormFieldState(FormField.displayName, path);
|
|
826
|
+
const jsonPath = createJsonPath2(path ?? []);
|
|
847
827
|
const fieldProps = {
|
|
848
828
|
type,
|
|
849
|
-
format:
|
|
829
|
+
format: Format4.FormatAnnotation.getFromAst(type).pipe((annotation) => Option2.getOrUndefined(annotation)),
|
|
850
830
|
readonly,
|
|
851
831
|
label,
|
|
832
|
+
jsonPath,
|
|
852
833
|
placeholder,
|
|
853
834
|
layout,
|
|
854
835
|
db,
|
|
855
836
|
...fieldState
|
|
856
837
|
};
|
|
857
|
-
|
|
838
|
+
if (readonly && fieldState.getValue() == null) {
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
858
841
|
const CustomField = fieldMap?.[jsonPath];
|
|
859
842
|
if (CustomField) {
|
|
860
843
|
return /* @__PURE__ */ React2.createElement(CustomField, fieldProps);
|
|
861
844
|
}
|
|
862
845
|
const component = fieldProvider?.({
|
|
863
846
|
schema: Schema.make(type),
|
|
864
|
-
prop: name,
|
|
847
|
+
prop: name ?? "",
|
|
865
848
|
fieldProps
|
|
866
849
|
});
|
|
867
850
|
if (component) {
|
|
868
851
|
return component;
|
|
869
852
|
}
|
|
870
|
-
if (
|
|
853
|
+
if (isArrayType3(type)) {
|
|
871
854
|
return /* @__PURE__ */ React2.createElement(ArrayField, {
|
|
872
855
|
fieldProps: fieldState,
|
|
873
856
|
label,
|
|
@@ -896,6 +879,16 @@ var FormField = (props) => {
|
|
|
896
879
|
}
|
|
897
880
|
const refProps = getRefProps(type);
|
|
898
881
|
if (refProps) {
|
|
882
|
+
const inline = Annotation2.FormInlineAnnotation.getFromAst(refProps.ast).pipe(Option2.getOrElse(() => false));
|
|
883
|
+
if (inline && !refProps.isArray) {
|
|
884
|
+
return /* @__PURE__ */ React2.createElement(InlineRefField, {
|
|
885
|
+
...fieldProps,
|
|
886
|
+
...refProps,
|
|
887
|
+
db,
|
|
888
|
+
useType: schemaHook,
|
|
889
|
+
onCreate
|
|
890
|
+
});
|
|
891
|
+
}
|
|
899
892
|
const isCreateTarget = !createTypename || refProps.typename === createTypename;
|
|
900
893
|
return /* @__PURE__ */ React2.createElement(RefField, {
|
|
901
894
|
...fieldProps,
|
|
@@ -905,17 +898,17 @@ var FormField = (props) => {
|
|
|
905
898
|
createInitialValuePath: isCreateTarget ? createInitialValuePath : void 0,
|
|
906
899
|
createFieldMap: isCreateTarget ? createFieldMap3 : void 0,
|
|
907
900
|
db,
|
|
908
|
-
|
|
901
|
+
useType: schemaHook,
|
|
909
902
|
getOptions,
|
|
910
903
|
onCreate
|
|
911
904
|
});
|
|
912
905
|
}
|
|
913
|
-
if (
|
|
906
|
+
if (isNestedType2(type)) {
|
|
914
907
|
const baseNode = findNode(type, isDiscriminatedUnion);
|
|
915
|
-
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type,
|
|
908
|
+
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, fieldState.getValue()) : findNode(type, SchemaAST3.isTypeLiteral);
|
|
916
909
|
if (typeLiteral) {
|
|
917
910
|
const schema = Schema.make(typeLiteral);
|
|
918
|
-
return /* @__PURE__ */ React2.createElement(FormFieldSet, {
|
|
911
|
+
return /* @__PURE__ */ React2.createElement(Nesting, null, /* @__PURE__ */ React2.createElement(FormFieldSet, {
|
|
919
912
|
schema,
|
|
920
913
|
path,
|
|
921
914
|
readonly,
|
|
@@ -928,17 +921,33 @@ var FormField = (props) => {
|
|
|
928
921
|
createOptionIcon,
|
|
929
922
|
createInitialValuePath,
|
|
930
923
|
db,
|
|
931
|
-
|
|
924
|
+
useType: schemaHook,
|
|
932
925
|
getOptions,
|
|
933
926
|
onCreate
|
|
934
|
-
});
|
|
927
|
+
}));
|
|
935
928
|
}
|
|
936
929
|
}
|
|
937
930
|
return null;
|
|
938
931
|
};
|
|
939
932
|
FormField.displayName = "Form.FormField";
|
|
933
|
+
var Nesting = ({ children }) => /* @__PURE__ */ React2.createElement("div", {
|
|
934
|
+
className: "px-2 border border-subdued-separator rounded-sm mt-2"
|
|
935
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
936
|
+
className: "pb-2"
|
|
937
|
+
}, children));
|
|
938
|
+
var IconBlock = ({ inline, ...props }) => {
|
|
939
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
940
|
+
className: mx2("h-full flex px-1", inline ? "items-center" : "flex-col pt-2.5")
|
|
941
|
+
}, /* @__PURE__ */ React2.createElement(IconButton, {
|
|
942
|
+
variant: "ghost",
|
|
943
|
+
density: "xs",
|
|
944
|
+
square: true,
|
|
945
|
+
iconOnly: true,
|
|
946
|
+
...props
|
|
947
|
+
}));
|
|
948
|
+
};
|
|
940
949
|
var getFormField = ({ type, format }) => {
|
|
941
|
-
const formatField = Match.value(format).pipe(Match.withReturnType(), Match.when(
|
|
950
|
+
const formatField = Match.value(format).pipe(Match.withReturnType(), Match.when(Format4.TypeFormat.Date, () => DateField), Match.when(Format4.TypeFormat.DateTime, () => DateField), Match.when(Format4.TypeFormat.GeoPoint, () => GeoPointField), Match.when(Format4.TypeFormat.Markdown, () => MarkdownField), Match.when(Format4.TypeFormat.Text, () => TextAreaField), Match.when(Format4.TypeFormat.Time, () => DateField), Match.orElse(() => void 0));
|
|
942
951
|
if (formatField) {
|
|
943
952
|
return formatField;
|
|
944
953
|
}
|
|
@@ -957,12 +966,283 @@ var getSelectOptions = (ast) => {
|
|
|
957
966
|
if (isLiteralUnion2(ast)) {
|
|
958
967
|
return ast.types.map((type) => type.literal).filter((v) => v !== null);
|
|
959
968
|
}
|
|
960
|
-
return
|
|
969
|
+
return Format4.OptionsAnnotation.getFromAst(ast).pipe((annotation) => Option2.getOrUndefined(annotation));
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
// src/components/Form/Layout/annotation.ts
|
|
973
|
+
import { createAnnotationHelper } from "@dxos/echo/internal";
|
|
974
|
+
var FormLayoutAnnotationId = /* @__PURE__ */ Symbol.for("@dxos/react-ui-form/annotation/Layout");
|
|
975
|
+
var FormLayoutAnnotation = createAnnotationHelper(FormLayoutAnnotationId);
|
|
976
|
+
var DEFAULT_LAYOUT_NAME = "default";
|
|
977
|
+
|
|
978
|
+
// src/components/Form/Layout/FormLayout.tsx
|
|
979
|
+
import * as Option3 from "effect/Option";
|
|
980
|
+
import * as Schema2 from "effect/Schema";
|
|
981
|
+
import * as SchemaAST4 from "effect/SchemaAST";
|
|
982
|
+
import * as String3 from "effect/String";
|
|
983
|
+
import React3, { Fragment, useMemo as useMemo3 } from "react";
|
|
984
|
+
import { Annotation as Annotation3 } from "@dxos/echo";
|
|
985
|
+
import { createJsonPath as createJsonPath3, findNode as findNode2, getAnnotation as getAnnotation3, getBaseType } from "@dxos/effect";
|
|
986
|
+
import { Input as Input2 } from "@dxos/react-ui";
|
|
987
|
+
|
|
988
|
+
// src/components/Form/Layout/parser.ts
|
|
989
|
+
var LayoutParseError = class extends Error {
|
|
990
|
+
position;
|
|
991
|
+
_tag = "LayoutParseError";
|
|
992
|
+
constructor(message, position) {
|
|
993
|
+
super(position !== void 0 ? `${message} (at position ${position})` : message), this.position = position;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
var TAG_RE = /<\s*(\/?)\s*(\w+)([^>]*?)(\/?)\s*>/g;
|
|
997
|
+
var ATTR_RE = /([\w-]+)\s*=\s*(?:"([^"]*)"|'([^']*)'|(\d+))/g;
|
|
998
|
+
var parseAttrs = (raw) => {
|
|
999
|
+
const attrs = {};
|
|
1000
|
+
ATTR_RE.lastIndex = 0;
|
|
1001
|
+
let match;
|
|
1002
|
+
while ((match = ATTR_RE.exec(raw)) !== null) {
|
|
1003
|
+
const [, key, doubleQuoted, singleQuoted, bare] = match;
|
|
1004
|
+
attrs[key] = doubleQuoted ?? singleQuoted ?? bare;
|
|
1005
|
+
}
|
|
1006
|
+
return attrs;
|
|
1007
|
+
};
|
|
1008
|
+
var tokenize = (input) => {
|
|
1009
|
+
const tokens = [];
|
|
1010
|
+
TAG_RE.lastIndex = 0;
|
|
1011
|
+
let match;
|
|
1012
|
+
let cursor = 0;
|
|
1013
|
+
while ((match = TAG_RE.exec(input)) !== null) {
|
|
1014
|
+
const between = input.slice(cursor, match.index);
|
|
1015
|
+
if (between.trim().length > 0) {
|
|
1016
|
+
throw new LayoutParseError(`unexpected text content: ${JSON.stringify(between.trim())}`, cursor);
|
|
1017
|
+
}
|
|
1018
|
+
const [, slash, name, attrsRaw, selfSlash] = match;
|
|
1019
|
+
if (slash) {
|
|
1020
|
+
tokens.push({
|
|
1021
|
+
type: "close",
|
|
1022
|
+
name,
|
|
1023
|
+
position: match.index
|
|
1024
|
+
});
|
|
1025
|
+
} else {
|
|
1026
|
+
tokens.push({
|
|
1027
|
+
type: "open",
|
|
1028
|
+
name,
|
|
1029
|
+
attrs: parseAttrs(attrsRaw),
|
|
1030
|
+
selfClosing: selfSlash === "/",
|
|
1031
|
+
position: match.index
|
|
1032
|
+
});
|
|
1033
|
+
}
|
|
1034
|
+
cursor = match.index + match[0].length;
|
|
1035
|
+
}
|
|
1036
|
+
const trailing = input.slice(cursor);
|
|
1037
|
+
if (trailing.trim().length > 0) {
|
|
1038
|
+
throw new LayoutParseError(`unexpected text content: ${JSON.stringify(trailing.trim())}`, cursor);
|
|
1039
|
+
}
|
|
1040
|
+
return tokens;
|
|
1041
|
+
};
|
|
1042
|
+
var requireAttr = (attrs, key, tag, position) => {
|
|
1043
|
+
const value3 = attrs[key];
|
|
1044
|
+
if (value3 === void 0) {
|
|
1045
|
+
throw new LayoutParseError(`<${tag}> missing required attribute "${key}"`, position);
|
|
1046
|
+
}
|
|
1047
|
+
return value3;
|
|
1048
|
+
};
|
|
1049
|
+
var parseInteger = (value3, attr, tag, position) => {
|
|
1050
|
+
if (!/^\d+$/.test(value3)) {
|
|
1051
|
+
throw new LayoutParseError(`<${tag}> attribute "${attr}" expects an integer, got ${JSON.stringify(value3)}`, position);
|
|
1052
|
+
}
|
|
1053
|
+
return Number.parseInt(value3, 10);
|
|
1054
|
+
};
|
|
1055
|
+
var parseLayout = (template) => {
|
|
1056
|
+
const tokens = tokenize(template);
|
|
1057
|
+
if (tokens.length === 0) {
|
|
1058
|
+
throw new LayoutParseError("empty template");
|
|
1059
|
+
}
|
|
1060
|
+
let index = 0;
|
|
1061
|
+
const parseNode = () => {
|
|
1062
|
+
const token = tokens[index];
|
|
1063
|
+
if (!token || token.type !== "open") {
|
|
1064
|
+
throw new LayoutParseError(`expected an opening tag, got ${JSON.stringify(token)}`, token?.position);
|
|
1065
|
+
}
|
|
1066
|
+
if (token.name === "field") {
|
|
1067
|
+
if (!token.selfClosing) {
|
|
1068
|
+
throw new LayoutParseError('<field> must be self-closing (e.g. <field name="x"/>)', token.position);
|
|
1069
|
+
}
|
|
1070
|
+
const name = requireAttr(token.attrs, "name", "field", token.position);
|
|
1071
|
+
const spanRaw = token.attrs.span;
|
|
1072
|
+
const span = spanRaw !== void 0 ? parseInteger(spanRaw, "span", "field", token.position) : void 0;
|
|
1073
|
+
index += 1;
|
|
1074
|
+
return {
|
|
1075
|
+
kind: "field",
|
|
1076
|
+
name,
|
|
1077
|
+
span
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
if (token.name === "grid") {
|
|
1081
|
+
if (token.selfClosing) {
|
|
1082
|
+
throw new LayoutParseError("<grid> must wrap children (cannot self-close)", token.position);
|
|
1083
|
+
}
|
|
1084
|
+
const cols = parseInteger(requireAttr(token.attrs, "cols", "grid", token.position), "cols", "grid", token.position);
|
|
1085
|
+
index += 1;
|
|
1086
|
+
const children = [];
|
|
1087
|
+
while (index < tokens.length && !(tokens[index].type === "close" && tokens[index].name === "grid")) {
|
|
1088
|
+
children.push(parseNode());
|
|
1089
|
+
}
|
|
1090
|
+
const closing = tokens[index];
|
|
1091
|
+
if (!closing || closing.type !== "close" || closing.name !== "grid") {
|
|
1092
|
+
throw new LayoutParseError("<grid> not closed", token.position);
|
|
1093
|
+
}
|
|
1094
|
+
index += 1;
|
|
1095
|
+
return {
|
|
1096
|
+
kind: "grid",
|
|
1097
|
+
cols,
|
|
1098
|
+
children
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
throw new LayoutParseError(`unknown element <${token.name}>`, token.position);
|
|
1102
|
+
};
|
|
1103
|
+
const root = parseNode();
|
|
1104
|
+
if (index !== tokens.length) {
|
|
1105
|
+
const trailing = tokens[index];
|
|
1106
|
+
throw new LayoutParseError(`unexpected trailing tag <${trailing.type === "open" ? "" : "/"}${trailing.name}>`, trailing.position);
|
|
1107
|
+
}
|
|
1108
|
+
if (root.kind !== "grid") {
|
|
1109
|
+
throw new LayoutParseError("root element must be <grid>");
|
|
1110
|
+
}
|
|
1111
|
+
return root;
|
|
1112
|
+
};
|
|
1113
|
+
|
|
1114
|
+
// src/components/Form/Layout/FormLayout.tsx
|
|
1115
|
+
var FORM_LAYOUT_NAME = "Form.Layout";
|
|
1116
|
+
var FormLayout = ({ schema, template, name = DEFAULT_LAYOUT_NAME, path, readonly, layout, projection, ...props }) => {
|
|
1117
|
+
const annotated = Option3.getOrUndefined(FormLayoutAnnotation.get(schema));
|
|
1118
|
+
const source = template ?? annotated?.[name];
|
|
1119
|
+
if (source === void 0) {
|
|
1120
|
+
throw new LayoutParseError(annotated ? `no layout named "${name}" on schema (available: ${Object.keys(annotated).join(", ") || "\u2205"})` : `no template provided and schema has no FormLayoutAnnotation`);
|
|
1121
|
+
}
|
|
1122
|
+
const tree = useMemo3(() => parseLayout(source), [
|
|
1123
|
+
source
|
|
1124
|
+
]);
|
|
1125
|
+
return /* @__PURE__ */ React3.createElement(RenderNode, {
|
|
1126
|
+
node: tree,
|
|
1127
|
+
schema,
|
|
1128
|
+
basePath: path ?? [],
|
|
1129
|
+
readonly,
|
|
1130
|
+
layout,
|
|
1131
|
+
projection,
|
|
1132
|
+
...props
|
|
1133
|
+
});
|
|
1134
|
+
};
|
|
1135
|
+
FormLayout.displayName = FORM_LAYOUT_NAME;
|
|
1136
|
+
var RenderNode = ({ node, schema, basePath, ...props }) => {
|
|
1137
|
+
if (node.kind === "grid") {
|
|
1138
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1139
|
+
className: "grid gap-x-form-gap",
|
|
1140
|
+
style: {
|
|
1141
|
+
gridTemplateColumns: `repeat(${node.cols}, minmax(0, 1fr))`
|
|
1142
|
+
}
|
|
1143
|
+
}, node.children.map((child, index) => /* @__PURE__ */ React3.createElement(Fragment, {
|
|
1144
|
+
key: index
|
|
1145
|
+
}, /* @__PURE__ */ React3.createElement(RenderNode, {
|
|
1146
|
+
node: child,
|
|
1147
|
+
schema,
|
|
1148
|
+
basePath,
|
|
1149
|
+
...props
|
|
1150
|
+
}))));
|
|
1151
|
+
}
|
|
1152
|
+
const resolved = resolveLayoutField(schema, node.name);
|
|
1153
|
+
if (!resolved) {
|
|
1154
|
+
throw new LayoutParseError(`field "${node.name}" not found on schema`);
|
|
1155
|
+
}
|
|
1156
|
+
const { type, segments, leafName, title, labelType } = resolved;
|
|
1157
|
+
const path = [
|
|
1158
|
+
...basePath,
|
|
1159
|
+
...segments
|
|
1160
|
+
];
|
|
1161
|
+
const span = node.span ? {
|
|
1162
|
+
gridColumn: `span ${node.span} / span ${node.span}`
|
|
1163
|
+
} : void 0;
|
|
1164
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1165
|
+
className: "min-w-0",
|
|
1166
|
+
style: span
|
|
1167
|
+
}, /* @__PURE__ */ React3.createElement(FormFieldErrorBoundary, {
|
|
1168
|
+
path
|
|
1169
|
+
}, labelType ? /* @__PURE__ */ React3.createElement(LabelField, {
|
|
1170
|
+
schema: Schema2.make(labelType),
|
|
1171
|
+
label: title ?? String3.capitalize(leafName),
|
|
1172
|
+
path,
|
|
1173
|
+
layout: props.layout
|
|
1174
|
+
}) : /* @__PURE__ */ React3.createElement(FormField, {
|
|
1175
|
+
type,
|
|
1176
|
+
name: leafName,
|
|
1177
|
+
path,
|
|
1178
|
+
...props
|
|
1179
|
+
})));
|
|
1180
|
+
};
|
|
1181
|
+
var resolvePropertySignature = (ast, segments) => {
|
|
1182
|
+
let node = ast;
|
|
1183
|
+
for (let index = 0; index < segments.length; index++) {
|
|
1184
|
+
const typeLiteral = findNode2(node, SchemaAST4.isTypeLiteral);
|
|
1185
|
+
if (!typeLiteral) {
|
|
1186
|
+
return void 0;
|
|
1187
|
+
}
|
|
1188
|
+
const prop = SchemaAST4.getPropertySignatures(typeLiteral).find((p) => globalThis.String(p.name) === segments[index]);
|
|
1189
|
+
if (!prop) {
|
|
1190
|
+
return void 0;
|
|
1191
|
+
}
|
|
1192
|
+
if (index === segments.length - 1) {
|
|
1193
|
+
return prop;
|
|
1194
|
+
}
|
|
1195
|
+
node = prop.type;
|
|
1196
|
+
}
|
|
1197
|
+
return void 0;
|
|
1198
|
+
};
|
|
1199
|
+
var resolveLayoutField = (schema, name) => {
|
|
1200
|
+
const segments = name.split(".");
|
|
1201
|
+
const prop = resolvePropertySignature(schema.ast, segments);
|
|
1202
|
+
if (!prop) {
|
|
1203
|
+
return void 0;
|
|
1204
|
+
}
|
|
1205
|
+
const { type: baseType } = getBaseType(prop);
|
|
1206
|
+
const type = prop.annotations && Reflect.ownKeys(prop.annotations).length > 0 ? {
|
|
1207
|
+
...baseType,
|
|
1208
|
+
annotations: {
|
|
1209
|
+
...baseType.annotations,
|
|
1210
|
+
...prop.annotations
|
|
1211
|
+
}
|
|
1212
|
+
} : baseType;
|
|
1213
|
+
const title = getAnnotation3(SchemaAST4.TitleAnnotationId)(type);
|
|
1214
|
+
const labelType = findNode2(prop.type, SchemaAST4.isTypeLiteral);
|
|
1215
|
+
const labelled = labelType != null && Option3.isSome(Annotation3.LabelAnnotation.getFromAst(labelType));
|
|
1216
|
+
return {
|
|
1217
|
+
type,
|
|
1218
|
+
segments,
|
|
1219
|
+
leafName: segments[segments.length - 1],
|
|
1220
|
+
title,
|
|
1221
|
+
labelType: labelled ? labelType : void 0
|
|
1222
|
+
};
|
|
1223
|
+
};
|
|
1224
|
+
var LabelField = ({ schema, label, path, layout }) => {
|
|
1225
|
+
const { getValue } = useFormFieldState(FORM_LAYOUT_NAME, path);
|
|
1226
|
+
const value3 = getValue();
|
|
1227
|
+
const text = value3 == null ? void 0 : Annotation3.getLabelWithSchema(schema, value3);
|
|
1228
|
+
if (text == null || text.trim().length === 0) {
|
|
1229
|
+
return null;
|
|
1230
|
+
}
|
|
1231
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
1232
|
+
className: "contents"
|
|
1233
|
+
}, /* @__PURE__ */ React3.createElement(Input2.Root, null, layout !== "inline" && /* @__PURE__ */ React3.createElement(FormFieldLabel, {
|
|
1234
|
+
readonly: true,
|
|
1235
|
+
label,
|
|
1236
|
+
path: createJsonPath3(path)
|
|
1237
|
+
}), /* @__PURE__ */ React3.createElement("p", {
|
|
1238
|
+
className: "truncate min-w-0",
|
|
1239
|
+
title: text
|
|
1240
|
+
}, text)));
|
|
961
1241
|
};
|
|
962
1242
|
|
|
963
1243
|
// src/components/Form/FormFieldSet.tsx
|
|
964
1244
|
var FORM_FIELDSET_NAME = "Form.FieldSet";
|
|
965
|
-
var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, ...props }) => {
|
|
1245
|
+
var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection, layout, layoutName = DEFAULT_LAYOUT_NAME, ...props }) => {
|
|
966
1246
|
const values = useFormValues(FORM_FIELDSET_NAME, path);
|
|
967
1247
|
const properties = useFormFieldSetProperties({
|
|
968
1248
|
schema,
|
|
@@ -974,18 +1254,35 @@ var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection,
|
|
|
974
1254
|
if ((readonly || layout === "static") && values == null) {
|
|
975
1255
|
return null;
|
|
976
1256
|
}
|
|
977
|
-
|
|
1257
|
+
const layouts = schema ? Option4.getOrUndefined(FormLayoutAnnotation.get(schema)) : void 0;
|
|
1258
|
+
if (layouts?.[layoutName] !== void 0 && schema) {
|
|
1259
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
|
|
1260
|
+
label,
|
|
1261
|
+
path: createJsonPath4(path ?? []),
|
|
1262
|
+
asChild: true
|
|
1263
|
+
}), /* @__PURE__ */ React4.createElement(FormLayout, {
|
|
1264
|
+
schema,
|
|
1265
|
+
name: layoutName,
|
|
1266
|
+
path,
|
|
1267
|
+
readonly,
|
|
1268
|
+
layout,
|
|
1269
|
+
projection,
|
|
1270
|
+
...props
|
|
1271
|
+
}));
|
|
1272
|
+
}
|
|
1273
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, layout !== "inline" && label && /* @__PURE__ */ React4.createElement(FormFieldLabel, {
|
|
978
1274
|
label,
|
|
1275
|
+
path: createJsonPath4(path ?? []),
|
|
979
1276
|
asChild: true
|
|
980
1277
|
}), properties.map((property) => {
|
|
981
1278
|
const name = property.name.toString();
|
|
982
|
-
return /* @__PURE__ */
|
|
1279
|
+
return /* @__PURE__ */ React4.createElement(FormFieldErrorBoundary, {
|
|
983
1280
|
key: name,
|
|
984
1281
|
path: [
|
|
985
1282
|
...path ?? [],
|
|
986
1283
|
name
|
|
987
1284
|
]
|
|
988
|
-
}, /* @__PURE__ */
|
|
1285
|
+
}, /* @__PURE__ */ React4.createElement(FormField, {
|
|
989
1286
|
type: property.type,
|
|
990
1287
|
name,
|
|
991
1288
|
path: [
|
|
@@ -1001,7 +1298,7 @@ var FormFieldSet = ({ label, schema, readonly, path, sort, exclude, projection,
|
|
|
1001
1298
|
};
|
|
1002
1299
|
FormFieldSet.displayName = FORM_FIELDSET_NAME;
|
|
1003
1300
|
var useFormFieldSetProperties = ({ schema, exclude, projection, values, sort }) => {
|
|
1004
|
-
return
|
|
1301
|
+
return useMemo4(() => {
|
|
1005
1302
|
if (!schema) {
|
|
1006
1303
|
return [];
|
|
1007
1304
|
}
|
|
@@ -1037,25 +1334,28 @@ var useFormFieldSetProperties = ({ schema, exclude, projection, values, sort })
|
|
|
1037
1334
|
};
|
|
1038
1335
|
|
|
1039
1336
|
// src/components/Form/Form.tsx
|
|
1040
|
-
var omitId = (
|
|
1337
|
+
var omitId = (schemaOrType) => {
|
|
1338
|
+
const schema = Type.isType(schemaOrType) ? Type.getSchema(schemaOrType) : schemaOrType;
|
|
1339
|
+
return schema.pipe(Schema3.omit("id"));
|
|
1340
|
+
};
|
|
1041
1341
|
var omitHiddenFormFields = (schema) => {
|
|
1042
|
-
const properties =
|
|
1043
|
-
const hidden = properties.filter((prop) =>
|
|
1044
|
-
return hidden.length === 0 ? schema : schema.pipe(
|
|
1342
|
+
const properties = SchemaAST5.getPropertySignatures(schema.ast);
|
|
1343
|
+
const hidden = properties.filter((prop) => Option5.getOrElse(EchoAnnotation.FormInputAnnotation.getFromAst(prop.type), () => true) === false).map((prop) => prop.name);
|
|
1344
|
+
return hidden.length === 0 ? schema : schema.pipe(Schema3.omit(...hidden));
|
|
1045
1345
|
};
|
|
1046
|
-
var [FormContextProvider, useFormContext] =
|
|
1346
|
+
var [FormContextProvider, useFormContext] = createContext2("Form");
|
|
1047
1347
|
var useFormValues = (componentName, path, defaultValue) => {
|
|
1048
|
-
const stablePath =
|
|
1348
|
+
const stablePath = useMemo5(() => path ?? [], [
|
|
1049
1349
|
path ? path.join(".") : void 0
|
|
1050
1350
|
]);
|
|
1051
|
-
const jsonPath =
|
|
1351
|
+
const jsonPath = createJsonPath5(stablePath);
|
|
1052
1352
|
const { form: { values, onValueChange } } = useFormContext(componentName);
|
|
1053
1353
|
const value3 = getValue$2(values, jsonPath);
|
|
1054
1354
|
const lastAppliedPathRef = useRef(null);
|
|
1055
1355
|
useEffect2(() => {
|
|
1056
1356
|
if (value3 == null && defaultValue && lastAppliedPathRef.current !== jsonPath) {
|
|
1057
1357
|
lastAppliedPathRef.current = jsonPath;
|
|
1058
|
-
onValueChange(stablePath,
|
|
1358
|
+
onValueChange(stablePath, SchemaAST5.stringKeyword, defaultValue());
|
|
1059
1359
|
}
|
|
1060
1360
|
}, [
|
|
1061
1361
|
value3,
|
|
@@ -1067,11 +1367,11 @@ var useFormValues = (componentName, path, defaultValue) => {
|
|
|
1067
1367
|
return value3;
|
|
1068
1368
|
};
|
|
1069
1369
|
var useFormFieldState = (componentName, path = []) => {
|
|
1070
|
-
const stablePath =
|
|
1370
|
+
const stablePath = useMemo5(() => path, [
|
|
1071
1371
|
Array.isArray(path) ? path.join(".") : path
|
|
1072
1372
|
]);
|
|
1073
1373
|
const { form: { getStatus, getValue, onBlur, onValueChange } } = useFormContext(componentName);
|
|
1074
|
-
return
|
|
1374
|
+
return useMemo5(() => ({
|
|
1075
1375
|
getStatus: () => getStatus(stablePath),
|
|
1076
1376
|
getValue: () => getValue(stablePath),
|
|
1077
1377
|
onBlur: () => onBlur(stablePath),
|
|
@@ -1092,22 +1392,42 @@ var FormRoot = ({ children, schema, values, onSave, onCancel, ...props }) => {
|
|
|
1092
1392
|
onCancel,
|
|
1093
1393
|
...props
|
|
1094
1394
|
});
|
|
1095
|
-
return /* @__PURE__ */
|
|
1395
|
+
return /* @__PURE__ */ React5.createElement(FormTooltipsContext.Provider, {
|
|
1396
|
+
value: props.tooltips ?? true
|
|
1397
|
+
}, /* @__PURE__ */ React5.createElement(FormContextProvider, {
|
|
1096
1398
|
form,
|
|
1097
1399
|
...props
|
|
1098
|
-
}, children);
|
|
1400
|
+
}, children));
|
|
1099
1401
|
};
|
|
1100
1402
|
FormRoot.displayName = "Form.Root";
|
|
1101
1403
|
var FORM_VIEWPORT_NAME = "Form.Viewport";
|
|
1102
|
-
var FormViewport = composable(({ children, ...props }, forwardedRef) => {
|
|
1103
|
-
|
|
1404
|
+
var FormViewport = composable(({ children, scroll, gutter = "sm", ...props }, forwardedRef) => {
|
|
1405
|
+
const span = "[.dx-column-root_&]:col-span-full";
|
|
1406
|
+
if (scroll) {
|
|
1407
|
+
return /* @__PURE__ */ React5.createElement(Column.Root, {
|
|
1408
|
+
gutter,
|
|
1409
|
+
classNames: [
|
|
1410
|
+
"dx-expander",
|
|
1411
|
+
span
|
|
1412
|
+
]
|
|
1413
|
+
}, /* @__PURE__ */ React5.createElement(ScrollArea.Root, {
|
|
1414
|
+
...composableProps(props),
|
|
1415
|
+
orientation: "vertical",
|
|
1416
|
+
centered: true,
|
|
1417
|
+
padding: true,
|
|
1418
|
+
thin: true,
|
|
1419
|
+
ref: forwardedRef
|
|
1420
|
+
}, /* @__PURE__ */ React5.createElement(ScrollArea.Viewport, null, children)));
|
|
1421
|
+
}
|
|
1422
|
+
return /* @__PURE__ */ React5.createElement(Column.Root, {
|
|
1104
1423
|
...composableProps(props),
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1424
|
+
gutter,
|
|
1425
|
+
classNames: [
|
|
1426
|
+
"w-full min-w-0",
|
|
1427
|
+
span
|
|
1428
|
+
],
|
|
1109
1429
|
ref: forwardedRef
|
|
1110
|
-
},
|
|
1430
|
+
}, children);
|
|
1111
1431
|
});
|
|
1112
1432
|
FormViewport.displayName = FORM_VIEWPORT_NAME;
|
|
1113
1433
|
var FORM_CONTENT_NAME = "Form.Content";
|
|
@@ -1119,10 +1439,10 @@ var FormContent = composable(({ children, ...props }, forwardedRef) => {
|
|
|
1119
1439
|
localRef
|
|
1120
1440
|
]);
|
|
1121
1441
|
useKeyHandler(localRef, form);
|
|
1122
|
-
return /* @__PURE__ */
|
|
1442
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1123
1443
|
...composableProps(props, {
|
|
1124
1444
|
role: "form",
|
|
1125
|
-
classNames:
|
|
1445
|
+
classNames: mx3(withColumn.center(), "flex flex-col w-full")
|
|
1126
1446
|
}),
|
|
1127
1447
|
"data-testid": testId,
|
|
1128
1448
|
ref: mergedRef
|
|
@@ -1132,30 +1452,43 @@ FormContent.displayName = FORM_CONTENT_NAME;
|
|
|
1132
1452
|
var FORM_FIELDSET_NAME2 = "Form.FieldSet";
|
|
1133
1453
|
var FormFieldSet2 = (props) => {
|
|
1134
1454
|
const { form, ...contextProps } = useFormContext(FORM_FIELDSET_NAME2);
|
|
1135
|
-
return /* @__PURE__ */
|
|
1455
|
+
return /* @__PURE__ */ React5.createElement(FormFieldSet, {
|
|
1136
1456
|
schema: form.schema,
|
|
1137
1457
|
...contextProps,
|
|
1138
1458
|
...props
|
|
1139
1459
|
});
|
|
1140
1460
|
};
|
|
1141
1461
|
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1462
|
+
var FORM_LAYOUT_NAME2 = "Form.Layout";
|
|
1463
|
+
var FormLayout2 = ({ schema, ...props }) => {
|
|
1464
|
+
const { form, ...contextProps } = useFormContext(FORM_LAYOUT_NAME2);
|
|
1465
|
+
const resolvedSchema = schema ?? form.schema;
|
|
1466
|
+
if (!resolvedSchema) {
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
return /* @__PURE__ */ React5.createElement(FormLayout, {
|
|
1470
|
+
schema: resolvedSchema,
|
|
1471
|
+
...contextProps,
|
|
1472
|
+
...props
|
|
1473
|
+
});
|
|
1474
|
+
};
|
|
1475
|
+
FormLayout2.displayName = FORM_LAYOUT_NAME2;
|
|
1142
1476
|
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1143
1477
|
var FormActions = ({ classNames }) => {
|
|
1144
|
-
const { t } = useTranslation2(
|
|
1478
|
+
const { t } = useTranslation2(translationKey2);
|
|
1145
1479
|
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1146
1480
|
if (readonly || layout === "static") {
|
|
1147
1481
|
return null;
|
|
1148
1482
|
}
|
|
1149
|
-
return /* @__PURE__ */
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
}, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1483
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1484
|
+
className: mx3(withColumn.center(), "grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
|
|
1485
|
+
}, onCancel && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1153
1486
|
icon: "ph--x--regular",
|
|
1154
1487
|
iconEnd: true,
|
|
1155
1488
|
label: t("cancel-button.label"),
|
|
1156
1489
|
onClick: onCancel,
|
|
1157
1490
|
"data-testid": "cancel-button"
|
|
1158
|
-
}), onSave && /* @__PURE__ */
|
|
1491
|
+
}), onSave && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1159
1492
|
type: "submit",
|
|
1160
1493
|
variant: "primary",
|
|
1161
1494
|
disabled: !canSave,
|
|
@@ -1169,29 +1502,28 @@ var FormActions = ({ classNames }) => {
|
|
|
1169
1502
|
FormActions.displayName = FORM_ACTIONS_NAME;
|
|
1170
1503
|
var FORM_SECTION_NAME = "Form.Section";
|
|
1171
1504
|
var FormSection = composable(({ children, label, description, ...props }, forwardedRef) => {
|
|
1172
|
-
return /* @__PURE__ */
|
|
1505
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1173
1506
|
...composableProps(props, {
|
|
1174
1507
|
classNames: "flex flex-col pt-form-section-gap first:pt-0"
|
|
1175
1508
|
}),
|
|
1176
1509
|
ref: forwardedRef
|
|
1177
|
-
}, /* @__PURE__ */
|
|
1510
|
+
}, label && /* @__PURE__ */ React5.createElement("h2", {
|
|
1178
1511
|
className: "text-lg"
|
|
1179
|
-
}, label), description && /* @__PURE__ */
|
|
1512
|
+
}, label), description && /* @__PURE__ */ React5.createElement("p", {
|
|
1180
1513
|
className: "text-description"
|
|
1181
1514
|
}, description), children);
|
|
1182
1515
|
});
|
|
1183
1516
|
FormSection.displayName = FORM_SECTION_NAME;
|
|
1184
1517
|
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1185
1518
|
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1186
|
-
const { t } = useTranslation2(
|
|
1519
|
+
const { t } = useTranslation2(translationKey2);
|
|
1187
1520
|
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1188
1521
|
if (readonly || layout === "static") {
|
|
1189
1522
|
return null;
|
|
1190
1523
|
}
|
|
1191
|
-
return /* @__PURE__ */
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1524
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1525
|
+
className: mx3("flex w-full pt-form-padding", classNames)
|
|
1526
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1195
1527
|
classNames: "w-full",
|
|
1196
1528
|
type: "submit",
|
|
1197
1529
|
variant: "primary",
|
|
@@ -1203,31 +1535,45 @@ var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
|
1203
1535
|
}));
|
|
1204
1536
|
};
|
|
1205
1537
|
FormSubmit.displayName = FORM_SUBMIT_NAME;
|
|
1538
|
+
var FORM_ERROR_NAME = "Form.Error";
|
|
1539
|
+
var FormError = ({ children, classNames }) => {
|
|
1540
|
+
if (!children) {
|
|
1541
|
+
return null;
|
|
1542
|
+
}
|
|
1543
|
+
return /* @__PURE__ */ React5.createElement(Input3.Root, {
|
|
1544
|
+
validationValence: "error"
|
|
1545
|
+
}, /* @__PURE__ */ React5.createElement(Input3.Validation, {
|
|
1546
|
+
classNames
|
|
1547
|
+
}, children));
|
|
1548
|
+
};
|
|
1549
|
+
FormError.displayName = FORM_ERROR_NAME;
|
|
1206
1550
|
var Form = {
|
|
1207
1551
|
Root: FormRoot,
|
|
1208
1552
|
Viewport: FormViewport,
|
|
1209
1553
|
Content: FormContent,
|
|
1210
1554
|
Section: FormSection,
|
|
1211
1555
|
FieldSet: FormFieldSet2,
|
|
1556
|
+
Layout: FormLayout2,
|
|
1212
1557
|
Label: FormFieldLabel,
|
|
1213
1558
|
Actions: FormActions,
|
|
1214
|
-
Submit: FormSubmit
|
|
1559
|
+
Submit: FormSubmit,
|
|
1560
|
+
Error: FormError
|
|
1215
1561
|
};
|
|
1216
1562
|
|
|
1217
1563
|
// src/components/Form/fields/ArrayField.tsx
|
|
1218
1564
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1219
|
-
const { t } = useTranslation3(
|
|
1565
|
+
const { t } = useTranslation3(translationKey3);
|
|
1220
1566
|
const elementType = getArrayElementType2(type);
|
|
1221
1567
|
const { onValueChange } = inputProps;
|
|
1222
1568
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
1223
1569
|
const getDefaultObjectValue = (typeNode) => {
|
|
1224
|
-
const baseNode =
|
|
1225
|
-
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) :
|
|
1570
|
+
const baseNode = findNode3(typeNode, isDiscriminatedUnion2);
|
|
1571
|
+
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, {}) : findNode3(typeNode, SchemaAST6.isTypeLiteral);
|
|
1226
1572
|
if (!typeLiteral) {
|
|
1227
1573
|
return {};
|
|
1228
1574
|
}
|
|
1229
1575
|
return Object.fromEntries(getFormProperties(typeLiteral).map((prop) => {
|
|
1230
|
-
const defaultValue =
|
|
1576
|
+
const defaultValue = SchemaAST6.getDefaultAnnotation(prop.type).pipe((annotation) => Option6.getOrUndefined(annotation));
|
|
1231
1577
|
return [
|
|
1232
1578
|
prop.name,
|
|
1233
1579
|
defaultValue
|
|
@@ -1235,9 +1581,9 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1235
1581
|
}));
|
|
1236
1582
|
};
|
|
1237
1583
|
const handleAdd = useCallback3(() => {
|
|
1238
|
-
const defaultValue =
|
|
1239
|
-
|
|
1240
|
-
...values,
|
|
1584
|
+
const defaultValue = isNestedType3(type) && elementType ? getDefaultObjectValue(elementType) : getDefaultValue(elementType);
|
|
1585
|
+
onValueChange(type, [
|
|
1586
|
+
...values ?? [],
|
|
1241
1587
|
defaultValue
|
|
1242
1588
|
]);
|
|
1243
1589
|
}, [
|
|
@@ -1256,47 +1602,49 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1256
1602
|
if (!elementType || (readonly || layout === "static") && values && values.length < 1) {
|
|
1257
1603
|
return null;
|
|
1258
1604
|
}
|
|
1259
|
-
|
|
1605
|
+
const renderItemAsObject = elementType && isNestedType3(elementType) && !Ref2.isRefType(elementType);
|
|
1606
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, (layout !== "static" || values && values.length > 0) && /* @__PURE__ */ React6.createElement("div", {
|
|
1607
|
+
className: "flex items-center gap-2"
|
|
1608
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
1609
|
+
className: "flex-1 min-w-0"
|
|
1610
|
+
}, /* @__PURE__ */ React6.createElement(FormFieldLabel, {
|
|
1260
1611
|
readonly,
|
|
1261
1612
|
label,
|
|
1613
|
+
path: createJsonPath6(path ?? []),
|
|
1262
1614
|
asChild: true
|
|
1263
|
-
}), /* @__PURE__ */
|
|
1264
|
-
|
|
1265
|
-
|
|
1615
|
+
})), !readonly && layout !== "static" && /* @__PURE__ */ React6.createElement(IconBlock, {
|
|
1616
|
+
inline: true,
|
|
1617
|
+
icon: "ph--plus--regular",
|
|
1618
|
+
label: t("add-item.button"),
|
|
1619
|
+
onClick: handleAdd
|
|
1620
|
+
})), /* @__PURE__ */ React6.createElement("div", {
|
|
1621
|
+
className: "flex flex-col"
|
|
1266
1622
|
}, values?.map((_, index) => {
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}, /* @__PURE__ */ React5.createElement(FormField, {
|
|
1272
|
-
autoFocus: index === values.length - 1,
|
|
1623
|
+
const isLast = index === values.length - 1;
|
|
1624
|
+
const fieldField = /* @__PURE__ */ React6.createElement(FormField, {
|
|
1625
|
+
...props,
|
|
1626
|
+
autoFocus: isLast,
|
|
1273
1627
|
type: elementType,
|
|
1628
|
+
...renderItemAsObject && {
|
|
1629
|
+
name: null
|
|
1630
|
+
},
|
|
1274
1631
|
path: [
|
|
1275
1632
|
...path ?? [],
|
|
1276
1633
|
index
|
|
1277
1634
|
],
|
|
1278
1635
|
readonly: readonly || layout === "static",
|
|
1279
|
-
layout: "inline"
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
className: "
|
|
1284
|
-
}, /* @__PURE__ */
|
|
1285
|
-
|
|
1286
|
-
className: "flex items-center h-[2rem]"
|
|
1287
|
-
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1636
|
+
layout: renderItemAsObject ? layout === "static" ? "static" : void 0 : "inline"
|
|
1637
|
+
});
|
|
1638
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
1639
|
+
key: index,
|
|
1640
|
+
className: "grid grid-cols-[1fr_min-content] items-center mb-1 last:mb-form-gap"
|
|
1641
|
+
}, fieldField, !readonly && layout !== "static" && /* @__PURE__ */ React6.createElement(IconBlock, {
|
|
1642
|
+
inline: !renderItemAsObject,
|
|
1288
1643
|
icon: "ph--x--regular",
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
}))));
|
|
1294
|
-
})), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1295
|
-
classNames: "flex w-full",
|
|
1296
|
-
icon: "ph--plus--regular",
|
|
1297
|
-
label: t("add-item.button"),
|
|
1298
|
-
onClick: handleAdd
|
|
1299
|
-
}));
|
|
1644
|
+
label: t("remove-item.button"),
|
|
1645
|
+
onClick: () => handleDelete(index)
|
|
1646
|
+
}));
|
|
1647
|
+
})));
|
|
1300
1648
|
};
|
|
1301
1649
|
ArrayField.displayName = "Form.ArrayField";
|
|
1302
1650
|
var getDefaultValue = (ast) => {
|
|
@@ -1314,7 +1662,7 @@ var getDefaultValue = (ast) => {
|
|
|
1314
1662
|
return getDefaultValue(ast.f());
|
|
1315
1663
|
}
|
|
1316
1664
|
default: {
|
|
1317
|
-
if (ast &&
|
|
1665
|
+
if (ast && isNestedType3(ast)) {
|
|
1318
1666
|
return {};
|
|
1319
1667
|
} else {
|
|
1320
1668
|
throw new Error(`Unsupported type: ${ast?._tag}`);
|
|
@@ -1324,38 +1672,112 @@ var getDefaultValue = (ast) => {
|
|
|
1324
1672
|
};
|
|
1325
1673
|
|
|
1326
1674
|
// src/components/Form/fields/BooleanField.tsx
|
|
1327
|
-
import
|
|
1328
|
-
import { Input as
|
|
1675
|
+
import React7, { useCallback as useCallback4 } from "react";
|
|
1676
|
+
import { Input as Input4 } from "@dxos/react-ui";
|
|
1329
1677
|
var BooleanField = ({ type, readonly, onValueChange, ...props }) => {
|
|
1330
1678
|
const handleChange = useCallback4((value3) => onValueChange?.(type, value3), [
|
|
1331
1679
|
type,
|
|
1332
1680
|
onValueChange
|
|
1333
1681
|
]);
|
|
1334
|
-
return /* @__PURE__ */
|
|
1682
|
+
return /* @__PURE__ */ React7.createElement(FormFieldWrapper, {
|
|
1335
1683
|
readonly,
|
|
1336
1684
|
...props
|
|
1337
|
-
}, ({ value: value3 }) => /* @__PURE__ */
|
|
1685
|
+
}, ({ value: value3 }) => /* @__PURE__ */ React7.createElement(Input4.Switch, {
|
|
1338
1686
|
disabled: !!readonly,
|
|
1339
1687
|
checked: value3,
|
|
1340
1688
|
onCheckedChange: handleChange
|
|
1341
1689
|
}));
|
|
1342
1690
|
};
|
|
1343
1691
|
|
|
1692
|
+
// src/components/Form/fields/DateField.tsx
|
|
1693
|
+
import { format as formatDate3 } from "date-fns";
|
|
1694
|
+
import React8, { useCallback as useCallback5 } from "react";
|
|
1695
|
+
import { Format as Format5 } from "@dxos/echo";
|
|
1696
|
+
import { Input as Input5 } from "@dxos/react-ui";
|
|
1697
|
+
var isoToLocalDateTime = (value3) => {
|
|
1698
|
+
if (!value3) {
|
|
1699
|
+
return "";
|
|
1700
|
+
}
|
|
1701
|
+
const date = new Date(value3);
|
|
1702
|
+
if (Number.isNaN(date.getTime())) {
|
|
1703
|
+
return "";
|
|
1704
|
+
}
|
|
1705
|
+
return formatDate3(date, "yyyy-MM-dd'T'HH:mm");
|
|
1706
|
+
};
|
|
1707
|
+
var localDateTimeToIso = (value3) => {
|
|
1708
|
+
if (!value3) {
|
|
1709
|
+
return void 0;
|
|
1710
|
+
}
|
|
1711
|
+
const date = new Date(value3);
|
|
1712
|
+
return Number.isNaN(date.getTime()) ? void 0 : date.toISOString();
|
|
1713
|
+
};
|
|
1714
|
+
var DateField = ({ type, format, readonly, placeholder: _placeholder, onValueChange, onBlur: _onBlur, ...props }) => {
|
|
1715
|
+
const handleSimpleChange = useCallback5((next) => onValueChange(type, next), [
|
|
1716
|
+
type,
|
|
1717
|
+
onValueChange
|
|
1718
|
+
]);
|
|
1719
|
+
const handleDateTimeChange = useCallback5((next) => {
|
|
1720
|
+
const iso = localDateTimeToIso(next);
|
|
1721
|
+
onValueChange(type, iso);
|
|
1722
|
+
}, [
|
|
1723
|
+
type,
|
|
1724
|
+
onValueChange
|
|
1725
|
+
]);
|
|
1726
|
+
return /* @__PURE__ */ React8.createElement(FormFieldWrapper, {
|
|
1727
|
+
readonly,
|
|
1728
|
+
format,
|
|
1729
|
+
...props
|
|
1730
|
+
}, ({ value: value3 }) => {
|
|
1731
|
+
switch (format) {
|
|
1732
|
+
case Format5.TypeFormat.Date:
|
|
1733
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1734
|
+
className: "grid grid-cols-[minmax(0,1fr)_min-content] items-stretch gap-1"
|
|
1735
|
+
}, /* @__PURE__ */ React8.createElement(Input5.Date, {
|
|
1736
|
+
classNames: "min-w-0 overflow-hidden",
|
|
1737
|
+
disabled: !!readonly,
|
|
1738
|
+
value: value3 ?? "",
|
|
1739
|
+
onValueChange: handleSimpleChange
|
|
1740
|
+
}), /* @__PURE__ */ React8.createElement(Input5.TriggerIcon, {
|
|
1741
|
+
classNames: "h-full"
|
|
1742
|
+
}));
|
|
1743
|
+
case Format5.TypeFormat.Time:
|
|
1744
|
+
return /* @__PURE__ */ React8.createElement(Input5.Time, {
|
|
1745
|
+
disabled: !!readonly,
|
|
1746
|
+
value: value3 ?? "",
|
|
1747
|
+
onValueChange: handleSimpleChange
|
|
1748
|
+
});
|
|
1749
|
+
case Format5.TypeFormat.DateTime:
|
|
1750
|
+
default:
|
|
1751
|
+
return /* @__PURE__ */ React8.createElement("div", {
|
|
1752
|
+
className: "grid grid-cols-[minmax(0,1fr)_min-content] items-stretch gap-1"
|
|
1753
|
+
}, /* @__PURE__ */ React8.createElement(Input5.DateTime, {
|
|
1754
|
+
classNames: "min-w-0 overflow-hidden",
|
|
1755
|
+
disabled: !!readonly,
|
|
1756
|
+
value: isoToLocalDateTime(value3),
|
|
1757
|
+
onValueChange: handleDateTimeChange
|
|
1758
|
+
}), /* @__PURE__ */ React8.createElement(Input5.TriggerIcon, {
|
|
1759
|
+
classNames: "h-full"
|
|
1760
|
+
}));
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1344
1765
|
// src/components/Form/fields/GeoPointField.tsx
|
|
1345
|
-
import
|
|
1766
|
+
import React9, { useCallback as useCallback6, useEffect as useEffect3, useMemo as useMemo6, useState as useState2 } from "react";
|
|
1346
1767
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1347
|
-
import { Input as
|
|
1768
|
+
import { Input as Input6, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1348
1769
|
import { safeParseFloat } from "@dxos/util";
|
|
1349
|
-
|
|
1350
|
-
|
|
1770
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1771
|
+
var GeoPointField = ({ type, label, jsonPath, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1772
|
+
const { t } = useTranslation4(translationKey4);
|
|
1351
1773
|
const { status, error } = getStatus();
|
|
1352
|
-
const geoPoint =
|
|
1774
|
+
const geoPoint = useMemo6(() => getValue() ?? [
|
|
1353
1775
|
0,
|
|
1354
1776
|
0
|
|
1355
1777
|
], [
|
|
1356
1778
|
getValue
|
|
1357
1779
|
]);
|
|
1358
|
-
const value3 =
|
|
1780
|
+
const value3 = useMemo6(() => GeoLocation3.fromGeoPoint(geoPoint), [
|
|
1359
1781
|
geoPoint
|
|
1360
1782
|
]);
|
|
1361
1783
|
const [longitudeText, setLongitudeText] = useState2(value3.longitude?.toString());
|
|
@@ -1367,7 +1789,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1367
1789
|
}, [
|
|
1368
1790
|
geoPoint
|
|
1369
1791
|
]);
|
|
1370
|
-
const handleChange =
|
|
1792
|
+
const handleChange = useCallback6((coordinateType, setText) => (event) => {
|
|
1371
1793
|
const inputText = event.target.value;
|
|
1372
1794
|
setText(inputText);
|
|
1373
1795
|
if (inputText !== "" && inputText !== "-") {
|
|
@@ -1393,17 +1815,17 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1393
1815
|
if ((readonly || layout === "static") && !value3?.latitude && !value3?.longitude) {
|
|
1394
1816
|
return null;
|
|
1395
1817
|
}
|
|
1396
|
-
return /* @__PURE__ */
|
|
1818
|
+
return /* @__PURE__ */ React9.createElement(Input6.Root, {
|
|
1397
1819
|
validationValence: status
|
|
1398
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
1820
|
+
}, layout !== "inline" && /* @__PURE__ */ React9.createElement(FormFieldLabel, {
|
|
1399
1821
|
error,
|
|
1400
1822
|
readonly,
|
|
1401
1823
|
label,
|
|
1824
|
+
path: jsonPath,
|
|
1402
1825
|
asChild: true
|
|
1403
|
-
}), layout === "static" ? /* @__PURE__ */
|
|
1404
|
-
role: "none",
|
|
1826
|
+
}), layout === "static" ? /* @__PURE__ */ React9.createElement(LatLng, value3) : /* @__PURE__ */ React9.createElement("div", {
|
|
1405
1827
|
className: "grid grid-cols-2 gap-form-gap"
|
|
1406
|
-
}, /* @__PURE__ */
|
|
1828
|
+
}, /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement(Input6.Root, null, layout !== "inline" && /* @__PURE__ */ React9.createElement(Input6.Label, null, t("latitude.label")), /* @__PURE__ */ React9.createElement(Input6.TextInput, {
|
|
1407
1829
|
type: "number",
|
|
1408
1830
|
step: "0.00001",
|
|
1409
1831
|
min: "-90",
|
|
@@ -1413,7 +1835,7 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1413
1835
|
value: latitudeText ?? "",
|
|
1414
1836
|
onChange: handleChange("latitude", setLatitudeText),
|
|
1415
1837
|
onBlur
|
|
1416
|
-
}))), /* @__PURE__ */
|
|
1838
|
+
}))), /* @__PURE__ */ React9.createElement("div", null, /* @__PURE__ */ React9.createElement(Input6.Root, null, layout !== "inline" && /* @__PURE__ */ React9.createElement(Input6.Label, null, t("longitude.label")), /* @__PURE__ */ React9.createElement(Input6.TextInput, {
|
|
1417
1839
|
type: "number",
|
|
1418
1840
|
step: "0.00001",
|
|
1419
1841
|
min: "-180",
|
|
@@ -1428,29 +1850,128 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1428
1850
|
var LatLng = ({ latitude = 0, longitude = 0 }) => {
|
|
1429
1851
|
const latHem = latitude >= 0 ? "N" : "S";
|
|
1430
1852
|
const lngHem = longitude >= 0 ? "E" : "W";
|
|
1431
|
-
return /* @__PURE__ */
|
|
1853
|
+
return /* @__PURE__ */ React9.createElement("span", {
|
|
1432
1854
|
className: "inline-flex items-center gap-form-gap"
|
|
1433
|
-
}, /* @__PURE__ */
|
|
1855
|
+
}, /* @__PURE__ */ React9.createElement("span", null, /* @__PURE__ */ React9.createElement("span", null, Math.abs(latitude).toFixed(5)), /* @__PURE__ */ React9.createElement("span", {
|
|
1434
1856
|
className: "text-subdued"
|
|
1435
|
-
}, "\xB0", latHem)), /* @__PURE__ */
|
|
1857
|
+
}, "\xB0", latHem)), /* @__PURE__ */ React9.createElement("span", null, /* @__PURE__ */ React9.createElement("span", null, Math.abs(longitude).toFixed(5)), /* @__PURE__ */ React9.createElement("span", {
|
|
1436
1858
|
className: "text-subdued"
|
|
1437
1859
|
}, "\xB0", lngHem)));
|
|
1438
1860
|
};
|
|
1439
1861
|
|
|
1440
|
-
// src/components/Form/fields/
|
|
1862
|
+
// src/components/Form/fields/InlineRefField.tsx
|
|
1441
1863
|
import { useAtomValue } from "@effect-atom/atom-react";
|
|
1442
|
-
import
|
|
1443
|
-
import { Obj, Ref as
|
|
1864
|
+
import React10, { useCallback as useCallback7, useMemo as useMemo7 } from "react";
|
|
1865
|
+
import { Obj, Ref as Ref3, Type as Type2 } from "@dxos/echo";
|
|
1444
1866
|
import { AtomRef } from "@dxos/echo-atom";
|
|
1867
|
+
import { useType as defaultUseType } from "@dxos/echo-react";
|
|
1868
|
+
import { ReferenceAnnotationId as ReferenceAnnotationId2, splitJsonPath } from "@dxos/echo/internal";
|
|
1869
|
+
import { findAnnotation as findAnnotation2 } from "@dxos/effect";
|
|
1870
|
+
import { Button, Icon as Icon2, Input as Input7, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
1871
|
+
import { translationKey as translationKey5 } from "#translations";
|
|
1872
|
+
var InlineRefField = (props) => {
|
|
1873
|
+
const { type, readonly, label, jsonPath, layout, db, getValue, onValueChange, onCreate, useType: useType2 = defaultUseType } = props;
|
|
1874
|
+
const { t } = useTranslation5(translationKey5);
|
|
1875
|
+
const reference = getValue();
|
|
1876
|
+
const typename = useMemo7(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
|
|
1877
|
+
type
|
|
1878
|
+
]);
|
|
1879
|
+
const createType = useType2(db, typename);
|
|
1880
|
+
const handleCreate = useCallback7(async () => {
|
|
1881
|
+
if (!createType || !onCreate) {
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
const newObject = await onCreate(createType, {});
|
|
1885
|
+
if (newObject) {
|
|
1886
|
+
onValueChange(type, Ref3.make(newObject));
|
|
1887
|
+
}
|
|
1888
|
+
}, [
|
|
1889
|
+
createType,
|
|
1890
|
+
onCreate,
|
|
1891
|
+
type,
|
|
1892
|
+
onValueChange
|
|
1893
|
+
]);
|
|
1894
|
+
if (readonly && !reference) {
|
|
1895
|
+
return null;
|
|
1896
|
+
}
|
|
1897
|
+
return /* @__PURE__ */ React10.createElement(Input7.Root, null, layout !== "inline" && /* @__PURE__ */ React10.createElement(FormFieldLabel, {
|
|
1898
|
+
readonly,
|
|
1899
|
+
label,
|
|
1900
|
+
path: jsonPath
|
|
1901
|
+
}), reference ? /* @__PURE__ */ React10.createElement(InlineForm, {
|
|
1902
|
+
reference,
|
|
1903
|
+
db,
|
|
1904
|
+
readonly,
|
|
1905
|
+
useType: useType2
|
|
1906
|
+
}) : !readonly && onCreate && /* @__PURE__ */ React10.createElement(Button, {
|
|
1907
|
+
classNames: "w-full gap-form-gap",
|
|
1908
|
+
disabled: !createType || !db,
|
|
1909
|
+
onClick: () => void handleCreate()
|
|
1910
|
+
}, /* @__PURE__ */ React10.createElement(Icon2, {
|
|
1911
|
+
icon: "ph--plus--regular",
|
|
1912
|
+
size: 4
|
|
1913
|
+
}), /* @__PURE__ */ React10.createElement("span", null, label || t("ref-field.placeholder"))));
|
|
1914
|
+
};
|
|
1915
|
+
var InlineForm = ({ reference, db, readonly, useType: useType2 = defaultUseType }) => {
|
|
1916
|
+
const target = useAtomValue(useMemo7(() => AtomRef.make(reference), [
|
|
1917
|
+
reference
|
|
1918
|
+
]));
|
|
1919
|
+
const typename = target ? Obj.getTypename(target) ?? void 0 : void 0;
|
|
1920
|
+
const typeFromRegistry = useType2(db, typename);
|
|
1921
|
+
const targetType = target && Obj.getType(target) || typeFromRegistry;
|
|
1922
|
+
const formSchema = useMemo7(() => targetType ? omitId(Type2.getSchema(targetType)) : void 0, [
|
|
1923
|
+
targetType
|
|
1924
|
+
]);
|
|
1925
|
+
const defaultValues = useMemo7(() => target ? {
|
|
1926
|
+
...target
|
|
1927
|
+
} : {}, [
|
|
1928
|
+
target
|
|
1929
|
+
]);
|
|
1930
|
+
const handleChange = useCallback7((values, { isValid, changed }) => {
|
|
1931
|
+
if (!isValid || !target) {
|
|
1932
|
+
return;
|
|
1933
|
+
}
|
|
1934
|
+
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
1935
|
+
if (changedPaths.length === 0) {
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1938
|
+
Obj.update(target, () => {
|
|
1939
|
+
for (const path of changedPaths) {
|
|
1940
|
+
const parts = splitJsonPath(path);
|
|
1941
|
+
Obj.setValue(target, parts, Obj.getValue(values, parts));
|
|
1942
|
+
}
|
|
1943
|
+
});
|
|
1944
|
+
}, [
|
|
1945
|
+
target
|
|
1946
|
+
]);
|
|
1947
|
+
if (!target || !formSchema) {
|
|
1948
|
+
return null;
|
|
1949
|
+
}
|
|
1950
|
+
return /* @__PURE__ */ React10.createElement(Nesting, null, /* @__PURE__ */ React10.createElement(Form.Root, {
|
|
1951
|
+
schema: formSchema,
|
|
1952
|
+
defaultValues,
|
|
1953
|
+
db,
|
|
1954
|
+
onValuesChanged: handleChange
|
|
1955
|
+
}, /* @__PURE__ */ React10.createElement(Form.Content, null, /* @__PURE__ */ React10.createElement(Form.FieldSet, {
|
|
1956
|
+
readonly
|
|
1957
|
+
}))));
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
// src/components/Form/fields/MarkdownField.tsx
|
|
1961
|
+
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
1962
|
+
import React11, { useCallback as useCallback8, useMemo as useMemo8 } from "react";
|
|
1963
|
+
import { Obj as Obj2, Ref as Ref4 } from "@dxos/echo";
|
|
1964
|
+
import { AtomRef as AtomRef2 } from "@dxos/echo-atom";
|
|
1445
1965
|
import { createDocAccessor } from "@dxos/echo-db";
|
|
1446
|
-
import { Button, Icon as
|
|
1966
|
+
import { Button as Button2, Icon as Icon3, Input as Input8, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1447
1967
|
import { Editor, useBasicMarkdownExtensions } from "@dxos/react-ui-editor";
|
|
1448
1968
|
import { Text } from "@dxos/schema";
|
|
1449
1969
|
import { createDataExtensions } from "@dxos/ui-editor";
|
|
1970
|
+
import { translationKey as translationKey6 } from "#translations";
|
|
1450
1971
|
var editorClassNames = "transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2";
|
|
1451
|
-
var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
|
|
1972
|
+
var MarkdownField = ({ type, readonly, label, jsonPath, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
|
|
1452
1973
|
const { status, error } = getStatus();
|
|
1453
|
-
const isRef =
|
|
1974
|
+
const isRef = Ref4.isRefType(type);
|
|
1454
1975
|
const value3 = getValue();
|
|
1455
1976
|
if ((readonly || layout === "static") && value3 == null) {
|
|
1456
1977
|
return null;
|
|
@@ -1459,7 +1980,7 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus
|
|
|
1459
1980
|
if (isRef) {
|
|
1460
1981
|
const reference = value3;
|
|
1461
1982
|
if (reference) {
|
|
1462
|
-
return /* @__PURE__ */
|
|
1983
|
+
return /* @__PURE__ */ React11.createElement(RefMarkdownEditor, {
|
|
1463
1984
|
reference,
|
|
1464
1985
|
placeholder
|
|
1465
1986
|
});
|
|
@@ -1467,13 +1988,13 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus
|
|
|
1467
1988
|
if (readonly) {
|
|
1468
1989
|
return null;
|
|
1469
1990
|
}
|
|
1470
|
-
return /* @__PURE__ */
|
|
1991
|
+
return /* @__PURE__ */ React11.createElement(CreateTextButton, {
|
|
1471
1992
|
db,
|
|
1472
1993
|
disabled: !db,
|
|
1473
1994
|
onCreate: (ref) => onValueChange(type, ref)
|
|
1474
1995
|
});
|
|
1475
1996
|
}
|
|
1476
|
-
return /* @__PURE__ */
|
|
1997
|
+
return /* @__PURE__ */ React11.createElement(StringMarkdownEditor, {
|
|
1477
1998
|
value: value3 ?? "",
|
|
1478
1999
|
placeholder,
|
|
1479
2000
|
readonly: !!readonly,
|
|
@@ -1483,40 +2004,41 @@ var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus
|
|
|
1483
2004
|
const renderStatic = () => {
|
|
1484
2005
|
if (isRef) {
|
|
1485
2006
|
const reference = value3;
|
|
1486
|
-
return reference ? /* @__PURE__ */
|
|
2007
|
+
return reference ? /* @__PURE__ */ React11.createElement(RefStaticText, {
|
|
1487
2008
|
reference
|
|
1488
2009
|
}) : null;
|
|
1489
2010
|
}
|
|
1490
|
-
return /* @__PURE__ */
|
|
2011
|
+
return /* @__PURE__ */ React11.createElement("p", {
|
|
1491
2012
|
className: "whitespace-pre-wrap"
|
|
1492
2013
|
}, value3 ?? "");
|
|
1493
2014
|
};
|
|
1494
|
-
return /* @__PURE__ */
|
|
2015
|
+
return /* @__PURE__ */ React11.createElement(Input8.Root, {
|
|
1495
2016
|
validationValence: status
|
|
1496
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
2017
|
+
}, layout !== "inline" && /* @__PURE__ */ React11.createElement(FormFieldLabel, {
|
|
1497
2018
|
error,
|
|
1498
2019
|
readonly,
|
|
1499
|
-
label
|
|
1500
|
-
|
|
2020
|
+
label,
|
|
2021
|
+
path: jsonPath
|
|
2022
|
+
}), layout === "static" ? renderStatic() : renderEditor(), layout === "full" && /* @__PURE__ */ React11.createElement(Input8.Validation, null, error));
|
|
1501
2023
|
};
|
|
1502
2024
|
var RefStaticText = ({ reference }) => {
|
|
1503
|
-
const text =
|
|
2025
|
+
const text = useAtomValue2(useMemo8(() => AtomRef2.make(reference), [
|
|
1504
2026
|
reference
|
|
1505
2027
|
]));
|
|
1506
2028
|
if (!text?.content) {
|
|
1507
2029
|
return null;
|
|
1508
2030
|
}
|
|
1509
|
-
return /* @__PURE__ */
|
|
2031
|
+
return /* @__PURE__ */ React11.createElement("p", {
|
|
1510
2032
|
className: "whitespace-pre-wrap"
|
|
1511
2033
|
}, text.content);
|
|
1512
2034
|
};
|
|
1513
2035
|
var RefMarkdownEditor = ({ reference, placeholder }) => {
|
|
1514
|
-
const text =
|
|
2036
|
+
const text = useAtomValue2(useMemo8(() => AtomRef2.make(reference), [
|
|
1515
2037
|
reference
|
|
1516
2038
|
]));
|
|
1517
|
-
const dataExtensions =
|
|
2039
|
+
const dataExtensions = useMemo8(() => text ? [
|
|
1518
2040
|
createDataExtensions({
|
|
1519
|
-
id: reference.
|
|
2041
|
+
id: reference.uri,
|
|
1520
2042
|
text: createDocAccessor(text, [
|
|
1521
2043
|
"content"
|
|
1522
2044
|
])
|
|
@@ -1532,7 +2054,7 @@ var RefMarkdownEditor = ({ reference, placeholder }) => {
|
|
|
1532
2054
|
if (!text) {
|
|
1533
2055
|
return null;
|
|
1534
2056
|
}
|
|
1535
|
-
return /* @__PURE__ */
|
|
2057
|
+
return /* @__PURE__ */ React11.createElement(Editor.Root, null, /* @__PURE__ */ React11.createElement(Editor.View, {
|
|
1536
2058
|
classNames: editorClassNames,
|
|
1537
2059
|
extensions
|
|
1538
2060
|
}));
|
|
@@ -1541,10 +2063,10 @@ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange })
|
|
|
1541
2063
|
const extensions = useBasicMarkdownExtensions({
|
|
1542
2064
|
placeholder
|
|
1543
2065
|
});
|
|
1544
|
-
const handleChange =
|
|
2066
|
+
const handleChange = useCallback8((next) => onChange(next), [
|
|
1545
2067
|
onChange
|
|
1546
2068
|
]);
|
|
1547
|
-
return /* @__PURE__ */
|
|
2069
|
+
return /* @__PURE__ */ React11.createElement(Editor.Root, null, /* @__PURE__ */ React11.createElement(Editor.View, {
|
|
1548
2070
|
classNames: editorClassNames,
|
|
1549
2071
|
extensions,
|
|
1550
2072
|
value: value3,
|
|
@@ -1552,41 +2074,41 @@ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange })
|
|
|
1552
2074
|
}));
|
|
1553
2075
|
};
|
|
1554
2076
|
var CreateTextButton = ({ db, disabled, onCreate }) => {
|
|
1555
|
-
const { t } =
|
|
1556
|
-
const handleClick =
|
|
2077
|
+
const { t } = useTranslation6(translationKey6);
|
|
2078
|
+
const handleClick = useCallback8(() => {
|
|
1557
2079
|
if (!db) {
|
|
1558
2080
|
return;
|
|
1559
2081
|
}
|
|
1560
|
-
const text = db.add(
|
|
2082
|
+
const text = db.add(Obj2.make(Text.Text, {
|
|
1561
2083
|
content: ""
|
|
1562
2084
|
}));
|
|
1563
|
-
onCreate(
|
|
2085
|
+
onCreate(Ref4.make(text));
|
|
1564
2086
|
}, [
|
|
1565
2087
|
db,
|
|
1566
2088
|
onCreate
|
|
1567
2089
|
]);
|
|
1568
|
-
return /* @__PURE__ */
|
|
2090
|
+
return /* @__PURE__ */ React11.createElement(Button2, {
|
|
1569
2091
|
onClick: handleClick,
|
|
1570
2092
|
disabled
|
|
1571
|
-
}, /* @__PURE__ */
|
|
2093
|
+
}, /* @__PURE__ */ React11.createElement(Icon3, {
|
|
1572
2094
|
icon: "ph--plus--regular",
|
|
1573
2095
|
size: 4
|
|
1574
|
-
}), /* @__PURE__ */
|
|
2096
|
+
}), /* @__PURE__ */ React11.createElement("span", null, t("create-text.label")));
|
|
1575
2097
|
};
|
|
1576
2098
|
|
|
1577
2099
|
// src/components/Form/fields/NumberField.tsx
|
|
1578
|
-
import
|
|
1579
|
-
import { Input as
|
|
2100
|
+
import React12, { useCallback as useCallback9 } from "react";
|
|
2101
|
+
import { Input as Input9 } from "@dxos/react-ui";
|
|
1580
2102
|
import { safeParseFloat as safeParseFloat2 } from "@dxos/util";
|
|
1581
2103
|
var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
1582
|
-
const handleChange =
|
|
2104
|
+
const handleChange = useCallback9((event) => onValueChange(type, safeParseFloat2(event.target.value) || 0), [
|
|
1583
2105
|
type,
|
|
1584
2106
|
onValueChange
|
|
1585
2107
|
]);
|
|
1586
|
-
return /* @__PURE__ */
|
|
2108
|
+
return /* @__PURE__ */ React12.createElement(FormFieldWrapper, {
|
|
1587
2109
|
readonly,
|
|
1588
2110
|
...props
|
|
1589
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
2111
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React12.createElement(Input9.TextInput, {
|
|
1590
2112
|
type: "number",
|
|
1591
2113
|
disabled: !!readonly,
|
|
1592
2114
|
placeholder,
|
|
@@ -1597,40 +2119,43 @@ var NumberField = ({ type, readonly, placeholder, onValueChange, onBlur, ...prop
|
|
|
1597
2119
|
};
|
|
1598
2120
|
|
|
1599
2121
|
// src/components/Form/fields/RefField.tsx
|
|
1600
|
-
import
|
|
2122
|
+
import React14, { useCallback as useCallback11, useMemo as useMemo9, useState as useState4 } from "react";
|
|
1601
2123
|
import "@dxos/lit-ui/dx-tag-picker.pcss";
|
|
1602
|
-
import { Entity, Filter, Obj as
|
|
1603
|
-
import { useQuery,
|
|
1604
|
-
import { ReferenceAnnotationId as
|
|
1605
|
-
import { findAnnotation as
|
|
1606
|
-
import {
|
|
2124
|
+
import { Entity, Filter, Obj as Obj3, Ref as Ref5, Type as Type3 } from "@dxos/echo";
|
|
2125
|
+
import { useQuery, useType as defaultUseType2 } from "@dxos/echo-react";
|
|
2126
|
+
import { ANY_OBJECT_TYPENAME, ReferenceAnnotationId as ReferenceAnnotationId3 } from "@dxos/echo/internal";
|
|
2127
|
+
import { findAnnotation as findAnnotation3 } from "@dxos/effect";
|
|
2128
|
+
import { URI } from "@dxos/keys";
|
|
1607
2129
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1608
|
-
import { Button as
|
|
2130
|
+
import { Button as Button3, Icon as Icon4, Input as Input10, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
1609
2131
|
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
2132
|
+
import { translationKey as translationKey8 } from "#translations";
|
|
1610
2133
|
|
|
1611
2134
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1612
|
-
import
|
|
1613
|
-
import { Popover, useTranslation as
|
|
1614
|
-
import { Combobox
|
|
2135
|
+
import React13, { forwardRef, useCallback as useCallback10, useState as useState3 } from "react";
|
|
2136
|
+
import { Popover, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
2137
|
+
import { Combobox } from "@dxos/react-ui-list";
|
|
2138
|
+
import { useSearchListResults } from "@dxos/react-ui-search";
|
|
2139
|
+
import { translationKey as translationKey7 } from "#translations";
|
|
1615
2140
|
var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, onSelect, onCreate, ...props }, forwardedRef) => {
|
|
1616
|
-
const { t } =
|
|
2141
|
+
const { t } = useTranslation7(translationKey7);
|
|
1617
2142
|
const [showForm, setShowForm] = useState3(false);
|
|
1618
2143
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1619
|
-
const { results, handleSearch } = useSearchListResults({
|
|
2144
|
+
const { results, query, handleSearch } = useSearchListResults({
|
|
1620
2145
|
items: options
|
|
1621
2146
|
});
|
|
1622
|
-
const handleFormSave =
|
|
2147
|
+
const handleFormSave = useCallback10(async (values) => {
|
|
1623
2148
|
await onCreate?.(values);
|
|
1624
2149
|
setShowForm(false);
|
|
1625
2150
|
setFormInitialValue("");
|
|
1626
2151
|
}, [
|
|
1627
2152
|
onCreate
|
|
1628
2153
|
]);
|
|
1629
|
-
const handleFormCancel =
|
|
2154
|
+
const handleFormCancel = useCallback10(() => {
|
|
1630
2155
|
setShowForm(false);
|
|
1631
2156
|
setFormInitialValue("");
|
|
1632
2157
|
}, []);
|
|
1633
|
-
const handleKeyDown =
|
|
2158
|
+
const handleKeyDown = useCallback10((event) => {
|
|
1634
2159
|
if (event.key === "Enter" && createSchema && event.currentTarget.querySelector('[role="option"][aria-selected="true"][data-value="__create__"]')) {
|
|
1635
2160
|
event.stopPropagation();
|
|
1636
2161
|
event.preventDefault();
|
|
@@ -1643,12 +2168,11 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
|
|
|
1643
2168
|
createSchema
|
|
1644
2169
|
]);
|
|
1645
2170
|
if (showForm && createSchema) {
|
|
1646
|
-
return /* @__PURE__ */
|
|
2171
|
+
return /* @__PURE__ */ React13.createElement(Combobox.Content, {
|
|
1647
2172
|
...props,
|
|
1648
|
-
onSearch: handleSearch,
|
|
1649
2173
|
onKeyDownCapture: handleKeyDown,
|
|
1650
2174
|
ref: forwardedRef
|
|
1651
|
-
}, /* @__PURE__ */
|
|
2175
|
+
}, /* @__PURE__ */ React13.createElement(Popover.Viewport, null, /* @__PURE__ */ React13.createElement(Form.Root, {
|
|
1652
2176
|
testId: "create-referenced-object-form",
|
|
1653
2177
|
schema: createSchema,
|
|
1654
2178
|
defaultValues: createInitialValuePath ? {
|
|
@@ -1657,40 +2181,41 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
|
|
|
1657
2181
|
fieldMap: createFieldMap3,
|
|
1658
2182
|
onSave: handleFormSave,
|
|
1659
2183
|
onCancel: handleFormCancel
|
|
1660
|
-
}, /* @__PURE__ */
|
|
2184
|
+
}, /* @__PURE__ */ React13.createElement(Form.Viewport, null, /* @__PURE__ */ React13.createElement(Form.Content, null, /* @__PURE__ */ React13.createElement(Form.FieldSet, null), /* @__PURE__ */ React13.createElement(Form.Actions, null))))), /* @__PURE__ */ React13.createElement(Combobox.Arrow, null));
|
|
1661
2185
|
}
|
|
1662
|
-
return /* @__PURE__ */
|
|
2186
|
+
return /* @__PURE__ */ React13.createElement(Combobox.Content, {
|
|
1663
2187
|
...props,
|
|
1664
|
-
onSearch: handleSearch,
|
|
1665
2188
|
onKeyDownCapture: handleKeyDown,
|
|
1666
2189
|
ref: forwardedRef
|
|
1667
|
-
}, /* @__PURE__ */
|
|
2190
|
+
}, /* @__PURE__ */ React13.createElement(Combobox.Input, {
|
|
1668
2191
|
placeholder: t("ref-field-combobox-input.placeholder"),
|
|
1669
|
-
autoFocus: true
|
|
1670
|
-
|
|
2192
|
+
autoFocus: true,
|
|
2193
|
+
value: query,
|
|
2194
|
+
onValueChange: handleSearch
|
|
2195
|
+
}), /* @__PURE__ */ React13.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React13.createElement(Combobox.Item, {
|
|
1671
2196
|
key: option.id,
|
|
1672
2197
|
value: option.id,
|
|
1673
2198
|
label: option.label,
|
|
1674
2199
|
checked: selectedIds?.includes(option.id),
|
|
1675
2200
|
onSelect: () => onSelect(option.id),
|
|
1676
2201
|
classNames: "flex items-center gap-2"
|
|
1677
|
-
})), createSchema && onCreate && /* @__PURE__ */
|
|
2202
|
+
})), createSchema && onCreate && /* @__PURE__ */ React13.createElement(CreateItem, {
|
|
2203
|
+
query,
|
|
1678
2204
|
createOptionLabel,
|
|
1679
2205
|
createOptionIcon: createOptionIcon ?? "ph--plus--regular",
|
|
1680
|
-
onCreateItemSelect: (
|
|
1681
|
-
setFormInitialValue(
|
|
2206
|
+
onCreateItemSelect: (currentQuery) => {
|
|
2207
|
+
setFormInitialValue(currentQuery);
|
|
1682
2208
|
setShowForm(true);
|
|
1683
2209
|
}
|
|
1684
|
-
})), /* @__PURE__ */
|
|
2210
|
+
})), /* @__PURE__ */ React13.createElement(Combobox.Arrow, null));
|
|
1685
2211
|
});
|
|
1686
|
-
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1687
|
-
const { t } =
|
|
1688
|
-
const { query } = useSearchListInput();
|
|
2212
|
+
var CreateItem = ({ query, createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
2213
|
+
const { t } = useTranslation7(translationKey7);
|
|
1689
2214
|
const label = createOptionLabel ? t(createOptionLabel[0], {
|
|
1690
2215
|
ns: createOptionLabel[1].ns,
|
|
1691
2216
|
text: query
|
|
1692
2217
|
}) : t("create-option.label");
|
|
1693
|
-
return /* @__PURE__ */
|
|
2218
|
+
return /* @__PURE__ */ React13.createElement(Combobox.Item, {
|
|
1694
2219
|
value: "__create__",
|
|
1695
2220
|
label,
|
|
1696
2221
|
icon: createOptionIcon,
|
|
@@ -1715,25 +2240,25 @@ var isRefSnapshot = (val) => {
|
|
|
1715
2240
|
return typeof val === "object" && typeof val?.["/"] === "string";
|
|
1716
2241
|
};
|
|
1717
2242
|
var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result) => {
|
|
1718
|
-
const id = Entity.
|
|
1719
|
-
const parent = parentLabel ?
|
|
2243
|
+
const id = Entity.getURI(result);
|
|
2244
|
+
const parent = parentLabel ? Obj3.getParent(result) : void 0;
|
|
1720
2245
|
const label = parent ? Entity.getLabel(parent) : Entity.getLabel(result);
|
|
1721
2246
|
return {
|
|
1722
2247
|
id,
|
|
1723
2248
|
label: label ?? id
|
|
1724
2249
|
};
|
|
1725
2250
|
});
|
|
1726
|
-
var defaultUseResults = (db, typename) => useQuery(db, typename ? typename ===
|
|
2251
|
+
var defaultUseResults = (db, typename) => useQuery(db, typename ? typename === ANY_OBJECT_TYPENAME ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1727
2252
|
var RefField = (props) => {
|
|
1728
|
-
const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db,
|
|
1729
|
-
const { t } =
|
|
2253
|
+
const { type, readonly, label, jsonPath, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, useType: useType2 = defaultUseType2, useResults = defaultUseResults, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
|
|
2254
|
+
const { t } = useTranslation8(translationKey8);
|
|
1730
2255
|
const { status, error } = getStatus();
|
|
1731
|
-
const typename =
|
|
2256
|
+
const typename = useMemo9(() => type ? findAnnotation3(type, ReferenceAnnotationId3)?.typename : void 0, [
|
|
1732
2257
|
type
|
|
1733
2258
|
]);
|
|
1734
2259
|
const results = useResults(db, typename);
|
|
1735
|
-
const options =
|
|
1736
|
-
const parentLabel = type ?
|
|
2260
|
+
const options = useMemo9(() => {
|
|
2261
|
+
const parentLabel = type ? findAnnotation3(type, ParentLabelAnnotationId) === true : false;
|
|
1737
2262
|
return getOptions(results, {
|
|
1738
2263
|
parentLabel
|
|
1739
2264
|
});
|
|
@@ -1742,15 +2267,15 @@ var RefField = (props) => {
|
|
|
1742
2267
|
getOptions,
|
|
1743
2268
|
type
|
|
1744
2269
|
]);
|
|
1745
|
-
const handleGetValue =
|
|
2270
|
+
const handleGetValue = useCallback11(() => {
|
|
1746
2271
|
const formValue = getValue();
|
|
1747
|
-
const
|
|
2272
|
+
const dxnToEntityId = (dxn) => dxn.split(/[:/]/).filter(Boolean).pop() ?? dxn;
|
|
1748
2273
|
const unknownToRefOption = (value3) => {
|
|
1749
|
-
const isRef =
|
|
2274
|
+
const isRef = Ref5.isRef(value3);
|
|
1750
2275
|
if (isRef || isRefSnapshot(value3)) {
|
|
1751
|
-
const dxnString = isRef ? value3.
|
|
1752
|
-
const objectId =
|
|
1753
|
-
const matchingOption = options.find((option) =>
|
|
2276
|
+
const dxnString = isRef ? value3.uri : value3["/"];
|
|
2277
|
+
const objectId = dxnToEntityId(dxnString);
|
|
2278
|
+
const matchingOption = options.find((option) => dxnToEntityId(option.id) === objectId);
|
|
1754
2279
|
if (matchingOption) {
|
|
1755
2280
|
return matchingOption;
|
|
1756
2281
|
}
|
|
@@ -1763,20 +2288,20 @@ var RefField = (props) => {
|
|
|
1763
2288
|
getValue
|
|
1764
2289
|
]);
|
|
1765
2290
|
const item = handleGetValue();
|
|
1766
|
-
const selectedIds =
|
|
2291
|
+
const selectedIds = useMemo9(() => item ? [
|
|
1767
2292
|
item.id
|
|
1768
2293
|
] : [], [
|
|
1769
2294
|
item
|
|
1770
2295
|
]);
|
|
1771
|
-
const createSchema =
|
|
2296
|
+
const createSchema = useType2(db, typename);
|
|
1772
2297
|
const [open, setOpen] = useState4(false);
|
|
1773
|
-
const handleCreate =
|
|
2298
|
+
const handleCreate = useCallback11(async (values) => {
|
|
1774
2299
|
if (!createSchema || !onCreate) {
|
|
1775
2300
|
return;
|
|
1776
2301
|
}
|
|
1777
2302
|
const newObject = await onCreate(createSchema, values);
|
|
1778
2303
|
if (newObject) {
|
|
1779
|
-
onValueChange(type,
|
|
2304
|
+
onValueChange(type, Ref5.make(newObject));
|
|
1780
2305
|
}
|
|
1781
2306
|
setOpen(false);
|
|
1782
2307
|
}, [
|
|
@@ -1785,16 +2310,16 @@ var RefField = (props) => {
|
|
|
1785
2310
|
type,
|
|
1786
2311
|
onValueChange
|
|
1787
2312
|
]);
|
|
1788
|
-
const handleUpdate =
|
|
2313
|
+
const handleUpdate = useCallback11((id) => {
|
|
1789
2314
|
const item2 = options.find((option) => option.id === id);
|
|
1790
|
-
const ref = item2 ?
|
|
2315
|
+
const ref = item2 ? Ref5.fromURI(URI.make(item2.id)) : void 0;
|
|
1791
2316
|
onValueChange(type, ref);
|
|
1792
2317
|
}, [
|
|
1793
2318
|
options,
|
|
1794
2319
|
type,
|
|
1795
2320
|
onValueChange
|
|
1796
2321
|
]);
|
|
1797
|
-
const handleSelect =
|
|
2322
|
+
const handleSelect = useCallback11((id) => {
|
|
1798
2323
|
if (item?.id === id) {
|
|
1799
2324
|
handleUpdate(void 0);
|
|
1800
2325
|
} else {
|
|
@@ -1807,104 +2332,117 @@ var RefField = (props) => {
|
|
|
1807
2332
|
if (!typename || (readonly || layout === "static") && !item) {
|
|
1808
2333
|
return null;
|
|
1809
2334
|
}
|
|
1810
|
-
return /* @__PURE__ */
|
|
2335
|
+
return /* @__PURE__ */ React14.createElement(Input10.Root, {
|
|
1811
2336
|
validationValence: status
|
|
1812
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
2337
|
+
}, layout !== "inline" && /* @__PURE__ */ React14.createElement(FormFieldLabel, {
|
|
1813
2338
|
error,
|
|
1814
2339
|
readonly,
|
|
1815
|
-
label
|
|
1816
|
-
|
|
2340
|
+
label,
|
|
2341
|
+
path: jsonPath
|
|
2342
|
+
}), /* @__PURE__ */ React14.createElement("div", null, readonly ? !item ? /* @__PURE__ */ React14.createElement("p", {
|
|
1817
2343
|
className: "text-description mb-2"
|
|
1818
|
-
}, t("empty-readonly-ref-field.label")) : /* @__PURE__ */
|
|
2344
|
+
}, t("empty-readonly-ref-field.label")) : /* @__PURE__ */ React14.createElement(DxAnchor, {
|
|
1819
2345
|
key: item.id,
|
|
1820
2346
|
dxn: item.id,
|
|
1821
2347
|
rootclassname: "me-1"
|
|
1822
|
-
}, item.label) : /* @__PURE__ */
|
|
2348
|
+
}, item.label) : /* @__PURE__ */ React14.createElement(ObjectPicker.Root, {
|
|
1823
2349
|
open,
|
|
1824
2350
|
onOpenChange: setOpen
|
|
1825
|
-
}, /* @__PURE__ */
|
|
2351
|
+
}, /* @__PURE__ */ React14.createElement(ObjectPicker.Trigger, {
|
|
1826
2352
|
asChild: true,
|
|
1827
2353
|
classNames: "p-0"
|
|
1828
|
-
}, item ? /* @__PURE__ */
|
|
1829
|
-
role: "none",
|
|
2354
|
+
}, item ? /* @__PURE__ */ React14.createElement("div", {
|
|
1830
2355
|
className: "flex gap-form-gap w-full"
|
|
1831
|
-
}, /* @__PURE__ */
|
|
2356
|
+
}, /* @__PURE__ */ React14.createElement(Input10.Root, {
|
|
1832
2357
|
key: item.id
|
|
1833
|
-
}, /* @__PURE__ */
|
|
2358
|
+
}, /* @__PURE__ */ React14.createElement(Input10.TextInput, {
|
|
1834
2359
|
value: item.label,
|
|
1835
2360
|
readOnly: true,
|
|
1836
2361
|
classNames: "w-full"
|
|
1837
|
-
}))) : /* @__PURE__ */
|
|
2362
|
+
}))) : /* @__PURE__ */ React14.createElement(Button3, {
|
|
1838
2363
|
classNames: "w-full text-start gap-form-gap"
|
|
1839
|
-
}, /* @__PURE__ */
|
|
1840
|
-
role: "none",
|
|
2364
|
+
}, /* @__PURE__ */ React14.createElement("div", {
|
|
1841
2365
|
className: "grow overflow-hidden"
|
|
1842
|
-
}, /* @__PURE__ */
|
|
2366
|
+
}, /* @__PURE__ */ React14.createElement("span", {
|
|
1843
2367
|
className: "truncate text-description"
|
|
1844
|
-
}, placeholder
|
|
2368
|
+
}, placeholder || label || t("ref-field.placeholder"))), /* @__PURE__ */ React14.createElement(Icon4, {
|
|
1845
2369
|
size: 3,
|
|
1846
2370
|
icon: "ph--caret-down--bold"
|
|
1847
|
-
}))), /* @__PURE__ */
|
|
2371
|
+
}))), /* @__PURE__ */ React14.createElement(ObjectPicker.Portal, null, /* @__PURE__ */ React14.createElement(ObjectPicker.Content, {
|
|
1848
2372
|
classNames: "dx-card-popover-width",
|
|
1849
2373
|
options,
|
|
1850
2374
|
selectedIds,
|
|
1851
2375
|
// Strip hidden (`FormInputAnnotation.set(false)`) fields so the
|
|
1852
2376
|
// form's validator doesn't reject required-but-hidden fields
|
|
1853
2377
|
// such as backing-object refs supplied by a `FactoryAnnotation`.
|
|
1854
|
-
createSchema: createSchema && omitHiddenFormFields(omitId(createSchema)),
|
|
2378
|
+
createSchema: createSchema && omitHiddenFormFields(omitId(Type3.getSchema(createSchema))),
|
|
1855
2379
|
createOptionLabel,
|
|
1856
2380
|
createOptionIcon,
|
|
1857
2381
|
createInitialValuePath,
|
|
1858
2382
|
createFieldMap: createFieldMap3,
|
|
1859
2383
|
onCreate: handleCreate,
|
|
1860
2384
|
onSelect: handleSelect
|
|
1861
|
-
})))), layout === "full" && /* @__PURE__ */
|
|
2385
|
+
})))), layout === "full" && /* @__PURE__ */ React14.createElement(Input10.DescriptionAndValidation, null, error));
|
|
1862
2386
|
};
|
|
1863
2387
|
|
|
1864
2388
|
// src/components/Form/fields/SelectField.tsx
|
|
1865
|
-
import
|
|
1866
|
-
import { Input as
|
|
1867
|
-
|
|
2389
|
+
import React15, { useCallback as useCallback12 } from "react";
|
|
2390
|
+
import { Icon as Icon5, Input as Input11, Select } from "@dxos/react-ui";
|
|
2391
|
+
import { getStyles } from "@dxos/ui-theme";
|
|
2392
|
+
var SelectField = ({ type, readonly, label, jsonPath, layout, placeholder, options, getStatus, getValue, onValueChange }) => {
|
|
1868
2393
|
const { status, error } = getStatus();
|
|
1869
2394
|
const value3 = getValue();
|
|
1870
|
-
const handleValueChange =
|
|
2395
|
+
const handleValueChange = useCallback12((value4) => onValueChange(type, value4), [
|
|
1871
2396
|
type,
|
|
1872
2397
|
onValueChange
|
|
1873
2398
|
]);
|
|
1874
2399
|
if ((readonly || layout === "static") && value3 == null) {
|
|
1875
2400
|
return null;
|
|
1876
2401
|
}
|
|
1877
|
-
return /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ React15.createElement(Input11.Root, {
|
|
1878
2403
|
validationValence: status
|
|
1879
|
-
}, layout !== "inline" && /* @__PURE__ */
|
|
2404
|
+
}, layout !== "inline" && /* @__PURE__ */ React15.createElement(FormFieldLabel, {
|
|
1880
2405
|
error,
|
|
1881
2406
|
readonly,
|
|
1882
|
-
label
|
|
1883
|
-
|
|
2407
|
+
label,
|
|
2408
|
+
path: jsonPath
|
|
2409
|
+
}), layout === "static" ? /* @__PURE__ */ React15.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value3)?.label ?? String(value3)) : /* @__PURE__ */ React15.createElement(Select.Root, {
|
|
1884
2410
|
value: value3,
|
|
1885
2411
|
onValueChange: handleValueChange
|
|
1886
|
-
}, /* @__PURE__ */
|
|
2412
|
+
}, /* @__PURE__ */ React15.createElement(Select.TriggerButton, {
|
|
1887
2413
|
classNames: "w-full",
|
|
1888
2414
|
disabled: !!readonly,
|
|
1889
2415
|
placeholder
|
|
1890
|
-
}), /* @__PURE__ */
|
|
2416
|
+
}), /* @__PURE__ */ React15.createElement(Select.Portal, null, /* @__PURE__ */ React15.createElement(Select.Content, null, /* @__PURE__ */ React15.createElement(Select.Viewport, null, options?.map(({ value: value4, label: label2, secondaryLabel, icon, iconHue }) => (
|
|
1891
2417
|
// NOTE: Numeric values are converted to and from strings.
|
|
1892
|
-
/* @__PURE__ */
|
|
2418
|
+
/* @__PURE__ */ React15.createElement(Select.Option, {
|
|
1893
2419
|
key: String(value4),
|
|
1894
2420
|
value: String(value4)
|
|
1895
|
-
},
|
|
1896
|
-
|
|
2421
|
+
}, /* @__PURE__ */ React15.createElement("span", {
|
|
2422
|
+
className: "flex items-center flex-row gap-2"
|
|
2423
|
+
}, icon && /* @__PURE__ */ React15.createElement(Icon5, {
|
|
2424
|
+
icon,
|
|
2425
|
+
classNames: getIconHueStyles(iconHue)
|
|
2426
|
+
}), label2 ?? String(value4), secondaryLabel && /* @__PURE__ */ React15.createElement("span", {
|
|
2427
|
+
className: "text-subdued text-xs"
|
|
2428
|
+
}, secondaryLabel)))
|
|
2429
|
+
))), /* @__PURE__ */ React15.createElement(Select.Arrow, null)))), layout === "full" && /* @__PURE__ */ React15.createElement(Input11.DescriptionAndValidation, null, error));
|
|
2430
|
+
};
|
|
2431
|
+
var getIconHueStyles = (iconHue) => {
|
|
2432
|
+
const styles = iconHue ? getStyles(iconHue) : void 0;
|
|
2433
|
+
return styles?.fg;
|
|
1897
2434
|
};
|
|
1898
2435
|
|
|
1899
2436
|
// src/components/Form/fields/SelectOptionField.tsx
|
|
1900
|
-
import
|
|
2437
|
+
import React16, { useCallback as useCallback13, useEffect as useEffect4, useRef as useRef2, useState as useState5 } from "react";
|
|
1901
2438
|
import { PublicKey } from "@dxos/keys";
|
|
1902
|
-
import { IconButton as IconButton3, Input as
|
|
2439
|
+
import { IconButton as IconButton3, Input as Input12, Tag, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
1903
2440
|
import { List } from "@dxos/react-ui-list";
|
|
1904
2441
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1905
|
-
import { hues, osTranslations
|
|
1906
|
-
|
|
1907
|
-
|
|
2442
|
+
import { hues, osTranslations } from "@dxos/ui-theme";
|
|
2443
|
+
import { translationKey as translationKey9 } from "#translations";
|
|
2444
|
+
var SelectOptionField = ({ type, readonly, label, jsonPath, getStatus, getValue, onValueChange }) => {
|
|
2445
|
+
const { t } = useTranslation9(translationKey9);
|
|
1908
2446
|
const { status, error } = getStatus();
|
|
1909
2447
|
const [selected, setSelectedId] = useState5(null);
|
|
1910
2448
|
const [isNewOption, setIsNewOption] = useState5(false);
|
|
@@ -1929,7 +2467,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1929
2467
|
const availableHues = hues.filter((hue) => !lastThree.has(hue));
|
|
1930
2468
|
return availableHues[Math.floor(Math.random() * availableHues.length)] ?? hues[Math.floor(Math.random() * hues.length)];
|
|
1931
2469
|
};
|
|
1932
|
-
const handleAdd =
|
|
2470
|
+
const handleAdd = useCallback13(() => {
|
|
1933
2471
|
const newId = PublicKey.random().truncate();
|
|
1934
2472
|
const newOption = {
|
|
1935
2473
|
id: newId,
|
|
@@ -1947,7 +2485,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1947
2485
|
type,
|
|
1948
2486
|
onValueChange
|
|
1949
2487
|
]);
|
|
1950
|
-
const handleDelete =
|
|
2488
|
+
const handleDelete = useCallback13((id) => {
|
|
1951
2489
|
const newOptions = options?.filter((option) => option.id !== id) ?? [];
|
|
1952
2490
|
onValueChange(type, newOptions);
|
|
1953
2491
|
setSelectedId(null);
|
|
@@ -1956,7 +2494,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1956
2494
|
type,
|
|
1957
2495
|
onValueChange
|
|
1958
2496
|
]);
|
|
1959
|
-
const handleMove =
|
|
2497
|
+
const handleMove = useCallback13((from, to) => {
|
|
1960
2498
|
if (!options) {
|
|
1961
2499
|
return;
|
|
1962
2500
|
}
|
|
@@ -1971,10 +2509,10 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1971
2509
|
type,
|
|
1972
2510
|
onValueChange
|
|
1973
2511
|
]);
|
|
1974
|
-
const handleClick =
|
|
2512
|
+
const handleClick = useCallback13((id) => {
|
|
1975
2513
|
setSelectedId((current) => current === id ? null : id);
|
|
1976
2514
|
}, []);
|
|
1977
|
-
const handleTitleChange =
|
|
2515
|
+
const handleTitleChange = useCallback13((id) => (e) => {
|
|
1978
2516
|
const newOptions = options?.map((o) => o.id === id ? {
|
|
1979
2517
|
...o,
|
|
1980
2518
|
title: e.target.value
|
|
@@ -1985,12 +2523,12 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
1985
2523
|
type,
|
|
1986
2524
|
onValueChange
|
|
1987
2525
|
]);
|
|
1988
|
-
const handleKeyDown =
|
|
2526
|
+
const handleKeyDown = useCallback13((ev) => {
|
|
1989
2527
|
if (ev.key === "Enter") {
|
|
1990
2528
|
setSelectedId(null);
|
|
1991
2529
|
}
|
|
1992
2530
|
}, []);
|
|
1993
|
-
const handleColorChange =
|
|
2531
|
+
const handleColorChange = useCallback13((id) => (hue) => {
|
|
1994
2532
|
const newOptions = options?.map((o) => o.id === id ? {
|
|
1995
2533
|
...o,
|
|
1996
2534
|
color: hue
|
|
@@ -2010,56 +2548,52 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
2010
2548
|
selected,
|
|
2011
2549
|
isNewOption
|
|
2012
2550
|
]);
|
|
2013
|
-
return /* @__PURE__ */
|
|
2551
|
+
return /* @__PURE__ */ React16.createElement(Input12.Root, {
|
|
2014
2552
|
validationValence: status
|
|
2015
|
-
}, /* @__PURE__ */
|
|
2553
|
+
}, /* @__PURE__ */ React16.createElement(FormFieldLabel, {
|
|
2016
2554
|
error,
|
|
2017
2555
|
readonly,
|
|
2018
|
-
label
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
}, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
2556
|
+
label,
|
|
2557
|
+
path: jsonPath
|
|
2558
|
+
}), /* @__PURE__ */ React16.createElement("div", null, options && /* @__PURE__ */ React16.createElement(List.Root, {
|
|
2022
2559
|
items: options,
|
|
2023
2560
|
isItem: (_item) => true,
|
|
2024
2561
|
onMove: readonly ? void 0 : handleMove,
|
|
2025
2562
|
readonly: !!readonly
|
|
2026
|
-
}, ({ items }) => /* @__PURE__ */
|
|
2563
|
+
}, ({ items }) => /* @__PURE__ */ React16.createElement("div", {
|
|
2027
2564
|
role: "list",
|
|
2028
2565
|
className: "w-full overflow-auto"
|
|
2029
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
2566
|
+
}, items?.map((item) => /* @__PURE__ */ React16.createElement("div", {
|
|
2030
2567
|
key: item.id
|
|
2031
|
-
}, /* @__PURE__ */
|
|
2568
|
+
}, /* @__PURE__ */ React16.createElement(List.Item, {
|
|
2032
2569
|
role: "button",
|
|
2033
2570
|
item,
|
|
2034
|
-
classNames:
|
|
2035
|
-
subtleHover,
|
|
2036
|
-
"flex flex-col cursor-pointer rounded-xs"
|
|
2037
|
-
],
|
|
2571
|
+
classNames: "flex flex-col cursor-pointer rounded-xs dx-hover",
|
|
2038
2572
|
"aria-expanded": selected === item.id
|
|
2039
|
-
}, /* @__PURE__ */
|
|
2573
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
2040
2574
|
className: "flex items-center"
|
|
2041
|
-
}, /* @__PURE__ */
|
|
2575
|
+
}, /* @__PURE__ */ React16.createElement(List.ItemDragHandle, {
|
|
2042
2576
|
disabled: !!readonly
|
|
2043
|
-
}), /* @__PURE__ */
|
|
2577
|
+
}), /* @__PURE__ */ React16.createElement(List.ItemTitle, {
|
|
2044
2578
|
onClick: () => handleClick(item.id),
|
|
2045
2579
|
classNames: "flex-1"
|
|
2046
|
-
}, /* @__PURE__ */
|
|
2580
|
+
}, /* @__PURE__ */ React16.createElement(Tag, {
|
|
2047
2581
|
palette: item.color
|
|
2048
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
2582
|
+
}, item.title || "\u200B")), /* @__PURE__ */ React16.createElement(IconButton3, {
|
|
2049
2583
|
iconOnly: true,
|
|
2050
2584
|
variant: "ghost",
|
|
2051
|
-
label: t(selected === item.id ? "collapse
|
|
2585
|
+
label: t(selected === item.id ? "collapse.label" : "expand.label", {
|
|
2052
2586
|
ns: osTranslations
|
|
2053
2587
|
}),
|
|
2054
2588
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
2055
2589
|
onClick: () => handleClick(item.id)
|
|
2056
|
-
})), selected === item.id && /* @__PURE__ */
|
|
2057
|
-
className: "flex flex-col p-form-padding gap-form-gap dx-density-
|
|
2058
|
-
}, /* @__PURE__ */
|
|
2059
|
-
classNames: "text-
|
|
2060
|
-
}, t("select-option.label")), /* @__PURE__ */
|
|
2590
|
+
})), selected === item.id && /* @__PURE__ */ React16.createElement("div", {
|
|
2591
|
+
className: "flex flex-col p-form-padding gap-form-gap dx-density-md"
|
|
2592
|
+
}, /* @__PURE__ */ React16.createElement(Input12.Label, {
|
|
2593
|
+
classNames: "text-sm"
|
|
2594
|
+
}, t("select-option.label")), /* @__PURE__ */ React16.createElement("div", {
|
|
2061
2595
|
className: "grid grid-cols-[1fr_min-content_min-content] gap-form-gap"
|
|
2062
|
-
}, /* @__PURE__ */
|
|
2596
|
+
}, /* @__PURE__ */ React16.createElement(Input12.TextInput, {
|
|
2063
2597
|
disabled: !!readonly,
|
|
2064
2598
|
placeholder: t("select-option-label.placeholder"),
|
|
2065
2599
|
ref: selected === item.id ? inputRef : void 0,
|
|
@@ -2067,17 +2601,17 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
2067
2601
|
onChange: handleTitleChange(item.id),
|
|
2068
2602
|
onKeyDown: handleKeyDown,
|
|
2069
2603
|
classNames: "flex-1"
|
|
2070
|
-
}), /* @__PURE__ */
|
|
2604
|
+
}), /* @__PURE__ */ React16.createElement(HuePicker, {
|
|
2071
2605
|
disabled: !!readonly,
|
|
2072
2606
|
value: item.color,
|
|
2073
2607
|
onChange: handleColorChange(item.id)
|
|
2074
|
-
}), /* @__PURE__ */
|
|
2608
|
+
}), /* @__PURE__ */ React16.createElement(IconButton3, {
|
|
2075
2609
|
disabled: !!readonly,
|
|
2076
2610
|
icon: "ph--trash--fill",
|
|
2077
2611
|
iconOnly: true,
|
|
2078
2612
|
label: t("select-option-delete.button"),
|
|
2079
2613
|
onClick: () => handleDelete(item.id)
|
|
2080
|
-
})))))), /* @__PURE__ */
|
|
2614
|
+
})))))), /* @__PURE__ */ React16.createElement(IconButton3, {
|
|
2081
2615
|
variant: "ghost",
|
|
2082
2616
|
icon: "ph--plus--regular",
|
|
2083
2617
|
label: t("select-option-add.button"),
|
|
@@ -2088,17 +2622,17 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
2088
2622
|
};
|
|
2089
2623
|
|
|
2090
2624
|
// src/components/Form/fields/TextField.tsx
|
|
2091
|
-
import
|
|
2092
|
-
import { Input as
|
|
2625
|
+
import React17, { useCallback as useCallback14 } from "react";
|
|
2626
|
+
import { Input as Input13 } from "@dxos/react-ui";
|
|
2093
2627
|
var TextField = ({ type, readonly, placeholder, onBlur, onValueChange, ...props }) => {
|
|
2094
|
-
const handleChange =
|
|
2628
|
+
const handleChange = useCallback14((event) => onValueChange(type, event.target.value), [
|
|
2095
2629
|
type,
|
|
2096
2630
|
onValueChange
|
|
2097
2631
|
]);
|
|
2098
|
-
return /* @__PURE__ */
|
|
2632
|
+
return /* @__PURE__ */ React17.createElement(FormFieldWrapper, {
|
|
2099
2633
|
readonly,
|
|
2100
2634
|
...props
|
|
2101
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
2635
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React17.createElement(Input13.TextInput, {
|
|
2102
2636
|
noAutoFill: true,
|
|
2103
2637
|
disabled: !!readonly,
|
|
2104
2638
|
placeholder,
|
|
@@ -2109,18 +2643,18 @@ var TextField = ({ type, readonly, placeholder, onBlur, onValueChange, ...props
|
|
|
2109
2643
|
};
|
|
2110
2644
|
|
|
2111
2645
|
// src/components/Form/fields/TextAreaField.tsx
|
|
2112
|
-
import
|
|
2113
|
-
import { Input as
|
|
2646
|
+
import React18, { useCallback as useCallback15 } from "react";
|
|
2647
|
+
import { Input as Input14 } from "@dxos/react-ui";
|
|
2114
2648
|
var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...props }) => {
|
|
2115
|
-
const handleChange =
|
|
2649
|
+
const handleChange = useCallback15((event) => onValueChange(type, event.target.value), [
|
|
2116
2650
|
type,
|
|
2117
2651
|
onValueChange
|
|
2118
2652
|
]);
|
|
2119
|
-
return /* @__PURE__ */
|
|
2653
|
+
return /* @__PURE__ */ React18.createElement(FormFieldWrapper, {
|
|
2120
2654
|
readonly,
|
|
2121
2655
|
...props
|
|
2122
|
-
}, ({ value: value3 = "" }) => /* @__PURE__ */
|
|
2123
|
-
rows:
|
|
2656
|
+
}, ({ value: value3 = "" }) => /* @__PURE__ */ React18.createElement(Input14.TextArea, {
|
|
2657
|
+
rows: 5,
|
|
2124
2658
|
disabled: !!readonly,
|
|
2125
2659
|
placeholder,
|
|
2126
2660
|
value: value3,
|
|
@@ -2130,9 +2664,9 @@ var TextAreaField = ({ type, readonly, placeholder, onValueChange, onBlur, ...pr
|
|
|
2130
2664
|
};
|
|
2131
2665
|
|
|
2132
2666
|
// src/components/Form/fields/TupleField.tsx
|
|
2133
|
-
import
|
|
2134
|
-
import { Input as
|
|
2135
|
-
import { mx as
|
|
2667
|
+
import React19 from "react";
|
|
2668
|
+
import { Input as Input15 } from "@dxos/react-ui";
|
|
2669
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
2136
2670
|
import { safeParseFloat as safeParseFloat3 } from "@dxos/util";
|
|
2137
2671
|
var gridCols = [
|
|
2138
2672
|
"grid-cols-1",
|
|
@@ -2140,18 +2674,19 @@ var gridCols = [
|
|
|
2140
2674
|
"grid-cols-3",
|
|
2141
2675
|
"grid-cols-4"
|
|
2142
2676
|
];
|
|
2143
|
-
var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValueChange, onBlur }) => {
|
|
2677
|
+
var TupleField = ({ binding, type, readonly, label, jsonPath, getStatus, getValue, onValueChange, onBlur }) => {
|
|
2144
2678
|
const { status, error } = getStatus();
|
|
2145
2679
|
const values = getValue() ?? {};
|
|
2146
|
-
return /* @__PURE__ */
|
|
2680
|
+
return /* @__PURE__ */ React19.createElement(Input15.Root, {
|
|
2147
2681
|
validationValence: status
|
|
2148
|
-
}, /* @__PURE__ */
|
|
2682
|
+
}, /* @__PURE__ */ React19.createElement(FormFieldLabel, {
|
|
2149
2683
|
error,
|
|
2150
2684
|
readonly,
|
|
2151
|
-
label
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2685
|
+
label,
|
|
2686
|
+
path: jsonPath
|
|
2687
|
+
}), /* @__PURE__ */ React19.createElement("div", {
|
|
2688
|
+
className: mx4("grid gap-form-gap", gridCols[binding.length - 1])
|
|
2689
|
+
}, binding.map((prop) => /* @__PURE__ */ React19.createElement(Input15.TextInput, {
|
|
2155
2690
|
key: prop,
|
|
2156
2691
|
type: "number",
|
|
2157
2692
|
disabled: !!readonly,
|
|
@@ -2166,10 +2701,20 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2166
2701
|
}))));
|
|
2167
2702
|
};
|
|
2168
2703
|
|
|
2704
|
+
// src/components/Form/meta-tags.ts
|
|
2705
|
+
import * as Schema4 from "effect/Schema";
|
|
2706
|
+
import { Ref as Ref6, Tag as Tag2 } from "@dxos/echo";
|
|
2707
|
+
var META_TAGS_KEY = "_tags";
|
|
2708
|
+
var withMetaTags = (schema) => omitId(Schema4.Struct({
|
|
2709
|
+
[META_TAGS_KEY]: Schema4.Array(Ref6.Ref(Tag2.Tag)).pipe(Schema4.annotations({
|
|
2710
|
+
title: "Tags"
|
|
2711
|
+
}), Schema4.optional)
|
|
2712
|
+
}).pipe(Schema4.extend(schema)));
|
|
2713
|
+
|
|
2169
2714
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2170
2715
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2171
2716
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2172
|
-
const { t } =
|
|
2717
|
+
const { t } = useTranslation10(translationKey10);
|
|
2173
2718
|
const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
|
|
2174
2719
|
useEffect5(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2175
2720
|
field,
|
|
@@ -2180,10 +2725,10 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2180
2725
|
if (!registry) {
|
|
2181
2726
|
return;
|
|
2182
2727
|
}
|
|
2183
|
-
const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
|
|
2728
|
+
const subscription = registry.query(Filter2.type(Type4.Type)).subscribe((query) => setSchemas(query.results), {
|
|
2184
2729
|
fire: true
|
|
2185
2730
|
});
|
|
2186
|
-
const schemas2 = await registry.query().run();
|
|
2731
|
+
const schemas2 = await registry.query(Filter2.type(Type4.Type)).run();
|
|
2187
2732
|
setSchemas(schemas2);
|
|
2188
2733
|
return () => subscription?.();
|
|
2189
2734
|
}, [
|
|
@@ -2191,7 +2736,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2191
2736
|
]);
|
|
2192
2737
|
const [referenceSchema, setReferenceSchema] = useState6();
|
|
2193
2738
|
useEffect5(() => {
|
|
2194
|
-
setReferenceSchema(schemas.find((schema) => schema
|
|
2739
|
+
setReferenceSchema(schemas.find((schema) => Type4.getTypename(schema) === props?.referenceSchema));
|
|
2195
2740
|
}, [
|
|
2196
2741
|
schemas,
|
|
2197
2742
|
props?.referenceSchema
|
|
@@ -2199,34 +2744,34 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2199
2744
|
const [{ fieldSchema }, setFieldSchema] = useState6({
|
|
2200
2745
|
fieldSchema: getFormatSchema(props?.format)
|
|
2201
2746
|
});
|
|
2202
|
-
const fieldMap =
|
|
2203
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
2747
|
+
const fieldMap = useMemo10(() => ({
|
|
2748
|
+
["format"]: (props2) => /* @__PURE__ */ React20.createElement(SelectField, {
|
|
2204
2749
|
...props2,
|
|
2205
|
-
options: FormatEnums.filter((value3) => value3 !==
|
|
2750
|
+
options: FormatEnums.filter((value3) => value3 !== Format6.TypeFormat.None).map((value3) => ({
|
|
2206
2751
|
value: value3,
|
|
2207
2752
|
label: t(`format.${value3}.label`)
|
|
2208
2753
|
}))
|
|
2209
2754
|
}),
|
|
2210
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
2755
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React20.createElement(SelectField, {
|
|
2211
2756
|
...props2,
|
|
2212
|
-
options: schemas.map((schema) => ({
|
|
2213
|
-
value:
|
|
2757
|
+
options: schemas.map((schema) => Type4.getTypename(schema)).filter((typename) => typename != null).map((typename) => ({
|
|
2758
|
+
value: typename
|
|
2214
2759
|
}))
|
|
2215
2760
|
}),
|
|
2216
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
2761
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React20.createElement(SelectField, {
|
|
2217
2762
|
...props2,
|
|
2218
|
-
options: referenceSchema ? getFormProperties(referenceSchema.ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
|
|
2763
|
+
options: referenceSchema ? getFormProperties(Type4.getSchema(referenceSchema).ast).sort((a, b) => a.name.toString().localeCompare(b.name.toString())).map((p) => ({
|
|
2219
2764
|
value: p.name.toString()
|
|
2220
2765
|
})) : []
|
|
2221
2766
|
}),
|
|
2222
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
2767
|
+
["options"]: (props2) => /* @__PURE__ */ React20.createElement(SelectOptionField, props2)
|
|
2223
2768
|
}), [
|
|
2224
2769
|
t,
|
|
2225
2770
|
schemas,
|
|
2226
2771
|
referenceSchema
|
|
2227
2772
|
]);
|
|
2228
|
-
const propIsNotType =
|
|
2229
|
-
const handleValuesChanged =
|
|
2773
|
+
const propIsNotType = useCallback16((props2) => props2.filter((prop) => prop.name !== "type"), []);
|
|
2774
|
+
const handleValuesChanged = useCallback16((_props) => {
|
|
2230
2775
|
setFieldSchema((prev) => {
|
|
2231
2776
|
const fieldSchema2 = getFormatSchema(_props.format);
|
|
2232
2777
|
if (prev.fieldSchema === fieldSchema2) {
|
|
@@ -2237,8 +2782,8 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2237
2782
|
};
|
|
2238
2783
|
});
|
|
2239
2784
|
setReferenceSchema((prev) => {
|
|
2240
|
-
if (_props.referenceSchema !== prev
|
|
2241
|
-
const newSchema = schemas.find((schema) => schema
|
|
2785
|
+
if (_props.referenceSchema !== (prev ? Type4.getTypename(prev) : void 0)) {
|
|
2786
|
+
const newSchema = schemas.find((schema) => Type4.getTypename(schema) === _props.referenceSchema);
|
|
2242
2787
|
if (newSchema) {
|
|
2243
2788
|
return newSchema;
|
|
2244
2789
|
}
|
|
@@ -2263,7 +2808,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2263
2808
|
props.format,
|
|
2264
2809
|
props.referenceSchema
|
|
2265
2810
|
]);
|
|
2266
|
-
const handleValidate =
|
|
2811
|
+
const handleValidate = useCallback16(({ property }) => {
|
|
2267
2812
|
if (property && projection.getFields().find((f) => f.path === property && f.path !== field.path)) {
|
|
2268
2813
|
return [
|
|
2269
2814
|
{
|
|
@@ -2276,9 +2821,9 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2276
2821
|
projection.getFields(),
|
|
2277
2822
|
field
|
|
2278
2823
|
]);
|
|
2279
|
-
const handleSave =
|
|
2824
|
+
const handleSave = useCallback16((props2) => {
|
|
2280
2825
|
if (view) {
|
|
2281
|
-
|
|
2826
|
+
Obj4.update(view, () => {
|
|
2282
2827
|
projection.setFieldProjection({
|
|
2283
2828
|
field,
|
|
2284
2829
|
props: props2
|
|
@@ -2297,7 +2842,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2297
2842
|
view,
|
|
2298
2843
|
onSave
|
|
2299
2844
|
]);
|
|
2300
|
-
const handleCancel =
|
|
2845
|
+
const handleCancel = useCallback16(() => {
|
|
2301
2846
|
onSave();
|
|
2302
2847
|
requestAnimationFrame(() => onCancel?.());
|
|
2303
2848
|
}, [
|
|
@@ -2306,15 +2851,10 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2306
2851
|
if (!fieldSchema) {
|
|
2307
2852
|
log2.warn("invalid format", {
|
|
2308
2853
|
props
|
|
2309
|
-
}, {
|
|
2310
|
-
F: __dxlog_file2,
|
|
2311
|
-
L: 172,
|
|
2312
|
-
S: void 0,
|
|
2313
|
-
C: (f, a) => f(...a)
|
|
2314
|
-
});
|
|
2854
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 156, S: void 0 });
|
|
2315
2855
|
return null;
|
|
2316
2856
|
}
|
|
2317
|
-
return /* @__PURE__ */
|
|
2857
|
+
return /* @__PURE__ */ React20.createElement(Form.Root, {
|
|
2318
2858
|
key: field.id,
|
|
2319
2859
|
fieldMap,
|
|
2320
2860
|
autoFocus: true,
|
|
@@ -2330,115 +2870,100 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2330
2870
|
onValidate: handleValidate,
|
|
2331
2871
|
onSave: handleSave,
|
|
2332
2872
|
onCancel: handleCancel
|
|
2333
|
-
}, /* @__PURE__ */
|
|
2873
|
+
}, /* @__PURE__ */ React20.createElement(Form.Content, null, /* @__PURE__ */ React20.createElement(Form.FieldSet, null), /* @__PURE__ */ React20.createElement(Form.Actions, null)));
|
|
2334
2874
|
};
|
|
2335
2875
|
|
|
2336
2876
|
// src/components/ObjectForm/ObjectForm.tsx
|
|
2337
|
-
import
|
|
2338
|
-
import
|
|
2339
|
-
import {
|
|
2340
|
-
import { splitJsonPath } from "@dxos/echo/internal";
|
|
2877
|
+
import React21, { useCallback as useCallback17, useMemo as useMemo11 } from "react";
|
|
2878
|
+
import { Obj as Obj5, Ref as Ref7, Tag as Tag3, Type as Type5 } from "@dxos/echo";
|
|
2879
|
+
import { splitJsonPath as splitJsonPath2 } from "@dxos/echo/internal";
|
|
2341
2880
|
import { invariant } from "@dxos/invariant";
|
|
2342
2881
|
import { HuePicker as HuePicker2 } from "@dxos/react-ui-pickers";
|
|
2343
|
-
import {
|
|
2882
|
+
import { translationKey as translationKey11 } from "#translations";
|
|
2344
2883
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectForm/ObjectForm.tsx";
|
|
2345
2884
|
var createFieldMap = {
|
|
2346
2885
|
hue: ({ type, label, layout, getValue, onValueChange }) => {
|
|
2347
|
-
const handleChange =
|
|
2886
|
+
const handleChange = useCallback17((nextHue) => onValueChange(type, nextHue), [
|
|
2348
2887
|
onValueChange,
|
|
2349
2888
|
type
|
|
2350
2889
|
]);
|
|
2351
|
-
const handleReset =
|
|
2890
|
+
const handleReset = useCallback17(() => onValueChange(type, void 0), [
|
|
2352
2891
|
onValueChange,
|
|
2353
2892
|
type
|
|
2354
2893
|
]);
|
|
2355
|
-
return /* @__PURE__ */
|
|
2894
|
+
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, layout !== "inline" && /* @__PURE__ */ React21.createElement(Form.Label, {
|
|
2356
2895
|
label
|
|
2357
|
-
}), /* @__PURE__ */
|
|
2896
|
+
}), /* @__PURE__ */ React21.createElement(HuePicker2, {
|
|
2358
2897
|
value: getValue(),
|
|
2359
2898
|
onChange: handleChange,
|
|
2360
2899
|
onReset: handleReset
|
|
2361
2900
|
}));
|
|
2362
2901
|
}
|
|
2363
2902
|
};
|
|
2364
|
-
var ObjectForm = ({ object,
|
|
2365
|
-
const db =
|
|
2366
|
-
const meta =
|
|
2367
|
-
const tags =
|
|
2368
|
-
|
|
2369
|
-
|
|
2903
|
+
var ObjectForm = ({ object, type }) => {
|
|
2904
|
+
const db = Obj5.getDatabase(object);
|
|
2905
|
+
const meta = Obj5.getMeta(object);
|
|
2906
|
+
const tags = [
|
|
2907
|
+
...meta.tags
|
|
2908
|
+
];
|
|
2909
|
+
const values = useMemo11(() => ({
|
|
2910
|
+
[META_TAGS_KEY]: tags,
|
|
2370
2911
|
...object
|
|
2371
2912
|
}), [
|
|
2372
2913
|
object,
|
|
2373
2914
|
tags
|
|
2374
2915
|
]);
|
|
2375
|
-
const formSchema =
|
|
2376
|
-
|
|
2377
|
-
}).pipe(Schema3.extend(schema))), [
|
|
2378
|
-
schema
|
|
2916
|
+
const formSchema = useMemo11(() => withMetaTags(Type5.getSchema(type)), [
|
|
2917
|
+
type
|
|
2379
2918
|
]);
|
|
2380
|
-
const handleCreate =
|
|
2381
|
-
invariant(db, void 0, {
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
});
|
|
2390
|
-
invariant(Type2.isObjectSchema(schema2), void 0, {
|
|
2391
|
-
F: __dxlog_file3,
|
|
2392
|
-
L: 52,
|
|
2393
|
-
S: void 0,
|
|
2394
|
-
A: [
|
|
2395
|
-
"Type.isObjectSchema(schema)",
|
|
2396
|
-
""
|
|
2397
|
-
]
|
|
2398
|
-
});
|
|
2399
|
-
const newObject = db.add(Obj4.make(schema2, values2));
|
|
2400
|
-
if (Obj4.instanceOf(Tag2.Tag, newObject)) {
|
|
2401
|
-
Obj4.change(object, (object2) => {
|
|
2402
|
-
Obj4.getMeta(object2).tags = [
|
|
2403
|
-
...Obj4.getMeta(object2).tags ?? [],
|
|
2404
|
-
Obj4.getDXN(newObject).toString()
|
|
2919
|
+
const handleCreate = useCallback17((type2, values2) => {
|
|
2920
|
+
invariant(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 48, S: void 0, A: ["db", ""] });
|
|
2921
|
+
invariant(Type5.isObject(type2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 49, S: void 0, A: ["Type.isObject(type)", ""] });
|
|
2922
|
+
const newObject = db.add(Obj5.make(type2, values2));
|
|
2923
|
+
if (Obj5.instanceOf(Tag3.Tag, newObject)) {
|
|
2924
|
+
Obj5.update(object, (object2) => {
|
|
2925
|
+
Obj5.getMeta(object2).tags = [
|
|
2926
|
+
...Obj5.getMeta(object2).tags,
|
|
2927
|
+
Ref7.make(newObject)
|
|
2405
2928
|
];
|
|
2406
2929
|
});
|
|
2407
2930
|
}
|
|
2408
2931
|
}, []);
|
|
2409
|
-
const handleChange =
|
|
2932
|
+
const handleChange = useCallback17(({ [META_TAGS_KEY]: metaTags, ...values2 }, { isValid, changed }) => {
|
|
2410
2933
|
if (!isValid) {
|
|
2411
2934
|
return;
|
|
2412
2935
|
}
|
|
2413
2936
|
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2414
|
-
const hasTagsChange = changedPaths.some((path) =>
|
|
2937
|
+
const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === META_TAGS_KEY);
|
|
2415
2938
|
if (hasTagsChange) {
|
|
2416
|
-
|
|
2417
|
-
|
|
2939
|
+
Obj5.update(object, (object2) => {
|
|
2940
|
+
Obj5.getMeta(object2).tags = Array.isArray(metaTags) ? [
|
|
2941
|
+
...metaTags
|
|
2942
|
+
] : [];
|
|
2418
2943
|
});
|
|
2419
2944
|
}
|
|
2420
|
-
const nonTagPaths = changedPaths.filter((path) =>
|
|
2945
|
+
const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== META_TAGS_KEY);
|
|
2421
2946
|
if (nonTagPaths.length > 0) {
|
|
2422
|
-
|
|
2947
|
+
Obj5.update(object, () => {
|
|
2423
2948
|
for (const path of nonTagPaths) {
|
|
2424
|
-
const parts =
|
|
2425
|
-
const value3 =
|
|
2426
|
-
|
|
2949
|
+
const parts = splitJsonPath2(path);
|
|
2950
|
+
const value3 = Obj5.getValue(values2, parts);
|
|
2951
|
+
Obj5.setValue(object, parts, value3);
|
|
2427
2952
|
}
|
|
2428
2953
|
});
|
|
2429
2954
|
}
|
|
2430
2955
|
}, [
|
|
2431
2956
|
object
|
|
2432
2957
|
]);
|
|
2433
|
-
return /* @__PURE__ */
|
|
2958
|
+
return /* @__PURE__ */ React21.createElement(Form.Root, {
|
|
2434
2959
|
schema: formSchema,
|
|
2435
2960
|
defaultValues: values,
|
|
2436
|
-
createTypename:
|
|
2961
|
+
createTypename: Type5.getTypename(Tag3.Tag),
|
|
2437
2962
|
createOptionIcon: "ph--plus--regular",
|
|
2438
2963
|
createOptionLabel: [
|
|
2439
2964
|
"add-tag.label",
|
|
2440
2965
|
{
|
|
2441
|
-
ns:
|
|
2966
|
+
ns: translationKey11
|
|
2442
2967
|
}
|
|
2443
2968
|
],
|
|
2444
2969
|
createInitialValuePath: "label",
|
|
@@ -2446,81 +2971,72 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2446
2971
|
db,
|
|
2447
2972
|
onValuesChanged: handleChange,
|
|
2448
2973
|
onCreate: handleCreate
|
|
2449
|
-
}, /* @__PURE__ */
|
|
2974
|
+
}, /* @__PURE__ */ React21.createElement(Form.Viewport, null, /* @__PURE__ */ React21.createElement(Form.Content, null, /* @__PURE__ */ React21.createElement(Form.FieldSet, null))));
|
|
2450
2975
|
};
|
|
2451
2976
|
|
|
2452
2977
|
// src/components/ObjectProperties/ObjectProperties.tsx
|
|
2453
2978
|
import * as Function from "effect/Function";
|
|
2454
|
-
import * as
|
|
2455
|
-
import
|
|
2456
|
-
import
|
|
2457
|
-
import {
|
|
2458
|
-
import { splitJsonPath as
|
|
2979
|
+
import * as Option7 from "effect/Option";
|
|
2980
|
+
import React22, { useCallback as useCallback18, useMemo as useMemo12 } from "react";
|
|
2981
|
+
import { Obj as Obj6, Tag as Tag4, Type as Type6 } from "@dxos/echo";
|
|
2982
|
+
import { useType } from "@dxos/echo-react";
|
|
2983
|
+
import { splitJsonPath as splitJsonPath3 } from "@dxos/echo/internal";
|
|
2459
2984
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
2985
|
+
import { composable as composable2, composableProps as composableProps2 } from "@dxos/react-ui";
|
|
2460
2986
|
import { HuePicker as HuePicker3 } from "@dxos/react-ui-pickers";
|
|
2461
2987
|
import { FactoryAnnotation } from "@dxos/schema";
|
|
2462
|
-
import {
|
|
2463
|
-
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2988
|
+
import { translationKey as translationKey12 } from "#translations";
|
|
2464
2989
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectProperties/ObjectProperties.tsx";
|
|
2465
2990
|
var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef) => {
|
|
2466
|
-
const db =
|
|
2467
|
-
const meta =
|
|
2468
|
-
const tags =
|
|
2469
|
-
|
|
2470
|
-
|
|
2991
|
+
const db = Obj6.getDatabase(object);
|
|
2992
|
+
const meta = Obj6.getMeta(object);
|
|
2993
|
+
const tags = [
|
|
2994
|
+
...meta.tags
|
|
2995
|
+
];
|
|
2996
|
+
const values = useMemo12(() => ({
|
|
2997
|
+
[META_TAGS_KEY]: tags,
|
|
2471
2998
|
...object
|
|
2472
2999
|
}), [
|
|
2473
3000
|
object,
|
|
2474
3001
|
tags
|
|
2475
3002
|
]);
|
|
2476
|
-
const
|
|
2477
|
-
|
|
3003
|
+
const typename = Obj6.getTypename(object) ?? void 0;
|
|
3004
|
+
const typeFromRegistry = useType(db, typename);
|
|
3005
|
+
const type = Obj6.getType(object) ?? typeFromRegistry;
|
|
3006
|
+
const formSchema = useMemo12(() => {
|
|
3007
|
+
return Function.pipe(type, Option7.fromNullable, Option7.map((type2) => Type6.getSchema(type2)), Option7.map((schema) => withMetaTags(schema)), Option7.getOrUndefined);
|
|
2478
3008
|
}, [
|
|
2479
|
-
|
|
3009
|
+
type
|
|
2480
3010
|
]);
|
|
2481
|
-
const handleCreate =
|
|
2482
|
-
invariant2(db, void 0, {
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
A: [
|
|
2487
|
-
"db",
|
|
2488
|
-
""
|
|
2489
|
-
]
|
|
2490
|
-
});
|
|
2491
|
-
invariant2(Type3.isObjectSchema(schema), void 0, {
|
|
2492
|
-
F: __dxlog_file4,
|
|
2493
|
-
L: 53,
|
|
2494
|
-
S: void 0,
|
|
2495
|
-
A: [
|
|
2496
|
-
"Type.isObjectSchema(schema)",
|
|
2497
|
-
""
|
|
2498
|
-
]
|
|
2499
|
-
});
|
|
2500
|
-
const factory = Option5.getOrUndefined(FactoryAnnotation.get(schema));
|
|
2501
|
-
const newObject = factory ? factory(values2) : Obj5.make(schema, values2);
|
|
3011
|
+
const handleCreate = useCallback18((type2, values2) => {
|
|
3012
|
+
invariant2(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 52, S: void 0, A: ["db", ""] });
|
|
3013
|
+
invariant2(Type6.isObject(type2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 53, S: void 0, A: ["Type.isObject(type)", ""] });
|
|
3014
|
+
const factory = Option7.getOrUndefined(FactoryAnnotation.get(Type6.getSchema(type2)));
|
|
3015
|
+
const newObject = factory ? factory(values2) : Obj6.make(type2, values2);
|
|
2502
3016
|
return db.add(newObject);
|
|
2503
3017
|
}, [
|
|
2504
3018
|
db
|
|
2505
3019
|
]);
|
|
2506
|
-
const handleChange =
|
|
3020
|
+
const handleChange = useCallback18(({ [META_TAGS_KEY]: metaTags, ...values2 }, { isValid, changed }) => {
|
|
2507
3021
|
if (!isValid) {
|
|
2508
3022
|
return;
|
|
2509
3023
|
}
|
|
2510
3024
|
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2511
|
-
const hasTagsChange = changedPaths.some((path) =>
|
|
3025
|
+
const hasTagsChange = changedPaths.some((path) => splitJsonPath3(path)[0] === META_TAGS_KEY);
|
|
2512
3026
|
if (hasTagsChange) {
|
|
2513
|
-
|
|
2514
|
-
|
|
3027
|
+
Obj6.update(object, (object2) => {
|
|
3028
|
+
Obj6.getMeta(object2).tags = Array.isArray(metaTags) ? [
|
|
3029
|
+
...metaTags
|
|
3030
|
+
] : [];
|
|
2515
3031
|
});
|
|
2516
3032
|
}
|
|
2517
|
-
const nonTagPaths = changedPaths.filter((path) =>
|
|
3033
|
+
const nonTagPaths = changedPaths.filter((path) => splitJsonPath3(path)[0] !== META_TAGS_KEY);
|
|
2518
3034
|
if (nonTagPaths.length > 0) {
|
|
2519
|
-
|
|
3035
|
+
Obj6.update(object, () => {
|
|
2520
3036
|
for (const path of nonTagPaths) {
|
|
2521
|
-
const parts =
|
|
2522
|
-
const value3 =
|
|
2523
|
-
|
|
3037
|
+
const parts = splitJsonPath3(path);
|
|
3038
|
+
const value3 = Obj6.getValue(values2, parts);
|
|
3039
|
+
Obj6.setValue(object, parts, value3);
|
|
2524
3040
|
}
|
|
2525
3041
|
});
|
|
2526
3042
|
}
|
|
@@ -2530,15 +3046,15 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2530
3046
|
if (!formSchema) {
|
|
2531
3047
|
return null;
|
|
2532
3048
|
}
|
|
2533
|
-
return /* @__PURE__ */
|
|
3049
|
+
return /* @__PURE__ */ React22.createElement(Form.Root, {
|
|
2534
3050
|
schema: formSchema,
|
|
2535
3051
|
defaultValues: values,
|
|
2536
|
-
createTypename:
|
|
3052
|
+
createTypename: Type6.getTypename(Tag4.Tag),
|
|
2537
3053
|
createOptionIcon: "ph--plus--regular",
|
|
2538
3054
|
createOptionLabel: [
|
|
2539
3055
|
"add-tag.label",
|
|
2540
3056
|
{
|
|
2541
|
-
ns:
|
|
3057
|
+
ns: translationKey12
|
|
2542
3058
|
}
|
|
2543
3059
|
],
|
|
2544
3060
|
createInitialValuePath: "label",
|
|
@@ -2546,77 +3062,198 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2546
3062
|
db,
|
|
2547
3063
|
onValuesChanged: handleChange,
|
|
2548
3064
|
onCreate: handleCreate
|
|
2549
|
-
}, /* @__PURE__ */
|
|
3065
|
+
}, /* @__PURE__ */ React22.createElement(Form.Viewport, {
|
|
2550
3066
|
...composableProps2(props),
|
|
2551
3067
|
ref: forwardedRef
|
|
2552
|
-
}, /* @__PURE__ */
|
|
3068
|
+
}, /* @__PURE__ */ React22.createElement(Form.Content, null, /* @__PURE__ */ React22.createElement(Form.FieldSet, null), children)));
|
|
2553
3069
|
});
|
|
2554
3070
|
var createFieldMap2 = {
|
|
2555
3071
|
hue: ({ type, label, layout, getValue, onValueChange }) => {
|
|
2556
|
-
const handleChange =
|
|
3072
|
+
const handleChange = useCallback18((nextHue) => onValueChange(type, nextHue), [
|
|
2557
3073
|
onValueChange,
|
|
2558
3074
|
type
|
|
2559
3075
|
]);
|
|
2560
|
-
const handleReset =
|
|
3076
|
+
const handleReset = useCallback18(() => onValueChange(type, void 0), [
|
|
2561
3077
|
onValueChange,
|
|
2562
3078
|
type
|
|
2563
3079
|
]);
|
|
2564
|
-
return /* @__PURE__ */
|
|
3080
|
+
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, layout !== "inline" && /* @__PURE__ */ React22.createElement(Form.Label, {
|
|
2565
3081
|
label
|
|
2566
|
-
}), /* @__PURE__ */
|
|
3082
|
+
}), /* @__PURE__ */ React22.createElement(HuePicker3, {
|
|
2567
3083
|
value: getValue(),
|
|
2568
3084
|
onChange: handleChange,
|
|
2569
3085
|
onReset: handleReset
|
|
2570
3086
|
}));
|
|
2571
3087
|
}
|
|
2572
3088
|
};
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
3089
|
+
|
|
3090
|
+
// src/components/ObjectTree/ObjectTree.tsx
|
|
3091
|
+
import * as SchemaAST7 from "effect/SchemaAST";
|
|
3092
|
+
import React23 from "react";
|
|
3093
|
+
import { composable as composable3, composableProps as composableProps3 } from "@dxos/react-ui";
|
|
3094
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
3095
|
+
var ObjectTreeImpl = composable3(({ schema, value: value3, ...props }, forwardedRef) => /* @__PURE__ */ React23.createElement("div", {
|
|
3096
|
+
...composableProps3(props, {
|
|
3097
|
+
role: "table",
|
|
3098
|
+
classNames: "font-mono text-sm w-full"
|
|
3099
|
+
}),
|
|
3100
|
+
ref: forwardedRef
|
|
3101
|
+
}, /* @__PURE__ */ React23.createElement(Node, {
|
|
3102
|
+
ast: schema.ast,
|
|
3103
|
+
value: value3,
|
|
3104
|
+
label: null,
|
|
3105
|
+
depth: 0
|
|
3106
|
+
})));
|
|
3107
|
+
ObjectTreeImpl.displayName = "ObjectTree";
|
|
3108
|
+
var ObjectTree = ObjectTreeImpl;
|
|
3109
|
+
var unwrap = (ast) => {
|
|
3110
|
+
if (SchemaAST7.isRefinement(ast)) {
|
|
3111
|
+
return unwrap(ast.from);
|
|
3112
|
+
}
|
|
3113
|
+
if (SchemaAST7.isSuspend(ast)) {
|
|
3114
|
+
return unwrap(ast.f());
|
|
3115
|
+
}
|
|
3116
|
+
if (SchemaAST7.isTransformation(ast)) {
|
|
3117
|
+
return unwrap(ast.from);
|
|
3118
|
+
}
|
|
3119
|
+
return ast;
|
|
3120
|
+
};
|
|
3121
|
+
var stripOptional = (ast) => {
|
|
3122
|
+
if (!SchemaAST7.isUnion(ast)) {
|
|
3123
|
+
return ast;
|
|
3124
|
+
}
|
|
3125
|
+
const nonUndef = ast.types.filter((t) => !SchemaAST7.isUndefinedKeyword(t));
|
|
3126
|
+
return nonUndef.length === 1 ? nonUndef[0] : ast;
|
|
3127
|
+
};
|
|
3128
|
+
var Node = ({ ast, value: value3, label, depth }) => {
|
|
3129
|
+
const inner = unwrap(stripOptional(ast));
|
|
3130
|
+
if (SchemaAST7.isTypeLiteral(inner) && isPlainObject(value3)) {
|
|
3131
|
+
const childDepth = label === null ? depth : depth + 1;
|
|
3132
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, label !== null && /* @__PURE__ */ React23.createElement(Row, {
|
|
3133
|
+
label,
|
|
3134
|
+
value: null,
|
|
3135
|
+
depth,
|
|
3136
|
+
kind: "group"
|
|
3137
|
+
}), inner.propertySignatures.map((prop) => /* @__PURE__ */ React23.createElement(Node, {
|
|
3138
|
+
key: String(prop.name),
|
|
3139
|
+
ast: prop.type,
|
|
3140
|
+
value: value3[String(prop.name)],
|
|
3141
|
+
label: String(prop.name),
|
|
3142
|
+
depth: childDepth
|
|
3143
|
+
})));
|
|
3144
|
+
}
|
|
3145
|
+
if (SchemaAST7.isTupleType(inner) && Array.isArray(value3)) {
|
|
3146
|
+
const elemType = inner.rest[0]?.type;
|
|
3147
|
+
return /* @__PURE__ */ React23.createElement(React23.Fragment, null, label !== null && /* @__PURE__ */ React23.createElement(Row, {
|
|
3148
|
+
label,
|
|
3149
|
+
value: `Array(${value3.length})`,
|
|
3150
|
+
depth,
|
|
3151
|
+
kind: "group"
|
|
3152
|
+
}), value3.map((item, index) => /* @__PURE__ */ React23.createElement(Node, {
|
|
3153
|
+
key: index,
|
|
3154
|
+
ast: elemType ?? SchemaAST7.unknownKeyword,
|
|
3155
|
+
value: item,
|
|
3156
|
+
label: `[${index}]`,
|
|
3157
|
+
depth: depth + 1
|
|
3158
|
+
})));
|
|
3159
|
+
}
|
|
3160
|
+
return /* @__PURE__ */ React23.createElement(Row, {
|
|
3161
|
+
label: label ?? "",
|
|
3162
|
+
value: formatLeaf(value3),
|
|
3163
|
+
depth,
|
|
3164
|
+
kind: "leaf"
|
|
3165
|
+
});
|
|
3166
|
+
};
|
|
3167
|
+
var Row = ({ label, value: value3, depth }) => /* @__PURE__ */ React23.createElement("div", {
|
|
3168
|
+
role: "row",
|
|
3169
|
+
className: mx5("flex items-baseline gap-3 py-1"),
|
|
3170
|
+
style: {
|
|
3171
|
+
paddingInlineStart: 8 + depth * 16
|
|
3172
|
+
}
|
|
3173
|
+
}, /* @__PURE__ */ React23.createElement("div", {
|
|
3174
|
+
role: "cell",
|
|
3175
|
+
className: "text-subdued"
|
|
3176
|
+
}, label), /* @__PURE__ */ React23.createElement("div", {
|
|
3177
|
+
role: "cell",
|
|
3178
|
+
className: mx5("break-all text-base-fg")
|
|
3179
|
+
}, value3));
|
|
3180
|
+
var isPlainObject = (value3) => typeof value3 === "object" && value3 !== null && !Array.isArray(value3);
|
|
3181
|
+
var formatLeaf = (value3) => {
|
|
3182
|
+
if (value3 === void 0) {
|
|
3183
|
+
return null;
|
|
3184
|
+
}
|
|
3185
|
+
if (value3 === null) {
|
|
3186
|
+
return /* @__PURE__ */ React23.createElement("span", {
|
|
3187
|
+
className: "text-description"
|
|
3188
|
+
}, "null");
|
|
3189
|
+
}
|
|
3190
|
+
switch (typeof value3) {
|
|
3191
|
+
case "string":
|
|
3192
|
+
return /* @__PURE__ */ React23.createElement("span", {
|
|
3193
|
+
className: "text-blue-text"
|
|
3194
|
+
}, JSON.stringify(value3));
|
|
3195
|
+
case "number":
|
|
3196
|
+
case "bigint":
|
|
3197
|
+
return /* @__PURE__ */ React23.createElement("span", {
|
|
3198
|
+
className: "text-green-text"
|
|
3199
|
+
}, String(value3));
|
|
3200
|
+
case "boolean":
|
|
3201
|
+
return /* @__PURE__ */ React23.createElement("span", {
|
|
3202
|
+
className: "text-purple-text"
|
|
3203
|
+
}, String(value3));
|
|
3204
|
+
default:
|
|
3205
|
+
try {
|
|
3206
|
+
return JSON.stringify(value3);
|
|
3207
|
+
} catch {
|
|
3208
|
+
return String(value3);
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
};
|
|
2576
3212
|
|
|
2577
3213
|
// src/components/Settings/Settings.tsx
|
|
2578
|
-
import
|
|
2579
|
-
import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as
|
|
2580
|
-
import { composable as
|
|
3214
|
+
import React26 from "react";
|
|
3215
|
+
import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as useTranslation12 } from "@dxos/react-ui";
|
|
3216
|
+
import { composable as composable4, composableProps as composableProps4 } from "@dxos/react-ui";
|
|
3217
|
+
import { mx as mx7 } from "@dxos/ui-theme";
|
|
3218
|
+
import { translationKey as translationKey14 } from "#translations";
|
|
2581
3219
|
|
|
2582
3220
|
// src/components/Settings/SettingsFieldSet.tsx
|
|
2583
|
-
import * as
|
|
2584
|
-
import * as
|
|
2585
|
-
import
|
|
2586
|
-
import { getAnnotation as
|
|
2587
|
-
import { Input as
|
|
3221
|
+
import * as SchemaAST8 from "effect/SchemaAST";
|
|
3222
|
+
import * as String4 from "effect/String";
|
|
3223
|
+
import React25, { useCallback as useCallback19, useMemo as useMemo13 } from "react";
|
|
3224
|
+
import { getAnnotation as getAnnotation4 } from "@dxos/effect";
|
|
3225
|
+
import { Input as Input17, Select as Select2 } from "@dxos/react-ui";
|
|
2588
3226
|
|
|
2589
3227
|
// src/components/Settings/SettingsItem.tsx
|
|
2590
|
-
import
|
|
2591
|
-
import { Input as
|
|
2592
|
-
import { mx as
|
|
3228
|
+
import React24 from "react";
|
|
3229
|
+
import { Input as Input16, toLocalizedString, useTranslation as useTranslation11 } from "@dxos/react-ui";
|
|
3230
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
3231
|
+
import { translationKey as translationKey13 } from "#translations";
|
|
2593
3232
|
var SETTINGS_PANEL_NAME = "Settings.Panel";
|
|
2594
3233
|
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2595
3234
|
var SettingsPanel = ({ classNames, children }) => {
|
|
2596
|
-
return /* @__PURE__ */
|
|
2597
|
-
|
|
2598
|
-
className: mx3("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
|
|
3235
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
3236
|
+
className: mx6("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
|
|
2599
3237
|
}, children);
|
|
2600
3238
|
};
|
|
2601
3239
|
SettingsPanel.displayName = SETTINGS_PANEL_NAME;
|
|
2602
3240
|
var SettingsItem = ({ title, description = "", children }) => {
|
|
2603
|
-
const { t } =
|
|
2604
|
-
return /* @__PURE__ */
|
|
3241
|
+
const { t } = useTranslation11(translationKey13);
|
|
3242
|
+
return /* @__PURE__ */ React24.createElement(Input16.Root, null, /* @__PURE__ */ React24.createElement(SettingsPanel, {
|
|
2605
3243
|
classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
|
|
2606
|
-
}, /* @__PURE__ */
|
|
2607
|
-
classNames: "pb-trim-md text-base-
|
|
2608
|
-
}, toLocalizedString(title, t)), /* @__PURE__ */
|
|
3244
|
+
}, /* @__PURE__ */ React24.createElement(Input16.Label, {
|
|
3245
|
+
classNames: "pb-trim-md text-base-fg text-lg md:col-span-2"
|
|
3246
|
+
}, toLocalizedString(title, t)), /* @__PURE__ */ React24.createElement(Input16.DescriptionAndValidation, null, /* @__PURE__ */ React24.createElement(Input16.Description, {
|
|
2609
3247
|
classNames: "text-base text-description"
|
|
2610
|
-
}, toLocalizedString(description, t))), /* @__PURE__ */
|
|
2611
|
-
role: "none",
|
|
3248
|
+
}, toLocalizedString(description, t))), /* @__PURE__ */ React24.createElement("div", {
|
|
2612
3249
|
className: "text-end py-1"
|
|
2613
3250
|
}, children)));
|
|
2614
3251
|
};
|
|
2615
3252
|
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2616
3253
|
|
|
2617
3254
|
// src/components/Settings/SettingsFieldSet.tsx
|
|
2618
|
-
var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort }) => {
|
|
2619
|
-
const properties =
|
|
3255
|
+
var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort, pathPrefix = "" }) => {
|
|
3256
|
+
const properties = useMemo13(() => {
|
|
2620
3257
|
const props = getFormProperties(schema.ast);
|
|
2621
3258
|
if (!sort) {
|
|
2622
3259
|
return props;
|
|
@@ -2632,7 +3269,7 @@ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, v
|
|
|
2632
3269
|
schema,
|
|
2633
3270
|
sort
|
|
2634
3271
|
]);
|
|
2635
|
-
const handleChange =
|
|
3272
|
+
const handleChange = useCallback19((name, value3) => {
|
|
2636
3273
|
onValuesChanged?.({
|
|
2637
3274
|
...values,
|
|
2638
3275
|
[name]: value3
|
|
@@ -2641,33 +3278,39 @@ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, v
|
|
|
2641
3278
|
values,
|
|
2642
3279
|
onValuesChanged
|
|
2643
3280
|
]);
|
|
2644
|
-
return /* @__PURE__ */
|
|
3281
|
+
return /* @__PURE__ */ React25.createElement(React25.Fragment, null, properties.map((property) => {
|
|
2645
3282
|
const name = property.name.toString();
|
|
2646
|
-
|
|
3283
|
+
const path = pathPrefix ? `${pathPrefix}.${name}` : name;
|
|
3284
|
+
if (visible && !visible(path, values)) {
|
|
2647
3285
|
return null;
|
|
2648
3286
|
}
|
|
2649
|
-
|
|
3287
|
+
const entry = fieldMap?.[name];
|
|
3288
|
+
return /* @__PURE__ */ React25.createElement(SettingsFieldItem, {
|
|
2650
3289
|
key: name,
|
|
3290
|
+
path,
|
|
2651
3291
|
property,
|
|
2652
3292
|
value: values[name],
|
|
2653
3293
|
onChange: (value3) => handleChange(name, value3),
|
|
2654
3294
|
readonly,
|
|
2655
|
-
customField:
|
|
3295
|
+
customField: typeof entry === "function" ? entry : void 0,
|
|
3296
|
+
nestedFieldMap: typeof entry === "object" ? entry : void 0,
|
|
3297
|
+
visible,
|
|
3298
|
+
sort
|
|
2656
3299
|
});
|
|
2657
3300
|
}));
|
|
2658
3301
|
};
|
|
2659
3302
|
SettingsFieldSet.displayName = "Settings.FieldSet";
|
|
2660
|
-
var SettingsFieldItem = ({ property, value: value3, onChange, readonly, customField }) => {
|
|
3303
|
+
var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, customField, nestedFieldMap, visible, sort }) => {
|
|
2661
3304
|
const { type } = property;
|
|
2662
3305
|
const name = property.name.toString();
|
|
2663
|
-
const title =
|
|
2664
|
-
const description =
|
|
3306
|
+
const title = getAnnotation4(SchemaAST8.TitleAnnotationId)(type) ?? String4.capitalize(name);
|
|
3307
|
+
const description = getAnnotation4(SchemaAST8.DescriptionAnnotationId)(type);
|
|
2665
3308
|
if (customField) {
|
|
2666
3309
|
const CustomField = customField;
|
|
2667
|
-
return /* @__PURE__ */
|
|
3310
|
+
return /* @__PURE__ */ React25.createElement(SettingsItem, {
|
|
2668
3311
|
title,
|
|
2669
3312
|
description
|
|
2670
|
-
}, /* @__PURE__ */
|
|
3313
|
+
}, /* @__PURE__ */ React25.createElement(CustomField, {
|
|
2671
3314
|
value: value3,
|
|
2672
3315
|
onChange,
|
|
2673
3316
|
readonly
|
|
@@ -2675,48 +3318,61 @@ var SettingsFieldItem = ({ property, value: value3, onChange, readonly, customFi
|
|
|
2675
3318
|
}
|
|
2676
3319
|
const fieldType = detectFieldType(type);
|
|
2677
3320
|
switch (fieldType) {
|
|
3321
|
+
case "struct":
|
|
3322
|
+
return /* @__PURE__ */ React25.createElement(SettingsFieldSet, {
|
|
3323
|
+
schema: {
|
|
3324
|
+
ast: type
|
|
3325
|
+
},
|
|
3326
|
+
values: value3 ?? {},
|
|
3327
|
+
onValuesChanged: onChange,
|
|
3328
|
+
readonly,
|
|
3329
|
+
fieldMap: nestedFieldMap,
|
|
3330
|
+
visible,
|
|
3331
|
+
sort,
|
|
3332
|
+
pathPrefix: path
|
|
3333
|
+
});
|
|
2678
3334
|
case "boolean":
|
|
2679
|
-
return /* @__PURE__ */
|
|
3335
|
+
return /* @__PURE__ */ React25.createElement(SettingsItem, {
|
|
2680
3336
|
title,
|
|
2681
3337
|
description
|
|
2682
|
-
}, /* @__PURE__ */
|
|
3338
|
+
}, /* @__PURE__ */ React25.createElement(Input17.Switch, {
|
|
2683
3339
|
disabled: readonly,
|
|
2684
3340
|
checked: !!value3,
|
|
2685
3341
|
onCheckedChange: (checked) => onChange(!!checked)
|
|
2686
3342
|
}));
|
|
2687
3343
|
case "select": {
|
|
2688
3344
|
const options = getSelectOptionsFromAst(type) ?? [];
|
|
2689
|
-
return /* @__PURE__ */
|
|
3345
|
+
return /* @__PURE__ */ React25.createElement(SettingsItem, {
|
|
2690
3346
|
title,
|
|
2691
3347
|
description
|
|
2692
|
-
}, /* @__PURE__ */
|
|
3348
|
+
}, /* @__PURE__ */ React25.createElement(Select2.Root, {
|
|
2693
3349
|
disabled: readonly,
|
|
2694
3350
|
value: value3 == null ? "" : globalThis.String(value3),
|
|
2695
3351
|
onValueChange: (selected) => {
|
|
2696
3352
|
const matched = options.find((option) => globalThis.String(option.value) === selected);
|
|
2697
3353
|
onChange(matched?.value ?? selected);
|
|
2698
3354
|
}
|
|
2699
|
-
}, /* @__PURE__ */
|
|
3355
|
+
}, /* @__PURE__ */ React25.createElement(Select2.TriggerButton, {
|
|
2700
3356
|
disabled: readonly
|
|
2701
|
-
}), /* @__PURE__ */
|
|
3357
|
+
}), /* @__PURE__ */ React25.createElement(Select2.Portal, null, /* @__PURE__ */ React25.createElement(Select2.Content, null, /* @__PURE__ */ React25.createElement(Select2.Viewport, null, options.map((option) => /* @__PURE__ */ React25.createElement(Select2.Option, {
|
|
2702
3358
|
key: globalThis.String(option.value),
|
|
2703
3359
|
value: globalThis.String(option.value)
|
|
2704
|
-
}, option.label ?? globalThis.String(option.value)))), /* @__PURE__ */
|
|
3360
|
+
}, option.label ?? globalThis.String(option.value)))), /* @__PURE__ */ React25.createElement(Select2.Arrow, null)))));
|
|
2705
3361
|
}
|
|
2706
3362
|
case "string":
|
|
2707
|
-
return /* @__PURE__ */
|
|
3363
|
+
return /* @__PURE__ */ React25.createElement(SettingsItem, {
|
|
2708
3364
|
title,
|
|
2709
3365
|
description
|
|
2710
|
-
}, /* @__PURE__ */
|
|
3366
|
+
}, /* @__PURE__ */ React25.createElement(Input17.TextInput, {
|
|
2711
3367
|
disabled: readonly,
|
|
2712
3368
|
value: value3 ?? "",
|
|
2713
3369
|
onChange: (event) => onChange(event.target.value)
|
|
2714
3370
|
}));
|
|
2715
3371
|
case "number":
|
|
2716
|
-
return /* @__PURE__ */
|
|
3372
|
+
return /* @__PURE__ */ React25.createElement(SettingsItem, {
|
|
2717
3373
|
title,
|
|
2718
3374
|
description
|
|
2719
|
-
}, /* @__PURE__ */
|
|
3375
|
+
}, /* @__PURE__ */ React25.createElement(Input17.TextInput, {
|
|
2720
3376
|
disabled: readonly,
|
|
2721
3377
|
type: "number",
|
|
2722
3378
|
value: value3 ?? "",
|
|
@@ -2739,33 +3395,32 @@ var SETTINGS_ROOT_NAME = "Settings.Root";
|
|
|
2739
3395
|
var SETTINGS_VIEWPORT_NAME = "Settings.Viewport";
|
|
2740
3396
|
var SETTINGS_SECTION_NAME = "Settings.Section";
|
|
2741
3397
|
var SettingsRoot = ({ children, classNames }) => {
|
|
2742
|
-
return /* @__PURE__ */
|
|
2743
|
-
className:
|
|
3398
|
+
return /* @__PURE__ */ React26.createElement("div", {
|
|
3399
|
+
className: mx7("flex flex-col gap-2", classNames)
|
|
2744
3400
|
}, children);
|
|
2745
3401
|
};
|
|
2746
3402
|
SettingsRoot.displayName = SETTINGS_ROOT_NAME;
|
|
2747
|
-
var SettingsViewport =
|
|
2748
|
-
return /* @__PURE__ */
|
|
2749
|
-
...
|
|
3403
|
+
var SettingsViewport = composable4(({ children, ...props }, forwardedRef) => {
|
|
3404
|
+
return /* @__PURE__ */ React26.createElement(ScrollArea2.Root, {
|
|
3405
|
+
...composableProps4(props),
|
|
2750
3406
|
orientation: "vertical",
|
|
2751
3407
|
centered: true,
|
|
2752
3408
|
thin: true,
|
|
2753
3409
|
ref: forwardedRef
|
|
2754
|
-
}, /* @__PURE__ */
|
|
3410
|
+
}, /* @__PURE__ */ React26.createElement(ScrollArea2.Viewport, {
|
|
2755
3411
|
classNames: "px-4 pointer-coarse:px-2"
|
|
2756
|
-
}, /* @__PURE__ */
|
|
2757
|
-
role: "none",
|
|
3412
|
+
}, /* @__PURE__ */ React26.createElement("div", {
|
|
2758
3413
|
className: "dx-document flex flex-col gap-2 py-4"
|
|
2759
3414
|
}, children)));
|
|
2760
3415
|
});
|
|
2761
3416
|
SettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;
|
|
2762
3417
|
var SettingsSection = ({ title, description, children }) => {
|
|
2763
|
-
const { t } =
|
|
2764
|
-
return /* @__PURE__ */
|
|
3418
|
+
const { t } = useTranslation12(translationKey14);
|
|
3419
|
+
return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement("h2", {
|
|
2765
3420
|
className: "px-trim-md mt-trim-md text-xl"
|
|
2766
|
-
}, toLocalizedString2(title, t)), description && /* @__PURE__ */
|
|
3421
|
+
}, toLocalizedString2(title, t)), description && /* @__PURE__ */ React26.createElement("p", {
|
|
2767
3422
|
className: "px-trim-md text-description"
|
|
2768
|
-
}, toLocalizedString2(description, t)), /* @__PURE__ */
|
|
3423
|
+
}, toLocalizedString2(description, t)), /* @__PURE__ */ React26.createElement("div", {
|
|
2769
3424
|
className: "w-full pt-trim-md space-y-trim-md"
|
|
2770
3425
|
}, children));
|
|
2771
3426
|
};
|
|
@@ -2779,31 +3434,53 @@ var Settings = {
|
|
|
2779
3434
|
FieldSet: SettingsFieldSet
|
|
2780
3435
|
};
|
|
2781
3436
|
|
|
3437
|
+
// src/components/Settings/SettingsSelectField.tsx
|
|
3438
|
+
import React27 from "react";
|
|
3439
|
+
import { Select as Select3 } from "@dxos/react-ui";
|
|
3440
|
+
var createSelectField = ({ options, defaultLabel = "Default" }) => {
|
|
3441
|
+
const normalized = options.map((option) => typeof option === "string" ? {
|
|
3442
|
+
value: option,
|
|
3443
|
+
label: option
|
|
3444
|
+
} : option);
|
|
3445
|
+
const hasDefault = defaultLabel !== null;
|
|
3446
|
+
const sentinel = hasDefault ? `__default__${Math.random().toString(36).slice(2)}` : "";
|
|
3447
|
+
return ({ value: value3, onChange, readonly }) => /* @__PURE__ */ React27.createElement(Select3.Root, {
|
|
3448
|
+
disabled: readonly,
|
|
3449
|
+
value: value3 ?? sentinel,
|
|
3450
|
+
onValueChange: (next) => onChange(hasDefault && next === sentinel ? void 0 : next)
|
|
3451
|
+
}, /* @__PURE__ */ React27.createElement(Select3.TriggerButton, {
|
|
3452
|
+
disabled: readonly
|
|
3453
|
+
}), /* @__PURE__ */ React27.createElement(Select3.Portal, null, /* @__PURE__ */ React27.createElement(Select3.Content, null, /* @__PURE__ */ React27.createElement(Select3.Viewport, null, hasDefault && /* @__PURE__ */ React27.createElement(Select3.Option, {
|
|
3454
|
+
value: sentinel
|
|
3455
|
+
}, defaultLabel), normalized.map((option) => /* @__PURE__ */ React27.createElement(Select3.Option, {
|
|
3456
|
+
key: option.value,
|
|
3457
|
+
value: option.value
|
|
3458
|
+
}, option.label ?? option.value))), /* @__PURE__ */ React27.createElement(Select3.Arrow, null))));
|
|
3459
|
+
};
|
|
3460
|
+
|
|
2782
3461
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
2783
3462
|
import { RegistryContext } from "@effect-atom/atom-react";
|
|
2784
|
-
import * as Array4 from "effect/Array";
|
|
2785
3463
|
import * as Match2 from "effect/Match";
|
|
2786
|
-
import * as
|
|
3464
|
+
import * as Option8 from "effect/Option";
|
|
2787
3465
|
import * as Schema5 from "effect/Schema";
|
|
2788
|
-
import
|
|
2789
|
-
import { Entity as Entity2, Feed, Filter as
|
|
2790
|
-
import { View } from "@dxos/echo";
|
|
2791
|
-
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
3466
|
+
import React28, { forwardRef as forwardRef2, useCallback as useCallback20, useContext as useContext2, useImperativeHandle, useMemo as useMemo14, useState as useState7 } from "react";
|
|
3467
|
+
import { Entity as Entity2, Feed, Filter as Filter3, Format as Format7, Obj as Obj7, Query, QueryAST, Ref as Ref8, Type as Type7, View } from "@dxos/echo";
|
|
2792
3468
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2793
3469
|
import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
2794
|
-
import { IconButton as IconButton4, Input as
|
|
3470
|
+
import { IconButton as IconButton4, Input as Input18, Message, useTranslation as useTranslation13 } from "@dxos/react-ui";
|
|
2795
3471
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2796
3472
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2797
3473
|
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2798
|
-
import { mx as
|
|
3474
|
+
import { mx as mx8, osTranslations as osTranslations2 } from "@dxos/ui-theme";
|
|
3475
|
+
import { translationKey as translationKey15 } from "#translations";
|
|
2799
3476
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2800
|
-
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames,
|
|
2801
|
-
const atomRegistry =
|
|
2802
|
-
const schemaReadonly =
|
|
2803
|
-
const { t } =
|
|
2804
|
-
const projectionModel =
|
|
2805
|
-
const jsonSchema =
|
|
2806
|
-
const change = createEchoChangeCallback(view,
|
|
3477
|
+
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, type, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
3478
|
+
const atomRegistry = useContext2(RegistryContext);
|
|
3479
|
+
const schemaReadonly = Type7.getDatabase(type) == null;
|
|
3480
|
+
const { t } = useTranslation13(translationKey15);
|
|
3481
|
+
const projectionModel = useMemo14(() => {
|
|
3482
|
+
const jsonSchema = type.jsonSchema;
|
|
3483
|
+
const change = createEchoChangeCallback(view, Type7.getDatabase(type) != null ? type : void 0);
|
|
2807
3484
|
const model = new ProjectionModel({
|
|
2808
3485
|
registry: atomRegistry,
|
|
2809
3486
|
view,
|
|
@@ -2813,7 +3490,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2813
3490
|
return model;
|
|
2814
3491
|
}, [
|
|
2815
3492
|
atomRegistry,
|
|
2816
|
-
|
|
3493
|
+
type,
|
|
2817
3494
|
view
|
|
2818
3495
|
]);
|
|
2819
3496
|
useImperativeHandle(forwardedRef, () => projectionModel, [
|
|
@@ -2825,22 +3502,23 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2825
3502
|
if (from._tag !== "scope") {
|
|
2826
3503
|
return void 0;
|
|
2827
3504
|
}
|
|
2828
|
-
|
|
3505
|
+
const feedScope = from.scopes.find((s) => s._tag === "feed");
|
|
3506
|
+
return Option8.fromNullable(feedScope).pipe(Option8.map((s) => s.feedUri), Option8.getOrUndefined);
|
|
2829
3507
|
}), Match2.orElse(() => void 0));
|
|
2830
|
-
const feeds = useQuery2(db,
|
|
2831
|
-
const targetRef =
|
|
3508
|
+
const feeds = useQuery2(db, Filter3.type(Feed.Feed));
|
|
3509
|
+
const targetRef = useMemo14(() => {
|
|
2832
3510
|
if (!queueTarget) {
|
|
2833
3511
|
return void 0;
|
|
2834
3512
|
}
|
|
2835
|
-
const feed = feeds.find((feed2) => Feed.
|
|
2836
|
-
return feed ?
|
|
3513
|
+
const feed = feeds.find((feed2) => Feed.getQueueUri(feed2)?.toString() === queueTarget);
|
|
3514
|
+
return feed ? Ref8.fromURI(Entity2.getURI(feed)) : void 0;
|
|
2837
3515
|
}, [
|
|
2838
3516
|
queueTarget,
|
|
2839
3517
|
feeds
|
|
2840
3518
|
]);
|
|
2841
|
-
const viewSchema =
|
|
3519
|
+
const viewSchema = useMemo14(() => {
|
|
2842
3520
|
const base = Schema5.Struct({
|
|
2843
|
-
query: mode === "schema" ?
|
|
3521
|
+
query: mode === "schema" ? Format7.URL.annotations({
|
|
2844
3522
|
title: "Record type"
|
|
2845
3523
|
}) : QueryAST.Query.annotations({
|
|
2846
3524
|
title: "Query"
|
|
@@ -2850,7 +3528,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2850
3528
|
return Schema5.Struct({
|
|
2851
3529
|
...base.fields,
|
|
2852
3530
|
// TODO(wittjosiah): Replace Type.Feed with Dataset.Dataset when Ref.Ref supports unions.
|
|
2853
|
-
target:
|
|
3531
|
+
target: Ref8.Ref(Feed.Feed).pipe(Schema5.annotations({
|
|
2854
3532
|
title: "Target Feed"
|
|
2855
3533
|
}), ParentLabelAnnotation.set(true), Schema5.optional)
|
|
2856
3534
|
}).pipe(Schema5.mutable);
|
|
@@ -2859,7 +3537,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2859
3537
|
}, [
|
|
2860
3538
|
mode
|
|
2861
3539
|
]);
|
|
2862
|
-
const viewValues =
|
|
3540
|
+
const viewValues = useMemo14(() => ({
|
|
2863
3541
|
query: mode === "schema" ? getTypenameFromQuery(view.query.ast) : view.query.ast,
|
|
2864
3542
|
target: targetRef
|
|
2865
3543
|
}), [
|
|
@@ -2867,7 +3545,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2867
3545
|
view.query.ast,
|
|
2868
3546
|
targetRef
|
|
2869
3547
|
]);
|
|
2870
|
-
const fieldMap =
|
|
3548
|
+
const fieldMap = useMemo14(() => mode === "tag" ? customFields({
|
|
2871
3549
|
types,
|
|
2872
3550
|
tags
|
|
2873
3551
|
}) : void 0, [
|
|
@@ -2875,55 +3553,46 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2875
3553
|
types,
|
|
2876
3554
|
tags
|
|
2877
3555
|
]);
|
|
2878
|
-
const handleUpdate =
|
|
3556
|
+
const handleUpdate = useCallback20((values) => {
|
|
2879
3557
|
const targetValue = values.target;
|
|
2880
3558
|
let queueDxn;
|
|
2881
|
-
if (
|
|
2882
|
-
const
|
|
2883
|
-
const feed = feeds.find((feed2) =>
|
|
3559
|
+
if (Ref8.isRef(targetValue)) {
|
|
3560
|
+
const feedUri = targetValue.uri;
|
|
3561
|
+
const feed = feeds.find((feed2) => Obj7.getURI(feed2) === feedUri);
|
|
2884
3562
|
if (feed) {
|
|
2885
|
-
queueDxn = Feed.
|
|
3563
|
+
queueDxn = Feed.getQueueUri(feed);
|
|
2886
3564
|
}
|
|
2887
3565
|
}
|
|
2888
|
-
const query = mode === "schema" ? Query.select(
|
|
3566
|
+
const query = mode === "schema" ? Query.select(Filter3.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
|
|
2889
3567
|
onQueryChanged?.(query, queueDxn);
|
|
2890
3568
|
}, [
|
|
2891
3569
|
onQueryChanged,
|
|
2892
3570
|
mode,
|
|
2893
3571
|
feeds
|
|
2894
3572
|
]);
|
|
2895
|
-
const handleDelete =
|
|
2896
|
-
invariant3(!readonly, void 0, {
|
|
2897
|
-
F: __dxlog_file5,
|
|
2898
|
-
L: 185,
|
|
2899
|
-
S: void 0,
|
|
2900
|
-
A: [
|
|
2901
|
-
"!readonly",
|
|
2902
|
-
""
|
|
2903
|
-
]
|
|
2904
|
-
});
|
|
3573
|
+
const handleDelete = useCallback20((fieldId) => {
|
|
3574
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 124, S: void 0, A: ["!readonly", ""] });
|
|
2905
3575
|
onDelete?.(fieldId);
|
|
2906
3576
|
}, [
|
|
2907
3577
|
onDelete,
|
|
2908
3578
|
readonly
|
|
2909
3579
|
]);
|
|
2910
|
-
return /* @__PURE__ */
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
}, schemaReadonly && !readonly && /* @__PURE__ */ React23.createElement(Message.Root, {
|
|
3580
|
+
return /* @__PURE__ */ React28.createElement("div", {
|
|
3581
|
+
className: mx8(classNames)
|
|
3582
|
+
}, schemaReadonly && !readonly && /* @__PURE__ */ React28.createElement(Message.Root, {
|
|
2914
3583
|
valence: "info",
|
|
2915
3584
|
classNames: "my-form-padding"
|
|
2916
|
-
}, /* @__PURE__ */
|
|
3585
|
+
}, /* @__PURE__ */ React28.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React28.createElement(Form.Root, {
|
|
2917
3586
|
schema: viewSchema,
|
|
2918
3587
|
values: viewValues,
|
|
2919
3588
|
fieldMap,
|
|
2920
3589
|
db,
|
|
2921
3590
|
onValuesChanged: handleUpdate
|
|
2922
|
-
}, /* @__PURE__ */
|
|
3591
|
+
}, /* @__PURE__ */ React28.createElement(Form.FieldSet, null), /* @__PURE__ */ React28.createElement(FormFieldLabel, {
|
|
2923
3592
|
label: t("fields.label"),
|
|
2924
3593
|
asChild: true
|
|
2925
|
-
}), /* @__PURE__ */
|
|
2926
|
-
|
|
3594
|
+
}), /* @__PURE__ */ React28.createElement(FieldList, {
|
|
3595
|
+
type,
|
|
2927
3596
|
view,
|
|
2928
3597
|
registry,
|
|
2929
3598
|
readonly,
|
|
@@ -2931,14 +3600,14 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2931
3600
|
onDelete: handleDelete
|
|
2932
3601
|
})));
|
|
2933
3602
|
});
|
|
2934
|
-
var FieldList = ({
|
|
2935
|
-
const atomRegistry =
|
|
2936
|
-
const schemaReadonly =
|
|
2937
|
-
const { t } =
|
|
3603
|
+
var FieldList = ({ type, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
3604
|
+
const atomRegistry = useContext2(RegistryContext);
|
|
3605
|
+
const schemaReadonly = Type7.getDatabase(type) == null;
|
|
3606
|
+
const { t } = useTranslation13(translationKey15);
|
|
2938
3607
|
const [viewSnapshot] = useObject(view);
|
|
2939
|
-
const projectionModel =
|
|
2940
|
-
const jsonSchema =
|
|
2941
|
-
const change = createEchoChangeCallback(view,
|
|
3608
|
+
const projectionModel = useMemo14(() => {
|
|
3609
|
+
const jsonSchema = type.jsonSchema;
|
|
3610
|
+
const change = createEchoChangeCallback(view, Type7.getDatabase(type) != null ? type : void 0);
|
|
2942
3611
|
const model = new ProjectionModel({
|
|
2943
3612
|
registry: atomRegistry,
|
|
2944
3613
|
view,
|
|
@@ -2948,41 +3617,25 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2948
3617
|
return model;
|
|
2949
3618
|
}, [
|
|
2950
3619
|
atomRegistry,
|
|
2951
|
-
|
|
3620
|
+
type,
|
|
2952
3621
|
view
|
|
2953
3622
|
]);
|
|
2954
3623
|
const [expandedField, setExpandedField] = useState7();
|
|
2955
|
-
const handleAdd =
|
|
2956
|
-
invariant3(!readonly, void 0, {
|
|
2957
|
-
F: __dxlog_file5,
|
|
2958
|
-
L: 250,
|
|
2959
|
-
S: void 0,
|
|
2960
|
-
A: [
|
|
2961
|
-
"!readonly",
|
|
2962
|
-
""
|
|
2963
|
-
]
|
|
2964
|
-
});
|
|
3624
|
+
const handleAdd = useCallback20(() => {
|
|
3625
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 178, S: void 0, A: ["!readonly", ""] });
|
|
2965
3626
|
const field = projectionModel.createFieldProjection();
|
|
2966
3627
|
setExpandedField(field.id);
|
|
2967
3628
|
}, [
|
|
2968
3629
|
projectionModel,
|
|
2969
3630
|
readonly
|
|
2970
3631
|
]);
|
|
2971
|
-
const handleToggleField =
|
|
3632
|
+
const handleToggleField = useCallback20((field) => {
|
|
2972
3633
|
setExpandedField((prevExpandedFieldId) => prevExpandedFieldId === field.id ? void 0 : field.id);
|
|
2973
3634
|
}, [
|
|
2974
3635
|
readonly
|
|
2975
3636
|
]);
|
|
2976
|
-
const handleDelete =
|
|
2977
|
-
invariant3(!readonly, void 0, {
|
|
2978
|
-
F: __dxlog_file5,
|
|
2979
|
-
L: 264,
|
|
2980
|
-
S: void 0,
|
|
2981
|
-
A: [
|
|
2982
|
-
"!readonly",
|
|
2983
|
-
""
|
|
2984
|
-
]
|
|
2985
|
-
});
|
|
3637
|
+
const handleDelete = useCallback20((fieldId) => {
|
|
3638
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 191, S: void 0, A: ["!readonly", ""] });
|
|
2986
3639
|
if (fieldId === expandedField) {
|
|
2987
3640
|
setExpandedField(void 0);
|
|
2988
3641
|
}
|
|
@@ -2992,17 +3645,9 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2992
3645
|
onDelete,
|
|
2993
3646
|
readonly
|
|
2994
3647
|
]);
|
|
2995
|
-
const handleMove =
|
|
2996
|
-
invariant3(!readonly, void 0, {
|
|
2997
|
-
|
|
2998
|
-
L: 276,
|
|
2999
|
-
S: void 0,
|
|
3000
|
-
A: [
|
|
3001
|
-
"!readonly",
|
|
3002
|
-
""
|
|
3003
|
-
]
|
|
3004
|
-
});
|
|
3005
|
-
Obj6.change(view, (view2) => {
|
|
3648
|
+
const handleMove = useCallback20((fromIndex, toIndex) => {
|
|
3649
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 202, S: void 0, A: ["!readonly", ""] });
|
|
3650
|
+
Obj7.update(view, (view2) => {
|
|
3006
3651
|
const fields = [
|
|
3007
3652
|
...view2.projection.fields
|
|
3008
3653
|
];
|
|
@@ -3014,14 +3659,14 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3014
3659
|
view,
|
|
3015
3660
|
readonly
|
|
3016
3661
|
]);
|
|
3017
|
-
const handleClose =
|
|
3018
|
-
const handleHide =
|
|
3662
|
+
const handleClose = useCallback20(() => setExpandedField(void 0), []);
|
|
3663
|
+
const handleHide = useCallback20((fieldId) => {
|
|
3019
3664
|
setExpandedField(void 0);
|
|
3020
3665
|
projectionModel.hideFieldProjection(fieldId);
|
|
3021
3666
|
}, [
|
|
3022
3667
|
projectionModel
|
|
3023
3668
|
]);
|
|
3024
|
-
const handleShow =
|
|
3669
|
+
const handleShow = useCallback20((property) => {
|
|
3025
3670
|
setExpandedField(void 0);
|
|
3026
3671
|
projectionModel.showFieldProjection(property);
|
|
3027
3672
|
}, [
|
|
@@ -3030,46 +3675,45 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3030
3675
|
if (!viewSnapshot) {
|
|
3031
3676
|
return null;
|
|
3032
3677
|
}
|
|
3033
|
-
return /* @__PURE__ */
|
|
3678
|
+
return /* @__PURE__ */ React28.createElement(List2.Root, {
|
|
3034
3679
|
items: viewSnapshot.projection.fields,
|
|
3035
3680
|
isItem: Schema5.is(View.FieldSchema),
|
|
3036
3681
|
getId: (field) => field.id,
|
|
3037
3682
|
onMove: readonly ? void 0 : handleMove,
|
|
3038
3683
|
readonly
|
|
3039
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
3684
|
+
}, ({ items: fields }) => /* @__PURE__ */ React28.createElement(React28.Fragment, null, showHeading && /* @__PURE__ */ React28.createElement("h3", {
|
|
3040
3685
|
className: "text-sm"
|
|
3041
|
-
}, t("field-path.label")), /* @__PURE__ */
|
|
3686
|
+
}, t("field-path.label")), /* @__PURE__ */ React28.createElement("div", {
|
|
3042
3687
|
role: "list",
|
|
3043
3688
|
className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
|
|
3044
3689
|
}, fields?.map((field) => {
|
|
3045
3690
|
const hidden = field.visible === false;
|
|
3046
|
-
return /* @__PURE__ */
|
|
3691
|
+
return /* @__PURE__ */ React28.createElement(List2.Item, {
|
|
3047
3692
|
key: field.id,
|
|
3048
3693
|
item: field,
|
|
3049
3694
|
classNames: "grid grid-cols-subgrid col-span-5",
|
|
3050
3695
|
"aria-expanded": expandedField === field.id
|
|
3051
|
-
}, /* @__PURE__ */
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
}, /* @__PURE__ */ React23.createElement(List2.ItemDragHandle, {
|
|
3696
|
+
}, /* @__PURE__ */ React28.createElement("div", {
|
|
3697
|
+
className: "grid grid-cols-subgrid col-span-5 rounded-xs cursor-pointer min-h-10 dx-hover"
|
|
3698
|
+
}, /* @__PURE__ */ React28.createElement(List2.ItemDragHandle, {
|
|
3055
3699
|
disabled: readonly || schemaReadonly
|
|
3056
|
-
}), /* @__PURE__ */
|
|
3700
|
+
}), /* @__PURE__ */ React28.createElement(List2.ItemTitle, {
|
|
3057
3701
|
classNames: hidden && "text-subdued",
|
|
3058
3702
|
onClick: () => handleToggleField(field)
|
|
3059
|
-
}, field.path), /* @__PURE__ */
|
|
3060
|
-
label: t(hidden ? "show
|
|
3703
|
+
}, field.path), /* @__PURE__ */ React28.createElement(List2.ItemIconButton, {
|
|
3704
|
+
label: t(hidden ? "show-field.label" : "hide-field.label"),
|
|
3061
3705
|
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
3062
3706
|
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
3063
3707
|
autoHide: false,
|
|
3064
3708
|
disabled: readonly || !hidden && projectionModel.getFields().length <= 1,
|
|
3065
3709
|
onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
|
|
3066
|
-
}), !readonly && /* @__PURE__ */
|
|
3710
|
+
}), !readonly && /* @__PURE__ */ React28.createElement(React28.Fragment, null, /* @__PURE__ */ React28.createElement(List2.ItemDeleteButton, {
|
|
3067
3711
|
label: t("delete-field.label"),
|
|
3068
3712
|
autoHide: false,
|
|
3069
3713
|
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
3070
3714
|
onClick: () => handleDelete(field.id),
|
|
3071
3715
|
"data-testid": "field.delete"
|
|
3072
|
-
}), /* @__PURE__ */
|
|
3716
|
+
}), /* @__PURE__ */ React28.createElement(List2.ItemIconButton, {
|
|
3073
3717
|
iconOnly: true,
|
|
3074
3718
|
variant: "ghost",
|
|
3075
3719
|
label: t("toggle-expand.label", {
|
|
@@ -3078,20 +3722,18 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3078
3722
|
icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
3079
3723
|
onClick: () => handleToggleField(field),
|
|
3080
3724
|
"data-testid": "field.toggle"
|
|
3081
|
-
}))), expandedField === field.id && !readonly && /* @__PURE__ */
|
|
3082
|
-
role: "none",
|
|
3725
|
+
}))), expandedField === field.id && !readonly && /* @__PURE__ */ React28.createElement("div", {
|
|
3083
3726
|
className: "col-span-full mt-1 mb-1 border border-separator rounded-md"
|
|
3084
|
-
}, /* @__PURE__ */
|
|
3727
|
+
}, /* @__PURE__ */ React28.createElement(FieldEditor, {
|
|
3085
3728
|
readonly: readonly || schemaReadonly,
|
|
3086
3729
|
registry,
|
|
3087
3730
|
projection: projectionModel,
|
|
3088
3731
|
field,
|
|
3089
3732
|
onSave: handleClose
|
|
3090
3733
|
})));
|
|
3091
|
-
})), !readonly && !expandedField && /* @__PURE__ */
|
|
3092
|
-
role: "none",
|
|
3734
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React28.createElement("div", {
|
|
3093
3735
|
className: "my-form-padding"
|
|
3094
|
-
}, /* @__PURE__ */
|
|
3736
|
+
}, /* @__PURE__ */ React28.createElement(IconButton4, {
|
|
3095
3737
|
icon: "ph--plus--regular",
|
|
3096
3738
|
label: t("add-property-button.label"),
|
|
3097
3739
|
onClick: handleAdd,
|
|
@@ -3101,13 +3743,13 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3101
3743
|
};
|
|
3102
3744
|
var customFields = ({ types, tags }) => ({
|
|
3103
3745
|
query: ({ type, readonly, label, getValue, onValueChange }) => {
|
|
3104
|
-
const handleChange =
|
|
3746
|
+
const handleChange = useCallback20((query) => onValueChange(type, query.ast), [
|
|
3105
3747
|
onValueChange
|
|
3106
3748
|
]);
|
|
3107
|
-
return /* @__PURE__ */
|
|
3749
|
+
return /* @__PURE__ */ React28.createElement(Input18.Root, null, /* @__PURE__ */ React28.createElement(FormFieldLabel, {
|
|
3108
3750
|
readonly,
|
|
3109
3751
|
label
|
|
3110
|
-
}), /* @__PURE__ */
|
|
3752
|
+
}), /* @__PURE__ */ React28.createElement(QueryForm, {
|
|
3111
3753
|
initialQuery: getValue(),
|
|
3112
3754
|
types,
|
|
3113
3755
|
tags,
|
|
@@ -3118,17 +3760,27 @@ var customFields = ({ types, tags }) => ({
|
|
|
3118
3760
|
export {
|
|
3119
3761
|
ArrayField,
|
|
3120
3762
|
BooleanField,
|
|
3763
|
+
DEFAULT_LAYOUT_NAME,
|
|
3764
|
+
DateField,
|
|
3121
3765
|
FieldEditor,
|
|
3122
3766
|
Form,
|
|
3123
3767
|
FormFieldErrorBoundary,
|
|
3124
3768
|
FormFieldLabel,
|
|
3125
3769
|
FormFieldWrapper,
|
|
3770
|
+
FormLayout,
|
|
3771
|
+
FormLayoutAnnotation,
|
|
3772
|
+
FormLayoutAnnotationId,
|
|
3773
|
+
FormTooltipsContext,
|
|
3126
3774
|
GeoPointField,
|
|
3775
|
+
InlineRefField,
|
|
3776
|
+
LayoutParseError,
|
|
3777
|
+
META_TAGS_KEY,
|
|
3127
3778
|
MarkdownField,
|
|
3128
3779
|
NumberField,
|
|
3129
3780
|
ObjectForm,
|
|
3130
3781
|
ObjectPicker,
|
|
3131
3782
|
ObjectProperties,
|
|
3783
|
+
ObjectTree,
|
|
3132
3784
|
RefField,
|
|
3133
3785
|
SelectField,
|
|
3134
3786
|
SelectOptionField,
|
|
@@ -3138,6 +3790,7 @@ export {
|
|
|
3138
3790
|
TupleField,
|
|
3139
3791
|
ViewEditor,
|
|
3140
3792
|
cellClassesForFieldType,
|
|
3793
|
+
createSelectField,
|
|
3141
3794
|
detectFieldType,
|
|
3142
3795
|
formatForDisplay,
|
|
3143
3796
|
formatForEditing,
|
|
@@ -3147,13 +3800,15 @@ export {
|
|
|
3147
3800
|
getSelectOptionsFromAst,
|
|
3148
3801
|
omitHiddenFormFields,
|
|
3149
3802
|
omitId,
|
|
3803
|
+
parseLayout,
|
|
3150
3804
|
parseValue,
|
|
3151
3805
|
pathNotUniqueError,
|
|
3152
|
-
translations,
|
|
3153
3806
|
useFormContext,
|
|
3154
3807
|
useFormFieldState,
|
|
3155
3808
|
useFormHandler,
|
|
3809
|
+
useFormTooltips,
|
|
3156
3810
|
useFormValues,
|
|
3157
|
-
useKeyHandler
|
|
3811
|
+
useKeyHandler,
|
|
3812
|
+
withMetaTags
|
|
3158
3813
|
};
|
|
3159
3814
|
//# sourceMappingURL=index.mjs.map
|