import type { CombiTableColumn, CombiTableOp, CombiTableExtraButton, CombiTablePresets } from '../combitabletypes'; import { PartialDateType } from '../types'; type Props = { /** the rows to display */ rows: { [key: string]: any | undefined; }[]; /** * Column configuration, in the order they will be displayed */ columns: CombiTableColumn[]; /** * Whether to enable sorting. Default false */ enableSort?: boolean; /** * Whether to enable filtering. Default false */ enableFilter?: boolean; /** * If no sorting is defined in the URL, sort on this */ defaultSort: string; /** * Date format for date cols. Default `yyyy-mm-dd`. * * Possible values `yyyy-mm-dd`, `dd-mm-yyyy`, `nn-dd-yyyy` */ dateFormat?: string; /** * Number of rows to show per page. Default 0 which is no pagination */ paginate?: number | "auto" | "none"; /** * Whether there are more rows before the ones passed to this table * (activates the Previous button). Default false */ havePrevious?: boolean; /** * Whether there are more rows after the ones passed to this table * (activates the Next button). Default false */ haveNext?: boolean; /** * URL to call to add a new row. If not given, adding is not activated. * If a function is passed instead of a URL, that function is called * with the record as its argument. It should return undefined or true * on success and false on failure. */ addUrl?: string | ((data: { [key: string]: any; }) => { [key: string]: any; } | Promise<{ [key: string]: any; }>); /** * URL to call to link this record to another. If not given, linking is not activated. */ linkUrl?: string; /** * URL to call to unlink this record from another. If not given, unlinking is not activated. */ unlinkUrl?: string; /** * URL to call to edit a row. If not given, editing is not activated. * If a function is passed instead of a URL, that function is called * with the record as its argument. It should return undefined or true * on success and false on failure. */ editUrl?: string | ((data: { [key: string]: any; }) => { [key: string]: any; } | Promise<{ [key: string]: any; }>); /** * URL to call to delete a row. If not given, deleting is not activated. * If a function is passed instead of a URL, that function is called * with the primary key and index in the row array. * It should return undefined or true * on success and false on failure. */ deleteUrl?: string | ((pk: string | number, idx: number) => void | Promise); /** * If passed, any column in this map will be pre-populated with * the corresponding value when a new record is being created. If * it is not here, the field will be empty. */ presets?: CombiTablePresets; /** * Tailwind CSS class for clickable fields. Default empty */ linkFormat?: string; /** * Use this if you have multiple tables on one page. Pass this * as the suffix to {@link SearchUrl} */ urlSuffix?: string; /** * Tailwind table with type `auto` or `fixed`. Default `auto` */ widthType?: "auto" | "fixed"; /** * Primary key field name, Only needed when activating, edit, add or delete. */ primaryKey?: string; /** * Enable selecting rows. Default false */ select?: boolean; /** * Height of page not occupied by this table. Needed to put the * buttons at the bottom of the page and put a scrollbar on the table. * * If not given, the whole page will scroll. */ restOfScreenHeight?: number; /** * Whether to make the title row sticky. Default false. */ stickyHeadRow?: boolean; /** * Optional operations when setting `select` to true. */ ops?: CombiTableOp[]; /** * Turn on preview mode. In this mode, only a small number of rows * is displayed, without the manipulation buttons. Intented to show * the user what column configuration will look like. * Default false. */ preview?: boolean; /** * Use this to make a whole row linkable, as opposed to individual columns. * * Will not give intended results if you have select buttons or operations * (edit, delete) on the row. */ link?: ((row: { [key: string]: any; }, i?: number) => string); /** * Bind to this to get a list of primary keys that have been selected * when `select` is true. * Default empty set. */ primaryKeysChecked?: (string | number)[]; onUpdate?: () => Promise; /** * Set this if you want to be able to disable/reenable all * editinng */ updateDisabled?: boolean; /** * Bind to this to find out when the table has unsaved data */ dirty?: boolean; /** * When a value is empty, display this */ emptyValue?: string; /** * Extra buttons to put next to the Add button */ addExtra?: CombiTableExtraButton[]; /** * Extra buttons to put in the navigation area (bottom of the table) */ navExtra?: CombiTableExtraButton[]; /** * Typing this character in a filter field will match the empty string. * * Default "-" */ emptySearch?: string; /** * Language for buttons etc. * * Default "en". Other supported values "de" and "el". */ lang?: string; /** * This component can also function as an input for DetailsFieldSet, * like a DetailsField. In this case. addUrl, editUrl, deleteUrl, * linkUrl and unlinkUrl are ignored and the parameters passed here * determine which of these functions are enabled. Linking and * unlinking are not currently supported in this mode. * * The add and edit functions are passed the following object : * name: {addItems: {[key:string]:any}[], editItems: {[key:string]:any}[], * deleteItems: (string|number)[]}. * Note that editItems also include _pk per row (addItems does as * well but it is a negative number, unpersisted number) */ detailsField?: { name: string; enableAdd?: boolean; enableEdit?: boolean; enableDelete?: boolean; }; /** * If true, columns can be resized. * * Only supported if widthType = "fixed" */ resizable?: boolean; /** * If defined, this will be called when resizing starts */ resizeStarted?: (colidx: number) => Promise; /** * If defined, this will be called every resizeUpdateInterval move moves */ resized?: (colidx: number, width: string) => Promise; /** * See resized. Default 1 */ resizeUpdateInterval?: number; resizeEnded?: (colidx: number, width: string) => Promise; /** * Maximum height of dropdown before adding a scrollbar. * * Default "10rem"". */ maxDropdownHeight?: string; tableClasses?: string; zebra?: boolean; tableStyles?: string; extraRowLinks?: { label: string; fn: (row: { [key: string]: any | undefined; }) => Promise | void; width: number; }[]; filterCheckBoxes?: { title: string; tag: string; default: boolean; }[]; buttonLabels?: { [key: string]: any; }; }; /** * Table component with adding, editing, deleting filtering * and type conversion from string fields * * Used in combination with {@link SearchUrl} which implements sorting * and filtering as URL parameters */ declare const CombiTable: import("svelte").Component string; printPartialDate: (date: Date | undefined | null, dateType: PartialDateType, edit?: boolean) => string; printTime: (date: Date | undefined | null, edit?: boolean) => string; printDateTime: (date: Date | undefined | null, edit?: boolean) => string; parseDateTime: (val: string, df?: string | undefined) => Date; stringIsDateTime: (val: string) => boolean; stringIsDate: (val: string) => boolean; stringIsTime: (val: string) => boolean; stringIsDateMonth: (val: string) => boolean; stringIsDateYear: (val: string) => boolean; stringIsPartialDate: (val: string) => boolean; parseDate: (val: string, df?: string | undefined) => Date; parsePartialDate: (val: string) => { date: Date; type: PartialDateType; }; parseTime: (val: string) => Date; saveEdit: (confirm?: { col: string; title: string; value: string; type: string; }[]) => Promise; showInfo: (info: string) => void; showError: (errors: string[] | string) => void; }, "dirty" | "rows" | "primaryKeysChecked">; type CombiTable = ReturnType; export default CombiTable;