import './data-grid/data-grid.js'; import './data-list/data-list.js'; import './data-card/data-card.js'; import { LitElement, PropertyValues } from 'lit'; import { PagePreferenceProvider } from '@operato/p13n'; import { DataCard } from './data-card/data-card.js'; import { DataConsumer } from './data-consumer.js'; import { DataGrid } from './data-grid/data-grid.js'; import { DataList } from './data-list/data-list.js'; import { ColumnConfig, FetchHandler, FilterValue, GristConfig, GristData, GristRecord, GristSelectFunction, PaginationConfig, SortersConfig, ValidationReason } from './types.js'; /** * A custom element for rendering data in a grid, list, or card format. * * @element ox-grist */ export declare class DataGrist extends LitElement implements DataConsumer { static styles: import("lit").CSSResult[]; /** * The rendering mode of the component, which can be 'GRID', 'LIST', or 'CARD'. * Default is 'GRID'. * * @property {string} */ mode: 'GRID' | 'LIST' | 'CARD'; /** * The configuration object for the data grist. * * @property {Object} */ config: any; /** * The data to be displayed in the data grist. * * @property {GristData} */ data: GristData; /** * An array of selected records in the data grist. * * @property {GristRecord[]} */ selectedRecords?: GristRecord[]; /** * Indicates whether explicit fetching of data is enabled. If true, data will be fetched * only when `fetch` method is called. Default is false. * * @property {boolean} */ explicitFetch: boolean; /** * The fetch handler function used to retrieve data from a remote source. * * @property {FetchHandler} */ fetchHandler?: FetchHandler; /** * Additional fetch options to be passed to the fetch handler. * * @property {Object} */ fetchOptions: any; /** * An array of filter values to be applied to the data grist. * * @property {FilterValue[]} */ filters?: FilterValue[]; /** * An array of sorters to determine the order of records in the data grist. * * @property {SortersConfig} */ sorters?: SortersConfig; /** * The pagination configuration for the data grist. * * @property {PaginationConfig} */ pagination?: PaginationConfig; /** * Indicates whether URL parameters are sensitive to changes. If true, changes in URL * parameters will trigger data fetching. Default is undefined. * * @property {boolean} */ urlParamsSensitive?: boolean; personalConfigProvider: PagePreferenceProvider; personalConfig?: { columns?: Partial[]; [key: string]: any; }; _data: GristData; _config: GristConfig; private _showSpinner; head: HTMLElement; grist: DataGrid | DataList | DataCard; private wrap; private timeCapsule?; private snapshotTaker?; private dataProvider?; private pulltorefreshHandle?; private headroom?; private orginPaddingTop?; private originMarginTop?; private lastLocation; private pendingFetch?; private popstateEventHandler; private fetchParamsChangeEventHandler; firstUpdated(): Promise; connectedCallback(): Promise; disconnectedCallback(): void; private resetPullToRefresh; private setPullToRefresh; applyUpdatedConfiguration(): void; private setHeadroom; render(): import("lit-html").TemplateResult<1>; private onKeydown; private _onDocumentKeydown; /** * Gets the current state of the component. The state includes information about the * dirty records and their changes. * * @getter * @public * @type {string} */ get state(): string; /** * Undoes the previous change in the component's data by restoring it to the previous state. * This method is part of the TimeCapsule feature, allowing users to revert changes. */ undo(): void; /** * Redoes the previously undone change in the component's data by restoring it to the next state. * This method is part of the TimeCapsule feature, allowing users to reapply changes. */ redo(): void; /** * Fetches data from a data source and updates the component's data. This method is used to retrieve * new data or refresh the existing data in the component. * * @method * @param {boolean} reset - If true, the method resets the scroll position to the top. */ fetch(reset?: boolean): Promise; updated(changes: PropertyValues): Promise; /** * Represents the compiled configuration of the component, which includes various settings and * column configurations. You can access this property to get information about how the component * is configured. * * @getter * @public * @type {GristConfig} */ get compiledConfig(): GristConfig; /** * Returns the dirty data in the component, which includes the records that have been added, * modified, or deleted but have not been committed to the main data yet. * * @getter * @public * @type {GristData} - An object representing the dirty data. */ get dirtyData(): GristData; /** * Returns an array of GristRecord objects representing the records in the dirty state. These are * the records that have been added, modified, or deleted but have not been committed to the main * data yet. * * @getter * @public * @type {GristRecord[]} - An array of GristRecord objects representing the dirty records. */ get dirtyRecords(): GristRecord[]; /** * Exports a list of patches representing the changes in the dirty state of records. Each patch * contains information about whether a record was added, modified, or deleted, along with the * record's unique identifier and the changed field values. * * @param {Object} options - Export options that control the format of the patch list. * @param {string} options.flagName - The name of the flag field in the patch indicating the change type (default: 'patchFlag'). * @param {string} options.addedFlag - The flag value for added records (default: '+'). * @param {string} options.deletedFlag - The flag value for deleted records (default: '-'). * @param {string} options.modifiedFlag - The flag value for modified records (default: 'M'). * @param {string} options.idField - The name of the unique identifier field (default: 'id'). * @returns {Object[]} - An array of objects representing the patches. */ exportPatchList({ flagName, addedFlag, deletedFlag, modifiedFlag, idField }: { flagName?: string | undefined; addedFlag?: string | undefined; deletedFlag?: string | undefined; modifiedFlag?: string | undefined; idField?: string | undefined; }): any[]; /** * Exports the selected records or all records in the component, depending on the specified options. * You can use this method to export data from the component in various formats or for different purposes. * * @param {Object} options - Export options that control the behavior of the export. * @param {boolean} options.ifSelectedOnly - If true, exports only the selected records. If false, exports all records. * @param {boolean} options.includeHiddenField - If true, includes hidden fields in the exported data. * @returns {Object[]} - An array of objects representing the exported records. */ exportRecords({ ifSelectedOnly, includeHiddenField }?: { ifSelectedOnly?: boolean | undefined; includeHiddenField?: boolean | undefined; }): any[]; /** * Gets the currently selected records in the component. It returns an array of GristRecord objects * that are currently selected. You can access this getter to retrieve the selected records. * * @getter * @public * @type {GristRecord[]} */ get selected(): GristRecord[]; /** * Sets the currently selected records in the component. You can use this setter to programmatically * select specific records by providing an array of GristRecord objects to be selected. * * @setter * @public * @type {GristRecord[]} */ set selected(selected: GristRecord[]); /** * Selects records in the component based on the provided selector function. You can use this method * to programmatically select specific records in the component. * * @method * @param {GristSelectFunction} selector - A function that determines which records to select. * @param {boolean} reset - If true, clears the previous selection before applying the new one. * If false, adds to the existing selection. */ select(selector: GristSelectFunction, reset?: boolean): void; /** * Shows the loading spinner in the component's UI to indicate ongoing data loading or processing. * You can call this method to display the spinner when necessary. */ showSpinner(): void; /** * Hides the loading spinner in the component's UI to indicate that data loading or processing has completed. * You can call this method to hide the spinner when loading or processing is finished. */ hideSpinner(): void; /** * Focuses on the component, making it the active element in the document. This method is useful * when you want to programmatically set focus to the component. */ focus(): void; /** * Commits the changes made in the dirty state to the component's data. This method updates the * component's data with the changes made in the dirty state and clears the dirty state. */ commit(): void; /** * Shows the headroom element in the component. The headroom element is typically used for * displaying additional information or controls at the top of the component. */ showHeadroom(): void; /** * Hides the headroom element in the component. This method hides the additional information * or controls displayed at the top of the component. */ hideHeadroom(): void; /** * Toggles the visibility of the headroom element in the component. If the headroom element is * currently visible, this method hides it. If it's hidden, this method shows it. */ toggleHeadroom(): void; /** * Forced internal data to be reflected on the screen * Data changing through a normal method is automatically reflected on the screen, so it is a method that does not need to be used in general. * Therefore, it will be deprecated. * @method */ refresh(): void; /** * Resets the component's data to its original state before any changes were made. * This method discards all unsaved changes and restores the data to its initial state. * * @method * @public */ reset(): void; private traverseReset; private traverseExpanded; /** * Checks for dirty records in the component's data and marks them as dirty. * Dirty records are those that have unsaved changes. */ checkDirties(): void; /** * Clones the selected records in the component's data. It creates a copy of the selected records * and marks them as new (added) records. */ cloneSelectedRecords(): void; /** * Adds child nodes to selected records in the component's tree data. It allows users to add child nodes * to the selected parent records. */ addChildNodes(): void; /** * Adds sibling nodes to selected records in the component's tree data. It allows users to add sibling nodes * to the selected records. */ addSiblingNodes(): void; /** * Deletes the selected records in the component's data. It removes the selected records from the data, * optionally marking them as deleted. * * @method * @param {boolean} dirty - If true, the method marks the records as deleted. */ deleteSelectedRecords(dirty?: boolean): void; /** * Adds a new record to the data grid. The added record is marked as newly created * by setting the `__dirty__` flag to '+'. This flag indicates that the record * is in a "new" state and hasn't been committed to the main data yet. * * @param {GristRecord} [record] - An optional record to add. If no record is provided, * an empty record with the `__dirty__` flag set to '+' will be added. */ addRecord(record?: GristRecord): void; /** * Adds a new record to the top of the data grid. The added record is marked as newly created * by setting the `__dirty__` flag to '+'. This flag indicates that the record * is in a "new" state and hasn't been committed to the main data yet. * * This method is useful when you need to add new records at the top of the grid * without changing the default behavior of the appendable row. * * @param {GristRecord} [record] - An optional record to add. If no record is provided, * an empty record with the `__dirty__` flag set to '+' will be added. */ addRecordToTop(record?: GristRecord): void; /** * Retrieves the search text used for filtering records. * * @property {string} */ get searchText(): string; /** * Sets the search text for filtering records. * * @property {string} */ set searchText(searchText: string); /** * Returns the current pagination limit. * @returns {number} The current pagination limit value */ getCurrentLimit(): number; /** * Checks the validity of dirty records. * @returns {Array<{record: GristRecord, invalidFields: Array<{field: string, reason: ValidationReason}>}>} List of invalid records and their corresponding invalid fields */ checkDirtyRecordsValidity(): { record: GristRecord; invalidFields: { field: string; reason: ValidationReason; }[]; }[]; }