@strapi/content-type-builder 5.16.1 → 5.17.0
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/admin/components/ApplyConditionButton.js +34 -0
- package/dist/admin/components/ApplyConditionButton.js.map +1 -0
- package/dist/admin/components/ApplyConditionButton.mjs +32 -0
- package/dist/admin/components/ApplyConditionButton.mjs.map +1 -0
- package/dist/admin/components/AttributeRow.js +58 -8
- package/dist/admin/components/AttributeRow.js.map +1 -1
- package/dist/admin/components/AttributeRow.mjs +59 -9
- package/dist/admin/components/AttributeRow.mjs.map +1 -1
- package/dist/admin/components/FormModal/FormModal.js +134 -3
- package/dist/admin/components/FormModal/FormModal.js.map +1 -1
- package/dist/admin/components/FormModal/FormModal.mjs +137 -5
- package/dist/admin/components/FormModal/FormModal.mjs.map +1 -1
- package/dist/admin/components/FormModal/attributes/ConditionForm.js +448 -0
- package/dist/admin/components/FormModal/attributes/ConditionForm.js.map +1 -0
- package/dist/admin/components/FormModal/attributes/ConditionForm.mjs +428 -0
- package/dist/admin/components/FormModal/attributes/ConditionForm.mjs.map +1 -0
- package/dist/admin/components/FormModal/attributes/advancedForm.js +55 -16
- package/dist/admin/components/FormModal/attributes/advancedForm.js.map +1 -1
- package/dist/admin/components/FormModal/attributes/advancedForm.mjs +55 -16
- package/dist/admin/components/FormModal/attributes/advancedForm.mjs.map +1 -1
- package/dist/admin/components/FormModal/forms/forms.js +3 -1
- package/dist/admin/components/FormModal/forms/forms.js.map +1 -1
- package/dist/admin/components/FormModal/forms/forms.mjs +3 -1
- package/dist/admin/components/FormModal/forms/forms.mjs.map +1 -1
- package/dist/admin/components/GenericInputs.js +5 -2
- package/dist/admin/components/GenericInputs.js.map +1 -1
- package/dist/admin/components/GenericInputs.mjs +5 -2
- package/dist/admin/components/GenericInputs.mjs.map +1 -1
- package/dist/admin/components/TabForm.js +88 -0
- package/dist/admin/components/TabForm.js.map +1 -1
- package/dist/admin/components/TabForm.mjs +89 -1
- package/dist/admin/components/TabForm.mjs.map +1 -1
- package/dist/admin/src/components/ApplyConditionButton.d.ts +8 -0
- package/dist/admin/src/components/FormModal/attributes/ConditionForm.d.ts +23 -0
- package/dist/admin/src/components/FormModal/attributes/advancedForm.d.ts +288 -8
- package/dist/admin/src/components/FormModal/attributes/form.d.ts +288 -8
- package/dist/admin/src/components/GenericInputs.d.ts +30 -3
- package/dist/admin/src/utils/conditions.d.ts +17 -0
- package/dist/admin/translations/en.json.js +24 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +24 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/utils/conditions.js +61 -0
- package/dist/admin/utils/conditions.js.map +1 -0
- package/dist/admin/utils/conditions.mjs +57 -0
- package/dist/admin/utils/conditions.mjs.map +1 -0
- package/dist/server/controllers/validation/schema.js +11 -2
- package/dist/server/controllers/validation/schema.js.map +1 -1
- package/dist/server/controllers/validation/schema.mjs +11 -2
- package/dist/server/controllers/validation/schema.mjs.map +1 -1
- package/dist/server/src/controllers/validation/schema.d.ts +25728 -0
- package/dist/server/src/controllers/validation/schema.d.ts.map +1 -1
- package/dist/server/src/services/schema.d.ts +1302 -0
- package/dist/server/src/services/schema.d.ts.map +1 -1
- package/dist/server/src/utils/attributes.d.ts +210 -0
- package/dist/server/src/utils/attributes.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
export declare const attributesForm: {
|
|
2
2
|
advanced: {
|
|
3
3
|
blocks(): {
|
|
4
|
-
sections: {
|
|
4
|
+
sections: ({
|
|
5
|
+
sectionTitle: {
|
|
6
|
+
id: string;
|
|
7
|
+
defaultMessage: string;
|
|
8
|
+
};
|
|
9
|
+
intlLabel: {
|
|
10
|
+
id: string;
|
|
11
|
+
defaultMessage: string;
|
|
12
|
+
};
|
|
13
|
+
items: {
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
intlLabel: {
|
|
17
|
+
id: string;
|
|
18
|
+
defaultMessage: string;
|
|
19
|
+
};
|
|
20
|
+
validations: {
|
|
21
|
+
required: boolean;
|
|
22
|
+
};
|
|
23
|
+
}[];
|
|
24
|
+
} | {
|
|
5
25
|
sectionTitle: {
|
|
6
26
|
id: string;
|
|
7
27
|
defaultMessage: string;
|
|
@@ -18,10 +38,30 @@ export declare const attributesForm: {
|
|
|
18
38
|
defaultMessage: string;
|
|
19
39
|
};
|
|
20
40
|
}[];
|
|
21
|
-
}[];
|
|
41
|
+
})[];
|
|
22
42
|
};
|
|
23
43
|
boolean(): {
|
|
24
44
|
sections: ({
|
|
45
|
+
sectionTitle: {
|
|
46
|
+
id: string;
|
|
47
|
+
defaultMessage: string;
|
|
48
|
+
};
|
|
49
|
+
intlLabel: {
|
|
50
|
+
id: string;
|
|
51
|
+
defaultMessage: string;
|
|
52
|
+
};
|
|
53
|
+
items: {
|
|
54
|
+
name: string;
|
|
55
|
+
type: string;
|
|
56
|
+
intlLabel: {
|
|
57
|
+
id: string;
|
|
58
|
+
defaultMessage: string;
|
|
59
|
+
};
|
|
60
|
+
validations: {
|
|
61
|
+
required: boolean;
|
|
62
|
+
};
|
|
63
|
+
}[];
|
|
64
|
+
} | {
|
|
25
65
|
sectionTitle: null;
|
|
26
66
|
items: {
|
|
27
67
|
autoFocus: boolean;
|
|
@@ -70,6 +110,26 @@ export declare const attributesForm: {
|
|
|
70
110
|
type: string;
|
|
71
111
|
}): {
|
|
72
112
|
sections: ({
|
|
113
|
+
sectionTitle: {
|
|
114
|
+
id: string;
|
|
115
|
+
defaultMessage: string;
|
|
116
|
+
};
|
|
117
|
+
intlLabel: {
|
|
118
|
+
id: string;
|
|
119
|
+
defaultMessage: string;
|
|
120
|
+
};
|
|
121
|
+
items: {
|
|
122
|
+
name: string;
|
|
123
|
+
type: string;
|
|
124
|
+
intlLabel: {
|
|
125
|
+
id: string;
|
|
126
|
+
defaultMessage: string;
|
|
127
|
+
};
|
|
128
|
+
validations: {
|
|
129
|
+
required: boolean;
|
|
130
|
+
};
|
|
131
|
+
}[];
|
|
132
|
+
} | {
|
|
73
133
|
sectionTitle: null;
|
|
74
134
|
items: {
|
|
75
135
|
type: string;
|
|
@@ -103,11 +163,15 @@ export declare const attributesForm: {
|
|
|
103
163
|
})[];
|
|
104
164
|
};
|
|
105
165
|
dynamiczone(): {
|
|
106
|
-
sections: {
|
|
166
|
+
sections: ({
|
|
107
167
|
sectionTitle: {
|
|
108
168
|
id: string;
|
|
109
169
|
defaultMessage: string;
|
|
110
170
|
};
|
|
171
|
+
intlLabel: {
|
|
172
|
+
id: string;
|
|
173
|
+
defaultMessage: string;
|
|
174
|
+
};
|
|
111
175
|
items: {
|
|
112
176
|
name: string;
|
|
113
177
|
type: string;
|
|
@@ -115,11 +179,47 @@ export declare const attributesForm: {
|
|
|
115
179
|
id: string;
|
|
116
180
|
defaultMessage: string;
|
|
117
181
|
};
|
|
182
|
+
validations: {
|
|
183
|
+
required: boolean;
|
|
184
|
+
};
|
|
118
185
|
}[];
|
|
119
|
-
}
|
|
186
|
+
} | {
|
|
187
|
+
sectionTitle: {
|
|
188
|
+
id: string;
|
|
189
|
+
defaultMessage: string;
|
|
190
|
+
};
|
|
191
|
+
items: {
|
|
192
|
+
name: string;
|
|
193
|
+
type: string;
|
|
194
|
+
intlLabel: {
|
|
195
|
+
id: string;
|
|
196
|
+
defaultMessage: string;
|
|
197
|
+
};
|
|
198
|
+
}[];
|
|
199
|
+
})[];
|
|
120
200
|
};
|
|
121
201
|
email(): {
|
|
122
202
|
sections: ({
|
|
203
|
+
sectionTitle: {
|
|
204
|
+
id: string;
|
|
205
|
+
defaultMessage: string;
|
|
206
|
+
};
|
|
207
|
+
intlLabel: {
|
|
208
|
+
id: string;
|
|
209
|
+
defaultMessage: string;
|
|
210
|
+
};
|
|
211
|
+
items: {
|
|
212
|
+
name: string;
|
|
213
|
+
type: string;
|
|
214
|
+
intlLabel: {
|
|
215
|
+
id: string;
|
|
216
|
+
defaultMessage: string;
|
|
217
|
+
};
|
|
218
|
+
validations: {
|
|
219
|
+
required: boolean;
|
|
220
|
+
};
|
|
221
|
+
}[];
|
|
222
|
+
} | {
|
|
123
223
|
sectionTitle: null;
|
|
124
224
|
items: {
|
|
125
225
|
type: string;
|
|
@@ -148,6 +248,26 @@ export declare const attributesForm: {
|
|
|
148
248
|
enum: string[];
|
|
149
249
|
}): {
|
|
150
250
|
sections: ({
|
|
251
|
+
sectionTitle: {
|
|
252
|
+
id: string;
|
|
253
|
+
defaultMessage: string;
|
|
254
|
+
};
|
|
255
|
+
intlLabel: {
|
|
256
|
+
id: string;
|
|
257
|
+
defaultMessage: string;
|
|
258
|
+
};
|
|
259
|
+
items: {
|
|
260
|
+
name: string;
|
|
261
|
+
type: string;
|
|
262
|
+
intlLabel: {
|
|
263
|
+
id: string;
|
|
264
|
+
defaultMessage: string;
|
|
265
|
+
};
|
|
266
|
+
validations: {
|
|
267
|
+
required: boolean;
|
|
268
|
+
};
|
|
269
|
+
}[];
|
|
270
|
+
} | {
|
|
151
271
|
sectionTitle: null;
|
|
152
272
|
items: ({
|
|
153
273
|
name: string;
|
|
@@ -202,7 +322,27 @@ export declare const attributesForm: {
|
|
|
202
322
|
})[];
|
|
203
323
|
};
|
|
204
324
|
json(): {
|
|
205
|
-
sections: {
|
|
325
|
+
sections: ({
|
|
326
|
+
sectionTitle: {
|
|
327
|
+
id: string;
|
|
328
|
+
defaultMessage: string;
|
|
329
|
+
};
|
|
330
|
+
intlLabel: {
|
|
331
|
+
id: string;
|
|
332
|
+
defaultMessage: string;
|
|
333
|
+
};
|
|
334
|
+
items: {
|
|
335
|
+
name: string;
|
|
336
|
+
type: string;
|
|
337
|
+
intlLabel: {
|
|
338
|
+
id: string;
|
|
339
|
+
defaultMessage: string;
|
|
340
|
+
};
|
|
341
|
+
validations: {
|
|
342
|
+
required: boolean;
|
|
343
|
+
};
|
|
344
|
+
}[];
|
|
345
|
+
} | {
|
|
206
346
|
sectionTitle: {
|
|
207
347
|
id: string;
|
|
208
348
|
defaultMessage: string;
|
|
@@ -219,10 +359,30 @@ export declare const attributesForm: {
|
|
|
219
359
|
defaultMessage: string;
|
|
220
360
|
};
|
|
221
361
|
}[];
|
|
222
|
-
}[];
|
|
362
|
+
})[];
|
|
223
363
|
};
|
|
224
364
|
media(): {
|
|
225
365
|
sections: ({
|
|
366
|
+
sectionTitle: {
|
|
367
|
+
id: string;
|
|
368
|
+
defaultMessage: string;
|
|
369
|
+
};
|
|
370
|
+
intlLabel: {
|
|
371
|
+
id: string;
|
|
372
|
+
defaultMessage: string;
|
|
373
|
+
};
|
|
374
|
+
items: {
|
|
375
|
+
name: string;
|
|
376
|
+
type: string;
|
|
377
|
+
intlLabel: {
|
|
378
|
+
id: string;
|
|
379
|
+
defaultMessage: string;
|
|
380
|
+
};
|
|
381
|
+
validations: {
|
|
382
|
+
required: boolean;
|
|
383
|
+
};
|
|
384
|
+
}[];
|
|
385
|
+
} | {
|
|
226
386
|
sectionTitle: null;
|
|
227
387
|
items: {
|
|
228
388
|
intlLabel: {
|
|
@@ -258,6 +418,26 @@ export declare const attributesForm: {
|
|
|
258
418
|
type: "string" | "decimal" | "biginteger" | "float" | "integer";
|
|
259
419
|
}): {
|
|
260
420
|
sections: ({
|
|
421
|
+
sectionTitle: {
|
|
422
|
+
id: string;
|
|
423
|
+
defaultMessage: string;
|
|
424
|
+
};
|
|
425
|
+
intlLabel: {
|
|
426
|
+
id: string;
|
|
427
|
+
defaultMessage: string;
|
|
428
|
+
};
|
|
429
|
+
items: {
|
|
430
|
+
name: string;
|
|
431
|
+
type: string;
|
|
432
|
+
intlLabel: {
|
|
433
|
+
id: string;
|
|
434
|
+
defaultMessage: string;
|
|
435
|
+
};
|
|
436
|
+
validations: {
|
|
437
|
+
required: boolean;
|
|
438
|
+
};
|
|
439
|
+
}[];
|
|
440
|
+
} | {
|
|
261
441
|
sectionTitle: null;
|
|
262
442
|
items: {
|
|
263
443
|
autoFocus: boolean;
|
|
@@ -287,6 +467,26 @@ export declare const attributesForm: {
|
|
|
287
467
|
};
|
|
288
468
|
password(): {
|
|
289
469
|
sections: ({
|
|
470
|
+
sectionTitle: {
|
|
471
|
+
id: string;
|
|
472
|
+
defaultMessage: string;
|
|
473
|
+
};
|
|
474
|
+
intlLabel: {
|
|
475
|
+
id: string;
|
|
476
|
+
defaultMessage: string;
|
|
477
|
+
};
|
|
478
|
+
items: {
|
|
479
|
+
name: string;
|
|
480
|
+
type: string;
|
|
481
|
+
intlLabel: {
|
|
482
|
+
id: string;
|
|
483
|
+
defaultMessage: string;
|
|
484
|
+
};
|
|
485
|
+
validations: {
|
|
486
|
+
required: boolean;
|
|
487
|
+
};
|
|
488
|
+
}[];
|
|
489
|
+
} | {
|
|
290
490
|
sectionTitle: null;
|
|
291
491
|
items: {
|
|
292
492
|
name: string;
|
|
@@ -312,7 +512,27 @@ export declare const attributesForm: {
|
|
|
312
512
|
})[];
|
|
313
513
|
};
|
|
314
514
|
relation(): {
|
|
315
|
-
sections: {
|
|
515
|
+
sections: ({
|
|
516
|
+
sectionTitle: {
|
|
517
|
+
id: string;
|
|
518
|
+
defaultMessage: string;
|
|
519
|
+
};
|
|
520
|
+
intlLabel: {
|
|
521
|
+
id: string;
|
|
522
|
+
defaultMessage: string;
|
|
523
|
+
};
|
|
524
|
+
items: {
|
|
525
|
+
name: string;
|
|
526
|
+
type: string;
|
|
527
|
+
intlLabel: {
|
|
528
|
+
id: string;
|
|
529
|
+
defaultMessage: string;
|
|
530
|
+
};
|
|
531
|
+
validations: {
|
|
532
|
+
required: boolean;
|
|
533
|
+
};
|
|
534
|
+
}[];
|
|
535
|
+
} | {
|
|
316
536
|
sectionTitle: {
|
|
317
537
|
id: string;
|
|
318
538
|
defaultMessage: string;
|
|
@@ -329,10 +549,30 @@ export declare const attributesForm: {
|
|
|
329
549
|
defaultMessage: string;
|
|
330
550
|
};
|
|
331
551
|
}[];
|
|
332
|
-
}[];
|
|
552
|
+
})[];
|
|
333
553
|
};
|
|
334
554
|
richtext(): {
|
|
335
555
|
sections: ({
|
|
556
|
+
sectionTitle: {
|
|
557
|
+
id: string;
|
|
558
|
+
defaultMessage: string;
|
|
559
|
+
};
|
|
560
|
+
intlLabel: {
|
|
561
|
+
id: string;
|
|
562
|
+
defaultMessage: string;
|
|
563
|
+
};
|
|
564
|
+
items: {
|
|
565
|
+
name: string;
|
|
566
|
+
type: string;
|
|
567
|
+
intlLabel: {
|
|
568
|
+
id: string;
|
|
569
|
+
defaultMessage: string;
|
|
570
|
+
};
|
|
571
|
+
validations: {
|
|
572
|
+
required: boolean;
|
|
573
|
+
};
|
|
574
|
+
}[];
|
|
575
|
+
} | {
|
|
336
576
|
sectionTitle: null;
|
|
337
577
|
items: {
|
|
338
578
|
name: string;
|
|
@@ -359,6 +599,26 @@ export declare const attributesForm: {
|
|
|
359
599
|
};
|
|
360
600
|
text(): {
|
|
361
601
|
sections: ({
|
|
602
|
+
sectionTitle: {
|
|
603
|
+
id: string;
|
|
604
|
+
defaultMessage: string;
|
|
605
|
+
};
|
|
606
|
+
intlLabel: {
|
|
607
|
+
id: string;
|
|
608
|
+
defaultMessage: string;
|
|
609
|
+
};
|
|
610
|
+
items: {
|
|
611
|
+
name: string;
|
|
612
|
+
type: string;
|
|
613
|
+
intlLabel: {
|
|
614
|
+
id: string;
|
|
615
|
+
defaultMessage: string;
|
|
616
|
+
};
|
|
617
|
+
validations: {
|
|
618
|
+
required: boolean;
|
|
619
|
+
};
|
|
620
|
+
}[];
|
|
621
|
+
} | {
|
|
362
622
|
sectionTitle: null;
|
|
363
623
|
items: {
|
|
364
624
|
name: string;
|
|
@@ -387,6 +647,26 @@ export declare const attributesForm: {
|
|
|
387
647
|
targetField: string;
|
|
388
648
|
}): {
|
|
389
649
|
sections: ({
|
|
650
|
+
sectionTitle: {
|
|
651
|
+
id: string;
|
|
652
|
+
defaultMessage: string;
|
|
653
|
+
};
|
|
654
|
+
intlLabel: {
|
|
655
|
+
id: string;
|
|
656
|
+
defaultMessage: string;
|
|
657
|
+
};
|
|
658
|
+
items: {
|
|
659
|
+
name: string;
|
|
660
|
+
type: string;
|
|
661
|
+
intlLabel: {
|
|
662
|
+
id: string;
|
|
663
|
+
defaultMessage: string;
|
|
664
|
+
};
|
|
665
|
+
validations: {
|
|
666
|
+
required: boolean;
|
|
667
|
+
};
|
|
668
|
+
}[];
|
|
669
|
+
} | {
|
|
390
670
|
sectionTitle: null;
|
|
391
671
|
items: {
|
|
392
672
|
disabled: boolean;
|
|
@@ -18,9 +18,33 @@ interface InputOption {
|
|
|
18
18
|
key: string;
|
|
19
19
|
value: string;
|
|
20
20
|
}
|
|
21
|
-
interface CustomInputProps<TAttribute extends Schema.Attribute.AnyAttribute
|
|
22
|
-
|
|
21
|
+
interface CustomInputProps<TAttribute extends Schema.Attribute.AnyAttribute = Schema.Attribute.AnyAttribute> {
|
|
22
|
+
attribute?: TAttribute;
|
|
23
|
+
autoComplete?: string;
|
|
24
|
+
description?: TranslationMessage;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
error?: string;
|
|
23
27
|
hint?: string | React.JSX.Element | (string | React.JSX.Element)[];
|
|
28
|
+
intlLabel: TranslationMessage;
|
|
29
|
+
labelAction?: React.ReactNode;
|
|
30
|
+
name: string;
|
|
31
|
+
onChange: (payload: {
|
|
32
|
+
target: {
|
|
33
|
+
name: string;
|
|
34
|
+
value: Schema.Attribute.Value<TAttribute>;
|
|
35
|
+
type?: string;
|
|
36
|
+
};
|
|
37
|
+
}, shouldSetInitialValue?: boolean) => void;
|
|
38
|
+
onDelete?: () => void;
|
|
39
|
+
options?: InputOption[];
|
|
40
|
+
placeholder?: TranslationMessage;
|
|
41
|
+
required?: boolean;
|
|
42
|
+
step?: number;
|
|
43
|
+
type: string;
|
|
44
|
+
value?: Schema.Attribute.Value<TAttribute>;
|
|
45
|
+
autoFocus?: boolean;
|
|
46
|
+
attributeName?: string;
|
|
47
|
+
conditionFields?: Record<string, boolean>;
|
|
24
48
|
}
|
|
25
49
|
interface GenericInputProps<TAttribute extends Schema.Attribute.AnyAttribute = Schema.Attribute.AnyAttribute> {
|
|
26
50
|
attribute?: TAttribute;
|
|
@@ -39,6 +63,7 @@ interface GenericInputProps<TAttribute extends Schema.Attribute.AnyAttribute = S
|
|
|
39
63
|
type?: string;
|
|
40
64
|
};
|
|
41
65
|
}, shouldSetInitialValue?: boolean) => void;
|
|
66
|
+
onDelete?: () => void;
|
|
42
67
|
options?: InputOption[];
|
|
43
68
|
placeholder?: TranslationMessage;
|
|
44
69
|
required?: boolean;
|
|
@@ -47,12 +72,14 @@ interface GenericInputProps<TAttribute extends Schema.Attribute.AnyAttribute = S
|
|
|
47
72
|
value?: Schema.Attribute.Value<TAttribute>;
|
|
48
73
|
isNullable?: boolean;
|
|
49
74
|
autoFocus?: boolean;
|
|
75
|
+
attributeName?: string;
|
|
76
|
+
conditionFields?: Record<string, boolean>;
|
|
50
77
|
}
|
|
51
78
|
/**
|
|
52
79
|
* we've memoized this component because we use a context to store all the data in our form in the content-manager.
|
|
53
80
|
* This then causes _every_ component to re-render because there are no selects incurring performance issues
|
|
54
81
|
* in content-types as the content-type gets more complicated.
|
|
55
82
|
*/
|
|
56
|
-
declare const MemoizedGenericInput: React.MemoExoticComponent<({ autoComplete, customInputs, description, disabled, intlLabel, labelAction, error, name, onChange, options, placeholder, required, step, type, value: defaultValue, isNullable, autoFocus, attribute, ...rest }: GenericInputProps) => import("react/jsx-runtime").JSX.Element>;
|
|
83
|
+
declare const MemoizedGenericInput: React.MemoExoticComponent<({ autoComplete, customInputs, description, disabled, intlLabel, labelAction, error, name, onChange, onDelete, options, placeholder, required, step, type, value: defaultValue, isNullable, autoFocus, attribute, attributeName, conditionFields, ...rest }: GenericInputProps) => import("react/jsx-runtime").JSX.Element>;
|
|
57
84
|
export type { GenericInputProps, CustomInputProps };
|
|
58
85
|
export { MemoizedGenericInput as GenericInput };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AnyAttribute } from '../types';
|
|
2
|
+
interface DependentRow {
|
|
3
|
+
contentTypeUid: string;
|
|
4
|
+
contentType: string;
|
|
5
|
+
attribute: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const checkDependentRows: (contentTypes: Record<string, any>, fieldName: string) => DependentRow[];
|
|
8
|
+
export declare const formatCondition: (condition: any, availableFields: Array<{
|
|
9
|
+
name: string;
|
|
10
|
+
type: string;
|
|
11
|
+
}>, attributeName: string) => string;
|
|
12
|
+
export declare const getAvailableConditionFields: (attributes: AnyAttribute[], currentFieldName: string) => {
|
|
13
|
+
name: string;
|
|
14
|
+
type: "string" | "boolean" | "time" | "media" | "text" | "date" | "email" | "password" | "decimal" | "component" | "relation" | "biginteger" | "blocks" | "datetime" | "dynamiczone" | "enumeration" | "float" | "integer" | "json" | "richtext" | "timestamp" | "uid";
|
|
15
|
+
enum: string[] | undefined;
|
|
16
|
+
}[];
|
|
17
|
+
export {};
|
|
@@ -128,6 +128,27 @@ var en = {
|
|
|
128
128
|
"form.attribute.text.option.long-text.description": "Best for descriptions, biography. Exact search is disabled.",
|
|
129
129
|
"form.attribute.text.option.short-text": "Short text",
|
|
130
130
|
"form.attribute.text.option.short-text.description": "Best for titles, names, links (URL). It also enables exact search on the field.",
|
|
131
|
+
"form.attribute.condition.title": "Condition",
|
|
132
|
+
"form.attribute.condition.description": "Toggle field settings depending on the value of another boolean or enumeration field.",
|
|
133
|
+
"form.attribute.condition.label": "Conditions",
|
|
134
|
+
"form.attribute.condition.field": "Field",
|
|
135
|
+
"form.attribute.condition.operator": "Operator",
|
|
136
|
+
"form.attribute.condition.value": "Value",
|
|
137
|
+
"form.attribute.condition.operator.is": "is",
|
|
138
|
+
"form.attribute.condition.operator.isNot": "is not",
|
|
139
|
+
"form.attribute.condition.value.true": "true",
|
|
140
|
+
"form.attribute.condition.value.false": "false",
|
|
141
|
+
"form.attribute.condition.apply": "Apply condition",
|
|
142
|
+
"form.attribute.condition.then": "Then",
|
|
143
|
+
"form.attribute.condition.action": "Action",
|
|
144
|
+
"form.attribute.condition.action.show": "Show",
|
|
145
|
+
"form.attribute.condition.action.hide": "Hide",
|
|
146
|
+
"form.attribute.condition.no-fields": "No boolean or enumeration fields available to set conditions on.",
|
|
147
|
+
"form.attribute.condition.enum-change-warning": "The following fields have conditions that depend on this field: {fieldNames}. Changing or removing the enum values {values} will break these conditions. Do you want to proceed?",
|
|
148
|
+
"form.attribute.condition.enum-change-warning-values": ". Changing or removing the enum values ",
|
|
149
|
+
"form.attribute.condition.enum-change-warning-end": " will break these conditions. Do you want to proceed?",
|
|
150
|
+
"form.attribute.condition.field-change-warning": "The following fields have conditions that depend on this field: {fieldNames}. Renaming it will break these conditions. Do you want to proceed?",
|
|
151
|
+
"form.attribute.condition.field-change-warning-end": ". Renaming it will break these conditions. Do you want to proceed?",
|
|
131
152
|
"form.button.add-components-to-dynamiczone": "Add components to the zone",
|
|
132
153
|
"form.button.add-field": "Add another field",
|
|
133
154
|
"form.button.add-first-field-to-created-component": "Add first field to the component",
|
|
@@ -196,6 +217,9 @@ var en = {
|
|
|
196
217
|
"popUpWarning.draft-publish.message": "If you disable the Draft & publish, your drafts will be deleted.",
|
|
197
218
|
"popUpWarning.draft-publish.second-message": "Are you sure you want to disable it?",
|
|
198
219
|
"popUpWarning.discardAll.message": "Are you sure you want to discard all changes?",
|
|
220
|
+
"popUpWarning.bodyMessage.delete-condition": "Are you sure you want to delete this condition?",
|
|
221
|
+
"popUpWarning.bodyMessage.delete-attribute-with-conditions": "The following fields have conditions that depend on this field: ",
|
|
222
|
+
"popUpWarning.bodyMessage.delete-attribute-with-conditions-end": ". Are you sure you want to delete it?",
|
|
199
223
|
"prompt.unsaved": "Are you sure you want to leave? All your modifications will be lost.",
|
|
200
224
|
"relation.attributeName.placeholder": "Ex: author, category, tag",
|
|
201
225
|
"relation.manyToMany": "has and belongs to many",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -124,6 +124,27 @@ var en = {
|
|
|
124
124
|
"form.attribute.text.option.long-text.description": "Best for descriptions, biography. Exact search is disabled.",
|
|
125
125
|
"form.attribute.text.option.short-text": "Short text",
|
|
126
126
|
"form.attribute.text.option.short-text.description": "Best for titles, names, links (URL). It also enables exact search on the field.",
|
|
127
|
+
"form.attribute.condition.title": "Condition",
|
|
128
|
+
"form.attribute.condition.description": "Toggle field settings depending on the value of another boolean or enumeration field.",
|
|
129
|
+
"form.attribute.condition.label": "Conditions",
|
|
130
|
+
"form.attribute.condition.field": "Field",
|
|
131
|
+
"form.attribute.condition.operator": "Operator",
|
|
132
|
+
"form.attribute.condition.value": "Value",
|
|
133
|
+
"form.attribute.condition.operator.is": "is",
|
|
134
|
+
"form.attribute.condition.operator.isNot": "is not",
|
|
135
|
+
"form.attribute.condition.value.true": "true",
|
|
136
|
+
"form.attribute.condition.value.false": "false",
|
|
137
|
+
"form.attribute.condition.apply": "Apply condition",
|
|
138
|
+
"form.attribute.condition.then": "Then",
|
|
139
|
+
"form.attribute.condition.action": "Action",
|
|
140
|
+
"form.attribute.condition.action.show": "Show",
|
|
141
|
+
"form.attribute.condition.action.hide": "Hide",
|
|
142
|
+
"form.attribute.condition.no-fields": "No boolean or enumeration fields available to set conditions on.",
|
|
143
|
+
"form.attribute.condition.enum-change-warning": "The following fields have conditions that depend on this field: {fieldNames}. Changing or removing the enum values {values} will break these conditions. Do you want to proceed?",
|
|
144
|
+
"form.attribute.condition.enum-change-warning-values": ". Changing or removing the enum values ",
|
|
145
|
+
"form.attribute.condition.enum-change-warning-end": " will break these conditions. Do you want to proceed?",
|
|
146
|
+
"form.attribute.condition.field-change-warning": "The following fields have conditions that depend on this field: {fieldNames}. Renaming it will break these conditions. Do you want to proceed?",
|
|
147
|
+
"form.attribute.condition.field-change-warning-end": ". Renaming it will break these conditions. Do you want to proceed?",
|
|
127
148
|
"form.button.add-components-to-dynamiczone": "Add components to the zone",
|
|
128
149
|
"form.button.add-field": "Add another field",
|
|
129
150
|
"form.button.add-first-field-to-created-component": "Add first field to the component",
|
|
@@ -192,6 +213,9 @@ var en = {
|
|
|
192
213
|
"popUpWarning.draft-publish.message": "If you disable the Draft & publish, your drafts will be deleted.",
|
|
193
214
|
"popUpWarning.draft-publish.second-message": "Are you sure you want to disable it?",
|
|
194
215
|
"popUpWarning.discardAll.message": "Are you sure you want to discard all changes?",
|
|
216
|
+
"popUpWarning.bodyMessage.delete-condition": "Are you sure you want to delete this condition?",
|
|
217
|
+
"popUpWarning.bodyMessage.delete-attribute-with-conditions": "The following fields have conditions that depend on this field: ",
|
|
218
|
+
"popUpWarning.bodyMessage.delete-attribute-with-conditions-end": ". Are you sure you want to delete it?",
|
|
195
219
|
"prompt.unsaved": "Are you sure you want to leave? All your modifications will be lost.",
|
|
196
220
|
"relation.attributeName.placeholder": "Ex: author, category, tag",
|
|
197
221
|
"relation.manyToMany": "has and belongs to many",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"en.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const checkDependentRows = (contentTypes, fieldName)=>{
|
|
4
|
+
const dependentRows = [];
|
|
5
|
+
Object.entries(contentTypes).forEach(([contentTypeUid, contentType])=>{
|
|
6
|
+
if (contentType.attributes) {
|
|
7
|
+
// Handle both array and object formats of attributes
|
|
8
|
+
const attributes = Array.isArray(contentType.attributes) ? contentType.attributes.reduce((acc, attr, index)=>{
|
|
9
|
+
acc[index.toString()] = attr;
|
|
10
|
+
return acc;
|
|
11
|
+
}, {}) : contentType.attributes;
|
|
12
|
+
Object.entries(attributes).forEach(([attrName, attr])=>{
|
|
13
|
+
if (attr.conditions?.visible) {
|
|
14
|
+
Object.entries(attr.conditions.visible).forEach(([, conditions])=>{
|
|
15
|
+
const [fieldVar] = conditions;
|
|
16
|
+
// Check if this condition references our field
|
|
17
|
+
if (fieldVar && fieldVar.var === fieldName) {
|
|
18
|
+
dependentRows.push({
|
|
19
|
+
contentTypeUid,
|
|
20
|
+
contentType: contentType.info.displayName,
|
|
21
|
+
attribute: attr.name || attrName
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return dependentRows;
|
|
30
|
+
};
|
|
31
|
+
const formatCondition = (condition, availableFields, attributeName)=>{
|
|
32
|
+
if (!condition?.visible) {
|
|
33
|
+
return '';
|
|
34
|
+
}
|
|
35
|
+
const [[operator, conditions]] = Object.entries(condition.visible);
|
|
36
|
+
const [fieldVar, value] = conditions;
|
|
37
|
+
const dependsOnField = availableFields.find((field)=>field.name === fieldVar.var);
|
|
38
|
+
const dependsOnFieldName = dependsOnField ? dependsOnField.name : fieldVar.var;
|
|
39
|
+
const operatorText = operator === '==' ? 'is' : 'is not';
|
|
40
|
+
const valueText = String(value);
|
|
41
|
+
const actionText = operator === '==' ? 'Show' : 'Hide';
|
|
42
|
+
return `If ${dependsOnFieldName} ${operatorText} ${valueText}, then ${actionText} ${attributeName}`;
|
|
43
|
+
};
|
|
44
|
+
const getAvailableConditionFields = (attributes, currentFieldName)=>{
|
|
45
|
+
return attributes.filter((attr)=>{
|
|
46
|
+
// Only include boolean and enum fields
|
|
47
|
+
const isCorrectType = attr.type === 'boolean' || attr.type === 'enumeration';
|
|
48
|
+
// Exclude the current field to prevent self-referential conditions
|
|
49
|
+
const isNotCurrentField = attr.name !== currentFieldName;
|
|
50
|
+
return isCorrectType && isNotCurrentField;
|
|
51
|
+
}).map((attr)=>({
|
|
52
|
+
name: attr.name,
|
|
53
|
+
type: attr.type,
|
|
54
|
+
enum: attr.type === 'enumeration' ? attr.enum : undefined
|
|
55
|
+
}));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.checkDependentRows = checkDependentRows;
|
|
59
|
+
exports.formatCondition = formatCondition;
|
|
60
|
+
exports.getAvailableConditionFields = getAvailableConditionFields;
|
|
61
|
+
//# sourceMappingURL=conditions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditions.js","sources":["../../../admin/src/utils/conditions.ts"],"sourcesContent":["import type { AnyAttribute } from '../types';\n\ninterface DependentRow {\n contentTypeUid: string;\n contentType: string;\n attribute: string;\n}\n\nexport const checkDependentRows = (\n contentTypes: Record<string, any>,\n fieldName: string\n): DependentRow[] => {\n const dependentRows: DependentRow[] = [];\n\n Object.entries(contentTypes).forEach(([contentTypeUid, contentType]: [string, any]) => {\n if (contentType.attributes) {\n // Handle both array and object formats of attributes\n const attributes = Array.isArray(contentType.attributes)\n ? contentType.attributes.reduce((acc: Record<string, any>, attr: any, index: number) => {\n acc[index.toString()] = attr;\n return acc;\n }, {})\n : contentType.attributes;\n\n Object.entries(attributes).forEach(([attrName, attr]: [string, any]) => {\n if (attr.conditions?.visible) {\n Object.entries(attr.conditions.visible).forEach(([, conditions]) => {\n const [fieldVar] = conditions as [{ var: string }, any];\n // Check if this condition references our field\n if (fieldVar && fieldVar.var === fieldName) {\n dependentRows.push({\n contentTypeUid,\n contentType: contentType.info.displayName,\n attribute: attr.name || attrName,\n });\n }\n });\n }\n });\n }\n });\n return dependentRows;\n};\n\nexport const formatCondition = (\n condition: any,\n availableFields: Array<{ name: string; type: string }>,\n attributeName: string\n): string => {\n if (!condition?.visible) {\n return '';\n }\n\n const [[operator, conditions]] = Object.entries(condition.visible);\n const [fieldVar, value] = conditions as [{ var: string }, any];\n\n const dependsOnField = availableFields.find((field) => field.name === fieldVar.var);\n const dependsOnFieldName = dependsOnField ? dependsOnField.name : fieldVar.var;\n\n const operatorText = operator === '==' ? 'is' : 'is not';\n const valueText = String(value);\n const actionText = operator === '==' ? 'Show' : 'Hide';\n\n return `If ${dependsOnFieldName} ${operatorText} ${valueText}, then ${actionText} ${attributeName}`;\n};\n\nexport const getAvailableConditionFields = (\n attributes: AnyAttribute[],\n currentFieldName: string\n) => {\n return attributes\n .filter((attr) => {\n // Only include boolean and enum fields\n const isCorrectType = attr.type === 'boolean' || attr.type === 'enumeration';\n // Exclude the current field to prevent self-referential conditions\n const isNotCurrentField = attr.name !== currentFieldName;\n return isCorrectType && isNotCurrentField;\n })\n .map((attr) => ({\n name: attr.name,\n type: attr.type,\n enum: attr.type === 'enumeration' ? attr.enum : undefined,\n }));\n};\n"],"names":["checkDependentRows","contentTypes","fieldName","dependentRows","Object","entries","forEach","contentTypeUid","contentType","attributes","Array","isArray","reduce","acc","attr","index","toString","attrName","conditions","visible","fieldVar","var","push","info","displayName","attribute","name","formatCondition","condition","availableFields","attributeName","operator","value","dependsOnField","find","field","dependsOnFieldName","operatorText","valueText","String","actionText","getAvailableConditionFields","currentFieldName","filter","isCorrectType","type","isNotCurrentField","map","enum","und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