@dxos/react-ui-form 0.8.2-main.f11618f → 0.8.2-staging.7ac8446
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 +102 -253
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +161 -312
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +102 -253
- 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 → ControlSection.d.ts} +5 -8
- package/dist/types/src/components/ControlSection.d.ts.map +1 -0
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +1 -3
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +2 -4
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +10 -13
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts +2 -2
- package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
- package/dist/types/src/components/Form/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/index.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/package.json +24 -24
- package/src/components/{ControlSection/ControlSection.tsx → ControlSection.tsx} +14 -38
- package/src/components/Form/ArrayField.tsx +1 -3
- package/src/components/Form/Form.stories.tsx +5 -48
- package/src/components/Form/Form.tsx +0 -4
- package/src/components/Form/FormContent.tsx +15 -59
- package/src/components/Form/FormContext.tsx +2 -10
- package/src/components/Form/custom/GeoPointInput.tsx +2 -2
- package/src/components/Form/custom/SelectOptionsInput.tsx +2 -2
- package/src/components/deprecated/Form.stories.tsx +6 -6
- package/src/components/deprecated/FormInput.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/util/formatting.ts +3 -15
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts +0 -8
- package/dist/types/src/components/ControlSection/ControlSection.stories.d.ts.map +0 -1
- package/dist/types/src/components/ControlSection/index.d.ts +0 -2
- package/dist/types/src/components/ControlSection/index.d.ts.map +0 -1
- package/dist/types/src/components/Form/RefField.d.ts +0 -23
- package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
- package/src/components/ControlSection/ControlSection.stories.tsx +0 -29
- package/src/components/ControlSection/index.ts +0 -5
- package/src/components/Form/RefField.tsx +0 -151
package/dist/lib/node/index.cjs
CHANGED
|
@@ -32,10 +32,8 @@ __export(node_exports, {
|
|
|
32
32
|
ControlFrame: () => ControlFrame,
|
|
33
33
|
ControlFrameItem: () => ControlFrameItem,
|
|
34
34
|
ControlGroup: () => ControlGroup,
|
|
35
|
-
ControlGroupButton: () => ControlGroupButton,
|
|
36
35
|
ControlItem: () => ControlItem,
|
|
37
36
|
ControlItemInput: () => ControlItemInput,
|
|
38
|
-
ControlPage: () => ControlPage,
|
|
39
37
|
ControlSection: () => ControlSection,
|
|
40
38
|
ControlSectionHeading: () => ControlSectionHeading,
|
|
41
39
|
DeprecatedFormContainer: () => DeprecatedFormContainer,
|
|
@@ -70,7 +68,6 @@ var import_react_ui = require("@dxos/react-ui");
|
|
|
70
68
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
71
69
|
var import_react2 = __toESM(require("react"));
|
|
72
70
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
73
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
74
71
|
var import_react3 = __toESM(require("react"));
|
|
75
72
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
76
73
|
var import_log = require("@dxos/log");
|
|
@@ -82,24 +79,24 @@ var import_react_ui4 = require("@dxos/react-ui");
|
|
|
82
79
|
var import_util = require("@dxos/util");
|
|
83
80
|
var import_react5 = __toESM(require("react"));
|
|
84
81
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
85
|
-
var
|
|
82
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
86
83
|
var import_react6 = __toESM(require("react"));
|
|
87
84
|
var import_keys = require("@dxos/keys");
|
|
88
85
|
var import_react_ui6 = require("@dxos/react-ui");
|
|
89
86
|
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
90
87
|
var import_react_ui_pickers = require("@dxos/react-ui-pickers");
|
|
91
|
-
var
|
|
88
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
92
89
|
var import_react7 = __toESM(require("react"));
|
|
93
90
|
var import_react_ui7 = require("@dxos/react-ui");
|
|
94
|
-
var
|
|
91
|
+
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
95
92
|
var import_util2 = require("@dxos/util");
|
|
96
93
|
var import_react8 = __toESM(require("react"));
|
|
97
94
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
98
95
|
var import_react9 = __toESM(require("react"));
|
|
99
|
-
var
|
|
96
|
+
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
100
97
|
var import_react10 = __toESM(require("react"));
|
|
101
98
|
var import_react_ui9 = require("@dxos/react-ui");
|
|
102
|
-
var
|
|
99
|
+
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
103
100
|
var import_react11 = __toESM(require("react"));
|
|
104
101
|
var import_debug = require("@dxos/debug");
|
|
105
102
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
@@ -116,7 +113,7 @@ var import_String = require("effect/String");
|
|
|
116
113
|
var import_react13 = __toESM(require("react"));
|
|
117
114
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
118
115
|
var import_effect5 = require("@dxos/effect");
|
|
119
|
-
var
|
|
116
|
+
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
|
120
117
|
var import_schema3 = require("@dxos/schema");
|
|
121
118
|
var import_util3 = require("@dxos/util");
|
|
122
119
|
var import_effect6 = require("effect");
|
|
@@ -126,25 +123,19 @@ var import_echo_schema6 = require("@dxos/echo-schema");
|
|
|
126
123
|
var import_effect7 = require("@dxos/effect");
|
|
127
124
|
var import_invariant2 = require("@dxos/invariant");
|
|
128
125
|
var import_react_ui10 = require("@dxos/react-ui");
|
|
129
|
-
var
|
|
126
|
+
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
|
130
127
|
var import_schema4 = require("@dxos/schema");
|
|
131
|
-
var import_react15 = __toESM(require("react"));
|
|
132
128
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
133
|
-
var
|
|
134
|
-
var import_keys2 = require("@dxos/keys");
|
|
135
|
-
var import_live_object = require("@dxos/live-object");
|
|
136
|
-
var import_log3 = require("@dxos/log");
|
|
129
|
+
var import_react15 = __toESM(require("react"));
|
|
137
130
|
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
131
|
var import_invariant3 = require("@dxos/invariant");
|
|
141
132
|
var import_react_ui11 = require("@dxos/react-ui");
|
|
142
133
|
var import_react_ui_list2 = require("@dxos/react-ui-list");
|
|
143
|
-
var
|
|
134
|
+
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
144
135
|
var import_schema5 = require("@dxos/schema");
|
|
145
|
-
var
|
|
136
|
+
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
146
137
|
var import_format = require("date-fns/format");
|
|
147
|
-
var
|
|
138
|
+
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
148
139
|
var translationKey = "react-ui-form";
|
|
149
140
|
var translations_default = [
|
|
150
141
|
{
|
|
@@ -206,7 +197,7 @@ var translations_default = [
|
|
|
206
197
|
var DeprecatedFormContainer = ({ children, classNames }) => {
|
|
207
198
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
208
199
|
role: "none",
|
|
209
|
-
className: "
|
|
200
|
+
className: "w-full p-4 justify-center overflow-x-hidden overflow-y-auto"
|
|
210
201
|
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
211
202
|
role: "form",
|
|
212
203
|
className: (0, import_react_ui_theme.mx)("flex flex-col", import_react_ui_theme.textBlockWidth, classNames)
|
|
@@ -239,19 +230,6 @@ var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
|
239
230
|
}
|
|
240
231
|
return primary;
|
|
241
232
|
};
|
|
242
|
-
var ControlPage = ({ children, classNames, ...props }) => {
|
|
243
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
244
|
-
role: "none",
|
|
245
|
-
className: (0, import_react_ui_theme2.mx)("pli-2", classNames),
|
|
246
|
-
...props
|
|
247
|
-
}, children);
|
|
248
|
-
};
|
|
249
|
-
var ControlSection = ({ title, description, children }) => {
|
|
250
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(ControlSectionHeading, {
|
|
251
|
-
title,
|
|
252
|
-
description
|
|
253
|
-
}), children);
|
|
254
|
-
};
|
|
255
233
|
var ControlSectionHeading = ({ title, description }) => {
|
|
256
234
|
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
257
235
|
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
|
|
@@ -260,18 +238,15 @@ var ControlSectionHeading = ({ title, description }) => {
|
|
|
260
238
|
className: "pli-4 mlb-4 container-max-width text-description"
|
|
261
239
|
}, (0, import_react_ui2.toLocalizedString)(description, t)));
|
|
262
240
|
};
|
|
263
|
-
var
|
|
264
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
classNames
|
|
269
|
-
]
|
|
270
|
-
});
|
|
241
|
+
var ControlSection = ({ title, description, children }) => {
|
|
242
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(ControlSectionHeading, {
|
|
243
|
+
title,
|
|
244
|
+
description
|
|
245
|
+
}), children);
|
|
271
246
|
};
|
|
272
|
-
var ControlGroup = ({ children
|
|
247
|
+
var ControlGroup = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
273
248
|
role: "none",
|
|
274
|
-
className:
|
|
249
|
+
className: "group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4"
|
|
275
250
|
}, children);
|
|
276
251
|
var ControlFrame = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
277
252
|
role: "none",
|
|
@@ -324,7 +299,7 @@ var InputHeader = ({ children, error }) => {
|
|
|
324
299
|
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Icon, {
|
|
325
300
|
icon: "ph--warning--regular",
|
|
326
301
|
size: 4,
|
|
327
|
-
classNames:
|
|
302
|
+
classNames: import_react_ui_theme2.errorText
|
|
328
303
|
})), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Content, {
|
|
329
304
|
side: "bottom"
|
|
330
305
|
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Arrow, null), error)));
|
|
@@ -416,13 +391,13 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
416
391
|
]);
|
|
417
392
|
const randomHue = () => {
|
|
418
393
|
const usedHues = new Set(options?.map((option) => option.color) ?? []);
|
|
419
|
-
const unusedHues =
|
|
394
|
+
const unusedHues = import_react_ui_theme3.hues.filter((hue) => !usedHues.has(hue));
|
|
420
395
|
if (unusedHues.length > 0) {
|
|
421
396
|
return unusedHues[Math.floor(Math.random() * unusedHues.length)];
|
|
422
397
|
}
|
|
423
398
|
const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
|
|
424
|
-
const availableHues =
|
|
425
|
-
return availableHues[Math.floor(Math.random() * availableHues.length)] ??
|
|
399
|
+
const availableHues = import_react_ui_theme3.hues.filter((hue) => !lastThree.has(hue));
|
|
400
|
+
return availableHues[Math.floor(Math.random() * availableHues.length)] ?? import_react_ui_theme3.hues[Math.floor(Math.random() * import_react_ui_theme3.hues.length)];
|
|
426
401
|
};
|
|
427
402
|
const handleAdd = (0, import_react6.useCallback)(() => {
|
|
428
403
|
const newId = import_keys.PublicKey.random().truncate();
|
|
@@ -523,7 +498,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
523
498
|
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Item, {
|
|
524
499
|
role: "button",
|
|
525
500
|
item,
|
|
526
|
-
classNames: (0,
|
|
501
|
+
classNames: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
527
502
|
"aria-expanded": selected === item.id
|
|
528
503
|
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
529
504
|
className: "flex items-center"
|
|
@@ -564,7 +539,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
564
539
|
role: "listitem"
|
|
565
540
|
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
566
541
|
role: "button",
|
|
567
|
-
className: (0,
|
|
542
|
+
className: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
568
543
|
onClick: handleAdd
|
|
569
544
|
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
570
545
|
className: "flex items-center gap-1"
|
|
@@ -588,7 +563,7 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
588
563
|
}, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
|
|
589
564
|
error
|
|
590
565
|
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
591
|
-
className: (0,
|
|
566
|
+
className: (0, import_react_ui_theme4.mx)("grid gap-2", gridCols[binding.length - 1])
|
|
592
567
|
}, binding.map((prop) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.TextInput, {
|
|
593
568
|
key: prop,
|
|
594
569
|
type: "number",
|
|
@@ -973,7 +948,7 @@ var FormActions = ({ onCancel, readonly }) => {
|
|
|
973
948
|
className: "mt-2 flex justify-center"
|
|
974
949
|
}, /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
975
950
|
role: "none",
|
|
976
|
-
className: (0,
|
|
951
|
+
className: (0, import_react_ui_theme6.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
|
|
977
952
|
}, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
978
953
|
"data-testid": "cancel-button",
|
|
979
954
|
icon: "ph--x--regular",
|
|
@@ -993,10 +968,10 @@ var padding = "px-2";
|
|
|
993
968
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
994
969
|
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
995
970
|
const { ast, name, type, title } = property;
|
|
996
|
-
const values = useFormValues(path ?? [])
|
|
971
|
+
const values = useFormValues(path ?? []);
|
|
997
972
|
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
998
973
|
F: __dxlog_file2,
|
|
999
|
-
L:
|
|
974
|
+
L: 37,
|
|
1000
975
|
S: void 0,
|
|
1001
976
|
A: [
|
|
1002
977
|
"Array.isArray(values)",
|
|
@@ -1052,7 +1027,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1052
1027
|
}
|
|
1053
1028
|
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1054
1029
|
role: "none",
|
|
1055
|
-
className: (0,
|
|
1030
|
+
className: (0, import_react_ui_theme8.mx)(padding)
|
|
1056
1031
|
}, /* @__PURE__ */ import_react14.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1057
1032
|
role: "none",
|
|
1058
1033
|
className: "flex flex-col gap-1"
|
|
@@ -1092,105 +1067,11 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
1092
1067
|
onClick: handleAdd
|
|
1093
1068
|
})));
|
|
1094
1069
|
};
|
|
1095
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/RefField.tsx";
|
|
1096
|
-
var RefField = ({ ast, type, label, readonly, placeholder, inline, onQueryRefOptions, inputProps }) => {
|
|
1097
|
-
const { getValue: getValue3, onValueChange, ...restInputProps } = inputProps;
|
|
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)(() => {
|
|
1102
|
-
if (!refTypeInfo || !onQueryRefOptions) {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
const fetchOptions = async () => {
|
|
1106
|
-
setLoading(true);
|
|
1107
|
-
try {
|
|
1108
|
-
const options = await onQueryRefOptions(refTypeInfo);
|
|
1109
|
-
setRefOptions(options.map((option) => ({
|
|
1110
|
-
label: option.label,
|
|
1111
|
-
value: option.dxn.toString()
|
|
1112
|
-
})));
|
|
1113
|
-
} catch (error) {
|
|
1114
|
-
import_log3.log.error("Failed to fetch ref options:", error, {
|
|
1115
|
-
F: __dxlog_file3,
|
|
1116
|
-
L: 68,
|
|
1117
|
-
S: void 0,
|
|
1118
|
-
C: (f, a) => f(...a)
|
|
1119
|
-
});
|
|
1120
|
-
setRefOptions([]);
|
|
1121
|
-
} finally {
|
|
1122
|
-
setLoading(false);
|
|
1123
|
-
}
|
|
1124
|
-
};
|
|
1125
|
-
void fetchOptions();
|
|
1126
|
-
}, [
|
|
1127
|
-
refTypeInfo,
|
|
1128
|
-
onQueryRefOptions
|
|
1129
|
-
]);
|
|
1130
|
-
if (!refTypeInfo) {
|
|
1131
|
-
return null;
|
|
1132
|
-
}
|
|
1133
|
-
if (refTypeInfo.typename === (0, import_echo_schema7.getTypeAnnotation)(import_echo_schema7.Expando)?.typename || !onQueryRefOptions) {
|
|
1134
|
-
const handleOnValueChange = (_type, dxnString) => {
|
|
1135
|
-
const dxn = import_keys2.DXN.tryParse(dxnString);
|
|
1136
|
-
if (dxn) {
|
|
1137
|
-
onValueChange?.("object", (0, import_live_object.refFromDXN)(dxn));
|
|
1138
|
-
} else if (dxnString === "") {
|
|
1139
|
-
onValueChange?.("object", void 0);
|
|
1140
|
-
} else {
|
|
1141
|
-
onValueChange?.("string", dxnString);
|
|
1142
|
-
}
|
|
1143
|
-
};
|
|
1144
|
-
const handleGetValue2 = () => {
|
|
1145
|
-
const formValue = getValue3();
|
|
1146
|
-
if (typeof formValue === "string") {
|
|
1147
|
-
return formValue;
|
|
1148
|
-
}
|
|
1149
|
-
if (formValue instanceof import_live_object.RefImpl) {
|
|
1150
|
-
return formValue.dxn.toString();
|
|
1151
|
-
}
|
|
1152
|
-
return void 0;
|
|
1153
|
-
};
|
|
1154
|
-
return /* @__PURE__ */ import_react15.default.createElement(TextInput, {
|
|
1155
|
-
type,
|
|
1156
|
-
label,
|
|
1157
|
-
disabled: readonly,
|
|
1158
|
-
placeholder,
|
|
1159
|
-
inputOnly: inline,
|
|
1160
|
-
getValue: handleGetValue2,
|
|
1161
|
-
onValueChange: handleOnValueChange,
|
|
1162
|
-
...restInputProps
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
const handleGetValue = () => {
|
|
1166
|
-
const formValue = getValue3();
|
|
1167
|
-
if (formValue instanceof import_live_object.RefImpl) {
|
|
1168
|
-
return formValue.dxn.toString();
|
|
1169
|
-
}
|
|
1170
|
-
return void 0;
|
|
1171
|
-
};
|
|
1172
|
-
const handleValueChanged = (_type, dxnString) => {
|
|
1173
|
-
const dxn = import_keys2.DXN.parse(dxnString);
|
|
1174
|
-
const ref = (0, import_live_object.refFromDXN)(dxn);
|
|
1175
|
-
onValueChange("object", ref);
|
|
1176
|
-
};
|
|
1177
|
-
return /* @__PURE__ */ import_react15.default.createElement(SelectInput, {
|
|
1178
|
-
type,
|
|
1179
|
-
label,
|
|
1180
|
-
disabled: readonly || loading,
|
|
1181
|
-
placeholder: loading ? "Loading options..." : placeholder,
|
|
1182
|
-
inputOnly: inline,
|
|
1183
|
-
getValue: handleGetValue,
|
|
1184
|
-
onValueChange: handleValueChanged,
|
|
1185
|
-
options: refOptions,
|
|
1186
|
-
...restInputProps
|
|
1187
|
-
});
|
|
1188
|
-
};
|
|
1189
1070
|
var getInputComponent = (type, format) => {
|
|
1190
1071
|
switch (format) {
|
|
1191
|
-
case
|
|
1072
|
+
case import_echo_schema7.FormatEnum.GeoPoint:
|
|
1192
1073
|
return GeoPointInput;
|
|
1193
|
-
case
|
|
1074
|
+
case import_echo_schema7.FormatEnum.Markdown:
|
|
1194
1075
|
return MarkdownInput;
|
|
1195
1076
|
}
|
|
1196
1077
|
switch (type) {
|
|
@@ -1202,7 +1083,7 @@ var getInputComponent = (type, format) => {
|
|
|
1202
1083
|
return BooleanInput;
|
|
1203
1084
|
}
|
|
1204
1085
|
};
|
|
1205
|
-
var FormField = ({ property, path, readonly, inline,
|
|
1086
|
+
var FormField = ({ property, path, readonly, inline, lookupComponent, Custom }) => {
|
|
1206
1087
|
const inputProps = useInputProps(path);
|
|
1207
1088
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1208
1089
|
const label = (0, import_react13.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
@@ -1283,39 +1164,23 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1283
1164
|
...inputProps
|
|
1284
1165
|
}));
|
|
1285
1166
|
}
|
|
1286
|
-
if (format === "ref") {
|
|
1287
|
-
return /* @__PURE__ */ import_react13.default.createElement(RefField, {
|
|
1288
|
-
ast,
|
|
1289
|
-
type,
|
|
1290
|
-
label,
|
|
1291
|
-
readonly,
|
|
1292
|
-
placeholder,
|
|
1293
|
-
inline,
|
|
1294
|
-
onQueryRefOptions,
|
|
1295
|
-
inputProps
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
1167
|
if (type === "object") {
|
|
1299
1168
|
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1300
1169
|
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_echo_schema5.AST.isTypeLiteral);
|
|
1301
1170
|
if (typeLiteral) {
|
|
1302
1171
|
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1303
1172
|
role: "none"
|
|
1304
|
-
}, !inline && /* @__PURE__ */ import_react13.default.createElement("
|
|
1305
|
-
className: "text-lg mbs-2 mbe-1"
|
|
1306
|
-
}, label), /* @__PURE__ */ import_react13.default.createElement(FormFields, {
|
|
1173
|
+
}, !inline && /* @__PURE__ */ import_react13.default.createElement("div", null, label), /* @__PURE__ */ import_react13.default.createElement(FormFields, {
|
|
1307
1174
|
schema: import_echo_schema5.S.make(typeLiteral),
|
|
1308
1175
|
path,
|
|
1309
1176
|
readonly,
|
|
1310
|
-
|
|
1311
|
-
Custom,
|
|
1312
|
-
lookupComponent
|
|
1177
|
+
Custom
|
|
1313
1178
|
}));
|
|
1314
1179
|
}
|
|
1315
1180
|
}
|
|
1316
1181
|
return null;
|
|
1317
1182
|
};
|
|
1318
|
-
var FormFields = ({ schema, path, filter, sort, readonly,
|
|
1183
|
+
var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custom }) => {
|
|
1319
1184
|
const values = useFormValues(path);
|
|
1320
1185
|
const properties = (0, import_react13.useMemo)(() => {
|
|
1321
1186
|
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
@@ -1329,7 +1194,7 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1329
1194
|
]);
|
|
1330
1195
|
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1331
1196
|
role: "form",
|
|
1332
|
-
className: (0,
|
|
1197
|
+
className: (0, import_react_ui_theme7.mx)("flex flex-col w-full gap-2")
|
|
1333
1198
|
}, properties.map((property) => {
|
|
1334
1199
|
return /* @__PURE__ */ import_react13.default.createElement(FormField, {
|
|
1335
1200
|
key: property.name,
|
|
@@ -1339,13 +1204,12 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1339
1204
|
property.name
|
|
1340
1205
|
],
|
|
1341
1206
|
readonly,
|
|
1342
|
-
onQueryRefOptions,
|
|
1343
1207
|
lookupComponent,
|
|
1344
1208
|
Custom
|
|
1345
1209
|
});
|
|
1346
1210
|
}).filter(import_util3.isNotFalsy));
|
|
1347
1211
|
};
|
|
1348
|
-
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel,
|
|
1212
|
+
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, lookupComponent, Custom }) => {
|
|
1349
1213
|
const formRef = (0, import_react9.useRef)(null);
|
|
1350
1214
|
const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
|
|
1351
1215
|
autoSave,
|
|
@@ -1373,7 +1237,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1373
1237
|
}, /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
1374
1238
|
ref: formRef,
|
|
1375
1239
|
role: "none",
|
|
1376
|
-
className: (0,
|
|
1240
|
+
className: (0, import_react_ui_theme5.mx)("p-2", classNames),
|
|
1377
1241
|
"data-testid": testId
|
|
1378
1242
|
}, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
|
|
1379
1243
|
schema,
|
|
@@ -1381,7 +1245,6 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1381
1245
|
readonly,
|
|
1382
1246
|
filter,
|
|
1383
1247
|
sort,
|
|
1384
|
-
onQueryRefOptions,
|
|
1385
1248
|
lookupComponent,
|
|
1386
1249
|
Custom
|
|
1387
1250
|
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
@@ -1389,7 +1252,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1389
1252
|
readonly
|
|
1390
1253
|
})));
|
|
1391
1254
|
};
|
|
1392
|
-
var
|
|
1255
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1393
1256
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1394
1257
|
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
1395
1258
|
const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
|
|
@@ -1522,7 +1385,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1522
1385
|
import_log.log.warn("invalid format", {
|
|
1523
1386
|
props
|
|
1524
1387
|
}, {
|
|
1525
|
-
F:
|
|
1388
|
+
F: __dxlog_file3,
|
|
1526
1389
|
L: 174,
|
|
1527
1390
|
S: void 0,
|
|
1528
1391
|
C: (f, a) => f(...a)
|
|
@@ -1546,24 +1409,24 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1546
1409
|
Custom
|
|
1547
1410
|
});
|
|
1548
1411
|
};
|
|
1549
|
-
var
|
|
1412
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1550
1413
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1551
|
-
var ViewMetaSchema =
|
|
1552
|
-
name:
|
|
1553
|
-
[
|
|
1414
|
+
var ViewMetaSchema = import_echo_schema8.S.Struct({
|
|
1415
|
+
name: import_echo_schema8.S.String.annotations({
|
|
1416
|
+
[import_echo_schema8.AST.TitleAnnotationId]: "View"
|
|
1554
1417
|
}),
|
|
1555
|
-
typename:
|
|
1556
|
-
[
|
|
1418
|
+
typename: import_echo_schema8.Format.URL.annotations({
|
|
1419
|
+
[import_echo_schema8.AST.TitleAnnotationId]: "Typename"
|
|
1557
1420
|
})
|
|
1558
|
-
}).pipe(
|
|
1421
|
+
}).pipe(import_echo_schema8.S.mutable);
|
|
1559
1422
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1560
1423
|
const { t } = (0, import_react_ui11.useTranslation)(translationKey);
|
|
1561
|
-
const projection = (0,
|
|
1424
|
+
const projection = (0, import_react15.useMemo)(() => new import_schema5.ViewProjection(schema.jsonSchema, view), [
|
|
1562
1425
|
schema,
|
|
1563
1426
|
view
|
|
1564
1427
|
]);
|
|
1565
|
-
const [field, setField] = (0,
|
|
1566
|
-
const viewValues = (0,
|
|
1428
|
+
const [field, setField] = (0, import_react15.useState)();
|
|
1429
|
+
const viewValues = (0, import_react15.useMemo)(() => {
|
|
1567
1430
|
return {
|
|
1568
1431
|
name: view.name,
|
|
1569
1432
|
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
@@ -1573,12 +1436,12 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1573
1436
|
}, [
|
|
1574
1437
|
view
|
|
1575
1438
|
]);
|
|
1576
|
-
const handleSelect = (0,
|
|
1439
|
+
const handleSelect = (0, import_react15.useCallback)((field2) => {
|
|
1577
1440
|
setField((f) => f === field2 ? void 0 : field2);
|
|
1578
1441
|
}, []);
|
|
1579
|
-
const handleAdd = (0,
|
|
1442
|
+
const handleAdd = (0, import_react15.useCallback)(() => {
|
|
1580
1443
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1581
|
-
F:
|
|
1444
|
+
F: __dxlog_file4,
|
|
1582
1445
|
L: 76,
|
|
1583
1446
|
S: void 0,
|
|
1584
1447
|
A: [
|
|
@@ -1592,9 +1455,9 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1592
1455
|
schema,
|
|
1593
1456
|
view
|
|
1594
1457
|
]);
|
|
1595
|
-
const handleUpdate = (0,
|
|
1458
|
+
const handleUpdate = (0, import_react15.useCallback)(({ name, typename }) => {
|
|
1596
1459
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1597
|
-
F:
|
|
1460
|
+
F: __dxlog_file4,
|
|
1598
1461
|
L: 83,
|
|
1599
1462
|
S: void 0,
|
|
1600
1463
|
A: [
|
|
@@ -1615,9 +1478,9 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1615
1478
|
view,
|
|
1616
1479
|
onTypenameChanged
|
|
1617
1480
|
]);
|
|
1618
|
-
const handleDelete = (0,
|
|
1481
|
+
const handleDelete = (0, import_react15.useCallback)((fieldId) => {
|
|
1619
1482
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1620
|
-
F:
|
|
1483
|
+
F: __dxlog_file4,
|
|
1621
1484
|
L: 99,
|
|
1622
1485
|
S: void 0,
|
|
1623
1486
|
A: [
|
|
@@ -1634,9 +1497,9 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1634
1497
|
field,
|
|
1635
1498
|
onDelete
|
|
1636
1499
|
]);
|
|
1637
|
-
const handleMove = (0,
|
|
1500
|
+
const handleMove = (0, import_react15.useCallback)((fromIndex, toIndex) => {
|
|
1638
1501
|
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1639
|
-
F:
|
|
1502
|
+
F: __dxlog_file4,
|
|
1640
1503
|
L: 111,
|
|
1641
1504
|
S: void 0,
|
|
1642
1505
|
A: [
|
|
@@ -1654,91 +1517,91 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1654
1517
|
schema,
|
|
1655
1518
|
view.fields
|
|
1656
1519
|
]);
|
|
1657
|
-
const handleClose = (0,
|
|
1520
|
+
const handleClose = (0, import_react15.useCallback)(() => setField(void 0), []);
|
|
1658
1521
|
const hiddenProperties = projection.getHiddenProperties();
|
|
1659
|
-
const handleHide = (0,
|
|
1522
|
+
const handleHide = (0, import_react15.useCallback)((fieldId) => {
|
|
1660
1523
|
setField(void 0);
|
|
1661
1524
|
projection.hideFieldProjection(fieldId);
|
|
1662
1525
|
}, [
|
|
1663
1526
|
projection
|
|
1664
1527
|
]);
|
|
1665
|
-
const handleShow = (0,
|
|
1528
|
+
const handleShow = (0, import_react15.useCallback)((property) => {
|
|
1666
1529
|
setField(void 0);
|
|
1667
1530
|
projection.showFieldProjection(property);
|
|
1668
1531
|
}, [
|
|
1669
1532
|
projection
|
|
1670
1533
|
]);
|
|
1671
|
-
return /* @__PURE__ */
|
|
1534
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1672
1535
|
role: "none",
|
|
1673
|
-
className: (0,
|
|
1674
|
-
}, /* @__PURE__ */
|
|
1536
|
+
className: (0, import_react_ui_theme9.mx)("flex flex-col w-full divide-y divide-separator", classNames)
|
|
1537
|
+
}, /* @__PURE__ */ import_react15.default.createElement(Form, {
|
|
1675
1538
|
autoSave: true,
|
|
1676
1539
|
schema: ViewMetaSchema,
|
|
1677
1540
|
values: viewValues,
|
|
1678
1541
|
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1679
|
-
}), /* @__PURE__ */
|
|
1542
|
+
}), /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1680
1543
|
role: "none",
|
|
1681
1544
|
className: "p-2"
|
|
1682
|
-
}, /* @__PURE__ */
|
|
1683
|
-
className: (0,
|
|
1684
|
-
}, t("fields label"))), /* @__PURE__ */
|
|
1545
|
+
}, /* @__PURE__ */ import_react15.default.createElement("label", {
|
|
1546
|
+
className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
|
|
1547
|
+
}, t("fields label"))), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Root, {
|
|
1685
1548
|
items: view.fields,
|
|
1686
|
-
isItem:
|
|
1549
|
+
isItem: import_echo_schema8.S.is(import_schema5.FieldSchema),
|
|
1687
1550
|
getId: (field2) => field2.id,
|
|
1688
1551
|
onMove: schema.readonly ? void 0 : handleMove
|
|
1689
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
1552
|
+
}, ({ items: fields }) => /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, showHeading && /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1690
1553
|
role: "heading",
|
|
1691
1554
|
className: grid
|
|
1692
|
-
}, /* @__PURE__ */
|
|
1555
|
+
}, /* @__PURE__ */ import_react15.default.createElement("div", null), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1693
1556
|
className: "flex items-center text-sm"
|
|
1694
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1557
|
+
}, t("field path label"))), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1695
1558
|
role: "list",
|
|
1696
1559
|
className: "flex flex-col w-full"
|
|
1697
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1560
|
+
}, fields?.map((field2) => /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Item, {
|
|
1698
1561
|
key: field2.id,
|
|
1699
1562
|
item: field2,
|
|
1700
|
-
classNames: (0,
|
|
1701
|
-
}, /* @__PURE__ */
|
|
1563
|
+
classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, "cursor-pointer")
|
|
1564
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemTitle, {
|
|
1702
1565
|
onClick: () => handleSelect(field2)
|
|
1703
|
-
}, field2.path), /* @__PURE__ */
|
|
1566
|
+
}, field2.path), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1704
1567
|
className: "flex items-center gap-2 -ml-4"
|
|
1705
|
-
}, /* @__PURE__ */
|
|
1568
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1706
1569
|
icon: "ph--eye-slash--regular",
|
|
1707
1570
|
disabled: view.fields.length <= 1,
|
|
1708
1571
|
onClick: () => handleHide(field2.id)
|
|
1709
|
-
}), !schema.readonly && /* @__PURE__ */
|
|
1572
|
+
}), !schema.readonly && /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
1710
1573
|
icon: "ph--trash--regular",
|
|
1711
1574
|
disabled: view.fields.length <= 1,
|
|
1712
1575
|
onClick: () => handleDelete(field2.id)
|
|
1713
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1576
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1714
1577
|
role: "none",
|
|
1715
1578
|
className: "p-2"
|
|
1716
|
-
}, /* @__PURE__ */
|
|
1717
|
-
className: (0,
|
|
1718
|
-
}, t("hidden fields label"))), /* @__PURE__ */
|
|
1579
|
+
}, /* @__PURE__ */ import_react15.default.createElement("label", {
|
|
1580
|
+
className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
|
|
1581
|
+
}, t("hidden fields label"))), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Root, {
|
|
1719
1582
|
items: hiddenProperties,
|
|
1720
1583
|
isItem: (item) => typeof item === "string",
|
|
1721
1584
|
getId: (property) => property
|
|
1722
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1585
|
+
}, ({ items: properties }) => /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1723
1586
|
role: "list",
|
|
1724
1587
|
className: "flex flex-col w-full"
|
|
1725
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1588
|
+
}, properties?.map((property) => /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Item, {
|
|
1726
1589
|
key: property,
|
|
1727
1590
|
item: property,
|
|
1728
|
-
classNames: (0,
|
|
1729
|
-
}, /* @__PURE__ */
|
|
1591
|
+
classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, "cursor-pointer")
|
|
1592
|
+
}, /* @__PURE__ */ import_react15.default.createElement("div", null), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemTitle, null, property), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1730
1593
|
icon: "ph--eye--regular",
|
|
1731
1594
|
onClick: () => handleShow(property)
|
|
1732
|
-
}))))))), field && /* @__PURE__ */
|
|
1595
|
+
}))))))), field && /* @__PURE__ */ import_react15.default.createElement(FieldEditor, {
|
|
1733
1596
|
key: field.id,
|
|
1734
1597
|
view,
|
|
1735
1598
|
projection,
|
|
1736
1599
|
field,
|
|
1737
1600
|
registry,
|
|
1738
1601
|
onSave: handleClose
|
|
1739
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1602
|
+
}), !readonly && !field && /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1740
1603
|
className: "flex p-2 justify-center"
|
|
1741
|
-
}, /* @__PURE__ */
|
|
1604
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui11.IconButton, {
|
|
1742
1605
|
icon: "ph--plus--regular",
|
|
1743
1606
|
label: t("button add property"),
|
|
1744
1607
|
onClick: schema.readonly ? void 0 : handleAdd,
|
|
@@ -1752,7 +1615,7 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1752
1615
|
}
|
|
1753
1616
|
const parseScalar = (type2) => {
|
|
1754
1617
|
switch (type2) {
|
|
1755
|
-
case
|
|
1618
|
+
case import_echo_schema9.TypeEnum.Boolean: {
|
|
1756
1619
|
if (typeof value === "string") {
|
|
1757
1620
|
const lowercaseValue = value.toLowerCase();
|
|
1758
1621
|
if (lowercaseValue === "0" || lowercaseValue === "false") {
|
|
@@ -1763,13 +1626,13 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1763
1626
|
}
|
|
1764
1627
|
return Boolean(value);
|
|
1765
1628
|
}
|
|
1766
|
-
case
|
|
1629
|
+
case import_echo_schema9.TypeEnum.Number: {
|
|
1767
1630
|
const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
|
|
1768
1631
|
const num = Number(cleaned);
|
|
1769
1632
|
return Number.isNaN(num) ? null : num;
|
|
1770
1633
|
}
|
|
1771
|
-
case
|
|
1772
|
-
case
|
|
1634
|
+
case import_echo_schema9.TypeEnum.String:
|
|
1635
|
+
case import_echo_schema9.TypeEnum.Ref:
|
|
1773
1636
|
return String(value);
|
|
1774
1637
|
default: {
|
|
1775
1638
|
return value;
|
|
@@ -1780,26 +1643,26 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1780
1643
|
return parseScalar(type);
|
|
1781
1644
|
}
|
|
1782
1645
|
switch (format) {
|
|
1783
|
-
case
|
|
1784
|
-
return parseScalar(
|
|
1785
|
-
case
|
|
1786
|
-
case
|
|
1787
|
-
case
|
|
1788
|
-
return parseScalar(
|
|
1789
|
-
case
|
|
1790
|
-
case
|
|
1791
|
-
return parseScalar(
|
|
1646
|
+
case import_echo_schema9.FormatEnum.Boolean:
|
|
1647
|
+
return parseScalar(import_echo_schema9.TypeEnum.Boolean);
|
|
1648
|
+
case import_echo_schema9.FormatEnum.Number:
|
|
1649
|
+
case import_echo_schema9.FormatEnum.Percent:
|
|
1650
|
+
case import_echo_schema9.FormatEnum.Currency:
|
|
1651
|
+
return parseScalar(import_echo_schema9.TypeEnum.Number);
|
|
1652
|
+
case import_echo_schema9.FormatEnum.String:
|
|
1653
|
+
case import_echo_schema9.FormatEnum.Markdown: {
|
|
1654
|
+
return parseScalar(import_echo_schema9.TypeEnum.String);
|
|
1792
1655
|
}
|
|
1793
|
-
case
|
|
1794
|
-
throw new Error(`unexpected format: ${
|
|
1795
|
-
case
|
|
1796
|
-
case
|
|
1797
|
-
case
|
|
1798
|
-
case
|
|
1656
|
+
case import_echo_schema9.FormatEnum.Ref:
|
|
1657
|
+
throw new Error(`unexpected format: ${import_echo_schema9.FormatEnum.Ref}`);
|
|
1658
|
+
case import_echo_schema9.FormatEnum.DateTime:
|
|
1659
|
+
case import_echo_schema9.FormatEnum.Date:
|
|
1660
|
+
case import_echo_schema9.FormatEnum.Time:
|
|
1661
|
+
case import_echo_schema9.FormatEnum.Timestamp: {
|
|
1799
1662
|
const date = new Date(value);
|
|
1800
1663
|
return isNaN(date.getTime()) ? null : date;
|
|
1801
1664
|
}
|
|
1802
|
-
case
|
|
1665
|
+
case import_echo_schema9.FormatEnum.GeoPoint: {
|
|
1803
1666
|
if (typeof value === "string") {
|
|
1804
1667
|
const cleaned = value.replace(/[^0-9.,-]+/g, "");
|
|
1805
1668
|
const parts = cleaned.split(",");
|
|
@@ -1807,7 +1670,7 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1807
1670
|
const lat = parseFloat(parts[0]);
|
|
1808
1671
|
const long = parseFloat(parts[1]);
|
|
1809
1672
|
if (!isNaN(lat) && !isNaN(long)) {
|
|
1810
|
-
return
|
|
1673
|
+
return import_echo_schema9.GeoLocation.toGeoPoint({
|
|
1811
1674
|
latitude: lat,
|
|
1812
1675
|
longitude: long
|
|
1813
1676
|
});
|
|
@@ -1827,19 +1690,19 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1827
1690
|
var cellClassesForFieldType = ({ type, format }) => {
|
|
1828
1691
|
if (!format) {
|
|
1829
1692
|
switch (type) {
|
|
1830
|
-
case
|
|
1693
|
+
case import_echo_schema9.TypeEnum.Number:
|
|
1831
1694
|
return [
|
|
1832
1695
|
"text-right",
|
|
1833
1696
|
"font-mono"
|
|
1834
1697
|
];
|
|
1835
|
-
case
|
|
1698
|
+
case import_echo_schema9.TypeEnum.Boolean:
|
|
1836
1699
|
return [
|
|
1837
1700
|
"text-right",
|
|
1838
1701
|
"font-mono"
|
|
1839
1702
|
];
|
|
1840
|
-
case
|
|
1703
|
+
case import_echo_schema9.TypeEnum.String:
|
|
1841
1704
|
return void 0;
|
|
1842
|
-
case
|
|
1705
|
+
case import_echo_schema9.TypeEnum.Ref:
|
|
1843
1706
|
return void 0;
|
|
1844
1707
|
default: {
|
|
1845
1708
|
return void 0;
|
|
@@ -1847,23 +1710,23 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1847
1710
|
}
|
|
1848
1711
|
}
|
|
1849
1712
|
switch (format) {
|
|
1850
|
-
case
|
|
1713
|
+
case import_echo_schema9.FormatEnum.Markdown:
|
|
1851
1714
|
return void 0;
|
|
1852
|
-
case
|
|
1853
|
-
case
|
|
1854
|
-
case
|
|
1855
|
-
case
|
|
1856
|
-
case
|
|
1715
|
+
case import_echo_schema9.FormatEnum.Time:
|
|
1716
|
+
case import_echo_schema9.FormatEnum.Timestamp:
|
|
1717
|
+
case import_echo_schema9.FormatEnum.DateTime:
|
|
1718
|
+
case import_echo_schema9.FormatEnum.Date:
|
|
1719
|
+
case import_echo_schema9.FormatEnum.Duration:
|
|
1857
1720
|
return [
|
|
1858
1721
|
"font-mono",
|
|
1859
1722
|
"text-right"
|
|
1860
1723
|
];
|
|
1861
|
-
case
|
|
1724
|
+
case import_echo_schema9.FormatEnum.Currency:
|
|
1862
1725
|
return [
|
|
1863
1726
|
"text-right"
|
|
1864
1727
|
];
|
|
1865
|
-
case
|
|
1866
|
-
case
|
|
1728
|
+
case import_echo_schema9.FormatEnum.JSON:
|
|
1729
|
+
case import_echo_schema9.FormatEnum.DID:
|
|
1867
1730
|
return [
|
|
1868
1731
|
"font-mono"
|
|
1869
1732
|
];
|
|
@@ -1878,12 +1741,12 @@ var pathNotUniqueError = (path) => ({
|
|
|
1878
1741
|
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1879
1742
|
const formatScalar = (type2) => {
|
|
1880
1743
|
switch (type2) {
|
|
1881
|
-
case
|
|
1744
|
+
case import_echo_schema10.TypeEnum.Boolean:
|
|
1882
1745
|
return value.toLocaleString().toUpperCase();
|
|
1883
|
-
case
|
|
1746
|
+
case import_echo_schema10.TypeEnum.Number:
|
|
1884
1747
|
return value.toLocaleString(locale);
|
|
1885
|
-
case
|
|
1886
|
-
case
|
|
1748
|
+
case import_echo_schema10.TypeEnum.String:
|
|
1749
|
+
case import_echo_schema10.TypeEnum.Ref:
|
|
1887
1750
|
return String(value);
|
|
1888
1751
|
default: {
|
|
1889
1752
|
return String(value);
|
|
@@ -1894,20 +1757,20 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1894
1757
|
return formatScalar(type);
|
|
1895
1758
|
}
|
|
1896
1759
|
switch (format) {
|
|
1897
|
-
case
|
|
1898
|
-
return formatScalar(
|
|
1760
|
+
case import_echo_schema10.FormatEnum.Boolean: {
|
|
1761
|
+
return formatScalar(import_echo_schema10.TypeEnum.Boolean);
|
|
1899
1762
|
}
|
|
1900
|
-
case
|
|
1901
|
-
return formatScalar(
|
|
1763
|
+
case import_echo_schema10.FormatEnum.Number: {
|
|
1764
|
+
return formatScalar(import_echo_schema10.TypeEnum.Number);
|
|
1902
1765
|
}
|
|
1903
|
-
case
|
|
1904
|
-
case
|
|
1905
|
-
return formatScalar(
|
|
1766
|
+
case import_echo_schema10.FormatEnum.String:
|
|
1767
|
+
case import_echo_schema10.FormatEnum.Ref: {
|
|
1768
|
+
return formatScalar(import_echo_schema10.TypeEnum.String);
|
|
1906
1769
|
}
|
|
1907
|
-
case
|
|
1770
|
+
case import_echo_schema10.FormatEnum.Percent: {
|
|
1908
1771
|
return `${value * 100}%`;
|
|
1909
1772
|
}
|
|
1910
|
-
case
|
|
1773
|
+
case import_echo_schema10.FormatEnum.Currency: {
|
|
1911
1774
|
return value.toLocaleString(locale, {
|
|
1912
1775
|
style: "currency",
|
|
1913
1776
|
currency: "USD",
|
|
@@ -1915,33 +1778,21 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1915
1778
|
maximumFractionDigits: 2
|
|
1916
1779
|
});
|
|
1917
1780
|
}
|
|
1918
|
-
case
|
|
1919
|
-
|
|
1920
|
-
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1921
|
-
} catch (error) {
|
|
1922
|
-
return "Invalid Date";
|
|
1923
|
-
}
|
|
1781
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1782
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1924
1783
|
}
|
|
1925
|
-
case
|
|
1926
|
-
|
|
1927
|
-
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1928
|
-
} catch (error) {
|
|
1929
|
-
return "Invalid Time";
|
|
1930
|
-
}
|
|
1784
|
+
case import_echo_schema10.FormatEnum.Time: {
|
|
1785
|
+
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1931
1786
|
}
|
|
1932
|
-
case
|
|
1933
|
-
|
|
1934
|
-
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1935
|
-
} catch (error) {
|
|
1936
|
-
return "Invalid DateTime";
|
|
1937
|
-
}
|
|
1787
|
+
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1788
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1938
1789
|
}
|
|
1939
|
-
case
|
|
1790
|
+
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1940
1791
|
if (value === null || value === void 0) {
|
|
1941
1792
|
return "";
|
|
1942
1793
|
}
|
|
1943
1794
|
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1944
|
-
const { latitude, longitude } =
|
|
1795
|
+
const { latitude, longitude } = import_echo_schema10.GeoLocation.fromGeoPoint(value);
|
|
1945
1796
|
return `${latitude},${longitude}`;
|
|
1946
1797
|
}
|
|
1947
1798
|
return String(value);
|
|
@@ -1957,10 +1808,10 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1957
1808
|
var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
1958
1809
|
const formatScalar = (type2) => {
|
|
1959
1810
|
switch (type2) {
|
|
1960
|
-
case
|
|
1961
|
-
case
|
|
1962
|
-
case
|
|
1963
|
-
case
|
|
1811
|
+
case import_echo_schema10.TypeEnum.Boolean:
|
|
1812
|
+
case import_echo_schema10.TypeEnum.Number:
|
|
1813
|
+
case import_echo_schema10.TypeEnum.String:
|
|
1814
|
+
case import_echo_schema10.TypeEnum.Ref:
|
|
1964
1815
|
return String(value);
|
|
1965
1816
|
default:
|
|
1966
1817
|
return String(value);
|
|
@@ -1970,36 +1821,36 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1970
1821
|
return formatScalar(type);
|
|
1971
1822
|
}
|
|
1972
1823
|
switch (format) {
|
|
1973
|
-
case
|
|
1974
|
-
case
|
|
1975
|
-
case
|
|
1976
|
-
case
|
|
1824
|
+
case import_echo_schema10.FormatEnum.Boolean:
|
|
1825
|
+
case import_echo_schema10.FormatEnum.Number:
|
|
1826
|
+
case import_echo_schema10.FormatEnum.String:
|
|
1827
|
+
case import_echo_schema10.FormatEnum.Ref: {
|
|
1977
1828
|
return formatScalar(type);
|
|
1978
1829
|
}
|
|
1979
|
-
case
|
|
1830
|
+
case import_echo_schema10.FormatEnum.Percent: {
|
|
1980
1831
|
return String(value * 100);
|
|
1981
1832
|
}
|
|
1982
|
-
case
|
|
1833
|
+
case import_echo_schema10.FormatEnum.Currency: {
|
|
1983
1834
|
return String(value);
|
|
1984
1835
|
}
|
|
1985
|
-
case
|
|
1836
|
+
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1986
1837
|
const date = new Date(value);
|
|
1987
1838
|
return date.toISOString();
|
|
1988
1839
|
}
|
|
1989
|
-
case
|
|
1840
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1990
1841
|
const date = new Date(value);
|
|
1991
1842
|
return date.toISOString().split("T")[0];
|
|
1992
1843
|
}
|
|
1993
|
-
case
|
|
1844
|
+
case import_echo_schema10.FormatEnum.Time: {
|
|
1994
1845
|
const date = new Date(value);
|
|
1995
1846
|
return date.toISOString().split("T")[1].split(".")[0];
|
|
1996
1847
|
}
|
|
1997
|
-
case
|
|
1848
|
+
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1998
1849
|
if (value === null || value === void 0) {
|
|
1999
1850
|
return "";
|
|
2000
1851
|
}
|
|
2001
1852
|
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
2002
|
-
const { latitude, longitude } =
|
|
1853
|
+
const { latitude, longitude } = import_echo_schema10.GeoLocation.fromGeoPoint(value);
|
|
2003
1854
|
return `${latitude},${longitude}`;
|
|
2004
1855
|
}
|
|
2005
1856
|
return String(value);
|
|
@@ -2015,10 +1866,8 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
2015
1866
|
ControlFrame,
|
|
2016
1867
|
ControlFrameItem,
|
|
2017
1868
|
ControlGroup,
|
|
2018
|
-
ControlGroupButton,
|
|
2019
1869
|
ControlItem,
|
|
2020
1870
|
ControlItemInput,
|
|
2021
|
-
ControlPage,
|
|
2022
1871
|
ControlSection,
|
|
2023
1872
|
ControlSectionHeading,
|
|
2024
1873
|
DeprecatedFormContainer,
|