UNPKG

@coreui/vue-pro

Version:

UI Components Library for Vue.js

482 lines (481 loc) 20.8 kB
import { PropType } from 'vue'; import type { Column, ColumnFilter, ColumnFilterValue, Item, ItemsPerPageSelect, FooterItem, Pagination, Sorter, SorterValue, TableFilter } from './types'; declare const CSmartTable: import("vue").DefineComponent<import("vue").ExtractPropTypes<{ /** * Sets active page. If 'pagination' prop is enabled, activePage is set only initially. */ activePage: { type: NumberConstructor; default: number; }; /** * When set, displays table cleaner above table, next to the table filter (or in place of table filter if `tableFilter` prop is not set) * Cleaner resets `tableFilterValue`, `columnFilterValue`, `sorterValue`. If clean is possible it is clickable (`tabIndex="0"` `role="button"`, `color="danger"`), otherwise it is not clickable and transparent. Cleaner can be customized through the `cleanerIcon` slot. * */ cleaner: BooleanConstructor; /** * Style table items as clickable. */ clickableRows: BooleanConstructor; /** * When set, displays additional filter row between table header and items, allowing filtering by specific column. * Column filter can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic filtering inside component. * - lazy (Boolean) - Set to true to trigger filter updates only on change event. */ columnFilter: { type: PropType<boolean | ColumnFilter>; }; /** * Value of table filter. To set pass object where keys are column names and values are filter strings e.g.: * { user: 'John', age: 12 } */ columnFilterValue: { type: PropType<ColumnFilterValue>; }; /** * Prop for table columns configuration. If prop is not defined, table will display columns based on the first item keys, omitting keys that begins with underscore (e.g. '_props') * * In columns prop each array item represents one column. Item might be specified in two ways: * String: each item define column name equal to item value. * Object: item is object with following keys available as column configuration: * - key (required)(String) - define column name equal to item key. * - filter (Boolean) - removes filter from column when set to false. * - label (String) - define visible label of column. If not defined, label will be generated automatically based on column name, by converting kebab-case and snake_case to individual words and capitalization of each word. * - sorter (Boolean) - disables sorting of the column when set to false * - [_props](https://coreui.io/vue/docs/components/table.html#ctableheadercell) (String/Array/Object) - add props to `CTableHeaderCell`. * - _style (String/Array/Object) - adds styles to the column header (useful for defining widths) */ columns: { type: PropType<(Column | string)[]>; }; /** * Enables table sorting by column value. Sorting will be performed corectly only if values in column are of one type: string (case insensitive) or number. * * Sorter can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic sorting inside the component, allowing for external sorting control. * - multiple (Boolean) - Enables sorting by multiple columns simultaneously. The sorting order will be maintained across multiple columns based on the order of interaction. * - resetable (Boolean) - If set to true, clicking on the sorter cycles through three states: ascending, descending, and null (no sorting). The third click on the sorter will reset the sorting and restore the table to its original order. */ columnSorter: { type: PropType<boolean | Sorter>; }; /** * If `true` Displays table footer, which mirrors table header. (without column filter). * Or Array of objects or strings, where each element represents one cell in the table footer. * * Example items: * `['FooterCell', 'FooterCell', 'FooterCell']` * or * `[{ label: 'FooterCell', _props: { color: 'success' }, ...]` */ footer: { type: PropType<boolean | (FooterItem | string)[]>; }; /** * Set to false to remove table header. */ header: { type: BooleanConstructor; default: boolean; }; /** * Array of objects, where each object represents one item - row in table. Additionally, you can customize each row by passing them by [_props](http://coreui.io/vue/docs/components/table.html#ctablerow) key and single cell by [_cellProps](http://coreui.io/vue/docs/components/table.html#ctabledatacell). * * Examples: * - `_props: { color: 'primary', align: 'middle'}` * - `_cellProps: { all: { class: 'fw-semibold'}, 'name': { color: 'info' }}` */ items: { type: PropType<Item[]>; default: () => never[]; }; /** * The total number of items. Use if you pass a portion of data from an external source to let know component what is the total number of items. * * @since 4.8.0 */ itemsNumber: NumberConstructor; /** * Number of items per site, when pagination is enabled. */ itemsPerPage: { type: NumberConstructor; default: number; }; /** * Label for items per page selector. */ itemsPerPageLabel: { type: StringConstructor; default: string; }; /** * Items per page selector options. */ itemsPerPageOptions: { type: PropType<number[]>; default: () => number[]; }; /** * Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values: * - external (Boolean) - disables automatic 'itemsPerPage' change (use to change pages externaly by 'pagination-change' event). */ itemsPerPageSelect: { type: PropType<boolean | ItemsPerPageSelect>; }; /** * When set, table will have loading style: loading spinner and reduced opacity. When 'small' prop is enabled spinner will be also smaller. */ loading: BooleanConstructor; /** * ReactNode or string for passing custom noItemsLabel texts. */ noItemsLabel: { type: StringConstructor; default: string; }; /** * Enables default pagination. Set to true for default setup or pass an object with additional CPagination props. Default pagination will always have the computed number of pages that cannot be changed. The number of pages is generated based on the number of passed items and 'itemsPerPage' prop. If this restriction is an obstacle, you can make external CPagination instead. */ pagination: { type: PropType<boolean | Pagination>; }; /** * Properties to [CSmartPagination](https://coreui.io/vue/docs/components/smart-pagination#csmartpagination) component. */ paginationProps: ObjectConstructor; /** * Add checkboxes to make table rows selectable. */ selectable: BooleanConstructor; /** * Enables select all checkbox displayed in the header of the table. * * Can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic selection inside the component. * * @since 4.8.0 */ selectAll: { type: PropType<boolean | { external?: boolean; }>; }; /** * Array of selected objects, where each object represents one item - row in table. * * Example item: `{ name: 'John' , age: 12 }` * * @since 4.8.0 */ selected: { type: PropType<Item[]>; default: () => never[]; }; /** * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. eg.: * { column: 'status', state: 'asc' } */ sorterValue: { type: PropType<SorterValue[] | SorterValue>; }; /** * Properties to [CTableBody](https://coreui.io/vue/docs/components/table/#ctablebody) component. */ tableBodyProps: ObjectConstructor; /** * Properties to [CTableFoot](https://coreui.io/vue/docs/components/table/#ctablefoot) component. */ tableFootProps: ObjectConstructor; /** * When set, displays table filter above table, allowing filtering by specific column. * * Column filter can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic filtering inside component. * - lazy (Boolean) - Set to true to trigger filter updates only on change event. */ tableFilter: { type: PropType<boolean | TableFilter>; }; /** * The element represents a caption for a component. */ tableFilterLabel: { type: StringConstructor; default: string; }; /** * Specifies a short hint that is visible in the search input. */ tableFilterPlaceholder: { type: StringConstructor; default: string; }; /** * Value of table filter. */ tableFilterValue: StringConstructor; /** * Properties to [CTableHead](https://coreui.io/vue/docs/components/table/#ctablehead) component. */ tableHeadProps: ObjectConstructor; /** * Properties to [CTable](https://coreui.io/vue/docs/components/table/#ctable) component. */ tableProps: ObjectConstructor; }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, { [key: string]: any; }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("selectAll" | "activePageChange" | "rowClick" | "columnFilterChange" | "filteredItemsChange" | "itemsPerPageChange" | "selectedItemsChange" | "sorterChange" | "tableFilterChange")[], "selectAll" | "activePageChange" | "rowClick" | "columnFilterChange" | "filteredItemsChange" | "itemsPerPageChange" | "selectedItemsChange" | "sorterChange" | "tableFilterChange", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{ /** * Sets active page. If 'pagination' prop is enabled, activePage is set only initially. */ activePage: { type: NumberConstructor; default: number; }; /** * When set, displays table cleaner above table, next to the table filter (or in place of table filter if `tableFilter` prop is not set) * Cleaner resets `tableFilterValue`, `columnFilterValue`, `sorterValue`. If clean is possible it is clickable (`tabIndex="0"` `role="button"`, `color="danger"`), otherwise it is not clickable and transparent. Cleaner can be customized through the `cleanerIcon` slot. * */ cleaner: BooleanConstructor; /** * Style table items as clickable. */ clickableRows: BooleanConstructor; /** * When set, displays additional filter row between table header and items, allowing filtering by specific column. * Column filter can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic filtering inside component. * - lazy (Boolean) - Set to true to trigger filter updates only on change event. */ columnFilter: { type: PropType<boolean | ColumnFilter>; }; /** * Value of table filter. To set pass object where keys are column names and values are filter strings e.g.: * { user: 'John', age: 12 } */ columnFilterValue: { type: PropType<ColumnFilterValue>; }; /** * Prop for table columns configuration. If prop is not defined, table will display columns based on the first item keys, omitting keys that begins with underscore (e.g. '_props') * * In columns prop each array item represents one column. Item might be specified in two ways: * String: each item define column name equal to item value. * Object: item is object with following keys available as column configuration: * - key (required)(String) - define column name equal to item key. * - filter (Boolean) - removes filter from column when set to false. * - label (String) - define visible label of column. If not defined, label will be generated automatically based on column name, by converting kebab-case and snake_case to individual words and capitalization of each word. * - sorter (Boolean) - disables sorting of the column when set to false * - [_props](https://coreui.io/vue/docs/components/table.html#ctableheadercell) (String/Array/Object) - add props to `CTableHeaderCell`. * - _style (String/Array/Object) - adds styles to the column header (useful for defining widths) */ columns: { type: PropType<(Column | string)[]>; }; /** * Enables table sorting by column value. Sorting will be performed corectly only if values in column are of one type: string (case insensitive) or number. * * Sorter can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic sorting inside the component, allowing for external sorting control. * - multiple (Boolean) - Enables sorting by multiple columns simultaneously. The sorting order will be maintained across multiple columns based on the order of interaction. * - resetable (Boolean) - If set to true, clicking on the sorter cycles through three states: ascending, descending, and null (no sorting). The third click on the sorter will reset the sorting and restore the table to its original order. */ columnSorter: { type: PropType<boolean | Sorter>; }; /** * If `true` Displays table footer, which mirrors table header. (without column filter). * Or Array of objects or strings, where each element represents one cell in the table footer. * * Example items: * `['FooterCell', 'FooterCell', 'FooterCell']` * or * `[{ label: 'FooterCell', _props: { color: 'success' }, ...]` */ footer: { type: PropType<boolean | (FooterItem | string)[]>; }; /** * Set to false to remove table header. */ header: { type: BooleanConstructor; default: boolean; }; /** * Array of objects, where each object represents one item - row in table. Additionally, you can customize each row by passing them by [_props](http://coreui.io/vue/docs/components/table.html#ctablerow) key and single cell by [_cellProps](http://coreui.io/vue/docs/components/table.html#ctabledatacell). * * Examples: * - `_props: { color: 'primary', align: 'middle'}` * - `_cellProps: { all: { class: 'fw-semibold'}, 'name': { color: 'info' }}` */ items: { type: PropType<Item[]>; default: () => never[]; }; /** * The total number of items. Use if you pass a portion of data from an external source to let know component what is the total number of items. * * @since 4.8.0 */ itemsNumber: NumberConstructor; /** * Number of items per site, when pagination is enabled. */ itemsPerPage: { type: NumberConstructor; default: number; }; /** * Label for items per page selector. */ itemsPerPageLabel: { type: StringConstructor; default: string; }; /** * Items per page selector options. */ itemsPerPageOptions: { type: PropType<number[]>; default: () => number[]; }; /** * Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values: * - external (Boolean) - disables automatic 'itemsPerPage' change (use to change pages externaly by 'pagination-change' event). */ itemsPerPageSelect: { type: PropType<boolean | ItemsPerPageSelect>; }; /** * When set, table will have loading style: loading spinner and reduced opacity. When 'small' prop is enabled spinner will be also smaller. */ loading: BooleanConstructor; /** * ReactNode or string for passing custom noItemsLabel texts. */ noItemsLabel: { type: StringConstructor; default: string; }; /** * Enables default pagination. Set to true for default setup or pass an object with additional CPagination props. Default pagination will always have the computed number of pages that cannot be changed. The number of pages is generated based on the number of passed items and 'itemsPerPage' prop. If this restriction is an obstacle, you can make external CPagination instead. */ pagination: { type: PropType<boolean | Pagination>; }; /** * Properties to [CSmartPagination](https://coreui.io/vue/docs/components/smart-pagination#csmartpagination) component. */ paginationProps: ObjectConstructor; /** * Add checkboxes to make table rows selectable. */ selectable: BooleanConstructor; /** * Enables select all checkbox displayed in the header of the table. * * Can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic selection inside the component. * * @since 4.8.0 */ selectAll: { type: PropType<boolean | { external?: boolean; }>; }; /** * Array of selected objects, where each object represents one item - row in table. * * Example item: `{ name: 'John' , age: 12 }` * * @since 4.8.0 */ selected: { type: PropType<Item[]>; default: () => never[]; }; /** * State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. eg.: * { column: 'status', state: 'asc' } */ sorterValue: { type: PropType<SorterValue[] | SorterValue>; }; /** * Properties to [CTableBody](https://coreui.io/vue/docs/components/table/#ctablebody) component. */ tableBodyProps: ObjectConstructor; /** * Properties to [CTableFoot](https://coreui.io/vue/docs/components/table/#ctablefoot) component. */ tableFootProps: ObjectConstructor; /** * When set, displays table filter above table, allowing filtering by specific column. * * Column filter can be customized, by passing prop as object with additional options as keys. Available options: * - external (Boolean) - Disables automatic filtering inside component. * - lazy (Boolean) - Set to true to trigger filter updates only on change event. */ tableFilter: { type: PropType<boolean | TableFilter>; }; /** * The element represents a caption for a component. */ tableFilterLabel: { type: StringConstructor; default: string; }; /** * Specifies a short hint that is visible in the search input. */ tableFilterPlaceholder: { type: StringConstructor; default: string; }; /** * Value of table filter. */ tableFilterValue: StringConstructor; /** * Properties to [CTableHead](https://coreui.io/vue/docs/components/table/#ctablehead) component. */ tableHeadProps: ObjectConstructor; /** * Properties to [CTable](https://coreui.io/vue/docs/components/table/#ctable) component. */ tableProps: ObjectConstructor; }>> & Readonly<{ onActivePageChange?: ((...args: any[]) => any) | undefined; onRowClick?: ((...args: any[]) => any) | undefined; onSelectAll?: ((...args: any[]) => any) | undefined; onColumnFilterChange?: ((...args: any[]) => any) | undefined; onFilteredItemsChange?: ((...args: any[]) => any) | undefined; onItemsPerPageChange?: ((...args: any[]) => any) | undefined; onSelectedItemsChange?: ((...args: any[]) => any) | undefined; onSorterChange?: ((...args: any[]) => any) | undefined; onTableFilterChange?: ((...args: any[]) => any) | undefined; }>, { header: boolean; selected: Item[]; cleaner: boolean; loading: boolean; activePage: number; items: Item[]; clickableRows: boolean; noItemsLabel: string; selectable: boolean; itemsPerPage: number; itemsPerPageLabel: string; itemsPerPageOptions: number[]; tableFilterLabel: string; tableFilterPlaceholder: string; }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>; export { CSmartTable };