@terreno/admin-frontend 0.13.3 → 0.14.1
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/AdminFieldRenderer.d.ts +5 -53
- package/dist/AdminFieldRenderer.js +6 -168
- package/dist/AdminFieldRenderer.js.map +1 -1
- package/dist/AdminFieldRendererCore.d.ts +26 -0
- package/dist/AdminFieldRendererCore.js +138 -0
- package/dist/AdminFieldRendererCore.js.map +1 -0
- package/dist/AdminModelForm.d.ts +6 -7
- package/dist/AdminModelForm.js.map +1 -1
- package/dist/AdminModelList.d.ts +2 -3
- package/dist/AdminModelList.js.map +1 -1
- package/dist/AdminModelTable.d.ts +2 -2
- package/dist/AdminModelTable.js +2 -1
- package/dist/AdminModelTable.js.map +1 -1
- package/dist/AdminNestedArrayField.d.ts +6 -7
- package/dist/AdminNestedArrayField.js +26 -2
- package/dist/AdminNestedArrayField.js.map +1 -1
- package/dist/AdminObjectPicker.d.ts +2 -2
- package/dist/AdminObjectPicker.js +13 -7
- package/dist/AdminObjectPicker.js.map +1 -1
- package/dist/AdminPrimitiveArrayField.d.ts +2 -3
- package/dist/AdminPrimitiveArrayField.js.map +1 -1
- package/dist/AdminScriptList.d.ts +2 -2
- package/dist/AdminScriptList.js.map +1 -1
- package/dist/AdminScriptRunModal.d.ts +2 -2
- package/dist/AdminScriptRunModal.js.map +1 -1
- package/dist/AdminVersionConfig.d.ts +2 -2
- package/dist/AdminVersionConfig.js +16 -10
- package/dist/AdminVersionConfig.js.map +1 -1
- package/dist/ConfigurationScreen.d.ts +2 -2
- package/dist/ConfigurationScreen.js +18 -9
- package/dist/ConfigurationScreen.js.map +1 -1
- package/dist/ConsentFormEditor.d.ts +27 -2
- package/dist/ConsentFormEditor.js +48 -32
- package/dist/ConsentFormEditor.js.map +1 -1
- package/dist/ConsentFormList.d.ts +2 -1
- package/dist/ConsentFormList.js.map +1 -1
- package/dist/ConsentResponseViewer.d.ts +2 -1
- package/dist/ConsentResponseViewer.js.map +1 -1
- package/dist/DocumentStorageBrowser.js.map +1 -1
- package/dist/types.d.ts +29 -4
- package/dist/types.js.map +1 -1
- package/dist/useAdminApi.d.ts +2 -2
- package/dist/useAdminApi.js +8 -5
- package/dist/useAdminApi.js.map +1 -1
- package/dist/useAdminConfig.d.ts +2 -3
- package/dist/useAdminConfig.js +2 -0
- package/dist/useAdminConfig.js.map +1 -1
- package/dist/useAdminScripts.d.ts +2 -3
- package/dist/useAdminScripts.js +6 -3
- package/dist/useAdminScripts.js.map +1 -1
- package/dist/useConfigurationApi.d.ts +11 -8
- package/dist/useConfigurationApi.js +7 -4
- package/dist/useConfigurationApi.js.map +1 -1
- package/dist/useDocumentStorageApi.d.ts +2 -2
- package/dist/useDocumentStorageApi.js +9 -6
- package/dist/useDocumentStorageApi.js.map +1 -1
- package/package.json +2 -2
- package/src/AdminFieldRenderer.test.tsx +48 -22
- package/src/AdminFieldRenderer.tsx +18 -371
- package/src/AdminFieldRendererCore.tsx +356 -0
- package/src/AdminModelForm.test.tsx +146 -40
- package/src/AdminModelForm.tsx +22 -17
- package/src/AdminModelList.test.tsx +14 -5
- package/src/AdminModelList.tsx +5 -5
- package/src/AdminModelTable.test.tsx +58 -31
- package/src/AdminModelTable.tsx +11 -10
- package/src/AdminNestedArrayField.tsx +91 -26
- package/src/AdminObjectPicker.tsx +33 -16
- package/src/AdminPrimitiveArrayField.test.tsx +14 -10
- package/src/AdminPrimitiveArrayField.tsx +2 -3
- package/src/AdminScriptList.test.tsx +7 -4
- package/src/AdminScriptList.tsx +2 -3
- package/src/AdminScriptRunModal.test.tsx +5 -2
- package/src/AdminScriptRunModal.tsx +2 -3
- package/src/AdminVersionConfig.test.tsx +47 -21
- package/src/AdminVersionConfig.tsx +29 -5
- package/src/CheckboxListEditor.test.tsx +9 -6
- package/src/ConfigurationScreen.test.tsx +16 -11
- package/src/ConfigurationScreen.tsx +43 -29
- package/src/ConsentFormEditor.test.tsx +95 -75
- package/src/ConsentFormEditor.tsx +76 -49
- package/src/ConsentFormList.test.tsx +28 -10
- package/src/ConsentFormList.tsx +14 -2
- package/src/ConsentResponseViewer.test.tsx +15 -12
- package/src/ConsentResponseViewer.tsx +3 -2
- package/src/DocumentStorageBrowser.test.tsx +69 -42
- package/src/DocumentStorageBrowser.tsx +4 -4
- package/src/LocaleContentEditor.test.tsx +28 -18
- package/src/isolated/AdminFieldRenderer.isolated.tsx +5 -2
- package/src/isolated/AdminNestedArrayField.isolated.tsx +49 -36
- package/src/isolated/AdminObjectPicker.isolated.tsx +31 -26
- package/src/isolated/AdminRefField.isolated.tsx +4 -1
- package/src/isolated/AdminScriptRunModal.isolated.tsx +24 -17
- package/src/isolated/DocumentStorageBrowser.isolated.tsx +80 -63
- package/src/isolated/hooks.isolated.tsx +40 -33
- package/src/types.ts +34 -4
- package/src/useAdminApi.ts +21 -13
- package/src/useAdminConfig.ts +5 -4
- package/src/useAdminScripts.ts +9 -7
- package/src/useConfigurationApi.ts +26 -12
- package/src/useDocumentStorageApi.ts +12 -9
|
@@ -1,96 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BooleanField,
|
|
3
|
-
DateTimeField,
|
|
4
|
-
MarkdownEditorField,
|
|
5
|
-
SelectField,
|
|
6
|
-
TextField,
|
|
7
|
-
} from "@terreno/ui";
|
|
8
1
|
import startCase from "lodash/startCase";
|
|
9
2
|
import React from "react";
|
|
3
|
+
import {AdminFieldRendererCore, type AdminFieldRendererCoreProps} from "./AdminFieldRendererCore";
|
|
10
4
|
import {AdminNestedArrayField} from "./AdminNestedArrayField";
|
|
11
|
-
import {
|
|
12
|
-
import {AdminRefField} from "./AdminRefField";
|
|
13
|
-
import {CheckboxListEditor} from "./CheckboxListEditor";
|
|
14
|
-
import {LocaleContentEditor} from "./LocaleContentEditor";
|
|
15
|
-
import type {AdminFieldConfig, AdminScreenProps, RefRendererMap} from "./types";
|
|
5
|
+
import type {AdminFieldValue} from "./types";
|
|
16
6
|
|
|
17
|
-
|
|
18
|
-
const parseJsonValue = (text: string): any => {
|
|
19
|
-
const trimmed = text.trim();
|
|
20
|
-
if (trimmed === "") {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(trimmed);
|
|
25
|
-
} catch {
|
|
26
|
-
return trimmed;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Serializes any value to a display string for the JSON editor
|
|
31
|
-
const serializeJsonValue = (val: any): string => {
|
|
32
|
-
if (val == null) {
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
if (typeof val === "string") {
|
|
36
|
-
return val;
|
|
37
|
-
}
|
|
38
|
-
return JSON.stringify(val, null, 2);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
interface AdminFieldRendererProps extends AdminScreenProps {
|
|
42
|
-
fieldKey: string;
|
|
43
|
-
fieldConfig: AdminFieldConfig;
|
|
44
|
-
value: any;
|
|
45
|
-
onChange: (value: any) => void;
|
|
46
|
-
errorText?: string;
|
|
47
|
-
modelConfigs?: Array<{name: string; routePath: string}>;
|
|
48
|
-
/** Parent document form state, used to derive dynamic options for sub-fields */
|
|
49
|
-
parentFormState?: Record<string, any>;
|
|
50
|
-
/**
|
|
51
|
-
* Optional map of custom ref-field renderers keyed by referenced model name.
|
|
52
|
-
* When `fieldConfig.ref` (single ref) or `fieldConfig.itemRef` (primitive array
|
|
53
|
-
* of refs) matches a key, the custom component renders in place of the built-in
|
|
54
|
-
* {@link AdminRefField}. Forwarded to {@link AdminNestedArrayField} and
|
|
55
|
-
* {@link AdminPrimitiveArrayField} so nested fields participate in the override.
|
|
56
|
-
*/
|
|
57
|
-
refRenderers?: RefRendererMap;
|
|
58
|
-
}
|
|
7
|
+
export type AdminFieldRendererProps = AdminFieldRendererCoreProps;
|
|
59
8
|
|
|
60
9
|
/**
|
|
61
10
|
* Renders an appropriate input field for a given model field in the admin form.
|
|
62
11
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* - `number` → TextField with number validation
|
|
66
|
-
* - `date`/`datetime` → DateTimeField
|
|
67
|
-
* - `enum` → SelectField with enum values as options
|
|
68
|
-
* - ObjectId with `ref` → AdminRefField (select from referenced model)
|
|
69
|
-
* - Default → TextField
|
|
70
|
-
*
|
|
71
|
-
* @param props - Component props
|
|
72
|
-
* @param props.fieldKey - The field key/name in the model
|
|
73
|
-
* @param props.fieldConfig - Field configuration metadata from backend
|
|
74
|
-
* @param props.value - Current field value
|
|
75
|
-
* @param props.onChange - Callback when field value changes
|
|
76
|
-
* @param props.errorText - Optional validation error message
|
|
77
|
-
* @param props.baseUrl - Base URL for admin routes
|
|
78
|
-
* @param props.api - RTK Query API instance
|
|
79
|
-
* @param props.modelConfigs - Available model configurations for reference field lookups
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```typescript
|
|
83
|
-
* <AdminFieldRenderer
|
|
84
|
-
* fieldKey="status"
|
|
85
|
-
* fieldConfig={{type: "string", required: true, enum: ["active", "inactive"]}}
|
|
86
|
-
* value={formState.status}
|
|
87
|
-
* onChange={(val) => setFormState({...formState, status: val})}
|
|
88
|
-
* baseUrl="/admin"
|
|
89
|
-
* api={api}
|
|
90
|
-
* />
|
|
91
|
-
* ```
|
|
12
|
+
* Delegates arrays of sub-documents to {@link AdminNestedArrayField}; all other
|
|
13
|
+
* field types are rendered by {@link AdminFieldRendererCore}.
|
|
92
14
|
*
|
|
93
|
-
* @see
|
|
15
|
+
* @see AdminFieldRendererCore for supported field type mappings
|
|
94
16
|
* @see AdminModelForm for form usage
|
|
95
17
|
*/
|
|
96
18
|
export const AdminFieldRenderer: React.FC<AdminFieldRendererProps> = ({
|
|
@@ -105,311 +27,36 @@ export const AdminFieldRenderer: React.FC<AdminFieldRendererProps> = ({
|
|
|
105
27
|
parentFormState,
|
|
106
28
|
refRenderers,
|
|
107
29
|
}) => {
|
|
108
|
-
const label = startCase(fieldKey);
|
|
109
|
-
const helperText = fieldConfig.description;
|
|
110
|
-
|
|
111
|
-
// Dynamic enum: look for a sibling array field whose items have a `key` property.
|
|
112
|
-
// E.g. sub-field "variant" → parent field "variants" → extract key values as options.
|
|
113
|
-
if (!fieldConfig.enum && parentFormState && fieldConfig.type === "string") {
|
|
114
|
-
const pluralKey = `${fieldKey}s`;
|
|
115
|
-
const siblingArray = parentFormState[pluralKey];
|
|
116
|
-
if (Array.isArray(siblingArray) && siblingArray.length > 0 && siblingArray[0]?.key != null) {
|
|
117
|
-
const dynamicOptions = siblingArray
|
|
118
|
-
.map((item: any) => item.key)
|
|
119
|
-
.filter(Boolean)
|
|
120
|
-
.map((k: string) => ({label: k, value: k}));
|
|
121
|
-
if (dynamicOptions.length > 0) {
|
|
122
|
-
return (
|
|
123
|
-
<SelectField
|
|
124
|
-
errorText={errorText}
|
|
125
|
-
helperText={helperText}
|
|
126
|
-
onChange={onChange}
|
|
127
|
-
options={dynamicOptions}
|
|
128
|
-
title={label}
|
|
129
|
-
value={value ?? ""}
|
|
130
|
-
/>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ObjectId with ref -> reference field (skip arrays — those go to AdminPrimitiveArrayField)
|
|
137
|
-
if (fieldConfig.ref && fieldConfig.type !== "array") {
|
|
138
|
-
const CustomRenderer = refRenderers?.[fieldConfig.ref];
|
|
139
|
-
const refModel = modelConfigs?.find((m) => m.name === fieldConfig.ref);
|
|
140
|
-
if (CustomRenderer) {
|
|
141
|
-
return (
|
|
142
|
-
<CustomRenderer
|
|
143
|
-
api={api}
|
|
144
|
-
baseUrl={baseUrl}
|
|
145
|
-
errorText={errorText}
|
|
146
|
-
helperText={helperText}
|
|
147
|
-
onChange={onChange}
|
|
148
|
-
refModelName={fieldConfig.ref}
|
|
149
|
-
routePath={refModel?.routePath ?? ""}
|
|
150
|
-
title={label}
|
|
151
|
-
value={value ?? ""}
|
|
152
|
-
/>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
if (refModel) {
|
|
156
|
-
return (
|
|
157
|
-
<AdminRefField
|
|
158
|
-
api={api}
|
|
159
|
-
baseUrl={baseUrl}
|
|
160
|
-
errorText={errorText}
|
|
161
|
-
helperText={helperText}
|
|
162
|
-
onChange={onChange}
|
|
163
|
-
refModelName={fieldConfig.ref}
|
|
164
|
-
routePath={refModel.routePath}
|
|
165
|
-
title={label}
|
|
166
|
-
value={value ?? ""}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Boolean
|
|
173
|
-
if (fieldConfig.type === "boolean") {
|
|
174
|
-
return (
|
|
175
|
-
<BooleanField
|
|
176
|
-
errorText={errorText}
|
|
177
|
-
helperText={helperText}
|
|
178
|
-
onChange={onChange}
|
|
179
|
-
title={label}
|
|
180
|
-
value={value ?? false}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// Enum -> SelectField
|
|
186
|
-
if (fieldConfig.enum && fieldConfig.enum.length > 0) {
|
|
187
|
-
const includesNullOption = fieldConfig.enum.some((value: any) => value == null);
|
|
188
|
-
const enumOptions = fieldConfig.enum
|
|
189
|
-
.filter((value: any): value is string => typeof value === "string")
|
|
190
|
-
.map((v: string) => ({label: startCase(v), value: v}));
|
|
191
|
-
const options = includesNullOption ? [{label: "None", value: ""}, ...enumOptions] : enumOptions;
|
|
192
|
-
return (
|
|
193
|
-
<SelectField
|
|
194
|
-
errorText={errorText}
|
|
195
|
-
helperText={helperText}
|
|
196
|
-
onChange={(nextValue: string) => onChange(nextValue === "" ? undefined : nextValue)}
|
|
197
|
-
options={options}
|
|
198
|
-
title={label}
|
|
199
|
-
value={value ?? ""}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
// Date/datetime
|
|
205
|
-
if (
|
|
206
|
-
fieldConfig.type === "date" ||
|
|
207
|
-
fieldConfig.type === "datetime" ||
|
|
208
|
-
(fieldConfig.type === "string" && fieldKey.toLowerCase().includes("date"))
|
|
209
|
-
) {
|
|
210
|
-
return (
|
|
211
|
-
<DateTimeField
|
|
212
|
-
errorText={errorText}
|
|
213
|
-
helperText={helperText}
|
|
214
|
-
onChange={onChange}
|
|
215
|
-
testID={`admin-field-${fieldKey}`}
|
|
216
|
-
title={label}
|
|
217
|
-
type="datetime"
|
|
218
|
-
value={value ?? ""}
|
|
219
|
-
/>
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Number
|
|
224
|
-
if (fieldConfig.type === "number") {
|
|
225
|
-
return (
|
|
226
|
-
<TextField
|
|
227
|
-
errorText={errorText}
|
|
228
|
-
helperText={helperText}
|
|
229
|
-
onChange={(text: string) => {
|
|
230
|
-
const num = Number(text);
|
|
231
|
-
onChange(Number.isNaN(num) ? text : num);
|
|
232
|
-
}}
|
|
233
|
-
testID={`admin-field-${fieldKey}`}
|
|
234
|
-
title={label}
|
|
235
|
-
value={value != null ? String(value) : ""}
|
|
236
|
-
/>
|
|
237
|
-
);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// Locale content widget (Map<locale, markdown>)
|
|
241
|
-
if (fieldConfig.widget === "locale-content") {
|
|
242
|
-
return (
|
|
243
|
-
<LocaleContentEditor
|
|
244
|
-
errorText={errorText}
|
|
245
|
-
helperText={helperText}
|
|
246
|
-
onChange={onChange}
|
|
247
|
-
title={label}
|
|
248
|
-
value={value ?? {}}
|
|
249
|
-
/>
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Locale default widget — dropdown populated from sibling content field's locale keys
|
|
254
|
-
if (fieldConfig.widget === "locale-default") {
|
|
255
|
-
const contentMap = parentFormState?.content;
|
|
256
|
-
const localeKeys =
|
|
257
|
-
contentMap && typeof contentMap === "object" && !Array.isArray(contentMap)
|
|
258
|
-
? Object.keys(contentMap)
|
|
259
|
-
: [];
|
|
260
|
-
const hasLocales = localeKeys.length > 0;
|
|
261
|
-
const options = localeKeys.map((k) => ({label: k.toUpperCase(), value: k}));
|
|
262
|
-
return (
|
|
263
|
-
<SelectField
|
|
264
|
-
disabled={!hasLocales}
|
|
265
|
-
errorText={errorText}
|
|
266
|
-
helperText={
|
|
267
|
-
hasLocales
|
|
268
|
-
? helperText
|
|
269
|
-
: "Add at least one locale with content before setting a default locale."
|
|
270
|
-
}
|
|
271
|
-
onChange={onChange}
|
|
272
|
-
options={options}
|
|
273
|
-
title={label}
|
|
274
|
-
value={value ?? ""}
|
|
275
|
-
/>
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// Mixed / object type — JSON-aware single-line field for schemaless fields (e.g., Mongoose Mixed)
|
|
280
|
-
if (fieldConfig.type === "object" || fieldConfig.type === "mixed") {
|
|
281
|
-
const displayValue = serializeJsonValue(value);
|
|
282
|
-
return (
|
|
283
|
-
<TextField
|
|
284
|
-
errorText={errorText}
|
|
285
|
-
helperText={helperText ?? "JSON value (string, number, boolean, object, or array)"}
|
|
286
|
-
onChange={(text: string) => {
|
|
287
|
-
onChange(parseJsonValue(text));
|
|
288
|
-
}}
|
|
289
|
-
testID={`admin-field-${fieldKey}`}
|
|
290
|
-
title={label}
|
|
291
|
-
value={displayValue}
|
|
292
|
-
/>
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// Array of primitives (string, number, boolean) or ObjectId refs
|
|
297
|
-
if (fieldConfig.type === "array" && fieldConfig.itemType && !fieldConfig.items) {
|
|
298
|
-
return (
|
|
299
|
-
<AdminPrimitiveArrayField
|
|
300
|
-
api={api}
|
|
301
|
-
baseUrl={baseUrl}
|
|
302
|
-
errorText={errorText}
|
|
303
|
-
helperText={helperText}
|
|
304
|
-
itemEnum={fieldConfig.itemEnum}
|
|
305
|
-
itemRef={fieldConfig.itemRef}
|
|
306
|
-
itemType={fieldConfig.itemType}
|
|
307
|
-
modelConfigs={modelConfigs}
|
|
308
|
-
onChange={onChange}
|
|
309
|
-
refRenderers={refRenderers}
|
|
310
|
-
title={label}
|
|
311
|
-
value={value ?? []}
|
|
312
|
-
/>
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// Array of sub-documents
|
|
317
30
|
if (fieldConfig.type === "array" && fieldConfig.items) {
|
|
318
31
|
return (
|
|
319
32
|
<AdminNestedArrayField
|
|
320
33
|
api={api}
|
|
321
34
|
baseUrl={baseUrl}
|
|
322
35
|
errorText={errorText}
|
|
323
|
-
helperText={
|
|
36
|
+
helperText={fieldConfig.description}
|
|
324
37
|
items={fieldConfig.items}
|
|
325
38
|
modelConfigs={modelConfigs}
|
|
326
39
|
onChange={onChange}
|
|
327
40
|
parentFormState={parentFormState}
|
|
328
41
|
refRenderers={refRenderers}
|
|
329
|
-
title={
|
|
330
|
-
value={value
|
|
331
|
-
/>
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// Array without item metadata — show as JSON text
|
|
336
|
-
if (fieldConfig.type === "array") {
|
|
337
|
-
const jsonValue =
|
|
338
|
-
value != null ? (typeof value === "string" ? value : JSON.stringify(value, null, 2)) : "[]";
|
|
339
|
-
return (
|
|
340
|
-
<TextField
|
|
341
|
-
errorText={errorText}
|
|
342
|
-
grow
|
|
343
|
-
helperText={helperText ?? "Enter valid JSON array"}
|
|
344
|
-
multiline
|
|
345
|
-
onChange={(text: string) => {
|
|
346
|
-
try {
|
|
347
|
-
onChange(JSON.parse(text));
|
|
348
|
-
} catch {
|
|
349
|
-
onChange(text);
|
|
350
|
-
}
|
|
351
|
-
}}
|
|
352
|
-
rows={4}
|
|
353
|
-
testID={`admin-field-${fieldKey}`}
|
|
354
|
-
title={label}
|
|
355
|
-
value={jsonValue}
|
|
356
|
-
/>
|
|
357
|
-
);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
// Markdown widget
|
|
361
|
-
if (fieldConfig.widget === "markdown") {
|
|
362
|
-
return (
|
|
363
|
-
<MarkdownEditorField
|
|
364
|
-
errorText={errorText}
|
|
365
|
-
helperText={helperText}
|
|
366
|
-
onChange={onChange}
|
|
367
|
-
testID={`admin-field-${fieldKey}`}
|
|
368
|
-
title={label}
|
|
369
|
-
value={value ?? ""}
|
|
370
|
-
/>
|
|
371
|
-
);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// Checkbox list widget
|
|
375
|
-
if (fieldConfig.widget === "checkbox-list") {
|
|
376
|
-
return (
|
|
377
|
-
<CheckboxListEditor
|
|
378
|
-
errorText={errorText}
|
|
379
|
-
helperText={helperText}
|
|
380
|
-
onChange={onChange}
|
|
381
|
-
title={label}
|
|
382
|
-
value={value ?? []}
|
|
383
|
-
/>
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// Textarea widget
|
|
388
|
-
if (fieldConfig.widget === "textarea") {
|
|
389
|
-
return (
|
|
390
|
-
<TextField
|
|
391
|
-
errorText={errorText}
|
|
392
|
-
grow
|
|
393
|
-
helperText={helperText}
|
|
394
|
-
multiline
|
|
395
|
-
onChange={onChange}
|
|
396
|
-
rows={6}
|
|
397
|
-
testID={`admin-field-${fieldKey}`}
|
|
398
|
-
title={label}
|
|
399
|
-
value={value ?? ""}
|
|
42
|
+
title={startCase(fieldKey)}
|
|
43
|
+
value={Array.isArray(value) ? (value as Record<string, AdminFieldValue>[]) : []}
|
|
400
44
|
/>
|
|
401
45
|
);
|
|
402
46
|
}
|
|
403
47
|
|
|
404
|
-
// Default: string -> TextField
|
|
405
48
|
return (
|
|
406
|
-
<
|
|
49
|
+
<AdminFieldRendererCore
|
|
50
|
+
api={api}
|
|
51
|
+
baseUrl={baseUrl}
|
|
407
52
|
errorText={errorText}
|
|
408
|
-
|
|
53
|
+
fieldConfig={fieldConfig}
|
|
54
|
+
fieldKey={fieldKey}
|
|
55
|
+
modelConfigs={modelConfigs}
|
|
409
56
|
onChange={onChange}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
value={value
|
|
57
|
+
parentFormState={parentFormState}
|
|
58
|
+
refRenderers={refRenderers}
|
|
59
|
+
value={value}
|
|
413
60
|
/>
|
|
414
61
|
);
|
|
415
62
|
};
|