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