@dxos/react-ui-form 0.8.2-main.2f9c567 → 0.8.2-main.36232bc
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 +117 -275
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +103 -258
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +117 -275
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +3 -6
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +32 -35
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +11 -14
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts +0 -1
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +2 -2
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +2 -2
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/package.json +25 -25
- package/src/components/Form/ArrayField.tsx +6 -5
- package/src/components/Form/Defaults.tsx +1 -4
- package/src/components/Form/Form.stories.tsx +38 -86
- package/src/components/Form/Form.tsx +2 -7
- package/src/components/Form/FormContent.tsx +19 -62
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +4 -5
- package/src/components/Form/index.ts +1 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +2 -3
- package/src/components/ViewEditor/ViewEditor.tsx +10 -12
- package/src/components/deprecated/Form.tsx +6 -6
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useForm.ts +3 -3
- package/dist/types/src/components/Form/RefField.d.ts +0 -24
- package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
- package/src/components/Form/RefField.tsx +0 -152
- package/src/hooks/useRefQueryLookupHandler.ts +0 -43
|
@@ -183,9 +183,9 @@ var ControlFrameItem = ({ title, description, children }) => {
|
|
|
183
183
|
};
|
|
184
184
|
|
|
185
185
|
// packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
|
|
186
|
-
import
|
|
186
|
+
import React13, { useCallback as useCallback6, useEffect as useEffect7, useMemo as useMemo7, useState as useState4 } from "react";
|
|
187
187
|
import { FormatEnum as FormatEnum2, FormatEnums, formatToType } from "@dxos/echo-schema";
|
|
188
|
-
import { log as
|
|
188
|
+
import { log as log2 } from "@dxos/log";
|
|
189
189
|
import { useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
190
190
|
import { getFormatSchema, getSchemaProperties as getSchemaProperties3, sortProperties } from "@dxos/schema";
|
|
191
191
|
|
|
@@ -548,28 +548,23 @@ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, on
|
|
|
548
548
|
};
|
|
549
549
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
550
550
|
const { status, error } = getStatus();
|
|
551
|
-
const value = getValue3();
|
|
552
|
-
const handleValueChange = useCallback3((value2) => onValueChange(type, value2), [
|
|
553
|
-
type,
|
|
554
|
-
onValueChange
|
|
555
|
-
]);
|
|
556
551
|
return /* @__PURE__ */ React7.createElement(Input6.Root, {
|
|
557
552
|
validationValence: status
|
|
558
553
|
}, !inputOnly && /* @__PURE__ */ React7.createElement(InputHeader, {
|
|
559
554
|
error
|
|
560
555
|
}, /* @__PURE__ */ React7.createElement(Input6.Label, null, label)), /* @__PURE__ */ React7.createElement(Select.Root, {
|
|
561
|
-
value,
|
|
562
|
-
onValueChange:
|
|
556
|
+
value: getValue3(),
|
|
557
|
+
onValueChange: (value) => onValueChange(type, value)
|
|
563
558
|
}, /* @__PURE__ */ React7.createElement(Select.TriggerButton, {
|
|
564
559
|
classNames: "is-full",
|
|
565
560
|
disabled,
|
|
566
561
|
placeholder
|
|
567
|
-
}), /* @__PURE__ */ React7.createElement(Select.Portal, null, /* @__PURE__ */ React7.createElement(Select.Content, null, /* @__PURE__ */ React7.createElement(Select.Viewport, null, options?.map(({ value
|
|
562
|
+
}), /* @__PURE__ */ React7.createElement(Select.Portal, null, /* @__PURE__ */ React7.createElement(Select.Content, null, /* @__PURE__ */ React7.createElement(Select.Viewport, null, options?.map(({ value, label: label2 }) => (
|
|
568
563
|
// NOTE: Numeric values are converted to and from strings.
|
|
569
564
|
/* @__PURE__ */ React7.createElement(Select.Option, {
|
|
570
|
-
key: String(
|
|
571
|
-
value: String(
|
|
572
|
-
}, label2 ?? String(
|
|
565
|
+
key: String(value),
|
|
566
|
+
value: String(value)
|
|
567
|
+
}, label2 ?? String(value))
|
|
573
568
|
)))))), inputOnly && /* @__PURE__ */ React7.createElement(Input6.DescriptionAndValidation, null, error));
|
|
574
569
|
};
|
|
575
570
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
@@ -613,7 +608,7 @@ var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus,
|
|
|
613
608
|
};
|
|
614
609
|
|
|
615
610
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
616
|
-
import
|
|
611
|
+
import React12, { useEffect as useEffect6, useMemo as useMemo6, useRef as useRef3 } from "react";
|
|
617
612
|
import { mx as mx8 } from "@dxos/react-ui-theme";
|
|
618
613
|
|
|
619
614
|
// packages/ui/react-ui-form/src/components/Form/FormActions.tsx
|
|
@@ -628,7 +623,7 @@ import { getValue as getValue2 } from "@dxos/echo-schema";
|
|
|
628
623
|
import { createJsonPath as createJsonPath2 } from "@dxos/effect";
|
|
629
624
|
|
|
630
625
|
// packages/ui/react-ui-form/src/hooks/useForm.ts
|
|
631
|
-
import { SchemaAST } from "effect";
|
|
626
|
+
import { SchemaAST as AST } from "effect";
|
|
632
627
|
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo2, useState as useState3 } from "react";
|
|
633
628
|
import { getValue, setValue } from "@dxos/echo-schema";
|
|
634
629
|
import { createJsonPath, fromEffectValidationPath } from "@dxos/effect";
|
|
@@ -637,12 +632,12 @@ import { log } from "@dxos/log";
|
|
|
637
632
|
import { validateSchema } from "@dxos/schema";
|
|
638
633
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.ts";
|
|
639
634
|
var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
|
|
640
|
-
invariant(
|
|
635
|
+
invariant(AST.isTypeLiteral(schema.ast), void 0, {
|
|
641
636
|
F: __dxlog_file,
|
|
642
637
|
L: 93,
|
|
643
638
|
S: void 0,
|
|
644
639
|
A: [
|
|
645
|
-
"
|
|
640
|
+
"AST.isTypeLiteral(schema.ast)",
|
|
646
641
|
""
|
|
647
642
|
]
|
|
648
643
|
});
|
|
@@ -836,35 +831,6 @@ var flatMap = (errors) => {
|
|
|
836
831
|
}, {});
|
|
837
832
|
};
|
|
838
833
|
|
|
839
|
-
// packages/ui/react-ui-form/src/hooks/useRefQueryLookupHandler.ts
|
|
840
|
-
import { useCallback as useCallback5 } from "react";
|
|
841
|
-
import { getDXN } from "@dxos/echo-schema";
|
|
842
|
-
import { Filter } from "@dxos/react-client/echo";
|
|
843
|
-
import { isNonNullable } from "@dxos/util";
|
|
844
|
-
var useRefQueryLookupHandler = ({ space }) => {
|
|
845
|
-
const handleRefQueryLookup = useCallback5(async (typeInfo) => {
|
|
846
|
-
if (!space) {
|
|
847
|
-
return [];
|
|
848
|
-
}
|
|
849
|
-
const query = space.db.query(Filter.typename(typeInfo.typename));
|
|
850
|
-
const { objects } = await query.run();
|
|
851
|
-
return objects.map((object) => {
|
|
852
|
-
const dxn = getDXN(object);
|
|
853
|
-
if (!dxn) {
|
|
854
|
-
return void 0;
|
|
855
|
-
}
|
|
856
|
-
const item = {
|
|
857
|
-
dxn,
|
|
858
|
-
label: object?.name ?? object?.id ?? ""
|
|
859
|
-
};
|
|
860
|
-
return item;
|
|
861
|
-
}).filter(isNonNullable);
|
|
862
|
-
}, [
|
|
863
|
-
space
|
|
864
|
-
]);
|
|
865
|
-
return handleRefQueryLookup;
|
|
866
|
-
};
|
|
867
|
-
|
|
868
834
|
// packages/ui/react-ui-form/src/components/Form/FormContext.tsx
|
|
869
835
|
var FormContext = /* @__PURE__ */ createContext(void 0);
|
|
870
836
|
var useFormContext = () => {
|
|
@@ -956,18 +922,20 @@ var FormActions = ({ onCancel, readonly }) => {
|
|
|
956
922
|
};
|
|
957
923
|
|
|
958
924
|
// packages/ui/react-ui-form/src/components/Form/FormContent.tsx
|
|
959
|
-
import {
|
|
925
|
+
import { pipe as pipe2 } from "effect";
|
|
960
926
|
import { capitalize as capitalize2 } from "effect/String";
|
|
961
|
-
import
|
|
927
|
+
import React11, { useMemo as useMemo5 } from "react";
|
|
928
|
+
import { AST as AST3, S } from "@dxos/echo-schema";
|
|
962
929
|
import { createJsonPath as createJsonPath3, findNode as findNode2, getDiscriminatedType as getDiscriminatedType2, isDiscriminatedUnion as isDiscriminatedUnion2 } from "@dxos/effect";
|
|
963
930
|
import { mx as mx7 } from "@dxos/react-ui-theme";
|
|
964
931
|
import { getSchemaProperties as getSchemaProperties2 } from "@dxos/schema";
|
|
965
932
|
import { isNotFalsy } from "@dxos/util";
|
|
966
933
|
|
|
967
934
|
// packages/ui/react-ui-form/src/components/Form/ArrayField.tsx
|
|
968
|
-
import {
|
|
935
|
+
import { pipe } from "effect";
|
|
969
936
|
import { capitalize } from "effect/String";
|
|
970
|
-
import React10, { useCallback as
|
|
937
|
+
import React10, { useCallback as useCallback5, useMemo as useMemo4 } from "react";
|
|
938
|
+
import { AST as AST2 } from "@dxos/echo-schema";
|
|
971
939
|
import { findNode, getDiscriminatedType, isDiscriminatedUnion, SimpleType } from "@dxos/effect";
|
|
972
940
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
973
941
|
import { IconButton as IconButton3, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
@@ -981,7 +949,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
981
949
|
const values = useFormValues(path ?? []) ?? [];
|
|
982
950
|
invariant2(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
983
951
|
F: __dxlog_file2,
|
|
984
|
-
L:
|
|
952
|
+
L: 39,
|
|
985
953
|
S: void 0,
|
|
986
954
|
A: [
|
|
987
955
|
"Array.isArray(values)",
|
|
@@ -989,11 +957,11 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
989
957
|
]
|
|
990
958
|
});
|
|
991
959
|
const label = title ?? pipe(name, capitalize);
|
|
992
|
-
const tupleType = findNode(ast,
|
|
960
|
+
const tupleType = findNode(ast, AST2.isTupleType);
|
|
993
961
|
const elementType = tupleType?.rest[0]?.type;
|
|
994
962
|
const getDefaultObjectValue = (typeNode) => {
|
|
995
963
|
const baseNode = findNode(typeNode, isDiscriminatedUnion);
|
|
996
|
-
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode(typeNode,
|
|
964
|
+
const typeLiteral = baseNode ? getDiscriminatedType(baseNode, {}) : findNode(typeNode, AST2.isTypeLiteral);
|
|
997
965
|
if (!typeLiteral) {
|
|
998
966
|
return {};
|
|
999
967
|
}
|
|
@@ -1012,7 +980,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1012
980
|
type,
|
|
1013
981
|
elementType
|
|
1014
982
|
]);
|
|
1015
|
-
const handleAdd =
|
|
983
|
+
const handleAdd = useCallback5(() => {
|
|
1016
984
|
inputProps.onValueChange(type, [
|
|
1017
985
|
...values,
|
|
1018
986
|
newValue
|
|
@@ -1024,7 +992,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1024
992
|
newValue,
|
|
1025
993
|
values
|
|
1026
994
|
]);
|
|
1027
|
-
const handleRemove =
|
|
995
|
+
const handleRemove = useCallback5((index) => {
|
|
1028
996
|
const newValues = values.filter((_, i) => i !== index);
|
|
1029
997
|
inputProps.onValueChange(type, newValues);
|
|
1030
998
|
}, [
|
|
@@ -1078,108 +1046,6 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1078
1046
|
})));
|
|
1079
1047
|
};
|
|
1080
1048
|
|
|
1081
|
-
// packages/ui/react-ui-form/src/components/Form/RefField.tsx
|
|
1082
|
-
import React11, { useEffect as useEffect6, useState as useState4 } from "react";
|
|
1083
|
-
import { Expando, getTypeAnnotation, Ref, ReferenceAnnotationId } from "@dxos/echo-schema";
|
|
1084
|
-
import { findAnnotation } from "@dxos/effect";
|
|
1085
|
-
import { DXN } from "@dxos/keys";
|
|
1086
|
-
import { refFromDXN } from "@dxos/live-object";
|
|
1087
|
-
import { log as log2 } from "@dxos/log";
|
|
1088
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/RefField.tsx";
|
|
1089
|
-
var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOptions, inputProps }) => {
|
|
1090
|
-
const { getValue: getValue3, onValueChange, ...restInputProps } = inputProps;
|
|
1091
|
-
const refTypeInfo = findAnnotation(ast, ReferenceAnnotationId);
|
|
1092
|
-
const [refOptions, setRefOptions] = useState4([]);
|
|
1093
|
-
const [loading, setLoading] = useState4(false);
|
|
1094
|
-
useEffect6(() => {
|
|
1095
|
-
if (!refTypeInfo || !onQueryRefOptions) {
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
const fetchOptions = async () => {
|
|
1099
|
-
setLoading(true);
|
|
1100
|
-
try {
|
|
1101
|
-
const options = await onQueryRefOptions(refTypeInfo);
|
|
1102
|
-
setRefOptions(options.map((option) => ({
|
|
1103
|
-
label: option.label,
|
|
1104
|
-
value: option.dxn.toString()
|
|
1105
|
-
})));
|
|
1106
|
-
} catch (error) {
|
|
1107
|
-
log2.error("Failed to fetch ref options:", error, {
|
|
1108
|
-
F: __dxlog_file3,
|
|
1109
|
-
L: 69,
|
|
1110
|
-
S: void 0,
|
|
1111
|
-
C: (f, a) => f(...a)
|
|
1112
|
-
});
|
|
1113
|
-
setRefOptions([]);
|
|
1114
|
-
} finally {
|
|
1115
|
-
setLoading(false);
|
|
1116
|
-
}
|
|
1117
|
-
};
|
|
1118
|
-
void fetchOptions();
|
|
1119
|
-
}, [
|
|
1120
|
-
refTypeInfo,
|
|
1121
|
-
onQueryRefOptions
|
|
1122
|
-
]);
|
|
1123
|
-
if (!refTypeInfo) {
|
|
1124
|
-
return null;
|
|
1125
|
-
}
|
|
1126
|
-
if (refTypeInfo.typename === getTypeAnnotation(Expando)?.typename || !onQueryRefOptions) {
|
|
1127
|
-
const handleOnValueChange = (_type, dxnString) => {
|
|
1128
|
-
const dxn = DXN.tryParse(dxnString);
|
|
1129
|
-
if (dxn) {
|
|
1130
|
-
onValueChange?.("object", refFromDXN(dxn));
|
|
1131
|
-
} else if (dxnString === "") {
|
|
1132
|
-
onValueChange?.("object", void 0);
|
|
1133
|
-
} else {
|
|
1134
|
-
onValueChange?.("string", dxnString);
|
|
1135
|
-
}
|
|
1136
|
-
};
|
|
1137
|
-
const handleGetValue2 = () => {
|
|
1138
|
-
const formValue = getValue3();
|
|
1139
|
-
if (typeof formValue === "string") {
|
|
1140
|
-
return formValue;
|
|
1141
|
-
}
|
|
1142
|
-
if (Ref.isRef(formValue)) {
|
|
1143
|
-
return formValue.dxn.toString();
|
|
1144
|
-
}
|
|
1145
|
-
return void 0;
|
|
1146
|
-
};
|
|
1147
|
-
return /* @__PURE__ */ React11.createElement(TextInput, {
|
|
1148
|
-
type,
|
|
1149
|
-
label,
|
|
1150
|
-
disabled: readonly,
|
|
1151
|
-
placeholder,
|
|
1152
|
-
inputOnly: inline,
|
|
1153
|
-
getValue: handleGetValue2,
|
|
1154
|
-
onValueChange: handleOnValueChange,
|
|
1155
|
-
...restInputProps
|
|
1156
|
-
});
|
|
1157
|
-
}
|
|
1158
|
-
const handleGetValue = () => {
|
|
1159
|
-
const formValue = getValue3();
|
|
1160
|
-
if (Ref.isRef(formValue)) {
|
|
1161
|
-
return formValue.dxn.toString();
|
|
1162
|
-
}
|
|
1163
|
-
return void 0;
|
|
1164
|
-
};
|
|
1165
|
-
const handleValueChanged = (_type, dxnString) => {
|
|
1166
|
-
const dxn = DXN.parse(dxnString);
|
|
1167
|
-
const ref = refFromDXN(dxn);
|
|
1168
|
-
onValueChange("object", ref);
|
|
1169
|
-
};
|
|
1170
|
-
return /* @__PURE__ */ React11.createElement(SelectInput, {
|
|
1171
|
-
type,
|
|
1172
|
-
label,
|
|
1173
|
-
disabled: readonly || loading,
|
|
1174
|
-
placeholder: loading ? "Loading options..." : placeholder,
|
|
1175
|
-
inputOnly: inline,
|
|
1176
|
-
getValue: handleGetValue,
|
|
1177
|
-
onValueChange: handleValueChanged,
|
|
1178
|
-
options: refOptions,
|
|
1179
|
-
...restInputProps
|
|
1180
|
-
});
|
|
1181
|
-
};
|
|
1182
|
-
|
|
1183
1049
|
// packages/ui/react-ui-form/src/components/Form/factory.tsx
|
|
1184
1050
|
import { FormatEnum } from "@dxos/echo-schema";
|
|
1185
1051
|
var getInputComponent = (type, format) => {
|
|
@@ -1200,7 +1066,7 @@ var getInputComponent = (type, format) => {
|
|
|
1200
1066
|
};
|
|
1201
1067
|
|
|
1202
1068
|
// packages/ui/react-ui-form/src/components/Form/FormContent.tsx
|
|
1203
|
-
var FormField = ({ property, path, readonly, inline,
|
|
1069
|
+
var FormField = ({ property, path, readonly, inline, lookupComponent, Custom }) => {
|
|
1204
1070
|
const inputProps = useInputProps(path);
|
|
1205
1071
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1206
1072
|
const label = useMemo5(() => title ?? pipe2(name, capitalize2), [
|
|
@@ -1213,7 +1079,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1213
1079
|
]);
|
|
1214
1080
|
const FoundComponent = lookupComponent?.({
|
|
1215
1081
|
prop: name,
|
|
1216
|
-
schema:
|
|
1082
|
+
schema: S.make(ast),
|
|
1217
1083
|
inputProps: {
|
|
1218
1084
|
type,
|
|
1219
1085
|
format,
|
|
@@ -1224,14 +1090,14 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1224
1090
|
}
|
|
1225
1091
|
});
|
|
1226
1092
|
if (FoundComponent) {
|
|
1227
|
-
return /* @__PURE__ */
|
|
1093
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1228
1094
|
role: "none"
|
|
1229
1095
|
}, FoundComponent);
|
|
1230
1096
|
}
|
|
1231
1097
|
const jsonPath = createJsonPath3(path ?? []);
|
|
1232
1098
|
const CustomComponent = Custom?.[jsonPath];
|
|
1233
1099
|
if (CustomComponent) {
|
|
1234
|
-
return /* @__PURE__ */
|
|
1100
|
+
return /* @__PURE__ */ React11.createElement(CustomComponent, {
|
|
1235
1101
|
type,
|
|
1236
1102
|
format,
|
|
1237
1103
|
label,
|
|
@@ -1242,7 +1108,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1242
1108
|
});
|
|
1243
1109
|
}
|
|
1244
1110
|
if (array) {
|
|
1245
|
-
return /* @__PURE__ */
|
|
1111
|
+
return /* @__PURE__ */ React11.createElement(ArrayField, {
|
|
1246
1112
|
property,
|
|
1247
1113
|
path,
|
|
1248
1114
|
inputProps,
|
|
@@ -1252,9 +1118,9 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1252
1118
|
}
|
|
1253
1119
|
const InputComponent = getInputComponent(type, format);
|
|
1254
1120
|
if (InputComponent) {
|
|
1255
|
-
return /* @__PURE__ */
|
|
1121
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1256
1122
|
role: "none"
|
|
1257
|
-
}, /* @__PURE__ */
|
|
1123
|
+
}, /* @__PURE__ */ React11.createElement(InputComponent, {
|
|
1258
1124
|
type,
|
|
1259
1125
|
format,
|
|
1260
1126
|
label,
|
|
@@ -1265,9 +1131,9 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1265
1131
|
}));
|
|
1266
1132
|
}
|
|
1267
1133
|
if (options) {
|
|
1268
|
-
return /* @__PURE__ */
|
|
1134
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1269
1135
|
role: "none"
|
|
1270
|
-
}, /* @__PURE__ */
|
|
1136
|
+
}, /* @__PURE__ */ React11.createElement(SelectInput, {
|
|
1271
1137
|
type,
|
|
1272
1138
|
format,
|
|
1273
1139
|
disabled: readonly,
|
|
@@ -1281,39 +1147,23 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1281
1147
|
...inputProps
|
|
1282
1148
|
}));
|
|
1283
1149
|
}
|
|
1284
|
-
if (format === "ref") {
|
|
1285
|
-
return /* @__PURE__ */ React12.createElement(RefField, {
|
|
1286
|
-
ast,
|
|
1287
|
-
type,
|
|
1288
|
-
label,
|
|
1289
|
-
readonly,
|
|
1290
|
-
placeholder,
|
|
1291
|
-
inline,
|
|
1292
|
-
onQueryRefOptions,
|
|
1293
|
-
inputProps
|
|
1294
|
-
});
|
|
1295
|
-
}
|
|
1296
1150
|
if (type === "object") {
|
|
1297
1151
|
const baseNode = findNode2(ast, isDiscriminatedUnion2);
|
|
1298
|
-
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode2(ast,
|
|
1152
|
+
const typeLiteral = baseNode ? getDiscriminatedType2(baseNode, inputProps.getValue()) : findNode2(ast, AST3.isTypeLiteral);
|
|
1299
1153
|
if (typeLiteral) {
|
|
1300
|
-
return /* @__PURE__ */
|
|
1154
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1301
1155
|
role: "none"
|
|
1302
|
-
}, !inline && /* @__PURE__ */
|
|
1303
|
-
|
|
1304
|
-
}, label), /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1305
|
-
schema: Schema.make(typeLiteral),
|
|
1156
|
+
}, !inline && /* @__PURE__ */ React11.createElement("div", null, label), /* @__PURE__ */ React11.createElement(FormFields, {
|
|
1157
|
+
schema: S.make(typeLiteral),
|
|
1306
1158
|
path,
|
|
1307
1159
|
readonly,
|
|
1308
|
-
|
|
1309
|
-
Custom,
|
|
1310
|
-
lookupComponent
|
|
1160
|
+
Custom
|
|
1311
1161
|
}));
|
|
1312
1162
|
}
|
|
1313
1163
|
}
|
|
1314
1164
|
return null;
|
|
1315
1165
|
};
|
|
1316
|
-
var FormFields = ({ schema, path, filter, sort, readonly,
|
|
1166
|
+
var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custom }) => {
|
|
1317
1167
|
const values = useFormValues(path);
|
|
1318
1168
|
const properties = useMemo5(() => {
|
|
1319
1169
|
const props = getSchemaProperties2(schema.ast, values);
|
|
@@ -1325,11 +1175,11 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1325
1175
|
filter,
|
|
1326
1176
|
sort
|
|
1327
1177
|
]);
|
|
1328
|
-
return /* @__PURE__ */
|
|
1178
|
+
return /* @__PURE__ */ React11.createElement("div", {
|
|
1329
1179
|
role: "form",
|
|
1330
1180
|
className: mx7("flex flex-col w-full gap-2")
|
|
1331
1181
|
}, properties.map((property) => {
|
|
1332
|
-
return /* @__PURE__ */
|
|
1182
|
+
return /* @__PURE__ */ React11.createElement(FormField, {
|
|
1333
1183
|
key: property.name,
|
|
1334
1184
|
property,
|
|
1335
1185
|
path: [
|
|
@@ -1337,7 +1187,6 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1337
1187
|
property.name
|
|
1338
1188
|
],
|
|
1339
1189
|
readonly,
|
|
1340
|
-
onQueryRefOptions,
|
|
1341
1190
|
lookupComponent,
|
|
1342
1191
|
Custom
|
|
1343
1192
|
});
|
|
@@ -1345,13 +1194,13 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1345
1194
|
};
|
|
1346
1195
|
|
|
1347
1196
|
// packages/ui/react-ui-form/src/components/Form/Form.tsx
|
|
1348
|
-
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel,
|
|
1197
|
+
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, lookupComponent, Custom }) => {
|
|
1349
1198
|
const formRef = useRef3(null);
|
|
1350
1199
|
const onValid = useMemo6(() => autoSave ? onSave : void 0, [
|
|
1351
1200
|
autoSave,
|
|
1352
1201
|
onSave
|
|
1353
1202
|
]);
|
|
1354
|
-
|
|
1203
|
+
useEffect6(() => {
|
|
1355
1204
|
if (autoFocus && formRef.current) {
|
|
1356
1205
|
const input = formRef.current.querySelector("input");
|
|
1357
1206
|
if (input) {
|
|
@@ -1361,7 +1210,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1361
1210
|
}, [
|
|
1362
1211
|
autoFocus
|
|
1363
1212
|
]);
|
|
1364
|
-
return /* @__PURE__ */
|
|
1213
|
+
return /* @__PURE__ */ React12.createElement(FormProvider, {
|
|
1365
1214
|
formRef,
|
|
1366
1215
|
schema,
|
|
1367
1216
|
autoSave,
|
|
@@ -1370,37 +1219,36 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1370
1219
|
onValidate,
|
|
1371
1220
|
onValid,
|
|
1372
1221
|
onSave
|
|
1373
|
-
}, /* @__PURE__ */
|
|
1222
|
+
}, /* @__PURE__ */ React12.createElement("div", {
|
|
1374
1223
|
ref: formRef,
|
|
1375
1224
|
role: "none",
|
|
1376
1225
|
className: mx8("p-2", classNames),
|
|
1377
1226
|
"data-testid": testId
|
|
1378
|
-
}, /* @__PURE__ */
|
|
1227
|
+
}, /* @__PURE__ */ React12.createElement(FormFields, {
|
|
1379
1228
|
schema,
|
|
1380
1229
|
path,
|
|
1381
1230
|
readonly,
|
|
1382
1231
|
filter,
|
|
1383
1232
|
sort,
|
|
1384
|
-
onQueryRefOptions,
|
|
1385
1233
|
lookupComponent,
|
|
1386
1234
|
Custom
|
|
1387
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */
|
|
1235
|
+
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ React12.createElement(FormActions, {
|
|
1388
1236
|
onCancel,
|
|
1389
1237
|
readonly
|
|
1390
1238
|
})));
|
|
1391
1239
|
};
|
|
1392
1240
|
|
|
1393
1241
|
// packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx
|
|
1394
|
-
var
|
|
1242
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1395
1243
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1396
1244
|
const { t } = useTranslation6(translationKey);
|
|
1397
|
-
const [props, setProps] =
|
|
1398
|
-
|
|
1245
|
+
const [props, setProps] = useState4(projection.getFieldProjection(field.id).props);
|
|
1246
|
+
useEffect7(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1399
1247
|
field,
|
|
1400
1248
|
projection
|
|
1401
1249
|
]);
|
|
1402
|
-
const [schemas, setSchemas] =
|
|
1403
|
-
|
|
1250
|
+
const [schemas, setSchemas] = useState4([]);
|
|
1251
|
+
useEffect7(() => {
|
|
1404
1252
|
if (!registry) {
|
|
1405
1253
|
return;
|
|
1406
1254
|
}
|
|
@@ -1418,17 +1266,17 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1418
1266
|
}, [
|
|
1419
1267
|
registry
|
|
1420
1268
|
]);
|
|
1421
|
-
const [referenceSchema, setReferenceSchema] =
|
|
1422
|
-
|
|
1269
|
+
const [referenceSchema, setReferenceSchema] = useState4();
|
|
1270
|
+
useEffect7(() => {
|
|
1423
1271
|
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
1424
1272
|
}, [
|
|
1425
1273
|
schemas,
|
|
1426
1274
|
props?.referenceSchema
|
|
1427
1275
|
]);
|
|
1428
|
-
const [{ fieldSchema }, setFieldSchema] =
|
|
1276
|
+
const [{ fieldSchema }, setFieldSchema] = useState4({
|
|
1429
1277
|
fieldSchema: getFormatSchema(props?.format)
|
|
1430
1278
|
});
|
|
1431
|
-
const handleValuesChanged =
|
|
1279
|
+
const handleValuesChanged = useCallback6((_props) => {
|
|
1432
1280
|
setFieldSchema((prev) => {
|
|
1433
1281
|
const fieldSchema2 = getFormatSchema(_props.format);
|
|
1434
1282
|
if (prev.fieldSchema === fieldSchema2) {
|
|
@@ -1463,7 +1311,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1463
1311
|
props.format,
|
|
1464
1312
|
props.referenceSchema
|
|
1465
1313
|
]);
|
|
1466
|
-
const handleValidate =
|
|
1314
|
+
const handleValidate = useCallback6(({ property }) => {
|
|
1467
1315
|
if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
1468
1316
|
return [
|
|
1469
1317
|
{
|
|
@@ -1476,7 +1324,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1476
1324
|
view.fields,
|
|
1477
1325
|
field
|
|
1478
1326
|
]);
|
|
1479
|
-
const handleSave =
|
|
1327
|
+
const handleSave = useCallback6((props2) => {
|
|
1480
1328
|
projection.setFieldProjection({
|
|
1481
1329
|
field,
|
|
1482
1330
|
props: props2
|
|
@@ -1487,51 +1335,51 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1487
1335
|
field,
|
|
1488
1336
|
onSave
|
|
1489
1337
|
]);
|
|
1490
|
-
const handleCancel =
|
|
1338
|
+
const handleCancel = useCallback6(() => {
|
|
1491
1339
|
requestAnimationFrame(() => onCancel?.());
|
|
1492
1340
|
onSave();
|
|
1493
1341
|
}, [
|
|
1494
1342
|
onSave
|
|
1495
1343
|
]);
|
|
1496
1344
|
const Custom = useMemo7(() => ({
|
|
1497
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
1345
|
+
["format"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
1498
1346
|
...props2,
|
|
1499
1347
|
options: FormatEnums.filter((value) => value !== FormatEnum2.None).map((value) => ({
|
|
1500
1348
|
value,
|
|
1501
1349
|
label: t(`format ${value}`)
|
|
1502
1350
|
}))
|
|
1503
1351
|
}),
|
|
1504
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
1352
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
1505
1353
|
...props2,
|
|
1506
1354
|
options: schemas.map((schema) => ({
|
|
1507
1355
|
value: schema.typename
|
|
1508
1356
|
}))
|
|
1509
1357
|
}),
|
|
1510
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
1358
|
+
["referencePath"]: (props2) => /* @__PURE__ */ React13.createElement(SelectInput, {
|
|
1511
1359
|
...props2,
|
|
1512
1360
|
options: referenceSchema ? getSchemaProperties3(referenceSchema.ast).sort(sortProperties).map((p) => ({
|
|
1513
1361
|
value: p.name
|
|
1514
1362
|
})) : []
|
|
1515
1363
|
}),
|
|
1516
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
1364
|
+
["options"]: (props2) => /* @__PURE__ */ React13.createElement(SelectOptionInput, props2)
|
|
1517
1365
|
}), [
|
|
1518
1366
|
t,
|
|
1519
1367
|
schemas,
|
|
1520
1368
|
referenceSchema
|
|
1521
1369
|
]);
|
|
1522
|
-
const propIsNotType =
|
|
1370
|
+
const propIsNotType = useCallback6((props2) => props2.filter((p) => p.name !== "type"), []);
|
|
1523
1371
|
if (!fieldSchema) {
|
|
1524
|
-
|
|
1372
|
+
log2.warn("invalid format", {
|
|
1525
1373
|
props
|
|
1526
1374
|
}, {
|
|
1527
|
-
F:
|
|
1375
|
+
F: __dxlog_file3,
|
|
1528
1376
|
L: 174,
|
|
1529
1377
|
S: void 0,
|
|
1530
1378
|
C: (f, a) => f(...a)
|
|
1531
1379
|
});
|
|
1532
1380
|
return null;
|
|
1533
1381
|
}
|
|
1534
|
-
return /* @__PURE__ */
|
|
1382
|
+
return /* @__PURE__ */ React13.createElement(Form, {
|
|
1535
1383
|
key: field.id,
|
|
1536
1384
|
autoFocus: true,
|
|
1537
1385
|
values: props,
|
|
@@ -1550,31 +1398,30 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1550
1398
|
};
|
|
1551
1399
|
|
|
1552
1400
|
// packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx
|
|
1553
|
-
import {
|
|
1554
|
-
import
|
|
1555
|
-
import { Format } from "@dxos/echo-schema";
|
|
1401
|
+
import React14, { useCallback as useCallback7, useMemo as useMemo8, useState as useState5 } from "react";
|
|
1402
|
+
import { AST as AST4, Format, S as S2 } from "@dxos/echo-schema";
|
|
1556
1403
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
1557
1404
|
import { IconButton as IconButton4, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
1558
1405
|
import { List as List2 } from "@dxos/react-ui-list";
|
|
1559
1406
|
import { ghostHover, inputTextLabel, mx as mx9 } from "@dxos/react-ui-theme";
|
|
1560
1407
|
import { FieldSchema, ViewProjection, VIEW_FIELD_LIMIT } from "@dxos/schema";
|
|
1561
|
-
var
|
|
1408
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1562
1409
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1563
|
-
var ViewMetaSchema =
|
|
1564
|
-
name:
|
|
1565
|
-
[
|
|
1410
|
+
var ViewMetaSchema = S2.Struct({
|
|
1411
|
+
name: S2.String.annotations({
|
|
1412
|
+
[AST4.TitleAnnotationId]: "View"
|
|
1566
1413
|
}),
|
|
1567
1414
|
typename: Format.URL.annotations({
|
|
1568
|
-
[
|
|
1415
|
+
[AST4.TitleAnnotationId]: "Typename"
|
|
1569
1416
|
})
|
|
1570
|
-
}).pipe(
|
|
1417
|
+
}).pipe(S2.mutable);
|
|
1571
1418
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1572
1419
|
const { t } = useTranslation7(translationKey);
|
|
1573
1420
|
const projection = useMemo8(() => new ViewProjection(schema.jsonSchema, view), [
|
|
1574
1421
|
schema,
|
|
1575
1422
|
view
|
|
1576
1423
|
]);
|
|
1577
|
-
const [field, setField] =
|
|
1424
|
+
const [field, setField] = useState5();
|
|
1578
1425
|
const viewValues = useMemo8(() => {
|
|
1579
1426
|
return {
|
|
1580
1427
|
name: view.name,
|
|
@@ -1585,13 +1432,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1585
1432
|
}, [
|
|
1586
1433
|
view
|
|
1587
1434
|
]);
|
|
1588
|
-
const handleSelect =
|
|
1435
|
+
const handleSelect = useCallback7((field2) => {
|
|
1589
1436
|
setField((f) => f === field2 ? void 0 : field2);
|
|
1590
1437
|
}, []);
|
|
1591
|
-
const handleAdd =
|
|
1438
|
+
const handleAdd = useCallback7(() => {
|
|
1592
1439
|
invariant3(!schema.readonly, void 0, {
|
|
1593
|
-
F:
|
|
1594
|
-
L:
|
|
1440
|
+
F: __dxlog_file4,
|
|
1441
|
+
L: 76,
|
|
1595
1442
|
S: void 0,
|
|
1596
1443
|
A: [
|
|
1597
1444
|
"!schema.readonly",
|
|
@@ -1604,10 +1451,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1604
1451
|
schema,
|
|
1605
1452
|
view
|
|
1606
1453
|
]);
|
|
1607
|
-
const handleUpdate =
|
|
1454
|
+
const handleUpdate = useCallback7(({ name, typename }) => {
|
|
1608
1455
|
invariant3(!schema.readonly, void 0, {
|
|
1609
|
-
F:
|
|
1610
|
-
L:
|
|
1456
|
+
F: __dxlog_file4,
|
|
1457
|
+
L: 83,
|
|
1611
1458
|
S: void 0,
|
|
1612
1459
|
A: [
|
|
1613
1460
|
"!schema.readonly",
|
|
@@ -1627,10 +1474,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1627
1474
|
view,
|
|
1628
1475
|
onTypenameChanged
|
|
1629
1476
|
]);
|
|
1630
|
-
const handleDelete =
|
|
1477
|
+
const handleDelete = useCallback7((fieldId) => {
|
|
1631
1478
|
invariant3(!schema.readonly, void 0, {
|
|
1632
|
-
F:
|
|
1633
|
-
L:
|
|
1479
|
+
F: __dxlog_file4,
|
|
1480
|
+
L: 99,
|
|
1634
1481
|
S: void 0,
|
|
1635
1482
|
A: [
|
|
1636
1483
|
"!schema.readonly",
|
|
@@ -1646,10 +1493,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1646
1493
|
field,
|
|
1647
1494
|
onDelete
|
|
1648
1495
|
]);
|
|
1649
|
-
const handleMove =
|
|
1496
|
+
const handleMove = useCallback7((fromIndex, toIndex) => {
|
|
1650
1497
|
invariant3(!schema.readonly, void 0, {
|
|
1651
|
-
F:
|
|
1652
|
-
L:
|
|
1498
|
+
F: __dxlog_file4,
|
|
1499
|
+
L: 111,
|
|
1653
1500
|
S: void 0,
|
|
1654
1501
|
A: [
|
|
1655
1502
|
"!schema.readonly",
|
|
@@ -1666,95 +1513,91 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1666
1513
|
schema,
|
|
1667
1514
|
view.fields
|
|
1668
1515
|
]);
|
|
1669
|
-
const handleClose =
|
|
1516
|
+
const handleClose = useCallback7(() => setField(void 0), []);
|
|
1670
1517
|
const hiddenProperties = projection.getHiddenProperties();
|
|
1671
|
-
const handleHide =
|
|
1518
|
+
const handleHide = useCallback7((fieldId) => {
|
|
1672
1519
|
setField(void 0);
|
|
1673
1520
|
projection.hideFieldProjection(fieldId);
|
|
1674
1521
|
}, [
|
|
1675
1522
|
projection
|
|
1676
1523
|
]);
|
|
1677
|
-
const handleShow =
|
|
1524
|
+
const handleShow = useCallback7((property) => {
|
|
1678
1525
|
setField(void 0);
|
|
1679
1526
|
projection.showFieldProjection(property);
|
|
1680
1527
|
}, [
|
|
1681
1528
|
projection
|
|
1682
1529
|
]);
|
|
1683
|
-
return /* @__PURE__ */
|
|
1530
|
+
return /* @__PURE__ */ React14.createElement("div", {
|
|
1684
1531
|
role: "none",
|
|
1685
|
-
className: mx9("
|
|
1686
|
-
}, /* @__PURE__ */
|
|
1532
|
+
className: mx9("flex flex-col w-full divide-y divide-separator", classNames)
|
|
1533
|
+
}, /* @__PURE__ */ React14.createElement(Form, {
|
|
1687
1534
|
autoSave: true,
|
|
1688
1535
|
schema: ViewMetaSchema,
|
|
1689
1536
|
values: viewValues,
|
|
1690
|
-
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1691
|
-
|
|
1692
|
-
}), /* @__PURE__ */ React15.createElement("div", {
|
|
1693
|
-
role: "none",
|
|
1694
|
-
className: "border-bs border-separator min-bs-0 overflow-y-auto"
|
|
1695
|
-
}, /* @__PURE__ */ React15.createElement("div", {
|
|
1537
|
+
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1538
|
+
}), /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", {
|
|
1696
1539
|
role: "none",
|
|
1697
1540
|
className: "p-2"
|
|
1698
|
-
}, /* @__PURE__ */
|
|
1541
|
+
}, /* @__PURE__ */ React14.createElement("label", {
|
|
1699
1542
|
className: mx9(inputTextLabel)
|
|
1700
|
-
}, t("fields label"))), /* @__PURE__ */
|
|
1543
|
+
}, t("fields label"))), /* @__PURE__ */ React14.createElement(List2.Root, {
|
|
1701
1544
|
items: view.fields,
|
|
1702
|
-
isItem:
|
|
1545
|
+
isItem: S2.is(FieldSchema),
|
|
1703
1546
|
getId: (field2) => field2.id,
|
|
1704
1547
|
onMove: schema.readonly ? void 0 : handleMove
|
|
1705
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
1548
|
+
}, ({ items: fields }) => /* @__PURE__ */ React14.createElement(React14.Fragment, null, showHeading && /* @__PURE__ */ React14.createElement("div", {
|
|
1706
1549
|
role: "heading",
|
|
1707
1550
|
className: grid
|
|
1708
|
-
}, /* @__PURE__ */
|
|
1551
|
+
}, /* @__PURE__ */ React14.createElement("div", null), /* @__PURE__ */ React14.createElement("div", {
|
|
1709
1552
|
className: "flex items-center text-sm"
|
|
1710
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1553
|
+
}, t("field path label"))), /* @__PURE__ */ React14.createElement("div", {
|
|
1711
1554
|
role: "list",
|
|
1712
1555
|
className: "flex flex-col w-full"
|
|
1713
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1556
|
+
}, fields?.map((field2) => /* @__PURE__ */ React14.createElement(List2.Item, {
|
|
1714
1557
|
key: field2.id,
|
|
1715
1558
|
item: field2,
|
|
1716
1559
|
classNames: mx9(grid, ghostHover, "cursor-pointer")
|
|
1717
|
-
}, /* @__PURE__ */
|
|
1560
|
+
}, /* @__PURE__ */ React14.createElement(List2.ItemDragHandle, null), /* @__PURE__ */ React14.createElement(List2.ItemTitle, {
|
|
1718
1561
|
onClick: () => handleSelect(field2)
|
|
1719
|
-
}, field2.path), /* @__PURE__ */
|
|
1562
|
+
}, field2.path), /* @__PURE__ */ React14.createElement("div", {
|
|
1720
1563
|
className: "flex items-center gap-2 -ml-4"
|
|
1721
|
-
}, /* @__PURE__ */
|
|
1564
|
+
}, /* @__PURE__ */ React14.createElement(List2.ItemButton, {
|
|
1722
1565
|
icon: "ph--eye-slash--regular",
|
|
1723
1566
|
disabled: view.fields.length <= 1,
|
|
1724
1567
|
onClick: () => handleHide(field2.id)
|
|
1725
|
-
}), !schema.readonly && /* @__PURE__ */
|
|
1568
|
+
}), !schema.readonly && /* @__PURE__ */ React14.createElement(List2.ItemDeleteButton, {
|
|
1726
1569
|
icon: "ph--trash--regular",
|
|
1727
1570
|
disabled: view.fields.length <= 1,
|
|
1728
1571
|
onClick: () => handleDelete(field2.id)
|
|
1729
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1572
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ React14.createElement("div", null, /* @__PURE__ */ React14.createElement("div", {
|
|
1730
1573
|
role: "none",
|
|
1731
1574
|
className: "p-2"
|
|
1732
|
-
}, /* @__PURE__ */
|
|
1575
|
+
}, /* @__PURE__ */ React14.createElement("label", {
|
|
1733
1576
|
className: mx9(inputTextLabel)
|
|
1734
|
-
}, t("hidden fields label"))), /* @__PURE__ */
|
|
1577
|
+
}, t("hidden fields label"))), /* @__PURE__ */ React14.createElement(List2.Root, {
|
|
1735
1578
|
items: hiddenProperties,
|
|
1736
1579
|
isItem: (item) => typeof item === "string",
|
|
1737
1580
|
getId: (property) => property
|
|
1738
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1581
|
+
}, ({ items: properties }) => /* @__PURE__ */ React14.createElement("div", {
|
|
1739
1582
|
role: "list",
|
|
1740
1583
|
className: "flex flex-col w-full"
|
|
1741
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1584
|
+
}, properties?.map((property) => /* @__PURE__ */ React14.createElement(List2.Item, {
|
|
1742
1585
|
key: property,
|
|
1743
1586
|
item: property,
|
|
1744
1587
|
classNames: mx9(grid, ghostHover, "cursor-pointer")
|
|
1745
|
-
}, /* @__PURE__ */
|
|
1588
|
+
}, /* @__PURE__ */ React14.createElement("div", null), /* @__PURE__ */ React14.createElement(List2.ItemTitle, null, property), /* @__PURE__ */ React14.createElement(List2.ItemButton, {
|
|
1746
1589
|
icon: "ph--eye--regular",
|
|
1747
1590
|
onClick: () => handleShow(property)
|
|
1748
|
-
}))))))), field && /* @__PURE__ */
|
|
1591
|
+
}))))))), field && /* @__PURE__ */ React14.createElement(FieldEditor, {
|
|
1749
1592
|
key: field.id,
|
|
1750
1593
|
view,
|
|
1751
1594
|
projection,
|
|
1752
1595
|
field,
|
|
1753
1596
|
registry,
|
|
1754
1597
|
onSave: handleClose
|
|
1755
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1598
|
+
}), !readonly && !field && /* @__PURE__ */ React14.createElement("div", {
|
|
1756
1599
|
className: "flex p-2 justify-center"
|
|
1757
|
-
}, /* @__PURE__ */
|
|
1600
|
+
}, /* @__PURE__ */ React14.createElement(IconButton4, {
|
|
1758
1601
|
icon: "ph--plus--regular",
|
|
1759
1602
|
label: t("button add property"),
|
|
1760
1603
|
onClick: schema.readonly ? void 0 : handleAdd,
|
|
@@ -2067,7 +1910,6 @@ export {
|
|
|
2067
1910
|
useForm,
|
|
2068
1911
|
useFormContext,
|
|
2069
1912
|
useFormValues,
|
|
2070
|
-
useInputProps
|
|
2071
|
-
useRefQueryLookupHandler
|
|
1913
|
+
useInputProps
|
|
2072
1914
|
};
|
|
2073
1915
|
//# sourceMappingURL=index.mjs.map
|