@dxos/react-ui-form 0.8.4-main.422d1c7879 → 0.8.4-main.4f23b4e393
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 +148 -273
- 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 +148 -273
- 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 +64 -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 +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 +3 -4
- 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 +3 -3
- package/src/components/Form/FormField.tsx +2 -1
- package/src/components/Form/FormFieldComponent.tsx +3 -3
- package/src/components/Form/fields/ArrayField.tsx +6 -9
- package/src/components/Form/fields/GeoPointField.tsx +3 -2
- package/src/components/Form/fields/MarkdownField.stories.tsx +56 -1
- package/src/components/Form/fields/MarkdownField.tsx +2 -1
- package/src/components/Form/fields/RefField.tsx +4 -3
- package/src/components/Form/fields/SelectOptionField.stories.tsx +2 -1
- package/src/components/Form/fields/SelectOptionField.tsx +6 -5
- package/src/components/ObjectForm/ObjectForm.tsx +6 -5
- package/src/components/ObjectPicker/ObjectPicker.stories.tsx +8 -5
- package/src/components/ObjectPicker/ObjectPicker.tsx +18 -9
- 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 +3 -4
- 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 +7 -7
- package/src/components/ViewEditor/ViewEditor.tsx +17 -24
- package/src/components/testing.tsx +1 -1
- 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);
|
|
@@ -729,7 +642,6 @@ import { inputTextLabel } from "@dxos/ui-theme";
|
|
|
729
642
|
var FormFieldLabel = ({ label, error, readonly, asChild }) => {
|
|
730
643
|
const Label = readonly || asChild ? "span" : Input.Label;
|
|
731
644
|
return /* @__PURE__ */ React.createElement("div", {
|
|
732
|
-
role: "none",
|
|
733
645
|
className: "flex items-center justify-between"
|
|
734
646
|
}, /* @__PURE__ */ React.createElement(Label, {
|
|
735
647
|
className: inputTextLabel
|
|
@@ -753,7 +665,6 @@ var FormFieldWrapper = (props) => {
|
|
|
753
665
|
}
|
|
754
666
|
const str = String(value3 ?? "");
|
|
755
667
|
return /* @__PURE__ */ React.createElement("div", {
|
|
756
|
-
role: "none",
|
|
757
668
|
className: "contents"
|
|
758
669
|
}, /* @__PURE__ */ React.createElement(Input.Root, {
|
|
759
670
|
validationValence: status
|
|
@@ -784,7 +695,7 @@ var FormFieldErrorBoundary = class extends Component {
|
|
|
784
695
|
return /* @__PURE__ */ React.createElement("div", {
|
|
785
696
|
className: "flex gap-2 border border-rose-fill font-mono text-sm"
|
|
786
697
|
}, /* @__PURE__ */ React.createElement("span", {
|
|
787
|
-
className: "bg-rose-fill text-
|
|
698
|
+
className: "bg-rose-fill text-base-foreground px-1 font-thin"
|
|
788
699
|
}, "ERROR"), String(this.props.path?.join(".")));
|
|
789
700
|
}
|
|
790
701
|
return this.props.children;
|
|
@@ -809,6 +720,7 @@ import React2, { useMemo as useMemo2 } from "react";
|
|
|
809
720
|
import { Format as Format3 } from "@dxos/echo";
|
|
810
721
|
import { createJsonPath as createJsonPath2, findNode, getAnnotation as getAnnotation2, getDiscriminatedType, isArrayType as isArrayType2, isDiscriminatedUnion, isLiteralUnion as isLiteralUnion2, isNestedType } from "@dxos/effect";
|
|
811
722
|
import { useTranslation } from "@dxos/react-ui";
|
|
723
|
+
import { translationKey } from "#translations";
|
|
812
724
|
var FormField = (props) => {
|
|
813
725
|
const {
|
|
814
726
|
type,
|
|
@@ -1141,13 +1053,12 @@ var FormFieldSet2 = (props) => {
|
|
|
1141
1053
|
FormFieldSet2.displayName = FORM_FIELDSET_NAME2;
|
|
1142
1054
|
var FORM_ACTIONS_NAME = "Form.Actions";
|
|
1143
1055
|
var FormActions = ({ classNames }) => {
|
|
1144
|
-
const { t } = useTranslation2(
|
|
1056
|
+
const { t } = useTranslation2(translationKey2);
|
|
1145
1057
|
const { form: { canSave, onSave, onCancel }, readonly, layout } = useFormContext(FORM_ACTIONS_NAME);
|
|
1146
1058
|
if (readonly || layout === "static") {
|
|
1147
1059
|
return null;
|
|
1148
1060
|
}
|
|
1149
1061
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
1150
|
-
role: "none",
|
|
1151
1062
|
className: mx(withColumn.center(), "grid grid-flow-col gap-form-gap auto-cols-fr py-form-padding", classNames)
|
|
1152
1063
|
}, onCancel && /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1153
1064
|
icon: "ph--x--regular",
|
|
@@ -1183,13 +1094,12 @@ var FormSection = composable(({ children, label, description, ...props }, forwar
|
|
|
1183
1094
|
FormSection.displayName = FORM_SECTION_NAME;
|
|
1184
1095
|
var FORM_SUBMIT_NAME = "Form.Submit";
|
|
1185
1096
|
var FormSubmit = ({ classNames, label, icon, disabled }) => {
|
|
1186
|
-
const { t } = useTranslation2(
|
|
1097
|
+
const { t } = useTranslation2(translationKey2);
|
|
1187
1098
|
const { form: { canSave, onSave }, readonly, layout } = useFormContext(FORM_SUBMIT_NAME);
|
|
1188
1099
|
if (readonly || layout === "static") {
|
|
1189
1100
|
return null;
|
|
1190
1101
|
}
|
|
1191
1102
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
1192
|
-
role: "none",
|
|
1193
1103
|
className: mx("flex w-full pt-form-padding", classNames)
|
|
1194
1104
|
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
1195
1105
|
classNames: "w-full",
|
|
@@ -1216,7 +1126,7 @@ var Form = {
|
|
|
1216
1126
|
|
|
1217
1127
|
// src/components/Form/fields/ArrayField.tsx
|
|
1218
1128
|
var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps, ...props }) => {
|
|
1219
|
-
const { t } = useTranslation3(
|
|
1129
|
+
const { t } = useTranslation3(translationKey3);
|
|
1220
1130
|
const elementType = getArrayElementType2(type);
|
|
1221
1131
|
const { onValueChange } = inputProps;
|
|
1222
1132
|
const values = useFormValues(ArrayField.displayName, path, () => []);
|
|
@@ -1261,11 +1171,9 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1261
1171
|
label,
|
|
1262
1172
|
asChild: true
|
|
1263
1173
|
}), /* @__PURE__ */ React5.createElement("div", {
|
|
1264
|
-
role: "none",
|
|
1265
1174
|
className: "flex flex-col gap-form-gap"
|
|
1266
1175
|
}, values?.map((_, index) => {
|
|
1267
1176
|
return /* @__PURE__ */ React5.createElement("div", {
|
|
1268
|
-
role: "none",
|
|
1269
1177
|
key: index,
|
|
1270
1178
|
className: "grid grid-cols-[1fr_min-content] gap-form-gap last:mb-form-gap items-center"
|
|
1271
1179
|
}, /* @__PURE__ */ React5.createElement(FormField, {
|
|
@@ -1279,10 +1187,8 @@ var ArrayField = ({ type, path, label, readonly, layout, fieldProps: inputProps,
|
|
|
1279
1187
|
layout: "inline",
|
|
1280
1188
|
...props
|
|
1281
1189
|
}), !readonly && layout !== "static" && /* @__PURE__ */ React5.createElement("div", {
|
|
1282
|
-
role: "none",
|
|
1283
1190
|
className: "flex flex-col h-full justify-end"
|
|
1284
1191
|
}, /* @__PURE__ */ React5.createElement("div", {
|
|
1285
|
-
role: "none",
|
|
1286
1192
|
className: "flex items-center h-[2rem]"
|
|
1287
1193
|
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
1288
1194
|
icon: "ph--x--regular",
|
|
@@ -1346,8 +1252,9 @@ import React7, { useCallback as useCallback5, useEffect as useEffect3, useMemo a
|
|
|
1346
1252
|
import { GeoLocation as GeoLocation3 } from "@dxos/echo/internal";
|
|
1347
1253
|
import { Input as Input3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
1348
1254
|
import { safeParseFloat } from "@dxos/util";
|
|
1255
|
+
import { translationKey as translationKey4 } from "#translations";
|
|
1349
1256
|
var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onValueChange, onBlur }) => {
|
|
1350
|
-
const { t } = useTranslation4(
|
|
1257
|
+
const { t } = useTranslation4(translationKey4);
|
|
1351
1258
|
const { status, error } = getStatus();
|
|
1352
1259
|
const geoPoint = useMemo5(() => getValue() ?? [
|
|
1353
1260
|
0,
|
|
@@ -1401,7 +1308,6 @@ var GeoPointField = ({ type, label, readonly, layout, getStatus, getValue, onVal
|
|
|
1401
1308
|
label,
|
|
1402
1309
|
asChild: true
|
|
1403
1310
|
}), layout === "static" ? /* @__PURE__ */ React7.createElement(LatLng, value3) : /* @__PURE__ */ React7.createElement("div", {
|
|
1404
|
-
role: "none",
|
|
1405
1311
|
className: "grid grid-cols-2 gap-form-gap"
|
|
1406
1312
|
}, /* @__PURE__ */ React7.createElement("div", null, /* @__PURE__ */ React7.createElement(Input3.Root, null, layout !== "inline" && /* @__PURE__ */ React7.createElement(Input3.Label, null, t("latitude.label")), /* @__PURE__ */ React7.createElement(Input3.TextInput, {
|
|
1407
1313
|
type: "number",
|
|
@@ -1447,6 +1353,7 @@ import { Button, Icon as Icon2, Input as Input4, useTranslation as useTranslatio
|
|
|
1447
1353
|
import { Editor, useBasicMarkdownExtensions } from "@dxos/react-ui-editor";
|
|
1448
1354
|
import { Text } from "@dxos/schema";
|
|
1449
1355
|
import { createDataExtensions } from "@dxos/ui-editor";
|
|
1356
|
+
import { translationKey as translationKey5 } from "#translations";
|
|
1450
1357
|
var editorClassNames = "transition-colors bg-input-surface focus-within:bg-focus-surface border border-separator rounded-xs p-1 px-2";
|
|
1451
1358
|
var MarkdownField = ({ type, readonly, label, placeholder, layout, db, getStatus, getValue, onValueChange }) => {
|
|
1452
1359
|
const { status, error } = getStatus();
|
|
@@ -1552,7 +1459,7 @@ var StringMarkdownEditor = ({ value: value3, placeholder, readonly, onChange })
|
|
|
1552
1459
|
}));
|
|
1553
1460
|
};
|
|
1554
1461
|
var CreateTextButton = ({ db, disabled, onCreate }) => {
|
|
1555
|
-
const { t } = useTranslation5(
|
|
1462
|
+
const { t } = useTranslation5(translationKey5);
|
|
1556
1463
|
const handleClick = useCallback6(() => {
|
|
1557
1464
|
if (!db) {
|
|
1558
1465
|
return;
|
|
@@ -1607,16 +1514,19 @@ import { DXN } from "@dxos/keys";
|
|
|
1607
1514
|
import { DxAnchor } from "@dxos/lit-ui/react";
|
|
1608
1515
|
import { Button as Button2, Icon as Icon3, Input as Input6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1609
1516
|
import { ParentLabelAnnotationId } from "@dxos/schema";
|
|
1517
|
+
import { translationKey as translationKey7 } from "#translations";
|
|
1610
1518
|
|
|
1611
1519
|
// src/components/ObjectPicker/ObjectPicker.tsx
|
|
1612
1520
|
import React10, { forwardRef, useCallback as useCallback8, useState as useState3 } from "react";
|
|
1613
1521
|
import { Popover, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
1614
|
-
import { Combobox
|
|
1522
|
+
import { Combobox } from "@dxos/react-ui-list";
|
|
1523
|
+
import { useSearchListResults } from "@dxos/react-ui-search";
|
|
1524
|
+
import { translationKey as translationKey6 } from "#translations";
|
|
1615
1525
|
var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, createSchema, createOptionLabel, createOptionIcon, createInitialValuePath, createFieldMap: createFieldMap3, onSelect, onCreate, ...props }, forwardedRef) => {
|
|
1616
|
-
const { t } = useTranslation6(
|
|
1526
|
+
const { t } = useTranslation6(translationKey6);
|
|
1617
1527
|
const [showForm, setShowForm] = useState3(false);
|
|
1618
1528
|
const [formInitialValue, setFormInitialValue] = useState3("");
|
|
1619
|
-
const { results, handleSearch } = useSearchListResults({
|
|
1529
|
+
const { results, query, handleSearch } = useSearchListResults({
|
|
1620
1530
|
items: options
|
|
1621
1531
|
});
|
|
1622
1532
|
const handleFormSave = useCallback8(async (values) => {
|
|
@@ -1645,7 +1555,6 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
|
|
|
1645
1555
|
if (showForm && createSchema) {
|
|
1646
1556
|
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1647
1557
|
...props,
|
|
1648
|
-
onSearch: handleSearch,
|
|
1649
1558
|
onKeyDownCapture: handleKeyDown,
|
|
1650
1559
|
ref: forwardedRef
|
|
1651
1560
|
}, /* @__PURE__ */ React10.createElement(Popover.Viewport, null, /* @__PURE__ */ React10.createElement(Form.Root, {
|
|
@@ -1661,12 +1570,13 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
|
|
|
1661
1570
|
}
|
|
1662
1571
|
return /* @__PURE__ */ React10.createElement(Combobox.Content, {
|
|
1663
1572
|
...props,
|
|
1664
|
-
onSearch: handleSearch,
|
|
1665
1573
|
onKeyDownCapture: handleKeyDown,
|
|
1666
1574
|
ref: forwardedRef
|
|
1667
1575
|
}, /* @__PURE__ */ React10.createElement(Combobox.Input, {
|
|
1668
1576
|
placeholder: t("ref-field-combobox-input.placeholder"),
|
|
1669
|
-
autoFocus: true
|
|
1577
|
+
autoFocus: true,
|
|
1578
|
+
value: query,
|
|
1579
|
+
onValueChange: handleSearch
|
|
1670
1580
|
}), /* @__PURE__ */ React10.createElement(Combobox.List, null, results.map((option) => /* @__PURE__ */ React10.createElement(Combobox.Item, {
|
|
1671
1581
|
key: option.id,
|
|
1672
1582
|
value: option.id,
|
|
@@ -1675,17 +1585,17 @@ var ObjectPickerContent = /* @__PURE__ */ forwardRef(({ options, selectedIds, cr
|
|
|
1675
1585
|
onSelect: () => onSelect(option.id),
|
|
1676
1586
|
classNames: "flex items-center gap-2"
|
|
1677
1587
|
})), createSchema && onCreate && /* @__PURE__ */ React10.createElement(CreateItem, {
|
|
1588
|
+
query,
|
|
1678
1589
|
createOptionLabel,
|
|
1679
1590
|
createOptionIcon: createOptionIcon ?? "ph--plus--regular",
|
|
1680
|
-
onCreateItemSelect: (
|
|
1681
|
-
setFormInitialValue(
|
|
1591
|
+
onCreateItemSelect: (currentQuery) => {
|
|
1592
|
+
setFormInitialValue(currentQuery);
|
|
1682
1593
|
setShowForm(true);
|
|
1683
1594
|
}
|
|
1684
1595
|
})), /* @__PURE__ */ React10.createElement(Combobox.Arrow, null));
|
|
1685
1596
|
});
|
|
1686
|
-
var CreateItem = ({ createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1687
|
-
const { t } = useTranslation6(
|
|
1688
|
-
const { query } = useSearchListInput();
|
|
1597
|
+
var CreateItem = ({ query, createOptionLabel, createOptionIcon, onCreateItemSelect }) => {
|
|
1598
|
+
const { t } = useTranslation6(translationKey6);
|
|
1689
1599
|
const label = createOptionLabel ? t(createOptionLabel[0], {
|
|
1690
1600
|
ns: createOptionLabel[1].ns,
|
|
1691
1601
|
text: query
|
|
@@ -1726,7 +1636,7 @@ var defaultGetOptions = (results, { parentLabel } = {}) => results.map((result)
|
|
|
1726
1636
|
var defaultUseResults = (db, typename) => useQuery(db, typename ? typename === Type.getTypename(Obj2.Unknown) ? Filter.everything() : Filter.typename(typename) : Filter.nothing());
|
|
1727
1637
|
var RefField = (props) => {
|
|
1728
1638
|
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(
|
|
1639
|
+
const { t } = useTranslation7(translationKey7);
|
|
1730
1640
|
const { status, error } = getStatus();
|
|
1731
1641
|
const typename = useMemo7(() => type ? findAnnotation2(type, ReferenceAnnotationId2)?.typename : void 0, [
|
|
1732
1642
|
type
|
|
@@ -1826,7 +1736,6 @@ var RefField = (props) => {
|
|
|
1826
1736
|
asChild: true,
|
|
1827
1737
|
classNames: "p-0"
|
|
1828
1738
|
}, item ? /* @__PURE__ */ React11.createElement("div", {
|
|
1829
|
-
role: "none",
|
|
1830
1739
|
className: "flex gap-form-gap w-full"
|
|
1831
1740
|
}, /* @__PURE__ */ React11.createElement(Input6.Root, {
|
|
1832
1741
|
key: item.id
|
|
@@ -1837,7 +1746,6 @@ var RefField = (props) => {
|
|
|
1837
1746
|
}))) : /* @__PURE__ */ React11.createElement(Button2, {
|
|
1838
1747
|
classNames: "w-full text-start gap-form-gap"
|
|
1839
1748
|
}, /* @__PURE__ */ React11.createElement("div", {
|
|
1840
|
-
role: "none",
|
|
1841
1749
|
className: "grow overflow-hidden"
|
|
1842
1750
|
}, /* @__PURE__ */ React11.createElement("span", {
|
|
1843
1751
|
className: "truncate text-description"
|
|
@@ -1902,9 +1810,10 @@ import { PublicKey } from "@dxos/keys";
|
|
|
1902
1810
|
import { IconButton as IconButton3, Input as Input8, Tag, useTranslation as useTranslation8 } from "@dxos/react-ui";
|
|
1903
1811
|
import { List } from "@dxos/react-ui-list";
|
|
1904
1812
|
import { HuePicker } from "@dxos/react-ui-pickers";
|
|
1905
|
-
import { hues, osTranslations
|
|
1813
|
+
import { hues, osTranslations } from "@dxos/ui-theme";
|
|
1814
|
+
import { translationKey as translationKey8 } from "#translations";
|
|
1906
1815
|
var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueChange }) => {
|
|
1907
|
-
const { t } = useTranslation8(
|
|
1816
|
+
const { t } = useTranslation8(translationKey8);
|
|
1908
1817
|
const { status, error } = getStatus();
|
|
1909
1818
|
const [selected, setSelectedId] = useState5(null);
|
|
1910
1819
|
const [isNewOption, setIsNewOption] = useState5(false);
|
|
@@ -2016,9 +1925,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
2016
1925
|
error,
|
|
2017
1926
|
readonly,
|
|
2018
1927
|
label
|
|
2019
|
-
}), /* @__PURE__ */ React13.createElement("div", {
|
|
2020
|
-
role: "none"
|
|
2021
|
-
}, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
1928
|
+
}), /* @__PURE__ */ React13.createElement("div", null, options && /* @__PURE__ */ React13.createElement(List.Root, {
|
|
2022
1929
|
items: options,
|
|
2023
1930
|
isItem: (_item) => true,
|
|
2024
1931
|
onMove: readonly ? void 0 : handleMove,
|
|
@@ -2031,10 +1938,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
2031
1938
|
}, /* @__PURE__ */ React13.createElement(List.Item, {
|
|
2032
1939
|
role: "button",
|
|
2033
1940
|
item,
|
|
2034
|
-
classNames:
|
|
2035
|
-
subtleHover,
|
|
2036
|
-
"flex flex-col cursor-pointer rounded-xs"
|
|
2037
|
-
],
|
|
1941
|
+
classNames: "flex flex-col cursor-pointer rounded-xs dx-hover",
|
|
2038
1942
|
"aria-expanded": selected === item.id
|
|
2039
1943
|
}, /* @__PURE__ */ React13.createElement("div", {
|
|
2040
1944
|
className: "flex items-center"
|
|
@@ -2048,7 +1952,7 @@ var SelectOptionField = ({ type, readonly, label, getStatus, getValue, onValueCh
|
|
|
2048
1952
|
}, item.title || "\u200B")), /* @__PURE__ */ React13.createElement(IconButton3, {
|
|
2049
1953
|
iconOnly: true,
|
|
2050
1954
|
variant: "ghost",
|
|
2051
|
-
label: t(selected === item.id ? "collapse
|
|
1955
|
+
label: t(selected === item.id ? "collapse.label" : "expand.label", {
|
|
2052
1956
|
ns: osTranslations
|
|
2053
1957
|
}),
|
|
2054
1958
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
@@ -2169,7 +2073,7 @@ var TupleField = ({ binding, type, readonly, label, getStatus, getValue, onValue
|
|
|
2169
2073
|
// src/components/FieldEditor/FieldEditor.tsx
|
|
2170
2074
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
2171
2075
|
var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCancel }) => {
|
|
2172
|
-
const { t } = useTranslation9(
|
|
2076
|
+
const { t } = useTranslation9(translationKey9);
|
|
2173
2077
|
const [props, setProps] = useState6(projection.getFieldProjection(field.id).props);
|
|
2174
2078
|
useEffect5(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
2175
2079
|
field,
|
|
@@ -2278,7 +2182,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2278
2182
|
]);
|
|
2279
2183
|
const handleSave = useCallback14((props2) => {
|
|
2280
2184
|
if (view) {
|
|
2281
|
-
Obj3.
|
|
2185
|
+
Obj3.update(view, () => {
|
|
2282
2186
|
projection.setFieldProjection({
|
|
2283
2187
|
field,
|
|
2284
2188
|
props: props2
|
|
@@ -2306,12 +2210,7 @@ var FieldEditor = ({ readonly, projection, field, registry, view, onSave, onCanc
|
|
|
2306
2210
|
if (!fieldSchema) {
|
|
2307
2211
|
log2.warn("invalid format", {
|
|
2308
2212
|
props
|
|
2309
|
-
}, {
|
|
2310
|
-
F: __dxlog_file2,
|
|
2311
|
-
L: 172,
|
|
2312
|
-
S: void 0,
|
|
2313
|
-
C: (f, a) => f(...a)
|
|
2314
|
-
});
|
|
2213
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 156, S: void 0 });
|
|
2315
2214
|
return null;
|
|
2316
2215
|
}
|
|
2317
2216
|
return /* @__PURE__ */ React17.createElement(Form.Root, {
|
|
@@ -2341,6 +2240,7 @@ import { splitJsonPath } from "@dxos/echo/internal";
|
|
|
2341
2240
|
import { invariant } from "@dxos/invariant";
|
|
2342
2241
|
import { HuePicker as HuePicker2 } from "@dxos/react-ui-pickers";
|
|
2343
2242
|
import { isNonNullable } from "@dxos/util";
|
|
2243
|
+
import { translationKey as translationKey10 } from "#translations";
|
|
2344
2244
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectForm/ObjectForm.tsx";
|
|
2345
2245
|
var createFieldMap = {
|
|
2346
2246
|
hue: ({ type, label, layout, getValue, onValueChange }) => {
|
|
@@ -2378,27 +2278,11 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2378
2278
|
schema
|
|
2379
2279
|
]);
|
|
2380
2280
|
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
|
-
});
|
|
2281
|
+
invariant(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 49, S: void 0, A: ["db", ""] });
|
|
2282
|
+
invariant(Type2.isObjectSchema(schema2), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 50, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
|
|
2399
2283
|
const newObject = db.add(Obj4.make(schema2, values2));
|
|
2400
2284
|
if (Obj4.instanceOf(Tag2.Tag, newObject)) {
|
|
2401
|
-
Obj4.
|
|
2285
|
+
Obj4.update(object, (object2) => {
|
|
2402
2286
|
Obj4.getMeta(object2).tags = [
|
|
2403
2287
|
...Obj4.getMeta(object2).tags ?? [],
|
|
2404
2288
|
Obj4.getDXN(newObject).toString()
|
|
@@ -2413,13 +2297,13 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2413
2297
|
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2414
2298
|
const hasTagsChange = changedPaths.some((path) => splitJsonPath(path)[0] === "tags");
|
|
2415
2299
|
if (hasTagsChange) {
|
|
2416
|
-
Obj4.
|
|
2300
|
+
Obj4.update(object, (object2) => {
|
|
2417
2301
|
Obj4.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
|
|
2418
2302
|
});
|
|
2419
2303
|
}
|
|
2420
2304
|
const nonTagPaths = changedPaths.filter((path) => splitJsonPath(path)[0] !== "tags");
|
|
2421
2305
|
if (nonTagPaths.length > 0) {
|
|
2422
|
-
Obj4.
|
|
2306
|
+
Obj4.update(object, () => {
|
|
2423
2307
|
for (const path of nonTagPaths) {
|
|
2424
2308
|
const parts = splitJsonPath(path);
|
|
2425
2309
|
const value3 = Obj4.getValue(values2, parts);
|
|
@@ -2438,7 +2322,7 @@ var ObjectForm = ({ object, schema }) => {
|
|
|
2438
2322
|
createOptionLabel: [
|
|
2439
2323
|
"add-tag.label",
|
|
2440
2324
|
{
|
|
2441
|
-
ns:
|
|
2325
|
+
ns: translationKey10
|
|
2442
2326
|
}
|
|
2443
2327
|
],
|
|
2444
2328
|
createInitialValuePath: "label",
|
|
@@ -2461,6 +2345,7 @@ import { HuePicker as HuePicker3 } from "@dxos/react-ui-pickers";
|
|
|
2461
2345
|
import { FactoryAnnotation } from "@dxos/schema";
|
|
2462
2346
|
import { composable as composable2, composableProps as composableProps2 } from "@dxos/ui-theme";
|
|
2463
2347
|
import { isNonNullable as isNonNullable2 } from "@dxos/util";
|
|
2348
|
+
import { translationKey as translationKey11 } from "#translations";
|
|
2464
2349
|
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ObjectProperties/ObjectProperties.tsx";
|
|
2465
2350
|
var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef) => {
|
|
2466
2351
|
const db = Obj5.getDatabase(object);
|
|
@@ -2479,24 +2364,8 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2479
2364
|
object
|
|
2480
2365
|
]);
|
|
2481
2366
|
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
|
-
});
|
|
2367
|
+
invariant2(db, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 45, S: void 0, A: ["db", ""] });
|
|
2368
|
+
invariant2(Type3.isObjectSchema(schema), void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 46, S: void 0, A: ["Type.isObjectSchema(schema)", ""] });
|
|
2500
2369
|
const factory = Option5.getOrUndefined(FactoryAnnotation.get(schema));
|
|
2501
2370
|
const newObject = factory ? factory(values2) : Obj5.make(schema, values2);
|
|
2502
2371
|
return db.add(newObject);
|
|
@@ -2510,13 +2379,13 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2510
2379
|
const changedPaths = Object.keys(changed).filter((path) => changed[path]);
|
|
2511
2380
|
const hasTagsChange = changedPaths.some((path) => splitJsonPath2(path)[0] === "tags");
|
|
2512
2381
|
if (hasTagsChange) {
|
|
2513
|
-
Obj5.
|
|
2382
|
+
Obj5.update(object, (object2) => {
|
|
2514
2383
|
Obj5.getMeta(object2).tags = tags2?.map((tag) => tag.dxn.toString()) ?? [];
|
|
2515
2384
|
});
|
|
2516
2385
|
}
|
|
2517
2386
|
const nonTagPaths = changedPaths.filter((path) => splitJsonPath2(path)[0] !== "tags");
|
|
2518
2387
|
if (nonTagPaths.length > 0) {
|
|
2519
|
-
Obj5.
|
|
2388
|
+
Obj5.update(object, () => {
|
|
2520
2389
|
for (const path of nonTagPaths) {
|
|
2521
2390
|
const parts = splitJsonPath2(path);
|
|
2522
2391
|
const value3 = Obj5.getValue(values2, parts);
|
|
@@ -2538,7 +2407,7 @@ var ObjectProperties = composable2(({ children, object, ...props }, forwardedRef
|
|
|
2538
2407
|
createOptionLabel: [
|
|
2539
2408
|
"add-tag.label",
|
|
2540
2409
|
{
|
|
2541
|
-
ns:
|
|
2410
|
+
ns: translationKey11
|
|
2542
2411
|
}
|
|
2543
2412
|
],
|
|
2544
2413
|
createInitialValuePath: "label",
|
|
@@ -2578,6 +2447,7 @@ var BaseSchema = Schema4.Struct({
|
|
|
2578
2447
|
import React22 from "react";
|
|
2579
2448
|
import { ScrollArea as ScrollArea2, toLocalizedString as toLocalizedString2, useTranslation as useTranslation11 } from "@dxos/react-ui";
|
|
2580
2449
|
import { composable as composable3, composableProps as composableProps3, mx as mx4 } from "@dxos/ui-theme";
|
|
2450
|
+
import { translationKey as translationKey13 } from "#translations";
|
|
2581
2451
|
|
|
2582
2452
|
// src/components/Settings/SettingsFieldSet.tsx
|
|
2583
2453
|
import * as SchemaAST5 from "effect/SchemaAST";
|
|
@@ -2590,32 +2460,31 @@ import { Input as Input13, Select as Select2 } from "@dxos/react-ui";
|
|
|
2590
2460
|
import React20 from "react";
|
|
2591
2461
|
import { Input as Input12, toLocalizedString, useTranslation as useTranslation10 } from "@dxos/react-ui";
|
|
2592
2462
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2463
|
+
import { translationKey as translationKey12 } from "#translations";
|
|
2593
2464
|
var SETTINGS_PANEL_NAME = "Settings.Panel";
|
|
2594
2465
|
var SETTINGS_ITEM_NAME = "Settings.Item";
|
|
2595
2466
|
var SettingsPanel = ({ classNames, children }) => {
|
|
2596
2467
|
return /* @__PURE__ */ React20.createElement("div", {
|
|
2597
|
-
role: "none",
|
|
2598
2468
|
className: mx3("flex flex-col gap-3 p-trim-md border border-separator rounded-sm", classNames)
|
|
2599
2469
|
}, children);
|
|
2600
2470
|
};
|
|
2601
2471
|
SettingsPanel.displayName = SETTINGS_PANEL_NAME;
|
|
2602
2472
|
var SettingsItem = ({ title, description = "", children }) => {
|
|
2603
|
-
const { t } = useTranslation10(
|
|
2473
|
+
const { t } = useTranslation10(translationKey12);
|
|
2604
2474
|
return /* @__PURE__ */ React20.createElement(Input12.Root, null, /* @__PURE__ */ React20.createElement(SettingsPanel, {
|
|
2605
2475
|
classNames: "grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-x-trim-lg gap-y-0"
|
|
2606
2476
|
}, /* @__PURE__ */ React20.createElement(Input12.Label, {
|
|
2607
|
-
classNames: "pb-trim-md text-base-
|
|
2477
|
+
classNames: "pb-trim-md text-base-foreground text-lg md:col-span-2"
|
|
2608
2478
|
}, toLocalizedString(title, t)), /* @__PURE__ */ React20.createElement(Input12.DescriptionAndValidation, null, /* @__PURE__ */ React20.createElement(Input12.Description, {
|
|
2609
2479
|
classNames: "text-base text-description"
|
|
2610
2480
|
}, toLocalizedString(description, t))), /* @__PURE__ */ React20.createElement("div", {
|
|
2611
|
-
role: "none",
|
|
2612
2481
|
className: "text-end py-1"
|
|
2613
2482
|
}, children)));
|
|
2614
2483
|
};
|
|
2615
2484
|
SettingsItem.displayName = SETTINGS_ITEM_NAME;
|
|
2616
2485
|
|
|
2617
2486
|
// src/components/Settings/SettingsFieldSet.tsx
|
|
2618
|
-
var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort }) => {
|
|
2487
|
+
var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, visible, sort, pathPrefix = "" }) => {
|
|
2619
2488
|
const properties = useMemo11(() => {
|
|
2620
2489
|
const props = getFormProperties(schema.ast);
|
|
2621
2490
|
if (!sort) {
|
|
@@ -2643,21 +2512,27 @@ var SettingsFieldSet = ({ schema, values, onValuesChanged, readonly, fieldMap, v
|
|
|
2643
2512
|
]);
|
|
2644
2513
|
return /* @__PURE__ */ React21.createElement(React21.Fragment, null, properties.map((property) => {
|
|
2645
2514
|
const name = property.name.toString();
|
|
2646
|
-
|
|
2515
|
+
const path = pathPrefix ? `${pathPrefix}.${name}` : name;
|
|
2516
|
+
if (visible && !visible(path, values)) {
|
|
2647
2517
|
return null;
|
|
2648
2518
|
}
|
|
2519
|
+
const entry = fieldMap?.[name];
|
|
2649
2520
|
return /* @__PURE__ */ React21.createElement(SettingsFieldItem, {
|
|
2650
2521
|
key: name,
|
|
2522
|
+
path,
|
|
2651
2523
|
property,
|
|
2652
2524
|
value: values[name],
|
|
2653
2525
|
onChange: (value3) => handleChange(name, value3),
|
|
2654
2526
|
readonly,
|
|
2655
|
-
customField:
|
|
2527
|
+
customField: typeof entry === "function" ? entry : void 0,
|
|
2528
|
+
nestedFieldMap: typeof entry === "object" ? entry : void 0,
|
|
2529
|
+
visible,
|
|
2530
|
+
sort
|
|
2656
2531
|
});
|
|
2657
2532
|
}));
|
|
2658
2533
|
};
|
|
2659
2534
|
SettingsFieldSet.displayName = "Settings.FieldSet";
|
|
2660
|
-
var SettingsFieldItem = ({ property, value: value3, onChange, readonly, customField }) => {
|
|
2535
|
+
var SettingsFieldItem = ({ property, path, value: value3, onChange, readonly, customField, nestedFieldMap, visible, sort }) => {
|
|
2661
2536
|
const { type } = property;
|
|
2662
2537
|
const name = property.name.toString();
|
|
2663
2538
|
const title = getAnnotation3(SchemaAST5.TitleAnnotationId)(type) ?? String3.capitalize(name);
|
|
@@ -2675,6 +2550,19 @@ var SettingsFieldItem = ({ property, value: value3, onChange, readonly, customFi
|
|
|
2675
2550
|
}
|
|
2676
2551
|
const fieldType = detectFieldType(type);
|
|
2677
2552
|
switch (fieldType) {
|
|
2553
|
+
case "struct":
|
|
2554
|
+
return /* @__PURE__ */ React21.createElement(SettingsFieldSet, {
|
|
2555
|
+
schema: {
|
|
2556
|
+
ast: type
|
|
2557
|
+
},
|
|
2558
|
+
values: value3 ?? {},
|
|
2559
|
+
onValuesChanged: onChange,
|
|
2560
|
+
readonly,
|
|
2561
|
+
fieldMap: nestedFieldMap,
|
|
2562
|
+
visible,
|
|
2563
|
+
sort,
|
|
2564
|
+
pathPrefix: path
|
|
2565
|
+
});
|
|
2678
2566
|
case "boolean":
|
|
2679
2567
|
return /* @__PURE__ */ React21.createElement(SettingsItem, {
|
|
2680
2568
|
title,
|
|
@@ -2754,13 +2642,12 @@ var SettingsViewport = composable3(({ children, ...props }, forwardedRef) => {
|
|
|
2754
2642
|
}, /* @__PURE__ */ React22.createElement(ScrollArea2.Viewport, {
|
|
2755
2643
|
classNames: "px-4 pointer-coarse:px-2"
|
|
2756
2644
|
}, /* @__PURE__ */ React22.createElement("div", {
|
|
2757
|
-
role: "none",
|
|
2758
2645
|
className: "dx-document flex flex-col gap-2 py-4"
|
|
2759
2646
|
}, children)));
|
|
2760
2647
|
});
|
|
2761
2648
|
SettingsViewport.displayName = SETTINGS_VIEWPORT_NAME;
|
|
2762
2649
|
var SettingsSection = ({ title, description, children }) => {
|
|
2763
|
-
const { t } = useTranslation11(
|
|
2650
|
+
const { t } = useTranslation11(translationKey13);
|
|
2764
2651
|
return /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement("h2", {
|
|
2765
2652
|
className: "px-trim-md mt-trim-md text-xl"
|
|
2766
2653
|
}, toLocalizedString2(title, t)), description && /* @__PURE__ */ React22.createElement("p", {
|
|
@@ -2779,15 +2666,38 @@ var Settings = {
|
|
|
2779
2666
|
FieldSet: SettingsFieldSet
|
|
2780
2667
|
};
|
|
2781
2668
|
|
|
2669
|
+
// src/components/Settings/SettingsSelectField.tsx
|
|
2670
|
+
import React23 from "react";
|
|
2671
|
+
import { Select as Select3 } from "@dxos/react-ui";
|
|
2672
|
+
var createSelectField = ({ options, defaultLabel = "Default" }) => {
|
|
2673
|
+
const normalized = options.map((option) => typeof option === "string" ? {
|
|
2674
|
+
value: option,
|
|
2675
|
+
label: option
|
|
2676
|
+
} : option);
|
|
2677
|
+
const hasDefault = defaultLabel !== null;
|
|
2678
|
+
const sentinel = hasDefault ? `__default__${Math.random().toString(36).slice(2)}` : "";
|
|
2679
|
+
return ({ value: value3, onChange, readonly }) => /* @__PURE__ */ React23.createElement(Select3.Root, {
|
|
2680
|
+
disabled: readonly,
|
|
2681
|
+
value: value3 ?? sentinel,
|
|
2682
|
+
onValueChange: (next) => onChange(hasDefault && next === sentinel ? void 0 : next)
|
|
2683
|
+
}, /* @__PURE__ */ React23.createElement(Select3.TriggerButton, {
|
|
2684
|
+
disabled: readonly
|
|
2685
|
+
}), /* @__PURE__ */ React23.createElement(Select3.Portal, null, /* @__PURE__ */ React23.createElement(Select3.Content, null, /* @__PURE__ */ React23.createElement(Select3.Viewport, null, hasDefault && /* @__PURE__ */ React23.createElement(Select3.Option, {
|
|
2686
|
+
value: sentinel
|
|
2687
|
+
}, defaultLabel), normalized.map((option) => /* @__PURE__ */ React23.createElement(Select3.Option, {
|
|
2688
|
+
key: option.value,
|
|
2689
|
+
value: option.value
|
|
2690
|
+
}, option.label ?? option.value))), /* @__PURE__ */ React23.createElement(Select3.Arrow, null))));
|
|
2691
|
+
};
|
|
2692
|
+
|
|
2782
2693
|
// src/components/ViewEditor/ViewEditor.tsx
|
|
2783
2694
|
import { RegistryContext } from "@effect-atom/atom-react";
|
|
2784
2695
|
import * as Array4 from "effect/Array";
|
|
2785
2696
|
import * as Match2 from "effect/Match";
|
|
2786
2697
|
import * as Option6 from "effect/Option";
|
|
2787
2698
|
import * as Schema5 from "effect/Schema";
|
|
2788
|
-
import
|
|
2789
|
-
import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj6, Query, QueryAST, Ref as Ref6 } from "@dxos/echo";
|
|
2790
|
-
import { View } from "@dxos/echo";
|
|
2699
|
+
import React24, { forwardRef as forwardRef2, useCallback as useCallback18, useContext, useImperativeHandle, useMemo as useMemo12, useState as useState7 } from "react";
|
|
2700
|
+
import { Entity as Entity2, Feed, Filter as Filter2, Format as Format5, Obj as Obj6, Query, QueryAST, Ref as Ref6, View } from "@dxos/echo";
|
|
2791
2701
|
import { EchoSchema, isMutable, toJsonSchema } from "@dxos/echo/internal";
|
|
2792
2702
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
2793
2703
|
import { useObject, useQuery as useQuery2 } from "@dxos/react-client/echo";
|
|
@@ -2795,12 +2705,13 @@ import { IconButton as IconButton4, Input as Input14, Message, useTranslation as
|
|
|
2795
2705
|
import { QueryForm } from "@dxos/react-ui-components";
|
|
2796
2706
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
2797
2707
|
import { ParentLabelAnnotation, ProjectionModel, VIEW_FIELD_LIMIT, createEchoChangeCallback, getTypenameFromQuery } from "@dxos/schema";
|
|
2798
|
-
import { mx as mx5, osTranslations as osTranslations2
|
|
2708
|
+
import { mx as mx5, osTranslations as osTranslations2 } from "@dxos/ui-theme";
|
|
2709
|
+
import { translationKey as translationKey14 } from "#translations";
|
|
2799
2710
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2800
2711
|
var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode = "schema", registry, db, readonly, showHeading = false, types, tags, onQueryChanged, onDelete }, forwardedRef) => {
|
|
2801
2712
|
const atomRegistry = useContext(RegistryContext);
|
|
2802
2713
|
const schemaReadonly = !isMutable(schema);
|
|
2803
|
-
const { t } = useTranslation12(
|
|
2714
|
+
const { t } = useTranslation12(translationKey14);
|
|
2804
2715
|
const projectionModel = useMemo12(() => {
|
|
2805
2716
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
2806
2717
|
const change = createEchoChangeCallback(view, schema instanceof EchoSchema ? schema : void 0);
|
|
@@ -2825,7 +2736,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2825
2736
|
if (from._tag !== "scope") {
|
|
2826
2737
|
return void 0;
|
|
2827
2738
|
}
|
|
2828
|
-
return Option6.fromNullable(from.scope.
|
|
2739
|
+
return Option6.fromNullable(from.scope.feeds).pipe(Option6.flatMap((feeds2) => Array4.head(feeds2)), Option6.map(String), Option6.getOrUndefined);
|
|
2829
2740
|
}), Match2.orElse(() => void 0));
|
|
2830
2741
|
const feeds = useQuery2(db, Filter2.type(Feed.Feed));
|
|
2831
2742
|
const targetRef = useMemo12(() => {
|
|
@@ -2877,52 +2788,43 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2877
2788
|
]);
|
|
2878
2789
|
const handleUpdate = useCallback18((values) => {
|
|
2879
2790
|
const targetValue = values.target;
|
|
2880
|
-
let
|
|
2791
|
+
let feedDXN;
|
|
2881
2792
|
if (Ref6.isRef(targetValue)) {
|
|
2882
|
-
const
|
|
2883
|
-
const feed = feeds.find((feed2) => Obj6.getDXN(feed2).toString() ===
|
|
2793
|
+
const targetDXN = targetValue.dxn.toString();
|
|
2794
|
+
const feed = feeds.find((feed2) => Obj6.getDXN(feed2).toString() === targetDXN);
|
|
2884
2795
|
if (feed) {
|
|
2885
|
-
|
|
2796
|
+
feedDXN = Feed.getQueueDxn(feed)?.toString();
|
|
2886
2797
|
}
|
|
2887
2798
|
}
|
|
2888
2799
|
const query = mode === "schema" ? Query.select(Filter2.typename(values.query)).ast : JSON.parse(JSON.stringify(values.query));
|
|
2889
|
-
onQueryChanged?.(query,
|
|
2800
|
+
onQueryChanged?.(query, feedDXN);
|
|
2890
2801
|
}, [
|
|
2891
2802
|
onQueryChanged,
|
|
2892
2803
|
mode,
|
|
2893
2804
|
feeds
|
|
2894
2805
|
]);
|
|
2895
2806
|
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
|
-
});
|
|
2807
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 126, S: void 0, A: ["!readonly", ""] });
|
|
2905
2808
|
onDelete?.(fieldId);
|
|
2906
2809
|
}, [
|
|
2907
2810
|
onDelete,
|
|
2908
2811
|
readonly
|
|
2909
2812
|
]);
|
|
2910
|
-
return /* @__PURE__ */
|
|
2911
|
-
role: "none",
|
|
2813
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
2912
2814
|
className: mx5(classNames)
|
|
2913
|
-
}, schemaReadonly && !readonly && /* @__PURE__ */
|
|
2815
|
+
}, schemaReadonly && !readonly && /* @__PURE__ */ React24.createElement(Message.Root, {
|
|
2914
2816
|
valence: "info",
|
|
2915
2817
|
classNames: "my-form-padding"
|
|
2916
|
-
}, /* @__PURE__ */
|
|
2818
|
+
}, /* @__PURE__ */ React24.createElement(Message.Title, null, t("system-schema.description"))), /* @__PURE__ */ React24.createElement(Form.Root, {
|
|
2917
2819
|
schema: viewSchema,
|
|
2918
2820
|
values: viewValues,
|
|
2919
2821
|
fieldMap,
|
|
2920
2822
|
db,
|
|
2921
2823
|
onValuesChanged: handleUpdate
|
|
2922
|
-
}, /* @__PURE__ */
|
|
2824
|
+
}, /* @__PURE__ */ React24.createElement(Form.FieldSet, null), /* @__PURE__ */ React24.createElement(FormFieldLabel, {
|
|
2923
2825
|
label: t("fields.label"),
|
|
2924
2826
|
asChild: true
|
|
2925
|
-
}), /* @__PURE__ */
|
|
2827
|
+
}), /* @__PURE__ */ React24.createElement(FieldList, {
|
|
2926
2828
|
schema,
|
|
2927
2829
|
view,
|
|
2928
2830
|
registry,
|
|
@@ -2934,7 +2836,7 @@ var ViewEditor = /* @__PURE__ */ forwardRef2(({ classNames, schema, view, mode =
|
|
|
2934
2836
|
var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDelete }) => {
|
|
2935
2837
|
const atomRegistry = useContext(RegistryContext);
|
|
2936
2838
|
const schemaReadonly = !isMutable(schema);
|
|
2937
|
-
const { t } = useTranslation12(
|
|
2839
|
+
const { t } = useTranslation12(translationKey14);
|
|
2938
2840
|
const [viewSnapshot] = useObject(view);
|
|
2939
2841
|
const projectionModel = useMemo12(() => {
|
|
2940
2842
|
const jsonSchema = schema instanceof EchoSchema ? schema.jsonSchema : toJsonSchema(schema);
|
|
@@ -2953,15 +2855,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2953
2855
|
]);
|
|
2954
2856
|
const [expandedField, setExpandedField] = useState7();
|
|
2955
2857
|
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
|
-
});
|
|
2858
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 181, S: void 0, A: ["!readonly", ""] });
|
|
2965
2859
|
const field = projectionModel.createFieldProjection();
|
|
2966
2860
|
setExpandedField(field.id);
|
|
2967
2861
|
}, [
|
|
@@ -2974,15 +2868,7 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2974
2868
|
readonly
|
|
2975
2869
|
]);
|
|
2976
2870
|
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
|
-
});
|
|
2871
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 194, S: void 0, A: ["!readonly", ""] });
|
|
2986
2872
|
if (fieldId === expandedField) {
|
|
2987
2873
|
setExpandedField(void 0);
|
|
2988
2874
|
}
|
|
@@ -2993,16 +2879,8 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
2993
2879
|
readonly
|
|
2994
2880
|
]);
|
|
2995
2881
|
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) => {
|
|
2882
|
+
invariant3(!readonly, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 205, S: void 0, A: ["!readonly", ""] });
|
|
2883
|
+
Obj6.update(view, (view2) => {
|
|
3006
2884
|
const fields = [
|
|
3007
2885
|
...view2.projection.fields
|
|
3008
2886
|
];
|
|
@@ -3030,46 +2908,45 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3030
2908
|
if (!viewSnapshot) {
|
|
3031
2909
|
return null;
|
|
3032
2910
|
}
|
|
3033
|
-
return /* @__PURE__ */
|
|
2911
|
+
return /* @__PURE__ */ React24.createElement(List2.Root, {
|
|
3034
2912
|
items: viewSnapshot.projection.fields,
|
|
3035
2913
|
isItem: Schema5.is(View.FieldSchema),
|
|
3036
2914
|
getId: (field) => field.id,
|
|
3037
2915
|
onMove: readonly ? void 0 : handleMove,
|
|
3038
2916
|
readonly
|
|
3039
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
2917
|
+
}, ({ items: fields }) => /* @__PURE__ */ React24.createElement(React24.Fragment, null, showHeading && /* @__PURE__ */ React24.createElement("h3", {
|
|
3040
2918
|
className: "text-sm"
|
|
3041
|
-
}, t("field-path.label")), /* @__PURE__ */
|
|
2919
|
+
}, t("field-path.label")), /* @__PURE__ */ React24.createElement("div", {
|
|
3042
2920
|
role: "list",
|
|
3043
2921
|
className: "grid grid-cols-[min-content_1fr_min-content_min-content_min-content]"
|
|
3044
2922
|
}, fields?.map((field) => {
|
|
3045
2923
|
const hidden = field.visible === false;
|
|
3046
|
-
return /* @__PURE__ */
|
|
2924
|
+
return /* @__PURE__ */ React24.createElement(List2.Item, {
|
|
3047
2925
|
key: field.id,
|
|
3048
2926
|
item: field,
|
|
3049
2927
|
classNames: "grid grid-cols-subgrid col-span-5",
|
|
3050
2928
|
"aria-expanded": expandedField === field.id
|
|
3051
|
-
}, /* @__PURE__ */
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
}, /* @__PURE__ */ React23.createElement(List2.ItemDragHandle, {
|
|
2929
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2930
|
+
className: "grid grid-cols-subgrid col-span-5 rounded-xs cursor-pointer min-h-10 dx-hover"
|
|
2931
|
+
}, /* @__PURE__ */ React24.createElement(List2.ItemDragHandle, {
|
|
3055
2932
|
disabled: readonly || schemaReadonly
|
|
3056
|
-
}), /* @__PURE__ */
|
|
2933
|
+
}), /* @__PURE__ */ React24.createElement(List2.ItemTitle, {
|
|
3057
2934
|
classNames: hidden && "text-subdued",
|
|
3058
2935
|
onClick: () => handleToggleField(field)
|
|
3059
|
-
}, field.path), /* @__PURE__ */
|
|
3060
|
-
label: t(hidden ? "show
|
|
2936
|
+
}, field.path), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
|
|
2937
|
+
label: t(hidden ? "show-field.label" : "hide-field.label"),
|
|
3061
2938
|
"data-testid": hidden ? "show-field-button" : "hide-field-button",
|
|
3062
2939
|
icon: hidden ? "ph--eye-closed--regular" : "ph--eye--regular",
|
|
3063
2940
|
autoHide: false,
|
|
3064
2941
|
disabled: readonly || !hidden && projectionModel.getFields().length <= 1,
|
|
3065
2942
|
onClick: () => hidden ? handleShow(field.path) : handleHide(field.id)
|
|
3066
|
-
}), !readonly && /* @__PURE__ */
|
|
2943
|
+
}), !readonly && /* @__PURE__ */ React24.createElement(React24.Fragment, null, /* @__PURE__ */ React24.createElement(List2.ItemDeleteButton, {
|
|
3067
2944
|
label: t("delete-field.label"),
|
|
3068
2945
|
autoHide: false,
|
|
3069
2946
|
disabled: readonly || schemaReadonly || viewSnapshot.projection.fields.length <= 1,
|
|
3070
2947
|
onClick: () => handleDelete(field.id),
|
|
3071
2948
|
"data-testid": "field.delete"
|
|
3072
|
-
}), /* @__PURE__ */
|
|
2949
|
+
}), /* @__PURE__ */ React24.createElement(List2.ItemIconButton, {
|
|
3073
2950
|
iconOnly: true,
|
|
3074
2951
|
variant: "ghost",
|
|
3075
2952
|
label: t("toggle-expand.label", {
|
|
@@ -3078,20 +2955,18 @@ var FieldList = ({ schema, view, registry, readonly, showHeading = false, onDele
|
|
|
3078
2955
|
icon: expandedField === field.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
3079
2956
|
onClick: () => handleToggleField(field),
|
|
3080
2957
|
"data-testid": "field.toggle"
|
|
3081
|
-
}))), expandedField === field.id && !readonly && /* @__PURE__ */
|
|
3082
|
-
role: "none",
|
|
2958
|
+
}))), expandedField === field.id && !readonly && /* @__PURE__ */ React24.createElement("div", {
|
|
3083
2959
|
className: "col-span-full mt-1 mb-1 border border-separator rounded-md"
|
|
3084
|
-
}, /* @__PURE__ */
|
|
2960
|
+
}, /* @__PURE__ */ React24.createElement(FieldEditor, {
|
|
3085
2961
|
readonly: readonly || schemaReadonly,
|
|
3086
2962
|
registry,
|
|
3087
2963
|
projection: projectionModel,
|
|
3088
2964
|
field,
|
|
3089
2965
|
onSave: handleClose
|
|
3090
2966
|
})));
|
|
3091
|
-
})), !readonly && !expandedField && /* @__PURE__ */
|
|
3092
|
-
role: "none",
|
|
2967
|
+
})), !readonly && !expandedField && /* @__PURE__ */ React24.createElement("div", {
|
|
3093
2968
|
className: "my-form-padding"
|
|
3094
|
-
}, /* @__PURE__ */
|
|
2969
|
+
}, /* @__PURE__ */ React24.createElement(IconButton4, {
|
|
3095
2970
|
icon: "ph--plus--regular",
|
|
3096
2971
|
label: t("add-property-button.label"),
|
|
3097
2972
|
onClick: handleAdd,
|
|
@@ -3104,10 +2979,10 @@ var customFields = ({ types, tags }) => ({
|
|
|
3104
2979
|
const handleChange = useCallback18((query) => onValueChange(type, query.ast), [
|
|
3105
2980
|
onValueChange
|
|
3106
2981
|
]);
|
|
3107
|
-
return /* @__PURE__ */
|
|
2982
|
+
return /* @__PURE__ */ React24.createElement(Input14.Root, null, /* @__PURE__ */ React24.createElement(FormFieldLabel, {
|
|
3108
2983
|
readonly,
|
|
3109
2984
|
label
|
|
3110
|
-
}), /* @__PURE__ */
|
|
2985
|
+
}), /* @__PURE__ */ React24.createElement(QueryForm, {
|
|
3111
2986
|
initialQuery: getValue(),
|
|
3112
2987
|
types,
|
|
3113
2988
|
tags,
|
|
@@ -3138,6 +3013,7 @@ export {
|
|
|
3138
3013
|
TupleField,
|
|
3139
3014
|
ViewEditor,
|
|
3140
3015
|
cellClassesForFieldType,
|
|
3016
|
+
createSelectField,
|
|
3141
3017
|
detectFieldType,
|
|
3142
3018
|
formatForDisplay,
|
|
3143
3019
|
formatForEditing,
|
|
@@ -3149,7 +3025,6 @@ export {
|
|
|
3149
3025
|
omitId,
|
|
3150
3026
|
parseValue,
|
|
3151
3027
|
pathNotUniqueError,
|
|
3152
|
-
translations,
|
|
3153
3028
|
useFormContext,
|
|
3154
3029
|
useFormFieldState,
|
|
3155
3030
|
useFormHandler,
|