@tinacms/schema-tools 0.1.6 → 0.1.8

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.
@@ -67,8 +67,8 @@ export declare type TinaIndex = {
67
67
  };
68
68
  export interface UICollection {
69
69
  filename?: {
70
- slugify?: (values: unknown) => string;
71
- disabled?: boolean;
70
+ slugify?: (values: Record<string, any>) => string;
71
+ readonly?: boolean;
72
72
  };
73
73
  /**
74
74
  * Forms for this collection will be editable from the global sidebar rather than the form panel
@@ -92,17 +92,19 @@ export interface UICollection {
92
92
  collection: TinaCloudCollection<true>;
93
93
  }) => string | undefined;
94
94
  }
95
+ declare type DefaultItem<ReturnType> = ReturnType | (() => ReturnType);
95
96
  interface BaseCollection {
96
97
  label?: string;
97
98
  name: string;
98
99
  path: string;
99
- defaultItem?: () => unknown | unknown;
100
+ defaultItem?: DefaultItem<Record<string, any>>;
100
101
  indexes?: TinaIndex[];
101
102
  format?: FormatType;
102
103
  ui?: UICollection;
103
104
  match?: string;
104
105
  }
105
- declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
106
+ export declare type CollectionTemplates<WithNamespace extends boolean> = WithNamespace extends true ? CollectionTemplatesWithNamespace<WithNamespace> : CollectionTemplatesInner<WithNamespace>;
107
+ export declare type TinaTemplate = Template<false>;
106
108
  interface CollectionTemplatesInner<WithNamespace extends boolean> extends BaseCollection {
107
109
  templates: (string | GlobalTemplate<WithNamespace>)[];
108
110
  fields?: undefined;
@@ -170,7 +172,9 @@ declare type StringField = {
170
172
  isBody?: boolean;
171
173
  list: true;
172
174
  isTitle?: never;
173
- ui?: UIField<any, string[]>;
175
+ ui?: UIField<any, string[]> & {
176
+ defaultItem?: DefaultItem<string>;
177
+ };
174
178
  };
175
179
  declare type BooleanField = {
176
180
  type: 'boolean';
@@ -262,6 +266,7 @@ interface ObjectTemplatesInnerWithList<WithNamespace extends boolean> extends Ob
262
266
  key?: string;
263
267
  label?: string;
264
268
  };
269
+ defaultItem?: DefaultItem<Record<string, any>>;
265
270
  } & UIField<any, string>);
266
271
  }
267
272
  interface ObjectTemplatesInnerWithoutList<WithNamespace extends boolean> extends ObjectTemplatesInnerBase<WithNamespace> {
@@ -288,6 +293,13 @@ interface ObjectTemplatesWithNamespace<WithNamespace extends boolean> extends Ti
288
293
  type: 'object';
289
294
  visualSelector?: boolean;
290
295
  required?: false;
296
+ ui?: UIField<any, Record<string, any>> & {
297
+ itemProps?(item: Record<string, any>): {
298
+ key?: string;
299
+ label?: string;
300
+ };
301
+ defaultItem?: DefaultItem<Record<string, any>>;
302
+ };
291
303
  list?: boolean;
292
304
  /**
293
305
  * templates can either be an array of Tina templates or a reference to
@@ -306,6 +318,13 @@ interface InnerObjectFields<WithNamespace extends boolean> extends TinaField {
306
318
  type: 'object';
307
319
  visualSelector?: boolean;
308
320
  required?: false;
321
+ ui?: UIField<any, Record<string, any>> & {
322
+ itemProps?(item: Record<string, any>): {
323
+ key?: string;
324
+ label?: string;
325
+ };
326
+ defaultItem?: DefaultItem<Record<string, any>>;
327
+ };
309
328
  /**
310
329
  * fields can either be an array of Tina fields, or a reference to the fields
311
330
  * of a global template definition.
@@ -320,6 +339,13 @@ interface InnerObjectFieldsWithNamespace<WithNamespace extends boolean> extends
320
339
  type: 'object';
321
340
  visualSelector?: boolean;
322
341
  required?: false;
342
+ ui?: UIField<any, Record<string, any>> & {
343
+ itemProps?(item: Record<string, any>): {
344
+ key?: string;
345
+ label?: string;
346
+ };
347
+ defaultItem?: DefaultItem<Record<string, any>>;
348
+ };
323
349
  /**
324
350
  * fields can either be an array of Tina fields, or a reference to the fields
325
351
  * of a global template definition.
@@ -386,6 +412,13 @@ export declare type CollectionTemplateableObject = {
386
412
  namespace: string[];
387
413
  type: 'object';
388
414
  visualSelector?: boolean;
415
+ ui?: UIField<any, Record<string, any>> & {
416
+ itemProps?(item: Record<string, any>): {
417
+ key?: string;
418
+ label?: string;
419
+ };
420
+ defaultItem?: DefaultItem<Record<string, any>>;
421
+ };
389
422
  required?: false;
390
423
  template: Templateable;
391
424
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinacms/schema-tools",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "main": "dist/index.js",
5
5
  "module": "./dist/index.es.js",
6
6
  "exports": {