@dxos/react-ui-form 0.8.2-main.f11618f → 0.8.2-staging.42af850
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 +1732 -1374
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1715 -1365
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1732 -1374
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts +1 -1
- package/dist/types/src/components/ControlSection/ControlSection.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.d.ts.map +1 -1
- package/dist/types/src/components/FieldEditor/FieldEditor.test.d.ts +2 -0
- package/dist/types/src/components/FieldEditor/FieldEditor.test.d.ts.map +1 -0
- package/dist/types/src/components/Form/ArrayField.d.ts.map +1 -1
- package/dist/types/src/components/Form/Defaults.d.ts +4 -4
- package/dist/types/src/components/Form/Defaults.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.d.ts +4 -4
- package/dist/types/src/components/Form/Form.d.ts.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +34 -34
- package/dist/types/src/components/Form/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts +1 -1
- package/dist/types/src/components/Form/FormActions.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContent.d.ts +9 -8
- package/dist/types/src/components/Form/FormContent.d.ts.map +1 -1
- package/dist/types/src/components/Form/FormContext.d.ts.map +1 -1
- package/dist/types/src/components/Form/Input.d.ts.map +1 -1
- package/dist/types/src/components/Form/RefField.d.ts +7 -18
- package/dist/types/src/components/Form/RefField.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/GeoPointInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/SelectOptionsInput.stories.d.ts.map +1 -1
- package/dist/types/src/components/Form/custom/TupleInput.d.ts.map +1 -1
- package/dist/types/src/components/Form/factory.d.ts +1 -1
- package/dist/types/src/components/Form/factory.d.ts.map +1 -1
- package/dist/types/src/components/Form/index.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/Test.stories.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts +2 -2
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +5 -3
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.d.ts +2 -2
- package/dist/types/src/components/deprecated/Form.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/Form.stories.d.ts.map +1 -1
- package/dist/types/src/components/deprecated/FormInput.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useForm.d.ts +2 -2
- package/dist/types/src/hooks/useForm.d.ts.map +1 -1
- package/dist/types/src/hooks/useQueryRefOptions.d.ts +23 -0
- package/dist/types/src/hooks/useQueryRefOptions.d.ts.map +1 -0
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts +8 -0
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +5 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/field.d.ts.map +1 -1
- package/dist/types/src/util/formatting.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/refs.d.ts +9 -0
- package/dist/types/src/util/refs.d.ts.map +1 -0
- package/dist/types/src/util/schema.d.ts +3 -0
- package/dist/types/src/util/schema.d.ts.map +1 -0
- package/dist/types/src/vitest-setup.d.ts +2 -0
- package/dist/types/src/vitest-setup.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +28 -25
- package/src/components/ControlSection/ControlSection.stories.tsx +1 -1
- package/src/components/ControlSection/ControlSection.tsx +2 -2
- package/src/components/FieldEditor/FieldEditor.stories.tsx +1 -1
- package/src/components/FieldEditor/FieldEditor.test.tsx +49 -0
- package/src/components/FieldEditor/FieldEditor.tsx +3 -2
- package/src/components/Form/ArrayField.tsx +60 -49
- package/src/components/Form/Defaults.tsx +77 -48
- package/src/components/Form/Form.stories.tsx +104 -122
- package/src/components/Form/Form.tsx +5 -6
- package/src/components/Form/FormActions.tsx +15 -18
- package/src/components/Form/FormContent.tsx +80 -54
- package/src/components/Form/FormContext.tsx +14 -8
- package/src/components/Form/Input.tsx +4 -10
- package/src/components/Form/RefField.tsx +167 -101
- package/src/components/Form/custom/SelectOptionsInput.stories.tsx +6 -5
- package/src/components/Form/factory.tsx +1 -1
- package/src/components/Form/index.ts +0 -1
- package/src/components/ViewEditor/ViewEditor.stories.tsx +19 -9
- package/src/components/ViewEditor/ViewEditor.tsx +65 -35
- package/src/components/deprecated/Form.tsx +6 -6
- package/src/components/testing.tsx +5 -9
- package/src/hooks/index.ts +3 -1
- package/src/hooks/useForm.ts +4 -3
- package/src/hooks/useQueryRefOptions.ts +53 -0
- package/src/hooks/useRefQueryLookupHandler.ts +39 -0
- package/src/translations.ts +9 -2
- package/src/util/index.ts +3 -1
- package/src/util/refs.ts +38 -0
- package/src/util/schema.ts +14 -0
- package/src/vitest-setup.ts +11 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -54,52 +54,66 @@ __export(node_exports, {
|
|
|
54
54
|
ViewEditor: () => ViewEditor,
|
|
55
55
|
cellClassesForFieldType: () => cellClassesForFieldType,
|
|
56
56
|
controlItemClasses: () => controlItemClasses,
|
|
57
|
+
findArrayElementType: () => findArrayElementType,
|
|
57
58
|
formatForDisplay: () => formatForDisplay,
|
|
58
59
|
formatForEditing: () => formatForEditing,
|
|
60
|
+
getRefProps: () => getRefProps,
|
|
59
61
|
parseValue: () => parseValue,
|
|
60
62
|
pathNotUniqueError: () => pathNotUniqueError,
|
|
61
63
|
translations: () => translations_default,
|
|
62
64
|
useForm: () => useForm,
|
|
63
65
|
useFormContext: () => useFormContext,
|
|
64
66
|
useFormValues: () => useFormValues,
|
|
65
|
-
useInputProps: () => useInputProps
|
|
67
|
+
useInputProps: () => useInputProps,
|
|
68
|
+
useQueryRefOptions: () => useQueryRefOptions,
|
|
69
|
+
useRefQueryLookupHandler: () => useRefQueryLookupHandler
|
|
66
70
|
});
|
|
67
71
|
module.exports = __toCommonJS(node_exports);
|
|
72
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
68
73
|
var import_react = __toESM(require("react"));
|
|
69
74
|
var import_react_ui = require("@dxos/react-ui");
|
|
70
75
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
76
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
71
77
|
var import_react2 = __toESM(require("react"));
|
|
72
78
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
73
79
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
80
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
74
81
|
var import_react3 = __toESM(require("react"));
|
|
75
82
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
76
83
|
var import_log = require("@dxos/log");
|
|
77
84
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
78
85
|
var import_schema = require("@dxos/schema");
|
|
86
|
+
var import_tracking4 = require("@preact-signals/safe-react/tracking");
|
|
79
87
|
var import_react4 = __toESM(require("react"));
|
|
80
88
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
81
89
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
82
90
|
var import_util = require("@dxos/util");
|
|
91
|
+
var import_tracking5 = require("@preact-signals/safe-react/tracking");
|
|
83
92
|
var import_react5 = __toESM(require("react"));
|
|
84
93
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
85
94
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
95
|
+
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
86
96
|
var import_react6 = __toESM(require("react"));
|
|
87
97
|
var import_keys = require("@dxos/keys");
|
|
88
98
|
var import_react_ui6 = require("@dxos/react-ui");
|
|
89
99
|
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
90
100
|
var import_react_ui_pickers = require("@dxos/react-ui-pickers");
|
|
91
101
|
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
102
|
+
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
92
103
|
var import_react7 = __toESM(require("react"));
|
|
93
104
|
var import_react_ui7 = require("@dxos/react-ui");
|
|
94
105
|
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
95
106
|
var import_util2 = require("@dxos/util");
|
|
107
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
96
108
|
var import_react8 = __toESM(require("react"));
|
|
97
109
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
110
|
+
var import_tracking9 = require("@preact-signals/safe-react/tracking");
|
|
98
111
|
var import_react9 = __toESM(require("react"));
|
|
99
112
|
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
113
|
+
var import_tracking10 = require("@preact-signals/safe-react/tracking");
|
|
100
114
|
var import_react10 = __toESM(require("react"));
|
|
101
115
|
var import_react_ui9 = require("@dxos/react-ui");
|
|
102
|
-
var
|
|
116
|
+
var import_tracking11 = require("@preact-signals/safe-react/tracking");
|
|
103
117
|
var import_react11 = __toESM(require("react"));
|
|
104
118
|
var import_debug = require("@dxos/debug");
|
|
105
119
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
@@ -111,40 +125,55 @@ var import_effect3 = require("@dxos/effect");
|
|
|
111
125
|
var import_invariant = require("@dxos/invariant");
|
|
112
126
|
var import_log2 = require("@dxos/log");
|
|
113
127
|
var import_schema2 = require("@dxos/schema");
|
|
128
|
+
var import_react13 = require("react");
|
|
129
|
+
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
130
|
+
var import_echo = require("@dxos/react-client/echo");
|
|
131
|
+
var import_util3 = require("@dxos/util");
|
|
132
|
+
var import_react14 = require("react");
|
|
133
|
+
var import_log3 = require("@dxos/log");
|
|
134
|
+
var import_tracking12 = require("@preact-signals/safe-react/tracking");
|
|
114
135
|
var import_effect4 = require("effect");
|
|
115
136
|
var import_String = require("effect/String");
|
|
116
|
-
var
|
|
117
|
-
var import_echo_schema5 = require("@dxos/echo-schema");
|
|
137
|
+
var import_react15 = __toESM(require("react"));
|
|
118
138
|
var import_effect5 = require("@dxos/effect");
|
|
119
|
-
var
|
|
139
|
+
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
|
120
140
|
var import_schema3 = require("@dxos/schema");
|
|
121
|
-
var
|
|
141
|
+
var import_util4 = require("@dxos/util");
|
|
142
|
+
var import_tracking13 = require("@preact-signals/safe-react/tracking");
|
|
122
143
|
var import_effect6 = require("effect");
|
|
123
144
|
var import_String2 = require("effect/String");
|
|
124
|
-
var
|
|
125
|
-
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
145
|
+
var import_react16 = __toESM(require("react"));
|
|
126
146
|
var import_effect7 = require("@dxos/effect");
|
|
127
147
|
var import_invariant2 = require("@dxos/invariant");
|
|
128
148
|
var import_react_ui10 = require("@dxos/react-ui");
|
|
129
|
-
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
130
149
|
var import_schema4 = require("@dxos/schema");
|
|
131
|
-
var
|
|
150
|
+
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
151
|
+
var import_format = require("date-fns/format");
|
|
132
152
|
var import_echo_schema7 = require("@dxos/echo-schema");
|
|
133
|
-
var import_effect8 = require("@dxos/effect");
|
|
134
|
-
var import_keys2 = require("@dxos/keys");
|
|
135
|
-
var import_live_object = require("@dxos/live-object");
|
|
136
|
-
var import_log3 = require("@dxos/log");
|
|
137
153
|
var import_echo_schema8 = require("@dxos/echo-schema");
|
|
138
|
-
var
|
|
154
|
+
var import_effect8 = require("@dxos/effect");
|
|
155
|
+
var import_effect9 = require("effect");
|
|
156
|
+
var import_effect10 = require("@dxos/effect");
|
|
157
|
+
var import_tracking14 = require("@preact-signals/safe-react/tracking");
|
|
158
|
+
var import_react17 = __toESM(require("react"));
|
|
139
159
|
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
140
|
-
var
|
|
160
|
+
var import_effect11 = require("@dxos/effect");
|
|
161
|
+
var import_keys2 = require("@dxos/keys");
|
|
162
|
+
var import_react18 = require("@dxos/lit-ui/react");
|
|
141
163
|
var import_react_ui11 = require("@dxos/react-ui");
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
var
|
|
164
|
+
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
165
|
+
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
|
166
|
+
var import_util5 = require("@dxos/util");
|
|
145
167
|
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
146
|
-
var
|
|
168
|
+
var import_tracking15 = require("@preact-signals/safe-react/tracking");
|
|
169
|
+
var import_effect12 = require("effect");
|
|
170
|
+
var import_react19 = __toESM(require("react"));
|
|
147
171
|
var import_echo_schema11 = require("@dxos/echo-schema");
|
|
172
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
173
|
+
var import_react_ui12 = require("@dxos/react-ui");
|
|
174
|
+
var import_react_ui_list2 = require("@dxos/react-ui-list");
|
|
175
|
+
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
176
|
+
var import_schema5 = require("@dxos/schema");
|
|
148
177
|
var translationKey = "react-ui-form";
|
|
149
178
|
var translations_default = [
|
|
150
179
|
{
|
|
@@ -152,6 +181,7 @@ var translations_default = [
|
|
|
152
181
|
[translationKey]: {
|
|
153
182
|
"fields label": "Fields",
|
|
154
183
|
"hidden fields label": "Hidden Fields",
|
|
184
|
+
"empty readonly ref field label": "(none)",
|
|
155
185
|
// TODO(burdon): Standardize field/property.
|
|
156
186
|
"button add property": "Add property",
|
|
157
187
|
"field property label": "Property",
|
|
@@ -161,6 +191,8 @@ var translations_default = [
|
|
|
161
191
|
"add field": "Add field",
|
|
162
192
|
"delete field": "Delete field",
|
|
163
193
|
"field limit reached": "Maximum number of fields reached",
|
|
194
|
+
"boolean input true value": "Yes",
|
|
195
|
+
"boolean input false value": "No",
|
|
164
196
|
// TODO(burdon): Factor out?
|
|
165
197
|
"button cancel": "Cancel",
|
|
166
198
|
"button save": "Save",
|
|
@@ -190,389 +222,466 @@ var translations_default = [
|
|
|
190
222
|
"format number": "Number",
|
|
191
223
|
"format uri": "URI",
|
|
192
224
|
"format uuid": "UUID",
|
|
193
|
-
// Placeholders
|
|
225
|
+
// Placeholders.
|
|
194
226
|
"placeholder latitude": "Latitude",
|
|
195
227
|
"placeholder longitude": "Longitude",
|
|
196
|
-
// SelectOptionsInput
|
|
228
|
+
// SelectOptionsInput.
|
|
197
229
|
"select option label": "Label",
|
|
198
230
|
"select option label placeholder": "Option label",
|
|
199
231
|
"select option color": "Color",
|
|
200
232
|
"select option delete": "Delete",
|
|
201
|
-
"select option add": "Add option"
|
|
233
|
+
"select option add": "Add option",
|
|
234
|
+
// System schema message.
|
|
235
|
+
"system schema title": "System Schema",
|
|
236
|
+
"system schema description": "This schema is managed by the system and cannot be modified."
|
|
202
237
|
}
|
|
203
238
|
}
|
|
204
239
|
}
|
|
205
240
|
];
|
|
206
241
|
var DeprecatedFormContainer = ({ children, classNames }) => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
242
|
+
var _effect = (0, import_tracking.useSignals)();
|
|
243
|
+
try {
|
|
244
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
245
|
+
role: "none",
|
|
246
|
+
className: "container-max-width p-4 justify-center overflow-x-hidden overflow-y-auto"
|
|
247
|
+
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
248
|
+
role: "form",
|
|
249
|
+
className: (0, import_react_ui_theme.mx)("flex flex-col", import_react_ui_theme.textBlockWidth, classNames)
|
|
250
|
+
}, children));
|
|
251
|
+
} finally {
|
|
252
|
+
_effect.f();
|
|
253
|
+
}
|
|
214
254
|
};
|
|
215
255
|
var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
role: "none",
|
|
233
|
-
className: "flex min-bs-[--rail-action] items-center"
|
|
234
|
-
}, children))));
|
|
235
|
-
if (secondary) {
|
|
236
|
-
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
256
|
+
var _effect = (0, import_tracking.useSignals)();
|
|
257
|
+
try {
|
|
258
|
+
const primary = /* @__PURE__ */ import_react.default.createElement("div", {
|
|
259
|
+
role: "none",
|
|
260
|
+
className: "flex w-full gap-4 py-1"
|
|
261
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Root, null, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
262
|
+
role: "none",
|
|
263
|
+
className: "flex flex-col w-full"
|
|
264
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Label, {
|
|
265
|
+
classNames: "flex min-bs-[--rail-action] items-center",
|
|
266
|
+
style: {
|
|
267
|
+
fontSize: "unset"
|
|
268
|
+
}
|
|
269
|
+
}, label), description && /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.DescriptionAndValidation, {
|
|
270
|
+
classNames: "mbs-0.5"
|
|
271
|
+
}, /* @__PURE__ */ import_react.default.createElement(import_react_ui.Input.Description, null, description))), /* @__PURE__ */ import_react.default.createElement("div", {
|
|
237
272
|
role: "none"
|
|
238
|
-
},
|
|
273
|
+
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
274
|
+
role: "none",
|
|
275
|
+
className: "flex min-bs-[--rail-action] items-center"
|
|
276
|
+
}, children))));
|
|
277
|
+
if (secondary) {
|
|
278
|
+
return /* @__PURE__ */ import_react.default.createElement("div", {
|
|
279
|
+
role: "none"
|
|
280
|
+
}, primary, secondary);
|
|
281
|
+
}
|
|
282
|
+
return primary;
|
|
283
|
+
} finally {
|
|
284
|
+
_effect.f();
|
|
239
285
|
}
|
|
240
|
-
return primary;
|
|
241
286
|
};
|
|
242
287
|
var ControlPage = ({ children, classNames, ...props }) => {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
288
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
289
|
+
try {
|
|
290
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
291
|
+
role: "none",
|
|
292
|
+
className: (0, import_react_ui_theme2.mx)("pli-2", classNames),
|
|
293
|
+
...props
|
|
294
|
+
}, children);
|
|
295
|
+
} finally {
|
|
296
|
+
_effect.f();
|
|
297
|
+
}
|
|
248
298
|
};
|
|
249
299
|
var ControlSection = ({ title, description, children }) => {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
300
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
301
|
+
try {
|
|
302
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement(ControlSectionHeading, {
|
|
303
|
+
title,
|
|
304
|
+
description
|
|
305
|
+
}), children);
|
|
306
|
+
} finally {
|
|
307
|
+
_effect.f();
|
|
308
|
+
}
|
|
254
309
|
};
|
|
255
310
|
var ControlSectionHeading = ({ title, description }) => {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
311
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
312
|
+
try {
|
|
313
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
314
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react2.default.Fragment, null, /* @__PURE__ */ import_react2.default.createElement("h2", {
|
|
315
|
+
className: "pli-4 container-max-width text-xl mbs-6 mbe-4"
|
|
316
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
|
|
317
|
+
className: "pli-4 mlb-4 container-max-width text-description"
|
|
318
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t)));
|
|
319
|
+
} finally {
|
|
320
|
+
_effect.f();
|
|
321
|
+
}
|
|
262
322
|
};
|
|
263
323
|
var ControlGroupButton = ({ classNames, ...props }) => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
classNames
|
|
269
|
-
|
|
270
|
-
|
|
324
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
325
|
+
try {
|
|
326
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Button, {
|
|
327
|
+
...props,
|
|
328
|
+
classNames: [
|
|
329
|
+
"md:col-span-2",
|
|
330
|
+
classNames
|
|
331
|
+
]
|
|
332
|
+
});
|
|
333
|
+
} finally {
|
|
334
|
+
_effect.f();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
var ControlGroup = ({ children, classNames }) => {
|
|
338
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
339
|
+
try {
|
|
340
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
341
|
+
role: "none",
|
|
342
|
+
className: (0, import_react_ui_theme2.mx)("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
|
|
343
|
+
}, children);
|
|
344
|
+
} finally {
|
|
345
|
+
_effect.f();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
var ControlFrame = ({ children }) => {
|
|
349
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
350
|
+
try {
|
|
351
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
352
|
+
role: "none",
|
|
353
|
+
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"
|
|
354
|
+
}, children);
|
|
355
|
+
} finally {
|
|
356
|
+
_effect.f();
|
|
357
|
+
}
|
|
271
358
|
};
|
|
272
|
-
var
|
|
273
|
-
|
|
274
|
-
className: (0, import_react_ui_theme2.mx)("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
|
|
275
|
-
}, children);
|
|
276
|
-
var ControlFrame = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
277
|
-
role: "none",
|
|
278
|
-
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"
|
|
279
|
-
}, children);
|
|
280
|
-
var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center";
|
|
281
|
-
var controlItemTitleClasses = "text-lg font-normal mbe-2";
|
|
359
|
+
var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center gap-2";
|
|
360
|
+
var controlItemTitleClasses = "text-lg font-normal";
|
|
282
361
|
var controlItemDescriptionClasses = "text-base mlb-2 md:mbe-0 text-description";
|
|
283
362
|
var ControlItem = ({ title, description, children }) => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
363
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
364
|
+
try {
|
|
365
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
366
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
367
|
+
className: controlItemClasses
|
|
368
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
369
|
+
role: "none"
|
|
370
|
+
}, /* @__PURE__ */ import_react2.default.createElement("h3", {
|
|
371
|
+
className: controlItemTitleClasses
|
|
372
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
|
|
373
|
+
className: controlItemDescriptionClasses
|
|
374
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t))), children);
|
|
375
|
+
} finally {
|
|
376
|
+
_effect.f();
|
|
377
|
+
}
|
|
294
378
|
};
|
|
295
379
|
var ControlItemInput = ({ title, description, children }) => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
380
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
381
|
+
try {
|
|
382
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
383
|
+
return /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Root, null, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
384
|
+
className: controlItemClasses
|
|
385
|
+
}, /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
386
|
+
role: "none"
|
|
387
|
+
}, /* @__PURE__ */ import_react2.default.createElement(import_react_ui2.Input.Label, {
|
|
388
|
+
classNames: controlItemTitleClasses
|
|
389
|
+
}, (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, {
|
|
390
|
+
classNames: controlItemDescriptionClasses
|
|
391
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t)))), children));
|
|
392
|
+
} finally {
|
|
393
|
+
_effect.f();
|
|
394
|
+
}
|
|
306
395
|
};
|
|
307
396
|
var ControlFrameItem = ({ title, description, children }) => {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
397
|
+
var _effect = (0, import_tracking2.useSignals)();
|
|
398
|
+
try {
|
|
399
|
+
const { t } = (0, import_react_ui2.useTranslation)(translationKey);
|
|
400
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
401
|
+
role: "group",
|
|
402
|
+
className: "min-is-0"
|
|
403
|
+
}, /* @__PURE__ */ import_react2.default.createElement("h3", {
|
|
404
|
+
className: "text-lg mbe-2"
|
|
405
|
+
}, (0, import_react_ui2.toLocalizedString)(title, t)), description && /* @__PURE__ */ import_react2.default.createElement("p", {
|
|
406
|
+
className: "mlb-2 md:mbe-0 text-description"
|
|
407
|
+
}, (0, import_react_ui2.toLocalizedString)(description, t)), children);
|
|
408
|
+
} finally {
|
|
409
|
+
_effect.f();
|
|
410
|
+
}
|
|
317
411
|
};
|
|
318
412
|
var InputHeader = ({ children, error }) => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
413
|
+
var _effect = (0, import_tracking5.useSignals)();
|
|
414
|
+
try {
|
|
415
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
416
|
+
role: "none",
|
|
417
|
+
className: "flex justify-between items-center mbs-2 mbe-1 first:mbs-0"
|
|
418
|
+
}, children, error && /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Tooltip.Trigger, {
|
|
419
|
+
asChild: true,
|
|
420
|
+
content: error,
|
|
421
|
+
side: "bottom"
|
|
422
|
+
}, /* @__PURE__ */ import_react5.default.createElement(import_react_ui5.Icon, {
|
|
423
|
+
icon: "ph--warning--regular",
|
|
424
|
+
size: 4,
|
|
425
|
+
classNames: import_react_ui_theme3.errorText
|
|
426
|
+
})));
|
|
427
|
+
} finally {
|
|
428
|
+
_effect.f();
|
|
429
|
+
}
|
|
331
430
|
};
|
|
332
431
|
var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
0
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
setText(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
if (
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
432
|
+
var _effect = (0, import_tracking4.useSignals)();
|
|
433
|
+
try {
|
|
434
|
+
const { t } = (0, import_react_ui4.useTranslation)(translationKey);
|
|
435
|
+
const { status, error } = getStatus();
|
|
436
|
+
const geoPoint = (0, import_react4.useMemo)(() => getValue3() ?? [
|
|
437
|
+
0,
|
|
438
|
+
0
|
|
439
|
+
], [
|
|
440
|
+
getValue3
|
|
441
|
+
]);
|
|
442
|
+
const geoLocation = (0, import_react4.useMemo)(() => import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint), [
|
|
443
|
+
geoPoint
|
|
444
|
+
]);
|
|
445
|
+
const [longitudeText, setLongitudeText] = (0, import_react4.useState)(geoLocation.longitude?.toString());
|
|
446
|
+
const [latitudeText, setLatitudeText] = (0, import_react4.useState)(geoLocation.latitude?.toString());
|
|
447
|
+
(0, import_react4.useEffect)(() => {
|
|
448
|
+
const location = import_echo_schema2.GeoLocation.fromGeoPoint(geoPoint);
|
|
449
|
+
setLongitudeText(location.longitude.toString());
|
|
450
|
+
setLatitudeText(location.latitude.toString());
|
|
451
|
+
}, [
|
|
452
|
+
geoPoint
|
|
453
|
+
]);
|
|
454
|
+
const handleCoordinateChange = (0, import_react4.useCallback)((coordinateType, setText) => (event) => {
|
|
455
|
+
const inputText = event.target.value;
|
|
456
|
+
setText(inputText);
|
|
457
|
+
if (inputText !== "" && inputText !== "-") {
|
|
458
|
+
const coord = (0, import_util.safeParseFloat)(inputText);
|
|
459
|
+
if (coord !== void 0 && !isNaN(coord)) {
|
|
460
|
+
const currentLocation = import_echo_schema2.GeoLocation.fromGeoPoint(getValue3() ?? [
|
|
461
|
+
0,
|
|
462
|
+
0
|
|
463
|
+
]);
|
|
464
|
+
const newLocation = {
|
|
465
|
+
...currentLocation,
|
|
466
|
+
[coordinateType]: coord
|
|
467
|
+
};
|
|
468
|
+
const newValue = import_echo_schema2.GeoLocation.toGeoPoint(newLocation);
|
|
469
|
+
onValueChange(type, newValue);
|
|
470
|
+
}
|
|
369
471
|
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
472
|
+
}, [
|
|
473
|
+
getValue3,
|
|
474
|
+
onValueChange,
|
|
475
|
+
type
|
|
476
|
+
]);
|
|
477
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Root, {
|
|
478
|
+
validationValence: status
|
|
479
|
+
}, /* @__PURE__ */ import_react4.default.createElement(InputHeader, {
|
|
480
|
+
error
|
|
481
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.Label, null, label)), /* @__PURE__ */ import_react4.default.createElement("div", {
|
|
482
|
+
role: "none",
|
|
483
|
+
className: "grid grid-cols-2 gap-2"
|
|
484
|
+
}, /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
|
|
485
|
+
type: "text",
|
|
486
|
+
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
487
|
+
disabled,
|
|
488
|
+
placeholder: t("placeholder latitude"),
|
|
489
|
+
value: latitudeText,
|
|
490
|
+
onChange: handleCoordinateChange("latitude", setLatitudeText),
|
|
491
|
+
onBlur
|
|
492
|
+
}), /* @__PURE__ */ import_react4.default.createElement(import_react_ui4.Input.TextInput, {
|
|
493
|
+
type: "text",
|
|
494
|
+
pattern: "^-?[0-9]*\\.?[0-9]*$",
|
|
495
|
+
disabled,
|
|
496
|
+
placeholder: t("placeholder longitude"),
|
|
497
|
+
value: longitudeText,
|
|
498
|
+
onChange: handleCoordinateChange("longitude", setLongitudeText),
|
|
499
|
+
onBlur
|
|
500
|
+
})));
|
|
501
|
+
} finally {
|
|
502
|
+
_effect.f();
|
|
503
|
+
}
|
|
400
504
|
};
|
|
401
505
|
var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const newId = import_keys.PublicKey.random().truncate();
|
|
429
|
-
const newOption = {
|
|
430
|
-
id: newId,
|
|
431
|
-
title: "",
|
|
432
|
-
color: randomHue()
|
|
506
|
+
var _effect = (0, import_tracking6.useSignals)();
|
|
507
|
+
try {
|
|
508
|
+
const [selected, setSelectedId] = (0, import_react6.useState)(null);
|
|
509
|
+
const [isNewOption, setIsNewOption] = (0, import_react6.useState)(false);
|
|
510
|
+
const inputRef = (0, import_react6.useRef)(null);
|
|
511
|
+
const { t } = (0, import_react_ui6.useTranslation)(translationKey);
|
|
512
|
+
const { status, error } = getStatus();
|
|
513
|
+
const options = getValue3();
|
|
514
|
+
(0, import_react6.useEffect)(() => {
|
|
515
|
+
if (options === void 0) {
|
|
516
|
+
onValueChange(type, []);
|
|
517
|
+
}
|
|
518
|
+
}, [
|
|
519
|
+
options,
|
|
520
|
+
onValueChange,
|
|
521
|
+
type
|
|
522
|
+
]);
|
|
523
|
+
const randomHue = () => {
|
|
524
|
+
const usedHues = new Set(options?.map((option) => option.color) ?? []);
|
|
525
|
+
const unusedHues = import_react_ui_theme4.hues.filter((hue) => !usedHues.has(hue));
|
|
526
|
+
if (unusedHues.length > 0) {
|
|
527
|
+
return unusedHues[Math.floor(Math.random() * unusedHues.length)];
|
|
528
|
+
}
|
|
529
|
+
const lastThree = new Set(options?.slice(-3).map((option) => option.color) ?? []);
|
|
530
|
+
const availableHues = import_react_ui_theme4.hues.filter((hue) => !lastThree.has(hue));
|
|
531
|
+
return availableHues[Math.floor(Math.random() * availableHues.length)] ?? import_react_ui_theme4.hues[Math.floor(Math.random() * import_react_ui_theme4.hues.length)];
|
|
433
532
|
};
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
newOption
|
|
533
|
+
const handleAdd = (0, import_react6.useCallback)(() => {
|
|
534
|
+
const newId = import_keys.PublicKey.random().truncate();
|
|
535
|
+
const newOption = {
|
|
536
|
+
id: newId,
|
|
537
|
+
title: "",
|
|
538
|
+
color: randomHue()
|
|
539
|
+
};
|
|
540
|
+
onValueChange(type, [
|
|
541
|
+
...options ?? [],
|
|
542
|
+
newOption
|
|
543
|
+
]);
|
|
544
|
+
setSelectedId(newId);
|
|
545
|
+
setIsNewOption(true);
|
|
546
|
+
}, [
|
|
547
|
+
options,
|
|
548
|
+
type,
|
|
549
|
+
onValueChange
|
|
437
550
|
]);
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
options,
|
|
442
|
-
type,
|
|
443
|
-
onValueChange
|
|
444
|
-
]);
|
|
445
|
-
const handleDelete = (0, import_react6.useCallback)((id) => {
|
|
446
|
-
const newOptions = options?.filter((option) => option.id !== id) ?? [];
|
|
447
|
-
onValueChange(type, newOptions);
|
|
448
|
-
setSelectedId(null);
|
|
449
|
-
}, [
|
|
450
|
-
options,
|
|
451
|
-
type,
|
|
452
|
-
onValueChange
|
|
453
|
-
]);
|
|
454
|
-
const handleMove = (0, import_react6.useCallback)((from, to) => {
|
|
455
|
-
if (!options) {
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
const newOptions = [
|
|
459
|
-
...options
|
|
460
|
-
];
|
|
461
|
-
const [removed] = newOptions.splice(from, 1);
|
|
462
|
-
newOptions.splice(to, 0, removed);
|
|
463
|
-
onValueChange(type, newOptions);
|
|
464
|
-
}, [
|
|
465
|
-
options,
|
|
466
|
-
type,
|
|
467
|
-
onValueChange
|
|
468
|
-
]);
|
|
469
|
-
const handleClick = (0, import_react6.useCallback)((id) => {
|
|
470
|
-
setSelectedId((current) => current === id ? null : id);
|
|
471
|
-
}, []);
|
|
472
|
-
const handleTitleChange = (0, import_react6.useCallback)((id) => (e) => {
|
|
473
|
-
const newOptions = options?.map((o) => o.id === id ? {
|
|
474
|
-
...o,
|
|
475
|
-
title: e.target.value
|
|
476
|
-
} : o);
|
|
477
|
-
onValueChange(type, newOptions ?? []);
|
|
478
|
-
}, [
|
|
479
|
-
options,
|
|
480
|
-
type,
|
|
481
|
-
onValueChange
|
|
482
|
-
]);
|
|
483
|
-
const handleKeyDown = (0, import_react6.useCallback)((e) => {
|
|
484
|
-
if (e.key === "Enter") {
|
|
551
|
+
const handleDelete = (0, import_react6.useCallback)((id) => {
|
|
552
|
+
const newOptions = options?.filter((option) => option.id !== id) ?? [];
|
|
553
|
+
onValueChange(type, newOptions);
|
|
485
554
|
setSelectedId(null);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
555
|
+
}, [
|
|
556
|
+
options,
|
|
557
|
+
type,
|
|
558
|
+
onValueChange
|
|
559
|
+
]);
|
|
560
|
+
const handleMove = (0, import_react6.useCallback)((from, to) => {
|
|
561
|
+
if (!options) {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
const newOptions = [
|
|
565
|
+
...options
|
|
566
|
+
];
|
|
567
|
+
const [removed] = newOptions.splice(from, 1);
|
|
568
|
+
newOptions.splice(to, 0, removed);
|
|
569
|
+
onValueChange(type, newOptions);
|
|
570
|
+
}, [
|
|
571
|
+
options,
|
|
572
|
+
type,
|
|
573
|
+
onValueChange
|
|
574
|
+
]);
|
|
575
|
+
const handleClick = (0, import_react6.useCallback)((id) => {
|
|
576
|
+
setSelectedId((current) => current === id ? null : id);
|
|
577
|
+
}, []);
|
|
578
|
+
const handleTitleChange = (0, import_react6.useCallback)((id) => (e) => {
|
|
579
|
+
const newOptions = options?.map((o) => o.id === id ? {
|
|
580
|
+
...o,
|
|
581
|
+
title: e.target.value
|
|
582
|
+
} : o);
|
|
583
|
+
onValueChange(type, newOptions ?? []);
|
|
584
|
+
}, [
|
|
585
|
+
options,
|
|
586
|
+
type,
|
|
587
|
+
onValueChange
|
|
588
|
+
]);
|
|
589
|
+
const handleKeyDown = (0, import_react6.useCallback)((e) => {
|
|
590
|
+
if (e.key === "Enter") {
|
|
591
|
+
setSelectedId(null);
|
|
592
|
+
}
|
|
593
|
+
}, []);
|
|
594
|
+
const handleColorChange = (0, import_react6.useCallback)((id) => (hue) => {
|
|
595
|
+
const newOptions = options?.map((o) => o.id === id ? {
|
|
596
|
+
...o,
|
|
597
|
+
color: hue
|
|
598
|
+
} : o);
|
|
599
|
+
onValueChange(type, newOptions ?? []);
|
|
600
|
+
}, [
|
|
601
|
+
options,
|
|
602
|
+
type,
|
|
603
|
+
onValueChange
|
|
604
|
+
]);
|
|
605
|
+
(0, import_react6.useEffect)(() => {
|
|
606
|
+
if (selected && isNewOption && inputRef.current) {
|
|
607
|
+
inputRef.current.focus();
|
|
608
|
+
setIsNewOption(false);
|
|
609
|
+
}
|
|
610
|
+
}, [
|
|
611
|
+
selected,
|
|
612
|
+
isNewOption
|
|
613
|
+
]);
|
|
614
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Root, {
|
|
615
|
+
validationValence: status
|
|
616
|
+
}, /* @__PURE__ */ import_react6.default.createElement(InputHeader, {
|
|
617
|
+
error
|
|
618
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, null, label)), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
619
|
+
role: "none"
|
|
620
|
+
}, options && /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Root, {
|
|
621
|
+
items: options,
|
|
622
|
+
isItem: (item) => true,
|
|
623
|
+
onMove: handleMove
|
|
624
|
+
}, ({ items }) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
625
|
+
role: "list",
|
|
626
|
+
className: "w-full overflow-auto"
|
|
627
|
+
}, items?.map((item) => /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
628
|
+
key: item.id
|
|
629
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.Item, {
|
|
630
|
+
role: "button",
|
|
631
|
+
item,
|
|
632
|
+
classNames: (0, import_react_ui_theme4.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
633
|
+
"aria-expanded": selected === item.id
|
|
634
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
635
|
+
className: "flex items-center"
|
|
636
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemDragHandle, null), /* @__PURE__ */ import_react6.default.createElement(import_react_ui_list.List.ItemTitle, {
|
|
637
|
+
onClick: () => handleClick(item.id),
|
|
638
|
+
classNames: "flex-1"
|
|
639
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Tag, {
|
|
640
|
+
palette: item.color
|
|
641
|
+
}, item.title || "\u200B")), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
|
|
642
|
+
icon: selected === item.id ? "ph--caret-down--regular" : "ph--caret-right--regular",
|
|
643
|
+
onClick: () => handleClick(item.id)
|
|
644
|
+
})), selected === item.id && /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
645
|
+
className: "mis-4 mbs-2 flex flex-col gap-1"
|
|
646
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.Label, {
|
|
647
|
+
classNames: "text-xs"
|
|
648
|
+
}, t("select option label")), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
649
|
+
className: "flex flex-row items-center gap-1"
|
|
650
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Input.TextInput, {
|
|
651
|
+
placeholder: t("select option label placeholder"),
|
|
652
|
+
ref: selected === item.id ? inputRef : void 0,
|
|
653
|
+
value: item.title,
|
|
654
|
+
onChange: handleTitleChange(item.id),
|
|
655
|
+
onKeyDown: handleKeyDown,
|
|
656
|
+
classNames: "flex-1",
|
|
657
|
+
"data-no-submit": true
|
|
658
|
+
}), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Toolbar.Root, {
|
|
659
|
+
classNames: "p-0 m-0 !is-auto"
|
|
660
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui_pickers.HuePicker, {
|
|
661
|
+
value: item.color,
|
|
662
|
+
onChange: handleColorChange(item.id),
|
|
663
|
+
rootVariant: "toolbar-button"
|
|
664
|
+
})), /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.IconButton, {
|
|
665
|
+
icon: "ph--trash--fill",
|
|
666
|
+
iconOnly: true,
|
|
667
|
+
label: t("select option delete"),
|
|
668
|
+
onClick: () => handleDelete(item.id)
|
|
669
|
+
})))))), /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
670
|
+
role: "listitem"
|
|
671
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
672
|
+
role: "button",
|
|
673
|
+
className: (0, import_react_ui_theme4.mx)("p-1 plb-2", "flex flex-col", "cursor-pointer", "hover:bg-hoverOverlay"),
|
|
674
|
+
onClick: handleAdd
|
|
675
|
+
}, /* @__PURE__ */ import_react6.default.createElement("div", {
|
|
676
|
+
className: "flex items-center gap-1"
|
|
677
|
+
}, /* @__PURE__ */ import_react6.default.createElement(import_react_ui6.Icon, {
|
|
678
|
+
icon: "ph--plus--regular"
|
|
679
|
+
}), /* @__PURE__ */ import_react6.default.createElement("span", {
|
|
680
|
+
className: "text-sm"
|
|
681
|
+
}, t("select option add")))))))));
|
|
682
|
+
} finally {
|
|
683
|
+
_effect.f();
|
|
684
|
+
}
|
|
576
685
|
};
|
|
577
686
|
var gridCols = [
|
|
578
687
|
"grid-cols-1",
|
|
@@ -581,126 +690,162 @@ var gridCols = [
|
|
|
581
690
|
"grid-cols-4"
|
|
582
691
|
];
|
|
583
692
|
var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
693
|
+
var _effect = (0, import_tracking7.useSignals)();
|
|
694
|
+
try {
|
|
695
|
+
const { status, error } = getStatus();
|
|
696
|
+
const values = getValue3() ?? {};
|
|
697
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Root, {
|
|
698
|
+
validationValence: status
|
|
699
|
+
}, /* @__PURE__ */ import_react7.default.createElement(InputHeader, {
|
|
700
|
+
error
|
|
701
|
+
}, /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.Label, null, label)), /* @__PURE__ */ import_react7.default.createElement("div", {
|
|
702
|
+
className: (0, import_react_ui_theme5.mx)("grid gap-2", gridCols[binding.length - 1])
|
|
703
|
+
}, binding.map((prop) => /* @__PURE__ */ import_react7.default.createElement(import_react_ui7.Input.TextInput, {
|
|
704
|
+
key: prop,
|
|
705
|
+
type: "number",
|
|
706
|
+
disabled,
|
|
707
|
+
value: values[prop],
|
|
708
|
+
onChange: (event) => onValueChange(type, {
|
|
709
|
+
...values,
|
|
710
|
+
[prop]: (0, import_util2.safeParseFloat)(event.target.value, 0)
|
|
711
|
+
}),
|
|
712
|
+
onBlur
|
|
713
|
+
}))));
|
|
714
|
+
} finally {
|
|
715
|
+
_effect.f();
|
|
716
|
+
}
|
|
603
717
|
};
|
|
604
718
|
var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
719
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
720
|
+
try {
|
|
721
|
+
const { status, error } = getStatus();
|
|
722
|
+
return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
723
|
+
validationValence: status
|
|
724
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
725
|
+
error
|
|
726
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
|
|
727
|
+
disabled,
|
|
728
|
+
placeholder,
|
|
729
|
+
value: getValue3() ?? "",
|
|
730
|
+
onChange: (event) => onValueChange(type, event.target.value),
|
|
731
|
+
onBlur
|
|
732
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
|
|
733
|
+
} finally {
|
|
734
|
+
_effect.f();
|
|
735
|
+
}
|
|
617
736
|
};
|
|
618
737
|
var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
disabled,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
738
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
739
|
+
try {
|
|
740
|
+
const { status, error } = getStatus();
|
|
741
|
+
return disabled && !getValue3() ? null : disabled && inputOnly ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
742
|
+
validationValence: status
|
|
743
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
744
|
+
error
|
|
745
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextInput, {
|
|
746
|
+
type: "number",
|
|
747
|
+
disabled,
|
|
748
|
+
placeholder,
|
|
749
|
+
value: getValue3() ?? 0,
|
|
750
|
+
onChange: (event) => onValueChange(type, event.target.value),
|
|
751
|
+
onBlur
|
|
752
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
753
|
+
} finally {
|
|
754
|
+
_effect.f();
|
|
755
|
+
}
|
|
632
756
|
};
|
|
633
|
-
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
757
|
+
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange, disabled }) => {
|
|
758
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
759
|
+
try {
|
|
760
|
+
const { status, error } = getStatus();
|
|
761
|
+
const checked = Boolean(getValue3());
|
|
762
|
+
const { t } = (0, import_react_ui8.useTranslation)(translationKey);
|
|
763
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
764
|
+
validationValence: status
|
|
765
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
766
|
+
error
|
|
767
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, t(checked ? "boolean input true value" : "boolean input false value")) : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Switch, {
|
|
768
|
+
checked,
|
|
769
|
+
onCheckedChange: (value) => onValueChange(type, value)
|
|
770
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
771
|
+
} finally {
|
|
772
|
+
_effect.f();
|
|
773
|
+
}
|
|
644
774
|
};
|
|
645
775
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
776
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
777
|
+
try {
|
|
778
|
+
const { status, error } = getStatus();
|
|
779
|
+
const value = getValue3();
|
|
780
|
+
const handleValueChange = (0, import_react8.useCallback)((value2) => onValueChange(type, value2), [
|
|
781
|
+
type,
|
|
782
|
+
onValueChange
|
|
783
|
+
]);
|
|
784
|
+
return disabled && !value ? null : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
785
|
+
validationValence: status
|
|
786
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
787
|
+
error
|
|
788
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, options?.find(({ value: optionValue }) => optionValue === value)?.label ?? String(value)) : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Root, {
|
|
789
|
+
value,
|
|
790
|
+
onValueChange: handleValueChange
|
|
791
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.TriggerButton, {
|
|
792
|
+
classNames: "is-full",
|
|
793
|
+
disabled,
|
|
794
|
+
placeholder
|
|
795
|
+
}), /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Portal, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Content, null, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Viewport, null, options?.map(({ value: value2, label: label2 }) => (
|
|
796
|
+
// NOTE: Numeric values are converted to and from strings.
|
|
797
|
+
/* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.Option, {
|
|
798
|
+
key: String(value2),
|
|
799
|
+
value: String(value2)
|
|
800
|
+
}, label2 ?? String(value2))
|
|
801
|
+
)))))), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.DescriptionAndValidation, null, error));
|
|
802
|
+
} finally {
|
|
803
|
+
_effect.f();
|
|
804
|
+
}
|
|
665
805
|
};
|
|
666
806
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
textarea
|
|
673
|
-
textarea
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
disabled,
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
807
|
+
var _effect = (0, import_tracking8.useSignals)();
|
|
808
|
+
try {
|
|
809
|
+
const { status, error } = getStatus();
|
|
810
|
+
const textareaRef = (0, import_react8.useRef)(null);
|
|
811
|
+
const adjustHeight = (0, import_react8.useCallback)(() => {
|
|
812
|
+
const textarea = textareaRef.current;
|
|
813
|
+
if (textarea) {
|
|
814
|
+
textarea.style.blockSize = "auto";
|
|
815
|
+
textarea.style.blockSize = `${textarea.scrollHeight + 2}px`;
|
|
816
|
+
}
|
|
817
|
+
}, []);
|
|
818
|
+
(0, import_react8.useEffect)(() => {
|
|
819
|
+
adjustHeight();
|
|
820
|
+
}, [
|
|
821
|
+
adjustHeight
|
|
822
|
+
]);
|
|
823
|
+
(0, import_react8.useEffect)(() => {
|
|
824
|
+
adjustHeight();
|
|
825
|
+
}, [
|
|
826
|
+
getValue3(),
|
|
827
|
+
adjustHeight
|
|
828
|
+
]);
|
|
829
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Root, {
|
|
830
|
+
validationValence: status
|
|
831
|
+
}, !inputOnly && /* @__PURE__ */ import_react8.default.createElement(InputHeader, {
|
|
832
|
+
error
|
|
833
|
+
}, /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Label, null, label)), disabled ? /* @__PURE__ */ import_react8.default.createElement("p", null, getValue3() ?? "") : /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.TextArea, {
|
|
834
|
+
ref: textareaRef,
|
|
835
|
+
disabled,
|
|
836
|
+
placeholder,
|
|
837
|
+
value: getValue3() ?? "",
|
|
838
|
+
classNames: "min-bs-auto max-h-40 overflow-auto",
|
|
839
|
+
onChange: (event) => onValueChange(type, event.target.value),
|
|
840
|
+
onBlur,
|
|
841
|
+
style: {
|
|
842
|
+
resize: "none"
|
|
843
|
+
},
|
|
844
|
+
spellCheck: false
|
|
845
|
+
}), inputOnly && /* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Input.Validation, null, error));
|
|
846
|
+
} finally {
|
|
847
|
+
_effect.f();
|
|
848
|
+
}
|
|
704
849
|
};
|
|
705
850
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.ts";
|
|
706
851
|
var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
|
|
@@ -709,7 +854,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
709
854
|
L: 93,
|
|
710
855
|
S: void 0,
|
|
711
856
|
A: [
|
|
712
|
-
"
|
|
857
|
+
"SchemaAST.isTypeLiteral(schema.ast)",
|
|
713
858
|
""
|
|
714
859
|
]
|
|
715
860
|
});
|
|
@@ -810,7 +955,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
810
955
|
} catch (err) {
|
|
811
956
|
import_log2.log.catch(err, void 0, {
|
|
812
957
|
F: __dxlog_file,
|
|
813
|
-
L:
|
|
958
|
+
L: 213,
|
|
814
959
|
S: void 0,
|
|
815
960
|
C: (f, a) => f(...a)
|
|
816
961
|
});
|
|
@@ -881,7 +1026,7 @@ var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, on
|
|
|
881
1026
|
var createKeySet = (obj, value) => {
|
|
882
1027
|
(0, import_invariant.invariant)(obj, void 0, {
|
|
883
1028
|
F: __dxlog_file,
|
|
884
|
-
L:
|
|
1029
|
+
L: 275,
|
|
885
1030
|
S: void 0,
|
|
886
1031
|
A: [
|
|
887
1032
|
"obj",
|
|
@@ -902,6 +1047,70 @@ var flatMap = (errors) => {
|
|
|
902
1047
|
return result;
|
|
903
1048
|
}, {});
|
|
904
1049
|
};
|
|
1050
|
+
var useRefQueryLookupHandler = ({ space }) => {
|
|
1051
|
+
return (0, import_react13.useCallback)(async (typeInfo) => {
|
|
1052
|
+
if (!space) {
|
|
1053
|
+
return [];
|
|
1054
|
+
}
|
|
1055
|
+
const query = space.db.query(import_echo.Filter.typename(typeInfo.typename));
|
|
1056
|
+
const { objects } = await query.run();
|
|
1057
|
+
return objects.map((object) => {
|
|
1058
|
+
const dxn = (0, import_echo_schema5.getDXN)(object);
|
|
1059
|
+
if (!dxn) {
|
|
1060
|
+
return void 0;
|
|
1061
|
+
}
|
|
1062
|
+
const item = {
|
|
1063
|
+
dxn,
|
|
1064
|
+
label: object?.name ?? object?.id ?? ""
|
|
1065
|
+
};
|
|
1066
|
+
return item;
|
|
1067
|
+
}).filter(import_util3.isNonNullable);
|
|
1068
|
+
}, [
|
|
1069
|
+
space
|
|
1070
|
+
]);
|
|
1071
|
+
};
|
|
1072
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useQueryRefOptions.ts";
|
|
1073
|
+
var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
|
|
1074
|
+
const [options, setOptions] = (0, import_react14.useState)([]);
|
|
1075
|
+
const [loading, setLoading] = (0, import_react14.useState)(false);
|
|
1076
|
+
(0, import_react14.useEffect)(() => {
|
|
1077
|
+
if (!refTypeInfo || !onQueryRefOptions) {
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
const fetchOptions = async () => {
|
|
1081
|
+
setLoading(true);
|
|
1082
|
+
try {
|
|
1083
|
+
const fetchedOptions = await onQueryRefOptions(refTypeInfo);
|
|
1084
|
+
setOptions(fetchedOptions.map((option) => {
|
|
1085
|
+
const dxn = option.dxn.toString();
|
|
1086
|
+
return {
|
|
1087
|
+
id: dxn,
|
|
1088
|
+
label: option.label ?? dxn,
|
|
1089
|
+
hue: "neutral"
|
|
1090
|
+
};
|
|
1091
|
+
}));
|
|
1092
|
+
} catch (error) {
|
|
1093
|
+
import_log3.log.error("Failed to fetch ref options:", error, {
|
|
1094
|
+
F: __dxlog_file2,
|
|
1095
|
+
L: 42,
|
|
1096
|
+
S: void 0,
|
|
1097
|
+
C: (f, a) => f(...a)
|
|
1098
|
+
});
|
|
1099
|
+
setOptions([]);
|
|
1100
|
+
} finally {
|
|
1101
|
+
setLoading(false);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
void fetchOptions();
|
|
1105
|
+
}, [
|
|
1106
|
+
refTypeInfo,
|
|
1107
|
+
onQueryRefOptions
|
|
1108
|
+
]);
|
|
1109
|
+
return {
|
|
1110
|
+
options,
|
|
1111
|
+
loading
|
|
1112
|
+
};
|
|
1113
|
+
};
|
|
905
1114
|
var FormContext = /* @__PURE__ */ (0, import_react11.createContext)(void 0);
|
|
906
1115
|
var useFormContext = () => {
|
|
907
1116
|
return (0, import_react11.useContext)(FormContext) ?? (0, import_debug.raise)(new Error("Missing FormContext"));
|
|
@@ -930,16 +1139,14 @@ var useInputProps = (path = []) => {
|
|
|
930
1139
|
]);
|
|
931
1140
|
};
|
|
932
1141
|
var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
}
|
|
938
|
-
const handleKeyDown = (event) => {
|
|
1142
|
+
var _effect = (0, import_tracking11.useSignals)();
|
|
1143
|
+
try {
|
|
1144
|
+
const form = useForm(formOptions);
|
|
1145
|
+
const handleKeyDown = (0, import_react11.useCallback)((event) => {
|
|
939
1146
|
const keyIsEnter = event.key === "Enter";
|
|
940
1147
|
const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
|
|
941
1148
|
const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
|
|
942
|
-
const inputOptOut = event.target.hasAttribute("data-no-submit");
|
|
1149
|
+
const inputOptOut = event.target.hasAttribute("data-no-submit") || event.target.closest("[data-no-submit]") !== null;
|
|
943
1150
|
const shouldSubmitRegularInput = !inputIsTextarea && keyIsEnter && !modifierUsed;
|
|
944
1151
|
const shouldSubmitTextarea = inputIsTextarea && keyIsEnter && event.metaKey;
|
|
945
1152
|
if ((shouldSubmitRegularInput || shouldSubmitTextarea) && !inputOptOut) {
|
|
@@ -950,829 +1157,83 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
950
1157
|
event.target.blur();
|
|
951
1158
|
}
|
|
952
1159
|
}
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
return () => formElement.removeEventListener("keydown", handleKeyDown);
|
|
957
|
-
}, [
|
|
958
|
-
formRef,
|
|
959
|
-
form.canSave,
|
|
960
|
-
form.formIsValid,
|
|
961
|
-
form.handleSave,
|
|
962
|
-
autoSave
|
|
963
|
-
]);
|
|
964
|
-
return /* @__PURE__ */ import_react11.default.createElement(FormContext.Provider, {
|
|
965
|
-
value: form
|
|
966
|
-
}, children);
|
|
967
|
-
};
|
|
968
|
-
var FormActions = ({ onCancel, readonly }) => {
|
|
969
|
-
const { t } = (0, import_react_ui9.useTranslation)(translationKey);
|
|
970
|
-
const { canSave, handleSave } = useFormContext();
|
|
971
|
-
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
972
|
-
role: "none",
|
|
973
|
-
className: "mt-2 flex justify-center"
|
|
974
|
-
}, /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
975
|
-
role: "none",
|
|
976
|
-
className: (0, import_react_ui_theme7.mx)(onCancel && !readonly && "grid grid-cols-2 gap-2")
|
|
977
|
-
}, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
978
|
-
"data-testid": "cancel-button",
|
|
979
|
-
icon: "ph--x--regular",
|
|
980
|
-
label: t("button cancel"),
|
|
981
|
-
onClick: onCancel
|
|
982
|
-
}), handleSave && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
983
|
-
type: "submit",
|
|
984
|
-
"data-testid": "save-button",
|
|
985
|
-
disabled: !canSave,
|
|
986
|
-
icon: "ph--check--regular",
|
|
987
|
-
label: t("button save"),
|
|
988
|
-
onClick: handleSave
|
|
989
|
-
})));
|
|
990
|
-
};
|
|
991
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
992
|
-
var padding = "px-2";
|
|
993
|
-
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
994
|
-
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
995
|
-
const { ast, name, type, title } = property;
|
|
996
|
-
const values = useFormValues(path ?? []) ?? [];
|
|
997
|
-
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
998
|
-
F: __dxlog_file2,
|
|
999
|
-
L: 39,
|
|
1000
|
-
S: void 0,
|
|
1001
|
-
A: [
|
|
1002
|
-
"Array.isArray(values)",
|
|
1003
|
-
"`Values at path ${path?.join('.')} must be an array.`"
|
|
1004
|
-
]
|
|
1005
|
-
});
|
|
1006
|
-
const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
|
|
1007
|
-
const tupleType = (0, import_effect7.findNode)(ast, import_echo_schema6.AST.isTupleType);
|
|
1008
|
-
const elementType = tupleType?.rest[0]?.type;
|
|
1009
|
-
const getDefaultObjectValue = (typeNode) => {
|
|
1010
|
-
const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
|
|
1011
|
-
const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_echo_schema6.AST.isTypeLiteral);
|
|
1012
|
-
if (!typeLiteral) {
|
|
1013
|
-
return {};
|
|
1014
|
-
}
|
|
1015
|
-
return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
|
|
1016
|
-
prop.name,
|
|
1017
|
-
prop.defaultValue
|
|
1018
|
-
]));
|
|
1019
|
-
};
|
|
1020
|
-
const newValue = (0, import_react14.useMemo)(() => {
|
|
1021
|
-
if (type === "object" && elementType) {
|
|
1022
|
-
return getDefaultObjectValue(elementType);
|
|
1023
|
-
} else {
|
|
1024
|
-
return import_effect7.SimpleType.getDefaultValue(type);
|
|
1025
|
-
}
|
|
1026
|
-
}, [
|
|
1027
|
-
type,
|
|
1028
|
-
elementType
|
|
1029
|
-
]);
|
|
1030
|
-
const handleAdd = (0, import_react14.useCallback)(() => {
|
|
1031
|
-
inputProps.onValueChange(type, [
|
|
1032
|
-
...values,
|
|
1033
|
-
newValue
|
|
1160
|
+
}, [
|
|
1161
|
+
form,
|
|
1162
|
+
autoSave
|
|
1034
1163
|
]);
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1164
|
+
(0, import_react11.useEffect)(() => {
|
|
1165
|
+
if (!formRef?.current) {
|
|
1166
|
+
return;
|
|
1167
|
+
}
|
|
1168
|
+
const formElement = formRef.current;
|
|
1169
|
+
formElement.addEventListener("keydown", handleKeyDown);
|
|
1170
|
+
return () => formElement.removeEventListener("keydown", handleKeyDown);
|
|
1171
|
+
}, [
|
|
1172
|
+
formRef,
|
|
1173
|
+
form.canSave,
|
|
1174
|
+
form.formIsValid,
|
|
1175
|
+
form.handleSave,
|
|
1176
|
+
autoSave
|
|
1177
|
+
]);
|
|
1178
|
+
return /* @__PURE__ */ import_react11.default.createElement(FormContext.Provider, {
|
|
1179
|
+
value: form
|
|
1180
|
+
}, children);
|
|
1181
|
+
} finally {
|
|
1182
|
+
_effect.f();
|
|
1052
1183
|
}
|
|
1053
|
-
return /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1054
|
-
role: "none",
|
|
1055
|
-
className: (0, import_react_ui_theme9.mx)(padding)
|
|
1056
|
-
}, /* @__PURE__ */ import_react14.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1057
|
-
role: "none",
|
|
1058
|
-
className: "flex flex-col gap-1"
|
|
1059
|
-
}, values.map((_value, index) => /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1060
|
-
key: index,
|
|
1061
|
-
role: "none",
|
|
1062
|
-
className: "flex items-center gap-1"
|
|
1063
|
-
}, /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1064
|
-
role: "none",
|
|
1065
|
-
className: "flex-1"
|
|
1066
|
-
}, /* @__PURE__ */ import_react14.default.createElement(FormField, {
|
|
1067
|
-
property: {
|
|
1068
|
-
...property,
|
|
1069
|
-
array: false,
|
|
1070
|
-
ast: elementType
|
|
1071
|
-
},
|
|
1072
|
-
path: [
|
|
1073
|
-
...path ?? [],
|
|
1074
|
-
index
|
|
1075
|
-
],
|
|
1076
|
-
readonly,
|
|
1077
|
-
inline: true,
|
|
1078
|
-
Custom,
|
|
1079
|
-
lookupComponent
|
|
1080
|
-
})), /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
|
|
1081
|
-
icon: "ph--trash--regular",
|
|
1082
|
-
iconOnly: true,
|
|
1083
|
-
label: t("button remove"),
|
|
1084
|
-
onClick: () => handleRemove(index)
|
|
1085
|
-
})))), /* @__PURE__ */ import_react14.default.createElement("div", {
|
|
1086
|
-
role: "none",
|
|
1087
|
-
className: "flex justify-between items-center plb-1"
|
|
1088
|
-
}, /* @__PURE__ */ import_react14.default.createElement(import_react_ui10.IconButton, {
|
|
1089
|
-
icon: "ph--plus--regular",
|
|
1090
|
-
iconOnly: true,
|
|
1091
|
-
label: t("button add"),
|
|
1092
|
-
onClick: handleAdd
|
|
1093
|
-
})));
|
|
1094
1184
|
};
|
|
1095
|
-
var
|
|
1096
|
-
var
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
C: (f, a) => f(...a)
|
|
1119
|
-
});
|
|
1120
|
-
setRefOptions([]);
|
|
1121
|
-
} finally {
|
|
1122
|
-
setLoading(false);
|
|
1123
|
-
}
|
|
1124
|
-
};
|
|
1125
|
-
void fetchOptions();
|
|
1126
|
-
}, [
|
|
1127
|
-
refTypeInfo,
|
|
1128
|
-
onQueryRefOptions
|
|
1129
|
-
]);
|
|
1130
|
-
if (!refTypeInfo) {
|
|
1131
|
-
return null;
|
|
1185
|
+
var FormActions = ({ readonly, onCancel }) => {
|
|
1186
|
+
var _effect = (0, import_tracking10.useSignals)();
|
|
1187
|
+
try {
|
|
1188
|
+
const { t } = (0, import_react_ui9.useTranslation)(translationKey);
|
|
1189
|
+
const { canSave, handleSave } = useFormContext();
|
|
1190
|
+
return /* @__PURE__ */ import_react10.default.createElement("div", {
|
|
1191
|
+
role: "none",
|
|
1192
|
+
className: "flex [&_button]:grow gap-1"
|
|
1193
|
+
}, onCancel && !readonly && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
1194
|
+
"data-testid": "cancel-button",
|
|
1195
|
+
icon: "ph--x--regular",
|
|
1196
|
+
label: t("button cancel"),
|
|
1197
|
+
onClick: onCancel
|
|
1198
|
+
}), handleSave && /* @__PURE__ */ import_react10.default.createElement(import_react_ui9.IconButton, {
|
|
1199
|
+
type: "submit",
|
|
1200
|
+
"data-testid": "save-button",
|
|
1201
|
+
disabled: !canSave,
|
|
1202
|
+
icon: "ph--check--regular",
|
|
1203
|
+
label: t("button save"),
|
|
1204
|
+
onClick: handleSave
|
|
1205
|
+
}));
|
|
1206
|
+
} finally {
|
|
1207
|
+
_effect.f();
|
|
1132
1208
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1209
|
+
};
|
|
1210
|
+
var parseValue = ({ type, format, value }) => {
|
|
1211
|
+
if (value === void 0 || value === null || value === "") {
|
|
1212
|
+
return void 0;
|
|
1213
|
+
}
|
|
1214
|
+
const parseScalar = (type2) => {
|
|
1215
|
+
switch (type2) {
|
|
1216
|
+
case import_echo_schema6.TypeEnum.Boolean: {
|
|
1217
|
+
if (typeof value === "string") {
|
|
1218
|
+
const lowercaseValue = value.toLowerCase();
|
|
1219
|
+
if (lowercaseValue === "0" || lowercaseValue === "false") {
|
|
1220
|
+
return false;
|
|
1221
|
+
} else if (lowercaseValue === "1" || lowercaseValue === "true") {
|
|
1222
|
+
return true;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
return Boolean(value);
|
|
1142
1226
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
return formValue;
|
|
1227
|
+
case import_echo_schema6.TypeEnum.Number: {
|
|
1228
|
+
const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
|
|
1229
|
+
const num = Number(cleaned);
|
|
1230
|
+
return Number.isNaN(num) ? null : num;
|
|
1148
1231
|
}
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
return /* @__PURE__ */ import_react15.default.createElement(TextInput, {
|
|
1155
|
-
type,
|
|
1156
|
-
label,
|
|
1157
|
-
disabled: readonly,
|
|
1158
|
-
placeholder,
|
|
1159
|
-
inputOnly: inline,
|
|
1160
|
-
getValue: handleGetValue2,
|
|
1161
|
-
onValueChange: handleOnValueChange,
|
|
1162
|
-
...restInputProps
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
const handleGetValue = () => {
|
|
1166
|
-
const formValue = getValue3();
|
|
1167
|
-
if (formValue instanceof import_live_object.RefImpl) {
|
|
1168
|
-
return formValue.dxn.toString();
|
|
1169
|
-
}
|
|
1170
|
-
return void 0;
|
|
1171
|
-
};
|
|
1172
|
-
const handleValueChanged = (_type, dxnString) => {
|
|
1173
|
-
const dxn = import_keys2.DXN.parse(dxnString);
|
|
1174
|
-
const ref = (0, import_live_object.refFromDXN)(dxn);
|
|
1175
|
-
onValueChange("object", ref);
|
|
1176
|
-
};
|
|
1177
|
-
return /* @__PURE__ */ import_react15.default.createElement(SelectInput, {
|
|
1178
|
-
type,
|
|
1179
|
-
label,
|
|
1180
|
-
disabled: readonly || loading,
|
|
1181
|
-
placeholder: loading ? "Loading options..." : placeholder,
|
|
1182
|
-
inputOnly: inline,
|
|
1183
|
-
getValue: handleGetValue,
|
|
1184
|
-
onValueChange: handleValueChanged,
|
|
1185
|
-
options: refOptions,
|
|
1186
|
-
...restInputProps
|
|
1187
|
-
});
|
|
1188
|
-
};
|
|
1189
|
-
var getInputComponent = (type, format) => {
|
|
1190
|
-
switch (format) {
|
|
1191
|
-
case import_echo_schema8.FormatEnum.GeoPoint:
|
|
1192
|
-
return GeoPointInput;
|
|
1193
|
-
case import_echo_schema8.FormatEnum.Markdown:
|
|
1194
|
-
return MarkdownInput;
|
|
1195
|
-
}
|
|
1196
|
-
switch (type) {
|
|
1197
|
-
case "string":
|
|
1198
|
-
return TextInput;
|
|
1199
|
-
case "number":
|
|
1200
|
-
return NumberInput;
|
|
1201
|
-
case "boolean":
|
|
1202
|
-
return BooleanInput;
|
|
1203
|
-
}
|
|
1204
|
-
};
|
|
1205
|
-
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1206
|
-
const inputProps = useInputProps(path);
|
|
1207
|
-
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1208
|
-
const label = (0, import_react13.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
1209
|
-
title,
|
|
1210
|
-
name
|
|
1211
|
-
]);
|
|
1212
|
-
const placeholder = (0, import_react13.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1213
|
-
examples,
|
|
1214
|
-
description
|
|
1215
|
-
]);
|
|
1216
|
-
const FoundComponent = lookupComponent?.({
|
|
1217
|
-
prop: name,
|
|
1218
|
-
schema: import_echo_schema5.S.make(ast),
|
|
1219
|
-
inputProps: {
|
|
1220
|
-
type,
|
|
1221
|
-
format,
|
|
1222
|
-
label,
|
|
1223
|
-
disabled: readonly,
|
|
1224
|
-
placeholder,
|
|
1225
|
-
...inputProps
|
|
1226
|
-
}
|
|
1227
|
-
});
|
|
1228
|
-
if (FoundComponent) {
|
|
1229
|
-
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1230
|
-
role: "none"
|
|
1231
|
-
}, FoundComponent);
|
|
1232
|
-
}
|
|
1233
|
-
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1234
|
-
const CustomComponent = Custom?.[jsonPath];
|
|
1235
|
-
if (CustomComponent) {
|
|
1236
|
-
return /* @__PURE__ */ import_react13.default.createElement(CustomComponent, {
|
|
1237
|
-
type,
|
|
1238
|
-
format,
|
|
1239
|
-
label,
|
|
1240
|
-
inputOnly: inline,
|
|
1241
|
-
placeholder,
|
|
1242
|
-
disabled: readonly,
|
|
1243
|
-
...inputProps
|
|
1244
|
-
});
|
|
1245
|
-
}
|
|
1246
|
-
if (array) {
|
|
1247
|
-
return /* @__PURE__ */ import_react13.default.createElement(ArrayField, {
|
|
1248
|
-
property,
|
|
1249
|
-
path,
|
|
1250
|
-
inputProps,
|
|
1251
|
-
readonly,
|
|
1252
|
-
Custom
|
|
1253
|
-
});
|
|
1254
|
-
}
|
|
1255
|
-
const InputComponent = getInputComponent(type, format);
|
|
1256
|
-
if (InputComponent) {
|
|
1257
|
-
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1258
|
-
role: "none"
|
|
1259
|
-
}, /* @__PURE__ */ import_react13.default.createElement(InputComponent, {
|
|
1260
|
-
type,
|
|
1261
|
-
format,
|
|
1262
|
-
label,
|
|
1263
|
-
inputOnly: inline,
|
|
1264
|
-
placeholder,
|
|
1265
|
-
disabled: readonly,
|
|
1266
|
-
...inputProps
|
|
1267
|
-
}));
|
|
1268
|
-
}
|
|
1269
|
-
if (options) {
|
|
1270
|
-
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1271
|
-
role: "none"
|
|
1272
|
-
}, /* @__PURE__ */ import_react13.default.createElement(SelectInput, {
|
|
1273
|
-
type,
|
|
1274
|
-
format,
|
|
1275
|
-
disabled: readonly,
|
|
1276
|
-
inputOnly: inline,
|
|
1277
|
-
label,
|
|
1278
|
-
options: options.map((option) => ({
|
|
1279
|
-
value: option,
|
|
1280
|
-
label: String(option)
|
|
1281
|
-
})),
|
|
1282
|
-
placeholder,
|
|
1283
|
-
...inputProps
|
|
1284
|
-
}));
|
|
1285
|
-
}
|
|
1286
|
-
if (format === "ref") {
|
|
1287
|
-
return /* @__PURE__ */ import_react13.default.createElement(RefField, {
|
|
1288
|
-
ast,
|
|
1289
|
-
type,
|
|
1290
|
-
label,
|
|
1291
|
-
readonly,
|
|
1292
|
-
placeholder,
|
|
1293
|
-
inline,
|
|
1294
|
-
onQueryRefOptions,
|
|
1295
|
-
inputProps
|
|
1296
|
-
});
|
|
1297
|
-
}
|
|
1298
|
-
if (type === "object") {
|
|
1299
|
-
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1300
|
-
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_echo_schema5.AST.isTypeLiteral);
|
|
1301
|
-
if (typeLiteral) {
|
|
1302
|
-
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1303
|
-
role: "none"
|
|
1304
|
-
}, !inline && /* @__PURE__ */ import_react13.default.createElement("h3", {
|
|
1305
|
-
className: "text-lg mbs-2 mbe-1"
|
|
1306
|
-
}, label), /* @__PURE__ */ import_react13.default.createElement(FormFields, {
|
|
1307
|
-
schema: import_echo_schema5.S.make(typeLiteral),
|
|
1308
|
-
path,
|
|
1309
|
-
readonly,
|
|
1310
|
-
onQueryRefOptions,
|
|
1311
|
-
Custom,
|
|
1312
|
-
lookupComponent
|
|
1313
|
-
}));
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
return null;
|
|
1317
|
-
};
|
|
1318
|
-
var FormFields = ({ schema, path, filter, sort, readonly, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1319
|
-
const values = useFormValues(path);
|
|
1320
|
-
const properties = (0, import_react13.useMemo)(() => {
|
|
1321
|
-
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
1322
|
-
const filtered = filter ? filter(props) : props;
|
|
1323
|
-
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
1324
|
-
}, [
|
|
1325
|
-
schema,
|
|
1326
|
-
values,
|
|
1327
|
-
filter,
|
|
1328
|
-
sort
|
|
1329
|
-
]);
|
|
1330
|
-
return /* @__PURE__ */ import_react13.default.createElement("div", {
|
|
1331
|
-
role: "form",
|
|
1332
|
-
className: (0, import_react_ui_theme8.mx)("flex flex-col w-full gap-2")
|
|
1333
|
-
}, properties.map((property) => {
|
|
1334
|
-
return /* @__PURE__ */ import_react13.default.createElement(FormField, {
|
|
1335
|
-
key: property.name,
|
|
1336
|
-
property,
|
|
1337
|
-
path: [
|
|
1338
|
-
...path ?? [],
|
|
1339
|
-
property.name
|
|
1340
|
-
],
|
|
1341
|
-
readonly,
|
|
1342
|
-
onQueryRefOptions,
|
|
1343
|
-
lookupComponent,
|
|
1344
|
-
Custom
|
|
1345
|
-
});
|
|
1346
|
-
}).filter(import_util3.isNotFalsy));
|
|
1347
|
-
};
|
|
1348
|
-
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1349
|
-
const formRef = (0, import_react9.useRef)(null);
|
|
1350
|
-
const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
|
|
1351
|
-
autoSave,
|
|
1352
|
-
onSave
|
|
1353
|
-
]);
|
|
1354
|
-
(0, import_react9.useEffect)(() => {
|
|
1355
|
-
if (autoFocus && formRef.current) {
|
|
1356
|
-
const input = formRef.current.querySelector("input");
|
|
1357
|
-
if (input) {
|
|
1358
|
-
input.focus();
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
}, [
|
|
1362
|
-
autoFocus
|
|
1363
|
-
]);
|
|
1364
|
-
return /* @__PURE__ */ import_react9.default.createElement(FormProvider, {
|
|
1365
|
-
formRef,
|
|
1366
|
-
schema,
|
|
1367
|
-
autoSave,
|
|
1368
|
-
initialValues,
|
|
1369
|
-
onValuesChanged,
|
|
1370
|
-
onValidate,
|
|
1371
|
-
onValid,
|
|
1372
|
-
onSave
|
|
1373
|
-
}, /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
1374
|
-
ref: formRef,
|
|
1375
|
-
role: "none",
|
|
1376
|
-
className: (0, import_react_ui_theme6.mx)("p-2", classNames),
|
|
1377
|
-
"data-testid": testId
|
|
1378
|
-
}, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
|
|
1379
|
-
schema,
|
|
1380
|
-
path,
|
|
1381
|
-
readonly,
|
|
1382
|
-
filter,
|
|
1383
|
-
sort,
|
|
1384
|
-
onQueryRefOptions,
|
|
1385
|
-
lookupComponent,
|
|
1386
|
-
Custom
|
|
1387
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
1388
|
-
onCancel,
|
|
1389
|
-
readonly
|
|
1390
|
-
})));
|
|
1391
|
-
};
|
|
1392
|
-
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1393
|
-
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1394
|
-
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
1395
|
-
const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
|
|
1396
|
-
(0, import_react3.useEffect)(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1397
|
-
field,
|
|
1398
|
-
projection
|
|
1399
|
-
]);
|
|
1400
|
-
const [schemas, setSchemas] = (0, import_react3.useState)([]);
|
|
1401
|
-
(0, import_react3.useEffect)(() => {
|
|
1402
|
-
if (!registry) {
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
|
|
1406
|
-
fire: true
|
|
1407
|
-
});
|
|
1408
|
-
const t2 = setTimeout(async () => {
|
|
1409
|
-
const schemas2 = await registry.query().run();
|
|
1410
|
-
setSchemas(schemas2);
|
|
1411
|
-
});
|
|
1412
|
-
return () => {
|
|
1413
|
-
clearTimeout(t2);
|
|
1414
|
-
subscription?.();
|
|
1415
|
-
};
|
|
1416
|
-
}, [
|
|
1417
|
-
registry
|
|
1418
|
-
]);
|
|
1419
|
-
const [referenceSchema, setReferenceSchema] = (0, import_react3.useState)();
|
|
1420
|
-
(0, import_react3.useEffect)(() => {
|
|
1421
|
-
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
1422
|
-
}, [
|
|
1423
|
-
schemas,
|
|
1424
|
-
props?.referenceSchema
|
|
1425
|
-
]);
|
|
1426
|
-
const [{ fieldSchema }, setFieldSchema] = (0, import_react3.useState)({
|
|
1427
|
-
fieldSchema: (0, import_schema.getFormatSchema)(props?.format)
|
|
1428
|
-
});
|
|
1429
|
-
const handleValuesChanged = (0, import_react3.useCallback)((_props) => {
|
|
1430
|
-
setFieldSchema((prev) => {
|
|
1431
|
-
const fieldSchema2 = (0, import_schema.getFormatSchema)(_props.format);
|
|
1432
|
-
if (prev.fieldSchema === fieldSchema2) {
|
|
1433
|
-
return prev;
|
|
1434
|
-
}
|
|
1435
|
-
return {
|
|
1436
|
-
fieldSchema: fieldSchema2
|
|
1437
|
-
};
|
|
1438
|
-
});
|
|
1439
|
-
setReferenceSchema((prev) => {
|
|
1440
|
-
if (_props.referenceSchema !== prev?.typename) {
|
|
1441
|
-
const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
|
|
1442
|
-
if (newSchema) {
|
|
1443
|
-
return newSchema;
|
|
1444
|
-
}
|
|
1445
|
-
}
|
|
1446
|
-
return prev;
|
|
1447
|
-
});
|
|
1448
|
-
setProps((props2) => {
|
|
1449
|
-
const type = import_echo_schema.formatToType[_props.format];
|
|
1450
|
-
if (props2.type !== type) {
|
|
1451
|
-
return {
|
|
1452
|
-
...props2,
|
|
1453
|
-
..._props,
|
|
1454
|
-
type
|
|
1455
|
-
};
|
|
1456
|
-
}
|
|
1457
|
-
return _props;
|
|
1458
|
-
});
|
|
1459
|
-
}, [
|
|
1460
|
-
schemas,
|
|
1461
|
-
props.format,
|
|
1462
|
-
props.referenceSchema
|
|
1463
|
-
]);
|
|
1464
|
-
const handleValidate = (0, import_react3.useCallback)(({ property }) => {
|
|
1465
|
-
if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
1466
|
-
return [
|
|
1467
|
-
{
|
|
1468
|
-
path: "property",
|
|
1469
|
-
message: `property is not unique: '${property}'`
|
|
1470
|
-
}
|
|
1471
|
-
];
|
|
1472
|
-
}
|
|
1473
|
-
}, [
|
|
1474
|
-
view.fields,
|
|
1475
|
-
field
|
|
1476
|
-
]);
|
|
1477
|
-
const handleSave = (0, import_react3.useCallback)((props2) => {
|
|
1478
|
-
projection.setFieldProjection({
|
|
1479
|
-
field,
|
|
1480
|
-
props: props2
|
|
1481
|
-
});
|
|
1482
|
-
onSave();
|
|
1483
|
-
}, [
|
|
1484
|
-
projection,
|
|
1485
|
-
field,
|
|
1486
|
-
onSave
|
|
1487
|
-
]);
|
|
1488
|
-
const handleCancel = (0, import_react3.useCallback)(() => {
|
|
1489
|
-
requestAnimationFrame(() => onCancel?.());
|
|
1490
|
-
onSave();
|
|
1491
|
-
}, [
|
|
1492
|
-
onSave
|
|
1493
|
-
]);
|
|
1494
|
-
const Custom = (0, import_react3.useMemo)(() => ({
|
|
1495
|
-
["format"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
1496
|
-
...props2,
|
|
1497
|
-
options: import_echo_schema.FormatEnums.filter((value) => value !== import_echo_schema.FormatEnum.None).map((value) => ({
|
|
1498
|
-
value,
|
|
1499
|
-
label: t(`format ${value}`)
|
|
1500
|
-
}))
|
|
1501
|
-
}),
|
|
1502
|
-
["referenceSchema"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
1503
|
-
...props2,
|
|
1504
|
-
options: schemas.map((schema) => ({
|
|
1505
|
-
value: schema.typename
|
|
1506
|
-
}))
|
|
1507
|
-
}),
|
|
1508
|
-
["referencePath"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
1509
|
-
...props2,
|
|
1510
|
-
options: referenceSchema ? (0, import_schema.getSchemaProperties)(referenceSchema.ast).sort(import_schema.sortProperties).map((p) => ({
|
|
1511
|
-
value: p.name
|
|
1512
|
-
})) : []
|
|
1513
|
-
}),
|
|
1514
|
-
["options"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectOptionInput, props2)
|
|
1515
|
-
}), [
|
|
1516
|
-
t,
|
|
1517
|
-
schemas,
|
|
1518
|
-
referenceSchema
|
|
1519
|
-
]);
|
|
1520
|
-
const propIsNotType = (0, import_react3.useCallback)((props2) => props2.filter((p) => p.name !== "type"), []);
|
|
1521
|
-
if (!fieldSchema) {
|
|
1522
|
-
import_log.log.warn("invalid format", {
|
|
1523
|
-
props
|
|
1524
|
-
}, {
|
|
1525
|
-
F: __dxlog_file4,
|
|
1526
|
-
L: 174,
|
|
1527
|
-
S: void 0,
|
|
1528
|
-
C: (f, a) => f(...a)
|
|
1529
|
-
});
|
|
1530
|
-
return null;
|
|
1531
|
-
}
|
|
1532
|
-
return /* @__PURE__ */ import_react3.default.createElement(Form, {
|
|
1533
|
-
key: field.id,
|
|
1534
|
-
autoFocus: true,
|
|
1535
|
-
values: props,
|
|
1536
|
-
schema: fieldSchema,
|
|
1537
|
-
filter: propIsNotType,
|
|
1538
|
-
sort: [
|
|
1539
|
-
"property",
|
|
1540
|
-
"format"
|
|
1541
|
-
],
|
|
1542
|
-
onValuesChanged: handleValuesChanged,
|
|
1543
|
-
onValidate: handleValidate,
|
|
1544
|
-
onSave: handleSave,
|
|
1545
|
-
onCancel: handleCancel,
|
|
1546
|
-
Custom
|
|
1547
|
-
});
|
|
1548
|
-
};
|
|
1549
|
-
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1550
|
-
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1551
|
-
var ViewMetaSchema = import_echo_schema9.S.Struct({
|
|
1552
|
-
name: import_echo_schema9.S.String.annotations({
|
|
1553
|
-
[import_echo_schema9.AST.TitleAnnotationId]: "View"
|
|
1554
|
-
}),
|
|
1555
|
-
typename: import_echo_schema9.Format.URL.annotations({
|
|
1556
|
-
[import_echo_schema9.AST.TitleAnnotationId]: "Typename"
|
|
1557
|
-
})
|
|
1558
|
-
}).pipe(import_echo_schema9.S.mutable);
|
|
1559
|
-
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1560
|
-
const { t } = (0, import_react_ui11.useTranslation)(translationKey);
|
|
1561
|
-
const projection = (0, import_react16.useMemo)(() => new import_schema5.ViewProjection(schema.jsonSchema, view), [
|
|
1562
|
-
schema,
|
|
1563
|
-
view
|
|
1564
|
-
]);
|
|
1565
|
-
const [field, setField] = (0, import_react16.useState)();
|
|
1566
|
-
const viewValues = (0, import_react16.useMemo)(() => {
|
|
1567
|
-
return {
|
|
1568
|
-
name: view.name,
|
|
1569
|
-
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
1570
|
-
// TODO(burdon): Settings should have domain name owned by user.
|
|
1571
|
-
typename: view.query.typename
|
|
1572
|
-
};
|
|
1573
|
-
}, [
|
|
1574
|
-
view
|
|
1575
|
-
]);
|
|
1576
|
-
const handleSelect = (0, import_react16.useCallback)((field2) => {
|
|
1577
|
-
setField((f) => f === field2 ? void 0 : field2);
|
|
1578
|
-
}, []);
|
|
1579
|
-
const handleAdd = (0, import_react16.useCallback)(() => {
|
|
1580
|
-
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1581
|
-
F: __dxlog_file5,
|
|
1582
|
-
L: 76,
|
|
1583
|
-
S: void 0,
|
|
1584
|
-
A: [
|
|
1585
|
-
"!schema.readonly",
|
|
1586
|
-
""
|
|
1587
|
-
]
|
|
1588
|
-
});
|
|
1589
|
-
const field2 = projection.createFieldProjection();
|
|
1590
|
-
setField(field2);
|
|
1591
|
-
}, [
|
|
1592
|
-
schema,
|
|
1593
|
-
view
|
|
1594
|
-
]);
|
|
1595
|
-
const handleUpdate = (0, import_react16.useCallback)(({ name, typename }) => {
|
|
1596
|
-
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1597
|
-
F: __dxlog_file5,
|
|
1598
|
-
L: 83,
|
|
1599
|
-
S: void 0,
|
|
1600
|
-
A: [
|
|
1601
|
-
"!schema.readonly",
|
|
1602
|
-
""
|
|
1603
|
-
]
|
|
1604
|
-
});
|
|
1605
|
-
requestAnimationFrame(() => {
|
|
1606
|
-
if (view.name !== name) {
|
|
1607
|
-
view.name = name;
|
|
1608
|
-
}
|
|
1609
|
-
if (view.query.typename !== typename) {
|
|
1610
|
-
onTypenameChanged?.(typename);
|
|
1611
|
-
}
|
|
1612
|
-
});
|
|
1613
|
-
}, [
|
|
1614
|
-
schema,
|
|
1615
|
-
view,
|
|
1616
|
-
onTypenameChanged
|
|
1617
|
-
]);
|
|
1618
|
-
const handleDelete = (0, import_react16.useCallback)((fieldId) => {
|
|
1619
|
-
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1620
|
-
F: __dxlog_file5,
|
|
1621
|
-
L: 99,
|
|
1622
|
-
S: void 0,
|
|
1623
|
-
A: [
|
|
1624
|
-
"!schema.readonly",
|
|
1625
|
-
""
|
|
1626
|
-
]
|
|
1627
|
-
});
|
|
1628
|
-
if (fieldId === field?.id) {
|
|
1629
|
-
setField(void 0);
|
|
1630
|
-
}
|
|
1631
|
-
onDelete?.(fieldId);
|
|
1632
|
-
}, [
|
|
1633
|
-
schema,
|
|
1634
|
-
field,
|
|
1635
|
-
onDelete
|
|
1636
|
-
]);
|
|
1637
|
-
const handleMove = (0, import_react16.useCallback)((fromIndex, toIndex) => {
|
|
1638
|
-
(0, import_invariant3.invariant)(!schema.readonly, void 0, {
|
|
1639
|
-
F: __dxlog_file5,
|
|
1640
|
-
L: 111,
|
|
1641
|
-
S: void 0,
|
|
1642
|
-
A: [
|
|
1643
|
-
"!schema.readonly",
|
|
1644
|
-
""
|
|
1645
|
-
]
|
|
1646
|
-
});
|
|
1647
|
-
const fields = [
|
|
1648
|
-
...view.fields
|
|
1649
|
-
];
|
|
1650
|
-
const [moved] = fields.splice(fromIndex, 1);
|
|
1651
|
-
fields.splice(toIndex, 0, moved);
|
|
1652
|
-
view.fields = fields;
|
|
1653
|
-
}, [
|
|
1654
|
-
schema,
|
|
1655
|
-
view.fields
|
|
1656
|
-
]);
|
|
1657
|
-
const handleClose = (0, import_react16.useCallback)(() => setField(void 0), []);
|
|
1658
|
-
const hiddenProperties = projection.getHiddenProperties();
|
|
1659
|
-
const handleHide = (0, import_react16.useCallback)((fieldId) => {
|
|
1660
|
-
setField(void 0);
|
|
1661
|
-
projection.hideFieldProjection(fieldId);
|
|
1662
|
-
}, [
|
|
1663
|
-
projection
|
|
1664
|
-
]);
|
|
1665
|
-
const handleShow = (0, import_react16.useCallback)((property) => {
|
|
1666
|
-
setField(void 0);
|
|
1667
|
-
projection.showFieldProjection(property);
|
|
1668
|
-
}, [
|
|
1669
|
-
projection
|
|
1670
|
-
]);
|
|
1671
|
-
return /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1672
|
-
role: "none",
|
|
1673
|
-
className: (0, import_react_ui_theme10.mx)("flex flex-col w-full divide-y divide-separator", classNames)
|
|
1674
|
-
}, /* @__PURE__ */ import_react16.default.createElement(Form, {
|
|
1675
|
-
autoSave: true,
|
|
1676
|
-
schema: ViewMetaSchema,
|
|
1677
|
-
values: viewValues,
|
|
1678
|
-
onSave: schema.readonly ? void 0 : handleUpdate
|
|
1679
|
-
}), /* @__PURE__ */ import_react16.default.createElement("div", null, /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1680
|
-
role: "none",
|
|
1681
|
-
className: "p-2"
|
|
1682
|
-
}, /* @__PURE__ */ import_react16.default.createElement("label", {
|
|
1683
|
-
className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
|
|
1684
|
-
}, t("fields label"))), /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.Root, {
|
|
1685
|
-
items: view.fields,
|
|
1686
|
-
isItem: import_echo_schema9.S.is(import_schema5.FieldSchema),
|
|
1687
|
-
getId: (field2) => field2.id,
|
|
1688
|
-
onMove: schema.readonly ? void 0 : handleMove
|
|
1689
|
-
}, ({ items: fields }) => /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, showHeading && /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1690
|
-
role: "heading",
|
|
1691
|
-
className: grid
|
|
1692
|
-
}, /* @__PURE__ */ import_react16.default.createElement("div", null), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1693
|
-
className: "flex items-center text-sm"
|
|
1694
|
-
}, t("field path label"))), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1695
|
-
role: "list",
|
|
1696
|
-
className: "flex flex-col w-full"
|
|
1697
|
-
}, fields?.map((field2) => /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.Item, {
|
|
1698
|
-
key: field2.id,
|
|
1699
|
-
item: field2,
|
|
1700
|
-
classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
|
|
1701
|
-
}, /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.ItemTitle, {
|
|
1702
|
-
onClick: () => handleSelect(field2)
|
|
1703
|
-
}, field2.path), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1704
|
-
className: "flex items-center gap-2 -ml-4"
|
|
1705
|
-
}, /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1706
|
-
icon: "ph--eye-slash--regular",
|
|
1707
|
-
disabled: view.fields.length <= 1,
|
|
1708
|
-
onClick: () => handleHide(field2.id)
|
|
1709
|
-
}), !schema.readonly && /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
1710
|
-
icon: "ph--trash--regular",
|
|
1711
|
-
disabled: view.fields.length <= 1,
|
|
1712
|
-
onClick: () => handleDelete(field2.id)
|
|
1713
|
-
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react16.default.createElement("div", null, /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1714
|
-
role: "none",
|
|
1715
|
-
className: "p-2"
|
|
1716
|
-
}, /* @__PURE__ */ import_react16.default.createElement("label", {
|
|
1717
|
-
className: (0, import_react_ui_theme10.mx)(import_react_ui_theme10.inputTextLabel)
|
|
1718
|
-
}, t("hidden fields label"))), /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.Root, {
|
|
1719
|
-
items: hiddenProperties,
|
|
1720
|
-
isItem: (item) => typeof item === "string",
|
|
1721
|
-
getId: (property) => property
|
|
1722
|
-
}, ({ items: properties }) => /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1723
|
-
role: "list",
|
|
1724
|
-
className: "flex flex-col w-full"
|
|
1725
|
-
}, properties?.map((property) => /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.Item, {
|
|
1726
|
-
key: property,
|
|
1727
|
-
item: property,
|
|
1728
|
-
classNames: (0, import_react_ui_theme10.mx)(grid, import_react_ui_theme10.ghostHover, "cursor-pointer")
|
|
1729
|
-
}, /* @__PURE__ */ import_react16.default.createElement("div", null), /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.ItemTitle, null, property), /* @__PURE__ */ import_react16.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
1730
|
-
icon: "ph--eye--regular",
|
|
1731
|
-
onClick: () => handleShow(property)
|
|
1732
|
-
}))))))), field && /* @__PURE__ */ import_react16.default.createElement(FieldEditor, {
|
|
1733
|
-
key: field.id,
|
|
1734
|
-
view,
|
|
1735
|
-
projection,
|
|
1736
|
-
field,
|
|
1737
|
-
registry,
|
|
1738
|
-
onSave: handleClose
|
|
1739
|
-
}), !readonly && !field && /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1740
|
-
className: "flex p-2 justify-center"
|
|
1741
|
-
}, /* @__PURE__ */ import_react16.default.createElement(import_react_ui11.IconButton, {
|
|
1742
|
-
icon: "ph--plus--regular",
|
|
1743
|
-
label: t("button add property"),
|
|
1744
|
-
onClick: schema.readonly ? void 0 : handleAdd,
|
|
1745
|
-
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
1746
|
-
disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT
|
|
1747
|
-
})));
|
|
1748
|
-
};
|
|
1749
|
-
var parseValue = ({ type, format, value }) => {
|
|
1750
|
-
if (value === void 0 || value === null || value === "") {
|
|
1751
|
-
return void 0;
|
|
1752
|
-
}
|
|
1753
|
-
const parseScalar = (type2) => {
|
|
1754
|
-
switch (type2) {
|
|
1755
|
-
case import_echo_schema10.TypeEnum.Boolean: {
|
|
1756
|
-
if (typeof value === "string") {
|
|
1757
|
-
const lowercaseValue = value.toLowerCase();
|
|
1758
|
-
if (lowercaseValue === "0" || lowercaseValue === "false") {
|
|
1759
|
-
return false;
|
|
1760
|
-
} else if (lowercaseValue === "1" || lowercaseValue === "true") {
|
|
1761
|
-
return true;
|
|
1762
|
-
}
|
|
1763
|
-
}
|
|
1764
|
-
return Boolean(value);
|
|
1765
|
-
}
|
|
1766
|
-
case import_echo_schema10.TypeEnum.Number: {
|
|
1767
|
-
const cleaned = typeof value === "string" ? value.replace(/[^0-9.-]+/g, "") : value;
|
|
1768
|
-
const num = Number(cleaned);
|
|
1769
|
-
return Number.isNaN(num) ? null : num;
|
|
1770
|
-
}
|
|
1771
|
-
case import_echo_schema10.TypeEnum.String:
|
|
1772
|
-
case import_echo_schema10.TypeEnum.Ref:
|
|
1773
|
-
return String(value);
|
|
1774
|
-
default: {
|
|
1775
|
-
return value;
|
|
1232
|
+
case import_echo_schema6.TypeEnum.String:
|
|
1233
|
+
case import_echo_schema6.TypeEnum.Ref:
|
|
1234
|
+
return String(value);
|
|
1235
|
+
default: {
|
|
1236
|
+
return value;
|
|
1776
1237
|
}
|
|
1777
1238
|
}
|
|
1778
1239
|
};
|
|
@@ -1780,26 +1241,26 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1780
1241
|
return parseScalar(type);
|
|
1781
1242
|
}
|
|
1782
1243
|
switch (format) {
|
|
1783
|
-
case
|
|
1784
|
-
return parseScalar(
|
|
1785
|
-
case
|
|
1786
|
-
case
|
|
1787
|
-
case
|
|
1788
|
-
return parseScalar(
|
|
1789
|
-
case
|
|
1790
|
-
case
|
|
1791
|
-
return parseScalar(
|
|
1244
|
+
case import_echo_schema6.FormatEnum.Boolean:
|
|
1245
|
+
return parseScalar(import_echo_schema6.TypeEnum.Boolean);
|
|
1246
|
+
case import_echo_schema6.FormatEnum.Number:
|
|
1247
|
+
case import_echo_schema6.FormatEnum.Percent:
|
|
1248
|
+
case import_echo_schema6.FormatEnum.Currency:
|
|
1249
|
+
return parseScalar(import_echo_schema6.TypeEnum.Number);
|
|
1250
|
+
case import_echo_schema6.FormatEnum.String:
|
|
1251
|
+
case import_echo_schema6.FormatEnum.Markdown: {
|
|
1252
|
+
return parseScalar(import_echo_schema6.TypeEnum.String);
|
|
1792
1253
|
}
|
|
1793
|
-
case
|
|
1794
|
-
throw new Error(`unexpected format: ${
|
|
1795
|
-
case
|
|
1796
|
-
case
|
|
1797
|
-
case
|
|
1798
|
-
case
|
|
1254
|
+
case import_echo_schema6.FormatEnum.Ref:
|
|
1255
|
+
throw new Error(`unexpected format: ${import_echo_schema6.FormatEnum.Ref}`);
|
|
1256
|
+
case import_echo_schema6.FormatEnum.DateTime:
|
|
1257
|
+
case import_echo_schema6.FormatEnum.Date:
|
|
1258
|
+
case import_echo_schema6.FormatEnum.Time:
|
|
1259
|
+
case import_echo_schema6.FormatEnum.Timestamp: {
|
|
1799
1260
|
const date = new Date(value);
|
|
1800
1261
|
return isNaN(date.getTime()) ? null : date;
|
|
1801
1262
|
}
|
|
1802
|
-
case
|
|
1263
|
+
case import_echo_schema6.FormatEnum.GeoPoint: {
|
|
1803
1264
|
if (typeof value === "string") {
|
|
1804
1265
|
const cleaned = value.replace(/[^0-9.,-]+/g, "");
|
|
1805
1266
|
const parts = cleaned.split(",");
|
|
@@ -1807,7 +1268,7 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1807
1268
|
const lat = parseFloat(parts[0]);
|
|
1808
1269
|
const long = parseFloat(parts[1]);
|
|
1809
1270
|
if (!isNaN(lat) && !isNaN(long)) {
|
|
1810
|
-
return
|
|
1271
|
+
return import_echo_schema6.GeoLocation.toGeoPoint({
|
|
1811
1272
|
latitude: lat,
|
|
1812
1273
|
longitude: long
|
|
1813
1274
|
});
|
|
@@ -1827,19 +1288,19 @@ var parseValue = ({ type, format, value }) => {
|
|
|
1827
1288
|
var cellClassesForFieldType = ({ type, format }) => {
|
|
1828
1289
|
if (!format) {
|
|
1829
1290
|
switch (type) {
|
|
1830
|
-
case
|
|
1291
|
+
case import_echo_schema6.TypeEnum.Number:
|
|
1831
1292
|
return [
|
|
1832
1293
|
"text-right",
|
|
1833
1294
|
"font-mono"
|
|
1834
1295
|
];
|
|
1835
|
-
case
|
|
1296
|
+
case import_echo_schema6.TypeEnum.Boolean:
|
|
1836
1297
|
return [
|
|
1837
1298
|
"text-right",
|
|
1838
1299
|
"font-mono"
|
|
1839
1300
|
];
|
|
1840
|
-
case
|
|
1301
|
+
case import_echo_schema6.TypeEnum.String:
|
|
1841
1302
|
return void 0;
|
|
1842
|
-
case
|
|
1303
|
+
case import_echo_schema6.TypeEnum.Ref:
|
|
1843
1304
|
return void 0;
|
|
1844
1305
|
default: {
|
|
1845
1306
|
return void 0;
|
|
@@ -1847,23 +1308,23 @@ var cellClassesForFieldType = ({ type, format }) => {
|
|
|
1847
1308
|
}
|
|
1848
1309
|
}
|
|
1849
1310
|
switch (format) {
|
|
1850
|
-
case
|
|
1311
|
+
case import_echo_schema6.FormatEnum.Markdown:
|
|
1851
1312
|
return void 0;
|
|
1852
|
-
case
|
|
1853
|
-
case
|
|
1854
|
-
case
|
|
1855
|
-
case
|
|
1856
|
-
case
|
|
1313
|
+
case import_echo_schema6.FormatEnum.Time:
|
|
1314
|
+
case import_echo_schema6.FormatEnum.Timestamp:
|
|
1315
|
+
case import_echo_schema6.FormatEnum.DateTime:
|
|
1316
|
+
case import_echo_schema6.FormatEnum.Date:
|
|
1317
|
+
case import_echo_schema6.FormatEnum.Duration:
|
|
1857
1318
|
return [
|
|
1858
1319
|
"font-mono",
|
|
1859
1320
|
"text-right"
|
|
1860
1321
|
];
|
|
1861
|
-
case
|
|
1322
|
+
case import_echo_schema6.FormatEnum.Currency:
|
|
1862
1323
|
return [
|
|
1863
1324
|
"text-right"
|
|
1864
1325
|
];
|
|
1865
|
-
case
|
|
1866
|
-
case
|
|
1326
|
+
case import_echo_schema6.FormatEnum.JSON:
|
|
1327
|
+
case import_echo_schema6.FormatEnum.DID:
|
|
1867
1328
|
return [
|
|
1868
1329
|
"font-mono"
|
|
1869
1330
|
];
|
|
@@ -1878,12 +1339,12 @@ var pathNotUniqueError = (path) => ({
|
|
|
1878
1339
|
var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
1879
1340
|
const formatScalar = (type2) => {
|
|
1880
1341
|
switch (type2) {
|
|
1881
|
-
case
|
|
1342
|
+
case import_echo_schema7.TypeEnum.Boolean:
|
|
1882
1343
|
return value.toLocaleString().toUpperCase();
|
|
1883
|
-
case
|
|
1344
|
+
case import_echo_schema7.TypeEnum.Number:
|
|
1884
1345
|
return value.toLocaleString(locale);
|
|
1885
|
-
case
|
|
1886
|
-
case
|
|
1346
|
+
case import_echo_schema7.TypeEnum.String:
|
|
1347
|
+
case import_echo_schema7.TypeEnum.Ref:
|
|
1887
1348
|
return String(value);
|
|
1888
1349
|
default: {
|
|
1889
1350
|
return String(value);
|
|
@@ -1894,20 +1355,20 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1894
1355
|
return formatScalar(type);
|
|
1895
1356
|
}
|
|
1896
1357
|
switch (format) {
|
|
1897
|
-
case
|
|
1898
|
-
return formatScalar(
|
|
1358
|
+
case import_echo_schema7.FormatEnum.Boolean: {
|
|
1359
|
+
return formatScalar(import_echo_schema7.TypeEnum.Boolean);
|
|
1899
1360
|
}
|
|
1900
|
-
case
|
|
1901
|
-
return formatScalar(
|
|
1361
|
+
case import_echo_schema7.FormatEnum.Number: {
|
|
1362
|
+
return formatScalar(import_echo_schema7.TypeEnum.Number);
|
|
1902
1363
|
}
|
|
1903
|
-
case
|
|
1904
|
-
case
|
|
1905
|
-
return formatScalar(
|
|
1364
|
+
case import_echo_schema7.FormatEnum.String:
|
|
1365
|
+
case import_echo_schema7.FormatEnum.Ref: {
|
|
1366
|
+
return formatScalar(import_echo_schema7.TypeEnum.String);
|
|
1906
1367
|
}
|
|
1907
|
-
case
|
|
1368
|
+
case import_echo_schema7.FormatEnum.Percent: {
|
|
1908
1369
|
return `${value * 100}%`;
|
|
1909
1370
|
}
|
|
1910
|
-
case
|
|
1371
|
+
case import_echo_schema7.FormatEnum.Currency: {
|
|
1911
1372
|
return value.toLocaleString(locale, {
|
|
1912
1373
|
style: "currency",
|
|
1913
1374
|
currency: "USD",
|
|
@@ -1915,33 +1376,33 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1915
1376
|
maximumFractionDigits: 2
|
|
1916
1377
|
});
|
|
1917
1378
|
}
|
|
1918
|
-
case
|
|
1379
|
+
case import_echo_schema7.FormatEnum.Date: {
|
|
1919
1380
|
try {
|
|
1920
1381
|
return (0, import_format.format)(new Date(value), "yyyy-MM-dd");
|
|
1921
1382
|
} catch (error) {
|
|
1922
1383
|
return "Invalid Date";
|
|
1923
1384
|
}
|
|
1924
1385
|
}
|
|
1925
|
-
case
|
|
1386
|
+
case import_echo_schema7.FormatEnum.Time: {
|
|
1926
1387
|
try {
|
|
1927
1388
|
return (0, import_format.format)(new Date(value), "HH:mm:ss");
|
|
1928
1389
|
} catch (error) {
|
|
1929
1390
|
return "Invalid Time";
|
|
1930
1391
|
}
|
|
1931
1392
|
}
|
|
1932
|
-
case
|
|
1393
|
+
case import_echo_schema7.FormatEnum.DateTime: {
|
|
1933
1394
|
try {
|
|
1934
1395
|
return (0, import_format.format)(new Date(value), "yyyy-MM-dd HH:mm:ss");
|
|
1935
1396
|
} catch (error) {
|
|
1936
1397
|
return "Invalid DateTime";
|
|
1937
1398
|
}
|
|
1938
1399
|
}
|
|
1939
|
-
case
|
|
1400
|
+
case import_echo_schema7.FormatEnum.GeoPoint: {
|
|
1940
1401
|
if (value === null || value === void 0) {
|
|
1941
1402
|
return "";
|
|
1942
1403
|
}
|
|
1943
1404
|
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
1944
|
-
const { latitude, longitude } =
|
|
1405
|
+
const { latitude, longitude } = import_echo_schema7.GeoLocation.fromGeoPoint(value);
|
|
1945
1406
|
return `${latitude},${longitude}`;
|
|
1946
1407
|
}
|
|
1947
1408
|
return String(value);
|
|
@@ -1957,10 +1418,10 @@ var formatForDisplay = ({ type, format, value, locale = void 0 }) => {
|
|
|
1957
1418
|
var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
1958
1419
|
const formatScalar = (type2) => {
|
|
1959
1420
|
switch (type2) {
|
|
1960
|
-
case
|
|
1961
|
-
case
|
|
1962
|
-
case
|
|
1963
|
-
case
|
|
1421
|
+
case import_echo_schema7.TypeEnum.Boolean:
|
|
1422
|
+
case import_echo_schema7.TypeEnum.Number:
|
|
1423
|
+
case import_echo_schema7.TypeEnum.String:
|
|
1424
|
+
case import_echo_schema7.TypeEnum.Ref:
|
|
1964
1425
|
return String(value);
|
|
1965
1426
|
default:
|
|
1966
1427
|
return String(value);
|
|
@@ -1970,36 +1431,36 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
1970
1431
|
return formatScalar(type);
|
|
1971
1432
|
}
|
|
1972
1433
|
switch (format) {
|
|
1973
|
-
case
|
|
1974
|
-
case
|
|
1975
|
-
case
|
|
1976
|
-
case
|
|
1434
|
+
case import_echo_schema7.FormatEnum.Boolean:
|
|
1435
|
+
case import_echo_schema7.FormatEnum.Number:
|
|
1436
|
+
case import_echo_schema7.FormatEnum.String:
|
|
1437
|
+
case import_echo_schema7.FormatEnum.Ref: {
|
|
1977
1438
|
return formatScalar(type);
|
|
1978
1439
|
}
|
|
1979
|
-
case
|
|
1440
|
+
case import_echo_schema7.FormatEnum.Percent: {
|
|
1980
1441
|
return String(value * 100);
|
|
1981
1442
|
}
|
|
1982
|
-
case
|
|
1443
|
+
case import_echo_schema7.FormatEnum.Currency: {
|
|
1983
1444
|
return String(value);
|
|
1984
1445
|
}
|
|
1985
|
-
case
|
|
1446
|
+
case import_echo_schema7.FormatEnum.DateTime: {
|
|
1986
1447
|
const date = new Date(value);
|
|
1987
1448
|
return date.toISOString();
|
|
1988
1449
|
}
|
|
1989
|
-
case
|
|
1450
|
+
case import_echo_schema7.FormatEnum.Date: {
|
|
1990
1451
|
const date = new Date(value);
|
|
1991
1452
|
return date.toISOString().split("T")[0];
|
|
1992
1453
|
}
|
|
1993
|
-
case
|
|
1454
|
+
case import_echo_schema7.FormatEnum.Time: {
|
|
1994
1455
|
const date = new Date(value);
|
|
1995
1456
|
return date.toISOString().split("T")[1].split(".")[0];
|
|
1996
1457
|
}
|
|
1997
|
-
case
|
|
1458
|
+
case import_echo_schema7.FormatEnum.GeoPoint: {
|
|
1998
1459
|
if (value === null || value === void 0) {
|
|
1999
1460
|
return "";
|
|
2000
1461
|
}
|
|
2001
1462
|
if (Array.isArray(value) && value.length >= 2 && value.every(Number.isFinite)) {
|
|
2002
|
-
const { latitude, longitude } =
|
|
1463
|
+
const { latitude, longitude } = import_echo_schema7.GeoLocation.fromGeoPoint(value);
|
|
2003
1464
|
return `${latitude},${longitude}`;
|
|
2004
1465
|
}
|
|
2005
1466
|
return String(value);
|
|
@@ -2009,6 +1470,891 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
2009
1470
|
}
|
|
2010
1471
|
}
|
|
2011
1472
|
};
|
|
1473
|
+
var findArrayElementType = (ast) => {
|
|
1474
|
+
const tupleType = (0, import_effect10.findNode)(ast, import_effect9.SchemaAST.isTupleType);
|
|
1475
|
+
const elementType = tupleType?.rest[0]?.type;
|
|
1476
|
+
return elementType;
|
|
1477
|
+
};
|
|
1478
|
+
var getRefProps = (property) => {
|
|
1479
|
+
const { ast, format, array } = property;
|
|
1480
|
+
if (format === import_echo_schema8.FormatEnum.Ref) {
|
|
1481
|
+
return {
|
|
1482
|
+
ast,
|
|
1483
|
+
isArray: false
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
if (array) {
|
|
1487
|
+
const elementType = findArrayElementType(ast);
|
|
1488
|
+
if (elementType) {
|
|
1489
|
+
const annotation = (0, import_effect8.findAnnotation)(elementType, import_echo_schema8.ReferenceAnnotationId);
|
|
1490
|
+
if (annotation) {
|
|
1491
|
+
return {
|
|
1492
|
+
ast: elementType,
|
|
1493
|
+
isArray: true
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
return void 0;
|
|
1499
|
+
};
|
|
1500
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
1501
|
+
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
1502
|
+
var _effect = (0, import_tracking13.useSignals)();
|
|
1503
|
+
try {
|
|
1504
|
+
const { t } = (0, import_react_ui10.useTranslation)(translationKey);
|
|
1505
|
+
const { ast, name, type, title } = property;
|
|
1506
|
+
const values = useFormValues(path ?? []) ?? [];
|
|
1507
|
+
(0, import_invariant2.invariant)(Array.isArray(values), `Values at path ${path?.join(".")} must be an array.`, {
|
|
1508
|
+
F: __dxlog_file3,
|
|
1509
|
+
L: 36,
|
|
1510
|
+
S: void 0,
|
|
1511
|
+
A: [
|
|
1512
|
+
"Array.isArray(values)",
|
|
1513
|
+
"`Values at path ${path?.join('.')} must be an array.`"
|
|
1514
|
+
]
|
|
1515
|
+
});
|
|
1516
|
+
const label = title ?? (0, import_effect6.pipe)(name, import_String2.capitalize);
|
|
1517
|
+
const elementType = findArrayElementType(ast);
|
|
1518
|
+
const getDefaultObjectValue = (typeNode) => {
|
|
1519
|
+
const baseNode = (0, import_effect7.findNode)(typeNode, import_effect7.isDiscriminatedUnion);
|
|
1520
|
+
const typeLiteral = baseNode ? (0, import_effect7.getDiscriminatedType)(baseNode, {}) : (0, import_effect7.findNode)(typeNode, import_effect6.SchemaAST.isTypeLiteral);
|
|
1521
|
+
if (!typeLiteral) {
|
|
1522
|
+
return {};
|
|
1523
|
+
}
|
|
1524
|
+
return Object.fromEntries((0, import_schema4.getSchemaProperties)(typeLiteral, {}).map((prop) => [
|
|
1525
|
+
prop.name,
|
|
1526
|
+
prop.defaultValue
|
|
1527
|
+
]));
|
|
1528
|
+
};
|
|
1529
|
+
const getDefaultValue = () => type === "object" && elementType ? getDefaultObjectValue(elementType) : import_effect7.SimpleType.getDefaultValue(type);
|
|
1530
|
+
const handleAdd = (0, import_react16.useCallback)(() => {
|
|
1531
|
+
inputProps.onValueChange(type, [
|
|
1532
|
+
...values,
|
|
1533
|
+
getDefaultValue()
|
|
1534
|
+
]);
|
|
1535
|
+
}, [
|
|
1536
|
+
type,
|
|
1537
|
+
elementType,
|
|
1538
|
+
inputProps,
|
|
1539
|
+
values
|
|
1540
|
+
]);
|
|
1541
|
+
const handleRemove = (0, import_react16.useCallback)((index) => {
|
|
1542
|
+
const newValues = values.filter((_, i) => i !== index);
|
|
1543
|
+
inputProps.onValueChange(type, newValues);
|
|
1544
|
+
}, [
|
|
1545
|
+
type,
|
|
1546
|
+
inputProps,
|
|
1547
|
+
values
|
|
1548
|
+
]);
|
|
1549
|
+
if (!elementType) {
|
|
1550
|
+
return null;
|
|
1551
|
+
}
|
|
1552
|
+
return readonly && values.length < 1 ? null : /* @__PURE__ */ import_react16.default.createElement(import_react16.default.Fragment, null, /* @__PURE__ */ import_react16.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1553
|
+
role: "none",
|
|
1554
|
+
className: readonly ? "flex flex-wrap gap-1 mlb-1" : values.length > 0 ? "grid gap-1 grid-cols-[1fr_min-content] mlb-1" : "hidden"
|
|
1555
|
+
}, values.map((_value, index) => {
|
|
1556
|
+
const field = /* @__PURE__ */ import_react16.default.createElement(FormField, {
|
|
1557
|
+
property: {
|
|
1558
|
+
...property,
|
|
1559
|
+
array: false,
|
|
1560
|
+
ast: elementType
|
|
1561
|
+
},
|
|
1562
|
+
path: [
|
|
1563
|
+
...path ?? [],
|
|
1564
|
+
index
|
|
1565
|
+
],
|
|
1566
|
+
readonly,
|
|
1567
|
+
inline: true,
|
|
1568
|
+
Custom,
|
|
1569
|
+
lookupComponent
|
|
1570
|
+
});
|
|
1571
|
+
return readonly ? field : /* @__PURE__ */ import_react16.default.createElement(import_react16.Fragment, {
|
|
1572
|
+
key: index
|
|
1573
|
+
}, /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1574
|
+
role: "none"
|
|
1575
|
+
}, field), /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
|
|
1576
|
+
icon: "ph--trash--regular",
|
|
1577
|
+
iconOnly: true,
|
|
1578
|
+
label: t("button remove"),
|
|
1579
|
+
onClick: () => handleRemove(index),
|
|
1580
|
+
classNames: "self-center"
|
|
1581
|
+
}));
|
|
1582
|
+
})), !readonly && /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
|
|
1583
|
+
classNames: "is-full mlb-1 flex",
|
|
1584
|
+
icon: "ph--plus--regular",
|
|
1585
|
+
label: t("add field"),
|
|
1586
|
+
onClick: handleAdd
|
|
1587
|
+
}));
|
|
1588
|
+
} finally {
|
|
1589
|
+
_effect.f();
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1593
|
+
var _effect = (0, import_tracking14.useSignals)();
|
|
1594
|
+
try {
|
|
1595
|
+
const { t } = (0, import_react_ui11.useTranslation)(translationKey);
|
|
1596
|
+
const refTypeInfo = (0, import_react17.useMemo)(() => ast ? (0, import_effect11.findAnnotation)(ast, import_echo_schema9.ReferenceAnnotationId) : void 0, [
|
|
1597
|
+
ast
|
|
1598
|
+
]);
|
|
1599
|
+
const { options: availableOptions, loading: _loading } = useQueryRefOptions({
|
|
1600
|
+
refTypeInfo,
|
|
1601
|
+
onQueryRefOptions
|
|
1602
|
+
});
|
|
1603
|
+
if (refTypeInfo && refTypeInfo?.typename === (0, import_echo_schema9.getTypeAnnotation)(import_echo_schema9.Expando)?.typename || !onQueryRefOptions) {
|
|
1604
|
+
return /* @__PURE__ */ import_react17.default.createElement(RefFieldFallback, {
|
|
1605
|
+
type,
|
|
1606
|
+
label,
|
|
1607
|
+
placeholder,
|
|
1608
|
+
disabled,
|
|
1609
|
+
inputOnly,
|
|
1610
|
+
getValue: getValue3,
|
|
1611
|
+
onBlur,
|
|
1612
|
+
onValueChange,
|
|
1613
|
+
...restInputProps
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
const handleGetValue = (0, import_react17.useCallback)(() => {
|
|
1617
|
+
const formValue = getValue3();
|
|
1618
|
+
const unknownToRefOption = (val) => {
|
|
1619
|
+
if (import_echo_schema9.Ref.isRef(val)) {
|
|
1620
|
+
const dxnString = val.dxn.toString();
|
|
1621
|
+
const matchingOption = availableOptions.find((option2) => option2.id === dxnString);
|
|
1622
|
+
if (matchingOption) {
|
|
1623
|
+
return matchingOption;
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return void 0;
|
|
1627
|
+
};
|
|
1628
|
+
if (array && Array.isArray(formValue)) {
|
|
1629
|
+
return formValue.map(unknownToRefOption).filter(import_util5.isNonNullable) ?? [];
|
|
1630
|
+
}
|
|
1631
|
+
const option = unknownToRefOption(formValue);
|
|
1632
|
+
if (option) {
|
|
1633
|
+
return [
|
|
1634
|
+
option
|
|
1635
|
+
];
|
|
1636
|
+
}
|
|
1637
|
+
return [];
|
|
1638
|
+
}, [
|
|
1639
|
+
getValue3,
|
|
1640
|
+
availableOptions,
|
|
1641
|
+
array
|
|
1642
|
+
]);
|
|
1643
|
+
const handleSearch = (0, import_react17.useCallback)((text, ids) => availableOptions.filter((option) => !ids.includes(option.id)).filter((option) => option.label.toLowerCase().includes(text.toLowerCase())).map((option) => ({
|
|
1644
|
+
id: option.id,
|
|
1645
|
+
label: option.label,
|
|
1646
|
+
hue: option.hue
|
|
1647
|
+
})), [
|
|
1648
|
+
availableOptions
|
|
1649
|
+
]);
|
|
1650
|
+
const handleUpdate = (0, import_react17.useCallback)((ids) => {
|
|
1651
|
+
if (ids.length === 0) {
|
|
1652
|
+
onValueChange("object", void 0);
|
|
1653
|
+
return;
|
|
1654
|
+
}
|
|
1655
|
+
const refs = ids.map((id) => {
|
|
1656
|
+
const item = availableOptions.find((option) => option.id === id);
|
|
1657
|
+
if (item) {
|
|
1658
|
+
const dxn = import_keys2.DXN.parse(item.id);
|
|
1659
|
+
return import_echo_schema9.Ref.fromDXN(dxn);
|
|
1660
|
+
}
|
|
1661
|
+
return null;
|
|
1662
|
+
}).filter(import_util5.isNonNullable);
|
|
1663
|
+
if (array) {
|
|
1664
|
+
onValueChange("object", refs);
|
|
1665
|
+
} else {
|
|
1666
|
+
onValueChange("object", refs[0]);
|
|
1667
|
+
}
|
|
1668
|
+
}, [
|
|
1669
|
+
availableOptions,
|
|
1670
|
+
array,
|
|
1671
|
+
onValueChange
|
|
1672
|
+
]);
|
|
1673
|
+
const tagPickerMode = (0, import_react17.useMemo)(() => array ? "multi-select" : "single-select", [
|
|
1674
|
+
array
|
|
1675
|
+
]);
|
|
1676
|
+
if (!refTypeInfo) {
|
|
1677
|
+
return null;
|
|
1678
|
+
}
|
|
1679
|
+
const { status, error } = restInputProps.getStatus();
|
|
1680
|
+
const items = handleGetValue();
|
|
1681
|
+
return disabled && items.length < 1 ? null : /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Root, {
|
|
1682
|
+
validationValence: status
|
|
1683
|
+
}, !inputOnly && /* @__PURE__ */ import_react17.default.createElement(InputHeader, {
|
|
1684
|
+
error
|
|
1685
|
+
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Label, null, label)), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1686
|
+
"data-no-submit": true
|
|
1687
|
+
}, disabled ? items.length < 1 ? /* @__PURE__ */ import_react17.default.createElement("p", {
|
|
1688
|
+
className: (0, import_react_ui_theme8.mx)(import_react_ui_theme8.descriptionText, "mbe-2")
|
|
1689
|
+
}, t("empty readonly ref field label")) : items.map((item) => /* @__PURE__ */ import_react17.default.createElement(import_react18.DxRefTag, {
|
|
1690
|
+
key: item.id,
|
|
1691
|
+
refid: item.id,
|
|
1692
|
+
rootclassname: "mie-1",
|
|
1693
|
+
style: {
|
|
1694
|
+
marginInlineEnd: ".25rem"
|
|
1695
|
+
}
|
|
1696
|
+
}, item.label)) : /* @__PURE__ */ import_react17.default.createElement(import_react_ui_tag_picker.TagPicker, {
|
|
1697
|
+
readonly: disabled,
|
|
1698
|
+
items,
|
|
1699
|
+
mode: tagPickerMode,
|
|
1700
|
+
onBlur: (event) => onBlur(event),
|
|
1701
|
+
onUpdate: handleUpdate,
|
|
1702
|
+
onSearch: handleSearch,
|
|
1703
|
+
classNames: "rounded-sm bg-inputSurface p-1.5"
|
|
1704
|
+
})), inputOnly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.DescriptionAndValidation, null, error));
|
|
1705
|
+
} finally {
|
|
1706
|
+
_effect.f();
|
|
1707
|
+
}
|
|
1708
|
+
};
|
|
1709
|
+
var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
|
|
1710
|
+
var _effect = (0, import_tracking14.useSignals)();
|
|
1711
|
+
try {
|
|
1712
|
+
const handleOnValueChange = (_type, dxnString) => {
|
|
1713
|
+
const dxn = import_keys2.DXN.tryParse(dxnString);
|
|
1714
|
+
if (dxn) {
|
|
1715
|
+
onValueChange?.("object", import_echo_schema9.Ref.fromDXN(dxn));
|
|
1716
|
+
} else if (dxnString === "") {
|
|
1717
|
+
onValueChange?.("object", void 0);
|
|
1718
|
+
} else {
|
|
1719
|
+
onValueChange?.("string", dxnString);
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
const handleGetValue = () => {
|
|
1723
|
+
const formValue = getValue3();
|
|
1724
|
+
if (typeof formValue === "string") {
|
|
1725
|
+
return formValue;
|
|
1726
|
+
}
|
|
1727
|
+
if (import_echo_schema9.Ref.isRef(formValue)) {
|
|
1728
|
+
return formValue.dxn.toString();
|
|
1729
|
+
}
|
|
1730
|
+
return void 0;
|
|
1731
|
+
};
|
|
1732
|
+
return /* @__PURE__ */ import_react17.default.createElement(TextInput, {
|
|
1733
|
+
type,
|
|
1734
|
+
label,
|
|
1735
|
+
disabled,
|
|
1736
|
+
placeholder,
|
|
1737
|
+
inputOnly,
|
|
1738
|
+
getValue: handleGetValue,
|
|
1739
|
+
onValueChange: handleOnValueChange,
|
|
1740
|
+
...restInputProps
|
|
1741
|
+
});
|
|
1742
|
+
} finally {
|
|
1743
|
+
_effect.f();
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
var getInputComponent = (type, format) => {
|
|
1747
|
+
switch (format) {
|
|
1748
|
+
case import_echo_schema10.FormatEnum.GeoPoint:
|
|
1749
|
+
return GeoPointInput;
|
|
1750
|
+
case import_echo_schema10.FormatEnum.Markdown:
|
|
1751
|
+
return MarkdownInput;
|
|
1752
|
+
}
|
|
1753
|
+
switch (type) {
|
|
1754
|
+
case "string":
|
|
1755
|
+
return TextInput;
|
|
1756
|
+
case "number":
|
|
1757
|
+
return NumberInput;
|
|
1758
|
+
case "boolean":
|
|
1759
|
+
return BooleanInput;
|
|
1760
|
+
}
|
|
1761
|
+
};
|
|
1762
|
+
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1763
|
+
var _effect = (0, import_tracking12.useSignals)();
|
|
1764
|
+
try {
|
|
1765
|
+
const inputProps = useInputProps(path);
|
|
1766
|
+
const { ast, name, type, format, title, description, options, examples, array } = property;
|
|
1767
|
+
const label = (0, import_react15.useMemo)(() => title ?? (0, import_effect4.pipe)(name, import_String.capitalize), [
|
|
1768
|
+
title,
|
|
1769
|
+
name
|
|
1770
|
+
]);
|
|
1771
|
+
const placeholder = (0, import_react15.useMemo)(() => examples?.length ? `Example: "${examples[0]}"` : description, [
|
|
1772
|
+
examples,
|
|
1773
|
+
description
|
|
1774
|
+
]);
|
|
1775
|
+
const FoundComponent = lookupComponent?.({
|
|
1776
|
+
prop: name,
|
|
1777
|
+
schema: import_effect4.Schema.make(ast),
|
|
1778
|
+
inputProps: {
|
|
1779
|
+
type,
|
|
1780
|
+
format,
|
|
1781
|
+
label,
|
|
1782
|
+
disabled: readonly,
|
|
1783
|
+
placeholder,
|
|
1784
|
+
...inputProps
|
|
1785
|
+
}
|
|
1786
|
+
});
|
|
1787
|
+
if (FoundComponent) {
|
|
1788
|
+
return FoundComponent;
|
|
1789
|
+
}
|
|
1790
|
+
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1791
|
+
const CustomComponent = Custom?.[jsonPath];
|
|
1792
|
+
if (CustomComponent) {
|
|
1793
|
+
return /* @__PURE__ */ import_react15.default.createElement(CustomComponent, {
|
|
1794
|
+
type,
|
|
1795
|
+
format,
|
|
1796
|
+
label,
|
|
1797
|
+
inputOnly: inline,
|
|
1798
|
+
placeholder,
|
|
1799
|
+
disabled: readonly,
|
|
1800
|
+
...inputProps
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
const refProps = getRefProps(property);
|
|
1804
|
+
if (refProps) {
|
|
1805
|
+
return /* @__PURE__ */ import_react15.default.createElement(RefField, {
|
|
1806
|
+
ast: refProps.ast,
|
|
1807
|
+
array: refProps.isArray,
|
|
1808
|
+
type,
|
|
1809
|
+
format,
|
|
1810
|
+
label,
|
|
1811
|
+
placeholder,
|
|
1812
|
+
disabled: readonly,
|
|
1813
|
+
inputOnly: inline,
|
|
1814
|
+
onQueryRefOptions,
|
|
1815
|
+
...inputProps
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
if (array) {
|
|
1819
|
+
return /* @__PURE__ */ import_react15.default.createElement(ArrayField, {
|
|
1820
|
+
property,
|
|
1821
|
+
path,
|
|
1822
|
+
inputProps,
|
|
1823
|
+
readonly,
|
|
1824
|
+
Custom
|
|
1825
|
+
});
|
|
1826
|
+
}
|
|
1827
|
+
const InputComponent = getInputComponent(type, format);
|
|
1828
|
+
if (InputComponent) {
|
|
1829
|
+
return /* @__PURE__ */ import_react15.default.createElement(InputComponent, {
|
|
1830
|
+
type,
|
|
1831
|
+
format,
|
|
1832
|
+
label,
|
|
1833
|
+
inputOnly: inline,
|
|
1834
|
+
placeholder,
|
|
1835
|
+
disabled: readonly,
|
|
1836
|
+
...inputProps
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
if (options) {
|
|
1840
|
+
return /* @__PURE__ */ import_react15.default.createElement(SelectInput, {
|
|
1841
|
+
type,
|
|
1842
|
+
format,
|
|
1843
|
+
disabled: readonly,
|
|
1844
|
+
inputOnly: inline,
|
|
1845
|
+
label,
|
|
1846
|
+
options: options.map((option) => ({
|
|
1847
|
+
value: option,
|
|
1848
|
+
label: String(option)
|
|
1849
|
+
})),
|
|
1850
|
+
placeholder,
|
|
1851
|
+
...inputProps
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
if (type === "object") {
|
|
1855
|
+
const baseNode = (0, import_effect5.findNode)(ast, import_effect5.isDiscriminatedUnion);
|
|
1856
|
+
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_effect4.SchemaAST.isTypeLiteral);
|
|
1857
|
+
if (typeLiteral) {
|
|
1858
|
+
return /* @__PURE__ */ import_react15.default.createElement(import_react15.default.Fragment, null, !inline && /* @__PURE__ */ import_react15.default.createElement("h3", {
|
|
1859
|
+
className: "text-lg mbs-2 mbe-1 first:mbs-0"
|
|
1860
|
+
}, label), /* @__PURE__ */ import_react15.default.createElement(FormFields, {
|
|
1861
|
+
schema: import_effect4.Schema.make(typeLiteral),
|
|
1862
|
+
path,
|
|
1863
|
+
readonly,
|
|
1864
|
+
onQueryRefOptions,
|
|
1865
|
+
Custom,
|
|
1866
|
+
lookupComponent
|
|
1867
|
+
}));
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1870
|
+
return null;
|
|
1871
|
+
} finally {
|
|
1872
|
+
_effect.f();
|
|
1873
|
+
}
|
|
1874
|
+
};
|
|
1875
|
+
var FormFields = ({ classNames, Custom, schema, path, filter, sort, readonly, lookupComponent, onQueryRefOptions }) => {
|
|
1876
|
+
var _effect = (0, import_tracking12.useSignals)();
|
|
1877
|
+
try {
|
|
1878
|
+
const values = useFormValues(path);
|
|
1879
|
+
const properties = (0, import_react15.useMemo)(() => {
|
|
1880
|
+
const props = (0, import_schema3.getSchemaProperties)(schema.ast, values);
|
|
1881
|
+
const filtered = filter ? filter(props) : props;
|
|
1882
|
+
return sort ? filtered.sort((a, b) => sort.indexOf(a.name) - sort.indexOf(b.name)) : filtered;
|
|
1883
|
+
}, [
|
|
1884
|
+
schema,
|
|
1885
|
+
values,
|
|
1886
|
+
filter,
|
|
1887
|
+
sort
|
|
1888
|
+
]);
|
|
1889
|
+
return (
|
|
1890
|
+
// TODO(burdon): Consistent padding (with composite forms).
|
|
1891
|
+
/* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1892
|
+
role: "form",
|
|
1893
|
+
className: (0, import_react_ui_theme7.mx)("p-2 is-full", classNames)
|
|
1894
|
+
}, properties.map((property) => {
|
|
1895
|
+
return /* @__PURE__ */ import_react15.default.createElement(FormField, {
|
|
1896
|
+
key: property.name,
|
|
1897
|
+
property,
|
|
1898
|
+
path: [
|
|
1899
|
+
...path ?? [],
|
|
1900
|
+
property.name
|
|
1901
|
+
],
|
|
1902
|
+
readonly,
|
|
1903
|
+
onQueryRefOptions,
|
|
1904
|
+
lookupComponent,
|
|
1905
|
+
Custom
|
|
1906
|
+
});
|
|
1907
|
+
}).filter(import_util4.isNotFalsy))
|
|
1908
|
+
);
|
|
1909
|
+
} finally {
|
|
1910
|
+
_effect.f();
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
var Form = ({ classNames, schema, values: initialValues, path = [], autoFocus, readonly, filter, sort, autoSave, testId, onValuesChanged, onValidate, onSave, onCancel, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1914
|
+
var _effect = (0, import_tracking9.useSignals)();
|
|
1915
|
+
try {
|
|
1916
|
+
const formRef = (0, import_react9.useRef)(null);
|
|
1917
|
+
const onValid = (0, import_react9.useMemo)(() => autoSave ? onSave : void 0, [
|
|
1918
|
+
autoSave,
|
|
1919
|
+
onSave
|
|
1920
|
+
]);
|
|
1921
|
+
(0, import_react9.useEffect)(() => {
|
|
1922
|
+
if (autoFocus && formRef.current) {
|
|
1923
|
+
const input = formRef.current.querySelector("input");
|
|
1924
|
+
if (input) {
|
|
1925
|
+
input.focus();
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
}, [
|
|
1929
|
+
autoFocus
|
|
1930
|
+
]);
|
|
1931
|
+
return /* @__PURE__ */ import_react9.default.createElement(FormProvider, {
|
|
1932
|
+
formRef,
|
|
1933
|
+
schema,
|
|
1934
|
+
autoSave,
|
|
1935
|
+
initialValues,
|
|
1936
|
+
onValuesChanged,
|
|
1937
|
+
onValidate,
|
|
1938
|
+
onValid,
|
|
1939
|
+
onSave
|
|
1940
|
+
}, /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
1941
|
+
ref: formRef,
|
|
1942
|
+
role: "none",
|
|
1943
|
+
className: (0, import_react_ui_theme6.mx)("flex flex-col gap-4", classNames),
|
|
1944
|
+
"data-testid": testId
|
|
1945
|
+
}, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
|
|
1946
|
+
schema,
|
|
1947
|
+
path,
|
|
1948
|
+
readonly,
|
|
1949
|
+
filter,
|
|
1950
|
+
sort,
|
|
1951
|
+
onQueryRefOptions,
|
|
1952
|
+
lookupComponent,
|
|
1953
|
+
Custom
|
|
1954
|
+
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
1955
|
+
onCancel,
|
|
1956
|
+
readonly
|
|
1957
|
+
})));
|
|
1958
|
+
} finally {
|
|
1959
|
+
_effect.f();
|
|
1960
|
+
}
|
|
1961
|
+
};
|
|
1962
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1963
|
+
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1964
|
+
var _effect = (0, import_tracking3.useSignals)();
|
|
1965
|
+
try {
|
|
1966
|
+
const { t } = (0, import_react_ui3.useTranslation)(translationKey);
|
|
1967
|
+
const [props, setProps] = (0, import_react3.useState)(projection.getFieldProjection(field.id).props);
|
|
1968
|
+
(0, import_react3.useEffect)(() => setProps(projection.getFieldProjection(field.id).props), [
|
|
1969
|
+
field,
|
|
1970
|
+
projection
|
|
1971
|
+
]);
|
|
1972
|
+
const [schemas, setSchemas] = (0, import_react3.useState)([]);
|
|
1973
|
+
(0, import_react3.useEffect)(() => {
|
|
1974
|
+
if (!registry) {
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
const subscription = registry.query().subscribe((query) => setSchemas(query.results), {
|
|
1978
|
+
fire: true
|
|
1979
|
+
});
|
|
1980
|
+
const t2 = setTimeout(async () => {
|
|
1981
|
+
const schemas2 = await registry.query().run();
|
|
1982
|
+
setSchemas(schemas2);
|
|
1983
|
+
});
|
|
1984
|
+
return () => {
|
|
1985
|
+
clearTimeout(t2);
|
|
1986
|
+
subscription?.();
|
|
1987
|
+
};
|
|
1988
|
+
}, [
|
|
1989
|
+
registry
|
|
1990
|
+
]);
|
|
1991
|
+
const [referenceSchema, setReferenceSchema] = (0, import_react3.useState)();
|
|
1992
|
+
(0, import_react3.useEffect)(() => {
|
|
1993
|
+
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
1994
|
+
}, [
|
|
1995
|
+
schemas,
|
|
1996
|
+
props?.referenceSchema
|
|
1997
|
+
]);
|
|
1998
|
+
const [{ fieldSchema }, setFieldSchema] = (0, import_react3.useState)({
|
|
1999
|
+
fieldSchema: (0, import_schema.getFormatSchema)(props?.format)
|
|
2000
|
+
});
|
|
2001
|
+
const handleValuesChanged = (0, import_react3.useCallback)((_props) => {
|
|
2002
|
+
setFieldSchema((prev) => {
|
|
2003
|
+
const fieldSchema2 = (0, import_schema.getFormatSchema)(_props.format);
|
|
2004
|
+
if (prev.fieldSchema === fieldSchema2) {
|
|
2005
|
+
return prev;
|
|
2006
|
+
}
|
|
2007
|
+
return {
|
|
2008
|
+
fieldSchema: fieldSchema2
|
|
2009
|
+
};
|
|
2010
|
+
});
|
|
2011
|
+
setReferenceSchema((prev) => {
|
|
2012
|
+
if (_props.referenceSchema !== prev?.typename) {
|
|
2013
|
+
const newSchema = schemas.find((schema) => schema.typename === _props.referenceSchema);
|
|
2014
|
+
if (newSchema) {
|
|
2015
|
+
return newSchema;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
return prev;
|
|
2019
|
+
});
|
|
2020
|
+
setProps((props2) => {
|
|
2021
|
+
const type = import_echo_schema.formatToType[_props.format];
|
|
2022
|
+
if (props2.type !== type) {
|
|
2023
|
+
return {
|
|
2024
|
+
...props2,
|
|
2025
|
+
..._props,
|
|
2026
|
+
type
|
|
2027
|
+
};
|
|
2028
|
+
}
|
|
2029
|
+
return _props;
|
|
2030
|
+
});
|
|
2031
|
+
}, [
|
|
2032
|
+
schemas,
|
|
2033
|
+
props.format,
|
|
2034
|
+
props.referenceSchema
|
|
2035
|
+
]);
|
|
2036
|
+
const handleValidate = (0, import_react3.useCallback)(({ property }) => {
|
|
2037
|
+
if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
2038
|
+
return [
|
|
2039
|
+
{
|
|
2040
|
+
path: "property",
|
|
2041
|
+
message: `property is not unique: '${property}'`
|
|
2042
|
+
}
|
|
2043
|
+
];
|
|
2044
|
+
}
|
|
2045
|
+
}, [
|
|
2046
|
+
view.fields,
|
|
2047
|
+
field
|
|
2048
|
+
]);
|
|
2049
|
+
const handleSave = (0, import_react3.useCallback)((props2) => {
|
|
2050
|
+
projection.setFieldProjection({
|
|
2051
|
+
field,
|
|
2052
|
+
props: props2
|
|
2053
|
+
});
|
|
2054
|
+
onSave();
|
|
2055
|
+
}, [
|
|
2056
|
+
projection,
|
|
2057
|
+
field,
|
|
2058
|
+
onSave
|
|
2059
|
+
]);
|
|
2060
|
+
const handleCancel = (0, import_react3.useCallback)(() => {
|
|
2061
|
+
requestAnimationFrame(() => onCancel?.());
|
|
2062
|
+
onSave();
|
|
2063
|
+
}, [
|
|
2064
|
+
onSave
|
|
2065
|
+
]);
|
|
2066
|
+
const custom = (0, import_react3.useMemo)(() => ({
|
|
2067
|
+
["format"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
2068
|
+
...props2,
|
|
2069
|
+
options: import_echo_schema.FormatEnums.filter((value) => value !== import_echo_schema.FormatEnum.None).map((value) => ({
|
|
2070
|
+
value,
|
|
2071
|
+
label: t(`format ${value}`)
|
|
2072
|
+
}))
|
|
2073
|
+
}),
|
|
2074
|
+
["referenceSchema"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
2075
|
+
...props2,
|
|
2076
|
+
options: schemas.map((schema) => ({
|
|
2077
|
+
value: schema.typename
|
|
2078
|
+
}))
|
|
2079
|
+
}),
|
|
2080
|
+
["referencePath"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectInput, {
|
|
2081
|
+
...props2,
|
|
2082
|
+
options: referenceSchema ? (0, import_schema.getSchemaProperties)(referenceSchema.ast).sort(import_schema.sortProperties).map((p) => ({
|
|
2083
|
+
value: p.name
|
|
2084
|
+
})) : []
|
|
2085
|
+
}),
|
|
2086
|
+
["options"]: (props2) => /* @__PURE__ */ import_react3.default.createElement(SelectOptionInput, props2)
|
|
2087
|
+
}), [
|
|
2088
|
+
t,
|
|
2089
|
+
schemas,
|
|
2090
|
+
referenceSchema
|
|
2091
|
+
]);
|
|
2092
|
+
const propIsNotType = (0, import_react3.useCallback)((props2) => props2.filter((p) => p.name !== "type"), []);
|
|
2093
|
+
if (!fieldSchema) {
|
|
2094
|
+
import_log.log.warn("invalid format", {
|
|
2095
|
+
props
|
|
2096
|
+
}, {
|
|
2097
|
+
F: __dxlog_file4,
|
|
2098
|
+
L: 175,
|
|
2099
|
+
S: void 0,
|
|
2100
|
+
C: (f, a) => f(...a)
|
|
2101
|
+
});
|
|
2102
|
+
return null;
|
|
2103
|
+
}
|
|
2104
|
+
return /* @__PURE__ */ import_react3.default.createElement(Form, {
|
|
2105
|
+
key: field.id,
|
|
2106
|
+
autoFocus: true,
|
|
2107
|
+
values: props,
|
|
2108
|
+
schema: fieldSchema,
|
|
2109
|
+
filter: propIsNotType,
|
|
2110
|
+
sort: [
|
|
2111
|
+
"property",
|
|
2112
|
+
"format"
|
|
2113
|
+
],
|
|
2114
|
+
onValuesChanged: handleValuesChanged,
|
|
2115
|
+
onValidate: handleValidate,
|
|
2116
|
+
onSave: handleSave,
|
|
2117
|
+
onCancel: handleCancel,
|
|
2118
|
+
Custom: custom
|
|
2119
|
+
});
|
|
2120
|
+
} finally {
|
|
2121
|
+
_effect.f();
|
|
2122
|
+
}
|
|
2123
|
+
};
|
|
2124
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
2125
|
+
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
2126
|
+
var ViewMetaSchema = import_effect12.Schema.Struct({
|
|
2127
|
+
name: import_effect12.Schema.String.annotations({
|
|
2128
|
+
title: "View"
|
|
2129
|
+
}),
|
|
2130
|
+
typename: import_echo_schema11.Format.URL.annotations({
|
|
2131
|
+
title: "Typename"
|
|
2132
|
+
})
|
|
2133
|
+
}).pipe(import_effect12.Schema.mutable);
|
|
2134
|
+
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
2135
|
+
var _effect = (0, import_tracking15.useSignals)();
|
|
2136
|
+
try {
|
|
2137
|
+
const { t } = (0, import_react_ui12.useTranslation)(translationKey);
|
|
2138
|
+
const projection = (0, import_react19.useMemo)(() => {
|
|
2139
|
+
const jsonSchema = schema instanceof import_echo_schema11.EchoSchema ? schema.jsonSchema : (0, import_echo_schema11.toJsonSchema)(schema);
|
|
2140
|
+
return new import_schema5.ViewProjection(jsonSchema, view);
|
|
2141
|
+
}, [
|
|
2142
|
+
schema,
|
|
2143
|
+
view
|
|
2144
|
+
]);
|
|
2145
|
+
const [field, setField] = (0, import_react19.useState)();
|
|
2146
|
+
const immutable = readonly || !(0, import_echo_schema11.isMutable)(schema);
|
|
2147
|
+
const viewValues = (0, import_react19.useMemo)(() => {
|
|
2148
|
+
return {
|
|
2149
|
+
name: view.name,
|
|
2150
|
+
// TODO(burdon): Need to warn user of possible consequences of editing.
|
|
2151
|
+
// TODO(burdon): Settings should have domain name owned by user.
|
|
2152
|
+
typename: view.query.typename
|
|
2153
|
+
};
|
|
2154
|
+
}, [
|
|
2155
|
+
view
|
|
2156
|
+
]);
|
|
2157
|
+
const handleSelect = (0, import_react19.useCallback)((field2) => {
|
|
2158
|
+
if (immutable) {
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2161
|
+
setField((f) => f === field2 ? void 0 : field2);
|
|
2162
|
+
}, [
|
|
2163
|
+
immutable
|
|
2164
|
+
]);
|
|
2165
|
+
const handleAdd = (0, import_react19.useCallback)(() => {
|
|
2166
|
+
(0, import_invariant3.invariant)(!immutable, void 0, {
|
|
2167
|
+
F: __dxlog_file5,
|
|
2168
|
+
L: 88,
|
|
2169
|
+
S: void 0,
|
|
2170
|
+
A: [
|
|
2171
|
+
"!immutable",
|
|
2172
|
+
""
|
|
2173
|
+
]
|
|
2174
|
+
});
|
|
2175
|
+
const field2 = projection.createFieldProjection();
|
|
2176
|
+
setField(field2);
|
|
2177
|
+
}, [
|
|
2178
|
+
schema,
|
|
2179
|
+
view
|
|
2180
|
+
]);
|
|
2181
|
+
const handleUpdate = (0, import_react19.useCallback)(({ name, typename }) => {
|
|
2182
|
+
(0, import_invariant3.invariant)(!immutable, void 0, {
|
|
2183
|
+
F: __dxlog_file5,
|
|
2184
|
+
L: 95,
|
|
2185
|
+
S: void 0,
|
|
2186
|
+
A: [
|
|
2187
|
+
"!immutable",
|
|
2188
|
+
""
|
|
2189
|
+
]
|
|
2190
|
+
});
|
|
2191
|
+
requestAnimationFrame(() => {
|
|
2192
|
+
if (view.name !== name) {
|
|
2193
|
+
view.name = name;
|
|
2194
|
+
}
|
|
2195
|
+
if (view.query.typename !== typename && !immutable) {
|
|
2196
|
+
onTypenameChanged?.(typename);
|
|
2197
|
+
}
|
|
2198
|
+
});
|
|
2199
|
+
}, [
|
|
2200
|
+
schema,
|
|
2201
|
+
view,
|
|
2202
|
+
onTypenameChanged,
|
|
2203
|
+
immutable
|
|
2204
|
+
]);
|
|
2205
|
+
const handleDelete = (0, import_react19.useCallback)((fieldId) => {
|
|
2206
|
+
(0, import_invariant3.invariant)(!immutable, void 0, {
|
|
2207
|
+
F: __dxlog_file5,
|
|
2208
|
+
L: 111,
|
|
2209
|
+
S: void 0,
|
|
2210
|
+
A: [
|
|
2211
|
+
"!immutable",
|
|
2212
|
+
""
|
|
2213
|
+
]
|
|
2214
|
+
});
|
|
2215
|
+
if (fieldId === field?.id) {
|
|
2216
|
+
setField(void 0);
|
|
2217
|
+
}
|
|
2218
|
+
onDelete?.(fieldId);
|
|
2219
|
+
}, [
|
|
2220
|
+
schema,
|
|
2221
|
+
field,
|
|
2222
|
+
onDelete
|
|
2223
|
+
]);
|
|
2224
|
+
const handleMove = (0, import_react19.useCallback)((fromIndex, toIndex) => {
|
|
2225
|
+
(0, import_invariant3.invariant)(!immutable, void 0, {
|
|
2226
|
+
F: __dxlog_file5,
|
|
2227
|
+
L: 123,
|
|
2228
|
+
S: void 0,
|
|
2229
|
+
A: [
|
|
2230
|
+
"!immutable",
|
|
2231
|
+
""
|
|
2232
|
+
]
|
|
2233
|
+
});
|
|
2234
|
+
const fields = [
|
|
2235
|
+
...view.fields
|
|
2236
|
+
];
|
|
2237
|
+
const [moved] = fields.splice(fromIndex, 1);
|
|
2238
|
+
fields.splice(toIndex, 0, moved);
|
|
2239
|
+
view.fields = fields;
|
|
2240
|
+
}, [
|
|
2241
|
+
schema,
|
|
2242
|
+
view.fields
|
|
2243
|
+
]);
|
|
2244
|
+
const handleClose = (0, import_react19.useCallback)(() => setField(void 0), []);
|
|
2245
|
+
const hiddenProperties = projection.getHiddenProperties();
|
|
2246
|
+
const handleHide = (0, import_react19.useCallback)((fieldId) => {
|
|
2247
|
+
setField(void 0);
|
|
2248
|
+
projection.hideFieldProjection(fieldId);
|
|
2249
|
+
}, [
|
|
2250
|
+
projection
|
|
2251
|
+
]);
|
|
2252
|
+
const handleShow = (0, import_react19.useCallback)((property) => {
|
|
2253
|
+
setField(void 0);
|
|
2254
|
+
projection.showFieldProjection(property);
|
|
2255
|
+
}, [
|
|
2256
|
+
projection
|
|
2257
|
+
]);
|
|
2258
|
+
return /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2259
|
+
role: "none",
|
|
2260
|
+
className: (0, import_react_ui_theme9.mx)("overflow-y-auto", classNames)
|
|
2261
|
+
}, /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2262
|
+
role: "none",
|
|
2263
|
+
className: "p-2"
|
|
2264
|
+
}, /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2265
|
+
role: "none",
|
|
2266
|
+
className: "mbe-2"
|
|
2267
|
+
}, immutable && /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Message.Root, {
|
|
2268
|
+
valence: "neutral",
|
|
2269
|
+
className: "rounded"
|
|
2270
|
+
}, /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Message.Title, null, /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Icon, {
|
|
2271
|
+
icon: "ph--info--regular",
|
|
2272
|
+
size: 5,
|
|
2273
|
+
classNames: "inline"
|
|
2274
|
+
}), " ", t("system schema title")), /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.Message.Body, null, t("system schema description")))), /* @__PURE__ */ import_react19.default.createElement(Form, {
|
|
2275
|
+
autoSave: true,
|
|
2276
|
+
schema: ViewMetaSchema,
|
|
2277
|
+
values: viewValues,
|
|
2278
|
+
onSave: handleUpdate,
|
|
2279
|
+
classNames: "min-bs-0 overflow-y-auto"
|
|
2280
|
+
})), /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2281
|
+
role: "none",
|
|
2282
|
+
className: "min-bs-0 overflow-y-auto"
|
|
2283
|
+
}, /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2284
|
+
role: "none",
|
|
2285
|
+
className: "p-2"
|
|
2286
|
+
}, /* @__PURE__ */ import_react19.default.createElement("label", {
|
|
2287
|
+
className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
|
|
2288
|
+
}, t("fields label"))), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Root, {
|
|
2289
|
+
items: view.fields,
|
|
2290
|
+
isItem: import_effect12.Schema.is(import_schema5.FieldSchema),
|
|
2291
|
+
getId: (field2) => field2.id,
|
|
2292
|
+
onMove: immutable ? void 0 : handleMove
|
|
2293
|
+
}, ({ items: fields }) => /* @__PURE__ */ import_react19.default.createElement(import_react19.default.Fragment, null, showHeading && /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2294
|
+
role: "heading",
|
|
2295
|
+
className: grid
|
|
2296
|
+
}, /* @__PURE__ */ import_react19.default.createElement("div", null), /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2297
|
+
className: "flex items-center text-sm"
|
|
2298
|
+
}, t("field path label"))), /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2299
|
+
role: "list",
|
|
2300
|
+
className: "flex flex-col w-full"
|
|
2301
|
+
}, fields?.map((field2) => /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Item, {
|
|
2302
|
+
key: field2.id,
|
|
2303
|
+
item: field2,
|
|
2304
|
+
classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, !immutable && "cursor-pointer")
|
|
2305
|
+
}, /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemDragHandle, null), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemTitle, {
|
|
2306
|
+
onClick: () => handleSelect(field2)
|
|
2307
|
+
}, field2.path), /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2308
|
+
className: "flex items-center gap-2 -ml-4"
|
|
2309
|
+
}, /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
2310
|
+
icon: "ph--eye-slash--regular",
|
|
2311
|
+
disabled: view.fields.length <= 1,
|
|
2312
|
+
onClick: () => handleHide(field2.id)
|
|
2313
|
+
}), !immutable && /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemDeleteButton, {
|
|
2314
|
+
icon: "ph--trash--regular",
|
|
2315
|
+
disabled: view.fields.length <= 1,
|
|
2316
|
+
onClick: () => handleDelete(field2.id)
|
|
2317
|
+
}))))))), hiddenProperties.length > 0 && /* @__PURE__ */ import_react19.default.createElement("div", null, /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2318
|
+
role: "none",
|
|
2319
|
+
className: "p-2"
|
|
2320
|
+
}, /* @__PURE__ */ import_react19.default.createElement("label", {
|
|
2321
|
+
className: (0, import_react_ui_theme9.mx)(import_react_ui_theme9.inputTextLabel)
|
|
2322
|
+
}, t("hidden fields label"))), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Root, {
|
|
2323
|
+
items: hiddenProperties,
|
|
2324
|
+
isItem: (item) => typeof item === "string",
|
|
2325
|
+
getId: (property) => property
|
|
2326
|
+
}, ({ items: properties }) => /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2327
|
+
role: "list",
|
|
2328
|
+
className: "flex flex-col w-full"
|
|
2329
|
+
}, properties?.map((property) => /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.Item, {
|
|
2330
|
+
key: property,
|
|
2331
|
+
item: property,
|
|
2332
|
+
classNames: (0, import_react_ui_theme9.mx)(grid, import_react_ui_theme9.ghostHover, !immutable && "cursor-pointer")
|
|
2333
|
+
}, /* @__PURE__ */ import_react19.default.createElement("div", null), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemTitle, null, property), /* @__PURE__ */ import_react19.default.createElement(import_react_ui_list2.List.ItemButton, {
|
|
2334
|
+
icon: "ph--eye--regular",
|
|
2335
|
+
onClick: () => handleShow(property)
|
|
2336
|
+
}))))))), field && /* @__PURE__ */ import_react19.default.createElement(FieldEditor, {
|
|
2337
|
+
key: field.id,
|
|
2338
|
+
view,
|
|
2339
|
+
projection,
|
|
2340
|
+
field,
|
|
2341
|
+
registry,
|
|
2342
|
+
onSave: handleClose
|
|
2343
|
+
}), !readonly && !field && /* @__PURE__ */ import_react19.default.createElement("div", {
|
|
2344
|
+
role: "none",
|
|
2345
|
+
className: "p-2"
|
|
2346
|
+
}, /* @__PURE__ */ import_react19.default.createElement(import_react_ui12.IconButton, {
|
|
2347
|
+
icon: "ph--plus--regular",
|
|
2348
|
+
label: t("button add property"),
|
|
2349
|
+
onClick: immutable ? void 0 : handleAdd,
|
|
2350
|
+
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2351
|
+
disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT,
|
|
2352
|
+
classNames: "flex is-full"
|
|
2353
|
+
})));
|
|
2354
|
+
} finally {
|
|
2355
|
+
_effect.f();
|
|
2356
|
+
}
|
|
2357
|
+
};
|
|
2012
2358
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2013
2359
|
0 && (module.exports = {
|
|
2014
2360
|
BooleanInput,
|
|
@@ -2037,14 +2383,18 @@ var formatForEditing = ({ type, format, value, locale = void 0 }) => {
|
|
|
2037
2383
|
ViewEditor,
|
|
2038
2384
|
cellClassesForFieldType,
|
|
2039
2385
|
controlItemClasses,
|
|
2386
|
+
findArrayElementType,
|
|
2040
2387
|
formatForDisplay,
|
|
2041
2388
|
formatForEditing,
|
|
2389
|
+
getRefProps,
|
|
2042
2390
|
parseValue,
|
|
2043
2391
|
pathNotUniqueError,
|
|
2044
2392
|
translations,
|
|
2045
2393
|
useForm,
|
|
2046
2394
|
useFormContext,
|
|
2047
2395
|
useFormValues,
|
|
2048
|
-
useInputProps
|
|
2396
|
+
useInputProps,
|
|
2397
|
+
useQueryRefOptions,
|
|
2398
|
+
useRefQueryLookupHandler
|
|
2049
2399
|
});
|
|
2050
2400
|
//# sourceMappingURL=index.cjs.map
|