Skip to content

Commit

Permalink
Merge pull request #5 from CloudCannon/more-type-updates
Browse files Browse the repository at this point in the history
Some more type updates
  • Loading branch information
rphillips-cc committed Jun 27, 2024
2 parents 252baa9 + 52a71e7 commit 16a62fc
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type EditorKey = 'visual' | 'content' | 'data';
export type SortOrder = 'ascending' | 'descending' | 'asc' | 'desc';

// TODO: use SnippetConfig from @cloudcannon/scrap-booker when ParserConfig issue resolved.
interface SnippetConfig extends ReducedCascade, Previewable, PickerPreviewable {
export interface SnippetConfig extends ReducedCascade, Previewable, PickerPreviewable {
/**
* Name of the snippet.
*/
Expand Down Expand Up @@ -184,12 +184,12 @@ interface ImageResizeable {
* A number suffixed with "x" (relative size) or "w" (fixed width) for setting the dimensions of
* the image (e.g. 2x, 3x, 100w, 360w).
*/
size: 'string';
size: string;
/**
* A reference to another input that is given the path to this additional image file.
*/
target?: 'string';
};
target?: string;
}[];
}

export interface Editables {
Expand Down Expand Up @@ -466,10 +466,7 @@ export interface BaseInputOptions<EmptyType = EmptyTypeText> {
}

export interface BaseInput<InputOptions = BaseInputOptions> {
/**
* Controls the type of input, changing how it is displayed and interacted with.
*/
type?: InputType;
type?: InputType | undefined | null;
/**
* Changes the subtext below the _Label_. Has no default. Supports a limited set of Markdown:
* links, bold, italic, subscript, superscript, and inline code elements are allowed.
Expand Down Expand Up @@ -670,6 +667,11 @@ export interface FileInputOptions extends BaseInputOptions, WithReducedPaths {
* Restricts which file types are available to select or upload to this input.
*/
accepts_mime_types?: MimeType[] | '*';
/**
* If you have one or more DAMs connected to your site, you can use this key to list which asset
* sources can be uploaded to and selected from.
*/
allowed_sources?: string[];
}

export interface FileInput extends BaseInput<FileInputOptions> {
Expand Down Expand Up @@ -737,6 +739,14 @@ export interface MultichoiceInput extends BaseInput<MultichoiceInputOptions> {
type: 'multichoice';
}

export interface ObjectInputGroup {
heading?: string;
comment?: string;
collapsed?: boolean;
inputs?: string[];
documentation?: Documentation;
}

export interface ObjectInputOptions extends BaseInputOptions<EmptyTypeObject> {
/**
* Changes the appearance and behavior of the input.
Expand Down Expand Up @@ -776,6 +786,21 @@ export interface ObjectInputOptions extends BaseInputOptions<EmptyTypeObject> {
* itself.
*/
structures?: string | Structure;

/**
* Allows you to group the inputs inside this object together without changing the data structure.
*/
groups?: ObjectInputGroup[];

/**
* Controls which order input groups and ungrouped inputs appear in.
*/
place_groups_below?: boolean;

/**
* Controls whether or not labels on mutable object entries are formatted.
*/
allow_label_formatting?: boolean;
}

export interface ObjectInput extends BaseInput<ObjectInputOptions> {
Expand All @@ -800,8 +825,13 @@ export interface ArrayInput extends BaseInput<ArrayInputOptions> {
type: 'array';
}

export interface UnknownInput extends BaseInput<BaseInputOptions> {
type?: undefined | null;
}

export type Input =
| BaseInput
| UnknownInput
| TextInput
| CodeInput
| ColorInput
Expand Down Expand Up @@ -852,6 +882,10 @@ export interface ReducedPaths {
* @default ''
*/
dam_static?: string;
/**
* When set to true, CloudCannon will reference files relative to the path of the file they were uploaded to.
*/
uploads_use_relative_path?: boolean;
}

export interface Paths extends ReducedPaths {
Expand Down

0 comments on commit 16a62fc

Please sign in to comment.