import { FieldProcessorAdt, FieldSchema, ValueSchema } from '@ephox/boulder';
import { Result } from '@ephox/katamari';

import { FormComponent, FormComponentApi, formComponentFields } from './FormComponent';

export interface CollectionApi extends FormComponentApi {
  type: 'collection';
  // TODO TINY-3229 implement collection columns properly
  // columns?: number | 'auto';
}

export interface Collection extends FormComponent {
  type: 'collection';
  columns: number | 'auto';
}

export const collectionFields: FieldProcessorAdt[] = formComponentFields.concat([
  FieldSchema.defaulted('columns', 'auto')
]);

export const collectionSchema = ValueSchema.objOf(collectionFields);

// TODO: Make type for CollectionItem
export const collectionDataProcessor = ValueSchema.arrOfObj([
  FieldSchema.strictString('value'),
  FieldSchema.optionString('text'),
  FieldSchema.optionString('icon')
]);

export const createCollection = (spec: CollectionApi): Result<Collection, ValueSchema.SchemaError<any>> => {
  return ValueSchema.asRaw<Collection>('collection', collectionSchema, spec);
};
import { FieldProcessorAdt, FieldSchema, ValueSchema } from '@ephox/boulder';
import { Result } from '@ephox/katamari';

import { FormComponent, FormComponentApi, formComponentFields } from './FormComponent';

export interface CollectionApi extends FormComponentApi {
  type: 'collection';
  columns?: number | 'auto';
}

export interface Collection extends FormComponent {
  type: 'collection';
  columns: number | 'auto';
}

export const collectionFields: FieldProcessorAdt[] = formComponentFields.concat([
  FieldSchema.defaulted('columns', 1)
]);

export const collectionSchema = ValueSchema.objOf(collectionFields);

// TODO: Make type for CollectionItem
export const collectionDataProcessor = ValueSchema.arrOfObj([
  FieldSchema.strictString('value'),
  FieldSchema.optionString('text'),
  FieldSchema.optionString('icon')
]);

export const createCollection = (spec: CollectionApi): Result<Collection, ValueSchema.SchemaError<any>> => {
  return ValueSchema.asRaw<Collection>('collection', collectionSchema, spec);
};
--- 
+++ 
@@ -5,7 +5,8 @@
 
 export interface CollectionApi extends FormComponentApi {
   type: 'collection';
-  columns?: number | 'auto';
+  // TODO TINY-3229 implement collection columns properly
+  // columns?: number | 'auto';
 }
 
 export interface Collection extends FormComponent {
@@ -14,7 +15,7 @@
 }
 
 export const collectionFields: FieldProcessorAdt[] = formComponentFields.concat([
-  FieldSchema.defaulted('columns', 1)
+  FieldSchema.defaulted('columns', 'auto')
 ]);
 
 export const collectionSchema = ValueSchema.objOf(collectionFields);
TINY-3229: Disable the columns property in the collection component for release, it will return later
