@webbycrown/advanced-fields 1.0.2 → 1.0.3
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/_chunks/en-BPwepUqK.js +84 -0
- package/dist/_chunks/en-CJmJkBE0.mjs +84 -0
- package/dist/_chunks/index-C-A6rX1K.mjs +268 -0
- package/dist/_chunks/index-CCaZAiQR.js +268 -0
- package/{admin/src/components/AdvancedInput/index.jsx → dist/_chunks/index-DTSlHlvg.mjs} +43 -92
- package/dist/_chunks/index-DXVpJkpj.mjs +282 -0
- package/dist/_chunks/index-TmoGbq0j.js +282 -0
- package/dist/_chunks/index-lJs3vGYF.js +130 -0
- package/dist/admin/index.js +867 -0
- package/dist/admin/index.mjs +868 -0
- package/package.json +5 -3
- package/admin/jsconfig.json +0 -10
- package/admin/src/components/AdvancedCheckbox/index.jsx +0 -377
- package/admin/src/components/AdvancedRadio/index.jsx +0 -344
- package/admin/src/components/Initializer.jsx +0 -18
- package/admin/src/components/PluginIcon.jsx +0 -108
- package/admin/src/index.js +0 -787
- package/admin/src/pages/App.jsx +0 -13
- package/admin/src/pluginId.js +0 -3
- package/admin/src/utils/getTranslation.js +0 -5
- /package/{admin/src → dist/admin}/translations/en.json +0 -0
package/admin/src/index.js
DELETED
|
@@ -1,787 +0,0 @@
|
|
|
1
|
-
import { PLUGIN_ID } from './pluginId';
|
|
2
|
-
import { Initializer } from './components/Initializer';
|
|
3
|
-
import { AdvancedCheckboxIcon, AdvancedInputIcon, AdvancedRadioIcon } from './components/PluginIcon';
|
|
4
|
-
|
|
5
|
-
// Dynamic field configuration with comprehensive options
|
|
6
|
-
const customFields = [
|
|
7
|
-
{
|
|
8
|
-
name: "input",
|
|
9
|
-
type: "string",
|
|
10
|
-
icon: AdvancedInputIcon,
|
|
11
|
-
pluginId: PLUGIN_ID,
|
|
12
|
-
component: () => import("./components/AdvancedInput"),
|
|
13
|
-
intlLabel: {
|
|
14
|
-
id: `${PLUGIN_ID}.input.label`,
|
|
15
|
-
defaultMessage: 'Advanced Input',
|
|
16
|
-
},
|
|
17
|
-
intlDescription: {
|
|
18
|
-
id: `${PLUGIN_ID}.input.description`,
|
|
19
|
-
defaultMessage: "Professional-grade text input with comprehensive validation and advanced configuration options",
|
|
20
|
-
},
|
|
21
|
-
options: {
|
|
22
|
-
base: [],
|
|
23
|
-
advanced: [
|
|
24
|
-
{
|
|
25
|
-
sectionTitle: {
|
|
26
|
-
id: `${PLUGIN_ID}.input.settings.advanced.label`,
|
|
27
|
-
defaultMessage: 'Advanced Settings',
|
|
28
|
-
},
|
|
29
|
-
items: [
|
|
30
|
-
{
|
|
31
|
-
name: 'required',
|
|
32
|
-
type: 'checkbox',
|
|
33
|
-
intlLabel: {
|
|
34
|
-
id: `${PLUGIN_ID}.input.options.required.label`,
|
|
35
|
-
defaultMessage: 'Required Field',
|
|
36
|
-
},
|
|
37
|
-
description: {
|
|
38
|
-
id: `${PLUGIN_ID}.input.options.required.description`,
|
|
39
|
-
defaultMessage: 'This field must be filled before saving',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: 'unique',
|
|
44
|
-
type: 'checkbox',
|
|
45
|
-
intlLabel: {
|
|
46
|
-
id: `${PLUGIN_ID}.input.options.unique.label`,
|
|
47
|
-
defaultMessage: 'Unique Value',
|
|
48
|
-
},
|
|
49
|
-
description: {
|
|
50
|
-
id: `${PLUGIN_ID}.input.options.unique.description`,
|
|
51
|
-
defaultMessage: 'Each entry must have a different value',
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'maxLength',
|
|
56
|
-
type: 'number',
|
|
57
|
-
intlLabel: {
|
|
58
|
-
id: `${PLUGIN_ID}.input.options.maxLength.label`,
|
|
59
|
-
defaultMessage: 'Maximum Length',
|
|
60
|
-
},
|
|
61
|
-
description: {
|
|
62
|
-
id: `${PLUGIN_ID}.input.options.maxLength.description`,
|
|
63
|
-
defaultMessage: 'Maximum number of characters allowed',
|
|
64
|
-
},
|
|
65
|
-
placeholder: {
|
|
66
|
-
id: `${PLUGIN_ID}.input.options.maxLength.placeholder`,
|
|
67
|
-
defaultMessage: 'Enter max length (e.g., 255)',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: 'minLength',
|
|
72
|
-
type: 'number',
|
|
73
|
-
intlLabel: {
|
|
74
|
-
id: `${PLUGIN_ID}.input.options.minLength.label`,
|
|
75
|
-
defaultMessage: 'Minimum Length',
|
|
76
|
-
},
|
|
77
|
-
description: {
|
|
78
|
-
id: `${PLUGIN_ID}.input.options.minLength.description`,
|
|
79
|
-
defaultMessage: 'Minimum number of characters required',
|
|
80
|
-
},
|
|
81
|
-
placeholder: {
|
|
82
|
-
id: `${PLUGIN_ID}.input.options.minLength.placeholder`,
|
|
83
|
-
defaultMessage: 'Enter min length (e.g., 3)',
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
name: 'options.defaultValue',
|
|
88
|
-
type: 'text',
|
|
89
|
-
intlLabel: {
|
|
90
|
-
id: `${PLUGIN_ID}.input.options.defaultValue.label`,
|
|
91
|
-
defaultMessage: 'Default Value',
|
|
92
|
-
},
|
|
93
|
-
description: {
|
|
94
|
-
id: `${PLUGIN_ID}.input.options.defaultValue.description`,
|
|
95
|
-
defaultMessage: 'Pre-filled value for new entries',
|
|
96
|
-
},
|
|
97
|
-
placeholder: {
|
|
98
|
-
id: `${PLUGIN_ID}.input.options.defaultValue.placeholder`,
|
|
99
|
-
defaultMessage: 'Enter default text',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
name: 'options.placeholder',
|
|
104
|
-
type: 'text',
|
|
105
|
-
intlLabel: {
|
|
106
|
-
id: `${PLUGIN_ID}.input.options.placeholder.label`,
|
|
107
|
-
defaultMessage: 'Placeholder Text',
|
|
108
|
-
},
|
|
109
|
-
description: {
|
|
110
|
-
id: `${PLUGIN_ID}.input.options.placeholder.description`,
|
|
111
|
-
defaultMessage: 'Hint text shown when field is empty',
|
|
112
|
-
},
|
|
113
|
-
placeholder: {
|
|
114
|
-
id: `${PLUGIN_ID}.input.options.placeholder.placeholder`,
|
|
115
|
-
defaultMessage: 'Enter placeholder text',
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'regex',
|
|
120
|
-
type: 'text',
|
|
121
|
-
intlLabel: {
|
|
122
|
-
id: `${PLUGIN_ID}.input.options.regex.label`,
|
|
123
|
-
defaultMessage: 'Regular Expression',
|
|
124
|
-
},
|
|
125
|
-
description: {
|
|
126
|
-
id: `${PLUGIN_ID}.input.options.regex.description`,
|
|
127
|
-
defaultMessage: 'Custom validation pattern (regex)',
|
|
128
|
-
},
|
|
129
|
-
placeholder: {
|
|
130
|
-
id: `${PLUGIN_ID}.input.options.regex.placeholder`,
|
|
131
|
-
defaultMessage: 'e.g., ^[A-Za-z]+$ for letters only',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
name: 'options.customErrorMessage',
|
|
136
|
-
type: 'text',
|
|
137
|
-
intlLabel: {
|
|
138
|
-
id: `${PLUGIN_ID}.input.options.customErrorMessage.label`,
|
|
139
|
-
defaultMessage: 'Custom Error Message',
|
|
140
|
-
},
|
|
141
|
-
description: {
|
|
142
|
-
id: `${PLUGIN_ID}.input.options.customErrorMessage.description`,
|
|
143
|
-
defaultMessage: 'Custom error message for validation failures',
|
|
144
|
-
},
|
|
145
|
-
placeholder: {
|
|
146
|
-
id: `${PLUGIN_ID}.input.options.customErrorMessage.placeholder`,
|
|
147
|
-
defaultMessage: 'Enter custom error message',
|
|
148
|
-
},
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
name: 'options.fieldNote',
|
|
152
|
-
type: 'text',
|
|
153
|
-
intlLabel: {
|
|
154
|
-
id: `${PLUGIN_ID}.input.options.fieldNote.label`,
|
|
155
|
-
defaultMessage: 'Field Note',
|
|
156
|
-
},
|
|
157
|
-
description: {
|
|
158
|
-
id: `${PLUGIN_ID}.input.options.fieldNote.description`,
|
|
159
|
-
defaultMessage: 'Add a helpful note that will appear below the field',
|
|
160
|
-
},
|
|
161
|
-
placeholder: {
|
|
162
|
-
id: `${PLUGIN_ID}.input.options.fieldNote.placeholder`,
|
|
163
|
-
defaultMessage: 'Enter a note for this field',
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
name: 'private',
|
|
168
|
-
type: 'checkbox',
|
|
169
|
-
intlLabel: {
|
|
170
|
-
id: `${PLUGIN_ID}.input.options.private.label`,
|
|
171
|
-
defaultMessage: 'Private Field',
|
|
172
|
-
},
|
|
173
|
-
description: {
|
|
174
|
-
id: `${PLUGIN_ID}.input.options.private.description`,
|
|
175
|
-
defaultMessage: 'Hide this field from API responses',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "checkbox",
|
|
185
|
-
type: "json",
|
|
186
|
-
icon: AdvancedCheckboxIcon,
|
|
187
|
-
pluginId: PLUGIN_ID,
|
|
188
|
-
component: () => import("./components/AdvancedCheckbox"),
|
|
189
|
-
intlLabel: {
|
|
190
|
-
id: `${PLUGIN_ID}.checkbox.label`,
|
|
191
|
-
defaultMessage: "Advanced Checkbox",
|
|
192
|
-
},
|
|
193
|
-
intlDescription: {
|
|
194
|
-
id: `${PLUGIN_ID}.checkbox.description`,
|
|
195
|
-
defaultMessage: "Unified checkbox field supporting both single and multiple selections with advanced configuration",
|
|
196
|
-
},
|
|
197
|
-
getDisplayValue: (value, field) => {
|
|
198
|
-
if (!value || !Array.isArray(value) || value.length === 0) {
|
|
199
|
-
return '';
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Get field options to map values to labels
|
|
203
|
-
const options = field?.options?.checkboxOptions || '';
|
|
204
|
-
const optionMap = {};
|
|
205
|
-
|
|
206
|
-
if (options) {
|
|
207
|
-
options.split('\n').forEach(opt => {
|
|
208
|
-
const [val, label] = opt.split('|');
|
|
209
|
-
if (val && label) {
|
|
210
|
-
optionMap[val.trim()] = label.trim();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
// Map values to labels, fallback to values if no labels found
|
|
216
|
-
const displayValues = value.map(val => optionMap[val] || val);
|
|
217
|
-
|
|
218
|
-
return displayValues.join(', ');
|
|
219
|
-
},
|
|
220
|
-
options: {
|
|
221
|
-
base: [],
|
|
222
|
-
advanced: [
|
|
223
|
-
{
|
|
224
|
-
sectionTitle: {
|
|
225
|
-
id: `${PLUGIN_ID}.checkbox.settings.advanced.label`,
|
|
226
|
-
defaultMessage: 'Advanced Settings',
|
|
227
|
-
},
|
|
228
|
-
items: [
|
|
229
|
-
{
|
|
230
|
-
name: 'required',
|
|
231
|
-
type: 'checkbox',
|
|
232
|
-
intlLabel: {
|
|
233
|
-
id: `${PLUGIN_ID}.checkbox.options.required.label`,
|
|
234
|
-
defaultMessage: 'Required Field',
|
|
235
|
-
},
|
|
236
|
-
description: {
|
|
237
|
-
id: `${PLUGIN_ID}.checkbox.options.required.description`,
|
|
238
|
-
defaultMessage: 'This field must be filled before saving',
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
name: 'options.checkboxType',
|
|
243
|
-
type: 'select',
|
|
244
|
-
intlLabel: {
|
|
245
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxType.label`,
|
|
246
|
-
defaultMessage: 'Checkbox Type',
|
|
247
|
-
},
|
|
248
|
-
description: {
|
|
249
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxType.description`,
|
|
250
|
-
defaultMessage: 'Choose between single checkbox or multiple checkboxes',
|
|
251
|
-
},
|
|
252
|
-
options: [
|
|
253
|
-
{
|
|
254
|
-
value: 'single',
|
|
255
|
-
metadatas: {
|
|
256
|
-
intlLabel: {
|
|
257
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxType.single`,
|
|
258
|
-
defaultMessage: 'Single Checkbox',
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
value: 'multiple',
|
|
264
|
-
metadatas: {
|
|
265
|
-
intlLabel: {
|
|
266
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxType.multiple`,
|
|
267
|
-
defaultMessage: 'Multiple Checkboxes',
|
|
268
|
-
},
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
defaultValue: 'single',
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
name: 'options.checkboxOptions',
|
|
276
|
-
type: 'textarea',
|
|
277
|
-
intlLabel: {
|
|
278
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxOptions.label`,
|
|
279
|
-
defaultMessage: 'Checkbox Options',
|
|
280
|
-
},
|
|
281
|
-
description: {
|
|
282
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxOptions.description`,
|
|
283
|
-
defaultMessage: 'Define available options for multiple checkboxes (one per line: value|label)',
|
|
284
|
-
},
|
|
285
|
-
placeholder: {
|
|
286
|
-
id: `${PLUGIN_ID}.checkbox.options.checkboxOptions.placeholder`,
|
|
287
|
-
defaultMessage: 'option1|Option 1\noption2|Option 2\noption3|Option 3',
|
|
288
|
-
},
|
|
289
|
-
condition: {
|
|
290
|
-
field: 'options.checkboxType',
|
|
291
|
-
operator: 'eq',
|
|
292
|
-
value: 'multiple',
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
{
|
|
296
|
-
name: 'options.defaultSelected',
|
|
297
|
-
type: 'textarea',
|
|
298
|
-
intlLabel: {
|
|
299
|
-
id: `${PLUGIN_ID}.checkbox.options.defaultSelected.label`,
|
|
300
|
-
defaultMessage: 'Default Selected',
|
|
301
|
-
},
|
|
302
|
-
description: {
|
|
303
|
-
id: `${PLUGIN_ID}.checkbox.options.defaultSelected.description`,
|
|
304
|
-
defaultMessage: 'Pre-selected options for multiple checkboxes (one per line)',
|
|
305
|
-
},
|
|
306
|
-
placeholder: {
|
|
307
|
-
id: `${PLUGIN_ID}.checkbox.options.defaultSelected.placeholder`,
|
|
308
|
-
defaultMessage: 'option1\noption2',
|
|
309
|
-
},
|
|
310
|
-
condition: {
|
|
311
|
-
field: 'options.checkboxType',
|
|
312
|
-
operator: 'eq',
|
|
313
|
-
value: 'multiple',
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
name: 'options.minChoices',
|
|
318
|
-
type: 'number',
|
|
319
|
-
intlLabel: {
|
|
320
|
-
id: `${PLUGIN_ID}.checkbox.options.minChoices.label`,
|
|
321
|
-
defaultMessage: 'Minimum Choices',
|
|
322
|
-
},
|
|
323
|
-
description: {
|
|
324
|
-
id: `${PLUGIN_ID}.checkbox.options.minChoices.description`,
|
|
325
|
-
defaultMessage: 'Minimum number of options that must be selected',
|
|
326
|
-
},
|
|
327
|
-
placeholder: {
|
|
328
|
-
id: `${PLUGIN_ID}.checkbox.options.minChoices.placeholder`,
|
|
329
|
-
defaultMessage: 'Enter minimum (0 for no limit)',
|
|
330
|
-
},
|
|
331
|
-
defaultValue: 0,
|
|
332
|
-
condition: {
|
|
333
|
-
field: 'options.checkboxType',
|
|
334
|
-
operator: 'eq',
|
|
335
|
-
value: 'multiple',
|
|
336
|
-
},
|
|
337
|
-
},
|
|
338
|
-
{
|
|
339
|
-
name: 'options.maxChoices',
|
|
340
|
-
type: 'number',
|
|
341
|
-
intlLabel: {
|
|
342
|
-
id: `${PLUGIN_ID}.checkbox.options.maxChoices.label`,
|
|
343
|
-
defaultMessage: 'Maximum Choices',
|
|
344
|
-
},
|
|
345
|
-
description: {
|
|
346
|
-
id: `${PLUGIN_ID}.checkbox.options.maxChoices.description`,
|
|
347
|
-
defaultMessage: 'Maximum number of options that can be selected',
|
|
348
|
-
},
|
|
349
|
-
placeholder: {
|
|
350
|
-
id: `${PLUGIN_ID}.checkbox.options.maxChoices.placeholder`,
|
|
351
|
-
defaultMessage: 'Enter maximum (0 for no limit)',
|
|
352
|
-
},
|
|
353
|
-
defaultValue: 0,
|
|
354
|
-
condition: {
|
|
355
|
-
field: 'options.checkboxType',
|
|
356
|
-
operator: 'eq',
|
|
357
|
-
value: 'multiple',
|
|
358
|
-
},
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
name: 'options.layout',
|
|
362
|
-
type: 'select',
|
|
363
|
-
intlLabel: {
|
|
364
|
-
id: `${PLUGIN_ID}.checkbox.options.layout.label`,
|
|
365
|
-
defaultMessage: 'Layout Style',
|
|
366
|
-
},
|
|
367
|
-
description: {
|
|
368
|
-
id: `${PLUGIN_ID}.checkbox.options.layout.description`,
|
|
369
|
-
defaultMessage: 'Visual layout of multiple checkbox options',
|
|
370
|
-
},
|
|
371
|
-
options: [
|
|
372
|
-
{
|
|
373
|
-
value: 'vertical',
|
|
374
|
-
metadatas: {
|
|
375
|
-
intlLabel: {
|
|
376
|
-
id: `${PLUGIN_ID}.checkbox.options.layout.vertical`,
|
|
377
|
-
defaultMessage: 'Vertical Stack',
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
value: 'horizontal',
|
|
383
|
-
metadatas: {
|
|
384
|
-
intlLabel: {
|
|
385
|
-
id: `${PLUGIN_ID}.checkbox.options.layout.horizontal`,
|
|
386
|
-
defaultMessage: 'Horizontal Row',
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
value: 'grid',
|
|
392
|
-
metadatas: {
|
|
393
|
-
intlLabel: {
|
|
394
|
-
id: `${PLUGIN_ID}.checkbox.options.layout.grid`,
|
|
395
|
-
defaultMessage: 'Grid Layout',
|
|
396
|
-
},
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
],
|
|
400
|
-
defaultValue: 'vertical',
|
|
401
|
-
condition: {
|
|
402
|
-
field: 'options.checkboxType',
|
|
403
|
-
operator: 'eq',
|
|
404
|
-
value: 'multiple',
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
name: 'options.customErrorMessage',
|
|
409
|
-
type: 'text',
|
|
410
|
-
intlLabel: {
|
|
411
|
-
id: `${PLUGIN_ID}.checkbox.options.customErrorMessage.label`,
|
|
412
|
-
defaultMessage: 'Custom Error Message',
|
|
413
|
-
},
|
|
414
|
-
description: {
|
|
415
|
-
id: `${PLUGIN_ID}.checkbox.options.customErrorMessage.description`,
|
|
416
|
-
defaultMessage: 'Custom error message for validation failures',
|
|
417
|
-
},
|
|
418
|
-
placeholder: {
|
|
419
|
-
id: `${PLUGIN_ID}.checkbox.options.customErrorMessage.placeholder`,
|
|
420
|
-
defaultMessage: 'Enter custom error message',
|
|
421
|
-
},
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
name: 'options.fieldNote',
|
|
425
|
-
type: 'text',
|
|
426
|
-
intlLabel: {
|
|
427
|
-
id: `${PLUGIN_ID}.checkbox.options.fieldNote.label`,
|
|
428
|
-
defaultMessage: 'Field Note',
|
|
429
|
-
},
|
|
430
|
-
description: {
|
|
431
|
-
id: `${PLUGIN_ID}.checkbox.options.fieldNote.description`,
|
|
432
|
-
defaultMessage: 'Add a helpful note that will appear below the field',
|
|
433
|
-
},
|
|
434
|
-
placeholder: {
|
|
435
|
-
id: `${PLUGIN_ID}.checkbox.options.fieldNote.placeholder`,
|
|
436
|
-
defaultMessage: 'Enter a note for this field',
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
{
|
|
440
|
-
name: 'private',
|
|
441
|
-
type: 'checkbox',
|
|
442
|
-
intlLabel: {
|
|
443
|
-
id: `${PLUGIN_ID}.checkbox.options.private.label`,
|
|
444
|
-
defaultMessage: 'Private Field',
|
|
445
|
-
},
|
|
446
|
-
description: {
|
|
447
|
-
id: `${PLUGIN_ID}.checkbox.options.private.description`,
|
|
448
|
-
defaultMessage: 'Hide this field from API responses',
|
|
449
|
-
},
|
|
450
|
-
},
|
|
451
|
-
],
|
|
452
|
-
},
|
|
453
|
-
],
|
|
454
|
-
},
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
name: "radio",
|
|
458
|
-
type: "json",
|
|
459
|
-
icon: AdvancedRadioIcon,
|
|
460
|
-
pluginId: PLUGIN_ID,
|
|
461
|
-
component: () => import("./components/AdvancedRadio"),
|
|
462
|
-
intlLabel: {
|
|
463
|
-
id: `${PLUGIN_ID}.radio.label`,
|
|
464
|
-
defaultMessage: "Advanced Radio",
|
|
465
|
-
},
|
|
466
|
-
intlDescription: {
|
|
467
|
-
id: `${PLUGIN_ID}.radio.description`,
|
|
468
|
-
defaultMessage: "Radio buttons with dynamic options and selection types",
|
|
469
|
-
},
|
|
470
|
-
getDisplayValue: (value, field) => {
|
|
471
|
-
if (!value || !Array.isArray(value) || value.length === 0) {
|
|
472
|
-
return '';
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
// Get field options to map values to labels
|
|
476
|
-
const options = field?.options?.radioOptions || '';
|
|
477
|
-
const optionMap = {};
|
|
478
|
-
|
|
479
|
-
if (options) {
|
|
480
|
-
options.split('\n').forEach(opt => {
|
|
481
|
-
const [val, label] = opt.split('|');
|
|
482
|
-
if (val && label) {
|
|
483
|
-
optionMap[val.trim()] = label.trim();
|
|
484
|
-
}
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// Map values to labels, fallback to values if no labels found
|
|
489
|
-
const displayValues = value.map(val => optionMap[val] || val);
|
|
490
|
-
|
|
491
|
-
return displayValues.join(', ');
|
|
492
|
-
},
|
|
493
|
-
options: {
|
|
494
|
-
base: [],
|
|
495
|
-
advanced: [
|
|
496
|
-
{
|
|
497
|
-
sectionTitle: {
|
|
498
|
-
id: `${PLUGIN_ID}.radio.settings.advanced.label`,
|
|
499
|
-
defaultMessage: 'Advanced Settings',
|
|
500
|
-
},
|
|
501
|
-
items: [
|
|
502
|
-
{
|
|
503
|
-
name: 'required',
|
|
504
|
-
type: 'checkbox',
|
|
505
|
-
intlLabel: {
|
|
506
|
-
id: `${PLUGIN_ID}.radio.options.required.label`,
|
|
507
|
-
defaultMessage: 'Required Field',
|
|
508
|
-
},
|
|
509
|
-
description: {
|
|
510
|
-
id: `${PLUGIN_ID}.radio.options.required.description`,
|
|
511
|
-
defaultMessage: 'At least one option must be selected',
|
|
512
|
-
},
|
|
513
|
-
},
|
|
514
|
-
{
|
|
515
|
-
name: 'options.radioOptions',
|
|
516
|
-
type: 'textarea',
|
|
517
|
-
intlLabel: {
|
|
518
|
-
id: `${PLUGIN_ID}.radio.options.radioOptions.label`,
|
|
519
|
-
defaultMessage: 'Radio Options',
|
|
520
|
-
},
|
|
521
|
-
description: {
|
|
522
|
-
id: `${PLUGIN_ID}.radio.options.radioOptions.description`,
|
|
523
|
-
defaultMessage: 'Define available options (one per line: value|label)',
|
|
524
|
-
},
|
|
525
|
-
placeholder: {
|
|
526
|
-
id: `${PLUGIN_ID}.radio.options.radioOptions.placeholder`,
|
|
527
|
-
defaultMessage: '1|Option 1\n2|Option 2\n3|Option 3',
|
|
528
|
-
},
|
|
529
|
-
},
|
|
530
|
-
{
|
|
531
|
-
name: 'options.defaultSelected',
|
|
532
|
-
type: 'textarea',
|
|
533
|
-
intlLabel: {
|
|
534
|
-
id: `${PLUGIN_ID}.radio.options.defaultSelected.label`,
|
|
535
|
-
defaultMessage: 'Default Selected',
|
|
536
|
-
},
|
|
537
|
-
description: {
|
|
538
|
-
id: `${PLUGIN_ID}.radio.options.defaultSelected.description`,
|
|
539
|
-
defaultMessage: 'Pre-selected options (one per line)',
|
|
540
|
-
},
|
|
541
|
-
placeholder: {
|
|
542
|
-
id: `${PLUGIN_ID}.radio.options.defaultSelected.placeholder`,
|
|
543
|
-
defaultMessage: '1\n2',
|
|
544
|
-
},
|
|
545
|
-
},
|
|
546
|
-
{
|
|
547
|
-
name: "options.selectionType",
|
|
548
|
-
type: "select",
|
|
549
|
-
intlLabel: {
|
|
550
|
-
id: `${PLUGIN_ID}.radio.options.selectionType.label`,
|
|
551
|
-
defaultMessage: "Selection Type",
|
|
552
|
-
},
|
|
553
|
-
description: {
|
|
554
|
-
id: `${PLUGIN_ID}.radio.options.selectionType.description`,
|
|
555
|
-
defaultMessage: "Choose whether users can select one or multiple options",
|
|
556
|
-
},
|
|
557
|
-
options: [
|
|
558
|
-
{
|
|
559
|
-
value: "single",
|
|
560
|
-
metadatas: {
|
|
561
|
-
intlLabel: {
|
|
562
|
-
id: `${PLUGIN_ID}.radio.options.selectionType.single`,
|
|
563
|
-
defaultMessage: "Single Selection",
|
|
564
|
-
},
|
|
565
|
-
},
|
|
566
|
-
},
|
|
567
|
-
{
|
|
568
|
-
value: "multiple",
|
|
569
|
-
metadatas: {
|
|
570
|
-
intlLabel: {
|
|
571
|
-
id: `${PLUGIN_ID}.radio.options.selectionType.multiple`,
|
|
572
|
-
defaultMessage: "Multiple Selection",
|
|
573
|
-
},
|
|
574
|
-
},
|
|
575
|
-
},
|
|
576
|
-
],
|
|
577
|
-
defaultValue: "single",
|
|
578
|
-
},
|
|
579
|
-
{
|
|
580
|
-
name: 'options.minChoices',
|
|
581
|
-
type: 'number',
|
|
582
|
-
intlLabel: {
|
|
583
|
-
id: `${PLUGIN_ID}.radio.options.minChoices.label`,
|
|
584
|
-
defaultMessage: 'Minimum Choices',
|
|
585
|
-
},
|
|
586
|
-
description: {
|
|
587
|
-
id: `${PLUGIN_ID}.radio.options.minChoices.description`,
|
|
588
|
-
defaultMessage: 'Minimum number of options that must be selected',
|
|
589
|
-
},
|
|
590
|
-
placeholder: {
|
|
591
|
-
id: `${PLUGIN_ID}.radio.options.minChoices.placeholder`,
|
|
592
|
-
defaultMessage: 'Enter minimum (0 for no limit)',
|
|
593
|
-
},
|
|
594
|
-
defaultValue: 0,
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
name: 'options.maxChoices',
|
|
598
|
-
type: 'number',
|
|
599
|
-
intlLabel: {
|
|
600
|
-
id: `${PLUGIN_ID}.radio.options.maxChoices.label`,
|
|
601
|
-
defaultMessage: 'Maximum Choices',
|
|
602
|
-
},
|
|
603
|
-
description: {
|
|
604
|
-
id: `${PLUGIN_ID}.radio.options.maxChoices.description`,
|
|
605
|
-
defaultMessage: 'Maximum number of options that can be selected',
|
|
606
|
-
},
|
|
607
|
-
placeholder: {
|
|
608
|
-
id: `${PLUGIN_ID}.radio.options.maxChoices.placeholder`,
|
|
609
|
-
defaultMessage: 'Enter maximum (0 for no limit)',
|
|
610
|
-
},
|
|
611
|
-
defaultValue: 0,
|
|
612
|
-
},
|
|
613
|
-
{
|
|
614
|
-
name: 'options.layout',
|
|
615
|
-
type: 'select',
|
|
616
|
-
intlLabel: {
|
|
617
|
-
id: `${PLUGIN_ID}.radio.options.layout.label`,
|
|
618
|
-
defaultMessage: 'Layout Style',
|
|
619
|
-
},
|
|
620
|
-
description: {
|
|
621
|
-
id: `${PLUGIN_ID}.radio.options.layout.description`,
|
|
622
|
-
defaultMessage: 'Visual layout of radio options',
|
|
623
|
-
},
|
|
624
|
-
options: [
|
|
625
|
-
{
|
|
626
|
-
value: 'vertical',
|
|
627
|
-
metadatas: {
|
|
628
|
-
intlLabel: {
|
|
629
|
-
id: `${PLUGIN_ID}.radio.options.layout.vertical`,
|
|
630
|
-
defaultMessage: 'Vertical Stack',
|
|
631
|
-
},
|
|
632
|
-
},
|
|
633
|
-
},
|
|
634
|
-
{
|
|
635
|
-
value: 'horizontal',
|
|
636
|
-
metadatas: {
|
|
637
|
-
intlLabel: {
|
|
638
|
-
id: `${PLUGIN_ID}.radio.options.layout.horizontal`,
|
|
639
|
-
defaultMessage: 'Horizontal Row',
|
|
640
|
-
},
|
|
641
|
-
},
|
|
642
|
-
},
|
|
643
|
-
{
|
|
644
|
-
value: 'grid',
|
|
645
|
-
metadatas: {
|
|
646
|
-
intlLabel: {
|
|
647
|
-
id: `${PLUGIN_ID}.radio.options.layout.grid`,
|
|
648
|
-
defaultMessage: 'Grid Layout',
|
|
649
|
-
},
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
],
|
|
653
|
-
defaultValue: 'vertical',
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
name: 'options.customErrorMessage',
|
|
657
|
-
type: 'text',
|
|
658
|
-
intlLabel: {
|
|
659
|
-
id: `${PLUGIN_ID}.radio.options.customErrorMessage.label`,
|
|
660
|
-
defaultMessage: 'Custom Error Message',
|
|
661
|
-
},
|
|
662
|
-
description: {
|
|
663
|
-
id: `${PLUGIN_ID}.radio.options.customErrorMessage.description`,
|
|
664
|
-
defaultMessage: 'Custom error message for validation failures',
|
|
665
|
-
},
|
|
666
|
-
placeholder: {
|
|
667
|
-
id: `${PLUGIN_ID}.radio.options.customErrorMessage.placeholder`,
|
|
668
|
-
defaultMessage: 'Enter custom error message',
|
|
669
|
-
},
|
|
670
|
-
},
|
|
671
|
-
{
|
|
672
|
-
name: 'options.fieldNote',
|
|
673
|
-
type: 'text',
|
|
674
|
-
intlLabel: {
|
|
675
|
-
id: `${PLUGIN_ID}.radio.options.fieldNote.label`,
|
|
676
|
-
defaultMessage: 'Field Note',
|
|
677
|
-
},
|
|
678
|
-
description: {
|
|
679
|
-
id: `${PLUGIN_ID}.radio.options.fieldNote.description`,
|
|
680
|
-
defaultMessage: 'Add a helpful note that will appear below the field',
|
|
681
|
-
},
|
|
682
|
-
placeholder: {
|
|
683
|
-
id: `${PLUGIN_ID}.radio.options.fieldNote.placeholder`,
|
|
684
|
-
defaultMessage: 'Enter a note for this field',
|
|
685
|
-
},
|
|
686
|
-
},
|
|
687
|
-
],
|
|
688
|
-
},
|
|
689
|
-
],
|
|
690
|
-
},
|
|
691
|
-
},
|
|
692
|
-
];
|
|
693
|
-
|
|
694
|
-
export default {
|
|
695
|
-
register(app) {
|
|
696
|
-
// Ensure custom fields registry is available
|
|
697
|
-
if (!app.customFields) {
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
// Register custom fields dynamically with error handling
|
|
702
|
-
customFields.forEach((field) => {
|
|
703
|
-
try {
|
|
704
|
-
app.customFields.register({
|
|
705
|
-
name: field.name,
|
|
706
|
-
pluginId: field.pluginId,
|
|
707
|
-
type: field.type,
|
|
708
|
-
intlLabel: field.intlLabel,
|
|
709
|
-
intlDescription: field.intlDescription,
|
|
710
|
-
icon: field.icon,
|
|
711
|
-
components: {
|
|
712
|
-
Input: field.component,
|
|
713
|
-
},
|
|
714
|
-
options: field.options,
|
|
715
|
-
getDisplayValue: field.getDisplayValue,
|
|
716
|
-
});
|
|
717
|
-
} catch (error) {
|
|
718
|
-
// Silent error handling
|
|
719
|
-
}
|
|
720
|
-
});
|
|
721
|
-
},
|
|
722
|
-
|
|
723
|
-
bootstrap(app) {
|
|
724
|
-
// Verify admin-side registration only if customFields.get is available
|
|
725
|
-
if (app.customFields && typeof app.customFields.get === 'function') {
|
|
726
|
-
customFields.forEach((field) => {
|
|
727
|
-
try {
|
|
728
|
-
const registeredField = app.customFields.get(`${field.pluginId}.${field.name}`);
|
|
729
|
-
// Field verification completed silently
|
|
730
|
-
} catch (error) {
|
|
731
|
-
// Silent error handling
|
|
732
|
-
}
|
|
733
|
-
});
|
|
734
|
-
}
|
|
735
|
-
},
|
|
736
|
-
|
|
737
|
-
async registerTrads({ locales }) {
|
|
738
|
-
return Promise.all(
|
|
739
|
-
locales.map(async (locale) => {
|
|
740
|
-
if (locale === 'en') {
|
|
741
|
-
// Build comprehensive translations from customFields
|
|
742
|
-
const translations = {
|
|
743
|
-
[`${PLUGIN_ID}.plugin.name`]: "Advanced Fields",
|
|
744
|
-
[`${PLUGIN_ID}.plugin.description`]: "Advanced custom fields with dynamic options",
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
// Helper function to extract all translations recursively
|
|
748
|
-
const extractTranslations = (obj, prefix = '') => {
|
|
749
|
-
Object.keys(obj).forEach(key => {
|
|
750
|
-
const value = obj[key];
|
|
751
|
-
const currentKey = prefix ? `${prefix}.${key}` : key;
|
|
752
|
-
|
|
753
|
-
if (typeof value === 'object' && value !== null) {
|
|
754
|
-
if (value.id && value.defaultMessage) {
|
|
755
|
-
// This is a translation object
|
|
756
|
-
translations[value.id] = value.defaultMessage;
|
|
757
|
-
} else if (Array.isArray(value)) {
|
|
758
|
-
// Handle arrays
|
|
759
|
-
value.forEach((item, index) => {
|
|
760
|
-
extractTranslations(item, `${currentKey}[${index}]`);
|
|
761
|
-
});
|
|
762
|
-
} else {
|
|
763
|
-
// Recursively extract from nested objects
|
|
764
|
-
extractTranslations(value, currentKey);
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
};
|
|
769
|
-
|
|
770
|
-
// Extract all translations from customFields
|
|
771
|
-
customFields.forEach((field) => {
|
|
772
|
-
extractTranslations(field);
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
return { data: translations, locale: 'en' };
|
|
776
|
-
}
|
|
777
|
-
|
|
778
|
-
try {
|
|
779
|
-
const { default: data } = await import(`./translations/${locale}.json`);
|
|
780
|
-
return { data, locale };
|
|
781
|
-
} catch {
|
|
782
|
-
return { data: {}, locale };
|
|
783
|
-
}
|
|
784
|
-
})
|
|
785
|
-
);
|
|
786
|
-
},
|
|
787
|
-
};
|