@dxos/react-ui-form 0.8.2-main.fbd8ed0 → 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 +1445 -1245
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +1431 -1231
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +1445 -1245
- package/dist/lib/node-esm/index.mjs.map +3 -3
- 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.map +1 -1
- package/dist/types/src/components/Form/Form.stories.d.ts +1 -2
- 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 +6 -5
- 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/RefField.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.d.ts.map +1 -1
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts +5 -3
- package/dist/types/src/components/ViewEditor/ViewEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/testing.d.ts.map +1 -1
- package/dist/types/src/hooks/useRefQueryLookupHandler.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +5 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/vitest-setup.d.ts +2 -0
- package/dist/types/src/vitest-setup.d.ts.map +1 -0
- package/package.json +27 -25
- package/src/components/ControlSection/ControlSection.tsx +2 -2
- package/src/components/FieldEditor/FieldEditor.test.tsx +49 -0
- package/src/components/FieldEditor/FieldEditor.tsx +3 -2
- package/src/components/Form/ArrayField.tsx +51 -34
- package/src/components/Form/Defaults.tsx +74 -48
- package/src/components/Form/Form.stories.tsx +77 -101
- package/src/components/Form/Form.tsx +1 -2
- package/src/components/Form/FormActions.tsx +15 -18
- package/src/components/Form/FormContent.tsx +34 -35
- package/src/components/Form/FormContext.tsx +11 -7
- package/src/components/Form/Input.tsx +1 -1
- package/src/components/Form/RefField.tsx +30 -10
- package/src/components/ViewEditor/ViewEditor.stories.tsx +14 -5
- package/src/components/ViewEditor/ViewEditor.tsx +51 -24
- package/src/components/testing.tsx +5 -9
- package/src/hooks/useRefQueryLookupHandler.ts +1 -3
- package/src/translations.ts +9 -2
- package/src/vitest-setup.ts +11 -0
package/dist/lib/node/index.cjs
CHANGED
|
@@ -69,41 +69,51 @@ __export(node_exports, {
|
|
|
69
69
|
useRefQueryLookupHandler: () => useRefQueryLookupHandler
|
|
70
70
|
});
|
|
71
71
|
module.exports = __toCommonJS(node_exports);
|
|
72
|
+
var import_tracking = require("@preact-signals/safe-react/tracking");
|
|
72
73
|
var import_react = __toESM(require("react"));
|
|
73
74
|
var import_react_ui = require("@dxos/react-ui");
|
|
74
75
|
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
76
|
+
var import_tracking2 = require("@preact-signals/safe-react/tracking");
|
|
75
77
|
var import_react2 = __toESM(require("react"));
|
|
76
78
|
var import_react_ui2 = require("@dxos/react-ui");
|
|
77
79
|
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
80
|
+
var import_tracking3 = require("@preact-signals/safe-react/tracking");
|
|
78
81
|
var import_react3 = __toESM(require("react"));
|
|
79
82
|
var import_echo_schema = require("@dxos/echo-schema");
|
|
80
83
|
var import_log = require("@dxos/log");
|
|
81
84
|
var import_react_ui3 = require("@dxos/react-ui");
|
|
82
85
|
var import_schema = require("@dxos/schema");
|
|
86
|
+
var import_tracking4 = require("@preact-signals/safe-react/tracking");
|
|
83
87
|
var import_react4 = __toESM(require("react"));
|
|
84
88
|
var import_echo_schema2 = require("@dxos/echo-schema");
|
|
85
89
|
var import_react_ui4 = require("@dxos/react-ui");
|
|
86
90
|
var import_util = require("@dxos/util");
|
|
91
|
+
var import_tracking5 = require("@preact-signals/safe-react/tracking");
|
|
87
92
|
var import_react5 = __toESM(require("react"));
|
|
88
93
|
var import_react_ui5 = require("@dxos/react-ui");
|
|
89
94
|
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
95
|
+
var import_tracking6 = require("@preact-signals/safe-react/tracking");
|
|
90
96
|
var import_react6 = __toESM(require("react"));
|
|
91
97
|
var import_keys = require("@dxos/keys");
|
|
92
98
|
var import_react_ui6 = require("@dxos/react-ui");
|
|
93
99
|
var import_react_ui_list = require("@dxos/react-ui-list");
|
|
94
100
|
var import_react_ui_pickers = require("@dxos/react-ui-pickers");
|
|
95
101
|
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
102
|
+
var import_tracking7 = require("@preact-signals/safe-react/tracking");
|
|
96
103
|
var import_react7 = __toESM(require("react"));
|
|
97
104
|
var import_react_ui7 = require("@dxos/react-ui");
|
|
98
105
|
var import_react_ui_theme5 = require("@dxos/react-ui-theme");
|
|
99
106
|
var import_util2 = require("@dxos/util");
|
|
107
|
+
var import_tracking8 = require("@preact-signals/safe-react/tracking");
|
|
100
108
|
var import_react8 = __toESM(require("react"));
|
|
101
109
|
var import_react_ui8 = require("@dxos/react-ui");
|
|
110
|
+
var import_tracking9 = require("@preact-signals/safe-react/tracking");
|
|
102
111
|
var import_react9 = __toESM(require("react"));
|
|
103
112
|
var import_react_ui_theme6 = require("@dxos/react-ui-theme");
|
|
113
|
+
var import_tracking10 = require("@preact-signals/safe-react/tracking");
|
|
104
114
|
var import_react10 = __toESM(require("react"));
|
|
105
115
|
var import_react_ui9 = require("@dxos/react-ui");
|
|
106
|
-
var
|
|
116
|
+
var import_tracking11 = require("@preact-signals/safe-react/tracking");
|
|
107
117
|
var import_react11 = __toESM(require("react"));
|
|
108
118
|
var import_debug = require("@dxos/debug");
|
|
109
119
|
var import_echo_schema3 = require("@dxos/echo-schema");
|
|
@@ -121,20 +131,21 @@ var import_echo = require("@dxos/react-client/echo");
|
|
|
121
131
|
var import_util3 = require("@dxos/util");
|
|
122
132
|
var import_react14 = require("react");
|
|
123
133
|
var import_log3 = require("@dxos/log");
|
|
134
|
+
var import_tracking12 = require("@preact-signals/safe-react/tracking");
|
|
124
135
|
var import_effect4 = require("effect");
|
|
125
136
|
var import_String = require("effect/String");
|
|
126
137
|
var import_react15 = __toESM(require("react"));
|
|
127
138
|
var import_effect5 = require("@dxos/effect");
|
|
128
|
-
var
|
|
139
|
+
var import_react_ui_theme7 = require("@dxos/react-ui-theme");
|
|
129
140
|
var import_schema3 = require("@dxos/schema");
|
|
130
141
|
var import_util4 = require("@dxos/util");
|
|
142
|
+
var import_tracking13 = require("@preact-signals/safe-react/tracking");
|
|
131
143
|
var import_effect6 = require("effect");
|
|
132
144
|
var import_String2 = require("effect/String");
|
|
133
145
|
var import_react16 = __toESM(require("react"));
|
|
134
146
|
var import_effect7 = require("@dxos/effect");
|
|
135
147
|
var import_invariant2 = require("@dxos/invariant");
|
|
136
148
|
var import_react_ui10 = require("@dxos/react-ui");
|
|
137
|
-
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
138
149
|
var import_schema4 = require("@dxos/schema");
|
|
139
150
|
var import_echo_schema6 = require("@dxos/echo-schema");
|
|
140
151
|
var import_format = require("date-fns/format");
|
|
@@ -143,21 +154,25 @@ var import_echo_schema8 = require("@dxos/echo-schema");
|
|
|
143
154
|
var import_effect8 = require("@dxos/effect");
|
|
144
155
|
var import_effect9 = require("effect");
|
|
145
156
|
var import_effect10 = require("@dxos/effect");
|
|
157
|
+
var import_tracking14 = require("@preact-signals/safe-react/tracking");
|
|
146
158
|
var import_react17 = __toESM(require("react"));
|
|
147
159
|
var import_echo_schema9 = require("@dxos/echo-schema");
|
|
148
160
|
var import_effect11 = require("@dxos/effect");
|
|
149
161
|
var import_keys2 = require("@dxos/keys");
|
|
162
|
+
var import_react18 = require("@dxos/lit-ui/react");
|
|
150
163
|
var import_react_ui11 = require("@dxos/react-ui");
|
|
151
164
|
var import_react_ui_tag_picker = require("@dxos/react-ui-tag-picker");
|
|
165
|
+
var import_react_ui_theme8 = require("@dxos/react-ui-theme");
|
|
152
166
|
var import_util5 = require("@dxos/util");
|
|
153
167
|
var import_echo_schema10 = require("@dxos/echo-schema");
|
|
168
|
+
var import_tracking15 = require("@preact-signals/safe-react/tracking");
|
|
154
169
|
var import_effect12 = require("effect");
|
|
155
|
-
var
|
|
170
|
+
var import_react19 = __toESM(require("react"));
|
|
156
171
|
var import_echo_schema11 = require("@dxos/echo-schema");
|
|
157
172
|
var import_invariant3 = require("@dxos/invariant");
|
|
158
173
|
var import_react_ui12 = require("@dxos/react-ui");
|
|
159
174
|
var import_react_ui_list2 = require("@dxos/react-ui-list");
|
|
160
|
-
var
|
|
175
|
+
var import_react_ui_theme9 = require("@dxos/react-ui-theme");
|
|
161
176
|
var import_schema5 = require("@dxos/schema");
|
|
162
177
|
var translationKey = "react-ui-form";
|
|
163
178
|
var translations_default = [
|
|
@@ -166,6 +181,7 @@ var translations_default = [
|
|
|
166
181
|
[translationKey]: {
|
|
167
182
|
"fields label": "Fields",
|
|
168
183
|
"hidden fields label": "Hidden Fields",
|
|
184
|
+
"empty readonly ref field label": "(none)",
|
|
169
185
|
// TODO(burdon): Standardize field/property.
|
|
170
186
|
"button add property": "Add property",
|
|
171
187
|
"field property label": "Property",
|
|
@@ -175,6 +191,8 @@ var translations_default = [
|
|
|
175
191
|
"add field": "Add field",
|
|
176
192
|
"delete field": "Delete field",
|
|
177
193
|
"field limit reached": "Maximum number of fields reached",
|
|
194
|
+
"boolean input true value": "Yes",
|
|
195
|
+
"boolean input false value": "No",
|
|
178
196
|
// TODO(burdon): Factor out?
|
|
179
197
|
"button cancel": "Cancel",
|
|
180
198
|
"button save": "Save",
|
|
@@ -204,389 +222,466 @@ var translations_default = [
|
|
|
204
222
|
"format number": "Number",
|
|
205
223
|
"format uri": "URI",
|
|
206
224
|
"format uuid": "UUID",
|
|
207
|
-
// Placeholders
|
|
225
|
+
// Placeholders.
|
|
208
226
|
"placeholder latitude": "Latitude",
|
|
209
227
|
"placeholder longitude": "Longitude",
|
|
210
|
-
// SelectOptionsInput
|
|
228
|
+
// SelectOptionsInput.
|
|
211
229
|
"select option label": "Label",
|
|
212
230
|
"select option label placeholder": "Option label",
|
|
213
231
|
"select option color": "Color",
|
|
214
232
|
"select option delete": "Delete",
|
|
215
|
-
"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."
|
|
216
237
|
}
|
|
217
238
|
}
|
|
218
239
|
}
|
|
219
240
|
];
|
|
220
241
|
var DeprecatedFormContainer = ({ children, classNames }) => {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
+
}
|
|
228
254
|
};
|
|
229
255
|
var DeprecatedFormInput = ({ label, description, secondary, children }) => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
role: "none",
|
|
247
|
-
className: "flex min-bs-[--rail-action] items-center"
|
|
248
|
-
}, children))));
|
|
249
|
-
if (secondary) {
|
|
250
|
-
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", {
|
|
251
272
|
role: "none"
|
|
252
|
-
},
|
|
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();
|
|
253
285
|
}
|
|
254
|
-
return primary;
|
|
255
286
|
};
|
|
256
287
|
var ControlPage = ({ children, classNames, ...props }) => {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
+
}
|
|
262
298
|
};
|
|
263
299
|
var ControlSection = ({ title, description, children }) => {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
+
}
|
|
268
309
|
};
|
|
269
310
|
var ControlSectionHeading = ({ title, description }) => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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
|
+
}
|
|
276
322
|
};
|
|
277
323
|
var ControlGroupButton = ({ classNames, ...props }) => {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
classNames
|
|
283
|
-
|
|
284
|
-
|
|
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
|
+
}
|
|
285
358
|
};
|
|
286
|
-
var
|
|
287
|
-
|
|
288
|
-
className: (0, import_react_ui_theme2.mx)("group container-max-width grid grid-cols-1 md:grid-cols-[1fr_min-content] gap-4", classNames)
|
|
289
|
-
}, children);
|
|
290
|
-
var ControlFrame = ({ children }) => /* @__PURE__ */ import_react2.default.createElement("div", {
|
|
291
|
-
role: "none",
|
|
292
|
-
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"
|
|
293
|
-
}, children);
|
|
294
|
-
var controlItemClasses = "p-4 border border-separator rounded-lg container-max-width grid md:col-span-2 grid-cols-subgrid items-center";
|
|
295
|
-
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";
|
|
296
361
|
var controlItemDescriptionClasses = "text-base mlb-2 md:mbe-0 text-description";
|
|
297
362
|
var ControlItem = ({ title, description, children }) => {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
+
}
|
|
308
378
|
};
|
|
309
379
|
var ControlItemInput = ({ title, description, children }) => {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
+
}
|
|
320
395
|
};
|
|
321
396
|
var ControlFrameItem = ({ title, description, children }) => {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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
|
+
}
|
|
331
411
|
};
|
|
332
412
|
var InputHeader = ({ children, error }) => {
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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
|
+
}
|
|
345
430
|
};
|
|
346
431
|
var GeoPointInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
0
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
setText(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
if (
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
+
}
|
|
383
471
|
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
}
|
|
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
|
+
}
|
|
414
504
|
};
|
|
415
505
|
var SelectOptionInput = ({ type, label, disabled, getStatus, getValue: getValue3, onValueChange }) => {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
const
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
const newId = import_keys.PublicKey.random().truncate();
|
|
443
|
-
const newOption = {
|
|
444
|
-
id: newId,
|
|
445
|
-
title: "",
|
|
446
|
-
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)];
|
|
447
532
|
};
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
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
|
|
451
550
|
]);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
options,
|
|
456
|
-
type,
|
|
457
|
-
onValueChange
|
|
458
|
-
]);
|
|
459
|
-
const handleDelete = (0, import_react6.useCallback)((id) => {
|
|
460
|
-
const newOptions = options?.filter((option) => option.id !== id) ?? [];
|
|
461
|
-
onValueChange(type, newOptions);
|
|
462
|
-
setSelectedId(null);
|
|
463
|
-
}, [
|
|
464
|
-
options,
|
|
465
|
-
type,
|
|
466
|
-
onValueChange
|
|
467
|
-
]);
|
|
468
|
-
const handleMove = (0, import_react6.useCallback)((from, to) => {
|
|
469
|
-
if (!options) {
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
const newOptions = [
|
|
473
|
-
...options
|
|
474
|
-
];
|
|
475
|
-
const [removed] = newOptions.splice(from, 1);
|
|
476
|
-
newOptions.splice(to, 0, removed);
|
|
477
|
-
onValueChange(type, newOptions);
|
|
478
|
-
}, [
|
|
479
|
-
options,
|
|
480
|
-
type,
|
|
481
|
-
onValueChange
|
|
482
|
-
]);
|
|
483
|
-
const handleClick = (0, import_react6.useCallback)((id) => {
|
|
484
|
-
setSelectedId((current) => current === id ? null : id);
|
|
485
|
-
}, []);
|
|
486
|
-
const handleTitleChange = (0, import_react6.useCallback)((id) => (e) => {
|
|
487
|
-
const newOptions = options?.map((o) => o.id === id ? {
|
|
488
|
-
...o,
|
|
489
|
-
title: e.target.value
|
|
490
|
-
} : o);
|
|
491
|
-
onValueChange(type, newOptions ?? []);
|
|
492
|
-
}, [
|
|
493
|
-
options,
|
|
494
|
-
type,
|
|
495
|
-
onValueChange
|
|
496
|
-
]);
|
|
497
|
-
const handleKeyDown = (0, import_react6.useCallback)((e) => {
|
|
498
|
-
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);
|
|
499
554
|
setSelectedId(null);
|
|
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
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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
|
+
}
|
|
590
685
|
};
|
|
591
686
|
var gridCols = [
|
|
592
687
|
"grid-cols-1",
|
|
@@ -595,131 +690,162 @@ var gridCols = [
|
|
|
595
690
|
"grid-cols-4"
|
|
596
691
|
];
|
|
597
692
|
var TupleInput = ({ binding, type, label, disabled, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
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
|
+
}
|
|
617
717
|
};
|
|
618
718
|
var TextInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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
|
+
}
|
|
631
736
|
};
|
|
632
737
|
var NumberInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
disabled,
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
+
}
|
|
646
756
|
};
|
|
647
|
-
var BooleanInput = ({ type, label, inputOnly, getStatus, getValue: getValue3, onValueChange }) => {
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
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
|
+
}
|
|
658
774
|
};
|
|
659
775
|
var SelectInput = ({ type, label, inputOnly, disabled, placeholder, options, getStatus, getValue: getValue3, onValueChange }) => {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
onValueChange
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
/* @__PURE__ */ import_react8.default.createElement(import_react_ui8.Select.
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
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
|
+
}
|
|
684
805
|
};
|
|
685
806
|
var MarkdownInput = ({ type, label, inputOnly, disabled, placeholder, getStatus, getValue: getValue3, onValueChange, onBlur }) => {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
textarea
|
|
692
|
-
textarea
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
disabled,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
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
|
+
}
|
|
723
849
|
};
|
|
724
850
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useForm.ts";
|
|
725
851
|
var useForm = ({ schema, initialValues, onValuesChanged, onValidate, onValid, onSave }) => {
|
|
@@ -922,7 +1048,7 @@ var flatMap = (errors) => {
|
|
|
922
1048
|
}, {});
|
|
923
1049
|
};
|
|
924
1050
|
var useRefQueryLookupHandler = ({ space }) => {
|
|
925
|
-
|
|
1051
|
+
return (0, import_react13.useCallback)(async (typeInfo) => {
|
|
926
1052
|
if (!space) {
|
|
927
1053
|
return [];
|
|
928
1054
|
}
|
|
@@ -942,7 +1068,6 @@ var useRefQueryLookupHandler = ({ space }) => {
|
|
|
942
1068
|
}, [
|
|
943
1069
|
space
|
|
944
1070
|
]);
|
|
945
|
-
return handleRefQueryLookup;
|
|
946
1071
|
};
|
|
947
1072
|
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/hooks/useQueryRefOptions.ts";
|
|
948
1073
|
var useQueryRefOptions = ({ refTypeInfo, onQueryRefOptions }) => {
|
|
@@ -1014,12 +1139,10 @@ var useInputProps = (path = []) => {
|
|
|
1014
1139
|
]);
|
|
1015
1140
|
};
|
|
1016
1141
|
var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
}
|
|
1022
|
-
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) => {
|
|
1023
1146
|
const keyIsEnter = event.key === "Enter";
|
|
1024
1147
|
const modifierUsed = event.ctrlKey || event.altKey || event.metaKey || event.shiftKey;
|
|
1025
1148
|
const inputIsTextarea = event.target.tagName.toLowerCase() === "textarea";
|
|
@@ -1034,43 +1157,55 @@ var FormProvider = ({ children, formRef, autoSave, ...formOptions }) => {
|
|
|
1034
1157
|
event.target.blur();
|
|
1035
1158
|
}
|
|
1036
1159
|
}
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1160
|
+
}, [
|
|
1161
|
+
form,
|
|
1162
|
+
autoSave
|
|
1163
|
+
]);
|
|
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();
|
|
1183
|
+
}
|
|
1051
1184
|
};
|
|
1052
|
-
var FormActions = ({
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}
|
|
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();
|
|
1208
|
+
}
|
|
1074
1209
|
};
|
|
1075
1210
|
var parseValue = ({ type, format, value }) => {
|
|
1076
1211
|
if (value === void 0 || value === null || value === "") {
|
|
@@ -1363,229 +1498,250 @@ var getRefProps = (property) => {
|
|
|
1363
1498
|
return void 0;
|
|
1364
1499
|
};
|
|
1365
1500
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/Form/ArrayField.tsx";
|
|
1366
|
-
var padding = "px-2";
|
|
1367
1501
|
var ArrayField = ({ property, readonly, path, inputProps, Custom, lookupComponent }) => {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
const
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
prop
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
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
|
|
1398
1540
|
]);
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
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();
|
|
1415
1590
|
}
|
|
1416
|
-
return /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1417
|
-
role: "none",
|
|
1418
|
-
className: (0, import_react_ui_theme9.mx)(padding)
|
|
1419
|
-
}, /* @__PURE__ */ import_react16.default.createElement(InputHeader, null, label), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1420
|
-
role: "none",
|
|
1421
|
-
className: "flex flex-col gap-1"
|
|
1422
|
-
}, values.map((_value, index) => /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1423
|
-
key: index,
|
|
1424
|
-
role: "none",
|
|
1425
|
-
className: "flex items-center gap-1"
|
|
1426
|
-
}, /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1427
|
-
role: "none",
|
|
1428
|
-
className: "flex-1"
|
|
1429
|
-
}, /* @__PURE__ */ import_react16.default.createElement(FormField, {
|
|
1430
|
-
property: {
|
|
1431
|
-
...property,
|
|
1432
|
-
array: false,
|
|
1433
|
-
ast: elementType
|
|
1434
|
-
},
|
|
1435
|
-
path: [
|
|
1436
|
-
...path ?? [],
|
|
1437
|
-
index
|
|
1438
|
-
],
|
|
1439
|
-
readonly,
|
|
1440
|
-
inline: true,
|
|
1441
|
-
Custom,
|
|
1442
|
-
lookupComponent
|
|
1443
|
-
})), /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
|
|
1444
|
-
icon: "ph--trash--regular",
|
|
1445
|
-
iconOnly: true,
|
|
1446
|
-
label: t("button remove"),
|
|
1447
|
-
onClick: () => handleRemove(index)
|
|
1448
|
-
})))), /* @__PURE__ */ import_react16.default.createElement("div", {
|
|
1449
|
-
role: "none",
|
|
1450
|
-
className: "flex justify-between items-center plb-1"
|
|
1451
|
-
}, /* @__PURE__ */ import_react16.default.createElement(import_react_ui10.IconButton, {
|
|
1452
|
-
icon: "ph--plus--regular",
|
|
1453
|
-
iconOnly: true,
|
|
1454
|
-
label: t("button add"),
|
|
1455
|
-
onClick: handleAdd
|
|
1456
|
-
})));
|
|
1457
1591
|
};
|
|
1458
1592
|
var RefField = ({ type, label, disabled, placeholder, inputOnly, array, ast, getValue: getValue3, onBlur, onQueryRefOptions, onValueChange, ...restInputProps }) => {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
type,
|
|
1469
|
-
label,
|
|
1470
|
-
placeholder,
|
|
1471
|
-
disabled,
|
|
1472
|
-
inputOnly,
|
|
1473
|
-
getValue: getValue3,
|
|
1474
|
-
onBlur,
|
|
1475
|
-
onValueChange,
|
|
1476
|
-
...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
|
|
1477
1602
|
});
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
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
|
+
}
|
|
1487
1625
|
}
|
|
1626
|
+
return void 0;
|
|
1627
|
+
};
|
|
1628
|
+
if (array && Array.isArray(formValue)) {
|
|
1629
|
+
return formValue.map(unknownToRefOption).filter(import_util5.isNonNullable) ?? [];
|
|
1488
1630
|
}
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
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]);
|
|
1523
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) {
|
|
1524
1677
|
return null;
|
|
1525
|
-
}).filter(import_util5.isNonNullable);
|
|
1526
|
-
if (array) {
|
|
1527
|
-
onValueChange("object", refs);
|
|
1528
|
-
} else {
|
|
1529
|
-
onValueChange("object", refs[0]);
|
|
1530
1678
|
}
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
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();
|
|
1541
1707
|
}
|
|
1542
|
-
const { status, error } = restInputProps.getStatus();
|
|
1543
|
-
return /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Root, {
|
|
1544
|
-
validationValence: status
|
|
1545
|
-
}, !inputOnly && /* @__PURE__ */ import_react17.default.createElement(InputHeader, {
|
|
1546
|
-
error
|
|
1547
|
-
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.Label, null, label)), /* @__PURE__ */ import_react17.default.createElement("div", {
|
|
1548
|
-
"data-no-submit": true
|
|
1549
|
-
}, /* @__PURE__ */ import_react17.default.createElement(import_react_ui_tag_picker.TagPicker, {
|
|
1550
|
-
items: handleGetValue(),
|
|
1551
|
-
mode: tagPickerMode,
|
|
1552
|
-
onBlur: (event) => onBlur(event),
|
|
1553
|
-
onUpdate: handleUpdate,
|
|
1554
|
-
onSearch: handleSearch,
|
|
1555
|
-
classNames: "rounded-sm bg-input p-1.5"
|
|
1556
|
-
})), inputOnly && /* @__PURE__ */ import_react17.default.createElement(import_react_ui11.Input.DescriptionAndValidation, null, error));
|
|
1557
1708
|
};
|
|
1558
1709
|
var RefFieldFallback = ({ type, label, disabled, placeholder, inputOnly, getValue: getValue3, onValueChange, ...restInputProps }) => {
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
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
|
+
}
|
|
1589
1745
|
};
|
|
1590
1746
|
var getInputComponent = (type, format) => {
|
|
1591
1747
|
switch (format) {
|
|
@@ -1604,556 +1760,600 @@ var getInputComponent = (type, format) => {
|
|
|
1604
1760
|
}
|
|
1605
1761
|
};
|
|
1606
1762
|
var FormField = ({ property, path, readonly, inline, onQueryRefOptions, lookupComponent, Custom }) => {
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
title,
|
|
1611
|
-
name
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
description
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1631
|
-
role: "none"
|
|
1632
|
-
}, FoundComponent);
|
|
1633
|
-
}
|
|
1634
|
-
const jsonPath = (0, import_effect5.createJsonPath)(path ?? []);
|
|
1635
|
-
const CustomComponent = Custom?.[jsonPath];
|
|
1636
|
-
if (CustomComponent) {
|
|
1637
|
-
return /* @__PURE__ */ import_react15.default.createElement(CustomComponent, {
|
|
1638
|
-
type,
|
|
1639
|
-
format,
|
|
1640
|
-
label,
|
|
1641
|
-
inputOnly: inline,
|
|
1642
|
-
placeholder,
|
|
1643
|
-
disabled: readonly,
|
|
1644
|
-
...inputProps
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
const refProps = getRefProps(property);
|
|
1648
|
-
if (refProps) {
|
|
1649
|
-
return /* @__PURE__ */ import_react15.default.createElement(RefField, {
|
|
1650
|
-
ast: refProps.ast,
|
|
1651
|
-
array: refProps.isArray,
|
|
1652
|
-
type,
|
|
1653
|
-
format,
|
|
1654
|
-
label,
|
|
1655
|
-
placeholder,
|
|
1656
|
-
disabled: readonly,
|
|
1657
|
-
inputOnly: inline,
|
|
1658
|
-
onQueryRefOptions,
|
|
1659
|
-
...inputProps
|
|
1660
|
-
});
|
|
1661
|
-
}
|
|
1662
|
-
if (array) {
|
|
1663
|
-
return /* @__PURE__ */ import_react15.default.createElement(ArrayField, {
|
|
1664
|
-
property,
|
|
1665
|
-
path,
|
|
1666
|
-
inputProps,
|
|
1667
|
-
readonly,
|
|
1668
|
-
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
|
+
}
|
|
1669
1786
|
});
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
const typeLiteral = baseNode ? (0, import_effect5.getDiscriminatedType)(baseNode, inputProps.getValue()) : (0, import_effect5.findNode)(ast, import_effect4.SchemaAST.isTypeLiteral);
|
|
1705
|
-
if (typeLiteral) {
|
|
1706
|
-
return /* @__PURE__ */ import_react15.default.createElement("div", {
|
|
1707
|
-
role: "none"
|
|
1708
|
-
}, !inline && /* @__PURE__ */ import_react15.default.createElement("h3", {
|
|
1709
|
-
className: "text-lg mbs-2 mbe-1"
|
|
1710
|
-
}, label), /* @__PURE__ */ import_react15.default.createElement(FormFields, {
|
|
1711
|
-
schema: import_effect4.Schema.make(typeLiteral),
|
|
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,
|
|
1712
1821
|
path,
|
|
1822
|
+
inputProps,
|
|
1713
1823
|
readonly,
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
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
|
+
});
|
|
1718
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();
|
|
1719
1873
|
}
|
|
1720
|
-
return null;
|
|
1721
1874
|
};
|
|
1722
|
-
var FormFields = ({ schema, path, filter, sort, readonly,
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
const
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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,
|
|
1745
1948
|
readonly,
|
|
1949
|
+
filter,
|
|
1950
|
+
sort,
|
|
1746
1951
|
onQueryRefOptions,
|
|
1747
1952
|
lookupComponent,
|
|
1748
1953
|
Custom
|
|
1749
|
-
})
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
onSave
|
|
1757
|
-
]);
|
|
1758
|
-
(0, import_react9.useEffect)(() => {
|
|
1759
|
-
if (autoFocus && formRef.current) {
|
|
1760
|
-
const input = formRef.current.querySelector("input");
|
|
1761
|
-
if (input) {
|
|
1762
|
-
input.focus();
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
}, [
|
|
1766
|
-
autoFocus
|
|
1767
|
-
]);
|
|
1768
|
-
return /* @__PURE__ */ import_react9.default.createElement(FormProvider, {
|
|
1769
|
-
formRef,
|
|
1770
|
-
schema,
|
|
1771
|
-
autoSave,
|
|
1772
|
-
initialValues,
|
|
1773
|
-
onValuesChanged,
|
|
1774
|
-
onValidate,
|
|
1775
|
-
onValid,
|
|
1776
|
-
onSave
|
|
1777
|
-
}, /* @__PURE__ */ import_react9.default.createElement("div", {
|
|
1778
|
-
ref: formRef,
|
|
1779
|
-
role: "none",
|
|
1780
|
-
className: (0, import_react_ui_theme6.mx)("p-2", classNames),
|
|
1781
|
-
"data-testid": testId
|
|
1782
|
-
}, /* @__PURE__ */ import_react9.default.createElement(FormFields, {
|
|
1783
|
-
schema,
|
|
1784
|
-
path,
|
|
1785
|
-
readonly,
|
|
1786
|
-
filter,
|
|
1787
|
-
sort,
|
|
1788
|
-
onQueryRefOptions,
|
|
1789
|
-
lookupComponent,
|
|
1790
|
-
Custom
|
|
1791
|
-
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
1792
|
-
onCancel,
|
|
1793
|
-
readonly
|
|
1794
|
-
})));
|
|
1954
|
+
}), (onCancel || onSave) && !autoSave && /* @__PURE__ */ import_react9.default.createElement(FormActions, {
|
|
1955
|
+
onCancel,
|
|
1956
|
+
readonly
|
|
1957
|
+
})));
|
|
1958
|
+
} finally {
|
|
1959
|
+
_effect.f();
|
|
1960
|
+
}
|
|
1795
1961
|
};
|
|
1796
1962
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/FieldEditor/FieldEditor.tsx";
|
|
1797
1963
|
var FieldEditor = ({ view, projection, field, registry, onSave, onCancel }) => {
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
field
|
|
1802
|
-
projection
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
fire: true
|
|
1811
|
-
});
|
|
1812
|
-
const t2 = setTimeout(async () => {
|
|
1813
|
-
const schemas2 = await registry.query().run();
|
|
1814
|
-
setSchemas(schemas2);
|
|
1815
|
-
});
|
|
1816
|
-
return () => {
|
|
1817
|
-
clearTimeout(t2);
|
|
1818
|
-
subscription?.();
|
|
1819
|
-
};
|
|
1820
|
-
}, [
|
|
1821
|
-
registry
|
|
1822
|
-
]);
|
|
1823
|
-
const [referenceSchema, setReferenceSchema] = (0, import_react3.useState)();
|
|
1824
|
-
(0, import_react3.useEffect)(() => {
|
|
1825
|
-
setReferenceSchema(schemas.find((schema) => schema.typename === props?.referenceSchema));
|
|
1826
|
-
}, [
|
|
1827
|
-
schemas,
|
|
1828
|
-
props?.referenceSchema
|
|
1829
|
-
]);
|
|
1830
|
-
const [{ fieldSchema }, setFieldSchema] = (0, import_react3.useState)({
|
|
1831
|
-
fieldSchema: (0, import_schema.getFormatSchema)(props?.format)
|
|
1832
|
-
});
|
|
1833
|
-
const handleValuesChanged = (0, import_react3.useCallback)((_props) => {
|
|
1834
|
-
setFieldSchema((prev) => {
|
|
1835
|
-
const fieldSchema2 = (0, import_schema.getFormatSchema)(_props.format);
|
|
1836
|
-
if (prev.fieldSchema === fieldSchema2) {
|
|
1837
|
-
return prev;
|
|
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;
|
|
1838
1976
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
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?.();
|
|
1841
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)
|
|
1842
2000
|
});
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
const
|
|
1846
|
-
if (
|
|
1847
|
-
return
|
|
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;
|
|
1848
2006
|
}
|
|
1849
|
-
}
|
|
1850
|
-
return prev;
|
|
1851
|
-
});
|
|
1852
|
-
setProps((props2) => {
|
|
1853
|
-
const type = import_echo_schema.formatToType[_props.format];
|
|
1854
|
-
if (props2.type !== type) {
|
|
1855
2007
|
return {
|
|
1856
|
-
|
|
1857
|
-
..._props,
|
|
1858
|
-
type
|
|
2008
|
+
fieldSchema: fieldSchema2
|
|
1859
2009
|
};
|
|
1860
|
-
}
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
]);
|
|
1868
|
-
const handleValidate = (0, import_react3.useCallback)(({ property }) => {
|
|
1869
|
-
if (property && view.fields.find((f) => f.path === property && f.path !== field.path)) {
|
|
1870
|
-
return [
|
|
1871
|
-
{
|
|
1872
|
-
path: "property",
|
|
1873
|
-
message: `property is not unique: '${property}'`
|
|
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
|
+
}
|
|
1874
2017
|
}
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
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,
|
|
1883
2057
|
field,
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
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
|
|
1933
2119
|
});
|
|
1934
|
-
|
|
2120
|
+
} finally {
|
|
2121
|
+
_effect.f();
|
|
1935
2122
|
}
|
|
1936
|
-
return /* @__PURE__ */ import_react3.default.createElement(Form, {
|
|
1937
|
-
key: field.id,
|
|
1938
|
-
autoFocus: true,
|
|
1939
|
-
values: props,
|
|
1940
|
-
schema: fieldSchema,
|
|
1941
|
-
filter: propIsNotType,
|
|
1942
|
-
sort: [
|
|
1943
|
-
"property",
|
|
1944
|
-
"format"
|
|
1945
|
-
],
|
|
1946
|
-
onValuesChanged: handleValuesChanged,
|
|
1947
|
-
onValidate: handleValidate,
|
|
1948
|
-
onSave: handleSave,
|
|
1949
|
-
onCancel: handleCancel,
|
|
1950
|
-
Custom
|
|
1951
|
-
});
|
|
1952
2123
|
};
|
|
1953
2124
|
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-form/src/components/ViewEditor/ViewEditor.tsx";
|
|
1954
2125
|
var grid = "grid grid-cols-[32px_1fr_32px] min-bs-[2.5rem]";
|
|
1955
2126
|
var ViewMetaSchema = import_effect12.Schema.Struct({
|
|
1956
2127
|
name: import_effect12.Schema.String.annotations({
|
|
1957
|
-
|
|
2128
|
+
title: "View"
|
|
1958
2129
|
}),
|
|
1959
2130
|
typename: import_echo_schema11.Format.URL.annotations({
|
|
1960
|
-
|
|
2131
|
+
title: "Typename"
|
|
1961
2132
|
})
|
|
1962
2133
|
}).pipe(import_effect12.Schema.mutable);
|
|
1963
2134
|
var ViewEditor = ({ classNames, schema, view, registry, readonly, showHeading = false, onTypenameChanged, onDelete }) => {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
A: [
|
|
1990
|
-
"!immutable",
|
|
1991
|
-
""
|
|
1992
|
-
]
|
|
1993
|
-
});
|
|
1994
|
-
const field2 = projection.createFieldProjection();
|
|
1995
|
-
setField(field2);
|
|
1996
|
-
}, [
|
|
1997
|
-
schema,
|
|
1998
|
-
view
|
|
1999
|
-
]);
|
|
2000
|
-
const handleUpdate = (0, import_react18.useCallback)(({ name, typename }) => {
|
|
2001
|
-
(0, import_invariant3.invariant)(!immutable, void 0, {
|
|
2002
|
-
F: __dxlog_file5,
|
|
2003
|
-
L: 85,
|
|
2004
|
-
S: void 0,
|
|
2005
|
-
A: [
|
|
2006
|
-
"!immutable",
|
|
2007
|
-
""
|
|
2008
|
-
]
|
|
2009
|
-
});
|
|
2010
|
-
requestAnimationFrame(() => {
|
|
2011
|
-
if (view.name !== name) {
|
|
2012
|
-
view.name = name;
|
|
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;
|
|
2013
2160
|
}
|
|
2014
|
-
|
|
2015
|
-
|
|
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);
|
|
2016
2217
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
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) => {
|
|
2034
2247
|
setField(void 0);
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
projection,
|
|
2145
|
-
field,
|
|
2146
|
-
registry,
|
|
2147
|
-
onSave: handleClose
|
|
2148
|
-
}), !readonly && !field && /* @__PURE__ */ import_react18.default.createElement("div", {
|
|
2149
|
-
className: "flex p-2 justify-center"
|
|
2150
|
-
}, /* @__PURE__ */ import_react18.default.createElement(import_react_ui12.IconButton, {
|
|
2151
|
-
icon: "ph--plus--regular",
|
|
2152
|
-
label: t("button add property"),
|
|
2153
|
-
onClick: immutable ? void 0 : handleAdd,
|
|
2154
|
-
// TODO(burdon): Show field limit in ux (not tooltip).
|
|
2155
|
-
disabled: view.fields.length >= import_schema5.VIEW_FIELD_LIMIT
|
|
2156
|
-
})));
|
|
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
|
+
}
|
|
2157
2357
|
};
|
|
2158
2358
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2159
2359
|
0 && (module.exports = {
|