@dxos/react-ui-form 0.8.2-main.12df754 → 0.8.2-main.2f9c567
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 +291 -121
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +274 -107
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +291 -121
- 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 +6 -3
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +37 -34
- package/dist/types/src/components/Form/Form.stories.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 +2 -2
- package/dist/types/src/components/Form/FormContext.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/index.d.ts +1 -0
- 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 +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/formatting.d.ts.map +1 -1
- package/package.json +25 -25
- package/src/components/Form/ArrayField.tsx +8 -7
- package/src/components/Form/Defaults.tsx +4 -1
- package/src/components/Form/Form.stories.tsx +90 -42
- package/src/components/Form/Form.tsx +7 -2
- package/src/components/Form/FormContent.tsx +62 -19
- package/src/components/Form/FormContext.tsx +10 -2
- package/src/components/Form/RefField.tsx +152 -0
- package/src/components/Form/custom/GeoPointInput.tsx +2 -2
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +5 -4
- package/src/components/Form/custom/SelectOptionsInput.tsx +2 -2
- 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
- package/src/util/formatting.ts +15 -3
package/dist/lib/node/index.cjs
CHANGED
|
@@ -62,7 +62,8 @@ __export(node_exports, {
|
|
|
62
62
|
useForm: () => useForm,
|
|
63
63
|
useFormContext: () => useFormContext,
|
|
64
64
|
useFormValues: () => useFormValues,
|
|
65
|
-
useInputProps: () => useInputProps
|
|
65
|
+
useInputProps: () => useInputProps,
|
|
66
|
+
useRefQueryLookupHandler: () => useRefQueryLookupHandler
|
|
66
67
|
});
|
|
67
68
|
module.exports = __toCommonJS(node_exports);
|
|
68
69
|
var import_react = __toESM(require("react"));
|
|
@@ -111,25 +112,34 @@ var import_effect3 = require("@dxos/effect");
|
|
|
111
112
|
var import_invariant = require("@dxos/invariant");
|
|
112
113
|
var import_log2 = require("@dxos/log");
|
|
113
114
|
var import_schema2 = require("@dxos/schema");
|
|
115
|
+
var import_react13 = require("react");
|
|
116
|
+
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
117
|
+
var import_echo = require("@dxos/react-client/echo");
|
|
118
|
+
var import_util3 = require("@dxos/util");
|
|
114
119
|
var import_effect4 = require("effect");
|
|
115
120
|
var import_String = require("effect/String");
|
|
116
|
-
var
|
|
117
|
-
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
121
|
+
var import_react14 = __toESM(require("react"));
|
|
118
122
|
var import_effect5 = require("@dxos/effect");
|
|
119
123
|
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
|
120
124
|
var import_schema3 = require("@dxos/schema");
|
|
121
|
-
var
|
|
125
|
+
var import_util4 = require("@dxos/util");
|
|
122
126
|
var import_effect6 = require("effect");
|
|
123
127
|
var import_String2 = require("effect/String");
|
|
124
|
-
var
|
|
125
|
-
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
128
|
+
var import_react15 = __toESM(require("react"));
|
|
126
129
|
var import_effect7 = require("@dxos/effect");
|
|
127
130
|
var import_invariant2 = require("@dxos/invariant");
|
|
128
131
|
var import_react_ui10 = require("@dxos/react-ui");
|
|
129
132
|
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
130
133
|
var import_schema4 = require("@dxos/schema");
|
|
134
|
+
var import_react16 = __toESM(require("react"));
|
|
135
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
136
|
+
var import_effect8 = require("@dxos/effect");
|
|
137
|
+
var import_keys2 = require("@dxos/keys");
|
|
138
|
+
var import_live_object = require("@dxos/live-object");
|
|
139
|
+
var import_log3 = require("@dxos/log");
|
|
131
140
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
132
|
-
var
|
|
141
|
+
var import_effect9 = require("effect");
|
|
142
|
+
var import_react17 = __toESM(require("react"));
|
|
133
143
|
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
134
144
|
var import_invariant3 = require("@dxos/invariant");
|
|
135
145
|
var import_react_ui11 = require("@dxos/react-ui");
|
|
@@ -638,23 +648,28 @@ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, on
|
|
|
638
648
|
};
|
|
639
649
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
640
650
|
const { status, error } = getStatus();
|
|
651
|
+
const value = getValue3();
|
|
652
|
+
const handleValueChange = (0, import_react8.useCallback)((value2) => onValueChange(type, value2), [
|
|
653
|
+
type,
|
|
654
|
+
onValueChange
|
|
655
|
+
]);
|
|
641
656
|
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
642
657
|
validationValence: status
|
|
643
658
|
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
644
659
|
error
|
|
645
660
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
|
|
646
|
-
value
|
|
647
|
-
onValueChange:
|
|
661
|
+
value,
|
|
662
|
+
onValueChange: handleValueChange
|
|
648
663
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
|
|
649
664
|
classNames: "is-full",
|
|
650
665
|
disabled,
|
|
651
666
|
placeholder
|
|
652
|
-
}), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Viewport, null, options?.map(({ value, label: label2 }) => (
|
|
667
|
+
}), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
|
|
653
668
|
// NOTE: Numeric values are converted to and from strings.
|
|
654
669
|
/* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
|
|
655
|
-
key: String(
|
|
656
|
-
value: String(
|
|
657
|
-
}, label2 ?? String(
|
|
670
|
+
key: String(value2),
|
|
671
|
+
value: String(value2)
|
|
672
|
+
}, label2 ?? String(value2))
|
|
658
673
|
)))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
659
674
|
};
|
|
660
675
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
@@ -703,7 +718,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
703
718
|
L: 93,
|
|
704
719
|
S: void 0,
|
|
705
720
|
A: [
|
|
706
|
-
"
|
|
721
|
+
"SchemaAST.isTypeLiteral(schema.ast)",
|
|
707
722
|
""
|
|
708
723
|
]
|
|
709
724
|
});
|
|
@@ -896,6 +911,29 @@ var flatMap = (errors) => {
|
|
|
896
911
|
return result;
|
|
897
912
|
}, {});
|
|
898
913
|
};
|
|
914
|
+
var useRefQueryLookupHandler = ({ space }) => {
|
|
915
|
+
const handleRefQueryLookup = (0, import_react13.useCallback)(async (typeInfo) => {
|
|
916
|
+
if (!space) {
|
|
917
|
+
return [];
|
|
918
|
+
}
|
|
919
|
+
const query = space.db.query(import_echo.Filter.typename(typeInfo.typename));
|
|
920
|
+
const { objects } = await query.run();
|
|
921
|
+
return objects.map((object) => {
|
|
922
|
+
const dxn = (0, import_echo_schema5.getDXN)(object);
|
|
923
|
+
if (!dxn) {
|
|
924
|
+
return void 0;
|
|
925
|
+
}
|
|
926
|
+
const item = {
|
|
927
|
+
dxn,
|
|
928
|
+
label: object?.name ?? object?.id ?? ""
|
|
929
|
+
};
|
|
930
|
+
return item;
|
|
931
|
+
}).filter(import_util3.isNonNullable);
|
|
932
|
+
}, [
|
|
933
|
+
space
|
|
934
|
+
]);
|
|
935
|
+
return handleRefQueryLookup;
|
|
936
|
+
};
|
|
899
937
|
var FormContext = /* @__PURE__ */ (0, import_react11.createContext)(void 0);
|
|
900
938
|
var useFormContext = () => {
|
|
901
939
|
return (0, import_react11.useContext)(FormContext) ?? (0, import_debug.raise)(new Error("Missing FormContext"));
|
|
@@ -987,10 +1025,10 @@ var padding = "px-2";
|
|
|
987
1025
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
988
1026
|
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
989
1027
|
const { ast, name, type, title } = property;
|
|
990
|
-
const values = useFormValues(path ?? []);
|
|
1028
|
+
const values = useFormValues(path ?? []) ?? [];
|
|
991
1029
|
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
992
1030
|
F: __dxlog_file2,
|
|
993
|
-
L:
|
|
1031
|
+
L: 38,
|
|
994
1032
|
S: void 0,
|
|
995
1033
|
A: [
|
|
996
1034
|
"Array.isArray(values)",
|
|
@@ -998,11 +1036,11 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
998
1036
|
]
|
|
999
1037
|
});
|
|
1000
1038
|
const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
|
|
1001
|
-
const tupleType = (0, import_effect7.findNode)(ast,
|
|
1039
|
+
const tupleType = (0, import_effect7.findNode)(ast, import_effect6.SchemaAST.isTupleType);
|
|
1002
1040
|
const elementType = tupleType?.rest[0]?.type;
|
|
1003
1041
|
const getDefaultObjectValue = (typeNode) => {
|
|
1004
1042
|
const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
|
|
1005
|
-
const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode,
|
|
1043
|
+
const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_effect6.SchemaAST.isTypeLiteral);
|
|
1006
1044
|
if (!typeLiteral) {
|
|
1007
1045
|
return {};
|
|
1008
1046
|
}
|
|
@@ -1011,7 +1049,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1011
1049
|
prop.defaultValue
|
|
1012
1050
|
]));
|
|
1013
1051
|
};
|
|
1014
|
-
const newValue = (0,
|
|
1052
|
+
const newValue = (0, import_react15.useMemo)(() => {
|
|
1015
1053
|
if (type === "object" && elementType) {
|
|
1016
1054
|
return getDefaultObjectValue(elementType);
|
|
1017
1055
|
} else {
|
|
@@ -1021,7 +1059,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1021
1059
|
type,
|
|
1022
1060
|
elementType
|
|
1023
1061
|
]);
|
|
1024
|
-
const handleAdd = (0,
|
|
1062
|
+
const handleAdd = (0, import_react15.useCallback)(() => {
|
|
1025
1063
|
inputProps.onValueChange(type, [
|
|
1026
1064
|
...values,
|
|
1027
1065
|
newValue
|
|
@@ -1033,7 +1071,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1033
1071
|
newValue,
|
|
1034
1072
|
values
|
|
1035
1073
|
]);
|
|
1036
|
-
const handleRemove = (0,
|
|
1074
|
+
const handleRemove = (0, import_react15.useCallback)((index) => {
|
|
1037
1075
|
const newValues = values.filter((_, i) => i !== index);
|
|
1038
1076
|
inputProps.onValueChange(type, newValues);
|
|
1039
1077
|
}, [
|
|
@@ -1044,20 +1082,20 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1044
1082
|
if (!elementType) {
|
|
1045
1083
|
return null;
|
|
1046
1084
|
}
|
|
1047
|
-
return /* @__PURE__ */
|
|
1085
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1048
1086
|
role: "none",
|
|
1049
1087
|
className: (0, import_react_ui_theme9.mx)(padding)
|
|
1050
|
-
}, /* @__PURE__ */
|
|
1088
|
+
}, /* @__PURE__ */ import_react15.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1051
1089
|
role: "none",
|
|
1052
1090
|
className: "flex flex-col gap-1"
|
|
1053
|
-
}, values.map((_value, index) => /* @__PURE__ */
|
|
1091
|
+
}, values.map((_value, index) => /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1054
1092
|
key: index,
|
|
1055
1093
|
role: "none",
|
|
1056
1094
|
className: "flex items-center gap-1"
|
|
1057
|
-
}, /* @__PURE__ */
|
|
1095
|
+
}, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1058
1096
|
role: "none",
|
|
1059
1097
|
className: "flex-1"
|
|
1060
|
-
}, /* @__PURE__ */
|
|
1098
|
+
}, /* @__PURE__ */ import_react15.default.createElement(FormField, {
|
|
1061
1099
|
property: {
|
|
1062
1100
|
...property,
|
|
1063
1101
|
array: false,
|
|
@@ -1071,21 +1109,115 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1071
1109
|
inline: true,
|
|
1072
1110
|
Custom,
|
|
1073
1111
|
lookupComponent
|
|
1074
|
-
})), /* @__PURE__ */
|
|
1112
|
+
})), /* @__PURE__ */ import_react15.default.createElement(import_react_ui10.IconButton, {
|
|
1075
1113
|
icon: "ph--trash--regular",
|
|
1076
1114
|
iconOnly: true,
|
|
1077
1115
|
label: t("button remove"),
|
|
1078
1116
|
onClick: () => handleRemove(index)
|
|
1079
|
-
})))), /* @__PURE__ */
|
|
1117
|
+
})))), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1080
1118
|
role: "none",
|
|
1081
1119
|
className: "flex justify-between items-center plb-1"
|
|
1082
|
-
}, /* @__PURE__ */
|
|
1120
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui10.IconButton, {
|
|
1083
1121
|
icon: "ph--plus--regular",
|
|
1084
1122
|
iconOnly: true,
|
|
1085
1123
|
label: t("button add"),
|
|
1086
1124
|
onClick: handleAdd
|
|
1087
1125
|
})));
|
|
1088
1126
|
};
|
|
1127
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/RefField.tsx";
|
|
1128
|
+
var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOptions, inputProps }) => {
|
|
1129
|
+
const { getValue: getValue3, onValueChange, ...restInputProps } = inputProps;
|
|
1130
|
+
const refTypeInfo = (0, import_effect8.findAnnotation)(ast, import_echo_schema6.ReferenceAnnotationId);
|
|
1131
|
+
const [refOptions, setRefOptions] = (0, import_react16.useState)([]);
|
|
1132
|
+
const [loading, setLoading] = (0, import_react16.useState)(false);
|
|
1133
|
+
(0, import_react16.useEffect)(() => {
|
|
1134
|
+
if (!refTypeInfo || !onQueryRefOptions) {
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
const fetchOptions = async () => {
|
|
1138
|
+
setLoading(true);
|
|
1139
|
+
try {
|
|
1140
|
+
const options = await onQueryRefOptions(refTypeInfo);
|
|
1141
|
+
setRefOptions(options.map((option) => ({
|
|
1142
|
+
label: option.label,
|
|
1143
|
+
value: option.dxn.toString()
|
|
1144
|
+
})));
|
|
1145
|
+
} catch (error) {
|
|
1146
|
+
import_log3.log.error("Failed to fetch ref options:", error, {
|
|
1147
|
+
F: __dxlog_file3,
|
|
1148
|
+
L: 69,
|
|
1149
|
+
S: void 0,
|
|
1150
|
+
C: (f, a) => f(...a)
|
|
1151
|
+
});
|
|
1152
|
+
setRefOptions([]);
|
|
1153
|
+
} finally {
|
|
1154
|
+
setLoading(false);
|
|
1155
|
+
}
|
|
1156
|
+
};
|
|
1157
|
+
void fetchOptions();
|
|
1158
|
+
}, [
|
|
1159
|
+
refTypeInfo,
|
|
1160
|
+
onQueryRefOptions
|
|
1161
|
+
]);
|
|
1162
|
+
if (!refTypeInfo) {
|
|
1163
|
+
return null;
|
|
1164
|
+
}
|
|
1165
|
+
if (refTypeInfo.typename === (0, import_echo_schema6.getTypeAnnotation)(import_echo_schema6.Expando)?.typename || !onQueryRefOptions) {
|
|
1166
|
+
const handleOnValueChange = (_type, dxnString) => {
|
|
1167
|
+
const dxn = import_keys2.DXN.tryParse(dxnString);
|
|
1168
|
+
if (dxn) {
|
|
1169
|
+
onValueChange?.("object", (0, import_live_object.refFromDXN)(dxn));
|
|
1170
|
+
} else if (dxnString === "") {
|
|
1171
|
+
onValueChange?.("object", void 0);
|
|
1172
|
+
} else {
|
|
1173
|
+
onValueChange?.("string", dxnString);
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
const handleGetValue2 = () => {
|
|
1177
|
+
const formValue = getValue3();
|
|
1178
|
+
if (typeof formValue === "string") {
|
|
1179
|
+
return formValue;
|
|
1180
|
+
}
|
|
1181
|
+
if (import_echo_schema6.Ref.isRef(formValue)) {
|
|
1182
|
+
return formValue.dxn.toString();
|
|
1183
|
+
}
|
|
1184
|
+
return void 0;
|
|
1185
|
+
};
|
|
1186
|
+
return /* @__PURE__ */ import_react16.default.createElement(TextInput, {
|
|
1187
|
+
type,
|
|
1188
|
+
label,
|
|
1189
|
+
disabled: readonly,
|
|
1190
|
+
placeholder,
|
|
1191
|
+
inputOnly: inline,
|
|
1192
|
+
getValue: handleGetValue2,
|
|
1193
|
+
onValueChange: handleOnValueChange,
|
|
1194
|
+
...restInputProps
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
const handleGetValue = () => {
|
|
1198
|
+
const formValue = getValue3();
|
|
1199
|
+
if (import_echo_schema6.Ref.isRef(formValue)) {
|
|
1200
|
+
return formValue.dxn.toString();
|
|
1201
|
+
}
|
|
1202
|
+
return void 0;
|
|
1203
|
+
};
|
|
1204
|
+
const handleValueChanged = (_type, dxnString) => {
|
|
1205
|
+
const dxn = import_keys2.DXN.parse(dxnString);
|
|
1206
|
+
const ref = (0, import_live_object.refFromDXN)(dxn);
|
|
1207
|
+
onValueChange("object", ref);
|
|
1208
|
+
};
|
|
1209
|
+
return /* @__PURE__ */ import_react16.default.createElement(SelectInput, {
|
|
1210
|
+
type,
|
|
1211
|
+
label,
|
|
1212
|
+
disabled: readonly || loading,
|
|
1213
|
+
placeholder: loading ? "Loading options..." : placeholder,
|
|
1214
|
+
inputOnly: inline,
|
|
1215
|
+
getValue: handleGetValue,
|
|
1216
|
+
onValueChange: handleValueChanged,
|
|
1217
|
+
options: refOptions,
|
|
1218
|
+
...restInputProps
|
|
1219
|
+
});
|
|
1220
|
+
};
|
|
1089
1221
|
var getInputComponent = (type, format) => {
|
|
1090
1222
|
switch (format) {
|
|
1091
1223
|
case import_echo_schema7.FormatEnum.GeoPoint:
|
|
@@ -1102,20 +1234,20 @@ var getInputComponent = (type, format) => {
|
|
|
1102
1234
|
return BooleanInput;
|
|
1103
1235
|
}
|
|
1104
1236
|
};
|
|
1105
|
-
var FormField = ({ property, path, readonly, inline, lookupComponent, Custom }) => {
|
|
1237
|
+
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1106
1238
|
const inputProps = useInputProps(path);
|
|
1107
1239
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1108
|
-
const label = (0,
|
|
1240
|
+
const label = (0, import_react14.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
1109
1241
|
title,
|
|
1110
1242
|
name
|
|
1111
1243
|
]);
|
|
1112
|
-
const placeholder = (0,
|
|
1244
|
+
const placeholder = (0, import_react14.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1113
1245
|
examples,
|
|
1114
1246
|
description
|
|
1115
1247
|
]);
|
|
1116
1248
|
const FoundComponent = lookupComponent?.({
|
|
1117
1249
|
prop: name,
|
|
1118
|
-
schema:
|
|
1250
|
+
schema: import_effect4.Schema.make(ast),
|
|
1119
1251
|
inputProps: {
|
|
1120
1252
|
type,
|
|
1121
1253
|
format,
|
|
@@ -1126,14 +1258,14 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1126
1258
|
}
|
|
1127
1259
|
});
|
|
1128
1260
|
if (FoundComponent) {
|
|
1129
|
-
return /* @__PURE__ */
|
|
1261
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1130
1262
|
role: "none"
|
|
1131
1263
|
}, FoundComponent);
|
|
1132
1264
|
}
|
|
1133
1265
|
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1134
1266
|
const CustomComponent = Custom?.[jsonPath];
|
|
1135
1267
|
if (CustomComponent) {
|
|
1136
|
-
return /* @__PURE__ */
|
|
1268
|
+
return /* @__PURE__ */ import_react14.default.createElement(CustomComponent, {
|
|
1137
1269
|
type,
|
|
1138
1270
|
format,
|
|
1139
1271
|
label,
|
|
@@ -1144,7 +1276,7 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1144
1276
|
});
|
|
1145
1277
|
}
|
|
1146
1278
|
if (array) {
|
|
1147
|
-
return /* @__PURE__ */
|
|
1279
|
+
return /* @__PURE__ */ import_react14.default.createElement(ArrayField, {
|
|
1148
1280
|
property,
|
|
1149
1281
|
path,
|
|
1150
1282
|
inputProps,
|
|
@@ -1154,9 +1286,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1154
1286
|
}
|
|
1155
1287
|
const InputComponent = getInputComponent(type, format);
|
|
1156
1288
|
if (InputComponent) {
|
|
1157
|
-
return /* @__PURE__ */
|
|
1289
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1158
1290
|
role: "none"
|
|
1159
|
-
}, /* @__PURE__ */
|
|
1291
|
+
}, /* @__PURE__ */ import_react14.default.createElement(InputComponent, {
|
|
1160
1292
|
type,
|
|
1161
1293
|
format,
|
|
1162
1294
|
label,
|
|
@@ -1167,9 +1299,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1167
1299
|
}));
|
|
1168
1300
|
}
|
|
1169
1301
|
if (options) {
|
|
1170
|
-
return /* @__PURE__ */
|
|
1302
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1171
1303
|
role: "none"
|
|
1172
|
-
}, /* @__PURE__ */
|
|
1304
|
+
}, /* @__PURE__ */ import_react14.default.createElement(SelectInput, {
|
|
1173
1305
|
type,
|
|
1174
1306
|
format,
|
|
1175
1307
|
disabled: readonly,
|
|
@@ -1183,25 +1315,41 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1183
1315
|
...inputProps
|
|
1184
1316
|
}));
|
|
1185
1317
|
}
|
|
1318
|
+
if (format === "ref") {
|
|
1319
|
+
return /* @__PURE__ */ import_react14.default.createElement(RefField, {
|
|
1320
|
+
ast,
|
|
1321
|
+
type,
|
|
1322
|
+
label,
|
|
1323
|
+
readonly,
|
|
1324
|
+
placeholder,
|
|
1325
|
+
inline,
|
|
1326
|
+
onQueryRefOptions,
|
|
1327
|
+
inputProps
|
|
1328
|
+
});
|
|
1329
|
+
}
|
|
1186
1330
|
if (type === "object") {
|
|
1187
1331
|
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1188
|
-
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast,
|
|
1332
|
+
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_effect4.SchemaAST.isTypeLiteral);
|
|
1189
1333
|
if (typeLiteral) {
|
|
1190
|
-
return /* @__PURE__ */
|
|
1334
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1191
1335
|
role: "none"
|
|
1192
|
-
}, !inline && /* @__PURE__ */
|
|
1193
|
-
|
|
1336
|
+
}, !inline && /* @__PURE__ */ import_react14.default.createElement("h3", {
|
|
1337
|
+
className: "text-lg mbs-2 mbe-1"
|
|
1338
|
+
}, label), /* @__PURE__ */ import_react14.default.createElement(FormFields, {
|
|
1339
|
+
schema: import_effect4.Schema.make(typeLiteral),
|
|
1194
1340
|
path,
|
|
1195
1341
|
readonly,
|
|
1196
|
-
|
|
1342
|
+
onQueryRefOptions,
|
|
1343
|
+
Custom,
|
|
1344
|
+
lookupComponent
|
|
1197
1345
|
}));
|
|
1198
1346
|
}
|
|
1199
1347
|
}
|
|
1200
1348
|
return null;
|
|
1201
1349
|
};
|
|
1202
|
-
var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custom }) => {
|
|
1350
|
+
var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1203
1351
|
const values = useFormValues(path);
|
|
1204
|
-
const properties = (0,
|
|
1352
|
+
const properties = (0, import_react14.useMemo)(() => {
|
|
1205
1353
|
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
1206
1354
|
const filtered = filter ? filter(props) : props;
|
|
1207
1355
|
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
@@ -1211,11 +1359,11 @@ var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custo
|
|
|
1211
1359
|
filter,
|
|
1212
1360
|
sort
|
|
1213
1361
|
]);
|
|
1214
|
-
return /* @__PURE__ */
|
|
1362
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1215
1363
|
role: "form",
|
|
1216
1364
|
className: (0, import_react_ui_theme8.mx)("flex flex-col w-full gap-2")
|
|
1217
1365
|
}, properties.map((property) => {
|
|
1218
|
-
return /* @__PURE__ */
|
|
1366
|
+
return /* @__PURE__ */ import_react14.default.createElement(FormField, {
|
|
1219
1367
|
key: property.name,
|
|
1220
1368
|
property,
|
|
1221
1369
|
path: [
|
|
@@ -1223,12 +1371,13 @@ var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custo
|
|
|
1223
1371
|
property.name
|
|
1224
1372
|
],
|
|
1225
1373
|
readonly,
|
|
1374
|
+
onQueryRefOptions,
|
|
1226
1375
|
lookupComponent,
|
|
1227
1376
|
Custom
|
|
1228
1377
|
});
|
|
1229
|
-
}).filter(
|
|
1378
|
+
}).filter(import_util4.isNotFalsy));
|
|
1230
1379
|
};
|
|
1231
|
-
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, lookupComponent, Custom }) => {
|
|
1380
|
+
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1232
1381
|
const formRef = (0, import_react9.useRef)(null);
|
|
1233
1382
|
const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
|
|
1234
1383
|
autoSave,
|
|
@@ -1264,6 +1413,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1264
1413
|
readonly,
|
|
1265
1414
|
filter,
|
|
1266
1415
|
sort,
|
|
1416
|
+
onQueryRefOptions,
|
|
1267
1417
|
lookupComponent,
|
|
1268
1418
|
Custom
|
|
1269
1419
|
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
@@ -1271,7 +1421,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1271
1421
|
readonly
|
|
1272
1422
|
})));
|
|
1273
1423
|
};
|
|
1274
|
-
var
|
|
1424
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1275
1425
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1276
1426
|
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
1277
1427
|
const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
|
|
@@ -1404,7 +1554,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1404
1554
|
import_log.log.warn("invalid format", {
|
|
1405
1555
|
props
|
|
1406
1556
|
}, {
|
|
1407
|
-
F:
|
|
1557
|
+
F: __dxlog_file4,
|
|
1408
1558
|
L: 174,
|
|
1409
1559
|
S: void 0,
|
|
1410
1560
|
C: (f, a) => f(...a)
|
|
@@ -1428,24 +1578,24 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1428
1578
|
Custom
|
|
1429
1579
|
});
|
|
1430
1580
|
};
|
|
1431
|
-
var
|
|
1581
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1432
1582
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1433
|
-
var ViewMetaSchema =
|
|
1434
|
-
name:
|
|
1435
|
-
[
|
|
1583
|
+
var ViewMetaSchema = import_effect9.Schema.Struct({
|
|
1584
|
+
name: import_effect9.Schema.String.annotations({
|
|
1585
|
+
[import_effect9.SchemaAST.TitleAnnotationId]: "View"
|
|
1436
1586
|
}),
|
|
1437
1587
|
typename: import_echo_schema8.Format.URL.annotations({
|
|
1438
|
-
[
|
|
1588
|
+
[import_effect9.SchemaAST.TitleAnnotationId]: "Typename"
|
|
1439
1589
|
})
|
|
1440
|
-
}).pipe(
|
|
1590
|
+
}).pipe(import_effect9.Schema.mutable);
|
|
1441
1591
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1442
1592
|
const { t } = (0, import_react_ui11.useTranslation)(translationKey);
|
|
1443
|
-
const projection = (0,
|
|
1593
|
+
const projection = (0, import_react17.useMemo)(() => new import_schema5.ViewProjection(schema.jsonSchema, view), [
|
|
1444
1594
|
schema,
|
|
1445
1595
|
view
|
|
1446
1596
|
]);
|
|
1447
|
-
const [field, setField] = (0,
|
|
1448
|
-
const viewValues = (0,
|
|
1597
|
+
const [field, setField] = (0, import_react17.useState)();
|
|
1598
|
+
const viewValues = (0, import_react17.useMemo)(() => {
|
|
1449
1599
|
return {
|
|
1450
1600
|
name: view.name,
|
|
1451
1601
|
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
@@ -1455,13 +1605,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1455
1605
|
}, [
|
|
1456
1606
|
view
|
|
1457
1607
|
]);
|
|
1458
|
-
const handleSelect = (0,
|
|
1608
|
+
const handleSelect = (0, import_react17.useCallback)((field2) => {
|
|
1459
1609
|
setField((f) => f === field2 ? void 0 : field2);
|
|
1460
1610
|
}, []);
|
|
1461
|
-
const handleAdd = (0,
|
|
1611
|
+
const handleAdd = (0, import_react17.useCallback)(() => {
|
|
1462
1612
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1463
|
-
F:
|
|
1464
|
-
L:
|
|
1613
|
+
F: __dxlog_file5,
|
|
1614
|
+
L: 77,
|
|
1465
1615
|
S: void 0,
|
|
1466
1616
|
A: [
|
|
1467
1617
|
"!schema.readonly",
|
|
@@ -1474,10 +1624,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1474
1624
|
schema,
|
|
1475
1625
|
view
|
|
1476
1626
|
]);
|
|
1477
|
-
const handleUpdate = (0,
|
|
1627
|
+
const handleUpdate = (0, import_react17.useCallback)(({ name, typename }) => {
|
|
1478
1628
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1479
|
-
F:
|
|
1480
|
-
L:
|
|
1629
|
+
F: __dxlog_file5,
|
|
1630
|
+
L: 84,
|
|
1481
1631
|
S: void 0,
|
|
1482
1632
|
A: [
|
|
1483
1633
|
"!schema.readonly",
|
|
@@ -1497,10 +1647,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1497
1647
|
view,
|
|
1498
1648
|
onTypenameChanged
|
|
1499
1649
|
]);
|
|
1500
|
-
const handleDelete = (0,
|
|
1650
|
+
const handleDelete = (0, import_react17.useCallback)((fieldId) => {
|
|
1501
1651
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1502
|
-
F:
|
|
1503
|
-
L:
|
|
1652
|
+
F: __dxlog_file5,
|
|
1653
|
+
L: 100,
|
|
1504
1654
|
S: void 0,
|
|
1505
1655
|
A: [
|
|
1506
1656
|
"!schema.readonly",
|
|
@@ -1516,10 +1666,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1516
1666
|
field,
|
|
1517
1667
|
onDelete
|
|
1518
1668
|
]);
|
|
1519
|
-
const handleMove = (0,
|
|
1669
|
+
const handleMove = (0, import_react17.useCallback)((fromIndex, toIndex) => {
|
|
1520
1670
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1521
|
-
F:
|
|
1522
|
-
L:
|
|
1671
|
+
F: __dxlog_file5,
|
|
1672
|
+
L: 112,
|
|
1523
1673
|
S: void 0,
|
|
1524
1674
|
A: [
|
|
1525
1675
|
"!schema.readonly",
|
|
@@ -1536,91 +1686,95 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1536
1686
|
schema,
|
|
1537
1687
|
view.fields
|
|
1538
1688
|
]);
|
|
1539
|
-
const handleClose = (0,
|
|
1689
|
+
const handleClose = (0, import_react17.useCallback)(() => setField(void 0), []);
|
|
1540
1690
|
const hiddenProperties = projection.getHiddenProperties();
|
|
1541
|
-
const handleHide = (0,
|
|
1691
|
+
const handleHide = (0, import_react17.useCallback)((fieldId) => {
|
|
1542
1692
|
setField(void 0);
|
|
1543
1693
|
projection.hideFieldProjection(fieldId);
|
|
1544
1694
|
}, [
|
|
1545
1695
|
projection
|
|
1546
1696
|
]);
|
|
1547
|
-
const handleShow = (0,
|
|
1697
|
+
const handleShow = (0, import_react17.useCallback)((property) => {
|
|
1548
1698
|
setField(void 0);
|
|
1549
1699
|
projection.showFieldProjection(property);
|
|
1550
1700
|
}, [
|
|
1551
1701
|
projection
|
|
1552
1702
|
]);
|
|
1553
|
-
return /* @__PURE__ */
|
|
1703
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1554
1704
|
role: "none",
|
|
1555
|
-
className: (0, import_react_ui_theme10.mx)("
|
|
1556
|
-
}, /* @__PURE__ */
|
|
1705
|
+
className: (0, import_react_ui_theme10.mx)("grid grid-rows-[1fr_1fr] min-bs-0", classNames)
|
|
1706
|
+
}, /* @__PURE__ */ import_react17.default.createElement(Form, {
|
|
1557
1707
|
autoSave: true,
|
|
1558
1708
|
schema: ViewMetaSchema,
|
|
1559
1709
|
values: viewValues,
|
|
1560
|
-
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1561
|
-
|
|
1710
|
+
onSave: schema.readonly ? void 0 : handleUpdate,
|
|
1711
|
+
classNames: "min-bs-0 overflow-y-auto"
|
|
1712
|
+
}), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1713
|
+
role: "none",
|
|
1714
|
+
className: "border-bs border-separator min-bs-0 overflow-y-auto"
|
|
1715
|
+
}, /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1562
1716
|
role: "none",
|
|
1563
1717
|
className: "p-2"
|
|
1564
|
-
}, /* @__PURE__ */
|
|
1718
|
+
}, /* @__PURE__ */ import_react17.default.createElement("label", {
|
|
1565
1719
|
className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
|
|
1566
|
-
}, t("fields label"))), /* @__PURE__ */
|
|
1720
|
+
}, t("fields label"))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Root, {
|
|
1567
1721
|
items: view.fields,
|
|
1568
|
-
isItem:
|
|
1722
|
+
isItem: import_effect9.Schema.is(import_schema5.FieldSchema),
|
|
1569
1723
|
getId: (field2) => field2.id,
|
|
1570
1724
|
onMove: schema.readonly ? void 0 : handleMove
|
|
1571
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
1725
|
+
}, ({ items: fields }) => /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, showHeading && /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1572
1726
|
role: "heading",
|
|
1573
1727
|
className: grid
|
|
1574
|
-
}, /* @__PURE__ */
|
|
1728
|
+
}, /* @__PURE__ */ import_react17.default.createElement("div", null), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1575
1729
|
className: "flex items-center text-sm"
|
|
1576
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1730
|
+
}, t("field path label"))), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1577
1731
|
role: "list",
|
|
1578
1732
|
className: "flex flex-col w-full"
|
|
1579
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1733
|
+
}, fields?.map((field2) => /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Item, {
|
|
1580
1734
|
key: field2.id,
|
|
1581
1735
|
item: field2,
|
|
1582
1736
|
classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
|
|
1583
|
-
}, /* @__PURE__ */
|
|
1737
|
+
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemTitle, {
|
|
1584
1738
|
onClick: () => handleSelect(field2)
|
|
1585
|
-
}, field2.path), /* @__PURE__ */
|
|
1739
|
+
}, field2.path), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1586
1740
|
className: "flex items-center gap-2 -ml-4"
|
|
1587
|
-
}, /* @__PURE__ */
|
|
1741
|
+
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1588
1742
|
icon: "ph--eye-slash--regular",
|
|
1589
1743
|
disabled: view.fields.length <= 1,
|
|
1590
1744
|
onClick: () => handleHide(field2.id)
|
|
1591
|
-
}), !schema.readonly && /* @__PURE__ */
|
|
1745
|
+
}), !schema.readonly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
1592
1746
|
icon: "ph--trash--regular",
|
|
1593
1747
|
disabled: view.fields.length <= 1,
|
|
1594
1748
|
onClick: () => handleDelete(field2.id)
|
|
1595
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1749
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react17.default.createElement("div", null, /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1596
1750
|
role: "none",
|
|
1597
1751
|
className: "p-2"
|
|
1598
|
-
}, /* @__PURE__ */
|
|
1752
|
+
}, /* @__PURE__ */ import_react17.default.createElement("label", {
|
|
1599
1753
|
className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
|
|
1600
|
-
}, t("hidden fields label"))), /* @__PURE__ */
|
|
1754
|
+
}, t("hidden fields label"))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Root, {
|
|
1601
1755
|
items: hiddenProperties,
|
|
1602
1756
|
isItem: (item) => typeof item === "string",
|
|
1603
1757
|
getId: (property) => property
|
|
1604
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1758
|
+
}, ({ items: properties }) => /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1605
1759
|
role: "list",
|
|
1606
1760
|
className: "flex flex-col w-full"
|
|
1607
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1761
|
+
}, properties?.map((property) => /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Item, {
|
|
1608
1762
|
key: property,
|
|
1609
1763
|
item: property,
|
|
1610
1764
|
classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
|
|
1611
|
-
}, /* @__PURE__ */
|
|
1765
|
+
}, /* @__PURE__ */ import_react17.default.createElement("div", null), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemTitle, null, property), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1612
1766
|
icon: "ph--eye--regular",
|
|
1613
1767
|
onClick: () => handleShow(property)
|
|
1614
|
-
}))))))), field && /* @__PURE__ */
|
|
1768
|
+
}))))))), field && /* @__PURE__ */ import_react17.default.createElement(FieldEditor, {
|
|
1615
1769
|
key: field.id,
|
|
1616
1770
|
view,
|
|
1617
1771
|
projection,
|
|
1618
1772
|
field,
|
|
1619
1773
|
registry,
|
|
1620
1774
|
onSave: handleClose
|
|
1621
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1775
|
+
}), !readonly && !field && /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1622
1776
|
className: "flex p-2 justify-center"
|
|
1623
|
-
}, /* @__PURE__ */
|
|
1777
|
+
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.IconButton, {
|
|
1624
1778
|
icon: "ph--plus--regular",
|
|
1625
1779
|
label: t("button add property"),
|
|
1626
1780
|
onClick: schema.readonly ? void 0 : handleAdd,
|
|
@@ -1798,13 +1952,25 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1798
1952
|
});
|
|
1799
1953
|
}
|
|
1800
1954
|
case import_echo_schema10.FormatEnum.Date: {
|
|
1801
|
-
|
|
1955
|
+
try {
|
|
1956
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1957
|
+
} catch (error) {
|
|
1958
|
+
return "Invalid Date";
|
|
1959
|
+
}
|
|
1802
1960
|
}
|
|
1803
1961
|
case import_echo_schema10.FormatEnum.Time: {
|
|
1804
|
-
|
|
1962
|
+
try {
|
|
1963
|
+
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1964
|
+
} catch (error) {
|
|
1965
|
+
return "Invalid Time";
|
|
1966
|
+
}
|
|
1805
1967
|
}
|
|
1806
1968
|
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1807
|
-
|
|
1969
|
+
try {
|
|
1970
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1971
|
+
} catch (error) {
|
|
1972
|
+
return "Invalid DateTime";
|
|
1973
|
+
}
|
|
1808
1974
|
}
|
|
1809
1975
|
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1810
1976
|
if (value === null || value === void 0) {
|
|
@@ -1915,6 +2081,7 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1915
2081
|
useForm,
|
|
1916
2082
|
useFormContext,
|
|
1917
2083
|
useFormValues,
|
|
1918
|
-
useInputProps
|
|
2084
|
+
useInputProps,
|
|
2085
|
+
useRefQueryLookupHandler
|
|
1919
2086
|
});
|
|
1920
2087
|
//# sourceMappingURL=index.cjs.map
|