breaking(types): type arrays as read-only (#1335)

Closes #1259

* breaking(types): type arrays as read-only

* Run "yarn build:docs"

* test: assert read-only arrays
This commit is contained in:
metonym 2022-06-05 13:25:43 -07:00 committed by GitHub
commit 260bf4e040
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 257 additions and 192 deletions

View file

@ -18,7 +18,7 @@ export interface CheckboxProps {
* Specify the bound group
* @default undefined
*/
group?: any[];
group?: ReadonlyArray<any>;
/**
* Specify whether the checkbox is indeterminate

View file

@ -15,7 +15,7 @@ export interface ComboBoxProps
* Set the combobox items
* @default []
*/
items?: ComboBoxItem[];
items?: ReadonlyArray<ComboBoxItem>;
/**
* Override the display of a combobox item

View file

@ -8,7 +8,7 @@ export interface ContextMenuProps
* If no element is specified, the context menu applies to the entire window
* @default null
*/
target?: null | HTMLElement | HTMLElement[];
target?: null | ReadonlyArray<null | HTMLElement>;
/**
* Set to `true` to open the menu

View file

@ -5,7 +5,7 @@ export interface ContextMenuGroupProps {
/**
* @default []
*/
selectedIds?: string[];
selectedIds?: ReadonlyArray<string>;
/**
* Specify the label text

View file

@ -46,14 +46,14 @@ export interface DataTableProps
* Specify the data table headers
* @default []
*/
headers?: DataTableHeader[];
headers?: ReadonlyArray<DataTableHeader>;
/**
* Specify the rows the data table should render
* keys defined in `headers` are used for the row ids
* @default []
*/
rows?: DataTableRow[];
rows?: ReadonlyArray<DataTableRow>;
/**
* Set the size of the data table
@ -102,13 +102,13 @@ export interface DataTableProps
* Specify the row ids to be expanded
* @default []
*/
expandedRowIds?: DataTableRowId[];
expandedRowIds?: ReadonlyArray<DataTableRowId>;
/**
* Specify the ids for rows that should not be expandable
* @default []
*/
nonExpandableRowIds?: DataTableRowId[];
nonExpandableRowIds?: ReadonlyArray<DataTableRowId>;
/**
* Set to `true` for the radio selection variant
@ -133,13 +133,13 @@ export interface DataTableProps
* Specify the row ids to be selected
* @default []
*/
selectedRowIds?: DataTableRowId[];
selectedRowIds?: ReadonlyArray<DataTableRowId>;
/**
* Specify the ids of rows that should not be selectable
* @default []
*/
nonSelectableRowIds?: DataTableRowId[];
nonSelectableRowIds?: ReadonlyArray<DataTableRowId>;
/**
* Set to `true` to enable a sticky header

View file

@ -41,7 +41,7 @@ export interface DataTableSkeletonProps
* Supersedes `columns` if value is a non-empty array
* @default []
*/
headers?: string[] | Partial<DataTableHeader>[];
headers?: ReadonlyArray<string | Partial<DataTableHeader>>;
/**
* Set to `false` to hide the toolbar

View file

@ -17,7 +17,7 @@ export interface DropdownProps
* Set the dropdown items
* @default []
*/
items?: DropdownItem[];
items?: ReadonlyArray<DropdownItem>;
/**
* Override the display of a dropdown item

View file

@ -19,13 +19,13 @@ export interface FileUploaderProps
* Specify the accepted file types
* @default []
*/
accept?: string[];
accept?: ReadonlyArray<string>;
/**
* Obtain a reference to the uploaded files
* @default []
*/
files?: File[];
files?: ReadonlyArray<File>;
/**
* Set to `true` to allow multiple files
@ -73,9 +73,9 @@ export interface FileUploaderProps
export default class FileUploader extends SvelteComponentTyped<
FileUploaderProps,
{
add: CustomEvent<File[]>;
remove: CustomEvent<File[]>;
change: CustomEvent<File[]>;
add: CustomEvent<ReadonlyArray<File>>;
remove: CustomEvent<ReadonlyArray<File>>;
change: CustomEvent<ReadonlyArray<File>>;
click: WindowEventMap["click"];
mouseover: WindowEventMap["mouseover"];
mouseenter: WindowEventMap["mouseenter"];

View file

@ -7,13 +7,13 @@ export interface FileUploaderButtonProps
* Specify the accepted file types
* @default []
*/
accept?: string[];
accept?: ReadonlyArray<string>;
/**
* Obtain a reference to the uploaded files
* @default []
*/
files?: File[];
files?: ReadonlyArray<File>;
/**
* Set to `true` to allow multiple files
@ -79,7 +79,7 @@ export interface FileUploaderButtonProps
export default class FileUploaderButton extends SvelteComponentTyped<
FileUploaderButtonProps,
{
change: CustomEvent<File[]>;
change: CustomEvent<ReadonlyArray<File>>;
keydown: WindowEventMap["keydown"];
click: WindowEventMap["click"];
},

View file

@ -7,13 +7,13 @@ export interface FileUploaderDropContainerProps
* Specify the accepted file types
* @default []
*/
accept?: string[];
accept?: ReadonlyArray<string>;
/**
* Obtain a reference to the uploaded files
* @default []
*/
files?: File[];
files?: ReadonlyArray<File>;
/**
* Set to `true` to allow multiple files
@ -22,11 +22,11 @@ export interface FileUploaderDropContainerProps
multiple?: boolean;
/**
* Override the default behavior of validating uploaded files
* The default behavior does not validate files
* Override the default behavior of validating uploaded files.
* By default, files are not validated
* @default (files) => files
*/
validateFiles?: (files: File[]) => File[];
validateFiles?: (files: ReadonlyArray<File>) => ReadonlyArray<File>;
/**
* Specify the label text
@ -74,8 +74,8 @@ export interface FileUploaderDropContainerProps
export default class FileUploaderDropContainer extends SvelteComponentTyped<
FileUploaderDropContainerProps,
{
add: CustomEvent<File[]>;
change: CustomEvent<File[]>;
add: CustomEvent<ReadonlyArray<File>>;
change: CustomEvent<ReadonlyArray<File>>;
dragover: WindowEventMap["dragover"];
dragleave: WindowEventMap["dragleave"];
drop: WindowEventMap["drop"];

View file

@ -17,7 +17,7 @@ export interface MultiSelectProps
* Set the multiselect items
* @default []
*/
items?: MultiSelectItem[];
items?: ReadonlyArray<MultiSelectItem>;
/**
* Override the display of a multiselect item
@ -39,7 +39,7 @@ export interface MultiSelectProps
* Set the selected ids
* @default []
*/
selectedIds?: MultiSelectItemId[];
selectedIds?: ReadonlyArray<MultiSelectItemId>;
/**
* Specify the multiselect value

View file

@ -73,7 +73,7 @@ export interface PaginationProps
* Specify the available page sizes
* @default [10]
*/
pageSizes?: number[];
pageSizes?: ReadonlyArray<number>;
/**
* Set to `true` if the number of pages is unknown

View file

@ -30,13 +30,13 @@ export interface TreeViewProps
* Set the node ids to be selected
* @default []
*/
selectedIds?: TreeNodeId[];
selectedIds?: ReadonlyArray<TreeNodeId>;
/**
* Set the node ids to be expanded
* @default []
*/
expandedIds?: TreeNodeId[];
expandedIds?: ReadonlyArray<TreeNodeId>;
/**
* Specify the TreeView size

View file

@ -31,7 +31,7 @@ export interface HeaderSearchProps
* Render a list of search results
* @default []
*/
results?: HeaderSearchResult[];
results?: ReadonlyArray<HeaderSearchResult>;
/**
* Specify the selected result index