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