@dxos/react-ui-form 0.8.4-main.422d1c7879 → 0.8.4-main.51f1e5ca51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +122 -224
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +82 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +122 -224
- 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 +84 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts +63 -63
- package/dist/types/src/components/FieldEditor/FieldEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +19 -3
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +72 -72
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormField.d.ts +4 -4
- package/dist/types/src/components/Form/FormField.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormFieldComponent.d.ts +5 -6
- 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 +4 -7
- package/dist/types/src/components/Form/FormFieldSet.d.ts.map +1 -1
- 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/GeoPointField.d.ts.map +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 +63 -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.map +1 -1
- package/dist/types/src/components/Form/fields/SelectField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.d.ts.map +1 -1
- package/dist/types/src/components/Form/fields/SelectOptionField.stories.d.ts +63 -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.map +1 -1
- package/dist/types/src/components/ObjectForm/ObjectForm.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.d.ts.map +1 -1
- package/dist/types/src/components/ObjectPicker/ObjectPicker.stories.d.ts +63 -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 +63 -63
- package/dist/types/src/components/ObjectProperties/ObjectProperties.stories.d.ts.map +1 -1
- 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 +63 -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 +2 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +63 -63
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useFormHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useKeyHandler.d.ts.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 +63 -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.map +1 -1
- package/dist/types/src/util/refs.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +39 -30
- package/src/components/FieldEditor/FieldEditor.stories.tsx +2 -1
- package/src/components/FieldEditor/FieldEditor.tsx +3 -2
- package/src/components/Form/Form.stories.tsx +2 -1
- package/src/components/Form/Form.tsx +2 -1
- package/src/components/Form/FormField.tsx +2 -1
- package/src/components/Form/fields/ArrayField.tsx +2 -1
- package/src/components/Form/fields/GeoPointField.tsx +2 -1
- package/src/components/Form/fields/MarkdownField.stories.tsx +2 -1
- package/src/components/Form/fields/MarkdownField.tsx +2 -1
- package/src/components/Form/fields/RefField.tsx +2 -1
- package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -1
- package/src/components/Form/fields/SelectOptionField.tsx +2 -1
- package/src/components/ObjectForm/ObjectForm.tsx +6 -5
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +5 -2
- package/src/components/ObjectPicker/ObjectPicker.tsx +2 -1
- package/src/components/ObjectProperties/ObjectProperties.stories.tsx +2 -1
- package/src/components/ObjectProperties/ObjectProperties.tsx +5 -4
- package/src/components/Settings/AUDIT.md +52 -0
- package/src/components/Settings/Settings.stories.tsx +2 -1
- package/src/components/Settings/Settings.tsx +2 -1
- package/src/components/Settings/SettingsFieldSet.tsx +55 -9
- package/src/components/Settings/SettingsItem.tsx +1 -1
- package/src/components/Settings/SettingsSelectField.tsx +59 -0
- package/src/components/Settings/index.ts +1 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +5 -4
- package/src/components/ViewEditor/ViewEditor.tsx +3 -2
- package/src/index.ts +0 -4
- package/src/util/field-type.ts +4 -1
|
@@ -1,81 +1,3 @@
|
|
|
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
2
|
import React17, { useCallback as useCallback14, useEffect as useEffect5, useMemo as useMemo8, useState as useState6 } from "react";
|
|
81
3
|
import { Obj as Obj3 } from "@dxos/echo";
|
|
@@ -83,6 +5,7 @@ import { Format as Format4, FormatEnums, formatToType } from "@dxos/echo/interna
|
|
|
83
5
|
import { log as log2 } from "@dxos/log";
|
|
84
6
|
import { useAsyncEffect, useTranslation as useTranslation9 } from "@dxos/react-ui";
|
|
85
7
|
import { formatToAdditionalPropertyAttributes, getFormatSchema } from "@dxos/schema";
|
|
8
|
+
import { translationKey as translationKey9 } 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";
|
|
@@ -423,6 +349,7 @@ import * as SchemaAST4 from "effect/SchemaAST";
|
|
|
423
349
|
import React5, { useCallback as useCallback3 } from "react";
|
|
424
350
|
import { findNode as findNode2, getArrayElementType as getArrayElementType2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2, isNestedType as isNestedType2 } from "@dxos/effect";
|
|
425
351
|
import { IconButton as IconButton2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
352
|
+
import { translationKey as translationKey3 } from "#translations";
|
|
426
353
|
|
|
427
354
|
// src/components/Form/Form.tsx
|
|
428
355
|
import { createContext } from "@radix-ui/react-context";
|
|
@@ -434,6 +361,7 @@ import { Annotation as EchoAnnotation } from "@dxos/echo";
|
|
|
434
361
|
import { createJsonPath as createJsonPath3, getValue as getValue$2 } from "@dxos/effect";
|
|
435
362
|
import { IconButton, ScrollArea, useMergeRefs, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
436
363
|
import { composable, composableProps, mx, withColumn } from "@dxos/ui-theme";
|
|
364
|
+
import { translationKey as translationKey2 } from "#translations";
|
|
437
365
|
|
|
438
366
|
// src/hooks/useFormHandler.ts
|
|
439
367
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
@@ -471,12 +399,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
471
399
|
log("validate", {
|
|
472
400
|
values: values2,
|
|
473
401
|
errors: errors2
|
|
474
|
-
}, {
|
|
475
|
-
F: __dxlog_file,
|
|
476
|
-
L: 155,
|
|
477
|
-
S: void 0,
|
|
478
|
-
C: (f, a) => f(...a)
|
|
479
|
-
});
|
|
402
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 42, S: void 0 });
|
|
480
403
|
if (errors2.length === 0 && onValidate) {
|
|
481
404
|
const validatedValues = values2;
|
|
482
405
|
errors2 = onValidate(validatedValues) ?? [];
|
|
@@ -564,12 +487,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
564
487
|
log("onValueChange", {
|
|
565
488
|
path,
|
|
566
489
|
value: value3
|
|
567
|
-
}, {
|
|
568
|
-
F: __dxlog_file,
|
|
569
|
-
L: 254,
|
|
570
|
-
S: void 0,
|
|
571
|
-
C: (f, a) => f(...a)
|
|
572
|
-
});
|
|
490
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 138, S: void 0 });
|
|
573
491
|
const jsonPath = createJsonPath(path);
|
|
574
492
|
const pathArray = path;
|
|
575
493
|
let parsedValue = value3;
|
|
@@ -578,12 +496,7 @@ var useFormHandler = ({ schema, autoSave, values: valuesProp, defaultValues: def
|
|
|
578
496
|
parsedValue = parseFloat(value3) || 0;
|
|
579
497
|
}
|
|
580
498
|
} 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
|
-
});
|
|
499
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 150, S: void 0 });
|
|
587
500
|
parsedValue = void 0;
|
|
588
501
|
}
|
|
589
502
|
const newValues = mergeAtPath(values, pathArray, parsedValue);
|
|
@@ -809,6 +722,7 @@ import React2, { useMemo as useMemo2 } from "react";
|
|
|
809
722
|
import { Format as Format3 } from "@dxos/echo";
|
|
810
723
|
import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion as isLiteralUnion2, isNestedType } from "@dxos/effect";
|
|
811
724
|
import { useTranslation } from "@dxos/react-ui";
|
|
725
|
+
import { translationKey } from "#translations";
|
|
812
726
|
var FormField = (props) => {
|
|
813
727
|
const {
|
|
814
728
|
type,
|
|
@@ -1141,7 +1055,7 @@ var FormFieldSet2 = (props) => {
|
|
|
1141
1055
|
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1142
1056
|
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1143
1057
|
var FormActions = ({ classNames }) => {
|
|
1144
|
-
const { t } = useTranslation2(
|
|
1058
|
+
const { t } = useTranslation2(translationKey2);
|
|
1145
1059
|
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1146
1060
|
if (readonly || layout === "static") {
|
|
1147
1061
|
return null;
|
|
@@ -1183,7 +1097,7 @@ var FormSection = composable(({ children, label, description, ...props }, forwar
|
|
|
1183
1097
|
FormSection.displayName = FORM_SECTION_NAME;
|
|
1184
1098
|
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1185
1099
|
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1186
|
-
const { t } = useTranslation2(
|
|
1100
|
+
const { t } = useTranslation2(translationKey2);
|
|
1187
1101
|
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1188
1102
|
if (readonly || layout === "static") {
|
|
1189
1103
|
return null;
|
|
@@ -1216,7 +1130,7 @@ var Form = {
|
|
|
1216
1130
|
|
|
1217
1131
|
// src/components/Form/fields/ArrayField.tsx
|
|
1218
1132
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1219
|
-
const { t } = useTranslation3(
|
|
1133
|
+
const { t } = useTranslation3(translationKey3);
|
|
1220
1134
|
const elementType = getArrayElementType2(type);
|
|
1221
1135
|
const { onValueChange } = inputProps;
|
|
1222
1136
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
@@ -1346,8 +1260,9 @@ import React7, { useCallback as useCallback5, useEffect as useEffect3, useMemo a
|
|
|
1346
1260
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1347
1261
|
import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1348
1262
|
import { safeParseFloat } from "@dxos/util";
|
|
1263
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1349
1264
|
var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1350
|
-
const { t } = useTranslation4(
|
|
1265
|
+
const { t } = useTranslation4(translationKey4);
|
|
1351
1266
|
const { status, error } = getStatus();
|
|
1352
1267
|
const geoPoint = useMemo5(() => getValue() ?? [
|
|
1353
1268
|
0,
|
|
@@ -1447,6 +1362,7 @@ import { Button, Icon as Icon2, Input as Input4, useTranslation as useTranslatio
|
|
|
1447
1362
|
import { Editor, useBasicMarkdownExtensions } from "@dxos/react-ui-editor";
|
|
1448
1363
|
import { Text } from "@dxos/schema";
|
|
1449
1364
|
import { createDataExtensions } from "@dxos/ui-editor";
|
|
1365
|
+
import { translationKey as translationKey5 } from "#translations";
|
|
1450
1366
|
var editorClassNames = "transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2";
|
|
1451
1367
|
var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
|
|
1452
1368
|
const { status, error } = getStatus();
|
|
@@ -1552,7 +1468,7 @@ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange })
|
|
|
1552
1468
|
}));
|
|
1553
1469
|
};
|
|
1554
1470
|
var CreateTextButton = ({ db, disabled, onCreate }) => {
|
|
1555
|
-
const { t } = useTranslation5(
|
|
1471
|
+
const { t } = useTranslation5(translationKey5);
|
|
1556
1472
|
const handleClick = useCallback6(() => {
|
|
1557
1473
|
if (!db) {
|
|
1558
1474
|
return;
|
|
@@ -1607,13 +1523,15 @@ import { DXN } from "@dxos/keys";
|
|
|
1607
1523
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1608
1524
|
import { Button as Button2, Icon as Icon3, Input as Input6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1609
1525
|
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
1526
|
+
import { translationKey as translationKey7 } from "#translations";
|
|
1610
1527
|
|
|
1611
1528
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1612
1529
|
import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
|
|
1613
1530
|
import { Popover, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1614
1531
|
import { Combobox, useSearchListInput, useSearchListResults } from "@dxos/react-ui-search";
|
|
1532
|
+
import { translationKey as translationKey6 } from "#translations";
|
|
1615
1533
|
var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, onSelect, onCreate, ...props }, forwardedRef) => {
|
|
1616
|
-
const { t } = useTranslation6(
|
|
1534
|
+
const { t } = useTranslation6(translationKey6);
|
|
1617
1535
|
const [showForm, setShowForm] = useState3(false);
|
|
1618
1536
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1619
1537
|
const { results, handleSearch } = useSearchListResults({
|
|
@@ -1684,7 +1602,7 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
|
|
|
1684
1602
|
})), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1685
1603
|
});
|
|
1686
1604
|
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1687
|
-
const { t } = useTranslation6(
|
|
1605
|
+
const { t } = useTranslation6(translationKey6);
|
|
1688
1606
|
const { query } = useSearchListInput();
|
|
1689
1607
|
const label = createOptionLabel ? t(createOptionLabel[0], {
|
|
1690
1608
|
ns: createOptionLabel[1].ns,
|
|
@@ -1726,7 +1644,7 @@ var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result)
|
|
|
1726
1644
|
var defaultUseResults = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj2.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1727
1645
|
var RefField = (props) => {
|
|
1728
1646
|
const { type, readonly, label, placeholder, layout, getStatus, getValue, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, db, useSchema = defaultUseSchema, useResults = defaultUseResults, getOptions = defaultGetOptions, onCreate, onValueChange } = props;
|
|
1729
|
-
const { t } = useTranslation7(
|
|
1647
|
+
const { t } = useTranslation7(translationKey7);
|
|
1730
1648
|
const { status, error } = getStatus();
|
|
1731
1649
|
const typename = useMemo7(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
|
|
1732
1650
|
type
|
|
@@ -1903,8 +1821,9 @@ import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useT
|
|
|
1903
1821
|
import { List } from "@dxos/react-ui-list";
|
|
1904
1822
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1905
1823
|
import { hues, osTranslations, subtleHover } from "@dxos/ui-theme";
|
|
1824
|
+
import { translationKey as translationKey8 } from "#translations";
|
|
1906
1825
|
var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
|
|
1907
|
-
const { t } = useTranslation8(
|
|
1826
|
+
const { t } = useTranslation8(translationKey8);
|
|
1908
1827
|
const { status, error } = getStatus();
|
|
1909
1828
|
const [selected, setSelectedId] = useState5(null);
|
|
1910
1829
|
const [isNewOption, setIsNewOption] = useState5(false);
|
|
@@ -2169,7 +2088,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2169
2088
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2170
2089
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2171
2090
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2172
|
-
const { t } = useTranslation9(
|
|
2091
|
+
const { t } = useTranslation9(translationKey9);
|
|
2173
2092
|
const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
|
|
2174
2093
|
useEffect5(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2175
2094
|
field,
|
|
@@ -2278,7 +2197,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2278
2197
|
]);
|
|
2279
2198
|
const handleSave = useCallback14((props2) => {
|
|
2280
2199
|
if (view) {
|
|
2281
|
-
Obj3.
|
|
2200
|
+
Obj3.update(view, () => {
|
|
2282
2201
|
projection.setFieldProjection({
|
|
2283
2202
|
field,
|
|
2284
2203
|
props: props2
|
|
@@ -2306,12 +2225,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2306
2225
|
if (!fieldSchema) {
|
|
2307
2226
|
log2.warn("invalid format", {
|
|
2308
2227
|
props
|
|
2309
|
-
}, {
|
|
2310
|
-
F: __dxlog_file2,
|
|
2311
|
-
L: 172,
|
|
2312
|
-
S: void 0,
|
|
2313
|
-
C: (f, a) => f(...a)
|
|
2314
|
-
});
|
|
2228
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 156, S: void 0 });
|
|
2315
2229
|
return null;
|
|
2316
2230
|
}
|
|
2317
2231
|
return /* @__PURE__ */ React17.createElement(Form.Root, {
|
|
@@ -2341,6 +2255,7 @@ import { splitJsonPath } from "@dxos/echo/internal";
|
|
|
2341
2255
|
import { invariant } from "@dxos/invariant";
|
|
2342
2256
|
import { HuePicker as HuePicker2 } from "@dxos/react-ui-pickers";
|
|
2343
2257
|
import { isNonNullable } from "@dxos/util";
|
|
2258
|
+
import { translationKey as translationKey10 } from "#translations";
|
|
2344
2259
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectForm/ObjectForm.tsx";
|
|
2345
2260
|
var createFieldMap = {
|
|
2346
2261
|
hue: ({ type, label, layout, getValue, onValueChange }) => {
|
|
@@ -2378,27 +2293,11 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2378
2293
|
schema
|
|
2379
2294
|
]);
|
|
2380
2295
|
const handleCreate = useCallback15((schema2, values2) => {
|
|
2381
|
-
invariant(db, void 0, {
|
|
2382
|
-
|
|
2383
|
-
L: 51,
|
|
2384
|
-
S: void 0,
|
|
2385
|
-
A: [
|
|
2386
|
-
"db",
|
|
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
|
-
});
|
|
2296
|
+
invariant(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 49, S: void 0, A: ["db", ""] });
|
|
2297
|
+
invariant(Type2.isObjectSchema(schema2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 50, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
|
|
2399
2298
|
const newObject = db.add(Obj4.make(schema2, values2));
|
|
2400
2299
|
if (Obj4.instanceOf(Tag2.Tag, newObject)) {
|
|
2401
|
-
Obj4.
|
|
2300
|
+
Obj4.update(object, (object2) => {
|
|
2402
2301
|
Obj4.getMeta(object2).tags = [
|
|
2403
2302
|
...Obj4.getMeta(object2).tags ?? [],
|
|
2404
2303
|
Obj4.getDXN(newObject).toString()
|
|
@@ -2413,13 +2312,13 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2413
2312
|
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2414
2313
|
const hasTagsChange = changedPaths.some((path) => splitJsonPath(path)[0] === "tags");
|
|
2415
2314
|
if (hasTagsChange) {
|
|
2416
|
-
Obj4.
|
|
2315
|
+
Obj4.update(object, (object2) => {
|
|
2417
2316
|
Obj4.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
|
|
2418
2317
|
});
|
|
2419
2318
|
}
|
|
2420
2319
|
const nonTagPaths = changedPaths.filter((path) => splitJsonPath(path)[0] !== "tags");
|
|
2421
2320
|
if (nonTagPaths.length > 0) {
|
|
2422
|
-
Obj4.
|
|
2321
|
+
Obj4.update(object, () => {
|
|
2423
2322
|
for (const path of nonTagPaths) {
|
|
2424
2323
|
const parts = splitJsonPath(path);
|
|
2425
2324
|
const value3 = Obj4.getValue(values2, parts);
|
|
@@ -2438,7 +2337,7 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2438
2337
|
createOptionLabel: [
|
|
2439
2338
|
"add-tag.label",
|
|
2440
2339
|
{
|
|
2441
|
-
ns:
|
|
2340
|
+
ns: translationKey10
|
|
2442
2341
|
}
|
|
2443
2342
|
],
|
|
2444
2343
|
createInitialValuePath: "label",
|
|
@@ -2461,6 +2360,7 @@ import { HuePicker as HuePicker3 } from "@dxos/react-ui-pickers";
|
|
|
2461
2360
|
import { FactoryAnnotation } from "@dxos/schema";
|
|
2462
2361
|
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
2463
2362
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2363
|
+
import { translationKey as translationKey11 } from "#translations";
|
|
2464
2364
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectProperties/ObjectProperties.tsx";
|
|
2465
2365
|
var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef) => {
|
|
2466
2366
|
const db = Obj5.getDatabase(object);
|
|
@@ -2479,24 +2379,8 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2479
2379
|
object
|
|
2480
2380
|
]);
|
|
2481
2381
|
const handleCreate = useCallback16((schema, values2) => {
|
|
2482
|
-
invariant2(db, void 0, {
|
|
2483
|
-
|
|
2484
|
-
L: 52,
|
|
2485
|
-
S: void 0,
|
|
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
|
-
});
|
|
2382
|
+
invariant2(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 45, S: void 0, A: ["db", ""] });
|
|
2383
|
+
invariant2(Type3.isObjectSchema(schema), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 46, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
|
|
2500
2384
|
const factory = Option5.getOrUndefined(FactoryAnnotation.get(schema));
|
|
2501
2385
|
const newObject = factory ? factory(values2) : Obj5.make(schema, values2);
|
|
2502
2386
|
return db.add(newObject);
|
|
@@ -2510,13 +2394,13 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2510
2394
|
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2511
2395
|
const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === "tags");
|
|
2512
2396
|
if (hasTagsChange) {
|
|
2513
|
-
Obj5.
|
|
2397
|
+
Obj5.update(object, (object2) => {
|
|
2514
2398
|
Obj5.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
|
|
2515
2399
|
});
|
|
2516
2400
|
}
|
|
2517
2401
|
const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== "tags");
|
|
2518
2402
|
if (nonTagPaths.length > 0) {
|
|
2519
|
-
Obj5.
|
|
2403
|
+
Obj5.update(object, () => {
|
|
2520
2404
|
for (const path of nonTagPaths) {
|
|
2521
2405
|
const parts = splitJsonPath2(path);
|
|
2522
2406
|
const value3 = Obj5.getValue(values2, parts);
|
|
@@ -2538,7 +2422,7 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2538
2422
|
createOptionLabel: [
|
|
2539
2423
|
"add-tag.label",
|
|
2540
2424
|
{
|
|
2541
|
-
ns:
|
|
2425
|
+
ns: translationKey11
|
|
2542
2426
|
}
|
|
2543
2427
|
],
|
|
2544
2428
|
createInitialValuePath: "label",
|
|
@@ -2578,6 +2462,7 @@ var BaseSchema = Schema4.Struct({
|
|
|
2578
2462
|
import React22 from "react";
|
|
2579
2463
|
import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as useTranslation11 } from "@dxos/react-ui";
|
|
2580
2464
|
import { composable as composable3, composableProps as composableProps3, mx as mx4 } from "@dxos/ui-theme";
|
|
2465
|
+
import { translationKey as translationKey13 } from "#translations";
|
|
2581
2466
|
|
|
2582
2467
|
// src/components/Settings/SettingsFieldSet.tsx
|
|
2583
2468
|
import * as SchemaAST5 from "effect/SchemaAST";
|
|
@@ -2590,6 +2475,7 @@ import { Input as Input13, Select as Select2 } from "@dxos/react-ui";
|
|
|
2590
2475
|
import React20 from "react";
|
|
2591
2476
|
import { Input as Input12, toLocalizedString, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2592
2477
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2478
|
+
import { translationKey as translationKey12 } from "#translations";
|
|
2593
2479
|
var SETTINGS_PANEL_NAME = "Settings.Panel";
|
|
2594
2480
|
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2595
2481
|
var SettingsPanel = ({ classNames, children }) => {
|
|
@@ -2600,7 +2486,7 @@ var SettingsPanel = ({ classNames, children }) => {
|
|
|
2600
2486
|
};
|
|
2601
2487
|
SettingsPanel.displayName = SETTINGS_PANEL_NAME;
|
|
2602
2488
|
var SettingsItem = ({ title, description = "", children }) => {
|
|
2603
|
-
const { t } = useTranslation10(
|
|
2489
|
+
const { t } = useTranslation10(translationKey12);
|
|
2604
2490
|
return /* @__PURE__ */ React20.createElement(Input12.Root, null, /* @__PURE__ */ React20.createElement(SettingsPanel, {
|
|
2605
2491
|
classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
|
|
2606
2492
|
}, /* @__PURE__ */ React20.createElement(Input12.Label, {
|
|
@@ -2615,7 +2501,7 @@ var SettingsItem = ({ title, description = "", children }) => {
|
|
|
2615
2501
|
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2616
2502
|
|
|
2617
2503
|
// src/components/Settings/SettingsFieldSet.tsx
|
|
2618
|
-
var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort }) => {
|
|
2504
|
+
var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort, pathPrefix = "" }) => {
|
|
2619
2505
|
const properties = useMemo11(() => {
|
|
2620
2506
|
const props = getFormProperties(schema.ast);
|
|
2621
2507
|
if (!sort) {
|
|
@@ -2643,21 +2529,27 @@ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, v
|
|
|
2643
2529
|
]);
|
|
2644
2530
|
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, properties.map((property) => {
|
|
2645
2531
|
const name = property.name.toString();
|
|
2646
|
-
|
|
2532
|
+
const path = pathPrefix ? `${pathPrefix}.${name}` : name;
|
|
2533
|
+
if (visible && !visible(path, values)) {
|
|
2647
2534
|
return null;
|
|
2648
2535
|
}
|
|
2536
|
+
const entry = fieldMap?.[name];
|
|
2649
2537
|
return /* @__PURE__ */ React21.createElement(SettingsFieldItem, {
|
|
2650
2538
|
key: name,
|
|
2539
|
+
path,
|
|
2651
2540
|
property,
|
|
2652
2541
|
value: values[name],
|
|
2653
2542
|
onChange: (value3) => handleChange(name, value3),
|
|
2654
2543
|
readonly,
|
|
2655
|
-
customField:
|
|
2544
|
+
customField: typeof entry === "function" ? entry : void 0,
|
|
2545
|
+
nestedFieldMap: typeof entry === "object" ? entry : void 0,
|
|
2546
|
+
visible,
|
|
2547
|
+
sort
|
|
2656
2548
|
});
|
|
2657
2549
|
}));
|
|
2658
2550
|
};
|
|
2659
2551
|
SettingsFieldSet.displayName = "Settings.FieldSet";
|
|
2660
|
-
var SettingsFieldItem = ({ property, value: value3, onChange, readonly, customField }) => {
|
|
2552
|
+
var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, customField, nestedFieldMap, visible, sort }) => {
|
|
2661
2553
|
const { type } = property;
|
|
2662
2554
|
const name = property.name.toString();
|
|
2663
2555
|
const title = getAnnotation3(SchemaAST5.TitleAnnotationId)(type) ?? String3.capitalize(name);
|
|
@@ -2675,6 +2567,19 @@ var SettingsFieldItem = ({ property, value: value3, onChange, readonly, customFi
|
|
|
2675
2567
|
}
|
|
2676
2568
|
const fieldType = detectFieldType(type);
|
|
2677
2569
|
switch (fieldType) {
|
|
2570
|
+
case "struct":
|
|
2571
|
+
return /* @__PURE__ */ React21.createElement(SettingsFieldSet, {
|
|
2572
|
+
schema: {
|
|
2573
|
+
ast: type
|
|
2574
|
+
},
|
|
2575
|
+
values: value3 ?? {},
|
|
2576
|
+
onValuesChanged: onChange,
|
|
2577
|
+
readonly,
|
|
2578
|
+
fieldMap: nestedFieldMap,
|
|
2579
|
+
visible,
|
|
2580
|
+
sort,
|
|
2581
|
+
pathPrefix: path
|
|
2582
|
+
});
|
|
2678
2583
|
case "boolean":
|
|
2679
2584
|
return /* @__PURE__ */ React21.createElement(SettingsItem, {
|
|
2680
2585
|
title,
|
|
@@ -2760,7 +2665,7 @@ var SettingsViewport = composable3(({ children, ...props }, forwardedRef) => {
|
|
|
2760
2665
|
});
|
|
2761
2666
|
SettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;
|
|
2762
2667
|
var SettingsSection = ({ title, description, children }) => {
|
|
2763
|
-
const { t } = useTranslation11(
|
|
2668
|
+
const { t } = useTranslation11(translationKey13);
|
|
2764
2669
|
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement("h2", {
|
|
2765
2670
|
className: "px-trim-md mt-trim-md text-xl"
|
|
2766
2671
|
}, toLocalizedString2(title, t)), description && /* @__PURE__ */ React22.createElement("p", {
|
|
@@ -2779,13 +2684,37 @@ var Settings = {
|
|
|
2779
2684
|
FieldSet: SettingsFieldSet
|
|
2780
2685
|
};
|
|
2781
2686
|
|
|
2687
|
+
// src/components/Settings/SettingsSelectField.tsx
|
|
2688
|
+
import React23 from "react";
|
|
2689
|
+
import { Select as Select3 } from "@dxos/react-ui";
|
|
2690
|
+
var createSelectField = ({ options, defaultLabel = "Default" }) => {
|
|
2691
|
+
const normalized = options.map((option) => typeof option === "string" ? {
|
|
2692
|
+
value: option,
|
|
2693
|
+
label: option
|
|
2694
|
+
} : option);
|
|
2695
|
+
const hasDefault = defaultLabel !== null;
|
|
2696
|
+
const sentinel = hasDefault ? `__default__${Math.random().toString(36).slice(2)}` : "";
|
|
2697
|
+
return ({ value: value3, onChange, readonly }) => /* @__PURE__ */ React23.createElement(Select3.Root, {
|
|
2698
|
+
disabled: readonly,
|
|
2699
|
+
value: value3 ?? sentinel,
|
|
2700
|
+
onValueChange: (next) => onChange(hasDefault && next === sentinel ? void 0 : next)
|
|
2701
|
+
}, /* @__PURE__ */ React23.createElement(Select3.TriggerButton, {
|
|
2702
|
+
disabled: readonly
|
|
2703
|
+
}), /* @__PURE__ */ React23.createElement(Select3.Portal, null, /* @__PURE__ */ React23.createElement(Select3.Content, null, /* @__PURE__ */ React23.createElement(Select3.Viewport, null, hasDefault && /* @__PURE__ */ React23.createElement(Select3.Option, {
|
|
2704
|
+
value: sentinel
|
|
2705
|
+
}, defaultLabel), normalized.map((option) => /* @__PURE__ */ React23.createElement(Select3.Option, {
|
|
2706
|
+
key: option.value,
|
|
2707
|
+
value: option.value
|
|
2708
|
+
}, option.label ?? option.value))), /* @__PURE__ */ React23.createElement(Select3.Arrow, null))));
|
|
2709
|
+
};
|
|
2710
|
+
|
|
2782
2711
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
2783
2712
|
import { RegistryContext } from "@effect-atom/atom-react";
|
|
2784
2713
|
import * as Array4 from "effect/Array";
|
|
2785
2714
|
import * as Match2 from "effect/Match";
|
|
2786
2715
|
import * as Option6 from "effect/Option";
|
|
2787
2716
|
import * as Schema5 from "effect/Schema";
|
|
2788
|
-
import
|
|
2717
|
+
import React24, { forwardRef as forwardRef2, useCallback as useCallback18, useContext, useImperativeHandle, useMemo as useMemo12, useState as useState7 } from "react";
|
|
2789
2718
|
import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj6, Query, QueryAST, Ref as Ref6 } from "@dxos/echo";
|
|
2790
2719
|
import { View } from "@dxos/echo";
|
|
2791
2720
|
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
@@ -2796,11 +2725,12 @@ import { QueryForm } from "@dxos/react-ui-components";
|
|
|
2796
2725
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2797
2726
|
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2798
2727
|
import { mx as mx5, osTranslations as osTranslations2, subtleHover as subtleHover2 } from "@dxos/ui-theme";
|
|
2728
|
+
import { translationKey as translationKey14 } from "#translations";
|
|
2799
2729
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2800
2730
|
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2801
2731
|
const atomRegistry = useContext(RegistryContext);
|
|
2802
2732
|
const schemaReadonly = !isMutable(schema);
|
|
2803
|
-
const { t } = useTranslation12(
|
|
2733
|
+
const { t } = useTranslation12(translationKey14);
|
|
2804
2734
|
const projectionModel = useMemo12(() => {
|
|
2805
2735
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2806
2736
|
const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
|
|
@@ -2893,36 +2823,28 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2893
2823
|
feeds
|
|
2894
2824
|
]);
|
|
2895
2825
|
const handleDelete = useCallback18((fieldId) => {
|
|
2896
|
-
invariant3(!readonly, void 0, {
|
|
2897
|
-
F: __dxlog_file5,
|
|
2898
|
-
L: 185,
|
|
2899
|
-
S: void 0,
|
|
2900
|
-
A: [
|
|
2901
|
-
"!readonly",
|
|
2902
|
-
""
|
|
2903
|
-
]
|
|
2904
|
-
});
|
|
2826
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 127, S: void 0, A: ["!readonly", ""] });
|
|
2905
2827
|
onDelete?.(fieldId);
|
|
2906
2828
|
}, [
|
|
2907
2829
|
onDelete,
|
|
2908
2830
|
readonly
|
|
2909
2831
|
]);
|
|
2910
|
-
return /* @__PURE__ */
|
|
2832
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
2911
2833
|
role: "none",
|
|
2912
2834
|
className: mx5(classNames)
|
|
2913
|
-
}, schemaReadonly && !readonly && /* @__PURE__ */
|
|
2835
|
+
}, schemaReadonly && !readonly && /* @__PURE__ */ React24.createElement(Message.Root, {
|
|
2914
2836
|
valence: "info",
|
|
2915
2837
|
classNames: "my-form-padding"
|
|
2916
|
-
}, /* @__PURE__ */
|
|
2838
|
+
}, /* @__PURE__ */ React24.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React24.createElement(Form.Root, {
|
|
2917
2839
|
schema: viewSchema,
|
|
2918
2840
|
values: viewValues,
|
|
2919
2841
|
fieldMap,
|
|
2920
2842
|
db,
|
|
2921
2843
|
onValuesChanged: handleUpdate
|
|
2922
|
-
}, /* @__PURE__ */
|
|
2844
|
+
}, /* @__PURE__ */ React24.createElement(Form.FieldSet, null), /* @__PURE__ */ React24.createElement(FormFieldLabel, {
|
|
2923
2845
|
label: t("fields.label"),
|
|
2924
2846
|
asChild: true
|
|
2925
|
-
}), /* @__PURE__ */
|
|
2847
|
+
}), /* @__PURE__ */ React24.createElement(FieldList, {
|
|
2926
2848
|
schema,
|
|
2927
2849
|
view,
|
|
2928
2850
|
registry,
|
|
@@ -2934,7 +2856,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2934
2856
|
var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
2935
2857
|
const atomRegistry = useContext(RegistryContext);
|
|
2936
2858
|
const schemaReadonly = !isMutable(schema);
|
|
2937
|
-
const { t } = useTranslation12(
|
|
2859
|
+
const { t } = useTranslation12(translationKey14);
|
|
2938
2860
|
const [viewSnapshot] = useObject(view);
|
|
2939
2861
|
const projectionModel = useMemo12(() => {
|
|
2940
2862
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
@@ -2953,15 +2875,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2953
2875
|
]);
|
|
2954
2876
|
const [expandedField, setExpandedField] = useState7();
|
|
2955
2877
|
const handleAdd = useCallback18(() => {
|
|
2956
|
-
invariant3(!readonly, void 0, {
|
|
2957
|
-
F: __dxlog_file5,
|
|
2958
|
-
L: 250,
|
|
2959
|
-
S: void 0,
|
|
2960
|
-
A: [
|
|
2961
|
-
"!readonly",
|
|
2962
|
-
""
|
|
2963
|
-
]
|
|
2964
|
-
});
|
|
2878
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 183, S: void 0, A: ["!readonly", ""] });
|
|
2965
2879
|
const field = projectionModel.createFieldProjection();
|
|
2966
2880
|
setExpandedField(field.id);
|
|
2967
2881
|
}, [
|
|
@@ -2974,15 +2888,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2974
2888
|
readonly
|
|
2975
2889
|
]);
|
|
2976
2890
|
const handleDelete = useCallback18((fieldId) => {
|
|
2977
|
-
invariant3(!readonly, void 0, {
|
|
2978
|
-
F: __dxlog_file5,
|
|
2979
|
-
L: 264,
|
|
2980
|
-
S: void 0,
|
|
2981
|
-
A: [
|
|
2982
|
-
"!readonly",
|
|
2983
|
-
""
|
|
2984
|
-
]
|
|
2985
|
-
});
|
|
2891
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 196, S: void 0, A: ["!readonly", ""] });
|
|
2986
2892
|
if (fieldId === expandedField) {
|
|
2987
2893
|
setExpandedField(void 0);
|
|
2988
2894
|
}
|
|
@@ -2993,16 +2899,8 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2993
2899
|
readonly
|
|
2994
2900
|
]);
|
|
2995
2901
|
const handleMove = useCallback18((fromIndex, toIndex) => {
|
|
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) => {
|
|
2902
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 207, S: void 0, A: ["!readonly", ""] });
|
|
2903
|
+
Obj6.update(view, (view2) => {
|
|
3006
2904
|
const fields = [
|
|
3007
2905
|
...view2.projection.fields
|
|
3008
2906
|
];
|
|
@@ -3030,46 +2928,46 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3030
2928
|
if (!viewSnapshot) {
|
|
3031
2929
|
return null;
|
|
3032
2930
|
}
|
|
3033
|
-
return /* @__PURE__ */
|
|
2931
|
+
return /* @__PURE__ */ React24.createElement(List2.Root, {
|
|
3034
2932
|
items: viewSnapshot.projection.fields,
|
|
3035
2933
|
isItem: Schema5.is(View.FieldSchema),
|
|
3036
2934
|
getId: (field) => field.id,
|
|
3037
2935
|
onMove: readonly ? void 0 : handleMove,
|
|
3038
2936
|
readonly
|
|
3039
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
2937
|
+
}, ({ items: fields }) => /* @__PURE__ */ React24.createElement(React24.Fragment, null, showHeading && /* @__PURE__ */ React24.createElement("h3", {
|
|
3040
2938
|
className: "text-sm"
|
|
3041
|
-
}, t("field-path.label")), /* @__PURE__ */
|
|
2939
|
+
}, t("field-path.label")), /* @__PURE__ */ React24.createElement("div", {
|
|
3042
2940
|
role: "list",
|
|
3043
2941
|
className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
|
|
3044
2942
|
}, fields?.map((field) => {
|
|
3045
2943
|
const hidden = field.visible === false;
|
|
3046
|
-
return /* @__PURE__ */
|
|
2944
|
+
return /* @__PURE__ */ React24.createElement(List2.Item, {
|
|
3047
2945
|
key: field.id,
|
|
3048
2946
|
item: field,
|
|
3049
2947
|
classNames: "grid grid-cols-subgrid col-span-5",
|
|
3050
2948
|
"aria-expanded": expandedField === field.id
|
|
3051
|
-
}, /* @__PURE__ */
|
|
2949
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
3052
2950
|
role: "none",
|
|
3053
2951
|
className: mx5(subtleHover2, "grid grid-cols-subgrid col-span-5", "rounded-xs cursor-pointer min-h-10")
|
|
3054
|
-
}, /* @__PURE__ */
|
|
2952
|
+
}, /* @__PURE__ */ React24.createElement(List2.ItemDragHandle, {
|
|
3055
2953
|
disabled: readonly || schemaReadonly
|
|
3056
|
-
}), /* @__PURE__ */
|
|
2954
|
+
}), /* @__PURE__ */ React24.createElement(List2.ItemTitle, {
|
|
3057
2955
|
classNames: hidden && "text-subdued",
|
|
3058
2956
|
onClick: () => handleToggleField(field)
|
|
3059
|
-
}, field.path), /* @__PURE__ */
|
|
2957
|
+
}, field.path), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
|
|
3060
2958
|
label: t(hidden ? "show field label" : "hide field label"),
|
|
3061
2959
|
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
3062
2960
|
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
3063
2961
|
autoHide: false,
|
|
3064
2962
|
disabled: readonly || !hidden && projectionModel.getFields().length <= 1,
|
|
3065
2963
|
onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
|
|
3066
|
-
}), !readonly && /* @__PURE__ */
|
|
2964
|
+
}), !readonly && /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(List2.ItemDeleteButton, {
|
|
3067
2965
|
label: t("delete-field.label"),
|
|
3068
2966
|
autoHide: false,
|
|
3069
2967
|
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
3070
2968
|
onClick: () => handleDelete(field.id),
|
|
3071
2969
|
"data-testid": "field.delete"
|
|
3072
|
-
}), /* @__PURE__ */
|
|
2970
|
+
}), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
|
|
3073
2971
|
iconOnly: true,
|
|
3074
2972
|
variant: "ghost",
|
|
3075
2973
|
label: t("toggle-expand.label", {
|
|
@@ -3078,20 +2976,20 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3078
2976
|
icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
3079
2977
|
onClick: () => handleToggleField(field),
|
|
3080
2978
|
"data-testid": "field.toggle"
|
|
3081
|
-
}))), expandedField === field.id && !readonly && /* @__PURE__ */
|
|
2979
|
+
}))), expandedField === field.id && !readonly && /* @__PURE__ */ React24.createElement("div", {
|
|
3082
2980
|
role: "none",
|
|
3083
2981
|
className: "col-span-full mt-1 mb-1 border border-separator rounded-md"
|
|
3084
|
-
}, /* @__PURE__ */
|
|
2982
|
+
}, /* @__PURE__ */ React24.createElement(FieldEditor, {
|
|
3085
2983
|
readonly: readonly || schemaReadonly,
|
|
3086
2984
|
registry,
|
|
3087
2985
|
projection: projectionModel,
|
|
3088
2986
|
field,
|
|
3089
2987
|
onSave: handleClose
|
|
3090
2988
|
})));
|
|
3091
|
-
})), !readonly && !expandedField && /* @__PURE__ */
|
|
2989
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React24.createElement("div", {
|
|
3092
2990
|
role: "none",
|
|
3093
2991
|
className: "my-form-padding"
|
|
3094
|
-
}, /* @__PURE__ */
|
|
2992
|
+
}, /* @__PURE__ */ React24.createElement(IconButton4, {
|
|
3095
2993
|
icon: "ph--plus--regular",
|
|
3096
2994
|
label: t("add-property-button.label"),
|
|
3097
2995
|
onClick: handleAdd,
|
|
@@ -3104,10 +3002,10 @@ var customFields = ({ types, tags }) => ({
|
|
|
3104
3002
|
const handleChange = useCallback18((query) => onValueChange(type, query.ast), [
|
|
3105
3003
|
onValueChange
|
|
3106
3004
|
]);
|
|
3107
|
-
return /* @__PURE__ */
|
|
3005
|
+
return /* @__PURE__ */ React24.createElement(Input14.Root, null, /* @__PURE__ */ React24.createElement(FormFieldLabel, {
|
|
3108
3006
|
readonly,
|
|
3109
3007
|
label
|
|
3110
|
-
}), /* @__PURE__ */
|
|
3008
|
+
}), /* @__PURE__ */ React24.createElement(QueryForm, {
|
|
3111
3009
|
initialQuery: getValue(),
|
|
3112
3010
|
types,
|
|
3113
3011
|
tags,
|
|
@@ -3138,6 +3036,7 @@ export {
|
|
|
3138
3036
|
TupleField,
|
|
3139
3037
|
ViewEditor,
|
|
3140
3038
|
cellClassesForFieldType,
|
|
3039
|
+
createSelectField,
|
|
3141
3040
|
detectFieldType,
|
|
3142
3041
|
formatForDisplay,
|
|
3143
3042
|
formatForEditing,
|
|
@@ -3149,7 +3048,6 @@ export {
|
|
|
3149
3048
|
omitId,
|
|
3150
3049
|
parseValue,
|
|
3151
3050
|
pathNotUniqueError,
|
|
3152
|
-
translations,
|
|
3153
3051
|
useFormContext,
|
|
3154
3052
|
useFormFieldState,
|
|
3155
3053
|
useFormHandler,
|