|
196 | 196 | * Common field properties that are shared among all field types. |
197 | 197 | * @typedef {object} CommonFieldProps |
198 | 198 | * @property {string} name Unique identifier for the field. It cannot include periods and spaces. |
| 199 | + */ |
| 200 | + |
| 201 | +/** |
| 202 | + * Standard field properties for a built-in widget. |
| 203 | + * @typedef {object} StandardFieldProps |
199 | 204 | * @property {string} [label] Label of the field to be displayed in the editor UI. Default: `name` |
200 | 205 | * field value. |
201 | 206 | * @property {string} [comment] Short description of the field to be displayed in the editor UI. |
|
207 | 212 | * non-default like `false` but automatically copies the default locale’s value to other locales. |
208 | 213 | * `translate` and `none` are aliases of `true` and `false`, respectively. This option only works |
209 | 214 | * when i18n is set up with the global and collection-level `i18n` option. |
210 | | - * @see https://decapcms.org/docs/configuration-options/#fields |
211 | | - * @see https://decapcms.org/docs/widgets/ |
212 | | - */ |
213 | | - |
214 | | -/** |
215 | | - * Standard field properties for a built-in widget. |
216 | | - * @typedef {object} StandardFieldProps |
217 | 215 | * @property {boolean | LocaleCode[]} [required] Whether to make data input on the field required. |
218 | 216 | * Default: `true`. This option also affects data output if the `omit_empty_optional_fields` global |
219 | 217 | * output option is `true`. If i18n is enabled and the field doesn’t require input in all locales, |
220 | 218 | * required locale codes can be passed as an array like `[en, fr]` instead of a boolean. |
221 | 219 | * @property {boolean} [readonly] Whether to make the field read-only. Default: `false`. This is |
222 | 220 | * useful when a `default` value is provided and the field should not be editable by users. |
| 221 | + * @see https://decapcms.org/docs/configuration-options/#fields |
| 222 | + * @see https://decapcms.org/docs/widgets/ |
| 223 | + */ |
| 224 | + |
| 225 | +/** |
| 226 | + * Properties for a field that is visible in the editor UI. |
| 227 | + * @typedef {CommonFieldProps & StandardFieldProps} VisibleFieldProps |
| 228 | + */ |
| 229 | + |
| 230 | +/** |
| 231 | + * Field validation properties. |
| 232 | + * @typedef {object} FieldValidationProps |
223 | 233 | * @property {[string | RegExp, string]} [pattern] Validation format. The first argument is a |
224 | 234 | * regular expression matching pattern for a valid input value, and the second argument is an error |
225 | | - * message. This option has no effect on a List or Object field with subfields. |
| 235 | + * message to be displayed when the input value does not match the pattern. |
226 | 236 | */ |
227 | 237 |
|
228 | 238 | /** |
|
331 | 341 |
|
332 | 342 | /** |
333 | 343 | * Boolean field definition. |
334 | | - * @typedef {CommonFieldProps & StandardFieldProps & BooleanFieldProps & AdjacentLabelProps |
335 | | - * } BooleanField |
| 344 | + * @typedef {VisibleFieldProps & BooleanFieldProps & AdjacentLabelProps} BooleanField |
336 | 345 | */ |
337 | 346 |
|
338 | 347 | /** |
|
354 | 363 |
|
355 | 364 | /** |
356 | 365 | * Code field definition. |
357 | | - * @typedef {CommonFieldProps & StandardFieldProps & CodeFieldProps} CodeField |
| 366 | + * @typedef {VisibleFieldProps & FieldValidationProps & CodeFieldProps} CodeField |
358 | 367 | */ |
359 | 368 |
|
360 | 369 | /** |
|
371 | 380 |
|
372 | 381 | /** |
373 | 382 | * Color field definition. |
374 | | - * @typedef {CommonFieldProps & StandardFieldProps & ColorFieldProps} ColorField |
| 383 | + * @typedef {VisibleFieldProps & FieldValidationProps & ColorFieldProps} ColorField |
375 | 384 | */ |
376 | 385 |
|
377 | 386 | /** |
|
384 | 393 |
|
385 | 394 | /** |
386 | 395 | * Compute field definition. |
387 | | - * @typedef {CommonFieldProps & StandardFieldProps & ComputeFieldProps} ComputeField |
| 396 | + * @typedef {VisibleFieldProps & ComputeFieldProps} ComputeField |
388 | 397 | */ |
389 | 398 |
|
390 | 399 | /** |
|
409 | 418 |
|
410 | 419 | /** |
411 | 420 | * DateTime field definition. |
412 | | - * @typedef {CommonFieldProps & StandardFieldProps & DateTimeFieldProps} DateTimeField |
| 421 | + * @typedef {VisibleFieldProps & FieldValidationProps & DateTimeFieldProps} DateTimeField |
413 | 422 | */ |
414 | 423 |
|
415 | 424 | /** |
|
421 | 430 |
|
422 | 431 | /** |
423 | 432 | * File field definition. |
424 | | - * @typedef {CommonFieldProps & StandardFieldProps & MediaFieldProps & FileFieldProps} FileField |
| 433 | + * @typedef {VisibleFieldProps & FieldValidationProps & MediaFieldProps & FileFieldProps } FileField |
425 | 434 | */ |
426 | 435 |
|
427 | 436 | /** |
|
430 | 439 | * @property {'hidden'} widget Widget name. |
431 | 440 | * @property {any} [default] Default value. Accepts any data type that can be stored with the |
432 | 441 | * configured file format. |
| 442 | + * @property {false | 'duplicate'} [i18n] Whether to enable the field in locales other than the |
| 443 | + * default. Unlike other visible fields, hidden fields can be configured to be enabled in |
| 444 | + * non-default locales only when set to `duplicate`. In that case, the default locale’s value is |
| 445 | + * automatically copied to other locales. Default: `false`. This option only works when i18n is set |
| 446 | + * up with the global and collection-level `i18n` option. |
433 | 447 | * @see https://decapcms.org/docs/widgets/#Hidden |
434 | 448 | */ |
435 | 449 |
|
436 | 450 | /** |
437 | 451 | * Hidden field definition. |
438 | | - * @typedef {CommonFieldProps & StandardFieldProps & HiddenFieldProps} HiddenField |
| 452 | + * @typedef {CommonFieldProps & HiddenFieldProps} HiddenField |
439 | 453 | */ |
440 | 454 |
|
441 | 455 | /** |
|
447 | 461 |
|
448 | 462 | /** |
449 | 463 | * Image field definition. |
450 | | - * @typedef {CommonFieldProps & StandardFieldProps & MediaFieldProps & ImageFieldProps} ImageField |
| 464 | + * @typedef {VisibleFieldProps & FieldValidationProps & MediaFieldProps & ImageFieldProps |
| 465 | + * } ImageField |
451 | 466 | */ |
452 | 467 |
|
453 | 468 | /** |
|
462 | 477 |
|
463 | 478 | /** |
464 | 479 | * KeyValue field definition. |
465 | | - * @typedef {CommonFieldProps & StandardFieldProps & KeyValueFieldProps & MultiValueFieldProps |
466 | | - * } KeyValueField |
| 480 | + * @typedef {VisibleFieldProps & KeyValueFieldProps & MultiValueFieldProps} KeyValueField |
467 | 481 | */ |
468 | 482 |
|
469 | 483 | /** |
|
476 | 490 | * @see https://decapcms.org/docs/widgets/#List |
477 | 491 | */ |
478 | 492 |
|
| 493 | +/** |
| 494 | + * Base properties for a List field. |
| 495 | + * @typedef {VisibleFieldProps & ListFieldProps & MultiValueFieldProps} ListFieldBaseProps |
| 496 | + */ |
| 497 | + |
| 498 | +/** |
| 499 | + * Simple List field definition with primitive item types. |
| 500 | + * @typedef {ListFieldBaseProps & FieldValidationProps} SimpleListField |
| 501 | + */ |
| 502 | + |
479 | 503 | /** |
480 | 504 | * Base properties for a complex List field with subfields or variable types. |
481 | 505 | * @typedef {object} ComplexListFieldBaseProps |
|
506 | 530 | * details. |
507 | 531 | */ |
508 | 532 |
|
509 | | -/** |
510 | | - * Simple List field definition with primitive item types. |
511 | | - * @typedef {CommonFieldProps & StandardFieldProps & ListFieldProps & MultiValueFieldProps |
512 | | - * } SimpleListField |
513 | | - */ |
514 | | - |
515 | 533 | /** |
516 | 534 | * Properties for a complex List field with subfields or variable types. |
517 | | - * @typedef {SimpleListField & ComplexListFieldBaseProps} ComplexListFieldProps |
| 535 | + * @typedef {ListFieldBaseProps & ComplexListFieldBaseProps} ComplexListFieldProps |
518 | 536 | */ |
519 | 537 |
|
520 | 538 | /** |
|
568 | 586 |
|
569 | 587 | /** |
570 | 588 | * Map field definition. |
571 | | - * @typedef {CommonFieldProps & StandardFieldProps & MapFieldProps} MapField |
| 589 | + * @typedef {VisibleFieldProps & FieldValidationProps & MapFieldProps} MapField |
572 | 590 | */ |
573 | 591 |
|
574 | 592 | /** |
|
618 | 636 |
|
619 | 637 | /** |
620 | 638 | * Markdown field definition. |
621 | | - * @typedef {CommonFieldProps & StandardFieldProps & MarkdownFieldProps} MarkdownField |
| 639 | + * @typedef {VisibleFieldProps & FieldValidationProps & MarkdownFieldProps} MarkdownField |
622 | 640 | */ |
623 | 641 |
|
624 | 642 | /** |
|
635 | 653 |
|
636 | 654 | /** |
637 | 655 | * Number field definition. |
638 | | - * @typedef {CommonFieldProps & StandardFieldProps & NumberFieldProps & AdjacentLabelProps |
| 656 | + * @typedef {VisibleFieldProps & FieldValidationProps & NumberFieldProps & AdjacentLabelProps |
639 | 657 | * } NumberField |
640 | 658 | */ |
641 | 659 |
|
|
653 | 671 |
|
654 | 672 | /** |
655 | 673 | * Base properties for a complex Object field with subfields or variable types. |
656 | | - * @typedef {CommonFieldProps & StandardFieldProps & ObjectFieldProps} ComplexObjectFieldProps |
| 674 | + * @typedef {VisibleFieldProps & ObjectFieldProps} ComplexObjectFieldProps |
657 | 675 | */ |
658 | 676 |
|
659 | 677 | /** |
|
708 | 726 |
|
709 | 727 | /** |
710 | 728 | * Relation field definition. |
711 | | - * @typedef {CommonFieldProps & StandardFieldProps & RelationFieldProps & MultiOptionFieldProps |
| 729 | + * @typedef {VisibleFieldProps & FieldValidationProps & RelationFieldProps & MultiOptionFieldProps |
712 | 730 | * } RelationField |
713 | 731 | */ |
714 | 732 |
|
|
729 | 747 |
|
730 | 748 | /** |
731 | 749 | * Select field definition. |
732 | | - * @typedef {CommonFieldProps & StandardFieldProps & SelectFieldProps & MultiOptionFieldProps |
| 750 | + * @typedef {VisibleFieldProps & FieldValidationProps & SelectFieldProps & MultiOptionFieldProps |
733 | 751 | * } SelectField |
734 | 752 | */ |
735 | 753 |
|
|
747 | 765 |
|
748 | 766 | /** |
749 | 767 | * String field definition. |
750 | | - * @typedef {CommonFieldProps & StandardFieldProps & StringFieldProps & AdjacentLabelProps & |
| 768 | + * @typedef {VisibleFieldProps & FieldValidationProps & StringFieldProps & AdjacentLabelProps & |
751 | 769 | * CharCountProps} StringField |
752 | 770 | */ |
753 | 771 |
|
|
761 | 779 |
|
762 | 780 | /** |
763 | 781 | * Text field definition. |
764 | | - * @typedef {CommonFieldProps & StandardFieldProps & TextFieldProps & CharCountProps} TextField |
| 782 | + * @typedef {VisibleFieldProps & FieldValidationProps & TextFieldProps & CharCountProps } TextField |
765 | 783 | */ |
766 | 784 |
|
767 | 785 | /** |
|
779 | 797 |
|
780 | 798 | /** |
781 | 799 | * UUID field definition. |
782 | | - * @typedef {CommonFieldProps & StandardFieldProps & UuidFieldProps} UuidField |
| 800 | + * @typedef {VisibleFieldProps & UuidFieldProps} UuidField |
783 | 801 | */ |
784 | 802 |
|
785 | 803 | /** |
786 | | - * Entry field using a built-in widget. |
| 804 | + * Visible field types. |
787 | 805 | * @typedef {BooleanField | CodeField | ColorField | ComputeField | DateTimeField | FileField | |
788 | | - * HiddenField | ImageField | KeyValueField | ListField | MapField | MarkdownField | NumberField | |
789 | | - * ObjectField | RelationField | SelectField | StringField | TextField | UuidField} StandardField |
| 806 | + * ImageField | KeyValueField | ListField | MapField | MarkdownField | NumberField | ObjectField | |
| 807 | + * RelationField | SelectField | StringField | TextField | UuidField} VisibleField |
| 808 | + */ |
| 809 | + |
| 810 | +/** |
| 811 | + * Entry field using a built-in widget. |
| 812 | + * @typedef {VisibleField | HiddenField} StandardField |
790 | 813 | * @see https://decapcms.org/docs/widgets/ |
791 | 814 | */ |
792 | 815 |
|
|
0 commit comments