@dxos/react-ui-form 0.8.2-main.5885341 → 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 +83 -49
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +210 -177
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +83 -49
- 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 +3 -2
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +33 -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 +2 -2
- 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 +3 -2
- package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
- 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 +24 -24
- package/src/components/Form/ArrayField.tsx +5 -6
- package/src/components/Form/Defaults.tsx +4 -1
- package/src/components/Form/Form.stories.tsx +46 -41
- package/src/components/Form/Form.tsx +3 -2
- package/src/components/Form/FormContent.tsx +5 -6
- package/src/components/Form/RefField.tsx +2 -2
- 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 +9 -8
- 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/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,40 +112,43 @@ 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");
|
|
131
|
-
var
|
|
132
|
-
var
|
|
134
|
+
var import_react16 = __toESM(require("react"));
|
|
135
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
133
136
|
var import_effect8 = require("@dxos/effect");
|
|
134
137
|
var import_keys2 = require("@dxos/keys");
|
|
135
138
|
var import_live_object = require("@dxos/live-object");
|
|
136
139
|
var import_log3 = require("@dxos/log");
|
|
140
|
+
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
141
|
+
var import_effect9 = require("effect");
|
|
142
|
+
var import_react17 = __toESM(require("react"));
|
|
137
143
|
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
138
|
-
var import_react16 = __toESM(require("react"));
|
|
139
|
-
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
140
144
|
var import_invariant3 = require("@dxos/invariant");
|
|
141
145
|
var import_react_ui11 = require("@dxos/react-ui");
|
|
142
146
|
var import_react_ui_list2 = require("@dxos/react-ui-list");
|
|
143
147
|
var import_react_ui_theme10 = require("@dxos/react-ui-theme");
|
|
144
148
|
var import_schema5 = require("@dxos/schema");
|
|
145
|
-
var
|
|
149
|
+
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
146
150
|
var import_format = require("date-fns/format");
|
|
147
|
-
var
|
|
151
|
+
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
148
152
|
var translationKey = "react-ui-form";
|
|
149
153
|
var translations_default = [
|
|
150
154
|
{
|
|
@@ -644,23 +648,28 @@ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, on
|
|
|
644
648
|
};
|
|
645
649
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
646
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
|
+
]);
|
|
647
656
|
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
648
657
|
validationValence: status
|
|
649
658
|
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
650
659
|
error
|
|
651
660
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
|
|
652
|
-
value
|
|
653
|
-
onValueChange:
|
|
661
|
+
value,
|
|
662
|
+
onValueChange: handleValueChange
|
|
654
663
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
|
|
655
664
|
classNames: "is-full",
|
|
656
665
|
disabled,
|
|
657
666
|
placeholder
|
|
658
|
-
}), /* @__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 }) => (
|
|
659
668
|
// NOTE: Numeric values are converted to and from strings.
|
|
660
669
|
/* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
|
|
661
|
-
key: String(
|
|
662
|
-
value: String(
|
|
663
|
-
}, label2 ?? String(
|
|
670
|
+
key: String(value2),
|
|
671
|
+
value: String(value2)
|
|
672
|
+
}, label2 ?? String(value2))
|
|
664
673
|
)))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
665
674
|
};
|
|
666
675
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
@@ -709,7 +718,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
709
718
|
L: 93,
|
|
710
719
|
S: void 0,
|
|
711
720
|
A: [
|
|
712
|
-
"
|
|
721
|
+
"SchemaAST.isTypeLiteral(schema.ast)",
|
|
713
722
|
""
|
|
714
723
|
]
|
|
715
724
|
});
|
|
@@ -902,6 +911,29 @@ var flatMap = (errors) => {
|
|
|
902
911
|
return result;
|
|
903
912
|
}, {});
|
|
904
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
|
+
};
|
|
905
937
|
var FormContext = /* @__PURE__ */ (0, import_react11.createContext)(void 0);
|
|
906
938
|
var useFormContext = () => {
|
|
907
939
|
return (0, import_react11.useContext)(FormContext) ?? (0, import_debug.raise)(new Error("Missing FormContext"));
|
|
@@ -996,7 +1028,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
996
1028
|
const values = useFormValues(path ?? []) ?? [];
|
|
997
1029
|
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
998
1030
|
F: __dxlog_file2,
|
|
999
|
-
L:
|
|
1031
|
+
L: 38,
|
|
1000
1032
|
S: void 0,
|
|
1001
1033
|
A: [
|
|
1002
1034
|
"Array.isArray(values)",
|
|
@@ -1004,11 +1036,11 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1004
1036
|
]
|
|
1005
1037
|
});
|
|
1006
1038
|
const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
|
|
1007
|
-
const tupleType = (0, import_effect7.findNode)(ast,
|
|
1039
|
+
const tupleType = (0, import_effect7.findNode)(ast, import_effect6.SchemaAST.isTupleType);
|
|
1008
1040
|
const elementType = tupleType?.rest[0]?.type;
|
|
1009
1041
|
const getDefaultObjectValue = (typeNode) => {
|
|
1010
1042
|
const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
|
|
1011
|
-
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);
|
|
1012
1044
|
if (!typeLiteral) {
|
|
1013
1045
|
return {};
|
|
1014
1046
|
}
|
|
@@ -1017,7 +1049,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1017
1049
|
prop.defaultValue
|
|
1018
1050
|
]));
|
|
1019
1051
|
};
|
|
1020
|
-
const newValue = (0,
|
|
1052
|
+
const newValue = (0, import_react15.useMemo)(() => {
|
|
1021
1053
|
if (type === "object" && elementType) {
|
|
1022
1054
|
return getDefaultObjectValue(elementType);
|
|
1023
1055
|
} else {
|
|
@@ -1027,7 +1059,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1027
1059
|
type,
|
|
1028
1060
|
elementType
|
|
1029
1061
|
]);
|
|
1030
|
-
const handleAdd = (0,
|
|
1062
|
+
const handleAdd = (0, import_react15.useCallback)(() => {
|
|
1031
1063
|
inputProps.onValueChange(type, [
|
|
1032
1064
|
...values,
|
|
1033
1065
|
newValue
|
|
@@ -1039,7 +1071,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1039
1071
|
newValue,
|
|
1040
1072
|
values
|
|
1041
1073
|
]);
|
|
1042
|
-
const handleRemove = (0,
|
|
1074
|
+
const handleRemove = (0, import_react15.useCallback)((index) => {
|
|
1043
1075
|
const newValues = values.filter((_, i) => i !== index);
|
|
1044
1076
|
inputProps.onValueChange(type, newValues);
|
|
1045
1077
|
}, [
|
|
@@ -1050,20 +1082,20 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1050
1082
|
if (!elementType) {
|
|
1051
1083
|
return null;
|
|
1052
1084
|
}
|
|
1053
|
-
return /* @__PURE__ */
|
|
1085
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1054
1086
|
role: "none",
|
|
1055
1087
|
className: (0, import_react_ui_theme9.mx)(padding)
|
|
1056
|
-
}, /* @__PURE__ */
|
|
1088
|
+
}, /* @__PURE__ */ import_react15.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1057
1089
|
role: "none",
|
|
1058
1090
|
className: "flex flex-col gap-1"
|
|
1059
|
-
}, values.map((_value, index) => /* @__PURE__ */
|
|
1091
|
+
}, values.map((_value, index) => /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1060
1092
|
key: index,
|
|
1061
1093
|
role: "none",
|
|
1062
1094
|
className: "flex items-center gap-1"
|
|
1063
|
-
}, /* @__PURE__ */
|
|
1095
|
+
}, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1064
1096
|
role: "none",
|
|
1065
1097
|
className: "flex-1"
|
|
1066
|
-
}, /* @__PURE__ */
|
|
1098
|
+
}, /* @__PURE__ */ import_react15.default.createElement(FormField, {
|
|
1067
1099
|
property: {
|
|
1068
1100
|
...property,
|
|
1069
1101
|
array: false,
|
|
@@ -1077,15 +1109,15 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1077
1109
|
inline: true,
|
|
1078
1110
|
Custom,
|
|
1079
1111
|
lookupComponent
|
|
1080
|
-
})), /* @__PURE__ */
|
|
1112
|
+
})), /* @__PURE__ */ import_react15.default.createElement(import_react_ui10.IconButton, {
|
|
1081
1113
|
icon: "ph--trash--regular",
|
|
1082
1114
|
iconOnly: true,
|
|
1083
1115
|
label: t("button remove"),
|
|
1084
1116
|
onClick: () => handleRemove(index)
|
|
1085
|
-
})))), /* @__PURE__ */
|
|
1117
|
+
})))), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1086
1118
|
role: "none",
|
|
1087
1119
|
className: "flex justify-between items-center plb-1"
|
|
1088
|
-
}, /* @__PURE__ */
|
|
1120
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui10.IconButton, {
|
|
1089
1121
|
icon: "ph--plus--regular",
|
|
1090
1122
|
iconOnly: true,
|
|
1091
1123
|
label: t("button add"),
|
|
@@ -1095,10 +1127,10 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1095
1127
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/RefField.tsx";
|
|
1096
1128
|
var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOptions, inputProps }) => {
|
|
1097
1129
|
const { getValue: getValue3, onValueChange, ...restInputProps } = inputProps;
|
|
1098
|
-
const refTypeInfo = (0, import_effect8.findAnnotation)(ast,
|
|
1099
|
-
const [refOptions, setRefOptions] = (0,
|
|
1100
|
-
const [loading, setLoading] = (0,
|
|
1101
|
-
(0,
|
|
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)(() => {
|
|
1102
1134
|
if (!refTypeInfo || !onQueryRefOptions) {
|
|
1103
1135
|
return;
|
|
1104
1136
|
}
|
|
@@ -1130,7 +1162,7 @@ var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOpt
|
|
|
1130
1162
|
if (!refTypeInfo) {
|
|
1131
1163
|
return null;
|
|
1132
1164
|
}
|
|
1133
|
-
if (refTypeInfo.typename === (0,
|
|
1165
|
+
if (refTypeInfo.typename === (0, import_echo_schema6.getTypeAnnotation)(import_echo_schema6.Expando)?.typename || !onQueryRefOptions) {
|
|
1134
1166
|
const handleOnValueChange = (_type, dxnString) => {
|
|
1135
1167
|
const dxn = import_keys2.DXN.tryParse(dxnString);
|
|
1136
1168
|
if (dxn) {
|
|
@@ -1146,12 +1178,12 @@ var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOpt
|
|
|
1146
1178
|
if (typeof formValue === "string") {
|
|
1147
1179
|
return formValue;
|
|
1148
1180
|
}
|
|
1149
|
-
if (
|
|
1181
|
+
if (import_echo_schema6.Ref.isRef(formValue)) {
|
|
1150
1182
|
return formValue.dxn.toString();
|
|
1151
1183
|
}
|
|
1152
1184
|
return void 0;
|
|
1153
1185
|
};
|
|
1154
|
-
return /* @__PURE__ */
|
|
1186
|
+
return /* @__PURE__ */ import_react16.default.createElement(TextInput, {
|
|
1155
1187
|
type,
|
|
1156
1188
|
label,
|
|
1157
1189
|
disabled: readonly,
|
|
@@ -1164,7 +1196,7 @@ var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOpt
|
|
|
1164
1196
|
}
|
|
1165
1197
|
const handleGetValue = () => {
|
|
1166
1198
|
const formValue = getValue3();
|
|
1167
|
-
if (
|
|
1199
|
+
if (import_echo_schema6.Ref.isRef(formValue)) {
|
|
1168
1200
|
return formValue.dxn.toString();
|
|
1169
1201
|
}
|
|
1170
1202
|
return void 0;
|
|
@@ -1174,7 +1206,7 @@ var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOpt
|
|
|
1174
1206
|
const ref = (0, import_live_object.refFromDXN)(dxn);
|
|
1175
1207
|
onValueChange("object", ref);
|
|
1176
1208
|
};
|
|
1177
|
-
return /* @__PURE__ */
|
|
1209
|
+
return /* @__PURE__ */ import_react16.default.createElement(SelectInput, {
|
|
1178
1210
|
type,
|
|
1179
1211
|
label,
|
|
1180
1212
|
disabled: readonly || loading,
|
|
@@ -1188,9 +1220,9 @@ var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOpt
|
|
|
1188
1220
|
};
|
|
1189
1221
|
var getInputComponent = (type, format) => {
|
|
1190
1222
|
switch (format) {
|
|
1191
|
-
case
|
|
1223
|
+
case import_echo_schema7.FormatEnum.GeoPoint:
|
|
1192
1224
|
return GeoPointInput;
|
|
1193
|
-
case
|
|
1225
|
+
case import_echo_schema7.FormatEnum.Markdown:
|
|
1194
1226
|
return MarkdownInput;
|
|
1195
1227
|
}
|
|
1196
1228
|
switch (type) {
|
|
@@ -1205,17 +1237,17 @@ var getInputComponent = (type, format) => {
|
|
|
1205
1237
|
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1206
1238
|
const inputProps = useInputProps(path);
|
|
1207
1239
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1208
|
-
const label = (0,
|
|
1240
|
+
const label = (0, import_react14.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
1209
1241
|
title,
|
|
1210
1242
|
name
|
|
1211
1243
|
]);
|
|
1212
|
-
const placeholder = (0,
|
|
1244
|
+
const placeholder = (0, import_react14.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1213
1245
|
examples,
|
|
1214
1246
|
description
|
|
1215
1247
|
]);
|
|
1216
1248
|
const FoundComponent = lookupComponent?.({
|
|
1217
1249
|
prop: name,
|
|
1218
|
-
schema:
|
|
1250
|
+
schema: import_effect4.Schema.make(ast),
|
|
1219
1251
|
inputProps: {
|
|
1220
1252
|
type,
|
|
1221
1253
|
format,
|
|
@@ -1226,14 +1258,14 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1226
1258
|
}
|
|
1227
1259
|
});
|
|
1228
1260
|
if (FoundComponent) {
|
|
1229
|
-
return /* @__PURE__ */
|
|
1261
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1230
1262
|
role: "none"
|
|
1231
1263
|
}, FoundComponent);
|
|
1232
1264
|
}
|
|
1233
1265
|
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1234
1266
|
const CustomComponent = Custom?.[jsonPath];
|
|
1235
1267
|
if (CustomComponent) {
|
|
1236
|
-
return /* @__PURE__ */
|
|
1268
|
+
return /* @__PURE__ */ import_react14.default.createElement(CustomComponent, {
|
|
1237
1269
|
type,
|
|
1238
1270
|
format,
|
|
1239
1271
|
label,
|
|
@@ -1244,7 +1276,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1244
1276
|
});
|
|
1245
1277
|
}
|
|
1246
1278
|
if (array) {
|
|
1247
|
-
return /* @__PURE__ */
|
|
1279
|
+
return /* @__PURE__ */ import_react14.default.createElement(ArrayField, {
|
|
1248
1280
|
property,
|
|
1249
1281
|
path,
|
|
1250
1282
|
inputProps,
|
|
@@ -1254,9 +1286,9 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1254
1286
|
}
|
|
1255
1287
|
const InputComponent = getInputComponent(type, format);
|
|
1256
1288
|
if (InputComponent) {
|
|
1257
|
-
return /* @__PURE__ */
|
|
1289
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1258
1290
|
role: "none"
|
|
1259
|
-
}, /* @__PURE__ */
|
|
1291
|
+
}, /* @__PURE__ */ import_react14.default.createElement(InputComponent, {
|
|
1260
1292
|
type,
|
|
1261
1293
|
format,
|
|
1262
1294
|
label,
|
|
@@ -1267,9 +1299,9 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1267
1299
|
}));
|
|
1268
1300
|
}
|
|
1269
1301
|
if (options) {
|
|
1270
|
-
return /* @__PURE__ */
|
|
1302
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1271
1303
|
role: "none"
|
|
1272
|
-
}, /* @__PURE__ */
|
|
1304
|
+
}, /* @__PURE__ */ import_react14.default.createElement(SelectInput, {
|
|
1273
1305
|
type,
|
|
1274
1306
|
format,
|
|
1275
1307
|
disabled: readonly,
|
|
@@ -1284,7 +1316,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1284
1316
|
}));
|
|
1285
1317
|
}
|
|
1286
1318
|
if (format === "ref") {
|
|
1287
|
-
return /* @__PURE__ */
|
|
1319
|
+
return /* @__PURE__ */ import_react14.default.createElement(RefField, {
|
|
1288
1320
|
ast,
|
|
1289
1321
|
type,
|
|
1290
1322
|
label,
|
|
@@ -1297,14 +1329,14 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1297
1329
|
}
|
|
1298
1330
|
if (type === "object") {
|
|
1299
1331
|
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1300
|
-
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);
|
|
1301
1333
|
if (typeLiteral) {
|
|
1302
|
-
return /* @__PURE__ */
|
|
1334
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1303
1335
|
role: "none"
|
|
1304
|
-
}, !inline && /* @__PURE__ */
|
|
1336
|
+
}, !inline && /* @__PURE__ */ import_react14.default.createElement("h3", {
|
|
1305
1337
|
className: "text-lg mbs-2 mbe-1"
|
|
1306
|
-
}, label), /* @__PURE__ */
|
|
1307
|
-
schema:
|
|
1338
|
+
}, label), /* @__PURE__ */ import_react14.default.createElement(FormFields, {
|
|
1339
|
+
schema: import_effect4.Schema.make(typeLiteral),
|
|
1308
1340
|
path,
|
|
1309
1341
|
readonly,
|
|
1310
1342
|
onQueryRefOptions,
|
|
@@ -1317,7 +1349,7 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1317
1349
|
};
|
|
1318
1350
|
var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1319
1351
|
const values = useFormValues(path);
|
|
1320
|
-
const properties = (0,
|
|
1352
|
+
const properties = (0, import_react14.useMemo)(() => {
|
|
1321
1353
|
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
1322
1354
|
const filtered = filter ? filter(props) : props;
|
|
1323
1355
|
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
@@ -1327,11 +1359,11 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1327
1359
|
filter,
|
|
1328
1360
|
sort
|
|
1329
1361
|
]);
|
|
1330
|
-
return /* @__PURE__ */
|
|
1362
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1331
1363
|
role: "form",
|
|
1332
1364
|
className: (0, import_react_ui_theme8.mx)("flex flex-col w-full gap-2")
|
|
1333
1365
|
}, properties.map((property) => {
|
|
1334
|
-
return /* @__PURE__ */
|
|
1366
|
+
return /* @__PURE__ */ import_react14.default.createElement(FormField, {
|
|
1335
1367
|
key: property.name,
|
|
1336
1368
|
property,
|
|
1337
1369
|
path: [
|
|
@@ -1343,7 +1375,7 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1343
1375
|
lookupComponent,
|
|
1344
1376
|
Custom
|
|
1345
1377
|
});
|
|
1346
|
-
}).filter(
|
|
1378
|
+
}).filter(import_util4.isNotFalsy));
|
|
1347
1379
|
};
|
|
1348
1380
|
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1349
1381
|
const formRef = (0, import_react9.useRef)(null);
|
|
@@ -1548,22 +1580,22 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1548
1580
|
};
|
|
1549
1581
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1550
1582
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1551
|
-
var ViewMetaSchema =
|
|
1552
|
-
name:
|
|
1553
|
-
[
|
|
1583
|
+
var ViewMetaSchema = import_effect9.Schema.Struct({
|
|
1584
|
+
name: import_effect9.Schema.String.annotations({
|
|
1585
|
+
[import_effect9.SchemaAST.TitleAnnotationId]: "View"
|
|
1554
1586
|
}),
|
|
1555
|
-
typename:
|
|
1556
|
-
[
|
|
1587
|
+
typename: import_echo_schema8.Format.URL.annotations({
|
|
1588
|
+
[import_effect9.SchemaAST.TitleAnnotationId]: "Typename"
|
|
1557
1589
|
})
|
|
1558
|
-
}).pipe(
|
|
1590
|
+
}).pipe(import_effect9.Schema.mutable);
|
|
1559
1591
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1560
1592
|
const { t } = (0, import_react_ui11.useTranslation)(translationKey);
|
|
1561
|
-
const projection = (0,
|
|
1593
|
+
const projection = (0, import_react17.useMemo)(() => new import_schema5.ViewProjection(schema.jsonSchema, view), [
|
|
1562
1594
|
schema,
|
|
1563
1595
|
view
|
|
1564
1596
|
]);
|
|
1565
|
-
const [field, setField] = (0,
|
|
1566
|
-
const viewValues = (0,
|
|
1597
|
+
const [field, setField] = (0, import_react17.useState)();
|
|
1598
|
+
const viewValues = (0, import_react17.useMemo)(() => {
|
|
1567
1599
|
return {
|
|
1568
1600
|
name: view.name,
|
|
1569
1601
|
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
@@ -1573,13 +1605,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1573
1605
|
}, [
|
|
1574
1606
|
view
|
|
1575
1607
|
]);
|
|
1576
|
-
const handleSelect = (0,
|
|
1608
|
+
const handleSelect = (0, import_react17.useCallback)((field2) => {
|
|
1577
1609
|
setField((f) => f === field2 ? void 0 : field2);
|
|
1578
1610
|
}, []);
|
|
1579
|
-
const handleAdd = (0,
|
|
1611
|
+
const handleAdd = (0, import_react17.useCallback)(() => {
|
|
1580
1612
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1581
1613
|
F: __dxlog_file5,
|
|
1582
|
-
L:
|
|
1614
|
+
L: 77,
|
|
1583
1615
|
S: void 0,
|
|
1584
1616
|
A: [
|
|
1585
1617
|
"!schema.readonly",
|
|
@@ -1592,10 +1624,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1592
1624
|
schema,
|
|
1593
1625
|
view
|
|
1594
1626
|
]);
|
|
1595
|
-
const handleUpdate = (0,
|
|
1627
|
+
const handleUpdate = (0, import_react17.useCallback)(({ name, typename }) => {
|
|
1596
1628
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1597
1629
|
F: __dxlog_file5,
|
|
1598
|
-
L:
|
|
1630
|
+
L: 84,
|
|
1599
1631
|
S: void 0,
|
|
1600
1632
|
A: [
|
|
1601
1633
|
"!schema.readonly",
|
|
@@ -1615,10 +1647,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1615
1647
|
view,
|
|
1616
1648
|
onTypenameChanged
|
|
1617
1649
|
]);
|
|
1618
|
-
const handleDelete = (0,
|
|
1650
|
+
const handleDelete = (0, import_react17.useCallback)((fieldId) => {
|
|
1619
1651
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1620
1652
|
F: __dxlog_file5,
|
|
1621
|
-
L:
|
|
1653
|
+
L: 100,
|
|
1622
1654
|
S: void 0,
|
|
1623
1655
|
A: [
|
|
1624
1656
|
"!schema.readonly",
|
|
@@ -1634,10 +1666,10 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1634
1666
|
field,
|
|
1635
1667
|
onDelete
|
|
1636
1668
|
]);
|
|
1637
|
-
const handleMove = (0,
|
|
1669
|
+
const handleMove = (0, import_react17.useCallback)((fromIndex, toIndex) => {
|
|
1638
1670
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1639
1671
|
F: __dxlog_file5,
|
|
1640
|
-
L:
|
|
1672
|
+
L: 112,
|
|
1641
1673
|
S: void 0,
|
|
1642
1674
|
A: [
|
|
1643
1675
|
"!schema.readonly",
|
|
@@ -1654,95 +1686,95 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1654
1686
|
schema,
|
|
1655
1687
|
view.fields
|
|
1656
1688
|
]);
|
|
1657
|
-
const handleClose = (0,
|
|
1689
|
+
const handleClose = (0, import_react17.useCallback)(() => setField(void 0), []);
|
|
1658
1690
|
const hiddenProperties = projection.getHiddenProperties();
|
|
1659
|
-
const handleHide = (0,
|
|
1691
|
+
const handleHide = (0, import_react17.useCallback)((fieldId) => {
|
|
1660
1692
|
setField(void 0);
|
|
1661
1693
|
projection.hideFieldProjection(fieldId);
|
|
1662
1694
|
}, [
|
|
1663
1695
|
projection
|
|
1664
1696
|
]);
|
|
1665
|
-
const handleShow = (0,
|
|
1697
|
+
const handleShow = (0, import_react17.useCallback)((property) => {
|
|
1666
1698
|
setField(void 0);
|
|
1667
1699
|
projection.showFieldProjection(property);
|
|
1668
1700
|
}, [
|
|
1669
1701
|
projection
|
|
1670
1702
|
]);
|
|
1671
|
-
return /* @__PURE__ */
|
|
1703
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1672
1704
|
role: "none",
|
|
1673
1705
|
className: (0, import_react_ui_theme10.mx)("grid grid-rows-[1fr_1fr] min-bs-0", classNames)
|
|
1674
|
-
}, /* @__PURE__ */
|
|
1706
|
+
}, /* @__PURE__ */ import_react17.default.createElement(Form, {
|
|
1675
1707
|
autoSave: true,
|
|
1676
1708
|
schema: ViewMetaSchema,
|
|
1677
1709
|
values: viewValues,
|
|
1678
1710
|
onSave: schema.readonly ? void 0 : handleUpdate,
|
|
1679
1711
|
classNames: "min-bs-0 overflow-y-auto"
|
|
1680
|
-
}), /* @__PURE__ */
|
|
1712
|
+
}), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1681
1713
|
role: "none",
|
|
1682
1714
|
className: "border-bs border-separator min-bs-0 overflow-y-auto"
|
|
1683
|
-
}, /* @__PURE__ */
|
|
1715
|
+
}, /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1684
1716
|
role: "none",
|
|
1685
1717
|
className: "p-2"
|
|
1686
|
-
}, /* @__PURE__ */
|
|
1718
|
+
}, /* @__PURE__ */ import_react17.default.createElement("label", {
|
|
1687
1719
|
className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
|
|
1688
|
-
}, t("fields label"))), /* @__PURE__ */
|
|
1720
|
+
}, t("fields label"))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Root, {
|
|
1689
1721
|
items: view.fields,
|
|
1690
|
-
isItem:
|
|
1722
|
+
isItem: import_effect9.Schema.is(import_schema5.FieldSchema),
|
|
1691
1723
|
getId: (field2) => field2.id,
|
|
1692
1724
|
onMove: schema.readonly ? void 0 : handleMove
|
|
1693
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
1725
|
+
}, ({ items: fields }) => /* @__PURE__ */ import_react17.default.createElement(import_react17.default.Fragment, null, showHeading && /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1694
1726
|
role: "heading",
|
|
1695
1727
|
className: grid
|
|
1696
|
-
}, /* @__PURE__ */
|
|
1728
|
+
}, /* @__PURE__ */ import_react17.default.createElement("div", null), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1697
1729
|
className: "flex items-center text-sm"
|
|
1698
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1730
|
+
}, t("field path label"))), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1699
1731
|
role: "list",
|
|
1700
1732
|
className: "flex flex-col w-full"
|
|
1701
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1733
|
+
}, fields?.map((field2) => /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Item, {
|
|
1702
1734
|
key: field2.id,
|
|
1703
1735
|
item: field2,
|
|
1704
1736
|
classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
|
|
1705
|
-
}, /* @__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, {
|
|
1706
1738
|
onClick: () => handleSelect(field2)
|
|
1707
|
-
}, field2.path), /* @__PURE__ */
|
|
1739
|
+
}, field2.path), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1708
1740
|
className: "flex items-center gap-2 -ml-4"
|
|
1709
|
-
}, /* @__PURE__ */
|
|
1741
|
+
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1710
1742
|
icon: "ph--eye-slash--regular",
|
|
1711
1743
|
disabled: view.fields.length <= 1,
|
|
1712
1744
|
onClick: () => handleHide(field2.id)
|
|
1713
|
-
}), !schema.readonly && /* @__PURE__ */
|
|
1745
|
+
}), !schema.readonly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
1714
1746
|
icon: "ph--trash--regular",
|
|
1715
1747
|
disabled: view.fields.length <= 1,
|
|
1716
1748
|
onClick: () => handleDelete(field2.id)
|
|
1717
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1749
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react17.default.createElement("div", null, /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1718
1750
|
role: "none",
|
|
1719
1751
|
className: "p-2"
|
|
1720
|
-
}, /* @__PURE__ */
|
|
1752
|
+
}, /* @__PURE__ */ import_react17.default.createElement("label", {
|
|
1721
1753
|
className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
|
|
1722
|
-
}, t("hidden fields label"))), /* @__PURE__ */
|
|
1754
|
+
}, t("hidden fields label"))), /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Root, {
|
|
1723
1755
|
items: hiddenProperties,
|
|
1724
1756
|
isItem: (item) => typeof item === "string",
|
|
1725
1757
|
getId: (property) => property
|
|
1726
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1758
|
+
}, ({ items: properties }) => /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1727
1759
|
role: "list",
|
|
1728
1760
|
className: "flex flex-col w-full"
|
|
1729
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1761
|
+
}, properties?.map((property) => /* @__PURE__ */ import_react17.default.createElement(import_react_ui_list2.List.Item, {
|
|
1730
1762
|
key: property,
|
|
1731
1763
|
item: property,
|
|
1732
1764
|
classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
|
|
1733
|
-
}, /* @__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, {
|
|
1734
1766
|
icon: "ph--eye--regular",
|
|
1735
1767
|
onClick: () => handleShow(property)
|
|
1736
|
-
}))))))), field && /* @__PURE__ */
|
|
1768
|
+
}))))))), field && /* @__PURE__ */ import_react17.default.createElement(FieldEditor, {
|
|
1737
1769
|
key: field.id,
|
|
1738
1770
|
view,
|
|
1739
1771
|
projection,
|
|
1740
1772
|
field,
|
|
1741
1773
|
registry,
|
|
1742
1774
|
onSave: handleClose
|
|
1743
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1775
|
+
}), !readonly && !field && /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1744
1776
|
className: "flex p-2 justify-center"
|
|
1745
|
-
}, /* @__PURE__ */
|
|
1777
|
+
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.IconButton, {
|
|
1746
1778
|
icon: "ph--plus--regular",
|
|
1747
1779
|
label: t("button add property"),
|
|
1748
1780
|
onClick: schema.readonly ? void 0 : handleAdd,
|
|
@@ -1756,7 +1788,7 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1756
1788
|
}
|
|
1757
1789
|
const parseScalar = (type2) => {
|
|
1758
1790
|
switch (type2) {
|
|
1759
|
-
case
|
|
1791
|
+
case import_echo_schema9.TypeEnum.Boolean: {
|
|
1760
1792
|
if (typeof value === "string") {
|
|
1761
1793
|
const lowercaseValue = value.toLowerCase();
|
|
1762
1794
|
if (lowercaseValue === "0" || lowercaseValue === "false") {
|
|
@@ -1767,13 +1799,13 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1767
1799
|
}
|
|
1768
1800
|
return Boolean(value);
|
|
1769
1801
|
}
|
|
1770
|
-
case
|
|
1802
|
+
case import_echo_schema9.TypeEnum.Number: {
|
|
1771
1803
|
const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
|
|
1772
1804
|
const num = Number(cleaned);
|
|
1773
1805
|
return Number.isNaN(num) ? null : num;
|
|
1774
1806
|
}
|
|
1775
|
-
case
|
|
1776
|
-
case
|
|
1807
|
+
case import_echo_schema9.TypeEnum.String:
|
|
1808
|
+
case import_echo_schema9.TypeEnum.Ref:
|
|
1777
1809
|
return String(value);
|
|
1778
1810
|
default: {
|
|
1779
1811
|
return value;
|
|
@@ -1784,26 +1816,26 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1784
1816
|
return parseScalar(type);
|
|
1785
1817
|
}
|
|
1786
1818
|
switch (format) {
|
|
1787
|
-
case
|
|
1788
|
-
return parseScalar(
|
|
1789
|
-
case
|
|
1790
|
-
case
|
|
1791
|
-
case
|
|
1792
|
-
return parseScalar(
|
|
1793
|
-
case
|
|
1794
|
-
case
|
|
1795
|
-
return parseScalar(
|
|
1819
|
+
case import_echo_schema9.FormatEnum.Boolean:
|
|
1820
|
+
return parseScalar(import_echo_schema9.TypeEnum.Boolean);
|
|
1821
|
+
case import_echo_schema9.FormatEnum.Number:
|
|
1822
|
+
case import_echo_schema9.FormatEnum.Percent:
|
|
1823
|
+
case import_echo_schema9.FormatEnum.Currency:
|
|
1824
|
+
return parseScalar(import_echo_schema9.TypeEnum.Number);
|
|
1825
|
+
case import_echo_schema9.FormatEnum.String:
|
|
1826
|
+
case import_echo_schema9.FormatEnum.Markdown: {
|
|
1827
|
+
return parseScalar(import_echo_schema9.TypeEnum.String);
|
|
1796
1828
|
}
|
|
1797
|
-
case
|
|
1798
|
-
throw new Error(`unexpected format: ${
|
|
1799
|
-
case
|
|
1800
|
-
case
|
|
1801
|
-
case
|
|
1802
|
-
case
|
|
1829
|
+
case import_echo_schema9.FormatEnum.Ref:
|
|
1830
|
+
throw new Error(`unexpected format: ${import_echo_schema9.FormatEnum.Ref}`);
|
|
1831
|
+
case import_echo_schema9.FormatEnum.DateTime:
|
|
1832
|
+
case import_echo_schema9.FormatEnum.Date:
|
|
1833
|
+
case import_echo_schema9.FormatEnum.Time:
|
|
1834
|
+
case import_echo_schema9.FormatEnum.Timestamp: {
|
|
1803
1835
|
const date = new Date(value);
|
|
1804
1836
|
return isNaN(date.getTime()) ? null : date;
|
|
1805
1837
|
}
|
|
1806
|
-
case
|
|
1838
|
+
case import_echo_schema9.FormatEnum.GeoPoint: {
|
|
1807
1839
|
if (typeof value === "string") {
|
|
1808
1840
|
const cleaned = value.replace(/[^0-9.,-]+/g, "");
|
|
1809
1841
|
const parts = cleaned.split(",");
|
|
@@ -1811,7 +1843,7 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1811
1843
|
const lat = parseFloat(parts[0]);
|
|
1812
1844
|
const long = parseFloat(parts[1]);
|
|
1813
1845
|
if (!isNaN(lat) && !isNaN(long)) {
|
|
1814
|
-
return
|
|
1846
|
+
return import_echo_schema9.GeoLocation.toGeoPoint({
|
|
1815
1847
|
latitude: lat,
|
|
1816
1848
|
longitude: long
|
|
1817
1849
|
});
|
|
@@ -1831,19 +1863,19 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1831
1863
|
var cellClassesForFieldType = ({ type, format }) => {
|
|
1832
1864
|
if (!format) {
|
|
1833
1865
|
switch (type) {
|
|
1834
|
-
case
|
|
1866
|
+
case import_echo_schema9.TypeEnum.Number:
|
|
1835
1867
|
return [
|
|
1836
1868
|
"text-right",
|
|
1837
1869
|
"font-mono"
|
|
1838
1870
|
];
|
|
1839
|
-
case
|
|
1871
|
+
case import_echo_schema9.TypeEnum.Boolean:
|
|
1840
1872
|
return [
|
|
1841
1873
|
"text-right",
|
|
1842
1874
|
"font-mono"
|
|
1843
1875
|
];
|
|
1844
|
-
case
|
|
1876
|
+
case import_echo_schema9.TypeEnum.String:
|
|
1845
1877
|
return void 0;
|
|
1846
|
-
case
|
|
1878
|
+
case import_echo_schema9.TypeEnum.Ref:
|
|
1847
1879
|
return void 0;
|
|
1848
1880
|
default: {
|
|
1849
1881
|
return void 0;
|
|
@@ -1851,23 +1883,23 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1851
1883
|
}
|
|
1852
1884
|
}
|
|
1853
1885
|
switch (format) {
|
|
1854
|
-
case
|
|
1886
|
+
case import_echo_schema9.FormatEnum.Markdown:
|
|
1855
1887
|
return void 0;
|
|
1856
|
-
case
|
|
1857
|
-
case
|
|
1858
|
-
case
|
|
1859
|
-
case
|
|
1860
|
-
case
|
|
1888
|
+
case import_echo_schema9.FormatEnum.Time:
|
|
1889
|
+
case import_echo_schema9.FormatEnum.Timestamp:
|
|
1890
|
+
case import_echo_schema9.FormatEnum.DateTime:
|
|
1891
|
+
case import_echo_schema9.FormatEnum.Date:
|
|
1892
|
+
case import_echo_schema9.FormatEnum.Duration:
|
|
1861
1893
|
return [
|
|
1862
1894
|
"font-mono",
|
|
1863
1895
|
"text-right"
|
|
1864
1896
|
];
|
|
1865
|
-
case
|
|
1897
|
+
case import_echo_schema9.FormatEnum.Currency:
|
|
1866
1898
|
return [
|
|
1867
1899
|
"text-right"
|
|
1868
1900
|
];
|
|
1869
|
-
case
|
|
1870
|
-
case
|
|
1901
|
+
case import_echo_schema9.FormatEnum.JSON:
|
|
1902
|
+
case import_echo_schema9.FormatEnum.DID:
|
|
1871
1903
|
return [
|
|
1872
1904
|
"font-mono"
|
|
1873
1905
|
];
|
|
@@ -1882,12 +1914,12 @@ var pathNotUniqueError = (path) => ({
|
|
|
1882
1914
|
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1883
1915
|
const formatScalar = (type2) => {
|
|
1884
1916
|
switch (type2) {
|
|
1885
|
-
case
|
|
1917
|
+
case import_echo_schema10.TypeEnum.Boolean:
|
|
1886
1918
|
return value.toLocaleString().toUpperCase();
|
|
1887
|
-
case
|
|
1919
|
+
case import_echo_schema10.TypeEnum.Number:
|
|
1888
1920
|
return value.toLocaleString(locale);
|
|
1889
|
-
case
|
|
1890
|
-
case
|
|
1921
|
+
case import_echo_schema10.TypeEnum.String:
|
|
1922
|
+
case import_echo_schema10.TypeEnum.Ref:
|
|
1891
1923
|
return String(value);
|
|
1892
1924
|
default: {
|
|
1893
1925
|
return String(value);
|
|
@@ -1898,20 +1930,20 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1898
1930
|
return formatScalar(type);
|
|
1899
1931
|
}
|
|
1900
1932
|
switch (format) {
|
|
1901
|
-
case
|
|
1902
|
-
return formatScalar(
|
|
1933
|
+
case import_echo_schema10.FormatEnum.Boolean: {
|
|
1934
|
+
return formatScalar(import_echo_schema10.TypeEnum.Boolean);
|
|
1903
1935
|
}
|
|
1904
|
-
case
|
|
1905
|
-
return formatScalar(
|
|
1936
|
+
case import_echo_schema10.FormatEnum.Number: {
|
|
1937
|
+
return formatScalar(import_echo_schema10.TypeEnum.Number);
|
|
1906
1938
|
}
|
|
1907
|
-
case
|
|
1908
|
-
case
|
|
1909
|
-
return formatScalar(
|
|
1939
|
+
case import_echo_schema10.FormatEnum.String:
|
|
1940
|
+
case import_echo_schema10.FormatEnum.Ref: {
|
|
1941
|
+
return formatScalar(import_echo_schema10.TypeEnum.String);
|
|
1910
1942
|
}
|
|
1911
|
-
case
|
|
1943
|
+
case import_echo_schema10.FormatEnum.Percent: {
|
|
1912
1944
|
return `${value * 100}%`;
|
|
1913
1945
|
}
|
|
1914
|
-
case
|
|
1946
|
+
case import_echo_schema10.FormatEnum.Currency: {
|
|
1915
1947
|
return value.toLocaleString(locale, {
|
|
1916
1948
|
style: "currency",
|
|
1917
1949
|
currency: "USD",
|
|
@@ -1919,33 +1951,33 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1919
1951
|
maximumFractionDigits: 2
|
|
1920
1952
|
});
|
|
1921
1953
|
}
|
|
1922
|
-
case
|
|
1954
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1923
1955
|
try {
|
|
1924
1956
|
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1925
1957
|
} catch (error) {
|
|
1926
1958
|
return "Invalid Date";
|
|
1927
1959
|
}
|
|
1928
1960
|
}
|
|
1929
|
-
case
|
|
1961
|
+
case import_echo_schema10.FormatEnum.Time: {
|
|
1930
1962
|
try {
|
|
1931
1963
|
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1932
1964
|
} catch (error) {
|
|
1933
1965
|
return "Invalid Time";
|
|
1934
1966
|
}
|
|
1935
1967
|
}
|
|
1936
|
-
case
|
|
1968
|
+
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1937
1969
|
try {
|
|
1938
1970
|
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1939
1971
|
} catch (error) {
|
|
1940
1972
|
return "Invalid DateTime";
|
|
1941
1973
|
}
|
|
1942
1974
|
}
|
|
1943
|
-
case
|
|
1975
|
+
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1944
1976
|
if (value === null || value === void 0) {
|
|
1945
1977
|
return "";
|
|
1946
1978
|
}
|
|
1947
1979
|
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1948
|
-
const { latitude, longitude } =
|
|
1980
|
+
const { latitude, longitude } = import_echo_schema10.GeoLocation.fromGeoPoint(value);
|
|
1949
1981
|
return `${latitude},${longitude}`;
|
|
1950
1982
|
}
|
|
1951
1983
|
return String(value);
|
|
@@ -1961,10 +1993,10 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1961
1993
|
var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
1962
1994
|
const formatScalar = (type2) => {
|
|
1963
1995
|
switch (type2) {
|
|
1964
|
-
case
|
|
1965
|
-
case
|
|
1966
|
-
case
|
|
1967
|
-
case
|
|
1996
|
+
case import_echo_schema10.TypeEnum.Boolean:
|
|
1997
|
+
case import_echo_schema10.TypeEnum.Number:
|
|
1998
|
+
case import_echo_schema10.TypeEnum.String:
|
|
1999
|
+
case import_echo_schema10.TypeEnum.Ref:
|
|
1968
2000
|
return String(value);
|
|
1969
2001
|
default:
|
|
1970
2002
|
return String(value);
|
|
@@ -1974,36 +2006,36 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1974
2006
|
return formatScalar(type);
|
|
1975
2007
|
}
|
|
1976
2008
|
switch (format) {
|
|
1977
|
-
case
|
|
1978
|
-
case
|
|
1979
|
-
case
|
|
1980
|
-
case
|
|
2009
|
+
case import_echo_schema10.FormatEnum.Boolean:
|
|
2010
|
+
case import_echo_schema10.FormatEnum.Number:
|
|
2011
|
+
case import_echo_schema10.FormatEnum.String:
|
|
2012
|
+
case import_echo_schema10.FormatEnum.Ref: {
|
|
1981
2013
|
return formatScalar(type);
|
|
1982
2014
|
}
|
|
1983
|
-
case
|
|
2015
|
+
case import_echo_schema10.FormatEnum.Percent: {
|
|
1984
2016
|
return String(value * 100);
|
|
1985
2017
|
}
|
|
1986
|
-
case
|
|
2018
|
+
case import_echo_schema10.FormatEnum.Currency: {
|
|
1987
2019
|
return String(value);
|
|
1988
2020
|
}
|
|
1989
|
-
case
|
|
2021
|
+
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1990
2022
|
const date = new Date(value);
|
|
1991
2023
|
return date.toISOString();
|
|
1992
2024
|
}
|
|
1993
|
-
case
|
|
2025
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1994
2026
|
const date = new Date(value);
|
|
1995
2027
|
return date.toISOString().split("T")[0];
|
|
1996
2028
|
}
|
|
1997
|
-
case
|
|
2029
|
+
case import_echo_schema10.FormatEnum.Time: {
|
|
1998
2030
|
const date = new Date(value);
|
|
1999
2031
|
return date.toISOString().split("T")[1].split(".")[0];
|
|
2000
2032
|
}
|
|
2001
|
-
case
|
|
2033
|
+
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
2002
2034
|
if (value === null || value === void 0) {
|
|
2003
2035
|
return "";
|
|
2004
2036
|
}
|
|
2005
2037
|
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
2006
|
-
const { latitude, longitude } =
|
|
2038
|
+
const { latitude, longitude } = import_echo_schema10.GeoLocation.fromGeoPoint(value);
|
|
2007
2039
|
return `${latitude},${longitude}`;
|
|
2008
2040
|
}
|
|
2009
2041
|
return String(value);
|
|
@@ -2049,6 +2081,7 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
2049
2081
|
useForm,
|
|
2050
2082
|
useFormContext,
|
|
2051
2083
|
useFormValues,
|
|
2052
|
-
useInputProps
|
|
2084
|
+
useInputProps,
|
|
2085
|
+
useRefQueryLookupHandler
|
|
2053
2086
|
});
|
|
2054
2087
|
//# sourceMappingURL=index.cjs.map
|