@sveltia/cms 0.87.2 → 0.87.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/types/public.d.ts CHANGED
@@ -36,7 +36,7 @@ export type RasterImageTransformationOptions = {
36
36
  */
37
37
  format?: RasterImageConversionFormat;
38
38
  /**
39
- * Image quality between 0 and 100. Default: 85.
39
+ * Image quality between 0 and 100. Default: `85`.
40
40
  */
41
41
  quality?: number;
42
42
  /**
@@ -154,7 +154,7 @@ export type CloudinaryMediaLibrary = {
154
154
  */
155
155
  use_secure_url?: boolean;
156
156
  /**
157
- * Options to be passed to Uploadcare, such as `multiple`.
157
+ * Options to be passed to Cloudinary, such as `multiple`.
158
158
  * The `cloud_name` and `api_key` options are required for the global `media_library` option. See
159
159
  * https://cloudinary.com/documentation/media_library_widget#2_set_the_configuration_options for a
160
160
  * full list of available options.
@@ -233,9 +233,9 @@ export type MediaLibraries = {
233
233
  stock_assets?: StockAssetMediaLibrary;
234
234
  };
235
235
  /**
236
- * Common field properties.
236
+ * Base field properties that are common to all fields.
237
237
  */
238
- export type CommonFieldProps = {
238
+ export type BaseFieldProps = {
239
239
  /**
240
240
  * Unique identifier for the field. It cannot include periods and spaces.
241
241
  */
@@ -250,10 +250,32 @@ export type CommonFieldProps = {
250
250
  */
251
251
  comment?: string;
252
252
  /**
253
- * Name of a widget that defines the input UI and data type. Default:
254
- * `string`.
253
+ * Help message to be displayed below the input UI. Limited Markdown
254
+ * formatting is supported: bold, italic, strikethrough and links.
255
+ */
256
+ hint?: string;
257
+ /**
258
+ * Whether to show the preview of the field. Default: `true`.
255
259
  */
256
- widget?: string;
260
+ preview?: boolean;
261
+ /**
262
+ * Whether to enable the editor UI
263
+ * in locales other than the default locale. Default: `false`. `duplicate` disables the UI in
264
+ * non-default like `false` but automatically copies the default locale’s value to other locales.
265
+ * `translate` and `none` are aliases of `true` and `false`, respectively. This option only works
266
+ * when i18n is set up with the global and collection-level `i18n` option.
267
+ */
268
+ i18n?: boolean | "duplicate" | "translate" | "none";
269
+ };
270
+ /**
271
+ * Common field properties. We have to allow arbitrary properties because custom widgets can have
272
+ * any properties. This is also required to enable schema autocomplete for the fields in IDEs.
273
+ */
274
+ export type CommonFieldProps = BaseFieldProps & Record<string, any>;
275
+ /**
276
+ * Standard field properties for a built-in widget.
277
+ */
278
+ export type StandardFieldProps = {
257
279
  /**
258
280
  * Whether to make data input on the field required.
259
281
  * Default: `true`. This option also affects data output if the `omit_empty_optional_fields` global
@@ -272,23 +294,6 @@ export type CommonFieldProps = {
272
294
  * message. This option has no effect on a List or Object field with subfields.
273
295
  */
274
296
  pattern?: [string | RegExp, string];
275
- /**
276
- * Help message to be displayed below the input UI. Limited Markdown
277
- * formatting is supported: bold, italic, strikethrough and links.
278
- */
279
- hint?: string;
280
- /**
281
- * Whether to show the preview of the field. Default: `true`.
282
- */
283
- preview?: boolean;
284
- /**
285
- * Whether to enable the editor UI
286
- * in locales other than the default locale. Default: `false`. `duplicate` disables the UI in
287
- * non-default like `false` but automatically copies the default locale’s value to other locales.
288
- * `translate` and `none` are aliases of `true` and `false`, respectively. This option only works
289
- * when i18n is set up with the global and collection-level `i18n` option.
290
- */
291
- i18n?: boolean | "duplicate" | "translate" | "none";
292
297
  };
293
298
  /**
294
299
  * Field-level media library options.
@@ -349,11 +354,11 @@ export type MediaFieldProps = {
349
354
  */
350
355
  export type MultiValueFieldProps = {
351
356
  /**
352
- * Minimum number of items that can be added. Default: 0.
357
+ * Minimum number of items that can be added. Default: `0`.
353
358
  */
354
359
  min?: number;
355
360
  /**
356
- * Maximum number of items that can be added. Default: infinity.
361
+ * Maximum number of items that can be added. Default: `Infinity`.
357
362
  */
358
363
  max?: number;
359
364
  };
@@ -367,17 +372,17 @@ export type MultiOptionFieldProps = {
367
372
  multiple?: boolean;
368
373
  /**
369
374
  * Minimum number of items that can be selected. Ignored if `multiple` is
370
- * `false`. Default: 0.
375
+ * `false`. Default: `0`.
371
376
  */
372
377
  min?: number;
373
378
  /**
374
379
  * Maximum number of items that can be selected. Ignored if `multiple` is
375
- * `false`. Default: infinity.
380
+ * `false`. Default: `Infinity`.
376
381
  */
377
382
  max?: number;
378
383
  /**
379
384
  * Maximum number of options to be displayed as radio
380
- * buttons (single-select) or checkboxes (multi-select) rather than a dropdown list. Default: 5.
385
+ * buttons (single-select) or checkboxes (multi-select) rather than a dropdown list. Default: `5`.
381
386
  */
382
387
  dropdown_threshold?: number;
383
388
  };
@@ -443,12 +448,12 @@ export type AdjacentLabelProps = {
443
448
  export type CharCountProps = {
444
449
  /**
445
450
  * Minimum number of characters that can be entered in the input.
446
- * Default: 0.
451
+ * Default: `0`.
447
452
  */
448
453
  minlength?: number;
449
454
  /**
450
455
  * Maximum number of characters that can be entered in the input.
451
- * Default: infinity.
456
+ * Default: `Infinity`.
452
457
  */
453
458
  maxlength?: number;
454
459
  };
@@ -468,7 +473,7 @@ export type BooleanFieldProps = {
468
473
  /**
469
474
  * Boolean field definition.
470
475
  */
471
- export type BooleanField = CommonFieldProps & BooleanFieldProps & AdjacentLabelProps;
476
+ export type BooleanField = CommonFieldProps & StandardFieldProps & BooleanFieldProps & AdjacentLabelProps;
472
477
  /**
473
478
  * Code field properties.
474
479
  */
@@ -509,7 +514,7 @@ export type CodeFieldProps = {
509
514
  /**
510
515
  * Code field definition.
511
516
  */
512
- export type CodeField = CommonFieldProps & CodeFieldProps;
517
+ export type CodeField = CommonFieldProps & StandardFieldProps & CodeFieldProps;
513
518
  /**
514
519
  * Color field properties.
515
520
  */
@@ -536,7 +541,7 @@ export type ColorFieldProps = {
536
541
  /**
537
542
  * Color field definition.
538
543
  */
539
- export type ColorField = CommonFieldProps & ColorFieldProps;
544
+ export type ColorField = CommonFieldProps & StandardFieldProps & ColorFieldProps;
540
545
  /**
541
546
  * Compute field properties.
542
547
  */
@@ -553,7 +558,7 @@ export type ComputeFieldProps = {
553
558
  /**
554
559
  * Compute field definition.
555
560
  */
556
- export type ComputeField = CommonFieldProps & ComputeFieldProps;
561
+ export type ComputeField = CommonFieldProps & StandardFieldProps & ComputeFieldProps;
557
562
  /**
558
563
  * DateTime field properties.
559
564
  */
@@ -592,7 +597,7 @@ export type DateTimeFieldProps = {
592
597
  /**
593
598
  * DateTime field definition.
594
599
  */
595
- export type DateTimeField = CommonFieldProps & DateTimeFieldProps;
600
+ export type DateTimeField = CommonFieldProps & StandardFieldProps & DateTimeFieldProps;
596
601
  /**
597
602
  * File field properties.
598
603
  */
@@ -605,7 +610,7 @@ export type FileFieldProps = {
605
610
  /**
606
611
  * File field definition.
607
612
  */
608
- export type FileField = CommonFieldProps & MediaFieldProps & FileFieldProps;
613
+ export type FileField = CommonFieldProps & StandardFieldProps & MediaFieldProps & FileFieldProps;
609
614
  /**
610
615
  * Hidden field properties.
611
616
  */
@@ -623,7 +628,7 @@ export type HiddenFieldProps = {
623
628
  /**
624
629
  * Hidden field definition.
625
630
  */
626
- export type HiddenField = CommonFieldProps & HiddenFieldProps;
631
+ export type HiddenField = CommonFieldProps & StandardFieldProps & HiddenFieldProps;
627
632
  /**
628
633
  * Image field properties.
629
634
  */
@@ -636,7 +641,7 @@ export type ImageFieldProps = {
636
641
  /**
637
642
  * Image field definition.
638
643
  */
639
- export type ImageField = CommonFieldProps & MediaFieldProps & ImageFieldProps;
644
+ export type ImageField = CommonFieldProps & StandardFieldProps & MediaFieldProps & ImageFieldProps;
640
645
  /**
641
646
  * KeyValue field properties.
642
647
  */
@@ -661,7 +666,7 @@ export type KeyValueFieldProps = {
661
666
  /**
662
667
  * KeyValue field definition.
663
668
  */
664
- export type KeyValueField = CommonFieldProps & KeyValueFieldProps & MultiValueFieldProps;
669
+ export type KeyValueField = CommonFieldProps & StandardFieldProps & KeyValueFieldProps & MultiValueFieldProps;
665
670
  /**
666
671
  * List field properties.
667
672
  */
@@ -725,7 +730,7 @@ export type ListFieldProps = {
725
730
  /**
726
731
  * List field definition.
727
732
  */
728
- export type ListField = CommonFieldProps & ListFieldProps & MultiValueFieldProps & VariableFieldProps;
733
+ export type ListField = CommonFieldProps & StandardFieldProps & ListFieldProps & MultiValueFieldProps & VariableFieldProps;
729
734
  /**
730
735
  * Map field properties.
731
736
  */
@@ -740,18 +745,18 @@ export type MapFieldProps = {
740
745
  */
741
746
  default?: string;
742
747
  /**
743
- * Precision of coordinates to be saved. Default: 7.
748
+ * Precision of coordinates to be saved. Default: `7`.
744
749
  */
745
750
  decimals?: number;
746
751
  /**
747
- * Geometry type. Default: Point.
752
+ * Geometry type. Default: `Point`.
748
753
  */
749
754
  type?: "Point" | "LineString" | "Polygon";
750
755
  };
751
756
  /**
752
757
  * Map field definition.
753
758
  */
754
- export type MapField = CommonFieldProps & MapFieldProps;
759
+ export type MapField = CommonFieldProps & StandardFieldProps & MapFieldProps;
755
760
  /**
756
761
  * Supported button name for the rich text editor.
757
762
  */
@@ -812,7 +817,7 @@ export type MarkdownFieldProps = {
812
817
  /**
813
818
  * Markdown field definition.
814
819
  */
815
- export type MarkdownField = CommonFieldProps & MarkdownFieldProps;
820
+ export type MarkdownField = CommonFieldProps & StandardFieldProps & MarkdownFieldProps;
816
821
  /**
817
822
  * Number field properties.
818
823
  */
@@ -830,22 +835,22 @@ export type NumberFieldProps = {
830
835
  */
831
836
  value_type?: "int" | "float" | string;
832
837
  /**
833
- * Minimum value that can be entered in the input. Default: undefined.
838
+ * Minimum value that can be entered in the input. Default: `-Infinity`.
834
839
  */
835
840
  min?: number;
836
841
  /**
837
- * Maximum value that can be entered in the input. Default: undefined.
842
+ * Maximum value that can be entered in the input. Default: `Infinity`.
838
843
  */
839
844
  max?: number;
840
845
  /**
841
- * Number to increase/decrease with the arrow key/button. Default: 1.
846
+ * Number to increase/decrease with the arrow key/button. Default: `1`.
842
847
  */
843
848
  step?: number;
844
849
  };
845
850
  /**
846
851
  * Number field definition.
847
852
  */
848
- export type NumberField = CommonFieldProps & NumberFieldProps & AdjacentLabelProps;
853
+ export type NumberField = CommonFieldProps & StandardFieldProps & NumberFieldProps & AdjacentLabelProps;
849
854
  /**
850
855
  * Object field properties.
851
856
  */
@@ -876,7 +881,7 @@ export type ObjectFieldProps = {
876
881
  /**
877
882
  * Object field definition.
878
883
  */
879
- export type ObjectField = CommonFieldProps & ObjectFieldProps & VariableFieldProps;
884
+ export type ObjectField = CommonFieldProps & StandardFieldProps & ObjectFieldProps & VariableFieldProps;
880
885
  /**
881
886
  * Entry filter options for a Relation field.
882
887
  */
@@ -938,7 +943,7 @@ export type RelationFieldProps = {
938
943
  /**
939
944
  * Relation field definition.
940
945
  */
941
- export type RelationField = CommonFieldProps & RelationFieldProps & MultiOptionFieldProps;
946
+ export type RelationField = CommonFieldProps & StandardFieldProps & RelationFieldProps & MultiOptionFieldProps;
942
947
  /**
943
948
  * Select field properties.
944
949
  */
@@ -963,7 +968,7 @@ export type SelectFieldProps = {
963
968
  /**
964
969
  * Select field definition.
965
970
  */
966
- export type SelectField = CommonFieldProps & SelectFieldProps & MultiOptionFieldProps;
971
+ export type SelectField = CommonFieldProps & StandardFieldProps & SelectFieldProps & MultiOptionFieldProps;
967
972
  /**
968
973
  * String field properties.
969
974
  */
@@ -971,14 +976,14 @@ export type StringFieldProps = {
971
976
  /**
972
977
  * Widget name.
973
978
  */
974
- widget: "string";
979
+ widget?: "string";
975
980
  /**
976
981
  * Default value.
977
982
  */
978
983
  default?: string;
979
984
  /**
980
985
  * Data type. It’s useful when the input value needs a
981
- * validation. Default: text.
986
+ * validation. Default: `text`.
982
987
  */
983
988
  type?: "text" | "url" | "email";
984
989
  /**
@@ -993,7 +998,7 @@ export type StringFieldProps = {
993
998
  /**
994
999
  * String field definition.
995
1000
  */
996
- export type StringField = CommonFieldProps & StringFieldProps & AdjacentLabelProps & CharCountProps;
1001
+ export type StringField = CommonFieldProps & StandardFieldProps & StringFieldProps & AdjacentLabelProps & CharCountProps;
997
1002
  /**
998
1003
  * Text field properties.
999
1004
  */
@@ -1010,7 +1015,7 @@ export type TextFieldProps = {
1010
1015
  /**
1011
1016
  * Text field definition.
1012
1017
  */
1013
- export type TextField = CommonFieldProps & TextFieldProps & CharCountProps;
1018
+ export type TextField = CommonFieldProps & StandardFieldProps & TextFieldProps & CharCountProps;
1014
1019
  /**
1015
1020
  * UUID field properties.
1016
1021
  */
@@ -1039,15 +1044,24 @@ export type UuidFieldProps = {
1039
1044
  /**
1040
1045
  * UUID field definition.
1041
1046
  */
1042
- export type UuidField = CommonFieldProps & UuidFieldProps;
1047
+ export type UuidField = CommonFieldProps & StandardFieldProps & UuidFieldProps;
1043
1048
  /**
1044
1049
  * Entry field using a built-in widget.
1045
1050
  */
1046
1051
  export type StandardField = BooleanField | CodeField | ColorField | ComputeField | DateTimeField | FileField | HiddenField | ImageField | KeyValueField | ListField | MapField | MarkdownField | NumberField | ObjectField | RelationField | SelectField | StringField | TextField | UuidField;
1047
1052
  /**
1048
- * Entry field using a custom widget. It can contain any properties.
1053
+ * Custom field properties.
1054
+ */
1055
+ export type CustomFieldProps = {
1056
+ /**
1057
+ * Widget name.
1058
+ */
1059
+ widget: string;
1060
+ };
1061
+ /**
1062
+ * Entry field using a custom widget.
1049
1063
  */
1050
- export type CustomField = CommonFieldProps & Record<string, any>;
1064
+ export type CustomField = CommonFieldProps & CustomFieldProps;
1051
1065
  /**
1052
1066
  * Entry field.
1053
1067
  */
@@ -1158,12 +1172,6 @@ export type CollectionFile = {
1158
1172
  * I18n options. Default: `false`.
1159
1173
  */
1160
1174
  i18n?: I18nOptions | boolean;
1161
- /**
1162
- * A special option to make this file a divider UI in the singleton
1163
- * file list. Default: `false`. Not supported in a file collection. If `true`, other options will be
1164
- * ignored, but you still have to provide a unique `name`.
1165
- */
1166
- divider?: boolean;
1167
1175
  /**
1168
1176
  * Preview URL path template.
1169
1177
  */
@@ -1281,7 +1289,7 @@ export type EditorOptions = {
1281
1289
  export type NestedCollectionOptions = {
1282
1290
  /**
1283
1291
  * Maximum depth to show nested items in the collection tree. Default:
1284
- * infinity.
1292
+ * `Infinity`.
1285
1293
  */
1286
1294
  depth?: number;
1287
1295
  /**
@@ -1344,6 +1352,23 @@ export type CollectionIndexFile = {
1344
1352
  */
1345
1353
  editor?: EditorOptions;
1346
1354
  };
1355
+ /**
1356
+ * A divider in the collection list and singleton list.
1357
+ */
1358
+ export type CollectionDivider = {
1359
+ /**
1360
+ * Unique identifier for the divider. Can be omitted, but it must be
1361
+ * unique across all the collections and singletons. This property is included here because in the
1362
+ * previous version of Sveltia CMS, a divider was defined as a collection with the `divider` option
1363
+ * set to `true`, and the `name` option was required.
1364
+ */
1365
+ name?: string;
1366
+ /**
1367
+ * Whether to make this collection a divider UI in the collection list.
1368
+ * It must be `true` to be used as a divider.
1369
+ */
1370
+ divider: boolean;
1371
+ };
1347
1372
  /**
1348
1373
  * A raw collection defined in the configuration file. Note: In Sveltia CMS, a folder collection is
1349
1374
  * called an entry collection.
@@ -1448,7 +1473,7 @@ export type Collection = {
1448
1473
  slug?: string;
1449
1474
  /**
1450
1475
  * The maximum number of characters allowed for an entry slug.
1451
- * Entry collection only. Default: infinity.
1476
+ * Entry collection only. Default: `Infinity`.
1452
1477
  */
1453
1478
  slug_length?: number;
1454
1479
  /**
@@ -1509,12 +1534,6 @@ export type Collection = {
1509
1534
  * options.
1510
1535
  */
1511
1536
  yaml_quote?: boolean;
1512
- /**
1513
- * A special option to make this collection a divider UI in the
1514
- * collection list. Default: `false`. If `true`, other options will be ignored, but you still have
1515
- * to provide a unique `name`.
1516
- */
1517
- divider?: boolean;
1518
1537
  /**
1519
1538
  * A field key path to be used to find an
1520
1539
  * entry thumbnail displayed on the entry list. A nested field can be specified using dot notation,
@@ -1525,7 +1544,7 @@ export type Collection = {
1525
1544
  thumbnail?: FieldKeyPath | FieldKeyPath[];
1526
1545
  /**
1527
1546
  * The maximum number of entries that can be created in the collection.
1528
- * Entry collection only. Default: infinity.
1547
+ * Entry collection only. Default: `Infinity`.
1529
1548
  */
1530
1549
  limit?: number;
1531
1550
  };
@@ -1654,7 +1673,7 @@ export type BackendOptions = {
1654
1673
  /**
1655
1674
  * Whether to enable or disable automatic deployments
1656
1675
  * with any connected CI/CD provider, such as GitHub Actions or Cloudflare Pages. If `false`, the
1657
- * `[skip ci]` prefix will be added to commit messages. Git backends only. Default: undefined. See
1676
+ * `[skip ci]` prefix will be added to commit messages. Git backends only. Default: `undefined`. See
1658
1677
  * https://github.com/sveltia/sveltia-cms#disabling-automatic-deployments for details.
1659
1678
  */
1660
1679
  automatic_deployments?: boolean;
@@ -1694,7 +1713,7 @@ export type JsonFormatOptions = {
1694
1713
  */
1695
1714
  indent_style?: "space" | "tab";
1696
1715
  /**
1697
- * Indent size. Default: 2.
1716
+ * Indent size. Default: `2`.
1698
1717
  */
1699
1718
  indent_size?: number;
1700
1719
  };
@@ -1703,7 +1722,7 @@ export type JsonFormatOptions = {
1703
1722
  */
1704
1723
  export type YamlFormatOptions = {
1705
1724
  /**
1706
- * Indent size. Default: 2.
1725
+ * Indent size. Default: `2`.
1707
1726
  */
1708
1727
  indent_size?: number;
1709
1728
  /**
@@ -1801,15 +1820,16 @@ export type SiteConfig = {
1801
1820
  */
1802
1821
  slug?: SlugOptions;
1803
1822
  /**
1804
- * Set of collections.
1823
+ * Set of collections. The list can also
1824
+ * contain dividers, which are used to group collections in the collection list.
1805
1825
  */
1806
- collections: Collection[];
1826
+ collections: (Collection | CollectionDivider)[];
1807
1827
  /**
1808
- * Set of singleton files, such as the site configuration
1809
- * file or the homepage file. They are not part of any collection and can be accessed directly
1810
- * through the collection list.
1828
+ * Set of singleton files, such as
1829
+ * the site configuration file or the homepage file. They are not part of any collection and can be
1830
+ * accessed directly through the collection list. The list can also contain dividers.
1811
1831
  */
1812
- singletons?: CollectionFile[];
1832
+ singletons?: (CollectionFile | CollectionDivider)[];
1813
1833
  /**
1814
1834
  * Global i18n options.
1815
1835
  */