@dxos/react-ui-form 0.8.2-main.fbd8ed0 → 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 +537 -846
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +506 -807
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +537 -846
- 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/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +4 -6
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +34 -37
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +11 -14
- 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/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/factory.d.ts +1 -1
- package/dist/types/src/components/Form/factory.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +2 -2
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +0 -2
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +2 -2
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +0 -2
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +25 -26
- package/src/components/{ControlSection/ControlSection.tsx → ControlSection.tsx} +14 -38
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/Form/ArrayField.tsx +17 -13
- package/src/components/Form/Defaults.tsx +1 -4
- package/src/components/Form/Form.stories.tsx +43 -92
- package/src/components/Form/Form.tsx +3 -7
- package/src/components/Form/FormContent.tsx +19 -90
- package/src/components/Form/FormContext.tsx +3 -13
- package/src/components/Form/Input.tsx +9 -3
- package/src/components/Form/custom/GeoPointInput.tsx +2 -2
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +5 -6
- package/src/components/Form/custom/SelectOptionsInput.tsx +2 -2
- package/src/components/Form/factory.tsx +1 -1
- package/src/components/Form/index.ts +1 -0
- package/src/components/ViewEditor/ViewEditor.stories.tsx +4 -5
- package/src/components/ViewEditor/ViewEditor.tsx +20 -23
- package/src/components/deprecated/Form.stories.tsx +6 -6
- package/src/components/deprecated/Form.tsx +6 -6
- package/src/components/deprecated/FormInput.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/hooks/index.ts +1 -3
- package/src/hooks/useForm.ts +3 -4
- package/src/util/formatting.ts +3 -15
- package/src/util/index.ts +1 -3
- 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 -12
- package/dist/types/src/components/Form/RefField.d.ts.map +0 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +0 -23
- package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +0 -1
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +0 -8
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +0 -1
- package/dist/types/src/util/refs.d.ts +0 -9
- package/dist/types/src/util/refs.d.ts.map +0 -1
- package/dist/types/src/util/schema.d.ts +0 -3
- package/dist/types/src/util/schema.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 -197
- package/src/hooks/useQueryRefOptions.ts +0 -53
- package/src/hooks/useRefQueryLookupHandler.ts +0 -41
- package/src/util/refs.ts +0 -38
- package/src/util/schema.ts +0 -14
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,
|
|
@@ -54,19 +52,15 @@ __export(node_exports, {
|
|
|
54
52
|
ViewEditor: () => ViewEditor,
|
|
55
53
|
cellClassesForFieldType: () => cellClassesForFieldType,
|
|
56
54
|
controlItemClasses: () => controlItemClasses,
|
|
57
|
-
findArrayElementType: () => findArrayElementType,
|
|
58
55
|
formatForDisplay: () => formatForDisplay,
|
|
59
56
|
formatForEditing: () => formatForEditing,
|
|
60
|
-
getRefProps: () => getRefProps,
|
|
61
57
|
parseValue: () => parseValue,
|
|
62
58
|
pathNotUniqueError: () => pathNotUniqueError,
|
|
63
59
|
translations: () => translations_default,
|
|
64
60
|
useForm: () => useForm,
|
|
65
61
|
useFormContext: () => useFormContext,
|
|
66
62
|
useFormValues: () => useFormValues,
|
|
67
|
-
useInputProps: () => useInputProps
|
|
68
|
-
useQueryRefOptions: () => useQueryRefOptions,
|
|
69
|
-
useRefQueryLookupHandler: () => useRefQueryLookupHandler
|
|
63
|
+
useInputProps: () => useInputProps
|
|
70
64
|
});
|
|
71
65
|
module.exports = __toCommonJS(node_exports);
|
|
72
66
|
var import_react = __toESM(require("react"));
|
|
@@ -74,7 +68,6 @@ var import_react_ui = require("@dxos/react-ui");
|
|
|
74
68
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
75
69
|
var import_react2 = __toESM(require("react"));
|
|
76
70
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
77
|
-
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
78
71
|
var import_react3 = __toESM(require("react"));
|
|
79
72
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
80
73
|
var import_log = require("@dxos/log");
|
|
@@ -86,24 +79,24 @@ var import_react_ui4 = require("@dxos/react-ui");
|
|
|
86
79
|
var import_util = require("@dxos/util");
|
|
87
80
|
var import_react5 = __toESM(require("react"));
|
|
88
81
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
89
|
-
var
|
|
82
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
90
83
|
var import_react6 = __toESM(require("react"));
|
|
91
84
|
var import_keys = require("@dxos/keys");
|
|
92
85
|
var import_react_ui6 = require("@dxos/react-ui");
|
|
93
86
|
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
94
87
|
var import_react_ui_pickers = require("@dxos/react-ui-pickers");
|
|
95
|
-
var
|
|
88
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
96
89
|
var import_react7 = __toESM(require("react"));
|
|
97
90
|
var import_react_ui7 = require("@dxos/react-ui");
|
|
98
|
-
var
|
|
91
|
+
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
99
92
|
var import_util2 = require("@dxos/util");
|
|
100
93
|
var import_react8 = __toESM(require("react"));
|
|
101
94
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
102
95
|
var import_react9 = __toESM(require("react"));
|
|
103
|
-
var
|
|
96
|
+
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
104
97
|
var import_react10 = __toESM(require("react"));
|
|
105
98
|
var import_react_ui9 = require("@dxos/react-ui");
|
|
106
|
-
var
|
|
99
|
+
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
107
100
|
var import_react11 = __toESM(require("react"));
|
|
108
101
|
var import_debug = require("@dxos/debug");
|
|
109
102
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
@@ -115,50 +108,34 @@ var import_effect3 = require("@dxos/effect");
|
|
|
115
108
|
var import_invariant = require("@dxos/invariant");
|
|
116
109
|
var import_log2 = require("@dxos/log");
|
|
117
110
|
var import_schema2 = require("@dxos/schema");
|
|
118
|
-
var import_react13 = require("react");
|
|
119
|
-
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
120
|
-
var import_echo = require("@dxos/react-client/echo");
|
|
121
|
-
var import_util3 = require("@dxos/util");
|
|
122
|
-
var import_react14 = require("react");
|
|
123
|
-
var import_log3 = require("@dxos/log");
|
|
124
111
|
var import_effect4 = require("effect");
|
|
125
112
|
var import_String = require("effect/String");
|
|
126
|
-
var
|
|
113
|
+
var import_react13 = __toESM(require("react"));
|
|
114
|
+
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
127
115
|
var import_effect5 = require("@dxos/effect");
|
|
128
|
-
var
|
|
116
|
+
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
|
129
117
|
var import_schema3 = require("@dxos/schema");
|
|
130
|
-
var
|
|
118
|
+
var import_util3 = require("@dxos/util");
|
|
131
119
|
var import_effect6 = require("effect");
|
|
132
120
|
var import_String2 = require("effect/String");
|
|
133
|
-
var
|
|
121
|
+
var import_react14 = __toESM(require("react"));
|
|
122
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
134
123
|
var import_effect7 = require("@dxos/effect");
|
|
135
124
|
var import_invariant2 = require("@dxos/invariant");
|
|
136
125
|
var import_react_ui10 = require("@dxos/react-ui");
|
|
137
|
-
var
|
|
126
|
+
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
|
138
127
|
var import_schema4 = require("@dxos/schema");
|
|
139
|
-
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
140
|
-
var import_format = require("date-fns/format");
|
|
141
128
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
129
|
+
var import_react15 = __toESM(require("react"));
|
|
142
130
|
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
143
|
-
var import_effect8 = require("@dxos/effect");
|
|
144
|
-
var import_effect9 = require("effect");
|
|
145
|
-
var import_effect10 = require("@dxos/effect");
|
|
146
|
-
var import_react17 = __toESM(require("react"));
|
|
147
|
-
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
148
|
-
var import_effect11 = require("@dxos/effect");
|
|
149
|
-
var import_keys2 = require("@dxos/keys");
|
|
150
|
-
var import_react_ui11 = require("@dxos/react-ui");
|
|
151
|
-
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
152
|
-
var import_util5 = require("@dxos/util");
|
|
153
|
-
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
154
|
-
var import_effect12 = require("effect");
|
|
155
|
-
var import_react18 = __toESM(require("react"));
|
|
156
|
-
var import_echo_schema11 = require("@dxos/echo-schema");
|
|
157
131
|
var import_invariant3 = require("@dxos/invariant");
|
|
158
|
-
var
|
|
132
|
+
var import_react_ui11 = require("@dxos/react-ui");
|
|
159
133
|
var import_react_ui_list2 = require("@dxos/react-ui-list");
|
|
160
|
-
var
|
|
134
|
+
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
161
135
|
var import_schema5 = require("@dxos/schema");
|
|
136
|
+
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
137
|
+
var import_format = require("date-fns/format");
|
|
138
|
+
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
162
139
|
var translationKey = "react-ui-form";
|
|
163
140
|
var translations_default = [
|
|
164
141
|
{
|
|
@@ -220,7 +197,7 @@ var translations_default = [
|
|
|
220
197
|
var DeprecatedFormContainer = ({ children, classNames }) => {
|
|
221
198
|
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
222
199
|
role: "none",
|
|
223
|
-
className: "
|
|
200
|
+
className: "w-full p-4 justify-center overflow-x-hidden overflow-y-auto"
|
|
224
201
|
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
225
202
|
role: "form",
|
|
226
203
|
className: (0, import_react_ui_theme.mx)("flex flex-col", import_react_ui_theme.textBlockWidth, classNames)
|
|
@@ -253,19 +230,6 @@ var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
|
253
230
|
}
|
|
254
231
|
return primary;
|
|
255
232
|
};
|
|
256
|
-
var ControlPage = ({ children, classNames, ...props }) => {
|
|
257
|
-
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
258
|
-
role: "none",
|
|
259
|
-
className: (0, import_react_ui_theme2.mx)("pli-2", classNames),
|
|
260
|
-
...props
|
|
261
|
-
}, children);
|
|
262
|
-
};
|
|
263
|
-
var ControlSection = ({ title, description, children }) => {
|
|
264
|
-
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(ControlSectionHeading, {
|
|
265
|
-
title,
|
|
266
|
-
description
|
|
267
|
-
}), children);
|
|
268
|
-
};
|
|
269
233
|
var ControlSectionHeading = ({ title, description }) => {
|
|
270
234
|
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
271
235
|
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
|
|
@@ -274,18 +238,15 @@ var ControlSectionHeading = ({ title, description }) => {
|
|
|
274
238
|
className: "pli-4 mlb-4 container-max-width text-description"
|
|
275
239
|
}, (0, import_react_ui2.toLocalizedString)(description, t)));
|
|
276
240
|
};
|
|
277
|
-
var
|
|
278
|
-
return /* @__PURE__ */ import_react2.default.createElement(
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
classNames
|
|
283
|
-
]
|
|
284
|
-
});
|
|
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);
|
|
285
246
|
};
|
|
286
|
-
var ControlGroup = ({ children
|
|
247
|
+
var ControlGroup = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
287
248
|
role: "none",
|
|
288
|
-
className:
|
|
249
|
+
className: "group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4"
|
|
289
250
|
}, children);
|
|
290
251
|
var ControlFrame = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
291
252
|
role: "none",
|
|
@@ -333,15 +294,15 @@ var InputHeader = ({ children, error }) => {
|
|
|
333
294
|
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
334
295
|
role: "none",
|
|
335
296
|
className: "flex justify-between items-center mb-1"
|
|
336
|
-
}, children, error && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Trigger, {
|
|
337
|
-
asChild: true
|
|
338
|
-
content: error,
|
|
339
|
-
side: "bottom"
|
|
297
|
+
}, children, error && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Trigger, {
|
|
298
|
+
asChild: true
|
|
340
299
|
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Icon, {
|
|
341
300
|
icon: "ph--warning--regular",
|
|
342
301
|
size: 4,
|
|
343
|
-
classNames:
|
|
344
|
-
}))
|
|
302
|
+
classNames: import_react_ui_theme2.errorText
|
|
303
|
+
})), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Content, {
|
|
304
|
+
side: "bottom"
|
|
305
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Arrow, null), error)));
|
|
345
306
|
};
|
|
346
307
|
var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
347
308
|
const { t } = (0, import_react_ui4.useTranslation)(translationKey);
|
|
@@ -430,13 +391,13 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
430
391
|
]);
|
|
431
392
|
const randomHue = () => {
|
|
432
393
|
const usedHues = new Set(options?.map((option) => option.color) ?? []);
|
|
433
|
-
const unusedHues =
|
|
394
|
+
const unusedHues = import_react_ui_theme3.hues.filter((hue) => !usedHues.has(hue));
|
|
434
395
|
if (unusedHues.length > 0) {
|
|
435
396
|
return unusedHues[Math.floor(Math.random() * unusedHues.length)];
|
|
436
397
|
}
|
|
437
398
|
const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
|
|
438
|
-
const availableHues =
|
|
439
|
-
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)];
|
|
440
401
|
};
|
|
441
402
|
const handleAdd = (0, import_react6.useCallback)(() => {
|
|
442
403
|
const newId = import_keys.PublicKey.random().truncate();
|
|
@@ -537,7 +498,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
537
498
|
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Item, {
|
|
538
499
|
role: "button",
|
|
539
500
|
item,
|
|
540
|
-
classNames: (0,
|
|
501
|
+
classNames: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
541
502
|
"aria-expanded": selected === item.id
|
|
542
503
|
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
543
504
|
className: "flex items-center"
|
|
@@ -578,7 +539,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
578
539
|
role: "listitem"
|
|
579
540
|
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
580
541
|
role: "button",
|
|
581
|
-
className: (0,
|
|
542
|
+
className: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
582
543
|
onClick: handleAdd
|
|
583
544
|
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
584
545
|
className: "flex items-center gap-1"
|
|
@@ -602,7 +563,7 @@ var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValu
|
|
|
602
563
|
}, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
|
|
603
564
|
error
|
|
604
565
|
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
605
|
-
className: (0,
|
|
566
|
+
className: (0, import_react_ui_theme4.mx)("grid gap-2", gridCols[binding.length - 1])
|
|
606
567
|
}, binding.map((prop) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.TextInput, {
|
|
607
568
|
key: prop,
|
|
608
569
|
type: "number",
|
|
@@ -658,28 +619,23 @@ var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, on
|
|
|
658
619
|
};
|
|
659
620
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
660
621
|
const { status, error } = getStatus();
|
|
661
|
-
const value = getValue3();
|
|
662
|
-
const handleValueChange = (0, import_react8.useCallback)((value2) => onValueChange(type, value2), [
|
|
663
|
-
type,
|
|
664
|
-
onValueChange
|
|
665
|
-
]);
|
|
666
622
|
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
667
623
|
validationValence: status
|
|
668
624
|
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
669
625
|
error
|
|
670
626
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
|
|
671
|
-
value,
|
|
672
|
-
onValueChange:
|
|
627
|
+
value: getValue3(),
|
|
628
|
+
onValueChange: (value) => onValueChange(type, value)
|
|
673
629
|
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
|
|
674
630
|
classNames: "is-full",
|
|
675
631
|
disabled,
|
|
676
632
|
placeholder
|
|
677
|
-
}), /* @__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
|
|
633
|
+
}), /* @__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 }) => (
|
|
678
634
|
// NOTE: Numeric values are converted to and from strings.
|
|
679
635
|
/* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
|
|
680
|
-
key: String(
|
|
681
|
-
value: String(
|
|
682
|
-
}, label2 ?? String(
|
|
636
|
+
key: String(value),
|
|
637
|
+
value: String(value)
|
|
638
|
+
}, label2 ?? String(value))
|
|
683
639
|
)))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
684
640
|
};
|
|
685
641
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
@@ -728,7 +684,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
728
684
|
L: 93,
|
|
729
685
|
S: void 0,
|
|
730
686
|
A: [
|
|
731
|
-
"
|
|
687
|
+
"AST.isTypeLiteral(schema.ast)",
|
|
732
688
|
""
|
|
733
689
|
]
|
|
734
690
|
});
|
|
@@ -829,7 +785,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
829
785
|
} catch (err) {
|
|
830
786
|
import_log2.log.catch(err, void 0, {
|
|
831
787
|
F: __dxlog_file,
|
|
832
|
-
L:
|
|
788
|
+
L: 212,
|
|
833
789
|
S: void 0,
|
|
834
790
|
C: (f, a) => f(...a)
|
|
835
791
|
});
|
|
@@ -900,7 +856,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
900
856
|
var createKeySet = (obj, value) => {
|
|
901
857
|
(0, import_invariant.invariant)(obj, void 0, {
|
|
902
858
|
F: __dxlog_file,
|
|
903
|
-
L:
|
|
859
|
+
L: 274,
|
|
904
860
|
S: void 0,
|
|
905
861
|
A: [
|
|
906
862
|
"obj",
|
|
@@ -921,71 +877,6 @@ var flatMap = (errors) => {
|
|
|
921
877
|
return result;
|
|
922
878
|
}, {});
|
|
923
879
|
};
|
|
924
|
-
var useRefQueryLookupHandler = ({ space }) => {
|
|
925
|
-
const handleRefQueryLookup = (0, import_react13.useCallback)(async (typeInfo) => {
|
|
926
|
-
if (!space) {
|
|
927
|
-
return [];
|
|
928
|
-
}
|
|
929
|
-
const query = space.db.query(import_echo.Filter.typename(typeInfo.typename));
|
|
930
|
-
const { objects } = await query.run();
|
|
931
|
-
return objects.map((object) => {
|
|
932
|
-
const dxn = (0, import_echo_schema5.getDXN)(object);
|
|
933
|
-
if (!dxn) {
|
|
934
|
-
return void 0;
|
|
935
|
-
}
|
|
936
|
-
const item = {
|
|
937
|
-
dxn,
|
|
938
|
-
label: object?.name ?? object?.id ?? ""
|
|
939
|
-
};
|
|
940
|
-
return item;
|
|
941
|
-
}).filter(import_util3.isNonNullable);
|
|
942
|
-
}, [
|
|
943
|
-
space
|
|
944
|
-
]);
|
|
945
|
-
return handleRefQueryLookup;
|
|
946
|
-
};
|
|
947
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useQueryRefOptions.ts";
|
|
948
|
-
var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
|
|
949
|
-
const [options, setOptions] = (0, import_react14.useState)([]);
|
|
950
|
-
const [loading, setLoading] = (0, import_react14.useState)(false);
|
|
951
|
-
(0, import_react14.useEffect)(() => {
|
|
952
|
-
if (!refTypeInfo || !onQueryRefOptions) {
|
|
953
|
-
return;
|
|
954
|
-
}
|
|
955
|
-
const fetchOptions = async () => {
|
|
956
|
-
setLoading(true);
|
|
957
|
-
try {
|
|
958
|
-
const fetchedOptions = await onQueryRefOptions(refTypeInfo);
|
|
959
|
-
setOptions(fetchedOptions.map((option) => {
|
|
960
|
-
const dxn = option.dxn.toString();
|
|
961
|
-
return {
|
|
962
|
-
id: dxn,
|
|
963
|
-
label: option.label ?? dxn,
|
|
964
|
-
hue: "neutral"
|
|
965
|
-
};
|
|
966
|
-
}));
|
|
967
|
-
} catch (error) {
|
|
968
|
-
import_log3.log.error("Failed to fetch ref options:", error, {
|
|
969
|
-
F: __dxlog_file2,
|
|
970
|
-
L: 42,
|
|
971
|
-
S: void 0,
|
|
972
|
-
C: (f, a) => f(...a)
|
|
973
|
-
});
|
|
974
|
-
setOptions([]);
|
|
975
|
-
} finally {
|
|
976
|
-
setLoading(false);
|
|
977
|
-
}
|
|
978
|
-
};
|
|
979
|
-
void fetchOptions();
|
|
980
|
-
}, [
|
|
981
|
-
refTypeInfo,
|
|
982
|
-
onQueryRefOptions
|
|
983
|
-
]);
|
|
984
|
-
return {
|
|
985
|
-
options,
|
|
986
|
-
loading
|
|
987
|
-
};
|
|
988
|
-
};
|
|
989
880
|
var FormContext = /* @__PURE__ */ (0, import_react11.createContext)(void 0);
|
|
990
881
|
var useFormContext = () => {
|
|
991
882
|
return (0, import_react11.useContext)(FormContext) ?? (0, import_debug.raise)(new Error("Missing FormContext"));
|
|
@@ -1023,7 +914,7 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1023
914
|
const keyIsEnter = event.key === "Enter";
|
|
1024
915
|
const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
|
|
1025
916
|
const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
|
|
1026
|
-
const inputOptOut = event.target.hasAttribute("data-no-submit")
|
|
917
|
+
const inputOptOut = event.target.hasAttribute("data-no-submit");
|
|
1027
918
|
const shouldSubmitRegularInput = !inputIsTextarea && keyIsEnter && !modifierUsed;
|
|
1028
919
|
const shouldSubmitTextarea = inputIsTextarea && keyIsEnter && event.metaKey;
|
|
1029
920
|
if ((shouldSubmitRegularInput || shouldSubmitTextarea) && !inputOptOut) {
|
|
@@ -1057,7 +948,7 @@ var FormActions = ({ onCancel, readonly }) => {
|
|
|
1057
948
|
className: "mt-2 flex justify-center"
|
|
1058
949
|
}, /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1059
950
|
role: "none",
|
|
1060
|
-
className: (0,
|
|
951
|
+
className: (0, import_react_ui_theme6.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
|
|
1061
952
|
}, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
1062
953
|
"data-testid": "cancel-button",
|
|
1063
954
|
icon: "ph--x--regular",
|
|
@@ -1072,551 +963,140 @@ var FormActions = ({ onCancel, readonly }) => {
|
|
|
1072
963
|
onClick: handleSave
|
|
1073
964
|
})));
|
|
1074
965
|
};
|
|
1075
|
-
var
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
}
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
case import_echo_schema6.TypeEnum.Ref:
|
|
1099
|
-
return String(value);
|
|
1100
|
-
default: {
|
|
1101
|
-
return value;
|
|
1102
|
-
}
|
|
966
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
967
|
+
var padding = "px-2";
|
|
968
|
+
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
969
|
+
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
970
|
+
const { ast, name, type, title } = property;
|
|
971
|
+
const values = useFormValues(path ?? []);
|
|
972
|
+
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
973
|
+
F: __dxlog_file2,
|
|
974
|
+
L: 37,
|
|
975
|
+
S: void 0,
|
|
976
|
+
A: [
|
|
977
|
+
"Array.isArray(values)",
|
|
978
|
+
"`Values at path ${path?.join('.')} must be an array.`"
|
|
979
|
+
]
|
|
980
|
+
});
|
|
981
|
+
const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
|
|
982
|
+
const tupleType = (0, import_effect7.findNode)(ast, import_echo_schema6.AST.isTupleType);
|
|
983
|
+
const elementType = tupleType?.rest[0]?.type;
|
|
984
|
+
const getDefaultObjectValue = (typeNode) => {
|
|
985
|
+
const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
|
|
986
|
+
const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_echo_schema6.AST.isTypeLiteral);
|
|
987
|
+
if (!typeLiteral) {
|
|
988
|
+
return {};
|
|
1103
989
|
}
|
|
990
|
+
return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
|
|
991
|
+
prop.name,
|
|
992
|
+
prop.defaultValue
|
|
993
|
+
]));
|
|
1104
994
|
};
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
return parseScalar(import_echo_schema6.TypeEnum.Boolean);
|
|
1111
|
-
case import_echo_schema6.FormatEnum.Number:
|
|
1112
|
-
case import_echo_schema6.FormatEnum.Percent:
|
|
1113
|
-
case import_echo_schema6.FormatEnum.Currency:
|
|
1114
|
-
return parseScalar(import_echo_schema6.TypeEnum.Number);
|
|
1115
|
-
case import_echo_schema6.FormatEnum.String:
|
|
1116
|
-
case import_echo_schema6.FormatEnum.Markdown: {
|
|
1117
|
-
return parseScalar(import_echo_schema6.TypeEnum.String);
|
|
1118
|
-
}
|
|
1119
|
-
case import_echo_schema6.FormatEnum.Ref:
|
|
1120
|
-
throw new Error(`unexpected format: ${import_echo_schema6.FormatEnum.Ref}`);
|
|
1121
|
-
case import_echo_schema6.FormatEnum.DateTime:
|
|
1122
|
-
case import_echo_schema6.FormatEnum.Date:
|
|
1123
|
-
case import_echo_schema6.FormatEnum.Time:
|
|
1124
|
-
case import_echo_schema6.FormatEnum.Timestamp: {
|
|
1125
|
-
const date = new Date(value);
|
|
1126
|
-
return isNaN(date.getTime()) ? null : date;
|
|
1127
|
-
}
|
|
1128
|
-
case import_echo_schema6.FormatEnum.GeoPoint: {
|
|
1129
|
-
if (typeof value === "string") {
|
|
1130
|
-
const cleaned = value.replace(/[^0-9.,-]+/g, "");
|
|
1131
|
-
const parts = cleaned.split(",");
|
|
1132
|
-
if (parts.length === 2) {
|
|
1133
|
-
const lat = parseFloat(parts[0]);
|
|
1134
|
-
const long = parseFloat(parts[1]);
|
|
1135
|
-
if (!isNaN(lat) && !isNaN(long)) {
|
|
1136
|
-
return import_echo_schema6.GeoLocation.toGeoPoint({
|
|
1137
|
-
latitude: lat,
|
|
1138
|
-
longitude: long
|
|
1139
|
-
});
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
return [
|
|
1144
|
-
0,
|
|
1145
|
-
0
|
|
1146
|
-
];
|
|
1147
|
-
}
|
|
1148
|
-
default: {
|
|
1149
|
-
return value;
|
|
995
|
+
const newValue = (0, import_react14.useMemo)(() => {
|
|
996
|
+
if (type === "object" && elementType) {
|
|
997
|
+
return getDefaultObjectValue(elementType);
|
|
998
|
+
} else {
|
|
999
|
+
return import_effect7.SimpleType.getDefaultValue(type);
|
|
1150
1000
|
}
|
|
1001
|
+
}, [
|
|
1002
|
+
type,
|
|
1003
|
+
elementType
|
|
1004
|
+
]);
|
|
1005
|
+
const handleAdd = (0, import_react14.useCallback)(() => {
|
|
1006
|
+
inputProps.onValueChange(type, [
|
|
1007
|
+
...values,
|
|
1008
|
+
newValue
|
|
1009
|
+
]);
|
|
1010
|
+
}, [
|
|
1011
|
+
type,
|
|
1012
|
+
elementType,
|
|
1013
|
+
inputProps,
|
|
1014
|
+
newValue,
|
|
1015
|
+
values
|
|
1016
|
+
]);
|
|
1017
|
+
const handleRemove = (0, import_react14.useCallback)((index) => {
|
|
1018
|
+
const newValues = values.filter((_, i) => i !== index);
|
|
1019
|
+
inputProps.onValueChange(type, newValues);
|
|
1020
|
+
}, [
|
|
1021
|
+
type,
|
|
1022
|
+
inputProps,
|
|
1023
|
+
values
|
|
1024
|
+
]);
|
|
1025
|
+
if (!elementType) {
|
|
1026
|
+
return null;
|
|
1151
1027
|
}
|
|
1028
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1029
|
+
role: "none",
|
|
1030
|
+
className: (0, import_react_ui_theme8.mx)(padding)
|
|
1031
|
+
}, /* @__PURE__ */ import_react14.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1032
|
+
role: "none",
|
|
1033
|
+
className: "flex flex-col gap-1"
|
|
1034
|
+
}, values.map((_value, index) => /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1035
|
+
key: index,
|
|
1036
|
+
role: "none",
|
|
1037
|
+
className: "flex items-center gap-1"
|
|
1038
|
+
}, /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1039
|
+
role: "none",
|
|
1040
|
+
className: "flex-1"
|
|
1041
|
+
}, /* @__PURE__ */ import_react14.default.createElement(FormField, {
|
|
1042
|
+
property: {
|
|
1043
|
+
...property,
|
|
1044
|
+
array: false,
|
|
1045
|
+
ast: elementType
|
|
1046
|
+
},
|
|
1047
|
+
path: [
|
|
1048
|
+
...path ?? [],
|
|
1049
|
+
index
|
|
1050
|
+
],
|
|
1051
|
+
readonly,
|
|
1052
|
+
inline: true,
|
|
1053
|
+
Custom,
|
|
1054
|
+
lookupComponent
|
|
1055
|
+
})), /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
|
|
1056
|
+
icon: "ph--trash--regular",
|
|
1057
|
+
iconOnly: true,
|
|
1058
|
+
label: t("button remove"),
|
|
1059
|
+
onClick: () => handleRemove(index)
|
|
1060
|
+
})))), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1061
|
+
role: "none",
|
|
1062
|
+
className: "flex justify-between items-center plb-1"
|
|
1063
|
+
}, /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
|
|
1064
|
+
icon: "ph--plus--regular",
|
|
1065
|
+
iconOnly: true,
|
|
1066
|
+
label: t("button add"),
|
|
1067
|
+
onClick: handleAdd
|
|
1068
|
+
})));
|
|
1152
1069
|
};
|
|
1153
|
-
var
|
|
1154
|
-
if (!format) {
|
|
1155
|
-
switch (type) {
|
|
1156
|
-
case import_echo_schema6.TypeEnum.Number:
|
|
1157
|
-
return [
|
|
1158
|
-
"text-right",
|
|
1159
|
-
"font-mono"
|
|
1160
|
-
];
|
|
1161
|
-
case import_echo_schema6.TypeEnum.Boolean:
|
|
1162
|
-
return [
|
|
1163
|
-
"text-right",
|
|
1164
|
-
"font-mono"
|
|
1165
|
-
];
|
|
1166
|
-
case import_echo_schema6.TypeEnum.String:
|
|
1167
|
-
return void 0;
|
|
1168
|
-
case import_echo_schema6.TypeEnum.Ref:
|
|
1169
|
-
return void 0;
|
|
1170
|
-
default: {
|
|
1171
|
-
return void 0;
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1070
|
+
var getInputComponent = (type, format) => {
|
|
1175
1071
|
switch (format) {
|
|
1176
|
-
case
|
|
1177
|
-
return
|
|
1178
|
-
case
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
case
|
|
1183
|
-
return
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
return [
|
|
1189
|
-
"text-right"
|
|
1190
|
-
];
|
|
1191
|
-
case import_echo_schema6.FormatEnum.JSON:
|
|
1192
|
-
case import_echo_schema6.FormatEnum.DID:
|
|
1193
|
-
return [
|
|
1194
|
-
"font-mono"
|
|
1195
|
-
];
|
|
1196
|
-
default:
|
|
1197
|
-
return void 0;
|
|
1072
|
+
case import_echo_schema7.FormatEnum.GeoPoint:
|
|
1073
|
+
return GeoPointInput;
|
|
1074
|
+
case import_echo_schema7.FormatEnum.Markdown:
|
|
1075
|
+
return MarkdownInput;
|
|
1076
|
+
}
|
|
1077
|
+
switch (type) {
|
|
1078
|
+
case "string":
|
|
1079
|
+
return TextInput;
|
|
1080
|
+
case "number":
|
|
1081
|
+
return NumberInput;
|
|
1082
|
+
case "boolean":
|
|
1083
|
+
return BooleanInput;
|
|
1198
1084
|
}
|
|
1199
1085
|
};
|
|
1200
|
-
var
|
|
1201
|
-
path: "path",
|
|
1202
|
-
message: `'${path}' is already present`
|
|
1203
|
-
});
|
|
1204
|
-
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1205
|
-
const formatScalar = (type2) => {
|
|
1206
|
-
switch (type2) {
|
|
1207
|
-
case import_echo_schema7.TypeEnum.Boolean:
|
|
1208
|
-
return value.toLocaleString().toUpperCase();
|
|
1209
|
-
case import_echo_schema7.TypeEnum.Number:
|
|
1210
|
-
return value.toLocaleString(locale);
|
|
1211
|
-
case import_echo_schema7.TypeEnum.String:
|
|
1212
|
-
case import_echo_schema7.TypeEnum.Ref:
|
|
1213
|
-
return String(value);
|
|
1214
|
-
default: {
|
|
1215
|
-
return String(value);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
};
|
|
1219
|
-
if (!format) {
|
|
1220
|
-
return formatScalar(type);
|
|
1221
|
-
}
|
|
1222
|
-
switch (format) {
|
|
1223
|
-
case import_echo_schema7.FormatEnum.Boolean: {
|
|
1224
|
-
return formatScalar(import_echo_schema7.TypeEnum.Boolean);
|
|
1225
|
-
}
|
|
1226
|
-
case import_echo_schema7.FormatEnum.Number: {
|
|
1227
|
-
return formatScalar(import_echo_schema7.TypeEnum.Number);
|
|
1228
|
-
}
|
|
1229
|
-
case import_echo_schema7.FormatEnum.String:
|
|
1230
|
-
case import_echo_schema7.FormatEnum.Ref: {
|
|
1231
|
-
return formatScalar(import_echo_schema7.TypeEnum.String);
|
|
1232
|
-
}
|
|
1233
|
-
case import_echo_schema7.FormatEnum.Percent: {
|
|
1234
|
-
return `${value * 100}%`;
|
|
1235
|
-
}
|
|
1236
|
-
case import_echo_schema7.FormatEnum.Currency: {
|
|
1237
|
-
return value.toLocaleString(locale, {
|
|
1238
|
-
style: "currency",
|
|
1239
|
-
currency: "USD",
|
|
1240
|
-
minimumFractionDigits: 2,
|
|
1241
|
-
maximumFractionDigits: 2
|
|
1242
|
-
});
|
|
1243
|
-
}
|
|
1244
|
-
case import_echo_schema7.FormatEnum.Date: {
|
|
1245
|
-
try {
|
|
1246
|
-
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1247
|
-
} catch (error) {
|
|
1248
|
-
return "Invalid Date";
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
case import_echo_schema7.FormatEnum.Time: {
|
|
1252
|
-
try {
|
|
1253
|
-
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1254
|
-
} catch (error) {
|
|
1255
|
-
return "Invalid Time";
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
case import_echo_schema7.FormatEnum.DateTime: {
|
|
1259
|
-
try {
|
|
1260
|
-
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1261
|
-
} catch (error) {
|
|
1262
|
-
return "Invalid DateTime";
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
case import_echo_schema7.FormatEnum.GeoPoint: {
|
|
1266
|
-
if (value === null || value === void 0) {
|
|
1267
|
-
return "";
|
|
1268
|
-
}
|
|
1269
|
-
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1270
|
-
const { latitude, longitude } = import_echo_schema7.GeoLocation.fromGeoPoint(value);
|
|
1271
|
-
return `${latitude},${longitude}`;
|
|
1272
|
-
}
|
|
1273
|
-
return String(value);
|
|
1274
|
-
}
|
|
1275
|
-
default: {
|
|
1276
|
-
if (value === null || value === "undefined") {
|
|
1277
|
-
return "";
|
|
1278
|
-
}
|
|
1279
|
-
return String(value);
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
};
|
|
1283
|
-
var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
1284
|
-
const formatScalar = (type2) => {
|
|
1285
|
-
switch (type2) {
|
|
1286
|
-
case import_echo_schema7.TypeEnum.Boolean:
|
|
1287
|
-
case import_echo_schema7.TypeEnum.Number:
|
|
1288
|
-
case import_echo_schema7.TypeEnum.String:
|
|
1289
|
-
case import_echo_schema7.TypeEnum.Ref:
|
|
1290
|
-
return String(value);
|
|
1291
|
-
default:
|
|
1292
|
-
return String(value);
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
if (!format) {
|
|
1296
|
-
return formatScalar(type);
|
|
1297
|
-
}
|
|
1298
|
-
switch (format) {
|
|
1299
|
-
case import_echo_schema7.FormatEnum.Boolean:
|
|
1300
|
-
case import_echo_schema7.FormatEnum.Number:
|
|
1301
|
-
case import_echo_schema7.FormatEnum.String:
|
|
1302
|
-
case import_echo_schema7.FormatEnum.Ref: {
|
|
1303
|
-
return formatScalar(type);
|
|
1304
|
-
}
|
|
1305
|
-
case import_echo_schema7.FormatEnum.Percent: {
|
|
1306
|
-
return String(value * 100);
|
|
1307
|
-
}
|
|
1308
|
-
case import_echo_schema7.FormatEnum.Currency: {
|
|
1309
|
-
return String(value);
|
|
1310
|
-
}
|
|
1311
|
-
case import_echo_schema7.FormatEnum.DateTime: {
|
|
1312
|
-
const date = new Date(value);
|
|
1313
|
-
return date.toISOString();
|
|
1314
|
-
}
|
|
1315
|
-
case import_echo_schema7.FormatEnum.Date: {
|
|
1316
|
-
const date = new Date(value);
|
|
1317
|
-
return date.toISOString().split("T")[0];
|
|
1318
|
-
}
|
|
1319
|
-
case import_echo_schema7.FormatEnum.Time: {
|
|
1320
|
-
const date = new Date(value);
|
|
1321
|
-
return date.toISOString().split("T")[1].split(".")[0];
|
|
1322
|
-
}
|
|
1323
|
-
case import_echo_schema7.FormatEnum.GeoPoint: {
|
|
1324
|
-
if (value === null || value === void 0) {
|
|
1325
|
-
return "";
|
|
1326
|
-
}
|
|
1327
|
-
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1328
|
-
const { latitude, longitude } = import_echo_schema7.GeoLocation.fromGeoPoint(value);
|
|
1329
|
-
return `${latitude},${longitude}`;
|
|
1330
|
-
}
|
|
1331
|
-
return String(value);
|
|
1332
|
-
}
|
|
1333
|
-
default: {
|
|
1334
|
-
return String(value);
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
};
|
|
1338
|
-
var findArrayElementType = (ast) => {
|
|
1339
|
-
const tupleType = (0, import_effect10.findNode)(ast, import_effect9.SchemaAST.isTupleType);
|
|
1340
|
-
const elementType = tupleType?.rest[0]?.type;
|
|
1341
|
-
return elementType;
|
|
1342
|
-
};
|
|
1343
|
-
var getRefProps = (property) => {
|
|
1344
|
-
const { ast, format, array } = property;
|
|
1345
|
-
if (format === import_echo_schema8.FormatEnum.Ref) {
|
|
1346
|
-
return {
|
|
1347
|
-
ast,
|
|
1348
|
-
isArray: false
|
|
1349
|
-
};
|
|
1350
|
-
}
|
|
1351
|
-
if (array) {
|
|
1352
|
-
const elementType = findArrayElementType(ast);
|
|
1353
|
-
if (elementType) {
|
|
1354
|
-
const annotation = (0, import_effect8.findAnnotation)(elementType, import_echo_schema8.ReferenceAnnotationId);
|
|
1355
|
-
if (annotation) {
|
|
1356
|
-
return {
|
|
1357
|
-
ast: elementType,
|
|
1358
|
-
isArray: true
|
|
1359
|
-
};
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
return void 0;
|
|
1364
|
-
};
|
|
1365
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
1366
|
-
var padding = "px-2";
|
|
1367
|
-
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
1368
|
-
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
1369
|
-
const { ast, name, type, title } = property;
|
|
1370
|
-
const values = useFormValues(path ?? []) ?? [];
|
|
1371
|
-
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
1372
|
-
F: __dxlog_file3,
|
|
1373
|
-
L: 39,
|
|
1374
|
-
S: void 0,
|
|
1375
|
-
A: [
|
|
1376
|
-
"Array.isArray(values)",
|
|
1377
|
-
"`Values at path ${path?.join('.')} must be an array.`"
|
|
1378
|
-
]
|
|
1379
|
-
});
|
|
1380
|
-
const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
|
|
1381
|
-
const elementType = findArrayElementType(ast);
|
|
1382
|
-
const getDefaultObjectValue = (typeNode) => {
|
|
1383
|
-
const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
|
|
1384
|
-
const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_effect6.SchemaAST.isTypeLiteral);
|
|
1385
|
-
if (!typeLiteral) {
|
|
1386
|
-
return {};
|
|
1387
|
-
}
|
|
1388
|
-
return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
|
|
1389
|
-
prop.name,
|
|
1390
|
-
prop.defaultValue
|
|
1391
|
-
]));
|
|
1392
|
-
};
|
|
1393
|
-
const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : import_effect7.SimpleType.getDefaultValue(type);
|
|
1394
|
-
const handleAdd = (0, import_react16.useCallback)(() => {
|
|
1395
|
-
inputProps.onValueChange(type, [
|
|
1396
|
-
...values,
|
|
1397
|
-
getDefaultValue()
|
|
1398
|
-
]);
|
|
1399
|
-
}, [
|
|
1400
|
-
type,
|
|
1401
|
-
elementType,
|
|
1402
|
-
inputProps,
|
|
1403
|
-
values
|
|
1404
|
-
]);
|
|
1405
|
-
const handleRemove = (0, import_react16.useCallback)((index) => {
|
|
1406
|
-
const newValues = values.filter((_, i) => i !== index);
|
|
1407
|
-
inputProps.onValueChange(type, newValues);
|
|
1408
|
-
}, [
|
|
1409
|
-
type,
|
|
1410
|
-
inputProps,
|
|
1411
|
-
values
|
|
1412
|
-
]);
|
|
1413
|
-
if (!elementType) {
|
|
1414
|
-
return null;
|
|
1415
|
-
}
|
|
1416
|
-
return /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1417
|
-
role: "none",
|
|
1418
|
-
className: (0, import_react_ui_theme9.mx)(padding)
|
|
1419
|
-
}, /* @__PURE__ */ import_react16.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1420
|
-
role: "none",
|
|
1421
|
-
className: "flex flex-col gap-1"
|
|
1422
|
-
}, values.map((_value, index) => /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1423
|
-
key: index,
|
|
1424
|
-
role: "none",
|
|
1425
|
-
className: "flex items-center gap-1"
|
|
1426
|
-
}, /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1427
|
-
role: "none",
|
|
1428
|
-
className: "flex-1"
|
|
1429
|
-
}, /* @__PURE__ */ import_react16.default.createElement(FormField, {
|
|
1430
|
-
property: {
|
|
1431
|
-
...property,
|
|
1432
|
-
array: false,
|
|
1433
|
-
ast: elementType
|
|
1434
|
-
},
|
|
1435
|
-
path: [
|
|
1436
|
-
...path ?? [],
|
|
1437
|
-
index
|
|
1438
|
-
],
|
|
1439
|
-
readonly,
|
|
1440
|
-
inline: true,
|
|
1441
|
-
Custom,
|
|
1442
|
-
lookupComponent
|
|
1443
|
-
})), /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
|
|
1444
|
-
icon: "ph--trash--regular",
|
|
1445
|
-
iconOnly: true,
|
|
1446
|
-
label: t("button remove"),
|
|
1447
|
-
onClick: () => handleRemove(index)
|
|
1448
|
-
})))), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1449
|
-
role: "none",
|
|
1450
|
-
className: "flex justify-between items-center plb-1"
|
|
1451
|
-
}, /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
|
|
1452
|
-
icon: "ph--plus--regular",
|
|
1453
|
-
iconOnly: true,
|
|
1454
|
-
label: t("button add"),
|
|
1455
|
-
onClick: handleAdd
|
|
1456
|
-
})));
|
|
1457
|
-
};
|
|
1458
|
-
var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1459
|
-
const refTypeInfo = (0, import_react17.useMemo)(() => ast ? (0, import_effect11.findAnnotation)(ast, import_echo_schema9.ReferenceAnnotationId) : void 0, [
|
|
1460
|
-
ast
|
|
1461
|
-
]);
|
|
1462
|
-
const { options: availableOptions, loading: _loading } = useQueryRefOptions({
|
|
1463
|
-
refTypeInfo,
|
|
1464
|
-
onQueryRefOptions
|
|
1465
|
-
});
|
|
1466
|
-
if (refTypeInfo && refTypeInfo?.typename === (0, import_echo_schema9.getTypeAnnotation)(import_echo_schema9.Expando)?.typename || !onQueryRefOptions) {
|
|
1467
|
-
return /* @__PURE__ */ import_react17.default.createElement(RefFieldFallback, {
|
|
1468
|
-
type,
|
|
1469
|
-
label,
|
|
1470
|
-
placeholder,
|
|
1471
|
-
disabled,
|
|
1472
|
-
inputOnly,
|
|
1473
|
-
getValue: getValue3,
|
|
1474
|
-
onBlur,
|
|
1475
|
-
onValueChange,
|
|
1476
|
-
...restInputProps
|
|
1477
|
-
});
|
|
1478
|
-
}
|
|
1479
|
-
const handleGetValue = (0, import_react17.useCallback)(() => {
|
|
1480
|
-
const formValue = getValue3();
|
|
1481
|
-
const unknownToRefOption = (val) => {
|
|
1482
|
-
if (import_echo_schema9.Ref.isRef(val)) {
|
|
1483
|
-
const dxnString = val.dxn.toString();
|
|
1484
|
-
const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
|
|
1485
|
-
if (matchingOption) {
|
|
1486
|
-
return matchingOption;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
return void 0;
|
|
1490
|
-
};
|
|
1491
|
-
if (array && Array.isArray(formValue)) {
|
|
1492
|
-
return formValue.map(unknownToRefOption).filter(import_util5.isNonNullable) ?? [];
|
|
1493
|
-
}
|
|
1494
|
-
const option = unknownToRefOption(formValue);
|
|
1495
|
-
if (option) {
|
|
1496
|
-
return [
|
|
1497
|
-
option
|
|
1498
|
-
];
|
|
1499
|
-
}
|
|
1500
|
-
return [];
|
|
1501
|
-
}, [
|
|
1502
|
-
getValue3,
|
|
1503
|
-
availableOptions,
|
|
1504
|
-
array
|
|
1505
|
-
]);
|
|
1506
|
-
const handleSearch = (0, import_react17.useCallback)((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
|
|
1507
|
-
id: option.id,
|
|
1508
|
-
label: option.label,
|
|
1509
|
-
hue: option.hue
|
|
1510
|
-
})), [
|
|
1511
|
-
availableOptions
|
|
1512
|
-
]);
|
|
1513
|
-
const handleUpdate = (0, import_react17.useCallback)((ids) => {
|
|
1514
|
-
if (ids.length === 0) {
|
|
1515
|
-
onValueChange("object", void 0);
|
|
1516
|
-
return;
|
|
1517
|
-
}
|
|
1518
|
-
const refs = ids.map((id) => {
|
|
1519
|
-
const item = availableOptions.find((option) => option.id === id);
|
|
1520
|
-
if (item) {
|
|
1521
|
-
const dxn = import_keys2.DXN.parse(item.id);
|
|
1522
|
-
return import_echo_schema9.Ref.fromDXN(dxn);
|
|
1523
|
-
}
|
|
1524
|
-
return null;
|
|
1525
|
-
}).filter(import_util5.isNonNullable);
|
|
1526
|
-
if (array) {
|
|
1527
|
-
onValueChange("object", refs);
|
|
1528
|
-
} else {
|
|
1529
|
-
onValueChange("object", refs[0]);
|
|
1530
|
-
}
|
|
1531
|
-
}, [
|
|
1532
|
-
availableOptions,
|
|
1533
|
-
array,
|
|
1534
|
-
onValueChange
|
|
1535
|
-
]);
|
|
1536
|
-
const tagPickerMode = (0, import_react17.useMemo)(() => array ? "multi-select" : "single-select", [
|
|
1537
|
-
array
|
|
1538
|
-
]);
|
|
1539
|
-
if (!refTypeInfo) {
|
|
1540
|
-
return null;
|
|
1541
|
-
}
|
|
1542
|
-
const { status, error } = restInputProps.getStatus();
|
|
1543
|
-
return /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Root, {
|
|
1544
|
-
validationValence: status
|
|
1545
|
-
}, !inputOnly && /* @__PURE__ */ import_react17.default.createElement(InputHeader, {
|
|
1546
|
-
error
|
|
1547
|
-
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Label, null, label)), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1548
|
-
"data-no-submit": true
|
|
1549
|
-
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_tag_picker.TagPicker, {
|
|
1550
|
-
items: handleGetValue(),
|
|
1551
|
-
mode: tagPickerMode,
|
|
1552
|
-
onBlur: (event) => onBlur(event),
|
|
1553
|
-
onUpdate: handleUpdate,
|
|
1554
|
-
onSearch: handleSearch,
|
|
1555
|
-
classNames: "rounded-sm bg-input p-1.5"
|
|
1556
|
-
})), inputOnly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.DescriptionAndValidation, null, error));
|
|
1557
|
-
};
|
|
1558
|
-
var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
|
|
1559
|
-
const handleOnValueChange = (_type, dxnString) => {
|
|
1560
|
-
const dxn = import_keys2.DXN.tryParse(dxnString);
|
|
1561
|
-
if (dxn) {
|
|
1562
|
-
onValueChange?.("object", import_echo_schema9.Ref.fromDXN(dxn));
|
|
1563
|
-
} else if (dxnString === "") {
|
|
1564
|
-
onValueChange?.("object", void 0);
|
|
1565
|
-
} else {
|
|
1566
|
-
onValueChange?.("string", dxnString);
|
|
1567
|
-
}
|
|
1568
|
-
};
|
|
1569
|
-
const handleGetValue = () => {
|
|
1570
|
-
const formValue = getValue3();
|
|
1571
|
-
if (typeof formValue === "string") {
|
|
1572
|
-
return formValue;
|
|
1573
|
-
}
|
|
1574
|
-
if (import_echo_schema9.Ref.isRef(formValue)) {
|
|
1575
|
-
return formValue.dxn.toString();
|
|
1576
|
-
}
|
|
1577
|
-
return void 0;
|
|
1578
|
-
};
|
|
1579
|
-
return /* @__PURE__ */ import_react17.default.createElement(TextInput, {
|
|
1580
|
-
type,
|
|
1581
|
-
label,
|
|
1582
|
-
disabled,
|
|
1583
|
-
placeholder,
|
|
1584
|
-
inputOnly,
|
|
1585
|
-
getValue: handleGetValue,
|
|
1586
|
-
onValueChange: handleOnValueChange,
|
|
1587
|
-
...restInputProps
|
|
1588
|
-
});
|
|
1589
|
-
};
|
|
1590
|
-
var getInputComponent = (type, format) => {
|
|
1591
|
-
switch (format) {
|
|
1592
|
-
case import_echo_schema10.FormatEnum.GeoPoint:
|
|
1593
|
-
return GeoPointInput;
|
|
1594
|
-
case import_echo_schema10.FormatEnum.Markdown:
|
|
1595
|
-
return MarkdownInput;
|
|
1596
|
-
}
|
|
1597
|
-
switch (type) {
|
|
1598
|
-
case "string":
|
|
1599
|
-
return TextInput;
|
|
1600
|
-
case "number":
|
|
1601
|
-
return NumberInput;
|
|
1602
|
-
case "boolean":
|
|
1603
|
-
return BooleanInput;
|
|
1604
|
-
}
|
|
1605
|
-
};
|
|
1606
|
-
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1086
|
+
var FormField = ({ property, path, readonly, inline, lookupComponent, Custom }) => {
|
|
1607
1087
|
const inputProps = useInputProps(path);
|
|
1608
1088
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1609
|
-
const label = (0,
|
|
1089
|
+
const label = (0, import_react13.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
1610
1090
|
title,
|
|
1611
1091
|
name
|
|
1612
1092
|
]);
|
|
1613
|
-
const placeholder = (0,
|
|
1093
|
+
const placeholder = (0, import_react13.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1614
1094
|
examples,
|
|
1615
1095
|
description
|
|
1616
1096
|
]);
|
|
1617
1097
|
const FoundComponent = lookupComponent?.({
|
|
1618
1098
|
prop: name,
|
|
1619
|
-
schema:
|
|
1099
|
+
schema: import_echo_schema5.S.make(ast),
|
|
1620
1100
|
inputProps: {
|
|
1621
1101
|
type,
|
|
1622
1102
|
format,
|
|
@@ -1627,14 +1107,14 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1627
1107
|
}
|
|
1628
1108
|
});
|
|
1629
1109
|
if (FoundComponent) {
|
|
1630
|
-
return /* @__PURE__ */
|
|
1110
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1631
1111
|
role: "none"
|
|
1632
1112
|
}, FoundComponent);
|
|
1633
1113
|
}
|
|
1634
1114
|
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1635
1115
|
const CustomComponent = Custom?.[jsonPath];
|
|
1636
1116
|
if (CustomComponent) {
|
|
1637
|
-
return /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ import_react13.default.createElement(CustomComponent, {
|
|
1638
1118
|
type,
|
|
1639
1119
|
format,
|
|
1640
1120
|
label,
|
|
@@ -1644,23 +1124,8 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1644
1124
|
...inputProps
|
|
1645
1125
|
});
|
|
1646
1126
|
}
|
|
1647
|
-
const refProps = getRefProps(property);
|
|
1648
|
-
if (refProps) {
|
|
1649
|
-
return /* @__PURE__ */ import_react15.default.createElement(RefField, {
|
|
1650
|
-
ast: refProps.ast,
|
|
1651
|
-
array: refProps.isArray,
|
|
1652
|
-
type,
|
|
1653
|
-
format,
|
|
1654
|
-
label,
|
|
1655
|
-
placeholder,
|
|
1656
|
-
disabled: readonly,
|
|
1657
|
-
inputOnly: inline,
|
|
1658
|
-
onQueryRefOptions,
|
|
1659
|
-
...inputProps
|
|
1660
|
-
});
|
|
1661
|
-
}
|
|
1662
1127
|
if (array) {
|
|
1663
|
-
return /* @__PURE__ */
|
|
1128
|
+
return /* @__PURE__ */ import_react13.default.createElement(ArrayField, {
|
|
1664
1129
|
property,
|
|
1665
1130
|
path,
|
|
1666
1131
|
inputProps,
|
|
@@ -1670,9 +1135,9 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1670
1135
|
}
|
|
1671
1136
|
const InputComponent = getInputComponent(type, format);
|
|
1672
1137
|
if (InputComponent) {
|
|
1673
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1674
1139
|
role: "none"
|
|
1675
|
-
}, /* @__PURE__ */
|
|
1140
|
+
}, /* @__PURE__ */ import_react13.default.createElement(InputComponent, {
|
|
1676
1141
|
type,
|
|
1677
1142
|
format,
|
|
1678
1143
|
label,
|
|
@@ -1683,9 +1148,9 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1683
1148
|
}));
|
|
1684
1149
|
}
|
|
1685
1150
|
if (options) {
|
|
1686
|
-
return /* @__PURE__ */
|
|
1151
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1687
1152
|
role: "none"
|
|
1688
|
-
}, /* @__PURE__ */
|
|
1153
|
+
}, /* @__PURE__ */ import_react13.default.createElement(SelectInput, {
|
|
1689
1154
|
type,
|
|
1690
1155
|
format,
|
|
1691
1156
|
disabled: readonly,
|
|
@@ -1701,27 +1166,23 @@ var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupCo
|
|
|
1701
1166
|
}
|
|
1702
1167
|
if (type === "object") {
|
|
1703
1168
|
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1704
|
-
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast,
|
|
1169
|
+
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_echo_schema5.AST.isTypeLiteral);
|
|
1705
1170
|
if (typeLiteral) {
|
|
1706
|
-
return /* @__PURE__ */
|
|
1171
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1707
1172
|
role: "none"
|
|
1708
|
-
}, !inline && /* @__PURE__ */
|
|
1709
|
-
|
|
1710
|
-
}, label), /* @__PURE__ */ import_react15.default.createElement(FormFields, {
|
|
1711
|
-
schema: import_effect4.Schema.make(typeLiteral),
|
|
1173
|
+
}, !inline && /* @__PURE__ */ import_react13.default.createElement("div", null, label), /* @__PURE__ */ import_react13.default.createElement(FormFields, {
|
|
1174
|
+
schema: import_echo_schema5.S.make(typeLiteral),
|
|
1712
1175
|
path,
|
|
1713
1176
|
readonly,
|
|
1714
|
-
|
|
1715
|
-
Custom,
|
|
1716
|
-
lookupComponent
|
|
1177
|
+
Custom
|
|
1717
1178
|
}));
|
|
1718
1179
|
}
|
|
1719
1180
|
}
|
|
1720
1181
|
return null;
|
|
1721
1182
|
};
|
|
1722
|
-
var FormFields = ({ schema, path, filter, sort, readonly,
|
|
1183
|
+
var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custom }) => {
|
|
1723
1184
|
const values = useFormValues(path);
|
|
1724
|
-
const properties = (0,
|
|
1185
|
+
const properties = (0, import_react13.useMemo)(() => {
|
|
1725
1186
|
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
1726
1187
|
const filtered = filter ? filter(props) : props;
|
|
1727
1188
|
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
@@ -1731,11 +1192,11 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1731
1192
|
filter,
|
|
1732
1193
|
sort
|
|
1733
1194
|
]);
|
|
1734
|
-
return /* @__PURE__ */
|
|
1195
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1735
1196
|
role: "form",
|
|
1736
|
-
className: (0,
|
|
1197
|
+
className: (0, import_react_ui_theme7.mx)("flex flex-col w-full gap-2")
|
|
1737
1198
|
}, properties.map((property) => {
|
|
1738
|
-
return /* @__PURE__ */
|
|
1199
|
+
return /* @__PURE__ */ import_react13.default.createElement(FormField, {
|
|
1739
1200
|
key: property.name,
|
|
1740
1201
|
property,
|
|
1741
1202
|
path: [
|
|
@@ -1743,13 +1204,12 @@ var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, loo
|
|
|
1743
1204
|
property.name
|
|
1744
1205
|
],
|
|
1745
1206
|
readonly,
|
|
1746
|
-
onQueryRefOptions,
|
|
1747
1207
|
lookupComponent,
|
|
1748
1208
|
Custom
|
|
1749
1209
|
});
|
|
1750
|
-
}).filter(
|
|
1210
|
+
}).filter(import_util3.isNotFalsy));
|
|
1751
1211
|
};
|
|
1752
|
-
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 }) => {
|
|
1753
1213
|
const formRef = (0, import_react9.useRef)(null);
|
|
1754
1214
|
const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
|
|
1755
1215
|
autoSave,
|
|
@@ -1777,7 +1237,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1777
1237
|
}, /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
1778
1238
|
ref: formRef,
|
|
1779
1239
|
role: "none",
|
|
1780
|
-
className: (0,
|
|
1240
|
+
className: (0, import_react_ui_theme5.mx)("p-2", classNames),
|
|
1781
1241
|
"data-testid": testId
|
|
1782
1242
|
}, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
|
|
1783
1243
|
schema,
|
|
@@ -1785,7 +1245,6 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1785
1245
|
readonly,
|
|
1786
1246
|
filter,
|
|
1787
1247
|
sort,
|
|
1788
|
-
onQueryRefOptions,
|
|
1789
1248
|
lookupComponent,
|
|
1790
1249
|
Custom
|
|
1791
1250
|
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
@@ -1793,7 +1252,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1793
1252
|
readonly
|
|
1794
1253
|
})));
|
|
1795
1254
|
};
|
|
1796
|
-
var
|
|
1255
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1797
1256
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1798
1257
|
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
1799
1258
|
const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
|
|
@@ -1926,7 +1385,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1926
1385
|
import_log.log.warn("invalid format", {
|
|
1927
1386
|
props
|
|
1928
1387
|
}, {
|
|
1929
|
-
F:
|
|
1388
|
+
F: __dxlog_file3,
|
|
1930
1389
|
L: 174,
|
|
1931
1390
|
S: void 0,
|
|
1932
1391
|
C: (f, a) => f(...a)
|
|
@@ -1950,25 +1409,24 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1950
1409
|
Custom
|
|
1951
1410
|
});
|
|
1952
1411
|
};
|
|
1953
|
-
var
|
|
1412
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1954
1413
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1955
|
-
var ViewMetaSchema =
|
|
1956
|
-
name:
|
|
1957
|
-
[
|
|
1414
|
+
var ViewMetaSchema = import_echo_schema8.S.Struct({
|
|
1415
|
+
name: import_echo_schema8.S.String.annotations({
|
|
1416
|
+
[import_echo_schema8.AST.TitleAnnotationId]: "View"
|
|
1958
1417
|
}),
|
|
1959
|
-
typename:
|
|
1960
|
-
[
|
|
1418
|
+
typename: import_echo_schema8.Format.URL.annotations({
|
|
1419
|
+
[import_echo_schema8.AST.TitleAnnotationId]: "Typename"
|
|
1961
1420
|
})
|
|
1962
|
-
}).pipe(
|
|
1421
|
+
}).pipe(import_echo_schema8.S.mutable);
|
|
1963
1422
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1964
|
-
const { t } = (0,
|
|
1965
|
-
const projection = (0,
|
|
1423
|
+
const { t } = (0, import_react_ui11.useTranslation)(translationKey);
|
|
1424
|
+
const projection = (0, import_react15.useMemo)(() => new import_schema5.ViewProjection(schema.jsonSchema, view), [
|
|
1966
1425
|
schema,
|
|
1967
1426
|
view
|
|
1968
1427
|
]);
|
|
1969
|
-
const [field, setField] = (0,
|
|
1970
|
-
const
|
|
1971
|
-
const viewValues = (0, import_react18.useMemo)(() => {
|
|
1428
|
+
const [field, setField] = (0, import_react15.useState)();
|
|
1429
|
+
const viewValues = (0, import_react15.useMemo)(() => {
|
|
1972
1430
|
return {
|
|
1973
1431
|
name: view.name,
|
|
1974
1432
|
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
@@ -1978,16 +1436,16 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1978
1436
|
}, [
|
|
1979
1437
|
view
|
|
1980
1438
|
]);
|
|
1981
|
-
const handleSelect = (0,
|
|
1439
|
+
const handleSelect = (0, import_react15.useCallback)((field2) => {
|
|
1982
1440
|
setField((f) => f === field2 ? void 0 : field2);
|
|
1983
1441
|
}, []);
|
|
1984
|
-
const handleAdd = (0,
|
|
1985
|
-
(0, import_invariant3.invariant)(!
|
|
1986
|
-
F:
|
|
1987
|
-
L:
|
|
1442
|
+
const handleAdd = (0, import_react15.useCallback)(() => {
|
|
1443
|
+
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1444
|
+
F: __dxlog_file4,
|
|
1445
|
+
L: 76,
|
|
1988
1446
|
S: void 0,
|
|
1989
1447
|
A: [
|
|
1990
|
-
"!
|
|
1448
|
+
"!schema.readonly",
|
|
1991
1449
|
""
|
|
1992
1450
|
]
|
|
1993
1451
|
});
|
|
@@ -1997,13 +1455,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1997
1455
|
schema,
|
|
1998
1456
|
view
|
|
1999
1457
|
]);
|
|
2000
|
-
const handleUpdate = (0,
|
|
2001
|
-
(0, import_invariant3.invariant)(!
|
|
2002
|
-
F:
|
|
2003
|
-
L:
|
|
1458
|
+
const handleUpdate = (0, import_react15.useCallback)(({ name, typename }) => {
|
|
1459
|
+
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1460
|
+
F: __dxlog_file4,
|
|
1461
|
+
L: 83,
|
|
2004
1462
|
S: void 0,
|
|
2005
1463
|
A: [
|
|
2006
|
-
"!
|
|
1464
|
+
"!schema.readonly",
|
|
2007
1465
|
""
|
|
2008
1466
|
]
|
|
2009
1467
|
});
|
|
@@ -2020,13 +1478,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2020
1478
|
view,
|
|
2021
1479
|
onTypenameChanged
|
|
2022
1480
|
]);
|
|
2023
|
-
const handleDelete = (0,
|
|
2024
|
-
(0, import_invariant3.invariant)(!
|
|
2025
|
-
F:
|
|
2026
|
-
L:
|
|
1481
|
+
const handleDelete = (0, import_react15.useCallback)((fieldId) => {
|
|
1482
|
+
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1483
|
+
F: __dxlog_file4,
|
|
1484
|
+
L: 99,
|
|
2027
1485
|
S: void 0,
|
|
2028
1486
|
A: [
|
|
2029
|
-
"!
|
|
1487
|
+
"!schema.readonly",
|
|
2030
1488
|
""
|
|
2031
1489
|
]
|
|
2032
1490
|
});
|
|
@@ -2039,13 +1497,13 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2039
1497
|
field,
|
|
2040
1498
|
onDelete
|
|
2041
1499
|
]);
|
|
2042
|
-
const handleMove = (0,
|
|
2043
|
-
(0, import_invariant3.invariant)(!
|
|
2044
|
-
F:
|
|
2045
|
-
L:
|
|
1500
|
+
const handleMove = (0, import_react15.useCallback)((fromIndex, toIndex) => {
|
|
1501
|
+
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1502
|
+
F: __dxlog_file4,
|
|
1503
|
+
L: 111,
|
|
2046
1504
|
S: void 0,
|
|
2047
1505
|
A: [
|
|
2048
|
-
"!
|
|
1506
|
+
"!schema.readonly",
|
|
2049
1507
|
""
|
|
2050
1508
|
]
|
|
2051
1509
|
});
|
|
@@ -2059,112 +1517,357 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2059
1517
|
schema,
|
|
2060
1518
|
view.fields
|
|
2061
1519
|
]);
|
|
2062
|
-
const handleClose = (0,
|
|
1520
|
+
const handleClose = (0, import_react15.useCallback)(() => setField(void 0), []);
|
|
2063
1521
|
const hiddenProperties = projection.getHiddenProperties();
|
|
2064
|
-
const handleHide = (0,
|
|
1522
|
+
const handleHide = (0, import_react15.useCallback)((fieldId) => {
|
|
2065
1523
|
setField(void 0);
|
|
2066
1524
|
projection.hideFieldProjection(fieldId);
|
|
2067
1525
|
}, [
|
|
2068
1526
|
projection
|
|
2069
1527
|
]);
|
|
2070
|
-
const handleShow = (0,
|
|
1528
|
+
const handleShow = (0, import_react15.useCallback)((property) => {
|
|
2071
1529
|
setField(void 0);
|
|
2072
1530
|
projection.showFieldProjection(property);
|
|
2073
1531
|
}, [
|
|
2074
1532
|
projection
|
|
2075
1533
|
]);
|
|
2076
|
-
return /* @__PURE__ */
|
|
1534
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2077
1535
|
role: "none",
|
|
2078
|
-
className: (0,
|
|
2079
|
-
}, /* @__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, {
|
|
2080
1538
|
autoSave: true,
|
|
2081
1539
|
schema: ViewMetaSchema,
|
|
2082
1540
|
values: viewValues,
|
|
2083
|
-
onSave:
|
|
2084
|
-
|
|
2085
|
-
}), /* @__PURE__ */ import_react18.default.createElement("div", {
|
|
2086
|
-
role: "none",
|
|
2087
|
-
className: "border-bs border-separator min-bs-0 overflow-y-auto"
|
|
2088
|
-
}, /* @__PURE__ */ import_react18.default.createElement("div", {
|
|
1541
|
+
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1542
|
+
}), /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2089
1543
|
role: "none",
|
|
2090
1544
|
className: "p-2"
|
|
2091
|
-
}, /* @__PURE__ */
|
|
2092
|
-
className: (0,
|
|
2093
|
-
}, 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, {
|
|
2094
1548
|
items: view.fields,
|
|
2095
|
-
isItem:
|
|
1549
|
+
isItem: import_echo_schema8.S.is(import_schema5.FieldSchema),
|
|
2096
1550
|
getId: (field2) => field2.id,
|
|
2097
|
-
onMove:
|
|
2098
|
-
}, ({ items: fields }) => /* @__PURE__ */
|
|
1551
|
+
onMove: schema.readonly ? void 0 : handleMove
|
|
1552
|
+
}, ({ items: fields }) => /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, showHeading && /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2099
1553
|
role: "heading",
|
|
2100
1554
|
className: grid
|
|
2101
|
-
}, /* @__PURE__ */
|
|
1555
|
+
}, /* @__PURE__ */ import_react15.default.createElement("div", null), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2102
1556
|
className: "flex items-center text-sm"
|
|
2103
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1557
|
+
}, t("field path label"))), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2104
1558
|
role: "list",
|
|
2105
1559
|
className: "flex flex-col w-full"
|
|
2106
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1560
|
+
}, fields?.map((field2) => /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Item, {
|
|
2107
1561
|
key: field2.id,
|
|
2108
1562
|
item: field2,
|
|
2109
|
-
classNames: (0,
|
|
2110
|
-
}, /* @__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, {
|
|
2111
1565
|
onClick: () => handleSelect(field2)
|
|
2112
|
-
}, field2.path), /* @__PURE__ */
|
|
1566
|
+
}, field2.path), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2113
1567
|
className: "flex items-center gap-2 -ml-4"
|
|
2114
|
-
}, /* @__PURE__ */
|
|
1568
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
2115
1569
|
icon: "ph--eye-slash--regular",
|
|
2116
1570
|
disabled: view.fields.length <= 1,
|
|
2117
1571
|
onClick: () => handleHide(field2.id)
|
|
2118
|
-
}), !
|
|
1572
|
+
}), !schema.readonly && /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
2119
1573
|
icon: "ph--trash--regular",
|
|
2120
1574
|
disabled: view.fields.length <= 1,
|
|
2121
1575
|
onClick: () => handleDelete(field2.id)
|
|
2122
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1576
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2123
1577
|
role: "none",
|
|
2124
1578
|
className: "p-2"
|
|
2125
|
-
}, /* @__PURE__ */
|
|
2126
|
-
className: (0,
|
|
2127
|
-
}, 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, {
|
|
2128
1582
|
items: hiddenProperties,
|
|
2129
1583
|
isItem: (item) => typeof item === "string",
|
|
2130
1584
|
getId: (property) => property
|
|
2131
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1585
|
+
}, ({ items: properties }) => /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2132
1586
|
role: "list",
|
|
2133
1587
|
className: "flex flex-col w-full"
|
|
2134
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1588
|
+
}, properties?.map((property) => /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Item, {
|
|
2135
1589
|
key: property,
|
|
2136
1590
|
item: property,
|
|
2137
|
-
classNames: (0,
|
|
2138
|
-
}, /* @__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, {
|
|
2139
1593
|
icon: "ph--eye--regular",
|
|
2140
1594
|
onClick: () => handleShow(property)
|
|
2141
|
-
}))))))), field && /* @__PURE__ */
|
|
1595
|
+
}))))))), field && /* @__PURE__ */ import_react15.default.createElement(FieldEditor, {
|
|
2142
1596
|
key: field.id,
|
|
2143
1597
|
view,
|
|
2144
1598
|
projection,
|
|
2145
1599
|
field,
|
|
2146
1600
|
registry,
|
|
2147
1601
|
onSave: handleClose
|
|
2148
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1602
|
+
}), !readonly && !field && /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
2149
1603
|
className: "flex p-2 justify-center"
|
|
2150
|
-
}, /* @__PURE__ */
|
|
1604
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui11.IconButton, {
|
|
2151
1605
|
icon: "ph--plus--regular",
|
|
2152
1606
|
label: t("button add property"),
|
|
2153
|
-
onClick:
|
|
1607
|
+
onClick: schema.readonly ? void 0 : handleAdd,
|
|
2154
1608
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2155
1609
|
disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT
|
|
2156
1610
|
})));
|
|
2157
1611
|
};
|
|
1612
|
+
var parseValue = ({ type, format, value }) => {
|
|
1613
|
+
if (value === void 0 || value === null || value === "") {
|
|
1614
|
+
return void 0;
|
|
1615
|
+
}
|
|
1616
|
+
const parseScalar = (type2) => {
|
|
1617
|
+
switch (type2) {
|
|
1618
|
+
case import_echo_schema9.TypeEnum.Boolean: {
|
|
1619
|
+
if (typeof value === "string") {
|
|
1620
|
+
const lowercaseValue = value.toLowerCase();
|
|
1621
|
+
if (lowercaseValue === "0" || lowercaseValue === "false") {
|
|
1622
|
+
return false;
|
|
1623
|
+
} else if (lowercaseValue === "1" || lowercaseValue === "true") {
|
|
1624
|
+
return true;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
return Boolean(value);
|
|
1628
|
+
}
|
|
1629
|
+
case import_echo_schema9.TypeEnum.Number: {
|
|
1630
|
+
const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
|
|
1631
|
+
const num = Number(cleaned);
|
|
1632
|
+
return Number.isNaN(num) ? null : num;
|
|
1633
|
+
}
|
|
1634
|
+
case import_echo_schema9.TypeEnum.String:
|
|
1635
|
+
case import_echo_schema9.TypeEnum.Ref:
|
|
1636
|
+
return String(value);
|
|
1637
|
+
default: {
|
|
1638
|
+
return value;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
};
|
|
1642
|
+
if (!format) {
|
|
1643
|
+
return parseScalar(type);
|
|
1644
|
+
}
|
|
1645
|
+
switch (format) {
|
|
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);
|
|
1655
|
+
}
|
|
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: {
|
|
1662
|
+
const date = new Date(value);
|
|
1663
|
+
return isNaN(date.getTime()) ? null : date;
|
|
1664
|
+
}
|
|
1665
|
+
case import_echo_schema9.FormatEnum.GeoPoint: {
|
|
1666
|
+
if (typeof value === "string") {
|
|
1667
|
+
const cleaned = value.replace(/[^0-9.,-]+/g, "");
|
|
1668
|
+
const parts = cleaned.split(",");
|
|
1669
|
+
if (parts.length === 2) {
|
|
1670
|
+
const lat = parseFloat(parts[0]);
|
|
1671
|
+
const long = parseFloat(parts[1]);
|
|
1672
|
+
if (!isNaN(lat) && !isNaN(long)) {
|
|
1673
|
+
return import_echo_schema9.GeoLocation.toGeoPoint({
|
|
1674
|
+
latitude: lat,
|
|
1675
|
+
longitude: long
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
return [
|
|
1681
|
+
0,
|
|
1682
|
+
0
|
|
1683
|
+
];
|
|
1684
|
+
}
|
|
1685
|
+
default: {
|
|
1686
|
+
return value;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
var cellClassesForFieldType = ({ type, format }) => {
|
|
1691
|
+
if (!format) {
|
|
1692
|
+
switch (type) {
|
|
1693
|
+
case import_echo_schema9.TypeEnum.Number:
|
|
1694
|
+
return [
|
|
1695
|
+
"text-right",
|
|
1696
|
+
"font-mono"
|
|
1697
|
+
];
|
|
1698
|
+
case import_echo_schema9.TypeEnum.Boolean:
|
|
1699
|
+
return [
|
|
1700
|
+
"text-right",
|
|
1701
|
+
"font-mono"
|
|
1702
|
+
];
|
|
1703
|
+
case import_echo_schema9.TypeEnum.String:
|
|
1704
|
+
return void 0;
|
|
1705
|
+
case import_echo_schema9.TypeEnum.Ref:
|
|
1706
|
+
return void 0;
|
|
1707
|
+
default: {
|
|
1708
|
+
return void 0;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
switch (format) {
|
|
1713
|
+
case import_echo_schema9.FormatEnum.Markdown:
|
|
1714
|
+
return void 0;
|
|
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:
|
|
1720
|
+
return [
|
|
1721
|
+
"font-mono",
|
|
1722
|
+
"text-right"
|
|
1723
|
+
];
|
|
1724
|
+
case import_echo_schema9.FormatEnum.Currency:
|
|
1725
|
+
return [
|
|
1726
|
+
"text-right"
|
|
1727
|
+
];
|
|
1728
|
+
case import_echo_schema9.FormatEnum.JSON:
|
|
1729
|
+
case import_echo_schema9.FormatEnum.DID:
|
|
1730
|
+
return [
|
|
1731
|
+
"font-mono"
|
|
1732
|
+
];
|
|
1733
|
+
default:
|
|
1734
|
+
return void 0;
|
|
1735
|
+
}
|
|
1736
|
+
};
|
|
1737
|
+
var pathNotUniqueError = (path) => ({
|
|
1738
|
+
path: "path",
|
|
1739
|
+
message: `'${path}' is already present`
|
|
1740
|
+
});
|
|
1741
|
+
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1742
|
+
const formatScalar = (type2) => {
|
|
1743
|
+
switch (type2) {
|
|
1744
|
+
case import_echo_schema10.TypeEnum.Boolean:
|
|
1745
|
+
return value.toLocaleString().toUpperCase();
|
|
1746
|
+
case import_echo_schema10.TypeEnum.Number:
|
|
1747
|
+
return value.toLocaleString(locale);
|
|
1748
|
+
case import_echo_schema10.TypeEnum.String:
|
|
1749
|
+
case import_echo_schema10.TypeEnum.Ref:
|
|
1750
|
+
return String(value);
|
|
1751
|
+
default: {
|
|
1752
|
+
return String(value);
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1756
|
+
if (!format) {
|
|
1757
|
+
return formatScalar(type);
|
|
1758
|
+
}
|
|
1759
|
+
switch (format) {
|
|
1760
|
+
case import_echo_schema10.FormatEnum.Boolean: {
|
|
1761
|
+
return formatScalar(import_echo_schema10.TypeEnum.Boolean);
|
|
1762
|
+
}
|
|
1763
|
+
case import_echo_schema10.FormatEnum.Number: {
|
|
1764
|
+
return formatScalar(import_echo_schema10.TypeEnum.Number);
|
|
1765
|
+
}
|
|
1766
|
+
case import_echo_schema10.FormatEnum.String:
|
|
1767
|
+
case import_echo_schema10.FormatEnum.Ref: {
|
|
1768
|
+
return formatScalar(import_echo_schema10.TypeEnum.String);
|
|
1769
|
+
}
|
|
1770
|
+
case import_echo_schema10.FormatEnum.Percent: {
|
|
1771
|
+
return `${value * 100}%`;
|
|
1772
|
+
}
|
|
1773
|
+
case import_echo_schema10.FormatEnum.Currency: {
|
|
1774
|
+
return value.toLocaleString(locale, {
|
|
1775
|
+
style: "currency",
|
|
1776
|
+
currency: "USD",
|
|
1777
|
+
minimumFractionDigits: 2,
|
|
1778
|
+
maximumFractionDigits: 2
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1782
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1783
|
+
}
|
|
1784
|
+
case import_echo_schema10.FormatEnum.Time: {
|
|
1785
|
+
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1786
|
+
}
|
|
1787
|
+
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1788
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1789
|
+
}
|
|
1790
|
+
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1791
|
+
if (value === null || value === void 0) {
|
|
1792
|
+
return "";
|
|
1793
|
+
}
|
|
1794
|
+
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1795
|
+
const { latitude, longitude } = import_echo_schema10.GeoLocation.fromGeoPoint(value);
|
|
1796
|
+
return `${latitude},${longitude}`;
|
|
1797
|
+
}
|
|
1798
|
+
return String(value);
|
|
1799
|
+
}
|
|
1800
|
+
default: {
|
|
1801
|
+
if (value === null || value === "undefined") {
|
|
1802
|
+
return "";
|
|
1803
|
+
}
|
|
1804
|
+
return String(value);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
1809
|
+
const formatScalar = (type2) => {
|
|
1810
|
+
switch (type2) {
|
|
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:
|
|
1815
|
+
return String(value);
|
|
1816
|
+
default:
|
|
1817
|
+
return String(value);
|
|
1818
|
+
}
|
|
1819
|
+
};
|
|
1820
|
+
if (!format) {
|
|
1821
|
+
return formatScalar(type);
|
|
1822
|
+
}
|
|
1823
|
+
switch (format) {
|
|
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: {
|
|
1828
|
+
return formatScalar(type);
|
|
1829
|
+
}
|
|
1830
|
+
case import_echo_schema10.FormatEnum.Percent: {
|
|
1831
|
+
return String(value * 100);
|
|
1832
|
+
}
|
|
1833
|
+
case import_echo_schema10.FormatEnum.Currency: {
|
|
1834
|
+
return String(value);
|
|
1835
|
+
}
|
|
1836
|
+
case import_echo_schema10.FormatEnum.DateTime: {
|
|
1837
|
+
const date = new Date(value);
|
|
1838
|
+
return date.toISOString();
|
|
1839
|
+
}
|
|
1840
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1841
|
+
const date = new Date(value);
|
|
1842
|
+
return date.toISOString().split("T")[0];
|
|
1843
|
+
}
|
|
1844
|
+
case import_echo_schema10.FormatEnum.Time: {
|
|
1845
|
+
const date = new Date(value);
|
|
1846
|
+
return date.toISOString().split("T")[1].split(".")[0];
|
|
1847
|
+
}
|
|
1848
|
+
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1849
|
+
if (value === null || value === void 0) {
|
|
1850
|
+
return "";
|
|
1851
|
+
}
|
|
1852
|
+
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1853
|
+
const { latitude, longitude } = import_echo_schema10.GeoLocation.fromGeoPoint(value);
|
|
1854
|
+
return `${latitude},${longitude}`;
|
|
1855
|
+
}
|
|
1856
|
+
return String(value);
|
|
1857
|
+
}
|
|
1858
|
+
default: {
|
|
1859
|
+
return String(value);
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
2158
1863
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2159
1864
|
0 && (module.exports = {
|
|
2160
1865
|
BooleanInput,
|
|
2161
1866
|
ControlFrame,
|
|
2162
1867
|
ControlFrameItem,
|
|
2163
1868
|
ControlGroup,
|
|
2164
|
-
ControlGroupButton,
|
|
2165
1869
|
ControlItem,
|
|
2166
1870
|
ControlItemInput,
|
|
2167
|
-
ControlPage,
|
|
2168
1871
|
ControlSection,
|
|
2169
1872
|
ControlSectionHeading,
|
|
2170
1873
|
DeprecatedFormContainer,
|
|
@@ -2183,18 +1886,14 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
2183
1886
|
ViewEditor,
|
|
2184
1887
|
cellClassesForFieldType,
|
|
2185
1888
|
controlItemClasses,
|
|
2186
|
-
findArrayElementType,
|
|
2187
1889
|
formatForDisplay,
|
|
2188
1890
|
formatForEditing,
|
|
2189
|
-
getRefProps,
|
|
2190
1891
|
parseValue,
|
|
2191
1892
|
pathNotUniqueError,
|
|
2192
1893
|
translations,
|
|
2193
1894
|
useForm,
|
|
2194
1895
|
useFormContext,
|
|
2195
1896
|
useFormValues,
|
|
2196
|
-
useInputProps
|
|
2197
|
-
useQueryRefOptions,
|
|
2198
|
-
useRefQueryLookupHandler
|
|
1897
|
+
useInputProps
|
|
2199
1898
|
});
|
|
2200
1899
|
//# sourceMappingURL=index.cjs.map
|