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