@dxos/react-ui-form 0.8.1-main.ba2dec9 → 0.8.1-staging.31c3ee1
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 +635 -511
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +710 -580
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +635 -511
- 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.d.ts +20 -0
- package/dist/types/src/components/ControlSection.d.ts.map +1 -0
- package/dist/types/src/components/Form/Form.stories.d.ts +2 -2
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts +1 -1
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts +1 -2
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +4 -4
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts +0 -1
- package/dist/types/src/util/field.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.tsx +113 -0
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/Form/Form.stories.tsx +2 -2
- package/src/components/Form/Input.tsx +1 -1
- package/src/components/Form/custom/SelectOptionsInput.tsx +5 -1
- package/src/components/Form/index.ts +1 -3
- package/src/components/ViewEditor/ViewEditor.stories.tsx +1 -1
- package/src/components/ViewEditor/ViewEditor.tsx +44 -28
- package/src/components/index.ts +1 -1
- package/src/hooks/useForm.ts +10 -1
- package/src/util/field.ts +4 -4
- package/src/util/formatting.ts +9 -10
package/dist/lib/node/index.cjs
CHANGED
|
@@ -29,10 +29,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var node_exports = {};
|
|
30
30
|
__export(node_exports, {
|
|
31
31
|
BooleanInput: () => BooleanInput,
|
|
32
|
+
ControlFrame: () => ControlFrame,
|
|
33
|
+
ControlFrameItem: () => ControlFrameItem,
|
|
34
|
+
ControlGroup: () => ControlGroup,
|
|
35
|
+
ControlItem: () => ControlItem,
|
|
36
|
+
ControlItemInput: () => ControlItemInput,
|
|
37
|
+
ControlSection: () => ControlSection,
|
|
38
|
+
ControlSectionHeading: () => ControlSectionHeading,
|
|
32
39
|
DeprecatedFormContainer: () => DeprecatedFormContainer,
|
|
33
40
|
DeprecatedFormInput: () => DeprecatedFormInput,
|
|
34
41
|
FieldEditor: () => FieldEditor,
|
|
35
42
|
Form: () => Form,
|
|
43
|
+
FormProvider: () => FormProvider,
|
|
36
44
|
GeoPointInput: () => GeoPointInput,
|
|
37
45
|
InputHeader: () => InputHeader,
|
|
38
46
|
MarkdownInput: () => MarkdownInput,
|
|
@@ -43,62 +51,66 @@ __export(node_exports, {
|
|
|
43
51
|
TupleInput: () => TupleInput,
|
|
44
52
|
ViewEditor: () => ViewEditor,
|
|
45
53
|
cellClassesForFieldType: () => cellClassesForFieldType,
|
|
46
|
-
|
|
54
|
+
controlItemClasses: () => controlItemClasses,
|
|
47
55
|
formatForDisplay: () => formatForDisplay,
|
|
48
56
|
formatForEditing: () => formatForEditing,
|
|
49
57
|
parseValue: () => parseValue,
|
|
50
58
|
pathNotUniqueError: () => pathNotUniqueError,
|
|
51
59
|
translations: () => translations_default,
|
|
52
60
|
useForm: () => useForm,
|
|
53
|
-
|
|
61
|
+
useFormContext: () => useFormContext,
|
|
62
|
+
useFormValues: () => useFormValues,
|
|
63
|
+
useInputProps: () => useInputProps
|
|
54
64
|
});
|
|
55
65
|
module.exports = __toCommonJS(node_exports);
|
|
56
66
|
var import_react = __toESM(require("react"));
|
|
57
67
|
var import_react_ui = require("@dxos/react-ui");
|
|
58
68
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
59
69
|
var import_react2 = __toESM(require("react"));
|
|
70
|
+
var import_react_ui2 = require("@dxos/react-ui");
|
|
71
|
+
var import_react3 = __toESM(require("react"));
|
|
60
72
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
61
73
|
var import_log = require("@dxos/log");
|
|
62
|
-
var
|
|
74
|
+
var import_react_ui3 = require("@dxos/react-ui");
|
|
63
75
|
var import_schema = require("@dxos/schema");
|
|
64
|
-
var
|
|
65
|
-
var import_debug = require("@dxos/debug");
|
|
76
|
+
var import_react4 = __toESM(require("react"));
|
|
66
77
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
67
|
-
var import_effect = require("@dxos/effect");
|
|
68
|
-
var import_effect2 = require("effect");
|
|
69
|
-
var import_react4 = require("react");
|
|
70
|
-
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
71
|
-
var import_effect3 = require("@dxos/effect");
|
|
72
|
-
var import_invariant = require("@dxos/invariant");
|
|
73
|
-
var import_log2 = require("@dxos/log");
|
|
74
|
-
var import_schema2 = require("@dxos/schema");
|
|
75
|
-
var import_react5 = __toESM(require("react"));
|
|
76
|
-
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
77
|
-
var import_react_ui3 = require("@dxos/react-ui");
|
|
78
|
-
var import_util = require("@dxos/util");
|
|
79
|
-
var import_react6 = __toESM(require("react"));
|
|
80
78
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
79
|
+
var import_util = require("@dxos/util");
|
|
80
|
+
var import_react5 = __toESM(require("react"));
|
|
81
|
+
var import_react_ui5 = require("@dxos/react-ui");
|
|
81
82
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
82
|
-
var
|
|
83
|
+
var import_react6 = __toESM(require("react"));
|
|
83
84
|
var import_keys = require("@dxos/keys");
|
|
84
|
-
var
|
|
85
|
+
var import_react_ui6 = require("@dxos/react-ui");
|
|
85
86
|
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
86
87
|
var import_react_ui_pickers = require("@dxos/react-ui-pickers");
|
|
87
88
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
88
|
-
var
|
|
89
|
-
var
|
|
89
|
+
var import_react7 = __toESM(require("react"));
|
|
90
|
+
var import_react_ui7 = require("@dxos/react-ui");
|
|
90
91
|
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
91
92
|
var import_util2 = require("@dxos/util");
|
|
93
|
+
var import_react8 = __toESM(require("react"));
|
|
94
|
+
var import_react_ui8 = require("@dxos/react-ui");
|
|
92
95
|
var import_react9 = __toESM(require("react"));
|
|
93
|
-
var import_react_ui7 = require("@dxos/react-ui");
|
|
94
|
-
var import_react10 = __toESM(require("react"));
|
|
95
96
|
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
96
|
-
var
|
|
97
|
-
var
|
|
97
|
+
var import_react10 = __toESM(require("react"));
|
|
98
|
+
var import_react_ui9 = require("@dxos/react-ui");
|
|
98
99
|
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
100
|
+
var import_react11 = __toESM(require("react"));
|
|
101
|
+
var import_debug = require("@dxos/debug");
|
|
102
|
+
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
103
|
+
var import_effect = require("@dxos/effect");
|
|
104
|
+
var import_effect2 = require("effect");
|
|
105
|
+
var import_react12 = require("react");
|
|
106
|
+
var import_echo_schema4 = require("@dxos/echo-schema");
|
|
107
|
+
var import_effect3 = require("@dxos/effect");
|
|
108
|
+
var import_invariant = require("@dxos/invariant");
|
|
109
|
+
var import_log2 = require("@dxos/log");
|
|
110
|
+
var import_schema2 = require("@dxos/schema");
|
|
99
111
|
var import_effect4 = require("effect");
|
|
100
112
|
var import_String = require("effect/String");
|
|
101
|
-
var
|
|
113
|
+
var import_react13 = __toESM(require("react"));
|
|
102
114
|
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
103
115
|
var import_effect5 = require("@dxos/effect");
|
|
104
116
|
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
|
@@ -106,21 +118,23 @@ var import_schema3 = require("@dxos/schema");
|
|
|
106
118
|
var import_util3 = require("@dxos/util");
|
|
107
119
|
var import_effect6 = require("effect");
|
|
108
120
|
var import_String2 = require("effect/String");
|
|
109
|
-
var
|
|
121
|
+
var import_react14 = __toESM(require("react"));
|
|
110
122
|
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
111
123
|
var import_effect7 = require("@dxos/effect");
|
|
112
124
|
var import_invariant2 = require("@dxos/invariant");
|
|
113
|
-
var
|
|
125
|
+
var import_react_ui10 = require("@dxos/react-ui");
|
|
114
126
|
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
|
115
127
|
var import_schema4 = require("@dxos/schema");
|
|
116
128
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
117
|
-
var
|
|
129
|
+
var import_react15 = __toESM(require("react"));
|
|
118
130
|
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
119
|
-
var
|
|
131
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
132
|
+
var import_react_ui11 = require("@dxos/react-ui");
|
|
120
133
|
var import_react_ui_list2 = require("@dxos/react-ui-list");
|
|
121
134
|
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
122
135
|
var import_schema5 = require("@dxos/schema");
|
|
123
136
|
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
137
|
+
var import_format = require("date-fns/format");
|
|
124
138
|
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
125
139
|
var translationKey = "react-ui-form";
|
|
126
140
|
var translations_default = [
|
|
@@ -216,303 +230,108 @@ var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
|
216
230
|
}
|
|
217
231
|
return primary;
|
|
218
232
|
};
|
|
219
|
-
var
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
"AST.isTypeLiteral(schema.ast)",
|
|
227
|
-
""
|
|
228
|
-
]
|
|
229
|
-
});
|
|
230
|
-
const [values, setValues] = (0, import_react4.useState)(initialValues);
|
|
231
|
-
(0, import_react4.useEffect)(() => {
|
|
232
|
-
setValues(initialValues);
|
|
233
|
-
}, [
|
|
234
|
-
initialValues
|
|
235
|
-
]);
|
|
236
|
-
const [touched, setTouched] = (0, import_react4.useState)(createKeySet(initialValues, false));
|
|
237
|
-
const [changed, setChanged] = (0, import_react4.useState)(createKeySet(initialValues, false));
|
|
238
|
-
const [errors, setErrors] = (0, import_react4.useState)({});
|
|
239
|
-
const [saving, setSaving] = (0, import_react4.useState)(false);
|
|
240
|
-
const validate = (0, import_react4.useCallback)((values2) => {
|
|
241
|
-
let errors2 = (0, import_schema2.validateSchema)(schema, values2) ?? [];
|
|
242
|
-
if (errors2.length === 0 && onValidate) {
|
|
243
|
-
const validatedValues = values2;
|
|
244
|
-
errors2 = onValidate(validatedValues) ?? [];
|
|
245
|
-
}
|
|
246
|
-
setErrors(flatMap(errors2));
|
|
247
|
-
const valid = errors2.length === 0;
|
|
248
|
-
return valid;
|
|
249
|
-
}, [
|
|
250
|
-
schema,
|
|
251
|
-
onValidate
|
|
252
|
-
]);
|
|
253
|
-
const [schemaDirty, setSchemaDirty] = (0, import_react4.useState)(false);
|
|
254
|
-
(0, import_react4.useEffect)(() => setSchemaDirty(true), [
|
|
255
|
-
schema
|
|
256
|
-
]);
|
|
257
|
-
(0, import_react4.useEffect)(() => {
|
|
258
|
-
if (schemaDirty) {
|
|
259
|
-
validate(values);
|
|
260
|
-
setSchemaDirty(false);
|
|
261
|
-
}
|
|
262
|
-
}, [
|
|
263
|
-
values,
|
|
264
|
-
schemaDirty
|
|
265
|
-
]);
|
|
266
|
-
const formIsValid = (0, import_react4.useMemo)(() => {
|
|
267
|
-
return Object.keys(errors).length === 0;
|
|
268
|
-
}, [
|
|
269
|
-
errors
|
|
270
|
-
]);
|
|
271
|
-
const canSave = (0, import_react4.useMemo)(() => !saving && // Check if any error paths that are touched have errors.
|
|
272
|
-
!Object.entries(touched).some(([path, isTouched]) => isTouched && Object.keys(errors).some((errorPath) => errorPath === path || errorPath.startsWith(`${path}.`) || errorPath.startsWith(`${path}[`))), [
|
|
273
|
-
touched,
|
|
274
|
-
errors,
|
|
275
|
-
saving
|
|
276
|
-
]);
|
|
277
|
-
const handleSave = (0, import_react4.useCallback)(async () => {
|
|
278
|
-
if (validate(values)) {
|
|
279
|
-
setSaving(true);
|
|
280
|
-
try {
|
|
281
|
-
await onSave?.(values, {
|
|
282
|
-
changed
|
|
283
|
-
});
|
|
284
|
-
} finally {
|
|
285
|
-
setSaving(false);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}, [
|
|
289
|
-
values,
|
|
290
|
-
validate,
|
|
291
|
-
onSave,
|
|
292
|
-
changed
|
|
293
|
-
]);
|
|
294
|
-
const getStatus = (0, import_react4.useCallback)((path) => {
|
|
295
|
-
const jsonPath = Array.isArray(path) ? (0, import_effect3.createJsonPath)(path) : path;
|
|
296
|
-
const matchingError = Object.entries(errors).find(([errorPath]) => errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`));
|
|
297
|
-
return {
|
|
298
|
-
status: matchingError ? "error" : void 0,
|
|
299
|
-
error: matchingError ? matchingError[1] : void 0
|
|
300
|
-
};
|
|
301
|
-
}, [
|
|
302
|
-
errors
|
|
303
|
-
]);
|
|
304
|
-
const getFormValue = (0, import_react4.useCallback)((path) => {
|
|
305
|
-
return (0, import_echo_schema3.getValue)(values, (0, import_effect3.createJsonPath)(path));
|
|
306
|
-
}, [
|
|
307
|
-
values
|
|
308
|
-
]);
|
|
309
|
-
const onValueChange = (0, import_react4.useCallback)((path, type, value) => {
|
|
310
|
-
const jsonPath = (0, import_effect3.createJsonPath)(path);
|
|
311
|
-
let parsedValue = value;
|
|
312
|
-
try {
|
|
313
|
-
if (type === "number") {
|
|
314
|
-
parsedValue = parseFloat(value) || 0;
|
|
315
|
-
}
|
|
316
|
-
} catch (err) {
|
|
317
|
-
import_log2.log.catch(err, void 0, {
|
|
318
|
-
F: __dxlog_file,
|
|
319
|
-
L: 203,
|
|
320
|
-
S: void 0,
|
|
321
|
-
C: (f, a) => f(...a)
|
|
322
|
-
});
|
|
323
|
-
parsedValue = void 0;
|
|
324
|
-
}
|
|
325
|
-
const newValues = {
|
|
326
|
-
...(0, import_echo_schema3.setValue)(values, jsonPath, parsedValue)
|
|
327
|
-
};
|
|
328
|
-
setValues(newValues);
|
|
329
|
-
setChanged((prev) => ({
|
|
330
|
-
...prev,
|
|
331
|
-
[jsonPath]: true
|
|
332
|
-
}));
|
|
333
|
-
onValuesChanged?.(newValues);
|
|
334
|
-
const isValid = validate(newValues);
|
|
335
|
-
if (isValid && onValid) {
|
|
336
|
-
onValid(newValues, {
|
|
337
|
-
changed
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
}, [
|
|
341
|
-
values,
|
|
342
|
-
onValuesChanged,
|
|
343
|
-
validate,
|
|
344
|
-
onValid,
|
|
345
|
-
changed
|
|
346
|
-
]);
|
|
347
|
-
const onTouched = (0, import_react4.useCallback)((path) => {
|
|
348
|
-
const jsonPath = (0, import_effect3.createJsonPath)(path);
|
|
349
|
-
setTouched((touched2) => ({
|
|
350
|
-
...touched2,
|
|
351
|
-
[jsonPath]: true
|
|
352
|
-
}));
|
|
353
|
-
validate(values);
|
|
354
|
-
}, [
|
|
355
|
-
validate,
|
|
356
|
-
values
|
|
357
|
-
]);
|
|
358
|
-
return (0, import_react4.useMemo)(() => ({
|
|
359
|
-
// State.
|
|
360
|
-
values,
|
|
361
|
-
errors,
|
|
362
|
-
touched,
|
|
363
|
-
changed,
|
|
364
|
-
canSave,
|
|
365
|
-
formIsValid,
|
|
366
|
-
// Actions.
|
|
367
|
-
handleSave,
|
|
368
|
-
// Field utils.
|
|
369
|
-
getStatus,
|
|
370
|
-
getValue: getFormValue,
|
|
371
|
-
onValueChange,
|
|
372
|
-
onTouched
|
|
373
|
-
}), [
|
|
374
|
-
values,
|
|
375
|
-
errors,
|
|
376
|
-
touched,
|
|
377
|
-
changed,
|
|
378
|
-
canSave,
|
|
379
|
-
formIsValid,
|
|
380
|
-
handleSave,
|
|
381
|
-
getStatus,
|
|
382
|
-
getFormValue,
|
|
383
|
-
onValueChange,
|
|
384
|
-
onTouched
|
|
385
|
-
]);
|
|
386
|
-
};
|
|
387
|
-
var createKeySet = (obj, value) => {
|
|
388
|
-
(0, import_invariant.invariant)(obj, void 0, {
|
|
389
|
-
F: __dxlog_file,
|
|
390
|
-
L: 265,
|
|
391
|
-
S: void 0,
|
|
392
|
-
A: [
|
|
393
|
-
"obj",
|
|
394
|
-
""
|
|
395
|
-
]
|
|
396
|
-
});
|
|
397
|
-
return Object.keys(obj).reduce((acc, key) => ({
|
|
398
|
-
...acc,
|
|
399
|
-
[key]: value
|
|
400
|
-
}), {});
|
|
401
|
-
};
|
|
402
|
-
var flatMap = (errors) => {
|
|
403
|
-
return errors.reduce((result, { path, message }) => {
|
|
404
|
-
const jsonPath = (0, import_effect3.fromEffectValidationPath)(path);
|
|
405
|
-
if (!(jsonPath in result)) {
|
|
406
|
-
result[jsonPath] = message;
|
|
407
|
-
}
|
|
408
|
-
return result;
|
|
409
|
-
}, {});
|
|
233
|
+
var ControlSectionHeading = ({ title, description }) => {
|
|
234
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
235
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
|
|
236
|
+
className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
|
|
237
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
|
|
238
|
+
className: "pli-4 mlb-4 container-max-width text-description"
|
|
239
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t)));
|
|
410
240
|
};
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
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);
|
|
414
246
|
};
|
|
415
|
-
var
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
247
|
+
var ControlGroup = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
248
|
+
role: "none",
|
|
249
|
+
className: "group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4"
|
|
250
|
+
}, children);
|
|
251
|
+
var ControlFrame = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
252
|
+
role: "none",
|
|
253
|
+
className: "p-4 border border-separator rounded-lg container-max-width grid grid-cols-1 md:grid-cols-[1fr_1fr] gap-2 md:gap-8"
|
|
254
|
+
}, children);
|
|
255
|
+
var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center";
|
|
256
|
+
var controlItemTitleClasses = "text-lg font-normal mbe-2";
|
|
257
|
+
var controlItemDescriptionClasses = "text-base mlb-2 md:mbe-0 text-description";
|
|
258
|
+
var ControlItem = ({ title, description, children }) => {
|
|
259
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
260
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
261
|
+
className: controlItemClasses
|
|
262
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
263
|
+
role: "none"
|
|
264
|
+
}, /* @__PURE__ */ import_react2.default.createElement("h3", {
|
|
265
|
+
className: controlItemTitleClasses
|
|
266
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
|
|
267
|
+
className: controlItemDescriptionClasses
|
|
268
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t))), children);
|
|
419
269
|
};
|
|
420
|
-
var
|
|
421
|
-
const {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
}),
|
|
431
|
-
getStatus,
|
|
432
|
-
getFormValue,
|
|
433
|
-
onValueChange,
|
|
434
|
-
onTouched,
|
|
435
|
-
stablePath
|
|
436
|
-
]);
|
|
270
|
+
var ControlItemInput = ({ title, description, children }) => {
|
|
271
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
272
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Root, null, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
273
|
+
className: controlItemClasses
|
|
274
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
275
|
+
role: "none"
|
|
276
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Label, {
|
|
277
|
+
classNames: controlItemTitleClasses
|
|
278
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.DescriptionAndValidation, null, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Description, {
|
|
279
|
+
classNames: controlItemDescriptionClasses
|
|
280
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t)))), children));
|
|
437
281
|
};
|
|
438
|
-
var
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const inputOptOut = event.target.hasAttribute("data-no-submit");
|
|
449
|
-
const shouldSubmitRegularInput = !inputIsTextarea && keyIsEnter && !modifierUsed;
|
|
450
|
-
const shouldSubmitTextarea = inputIsTextarea && keyIsEnter && event.metaKey;
|
|
451
|
-
if ((shouldSubmitRegularInput || shouldSubmitTextarea) && !inputOptOut) {
|
|
452
|
-
if (!autoSave && form.canSave) {
|
|
453
|
-
form.handleSave();
|
|
454
|
-
}
|
|
455
|
-
if (autoSave && form.formIsValid) {
|
|
456
|
-
event.target.blur();
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
const formElement = formRef.current;
|
|
461
|
-
formElement.addEventListener("keydown", handleKeyDown);
|
|
462
|
-
return () => formElement.removeEventListener("keydown", handleKeyDown);
|
|
463
|
-
}, [
|
|
464
|
-
formRef,
|
|
465
|
-
form.canSave,
|
|
466
|
-
form.formIsValid,
|
|
467
|
-
form.handleSave,
|
|
468
|
-
autoSave
|
|
469
|
-
]);
|
|
470
|
-
return /* @__PURE__ */ import_react3.default.createElement(FormContext.Provider, {
|
|
471
|
-
value: form
|
|
472
|
-
}, children);
|
|
282
|
+
var ControlFrameItem = ({ title, description, children }) => {
|
|
283
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
284
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
285
|
+
role: "group",
|
|
286
|
+
className: "min-is-0"
|
|
287
|
+
}, /* @__PURE__ */ import_react2.default.createElement("h3", {
|
|
288
|
+
className: "text-lg mbe-2"
|
|
289
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
|
|
290
|
+
className: "mlb-2 md:mbe-0 text-description"
|
|
291
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t)), children);
|
|
473
292
|
};
|
|
474
293
|
var InputHeader = ({ children, error }) => {
|
|
475
|
-
return /* @__PURE__ */
|
|
294
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
476
295
|
role: "none",
|
|
477
296
|
className: "flex justify-between items-center mb-1"
|
|
478
|
-
}, children, error && /* @__PURE__ */
|
|
297
|
+
}, children, error && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Root, null, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Trigger, {
|
|
479
298
|
asChild: true
|
|
480
|
-
}, /* @__PURE__ */
|
|
299
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Icon, {
|
|
481
300
|
icon: "ph--warning--regular",
|
|
482
301
|
size: 4,
|
|
483
302
|
classNames: import_react_ui_theme2.errorText
|
|
484
|
-
})), /* @__PURE__ */
|
|
303
|
+
})), /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Content, {
|
|
485
304
|
side: "bottom"
|
|
486
|
-
}, /* @__PURE__ */
|
|
305
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Arrow, null), error)));
|
|
487
306
|
};
|
|
488
307
|
var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
489
|
-
const { t } = (0,
|
|
308
|
+
const { t } = (0, import_react_ui4.useTranslation)(translationKey);
|
|
490
309
|
const { status, error } = getStatus();
|
|
491
|
-
const geoPoint = (0,
|
|
310
|
+
const geoPoint = (0, import_react4.useMemo)(() => getValue3() ?? [
|
|
492
311
|
0,
|
|
493
312
|
0
|
|
494
313
|
], [
|
|
495
314
|
getValue3
|
|
496
315
|
]);
|
|
497
|
-
const geoLocation = (0,
|
|
316
|
+
const geoLocation = (0, import_react4.useMemo)(() => import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint), [
|
|
498
317
|
geoPoint
|
|
499
318
|
]);
|
|
500
|
-
const [longitudeText, setLongitudeText] = (0,
|
|
501
|
-
const [latitudeText, setLatitudeText] = (0,
|
|
502
|
-
(0,
|
|
503
|
-
const location =
|
|
319
|
+
const [longitudeText, setLongitudeText] = (0, import_react4.useState)(geoLocation.longitude?.toString());
|
|
320
|
+
const [latitudeText, setLatitudeText] = (0, import_react4.useState)(geoLocation.latitude?.toString());
|
|
321
|
+
(0, import_react4.useEffect)(() => {
|
|
322
|
+
const location = import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint);
|
|
504
323
|
setLongitudeText(location.longitude.toString());
|
|
505
324
|
setLatitudeText(location.latitude.toString());
|
|
506
325
|
}, [
|
|
507
326
|
geoPoint
|
|
508
327
|
]);
|
|
509
|
-
const handleCoordinateChange = (0,
|
|
328
|
+
const handleCoordinateChange = (0, import_react4.useCallback)((coordinateType, setText) => (event) => {
|
|
510
329
|
const inputText = event.target.value;
|
|
511
330
|
setText(inputText);
|
|
512
331
|
if (inputText !== "" && inputText !== "-") {
|
|
513
332
|
const coord = (0, import_util.safeParseFloat)(inputText);
|
|
514
333
|
if (coord !== void 0 && !isNaN(coord)) {
|
|
515
|
-
const currentLocation =
|
|
334
|
+
const currentLocation = import_echo_schema2.GeoLocation.fromGeoPoint(getValue3() ?? [
|
|
516
335
|
0,
|
|
517
336
|
0
|
|
518
337
|
]);
|
|
@@ -520,7 +339,7 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
520
339
|
...currentLocation,
|
|
521
340
|
[coordinateType]: coord
|
|
522
341
|
};
|
|
523
|
-
const newValue =
|
|
342
|
+
const newValue = import_echo_schema2.GeoLocation.toGeoPoint(newLocation);
|
|
524
343
|
onValueChange(type, newValue);
|
|
525
344
|
}
|
|
526
345
|
}
|
|
@@ -529,14 +348,14 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
529
348
|
onValueChange,
|
|
530
349
|
type
|
|
531
350
|
]);
|
|
532
|
-
return /* @__PURE__ */
|
|
351
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Root, {
|
|
533
352
|
validationValence: status
|
|
534
|
-
}, /* @__PURE__ */
|
|
353
|
+
}, /* @__PURE__ */ import_react4.default.createElement(InputHeader, {
|
|
535
354
|
error
|
|
536
|
-
}, /* @__PURE__ */
|
|
355
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Label, null, label)), /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
537
356
|
role: "none",
|
|
538
357
|
className: "grid grid-cols-2 gap-2"
|
|
539
|
-
}, /* @__PURE__ */
|
|
358
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
|
|
540
359
|
type: "text",
|
|
541
360
|
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
542
361
|
disabled,
|
|
@@ -544,7 +363,7 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
544
363
|
value: latitudeText,
|
|
545
364
|
onChange: handleCoordinateChange("latitude", setLatitudeText),
|
|
546
365
|
onBlur
|
|
547
|
-
}), /* @__PURE__ */
|
|
366
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
|
|
548
367
|
type: "text",
|
|
549
368
|
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
550
369
|
disabled,
|
|
@@ -555,13 +374,13 @@ var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, on
|
|
|
555
374
|
})));
|
|
556
375
|
};
|
|
557
376
|
var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
|
|
558
|
-
const [selected, setSelectedId] = (0,
|
|
559
|
-
const [isNewOption, setIsNewOption] = (0,
|
|
560
|
-
const inputRef = (0,
|
|
561
|
-
const { t } = (0,
|
|
377
|
+
const [selected, setSelectedId] = (0, import_react6.useState)(null);
|
|
378
|
+
const [isNewOption, setIsNewOption] = (0, import_react6.useState)(false);
|
|
379
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
380
|
+
const { t } = (0, import_react_ui6.useTranslation)(translationKey);
|
|
562
381
|
const { status, error } = getStatus();
|
|
563
382
|
const options = getValue3();
|
|
564
|
-
(0,
|
|
383
|
+
(0, import_react6.useEffect)(() => {
|
|
565
384
|
if (options === void 0) {
|
|
566
385
|
onValueChange(type, []);
|
|
567
386
|
}
|
|
@@ -580,7 +399,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
580
399
|
const availableHues = import_react_ui_theme3.hues.filter((hue) => !lastThree.has(hue));
|
|
581
400
|
return availableHues[Math.floor(Math.random() * availableHues.length)] ?? import_react_ui_theme3.hues[Math.floor(Math.random() * import_react_ui_theme3.hues.length)];
|
|
582
401
|
};
|
|
583
|
-
const handleAdd = (0,
|
|
402
|
+
const handleAdd = (0, import_react6.useCallback)(() => {
|
|
584
403
|
const newId = import_keys.PublicKey.random().truncate();
|
|
585
404
|
const newOption = {
|
|
586
405
|
id: newId,
|
|
@@ -598,7 +417,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
598
417
|
type,
|
|
599
418
|
onValueChange
|
|
600
419
|
]);
|
|
601
|
-
const handleDelete = (0,
|
|
420
|
+
const handleDelete = (0, import_react6.useCallback)((id) => {
|
|
602
421
|
const newOptions = options?.filter((option) => option.id !== id) ?? [];
|
|
603
422
|
onValueChange(type, newOptions);
|
|
604
423
|
setSelectedId(null);
|
|
@@ -607,7 +426,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
607
426
|
type,
|
|
608
427
|
onValueChange
|
|
609
428
|
]);
|
|
610
|
-
const handleMove = (0,
|
|
429
|
+
const handleMove = (0, import_react6.useCallback)((from, to) => {
|
|
611
430
|
if (!options) {
|
|
612
431
|
return;
|
|
613
432
|
}
|
|
@@ -622,10 +441,10 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
622
441
|
type,
|
|
623
442
|
onValueChange
|
|
624
443
|
]);
|
|
625
|
-
const handleClick = (0,
|
|
444
|
+
const handleClick = (0, import_react6.useCallback)((id) => {
|
|
626
445
|
setSelectedId((current) => current === id ? null : id);
|
|
627
446
|
}, []);
|
|
628
|
-
const handleTitleChange = (0,
|
|
447
|
+
const handleTitleChange = (0, import_react6.useCallback)((id) => (e) => {
|
|
629
448
|
const newOptions = options?.map((o) => o.id === id ? {
|
|
630
449
|
...o,
|
|
631
450
|
title: e.target.value
|
|
@@ -636,12 +455,12 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
636
455
|
type,
|
|
637
456
|
onValueChange
|
|
638
457
|
]);
|
|
639
|
-
const handleKeyDown = (0,
|
|
458
|
+
const handleKeyDown = (0, import_react6.useCallback)((e) => {
|
|
640
459
|
if (e.key === "Enter") {
|
|
641
460
|
setSelectedId(null);
|
|
642
461
|
}
|
|
643
462
|
}, []);
|
|
644
|
-
const handleColorChange = (0,
|
|
463
|
+
const handleColorChange = (0, import_react6.useCallback)((id) => (hue) => {
|
|
645
464
|
const newOptions = options?.map((o) => o.id === id ? {
|
|
646
465
|
...o,
|
|
647
466
|
color: hue
|
|
@@ -652,7 +471,7 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
652
471
|
type,
|
|
653
472
|
onValueChange
|
|
654
473
|
]);
|
|
655
|
-
(0,
|
|
474
|
+
(0, import_react6.useEffect)(() => {
|
|
656
475
|
if (selected && isNewOption && inputRef.current) {
|
|
657
476
|
inputRef.current.focus();
|
|
658
477
|
setIsNewOption(false);
|
|
@@ -661,43 +480,43 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
661
480
|
selected,
|
|
662
481
|
isNewOption
|
|
663
482
|
]);
|
|
664
|
-
return /* @__PURE__ */
|
|
483
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
|
|
665
484
|
validationValence: status
|
|
666
|
-
}, /* @__PURE__ */
|
|
485
|
+
}, /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
|
|
667
486
|
error
|
|
668
|
-
}, /* @__PURE__ */
|
|
487
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
669
488
|
role: "none"
|
|
670
|
-
}, options && /* @__PURE__ */
|
|
489
|
+
}, options && /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Root, {
|
|
671
490
|
items: options,
|
|
672
491
|
isItem: (item) => true,
|
|
673
492
|
onMove: handleMove
|
|
674
|
-
}, ({ items }) => /* @__PURE__ */
|
|
493
|
+
}, ({ items }) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
675
494
|
role: "list",
|
|
676
495
|
className: "w-full overflow-auto"
|
|
677
|
-
}, items?.map((item) => /* @__PURE__ */
|
|
496
|
+
}, items?.map((item) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
678
497
|
key: item.id
|
|
679
|
-
}, /* @__PURE__ */
|
|
498
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Item, {
|
|
680
499
|
role: "button",
|
|
681
500
|
item,
|
|
682
501
|
classNames: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
683
502
|
"aria-expanded": selected === item.id
|
|
684
|
-
}, /* @__PURE__ */
|
|
503
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
685
504
|
className: "flex items-center"
|
|
686
|
-
}, /* @__PURE__ */
|
|
505
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemTitle, {
|
|
687
506
|
onClick: () => handleClick(item.id),
|
|
688
507
|
classNames: "flex-1"
|
|
689
|
-
}, /* @__PURE__ */
|
|
508
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Tag, {
|
|
690
509
|
palette: item.color
|
|
691
|
-
}, item.title || "\u200B")), /* @__PURE__ */
|
|
510
|
+
}, item.title || "\u200B")), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
|
|
692
511
|
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
693
512
|
onClick: () => handleClick(item.id)
|
|
694
|
-
})), selected === item.id && /* @__PURE__ */
|
|
513
|
+
})), selected === item.id && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
695
514
|
className: "mis-4 mbs-2 flex flex-col gap-1"
|
|
696
|
-
}, /* @__PURE__ */
|
|
515
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, {
|
|
697
516
|
classNames: "text-xs"
|
|
698
|
-
}, t("select option label")), /* @__PURE__ */
|
|
517
|
+
}, t("select option label")), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
699
518
|
className: "flex flex-row items-center gap-1"
|
|
700
|
-
}, /* @__PURE__ */
|
|
519
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.TextInput, {
|
|
701
520
|
placeholder: t("select option label placeholder"),
|
|
702
521
|
ref: selected === item.id ? inputRef : void 0,
|
|
703
522
|
value: item.title,
|
|
@@ -705,173 +524,437 @@ var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3
|
|
|
705
524
|
onKeyDown: handleKeyDown,
|
|
706
525
|
classNames: "flex-1",
|
|
707
526
|
"data-no-submit": true
|
|
708
|
-
}), /* @__PURE__ */
|
|
527
|
+
}), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Toolbar.Root, {
|
|
709
528
|
classNames: "p-0 m-0 !is-auto"
|
|
710
|
-
}, /* @__PURE__ */
|
|
529
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_pickers.HuePicker, {
|
|
711
530
|
value: item.color,
|
|
712
|
-
onChange: handleColorChange(item.id)
|
|
713
|
-
|
|
531
|
+
onChange: handleColorChange(item.id),
|
|
532
|
+
rootVariant: "toolbar-button"
|
|
533
|
+
})), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.IconButton, {
|
|
714
534
|
icon: "ph--trash--fill",
|
|
715
535
|
iconOnly: true,
|
|
716
536
|
label: t("select option delete"),
|
|
717
537
|
onClick: () => handleDelete(item.id)
|
|
718
|
-
})))))), /* @__PURE__ */
|
|
538
|
+
})))))), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
719
539
|
role: "listitem"
|
|
720
|
-
}, /* @__PURE__ */
|
|
540
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
721
541
|
role: "button",
|
|
722
542
|
className: (0, import_react_ui_theme3.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
723
543
|
onClick: handleAdd
|
|
724
|
-
}, /* @__PURE__ */
|
|
544
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
725
545
|
className: "flex items-center gap-1"
|
|
726
|
-
}, /* @__PURE__ */
|
|
546
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
|
|
727
547
|
icon: "ph--plus--regular"
|
|
728
|
-
}), /* @__PURE__ */
|
|
548
|
+
}), /* @__PURE__ */ import_react6.default.createElement("span", {
|
|
729
549
|
className: "text-sm"
|
|
730
550
|
}, t("select option add")))))))));
|
|
731
551
|
};
|
|
732
|
-
var gridCols = [
|
|
733
|
-
"grid-cols-1",
|
|
734
|
-
"grid-cols-2",
|
|
735
|
-
"grid-cols-3",
|
|
736
|
-
"grid-cols-4"
|
|
737
|
-
];
|
|
738
|
-
var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
739
|
-
const { status, error } = getStatus();
|
|
740
|
-
const values = getValue3() ?? {};
|
|
741
|
-
return /* @__PURE__ */
|
|
742
|
-
validationValence: status
|
|
743
|
-
}, /* @__PURE__ */
|
|
744
|
-
error
|
|
745
|
-
}, /* @__PURE__ */
|
|
746
|
-
className: (0, import_react_ui_theme4.mx)("grid gap-2", gridCols[binding.length - 1])
|
|
747
|
-
}, binding.map((prop) => /* @__PURE__ */
|
|
748
|
-
key: prop,
|
|
749
|
-
type: "number",
|
|
750
|
-
disabled,
|
|
751
|
-
value: values[prop],
|
|
752
|
-
onChange: (event) => onValueChange(type, {
|
|
753
|
-
...values,
|
|
754
|
-
[prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
|
|
755
|
-
}),
|
|
756
|
-
onBlur
|
|
757
|
-
}))));
|
|
552
|
+
var gridCols = [
|
|
553
|
+
"grid-cols-1",
|
|
554
|
+
"grid-cols-2",
|
|
555
|
+
"grid-cols-3",
|
|
556
|
+
"grid-cols-4"
|
|
557
|
+
];
|
|
558
|
+
var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
559
|
+
const { status, error } = getStatus();
|
|
560
|
+
const values = getValue3() ?? {};
|
|
561
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Root, {
|
|
562
|
+
validationValence: status
|
|
563
|
+
}, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
|
|
564
|
+
error
|
|
565
|
+
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
566
|
+
className: (0, import_react_ui_theme4.mx)("grid gap-2", gridCols[binding.length - 1])
|
|
567
|
+
}, binding.map((prop) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.TextInput, {
|
|
568
|
+
key: prop,
|
|
569
|
+
type: "number",
|
|
570
|
+
disabled,
|
|
571
|
+
value: values[prop],
|
|
572
|
+
onChange: (event) => onValueChange(type, {
|
|
573
|
+
...values,
|
|
574
|
+
[prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
|
|
575
|
+
}),
|
|
576
|
+
onBlur
|
|
577
|
+
}))));
|
|
578
|
+
};
|
|
579
|
+
var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
580
|
+
const { status, error } = getStatus();
|
|
581
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
582
|
+
validationValence: status
|
|
583
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
584
|
+
error
|
|
585
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
|
|
586
|
+
disabled,
|
|
587
|
+
placeholder,
|
|
588
|
+
value: getValue3() ?? "",
|
|
589
|
+
onChange: (event) => onValueChange(type, event.target.value),
|
|
590
|
+
onBlur
|
|
591
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
|
|
592
|
+
};
|
|
593
|
+
var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
594
|
+
const { status, error } = getStatus();
|
|
595
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
596
|
+
validationValence: status
|
|
597
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
598
|
+
error
|
|
599
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
|
|
600
|
+
type: "number",
|
|
601
|
+
disabled,
|
|
602
|
+
placeholder,
|
|
603
|
+
value: getValue3() ?? 0,
|
|
604
|
+
onChange: (event) => onValueChange(type, event.target.value),
|
|
605
|
+
onBlur
|
|
606
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
607
|
+
};
|
|
608
|
+
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
|
|
609
|
+
const { status, error } = getStatus();
|
|
610
|
+
const checked = Boolean(getValue3());
|
|
611
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
612
|
+
validationValence: status
|
|
613
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
614
|
+
error
|
|
615
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Switch, {
|
|
616
|
+
checked,
|
|
617
|
+
onCheckedChange: (value) => onValueChange(type, value)
|
|
618
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
619
|
+
};
|
|
620
|
+
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
621
|
+
const { status, error } = getStatus();
|
|
622
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
623
|
+
validationValence: status
|
|
624
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
625
|
+
error
|
|
626
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
|
|
627
|
+
value: getValue3(),
|
|
628
|
+
onValueChange: (value) => onValueChange(type, value)
|
|
629
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
|
|
630
|
+
classNames: "is-full",
|
|
631
|
+
disabled,
|
|
632
|
+
placeholder
|
|
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 }) => (
|
|
634
|
+
// NOTE: Numeric values are converted to and from strings.
|
|
635
|
+
/* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
|
|
636
|
+
key: String(value),
|
|
637
|
+
value: String(value)
|
|
638
|
+
}, label2 ?? String(value))
|
|
639
|
+
)))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
640
|
+
};
|
|
641
|
+
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
642
|
+
const { status, error } = getStatus();
|
|
643
|
+
const textareaRef = (0, import_react8.useRef)(null);
|
|
644
|
+
const adjustHeight = (0, import_react8.useCallback)(() => {
|
|
645
|
+
const textarea = textareaRef.current;
|
|
646
|
+
if (textarea) {
|
|
647
|
+
textarea.style.blockSize = "auto";
|
|
648
|
+
textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
|
|
649
|
+
}
|
|
650
|
+
}, []);
|
|
651
|
+
(0, import_react8.useEffect)(() => {
|
|
652
|
+
adjustHeight();
|
|
653
|
+
}, [
|
|
654
|
+
adjustHeight
|
|
655
|
+
]);
|
|
656
|
+
(0, import_react8.useEffect)(() => {
|
|
657
|
+
adjustHeight();
|
|
658
|
+
}, [
|
|
659
|
+
getValue3(),
|
|
660
|
+
adjustHeight
|
|
661
|
+
]);
|
|
662
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
663
|
+
validationValence: status
|
|
664
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
665
|
+
error
|
|
666
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextArea, {
|
|
667
|
+
ref: textareaRef,
|
|
668
|
+
disabled,
|
|
669
|
+
placeholder,
|
|
670
|
+
value: getValue3() ?? "",
|
|
671
|
+
classNames: "min-bs-auto max-h-40 overflow-auto",
|
|
672
|
+
onChange: (event) => onValueChange(type, event.target.value),
|
|
673
|
+
onBlur,
|
|
674
|
+
style: {
|
|
675
|
+
resize: "none"
|
|
676
|
+
},
|
|
677
|
+
spellCheck: false
|
|
678
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
|
|
679
|
+
};
|
|
680
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.ts";
|
|
681
|
+
var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
|
|
682
|
+
(0, import_invariant.invariant)(import_effect2.SchemaAST.isTypeLiteral(schema.ast), void 0, {
|
|
683
|
+
F: __dxlog_file,
|
|
684
|
+
L: 93,
|
|
685
|
+
S: void 0,
|
|
686
|
+
A: [
|
|
687
|
+
"AST.isTypeLiteral(schema.ast)",
|
|
688
|
+
""
|
|
689
|
+
]
|
|
690
|
+
});
|
|
691
|
+
const [values, setValues] = (0, import_react12.useState)(initialValues);
|
|
692
|
+
(0, import_react12.useEffect)(() => {
|
|
693
|
+
setValues(initialValues);
|
|
694
|
+
}, [
|
|
695
|
+
initialValues
|
|
696
|
+
]);
|
|
697
|
+
const [touched, setTouched] = (0, import_react12.useState)(createKeySet(initialValues, false));
|
|
698
|
+
const [changed, setChanged] = (0, import_react12.useState)(createKeySet(initialValues, false));
|
|
699
|
+
const [errors, setErrors] = (0, import_react12.useState)({});
|
|
700
|
+
const [saving, setSaving] = (0, import_react12.useState)(false);
|
|
701
|
+
const validate = (0, import_react12.useCallback)((values2) => {
|
|
702
|
+
let errors2 = (0, import_schema2.validateSchema)(schema, values2) ?? [];
|
|
703
|
+
if (errors2.length === 0 && onValidate) {
|
|
704
|
+
const validatedValues = values2;
|
|
705
|
+
errors2 = onValidate(validatedValues) ?? [];
|
|
706
|
+
}
|
|
707
|
+
setErrors(flatMap(errors2));
|
|
708
|
+
const valid = errors2.length === 0;
|
|
709
|
+
return valid;
|
|
710
|
+
}, [
|
|
711
|
+
schema,
|
|
712
|
+
onValidate
|
|
713
|
+
]);
|
|
714
|
+
const [schemaDirty, setSchemaDirty] = (0, import_react12.useState)(false);
|
|
715
|
+
(0, import_react12.useEffect)(() => setSchemaDirty(true), [
|
|
716
|
+
schema
|
|
717
|
+
]);
|
|
718
|
+
(0, import_react12.useEffect)(() => {
|
|
719
|
+
if (schemaDirty) {
|
|
720
|
+
validate(values);
|
|
721
|
+
setSchemaDirty(false);
|
|
722
|
+
}
|
|
723
|
+
}, [
|
|
724
|
+
values,
|
|
725
|
+
schemaDirty
|
|
726
|
+
]);
|
|
727
|
+
const formIsValid = (0, import_react12.useMemo)(() => {
|
|
728
|
+
return Object.keys(errors).length === 0;
|
|
729
|
+
}, [
|
|
730
|
+
errors
|
|
731
|
+
]);
|
|
732
|
+
const canSave = (0, import_react12.useMemo)(() => !saving && // Check if any error paths that are touched have errors.
|
|
733
|
+
!Object.entries(touched).some(([path, isTouched]) => isTouched && Object.keys(errors).some((errorPath) => errorPath === path || errorPath.startsWith(`${path}.`) || errorPath.startsWith(`${path}[`))), [
|
|
734
|
+
touched,
|
|
735
|
+
errors,
|
|
736
|
+
saving
|
|
737
|
+
]);
|
|
738
|
+
const handleSave = (0, import_react12.useCallback)(async () => {
|
|
739
|
+
if (validate(values)) {
|
|
740
|
+
setSaving(true);
|
|
741
|
+
try {
|
|
742
|
+
await onSave?.(values, {
|
|
743
|
+
changed
|
|
744
|
+
});
|
|
745
|
+
} finally {
|
|
746
|
+
setSaving(false);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}, [
|
|
750
|
+
values,
|
|
751
|
+
validate,
|
|
752
|
+
onSave,
|
|
753
|
+
changed
|
|
754
|
+
]);
|
|
755
|
+
const getStatus = (0, import_react12.useCallback)((path) => {
|
|
756
|
+
const jsonPath = Array.isArray(path) ? (0, import_effect3.createJsonPath)(path) : path;
|
|
757
|
+
const matchingError = Object.entries(errors).find(([errorPath]) => errorPath === jsonPath || errorPath.startsWith(`${jsonPath}.`) || errorPath.startsWith(`${jsonPath}[`));
|
|
758
|
+
const isTouched = touched[jsonPath];
|
|
759
|
+
if (!isTouched) {
|
|
760
|
+
return {
|
|
761
|
+
status: void 0,
|
|
762
|
+
error: void 0
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
return {
|
|
766
|
+
status: matchingError ? "error" : void 0,
|
|
767
|
+
error: matchingError ? matchingError[1] : void 0
|
|
768
|
+
};
|
|
769
|
+
}, [
|
|
770
|
+
errors,
|
|
771
|
+
touched
|
|
772
|
+
]);
|
|
773
|
+
const getFormValue = (0, import_react12.useCallback)((path) => {
|
|
774
|
+
return (0, import_echo_schema4.getValue)(values, (0, import_effect3.createJsonPath)(path));
|
|
775
|
+
}, [
|
|
776
|
+
values
|
|
777
|
+
]);
|
|
778
|
+
const onValueChange = (0, import_react12.useCallback)((path, type, value) => {
|
|
779
|
+
const jsonPath = (0, import_effect3.createJsonPath)(path);
|
|
780
|
+
let parsedValue = value;
|
|
781
|
+
try {
|
|
782
|
+
if (type === "number") {
|
|
783
|
+
parsedValue = parseFloat(value) || 0;
|
|
784
|
+
}
|
|
785
|
+
} catch (err) {
|
|
786
|
+
import_log2.log.catch(err, void 0, {
|
|
787
|
+
F: __dxlog_file,
|
|
788
|
+
L: 212,
|
|
789
|
+
S: void 0,
|
|
790
|
+
C: (f, a) => f(...a)
|
|
791
|
+
});
|
|
792
|
+
parsedValue = void 0;
|
|
793
|
+
}
|
|
794
|
+
const newValues = {
|
|
795
|
+
...(0, import_echo_schema4.setValue)(values, jsonPath, parsedValue)
|
|
796
|
+
};
|
|
797
|
+
setValues(newValues);
|
|
798
|
+
setChanged((prev) => ({
|
|
799
|
+
...prev,
|
|
800
|
+
[jsonPath]: true
|
|
801
|
+
}));
|
|
802
|
+
onValuesChanged?.(newValues);
|
|
803
|
+
const isValid = validate(newValues);
|
|
804
|
+
if (isValid && onValid) {
|
|
805
|
+
onValid(newValues, {
|
|
806
|
+
changed
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
}, [
|
|
810
|
+
values,
|
|
811
|
+
onValuesChanged,
|
|
812
|
+
validate,
|
|
813
|
+
onValid,
|
|
814
|
+
changed
|
|
815
|
+
]);
|
|
816
|
+
const onTouched = (0, import_react12.useCallback)((path) => {
|
|
817
|
+
const jsonPath = (0, import_effect3.createJsonPath)(path);
|
|
818
|
+
setTouched((touched2) => ({
|
|
819
|
+
...touched2,
|
|
820
|
+
[jsonPath]: true
|
|
821
|
+
}));
|
|
822
|
+
validate(values);
|
|
823
|
+
}, [
|
|
824
|
+
validate,
|
|
825
|
+
values
|
|
826
|
+
]);
|
|
827
|
+
return (0, import_react12.useMemo)(() => ({
|
|
828
|
+
// State.
|
|
829
|
+
values,
|
|
830
|
+
errors,
|
|
831
|
+
touched,
|
|
832
|
+
changed,
|
|
833
|
+
canSave,
|
|
834
|
+
formIsValid,
|
|
835
|
+
// Actions.
|
|
836
|
+
handleSave,
|
|
837
|
+
// Field utils.
|
|
838
|
+
getStatus,
|
|
839
|
+
getValue: getFormValue,
|
|
840
|
+
onValueChange,
|
|
841
|
+
onTouched
|
|
842
|
+
}), [
|
|
843
|
+
values,
|
|
844
|
+
errors,
|
|
845
|
+
touched,
|
|
846
|
+
changed,
|
|
847
|
+
canSave,
|
|
848
|
+
formIsValid,
|
|
849
|
+
handleSave,
|
|
850
|
+
getStatus,
|
|
851
|
+
getFormValue,
|
|
852
|
+
onValueChange,
|
|
853
|
+
onTouched
|
|
854
|
+
]);
|
|
855
|
+
};
|
|
856
|
+
var createKeySet = (obj, value) => {
|
|
857
|
+
(0, import_invariant.invariant)(obj, void 0, {
|
|
858
|
+
F: __dxlog_file,
|
|
859
|
+
L: 274,
|
|
860
|
+
S: void 0,
|
|
861
|
+
A: [
|
|
862
|
+
"obj",
|
|
863
|
+
""
|
|
864
|
+
]
|
|
865
|
+
});
|
|
866
|
+
return Object.keys(obj).reduce((acc, key) => ({
|
|
867
|
+
...acc,
|
|
868
|
+
[key]: value
|
|
869
|
+
}), {});
|
|
758
870
|
};
|
|
759
|
-
var
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
placeholder,
|
|
768
|
-
value: getValue3() ?? "",
|
|
769
|
-
onChange: (event) => onValueChange(type, event.target.value),
|
|
770
|
-
onBlur
|
|
771
|
-
}), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Validation, null, error));
|
|
871
|
+
var flatMap = (errors) => {
|
|
872
|
+
return errors.reduce((result, { path, message }) => {
|
|
873
|
+
const jsonPath = (0, import_effect3.fromEffectValidationPath)(path);
|
|
874
|
+
if (!(jsonPath in result)) {
|
|
875
|
+
result[jsonPath] = message;
|
|
876
|
+
}
|
|
877
|
+
return result;
|
|
878
|
+
}, {});
|
|
772
879
|
};
|
|
773
|
-
var
|
|
774
|
-
|
|
775
|
-
return
|
|
776
|
-
validationValence: status
|
|
777
|
-
}, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
|
|
778
|
-
error
|
|
779
|
-
}, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.TextInput, {
|
|
780
|
-
type: "number",
|
|
781
|
-
disabled,
|
|
782
|
-
placeholder,
|
|
783
|
-
value: getValue3() ?? 0,
|
|
784
|
-
onChange: (event) => onValueChange(type, event.target.value),
|
|
785
|
-
onBlur
|
|
786
|
-
}), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.DescriptionAndValidation, null, error));
|
|
880
|
+
var FormContext = /* @__PURE__ */ (0, import_react11.createContext)(void 0);
|
|
881
|
+
var useFormContext = () => {
|
|
882
|
+
return (0, import_react11.useContext)(FormContext) ?? (0, import_debug.raise)(new Error("Missing FormContext"));
|
|
787
883
|
};
|
|
788
|
-
var
|
|
789
|
-
const {
|
|
790
|
-
const
|
|
791
|
-
return
|
|
792
|
-
validationValence: status
|
|
793
|
-
}, !inputOnly && /* @__PURE__ */ import_react9.default.createElement(InputHeader, {
|
|
794
|
-
error
|
|
795
|
-
}, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Switch, {
|
|
796
|
-
checked,
|
|
797
|
-
onCheckedChange: (value) => onValueChange(type, value)
|
|
798
|
-
}), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.DescriptionAndValidation, null, error));
|
|
884
|
+
var useFormValues = (path = []) => {
|
|
885
|
+
const { values: formValues } = useFormContext();
|
|
886
|
+
const jsonPath = (0, import_effect.createJsonPath)(path);
|
|
887
|
+
return (0, import_echo_schema3.getValue)(formValues, jsonPath);
|
|
799
888
|
};
|
|
800
|
-
var
|
|
801
|
-
const {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
onValueChange: (value) => onValueChange(type, value)
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
value: String(value)
|
|
818
|
-
}, label2 ?? String(value))
|
|
819
|
-
)))))), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.DescriptionAndValidation, null, error));
|
|
889
|
+
var useInputProps = (path = []) => {
|
|
890
|
+
const { getStatus, getValue: getFormValue, onValueChange, onTouched } = useFormContext();
|
|
891
|
+
const stablePath = (0, import_react11.useMemo)(() => path, [
|
|
892
|
+
Array.isArray(path) ? path.join(".") : path
|
|
893
|
+
]);
|
|
894
|
+
return (0, import_react11.useMemo)(() => ({
|
|
895
|
+
getStatus: () => getStatus(stablePath),
|
|
896
|
+
getValue: () => getFormValue(stablePath),
|
|
897
|
+
onValueChange: (type, value) => onValueChange(stablePath, type, value),
|
|
898
|
+
onBlur: () => onTouched(stablePath)
|
|
899
|
+
}), [
|
|
900
|
+
getStatus,
|
|
901
|
+
getFormValue,
|
|
902
|
+
onValueChange,
|
|
903
|
+
onTouched,
|
|
904
|
+
stablePath
|
|
905
|
+
]);
|
|
820
906
|
};
|
|
821
|
-
var
|
|
822
|
-
const
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
if (textarea) {
|
|
827
|
-
textarea.style.blockSize = "auto";
|
|
828
|
-
textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
|
|
907
|
+
var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
908
|
+
const form = useForm(formOptions);
|
|
909
|
+
(0, import_react11.useEffect)(() => {
|
|
910
|
+
if (!formRef?.current) {
|
|
911
|
+
return;
|
|
829
912
|
}
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
913
|
+
const handleKeyDown = (event) => {
|
|
914
|
+
const keyIsEnter = event.key === "Enter";
|
|
915
|
+
const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
|
|
916
|
+
const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
|
|
917
|
+
const inputOptOut = event.target.hasAttribute("data-no-submit");
|
|
918
|
+
const shouldSubmitRegularInput = !inputIsTextarea && keyIsEnter && !modifierUsed;
|
|
919
|
+
const shouldSubmitTextarea = inputIsTextarea && keyIsEnter && event.metaKey;
|
|
920
|
+
if ((shouldSubmitRegularInput || shouldSubmitTextarea) && !inputOptOut) {
|
|
921
|
+
if (!autoSave && form.canSave) {
|
|
922
|
+
form.handleSave();
|
|
923
|
+
}
|
|
924
|
+
if (autoSave && form.formIsValid) {
|
|
925
|
+
event.target.blur();
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
const formElement = formRef.current;
|
|
930
|
+
formElement.addEventListener("keydown", handleKeyDown);
|
|
931
|
+
return () => formElement.removeEventListener("keydown", handleKeyDown);
|
|
838
932
|
}, [
|
|
839
|
-
|
|
840
|
-
|
|
933
|
+
formRef,
|
|
934
|
+
form.canSave,
|
|
935
|
+
form.formIsValid,
|
|
936
|
+
form.handleSave,
|
|
937
|
+
autoSave
|
|
841
938
|
]);
|
|
842
|
-
return /* @__PURE__ */
|
|
843
|
-
|
|
844
|
-
},
|
|
845
|
-
error
|
|
846
|
-
}, /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.TextArea, {
|
|
847
|
-
ref: textareaRef,
|
|
848
|
-
disabled,
|
|
849
|
-
placeholder,
|
|
850
|
-
value: getValue3() ?? "",
|
|
851
|
-
classNames: "min-bs-auto max-h-40 overflow-auto",
|
|
852
|
-
onChange: (event) => onValueChange(type, event.target.value),
|
|
853
|
-
onBlur,
|
|
854
|
-
style: {
|
|
855
|
-
resize: "none"
|
|
856
|
-
},
|
|
857
|
-
spellCheck: false
|
|
858
|
-
}), inputOnly && /* @__PURE__ */ import_react9.default.createElement(import_react_ui7.Input.Validation, null, error));
|
|
939
|
+
return /* @__PURE__ */ import_react11.default.createElement(FormContext.Provider, {
|
|
940
|
+
value: form
|
|
941
|
+
}, children);
|
|
859
942
|
};
|
|
860
943
|
var FormActions = ({ onCancel, readonly }) => {
|
|
861
|
-
const { t } = (0,
|
|
944
|
+
const { t } = (0, import_react_ui9.useTranslation)(translationKey);
|
|
862
945
|
const { canSave, handleSave } = useFormContext();
|
|
863
|
-
return /* @__PURE__ */
|
|
946
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
864
947
|
role: "none",
|
|
865
948
|
className: "mt-2 flex justify-center"
|
|
866
|
-
}, /* @__PURE__ */
|
|
949
|
+
}, /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
867
950
|
role: "none",
|
|
868
951
|
className: (0, import_react_ui_theme6.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
|
|
869
|
-
}, onCancel && !readonly && /* @__PURE__ */
|
|
952
|
+
}, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
870
953
|
"data-testid": "cancel-button",
|
|
871
954
|
icon: "ph--x--regular",
|
|
872
955
|
label: t("button cancel"),
|
|
873
956
|
onClick: onCancel
|
|
874
|
-
}), handleSave && /* @__PURE__ */
|
|
957
|
+
}), handleSave && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
875
958
|
type: "submit",
|
|
876
959
|
"data-testid": "save-button",
|
|
877
960
|
disabled: !canSave,
|
|
@@ -883,7 +966,7 @@ var FormActions = ({ onCancel, readonly }) => {
|
|
|
883
966
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
884
967
|
var padding = "px-2";
|
|
885
968
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
886
|
-
const { t } = (0,
|
|
969
|
+
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
887
970
|
const { ast, name, type, title } = property;
|
|
888
971
|
const values = useFormValues(path ?? []);
|
|
889
972
|
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
@@ -909,7 +992,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
909
992
|
prop.defaultValue
|
|
910
993
|
]));
|
|
911
994
|
};
|
|
912
|
-
const newValue = (0,
|
|
995
|
+
const newValue = (0, import_react14.useMemo)(() => {
|
|
913
996
|
if (type === "object" && elementType) {
|
|
914
997
|
return getDefaultObjectValue(elementType);
|
|
915
998
|
} else {
|
|
@@ -919,7 +1002,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
919
1002
|
type,
|
|
920
1003
|
elementType
|
|
921
1004
|
]);
|
|
922
|
-
const handleAdd = (0,
|
|
1005
|
+
const handleAdd = (0, import_react14.useCallback)(() => {
|
|
923
1006
|
inputProps.onValueChange(type, [
|
|
924
1007
|
...values,
|
|
925
1008
|
newValue
|
|
@@ -931,7 +1014,7 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
931
1014
|
newValue,
|
|
932
1015
|
values
|
|
933
1016
|
]);
|
|
934
|
-
const handleRemove = (0,
|
|
1017
|
+
const handleRemove = (0, import_react14.useCallback)((index) => {
|
|
935
1018
|
const newValues = values.filter((_, i) => i !== index);
|
|
936
1019
|
inputProps.onValueChange(type, newValues);
|
|
937
1020
|
}, [
|
|
@@ -942,20 +1025,20 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
942
1025
|
if (!elementType) {
|
|
943
1026
|
return null;
|
|
944
1027
|
}
|
|
945
|
-
return /* @__PURE__ */
|
|
1028
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
946
1029
|
role: "none",
|
|
947
1030
|
className: (0, import_react_ui_theme8.mx)(padding)
|
|
948
|
-
}, /* @__PURE__ */
|
|
1031
|
+
}, /* @__PURE__ */ import_react14.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
949
1032
|
role: "none",
|
|
950
1033
|
className: "flex flex-col gap-1"
|
|
951
|
-
}, values.map((_value, index) => /* @__PURE__ */
|
|
1034
|
+
}, values.map((_value, index) => /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
952
1035
|
key: index,
|
|
953
1036
|
role: "none",
|
|
954
1037
|
className: "flex items-center gap-1"
|
|
955
|
-
}, /* @__PURE__ */
|
|
1038
|
+
}, /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
956
1039
|
role: "none",
|
|
957
1040
|
className: "flex-1"
|
|
958
|
-
}, /* @__PURE__ */
|
|
1041
|
+
}, /* @__PURE__ */ import_react14.default.createElement(FormField, {
|
|
959
1042
|
property: {
|
|
960
1043
|
...property,
|
|
961
1044
|
array: false,
|
|
@@ -969,15 +1052,15 @@ var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponen
|
|
|
969
1052
|
inline: true,
|
|
970
1053
|
Custom,
|
|
971
1054
|
lookupComponent
|
|
972
|
-
})), /* @__PURE__ */
|
|
1055
|
+
})), /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
|
|
973
1056
|
icon: "ph--trash--regular",
|
|
974
1057
|
iconOnly: true,
|
|
975
1058
|
label: t("button remove"),
|
|
976
1059
|
onClick: () => handleRemove(index)
|
|
977
|
-
})))), /* @__PURE__ */
|
|
1060
|
+
})))), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
978
1061
|
role: "none",
|
|
979
1062
|
className: "flex justify-between items-center plb-1"
|
|
980
|
-
}, /* @__PURE__ */
|
|
1063
|
+
}, /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
|
|
981
1064
|
icon: "ph--plus--regular",
|
|
982
1065
|
iconOnly: true,
|
|
983
1066
|
label: t("button add"),
|
|
@@ -1003,11 +1086,11 @@ var getInputComponent = (type, format) => {
|
|
|
1003
1086
|
var FormField = ({ property, path, readonly, inline, lookupComponent, Custom }) => {
|
|
1004
1087
|
const inputProps = useInputProps(path);
|
|
1005
1088
|
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1006
|
-
const label = (0,
|
|
1089
|
+
const label = (0, import_react13.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
1007
1090
|
title,
|
|
1008
1091
|
name
|
|
1009
1092
|
]);
|
|
1010
|
-
const placeholder = (0,
|
|
1093
|
+
const placeholder = (0, import_react13.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1011
1094
|
examples,
|
|
1012
1095
|
description
|
|
1013
1096
|
]);
|
|
@@ -1024,14 +1107,14 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1024
1107
|
}
|
|
1025
1108
|
});
|
|
1026
1109
|
if (FoundComponent) {
|
|
1027
|
-
return /* @__PURE__ */
|
|
1110
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1028
1111
|
role: "none"
|
|
1029
1112
|
}, FoundComponent);
|
|
1030
1113
|
}
|
|
1031
1114
|
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1032
1115
|
const CustomComponent = Custom?.[jsonPath];
|
|
1033
1116
|
if (CustomComponent) {
|
|
1034
|
-
return /* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ import_react13.default.createElement(CustomComponent, {
|
|
1035
1118
|
type,
|
|
1036
1119
|
format,
|
|
1037
1120
|
label,
|
|
@@ -1042,7 +1125,7 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1042
1125
|
});
|
|
1043
1126
|
}
|
|
1044
1127
|
if (array) {
|
|
1045
|
-
return /* @__PURE__ */
|
|
1128
|
+
return /* @__PURE__ */ import_react13.default.createElement(ArrayField, {
|
|
1046
1129
|
property,
|
|
1047
1130
|
path,
|
|
1048
1131
|
inputProps,
|
|
@@ -1052,9 +1135,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1052
1135
|
}
|
|
1053
1136
|
const InputComponent = getInputComponent(type, format);
|
|
1054
1137
|
if (InputComponent) {
|
|
1055
|
-
return /* @__PURE__ */
|
|
1138
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1056
1139
|
role: "none"
|
|
1057
|
-
}, /* @__PURE__ */
|
|
1140
|
+
}, /* @__PURE__ */ import_react13.default.createElement(InputComponent, {
|
|
1058
1141
|
type,
|
|
1059
1142
|
format,
|
|
1060
1143
|
label,
|
|
@@ -1065,9 +1148,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1065
1148
|
}));
|
|
1066
1149
|
}
|
|
1067
1150
|
if (options) {
|
|
1068
|
-
return /* @__PURE__ */
|
|
1151
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1069
1152
|
role: "none"
|
|
1070
|
-
}, /* @__PURE__ */
|
|
1153
|
+
}, /* @__PURE__ */ import_react13.default.createElement(SelectInput, {
|
|
1071
1154
|
type,
|
|
1072
1155
|
format,
|
|
1073
1156
|
disabled: readonly,
|
|
@@ -1085,9 +1168,9 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1085
1168
|
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1086
1169
|
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_echo_schema5.AST.isTypeLiteral);
|
|
1087
1170
|
if (typeLiteral) {
|
|
1088
|
-
return /* @__PURE__ */
|
|
1171
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1089
1172
|
role: "none"
|
|
1090
|
-
}, !inline && /* @__PURE__ */
|
|
1173
|
+
}, !inline && /* @__PURE__ */ import_react13.default.createElement("div", null, label), /* @__PURE__ */ import_react13.default.createElement(FormFields, {
|
|
1091
1174
|
schema: import_echo_schema5.S.make(typeLiteral),
|
|
1092
1175
|
path,
|
|
1093
1176
|
readonly,
|
|
@@ -1099,7 +1182,7 @@ var FormField = ({ property, path, readonly, inline, lookupComponent, Custom })
|
|
|
1099
1182
|
};
|
|
1100
1183
|
var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custom }) => {
|
|
1101
1184
|
const values = useFormValues(path);
|
|
1102
|
-
const properties = (0,
|
|
1185
|
+
const properties = (0, import_react13.useMemo)(() => {
|
|
1103
1186
|
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
1104
1187
|
const filtered = filter ? filter(props) : props;
|
|
1105
1188
|
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
@@ -1109,11 +1192,11 @@ var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custo
|
|
|
1109
1192
|
filter,
|
|
1110
1193
|
sort
|
|
1111
1194
|
]);
|
|
1112
|
-
return /* @__PURE__ */
|
|
1195
|
+
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1113
1196
|
role: "form",
|
|
1114
1197
|
className: (0, import_react_ui_theme7.mx)("flex flex-col w-full gap-2")
|
|
1115
1198
|
}, properties.map((property) => {
|
|
1116
|
-
return /* @__PURE__ */
|
|
1199
|
+
return /* @__PURE__ */ import_react13.default.createElement(FormField, {
|
|
1117
1200
|
key: property.name,
|
|
1118
1201
|
property,
|
|
1119
1202
|
path: [
|
|
@@ -1127,12 +1210,12 @@ var FormFields = ({ schema, path, filter, sort, readonly, lookupComponent, Custo
|
|
|
1127
1210
|
}).filter(import_util3.isNotFalsy));
|
|
1128
1211
|
};
|
|
1129
1212
|
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, lookupComponent, Custom }) => {
|
|
1130
|
-
const formRef = (0,
|
|
1131
|
-
const onValid = (0,
|
|
1213
|
+
const formRef = (0, import_react9.useRef)(null);
|
|
1214
|
+
const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
|
|
1132
1215
|
autoSave,
|
|
1133
1216
|
onSave
|
|
1134
1217
|
]);
|
|
1135
|
-
(0,
|
|
1218
|
+
(0, import_react9.useEffect)(() => {
|
|
1136
1219
|
if (autoFocus && formRef.current) {
|
|
1137
1220
|
const input = formRef.current.querySelector("input");
|
|
1138
1221
|
if (input) {
|
|
@@ -1142,7 +1225,7 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1142
1225
|
}, [
|
|
1143
1226
|
autoFocus
|
|
1144
1227
|
]);
|
|
1145
|
-
return /* @__PURE__ */
|
|
1228
|
+
return /* @__PURE__ */ import_react9.default.createElement(FormProvider, {
|
|
1146
1229
|
formRef,
|
|
1147
1230
|
schema,
|
|
1148
1231
|
autoSave,
|
|
@@ -1151,12 +1234,12 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1151
1234
|
onValidate,
|
|
1152
1235
|
onValid,
|
|
1153
1236
|
onSave
|
|
1154
|
-
}, /* @__PURE__ */
|
|
1237
|
+
}, /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
1155
1238
|
ref: formRef,
|
|
1156
1239
|
role: "none",
|
|
1157
1240
|
className: (0, import_react_ui_theme5.mx)("p-2", classNames),
|
|
1158
1241
|
"data-testid": testId
|
|
1159
|
-
}, /* @__PURE__ */
|
|
1242
|
+
}, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
|
|
1160
1243
|
schema,
|
|
1161
1244
|
path,
|
|
1162
1245
|
readonly,
|
|
@@ -1164,21 +1247,21 @@ var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, r
|
|
|
1164
1247
|
sort,
|
|
1165
1248
|
lookupComponent,
|
|
1166
1249
|
Custom
|
|
1167
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */
|
|
1250
|
+
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
1168
1251
|
onCancel,
|
|
1169
1252
|
readonly
|
|
1170
1253
|
})));
|
|
1171
1254
|
};
|
|
1172
1255
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1173
1256
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1174
|
-
const { t } = (0,
|
|
1175
|
-
const [props, setProps] = (0,
|
|
1176
|
-
(0,
|
|
1257
|
+
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
1258
|
+
const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
|
|
1259
|
+
(0, import_react3.useEffect)(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1177
1260
|
field,
|
|
1178
1261
|
projection
|
|
1179
1262
|
]);
|
|
1180
|
-
const [schemas, setSchemas] = (0,
|
|
1181
|
-
(0,
|
|
1263
|
+
const [schemas, setSchemas] = (0, import_react3.useState)([]);
|
|
1264
|
+
(0, import_react3.useEffect)(() => {
|
|
1182
1265
|
if (!registry) {
|
|
1183
1266
|
return;
|
|
1184
1267
|
}
|
|
@@ -1196,17 +1279,17 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1196
1279
|
}, [
|
|
1197
1280
|
registry
|
|
1198
1281
|
]);
|
|
1199
|
-
const [referenceSchema, setReferenceSchema] = (0,
|
|
1200
|
-
(0,
|
|
1282
|
+
const [referenceSchema, setReferenceSchema] = (0, import_react3.useState)();
|
|
1283
|
+
(0, import_react3.useEffect)(() => {
|
|
1201
1284
|
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
1202
1285
|
}, [
|
|
1203
1286
|
schemas,
|
|
1204
1287
|
props?.referenceSchema
|
|
1205
1288
|
]);
|
|
1206
|
-
const [{ fieldSchema }, setFieldSchema] = (0,
|
|
1289
|
+
const [{ fieldSchema }, setFieldSchema] = (0, import_react3.useState)({
|
|
1207
1290
|
fieldSchema: (0, import_schema.getFormatSchema)(props?.format)
|
|
1208
1291
|
});
|
|
1209
|
-
const handleValuesChanged = (0,
|
|
1292
|
+
const handleValuesChanged = (0, import_react3.useCallback)((_props) => {
|
|
1210
1293
|
setFieldSchema((prev) => {
|
|
1211
1294
|
const fieldSchema2 = (0, import_schema.getFormatSchema)(_props.format);
|
|
1212
1295
|
if (prev.fieldSchema === fieldSchema2) {
|
|
@@ -1241,7 +1324,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1241
1324
|
props.format,
|
|
1242
1325
|
props.referenceSchema
|
|
1243
1326
|
]);
|
|
1244
|
-
const handleValidate = (0,
|
|
1327
|
+
const handleValidate = (0, import_react3.useCallback)(({ property }) => {
|
|
1245
1328
|
if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
1246
1329
|
return [
|
|
1247
1330
|
{
|
|
@@ -1254,7 +1337,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1254
1337
|
view.fields,
|
|
1255
1338
|
field
|
|
1256
1339
|
]);
|
|
1257
|
-
const handleSave = (0,
|
|
1340
|
+
const handleSave = (0, import_react3.useCallback)((props2) => {
|
|
1258
1341
|
projection.setFieldProjection({
|
|
1259
1342
|
field,
|
|
1260
1343
|
props: props2
|
|
@@ -1265,39 +1348,39 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1265
1348
|
field,
|
|
1266
1349
|
onSave
|
|
1267
1350
|
]);
|
|
1268
|
-
const handleCancel = (0,
|
|
1351
|
+
const handleCancel = (0, import_react3.useCallback)(() => {
|
|
1269
1352
|
requestAnimationFrame(() => onCancel?.());
|
|
1270
1353
|
onSave();
|
|
1271
1354
|
}, [
|
|
1272
1355
|
onSave
|
|
1273
1356
|
]);
|
|
1274
|
-
const Custom = (0,
|
|
1275
|
-
["format"]: (props2) => /* @__PURE__ */
|
|
1357
|
+
const Custom = (0, import_react3.useMemo)(() => ({
|
|
1358
|
+
["format"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
1276
1359
|
...props2,
|
|
1277
1360
|
options: import_echo_schema.FormatEnums.filter((value) => value !== import_echo_schema.FormatEnum.None).map((value) => ({
|
|
1278
1361
|
value,
|
|
1279
1362
|
label: t(`format ${value}`)
|
|
1280
1363
|
}))
|
|
1281
1364
|
}),
|
|
1282
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */
|
|
1365
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
1283
1366
|
...props2,
|
|
1284
1367
|
options: schemas.map((schema) => ({
|
|
1285
1368
|
value: schema.typename
|
|
1286
1369
|
}))
|
|
1287
1370
|
}),
|
|
1288
|
-
["referencePath"]: (props2) => /* @__PURE__ */
|
|
1371
|
+
["referencePath"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
1289
1372
|
...props2,
|
|
1290
1373
|
options: referenceSchema ? (0, import_schema.getSchemaProperties)(referenceSchema.ast).sort(import_schema.sortProperties).map((p) => ({
|
|
1291
1374
|
value: p.name
|
|
1292
1375
|
})) : []
|
|
1293
1376
|
}),
|
|
1294
|
-
["options"]: (props2) => /* @__PURE__ */
|
|
1377
|
+
["options"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectOptionInput, props2)
|
|
1295
1378
|
}), [
|
|
1296
1379
|
t,
|
|
1297
1380
|
schemas,
|
|
1298
1381
|
referenceSchema
|
|
1299
1382
|
]);
|
|
1300
|
-
const propIsNotType = (0,
|
|
1383
|
+
const propIsNotType = (0, import_react3.useCallback)((props2) => props2.filter((p) => p.name !== "type"), []);
|
|
1301
1384
|
if (!fieldSchema) {
|
|
1302
1385
|
import_log.log.warn("invalid format", {
|
|
1303
1386
|
props
|
|
@@ -1309,7 +1392,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1309
1392
|
});
|
|
1310
1393
|
return null;
|
|
1311
1394
|
}
|
|
1312
|
-
return /* @__PURE__ */
|
|
1395
|
+
return /* @__PURE__ */ import_react3.default.createElement(Form, {
|
|
1313
1396
|
key: field.id,
|
|
1314
1397
|
autoFocus: true,
|
|
1315
1398
|
values: props,
|
|
@@ -1326,6 +1409,7 @@ var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
|
1326
1409
|
Custom
|
|
1327
1410
|
});
|
|
1328
1411
|
};
|
|
1412
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1329
1413
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1330
1414
|
var ViewMetaSchema = import_echo_schema8.S.Struct({
|
|
1331
1415
|
name: import_echo_schema8.S.String.annotations({
|
|
@@ -1336,13 +1420,13 @@ var ViewMetaSchema = import_echo_schema8.S.Struct({
|
|
|
1336
1420
|
})
|
|
1337
1421
|
}).pipe(import_echo_schema8.S.mutable);
|
|
1338
1422
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1339
|
-
const { t } = (0,
|
|
1340
|
-
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), [
|
|
1341
1425
|
schema,
|
|
1342
1426
|
view
|
|
1343
1427
|
]);
|
|
1344
|
-
const [field, setField] = (0,
|
|
1345
|
-
const viewValues = (0,
|
|
1428
|
+
const [field, setField] = (0, import_react15.useState)();
|
|
1429
|
+
const viewValues = (0, import_react15.useMemo)(() => {
|
|
1346
1430
|
return {
|
|
1347
1431
|
name: view.name,
|
|
1348
1432
|
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
@@ -1352,39 +1436,77 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1352
1436
|
}, [
|
|
1353
1437
|
view
|
|
1354
1438
|
]);
|
|
1355
|
-
const
|
|
1439
|
+
const handleSelect = (0, import_react15.useCallback)((field2) => {
|
|
1440
|
+
setField((f) => f === field2 ? void 0 : field2);
|
|
1441
|
+
}, []);
|
|
1442
|
+
const handleAdd = (0, import_react15.useCallback)(() => {
|
|
1443
|
+
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1444
|
+
F: __dxlog_file4,
|
|
1445
|
+
L: 76,
|
|
1446
|
+
S: void 0,
|
|
1447
|
+
A: [
|
|
1448
|
+
"!schema.readonly",
|
|
1449
|
+
""
|
|
1450
|
+
]
|
|
1451
|
+
});
|
|
1452
|
+
const field2 = projection.createFieldProjection();
|
|
1453
|
+
setField(field2);
|
|
1454
|
+
}, [
|
|
1455
|
+
schema,
|
|
1456
|
+
view
|
|
1457
|
+
]);
|
|
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,
|
|
1462
|
+
S: void 0,
|
|
1463
|
+
A: [
|
|
1464
|
+
"!schema.readonly",
|
|
1465
|
+
""
|
|
1466
|
+
]
|
|
1467
|
+
});
|
|
1356
1468
|
requestAnimationFrame(() => {
|
|
1357
1469
|
if (view.name !== name) {
|
|
1358
1470
|
view.name = name;
|
|
1359
1471
|
}
|
|
1360
1472
|
if (view.query.typename !== typename) {
|
|
1361
|
-
onTypenameChanged(typename);
|
|
1473
|
+
onTypenameChanged?.(typename);
|
|
1362
1474
|
}
|
|
1363
1475
|
});
|
|
1364
1476
|
}, [
|
|
1365
|
-
view,
|
|
1366
1477
|
schema,
|
|
1478
|
+
view,
|
|
1367
1479
|
onTypenameChanged
|
|
1368
1480
|
]);
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1481
|
+
const handleDelete = (0, import_react15.useCallback)((fieldId) => {
|
|
1482
|
+
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1483
|
+
F: __dxlog_file4,
|
|
1484
|
+
L: 99,
|
|
1485
|
+
S: void 0,
|
|
1486
|
+
A: [
|
|
1487
|
+
"!schema.readonly",
|
|
1488
|
+
""
|
|
1489
|
+
]
|
|
1490
|
+
});
|
|
1379
1491
|
if (fieldId === field?.id) {
|
|
1380
1492
|
setField(void 0);
|
|
1381
1493
|
}
|
|
1382
|
-
onDelete(fieldId);
|
|
1494
|
+
onDelete?.(fieldId);
|
|
1383
1495
|
}, [
|
|
1384
|
-
|
|
1385
|
-
field
|
|
1496
|
+
schema,
|
|
1497
|
+
field,
|
|
1498
|
+
onDelete
|
|
1386
1499
|
]);
|
|
1387
|
-
const handleMove = (0,
|
|
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,
|
|
1504
|
+
S: void 0,
|
|
1505
|
+
A: [
|
|
1506
|
+
"!schema.readonly",
|
|
1507
|
+
""
|
|
1508
|
+
]
|
|
1509
|
+
});
|
|
1388
1510
|
const fields = [
|
|
1389
1511
|
...view.fields
|
|
1390
1512
|
];
|
|
@@ -1392,96 +1514,97 @@ var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading =
|
|
|
1392
1514
|
fields.splice(toIndex, 0, moved);
|
|
1393
1515
|
view.fields = fields;
|
|
1394
1516
|
}, [
|
|
1517
|
+
schema,
|
|
1395
1518
|
view.fields
|
|
1396
1519
|
]);
|
|
1397
|
-
const handleClose = (0,
|
|
1520
|
+
const handleClose = (0, import_react15.useCallback)(() => setField(void 0), []);
|
|
1398
1521
|
const hiddenProperties = projection.getHiddenProperties();
|
|
1399
|
-
const handleHide = (0,
|
|
1522
|
+
const handleHide = (0, import_react15.useCallback)((fieldId) => {
|
|
1400
1523
|
setField(void 0);
|
|
1401
1524
|
projection.hideFieldProjection(fieldId);
|
|
1402
1525
|
}, [
|
|
1403
1526
|
projection
|
|
1404
1527
|
]);
|
|
1405
|
-
const handleShow = (0,
|
|
1528
|
+
const handleShow = (0, import_react15.useCallback)((property) => {
|
|
1406
1529
|
setField(void 0);
|
|
1407
1530
|
projection.showFieldProjection(property);
|
|
1408
1531
|
}, [
|
|
1409
1532
|
projection
|
|
1410
1533
|
]);
|
|
1411
|
-
return /* @__PURE__ */
|
|
1534
|
+
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1412
1535
|
role: "none",
|
|
1413
1536
|
className: (0, import_react_ui_theme9.mx)("flex flex-col w-full divide-y divide-separator", classNames)
|
|
1414
|
-
}, /* @__PURE__ */
|
|
1537
|
+
}, /* @__PURE__ */ import_react15.default.createElement(Form, {
|
|
1415
1538
|
autoSave: true,
|
|
1416
1539
|
schema: ViewMetaSchema,
|
|
1417
1540
|
values: viewValues,
|
|
1418
|
-
onSave:
|
|
1419
|
-
}), /* @__PURE__ */
|
|
1541
|
+
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1542
|
+
}), /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1420
1543
|
role: "none",
|
|
1421
1544
|
className: "p-2"
|
|
1422
|
-
}, /* @__PURE__ */
|
|
1545
|
+
}, /* @__PURE__ */ import_react15.default.createElement("label", {
|
|
1423
1546
|
className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
|
|
1424
|
-
}, t("fields label"))), /* @__PURE__ */
|
|
1547
|
+
}, t("fields label"))), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Root, {
|
|
1425
1548
|
items: view.fields,
|
|
1426
1549
|
isItem: import_echo_schema8.S.is(import_schema5.FieldSchema),
|
|
1427
1550
|
getId: (field2) => field2.id,
|
|
1428
|
-
onMove: handleMove
|
|
1429
|
-
}, ({ 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", {
|
|
1430
1553
|
role: "heading",
|
|
1431
1554
|
className: grid
|
|
1432
|
-
}, /* @__PURE__ */
|
|
1555
|
+
}, /* @__PURE__ */ import_react15.default.createElement("div", null), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1433
1556
|
className: "flex items-center text-sm"
|
|
1434
|
-
}, t("field path label"))), /* @__PURE__ */
|
|
1557
|
+
}, t("field path label"))), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1435
1558
|
role: "list",
|
|
1436
1559
|
className: "flex flex-col w-full"
|
|
1437
|
-
}, fields?.map((field2) => /* @__PURE__ */
|
|
1560
|
+
}, fields?.map((field2) => /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Item, {
|
|
1438
1561
|
key: field2.id,
|
|
1439
1562
|
item: field2,
|
|
1440
1563
|
classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, "cursor-pointer")
|
|
1441
|
-
}, /* @__PURE__ */
|
|
1564
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemTitle, {
|
|
1442
1565
|
onClick: () => handleSelect(field2)
|
|
1443
|
-
}, field2.path), /* @__PURE__ */
|
|
1566
|
+
}, field2.path), /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1444
1567
|
className: "flex items-center gap-2 -ml-4"
|
|
1445
|
-
}, /* @__PURE__ */
|
|
1568
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1446
1569
|
icon: "ph--eye-slash--regular",
|
|
1447
1570
|
disabled: view.fields.length <= 1,
|
|
1448
1571
|
onClick: () => handleHide(field2.id)
|
|
1449
|
-
}), /* @__PURE__ */
|
|
1572
|
+
}), !schema.readonly && /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
1450
1573
|
icon: "ph--trash--regular",
|
|
1451
1574
|
disabled: view.fields.length <= 1,
|
|
1452
1575
|
onClick: () => handleDelete(field2.id)
|
|
1453
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */
|
|
1576
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react15.default.createElement("div", null, /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1454
1577
|
role: "none",
|
|
1455
1578
|
className: "p-2"
|
|
1456
|
-
}, /* @__PURE__ */
|
|
1579
|
+
}, /* @__PURE__ */ import_react15.default.createElement("label", {
|
|
1457
1580
|
className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
|
|
1458
|
-
}, t("hidden fields label"))), /* @__PURE__ */
|
|
1581
|
+
}, t("hidden fields label"))), /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Root, {
|
|
1459
1582
|
items: hiddenProperties,
|
|
1460
1583
|
isItem: (item) => typeof item === "string",
|
|
1461
1584
|
getId: (property) => property
|
|
1462
|
-
}, ({ items: properties }) => /* @__PURE__ */
|
|
1585
|
+
}, ({ items: properties }) => /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1463
1586
|
role: "list",
|
|
1464
1587
|
className: "flex flex-col w-full"
|
|
1465
|
-
}, properties?.map((property) => /* @__PURE__ */
|
|
1588
|
+
}, properties?.map((property) => /* @__PURE__ */ import_react15.default.createElement(import_react_ui_list2.List.Item, {
|
|
1466
1589
|
key: property,
|
|
1467
1590
|
item: property,
|
|
1468
1591
|
classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, "cursor-pointer")
|
|
1469
|
-
}, /* @__PURE__ */
|
|
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, {
|
|
1470
1593
|
icon: "ph--eye--regular",
|
|
1471
1594
|
onClick: () => handleShow(property)
|
|
1472
|
-
}))))))), field && /* @__PURE__ */
|
|
1595
|
+
}))))))), field && /* @__PURE__ */ import_react15.default.createElement(FieldEditor, {
|
|
1473
1596
|
key: field.id,
|
|
1474
1597
|
view,
|
|
1475
1598
|
projection,
|
|
1476
1599
|
field,
|
|
1477
1600
|
registry,
|
|
1478
1601
|
onSave: handleClose
|
|
1479
|
-
}), !readonly && !field && /* @__PURE__ */
|
|
1602
|
+
}), !readonly && !field && /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1480
1603
|
className: "flex p-2 justify-center"
|
|
1481
|
-
}, /* @__PURE__ */
|
|
1604
|
+
}, /* @__PURE__ */ import_react15.default.createElement(import_react_ui11.IconButton, {
|
|
1482
1605
|
icon: "ph--plus--regular",
|
|
1483
1606
|
label: t("button add property"),
|
|
1484
|
-
onClick: handleAdd,
|
|
1607
|
+
onClick: schema.readonly ? void 0 : handleAdd,
|
|
1485
1608
|
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
1486
1609
|
disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT
|
|
1487
1610
|
})));
|
|
@@ -1589,18 +1712,21 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1589
1712
|
switch (format) {
|
|
1590
1713
|
case import_echo_schema9.FormatEnum.Markdown:
|
|
1591
1714
|
return void 0;
|
|
1715
|
+
case import_echo_schema9.FormatEnum.Time:
|
|
1592
1716
|
case import_echo_schema9.FormatEnum.Timestamp:
|
|
1593
1717
|
case import_echo_schema9.FormatEnum.DateTime:
|
|
1594
1718
|
case import_echo_schema9.FormatEnum.Date:
|
|
1595
|
-
case import_echo_schema9.FormatEnum.
|
|
1719
|
+
case import_echo_schema9.FormatEnum.Duration:
|
|
1596
1720
|
return [
|
|
1597
|
-
"font-mono"
|
|
1721
|
+
"font-mono",
|
|
1722
|
+
"text-right"
|
|
1598
1723
|
];
|
|
1599
1724
|
case import_echo_schema9.FormatEnum.Currency:
|
|
1600
1725
|
return [
|
|
1601
1726
|
"text-right"
|
|
1602
1727
|
];
|
|
1603
1728
|
case import_echo_schema9.FormatEnum.JSON:
|
|
1729
|
+
case import_echo_schema9.FormatEnum.DID:
|
|
1604
1730
|
return [
|
|
1605
1731
|
"font-mono"
|
|
1606
1732
|
];
|
|
@@ -1608,9 +1734,6 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1608
1734
|
return void 0;
|
|
1609
1735
|
}
|
|
1610
1736
|
};
|
|
1611
|
-
var cellClassesForRowSelection = (selected) => selected ? [
|
|
1612
|
-
"!bg-gridCellSelected"
|
|
1613
|
-
] : void 0;
|
|
1614
1737
|
var pathNotUniqueError = (path) => ({
|
|
1615
1738
|
path: "path",
|
|
1616
1739
|
message: `'${path}' is already present`
|
|
@@ -1655,17 +1778,14 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1655
1778
|
maximumFractionDigits: 2
|
|
1656
1779
|
});
|
|
1657
1780
|
}
|
|
1658
|
-
case import_echo_schema10.FormatEnum.
|
|
1659
|
-
|
|
1781
|
+
case import_echo_schema10.FormatEnum.Date: {
|
|
1782
|
+
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1783
|
+
}
|
|
1660
1784
|
case import_echo_schema10.FormatEnum.Time: {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
return date.toLocaleDateString(locale);
|
|
1666
|
-
} else {
|
|
1667
|
-
return date.toLocaleTimeString(locale);
|
|
1668
|
-
}
|
|
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");
|
|
1669
1789
|
}
|
|
1670
1790
|
case import_echo_schema10.FormatEnum.GeoPoint: {
|
|
1671
1791
|
if (value === null || value === void 0) {
|
|
@@ -1743,10 +1863,18 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1743
1863
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1744
1864
|
0 && (module.exports = {
|
|
1745
1865
|
BooleanInput,
|
|
1866
|
+
ControlFrame,
|
|
1867
|
+
ControlFrameItem,
|
|
1868
|
+
ControlGroup,
|
|
1869
|
+
ControlItem,
|
|
1870
|
+
ControlItemInput,
|
|
1871
|
+
ControlSection,
|
|
1872
|
+
ControlSectionHeading,
|
|
1746
1873
|
DeprecatedFormContainer,
|
|
1747
1874
|
DeprecatedFormInput,
|
|
1748
1875
|
FieldEditor,
|
|
1749
1876
|
Form,
|
|
1877
|
+
FormProvider,
|
|
1750
1878
|
GeoPointInput,
|
|
1751
1879
|
InputHeader,
|
|
1752
1880
|
MarkdownInput,
|
|
@@ -1757,13 +1885,15 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1757
1885
|
TupleInput,
|
|
1758
1886
|
ViewEditor,
|
|
1759
1887
|
cellClassesForFieldType,
|
|
1760
|
-
|
|
1888
|
+
controlItemClasses,
|
|
1761
1889
|
formatForDisplay,
|
|
1762
1890
|
formatForEditing,
|
|
1763
1891
|
parseValue,
|
|
1764
1892
|
pathNotUniqueError,
|
|
1765
1893
|
translations,
|
|
1766
1894
|
useForm,
|
|
1767
|
-
|
|
1895
|
+
useFormContext,
|
|
1896
|
+
useFormValues,
|
|
1897
|
+
useInputProps
|
|
1768
1898
|
});
|
|
1769
1899
|
//# sourceMappingURL=index.cjs.map
|