import type { EventSubscription } from '@slickgrid-universal/event-pub-sub'; import { type FieldType, type OperatorType } from '../enums/index.js'; import type { Aggregator, CancellablePromiseWrapper, Column, GridOption, TreeDataPropNames } from '../interfaces/index.js'; import type { Observable, RxJsFacade, Subject, Subscription } from './rxjsFacade.js'; /** Cancelled Extension that can be only be thrown by the `cancellablePromise()` function */ export declare class CancelledException extends Error { constructor(message: string); } /** * From an input Promise, make it cancellable by wrapping it inside an object that holds the promise and a `cancel()` method * @param {Promise} - input Promise * @returns {Object} - Promise wrapper that holds the promise and a `cancel()` method */ export declare function cancellablePromise(inputPromise: Promise): CancellablePromiseWrapper; /** * Try casting an input of type Promise | Observable into a Promise type. * @param object which could be of type Promise or Observable * @param fromServiceName string representing the caller service name and will be used if we throw a casting problem error */ export declare function castObservableToPromise(rxjs: RxJsFacade, input: Promise | Observable | Subject, fromServiceName?: string): Promise; export declare function createDocumentFragmentOrElement(gridOptions?: GridOption, defaultElmType?: 'span' | 'div'): DocumentFragment | HTMLElement; /** * Mutate the original array and add a treeLevel (defaults to `__treeLevel`) property on each item. * @param {Array} treeArray - hierarchical tree array * @param {Object} options - options containing info like children & treeLevel property names * @param {Number} [treeLevel] - current tree level */ export declare function addTreeLevelByMutation(treeArray: T[], options: Required>, treeLevel?: number): void; export declare function addTreeLevelAndAggregatorsByMutation(treeArray: T[], options: { aggregator: Aggregator; } & Required>, treeLevel?: number, parent?: T): void; /** * Convert a hierarchical (tree) array (with children) into a flat array structure array (where the children are pushed as next indexed item in the array) * Note: for perf reasons, it mutates the array by adding extra props like `treeLevel` * @param {Array} treeArray - input hierarchical (tree) array * @param {Object} options - you can provide "childrenPropName" and other options (defaults to "children") * @return {Array} output - Parent/Child array */ export declare function flattenToParentChildArray(treeArray: T[], options?: { aggregators?: Aggregator[]; shouldAddTreeLevelNumber?: boolean; } & Omit): any[]; /** Find the associated property name from the Tree Data option when found or return a default property name that we defined internally */ export declare function getTreeDataOptionPropName(treeDataOptions: Partial | undefined, optionName: keyof TreeDataPropNames, defaultDataIdPropName?: string): string; /** * Convert a flat array (with "parentId" references) into a hierarchical (tree) dataset structure (where children are array(s) inside their parent objects) * Note: for perf reasons, it mutates the array by adding extra props like `treeLevel` * @param flatArray input array (flat dataset) * @param options you can provide the following tree data options (which are all prop names, except 1 boolean flag, to use or else use their defaults):: collapsedPropName, childrenPropName, parentPropName, identifierPropName and levelPropName and initiallyCollapsed (boolean) * @return roots - hierarchical (tree) data view array */ export declare function unflattenParentChildArrayToTree(flatArray: P[], options?: { aggregators?: Aggregator[]; initiallyCollapsed?: boolean; } & Omit): T[]; /** * Find an item from a tree (hierarchical) view structure (a parent that can have children array which themseleves can have children and so on) * @param {Array} treeArray - hierarchical tree dataset * @param {Function} predicate - search predicate to find the item in the hierarchical tree structure * @param {String} childrenPropertyName - children property name to use in the tree (defaults to "children") */ export declare function findItemInTreeStructure(treeArray: T[], predicate: (item: T) => boolean, childrenPropertyName: string): T | undefined; /** * Take a number (or a string) and display it as a formatted decimal string with defined minimum and maximum decimals * @param input * @param minDecimal * @param maxDecimal * @param decimalSeparator * @param thousandSeparator */ export declare function decimalFormatted(input: number | string, minDecimal?: number, maxDecimal?: number, decimalSeparator?: '.' | ',', thousandSeparator?: ',' | '_' | '.' | ' ' | ''): string; /** * Format a number following options passed as arguments (decimals, separator, ...) * @param input * @param minDecimal * @param maxDecimal * @param wrapNegativeNumberInBraquets * @param symbolPrefix * @param symbolSuffix * @param decimalSeparator * @param thousandSeparator */ export declare function formatNumber(input: number | string, minDecimal?: number, maxDecimal?: number, wrapNegativeNumberInBraquets?: boolean, symbolPrefix?: string, symbolSuffix?: string, decimalSeparator?: '.' | ',', thousandSeparator?: ',' | '_' | '.' | ' ' | ''): string; /** * When a queryFieldNameGetterFn is defined, then get the value from that getter callback function * @param {Column} columnDef * @param {Object} dataContext * @param {String} defaultValue - optional value to use if value isn't found in data context * @return outputValue */ export declare function getCellValueFromQueryFieldGetter(columnDef: Column, dataContext: any, defaultValue: any): string; /** * From a dot (.) notation path, find and return a property within an object given a path * @param object - object input * @param path - path of the complex object, string with dot (.) notation * @returns outputValue - the object property value found if any */ export declare function getDescendantProperty(object: T, path: string | undefined): any; /** Get I18N Translation Prefix, defaults to an empty string */ export declare function getTranslationPrefix(gridOptions?: GridOption): string; /** From a column definition, find column type */ export declare function getColumnFieldType(columnDef: Column): FieldType; /** Return all Date field types that exists in the library */ export declare function getAllDateFieldTypes(): FieldType[]; /** Verify if the identified column is of type Date */ export declare function isColumnDateType(fieldType?: FieldType): boolean; /** * Mapper for query operators (ex.: `<=` → `LE`, `>` → `GT`, ...) * @param string operator * @returns string map */ export declare function mapOperatorType(operator: OperatorType): OperatorType; /** * Find equivalent short designation of an Operator Type or Operator String. * When using a Compound Filter, we use the short designation and so we need the mapped value. * For example `StartsWith` short designation is `a*`, then `GE` → `>=`, ... */ export declare function mapOperatorToShorthandDesignation(operator: OperatorType): OperatorType; /** * Mapper for query operator by a Filter Type * For example a multiple-select typically uses 'IN' operator * @param operator * @returns string map */ export declare function mapOperatorByFieldType(fieldType: FieldType): OperatorType; /** * Takes an object and allow to provide a property key to omit from the original object * @param {Object} obj - input object * @param {String} omitKey - object property key to omit * @returns {String} original object without the property that user wants to omit */ export declare function objectWithoutKey(obj: T, omitKey: keyof T): T; /** * Format a number or a string into a string that is separated every thousand, * the default separator is a comma but user can optionally pass a different one * @param inputValue * @param separator default to comma "," * @returns string */ export declare function thousandSeparatorFormatted(inputValue: string | number | null, separator?: ',' | '_' | '.' | ' ' | ''): string | null; /** * Uses the logic function to find an item in an array or returns the default * value provided (empty object by default) * @param any[] array the array to filter * @param function logic the logic to find the item * @param any [defaultVal={}] the default value to return * @return object the found object or default value */ export declare function findOrDefault(array: T[], logic: (item: T) => boolean, defaultVal?: {}): any; /** * From an input that could be a Promise, an Observable, a Subject or a Fetch * @param {Promise | Observable | Subject} input * @param {RxJsFacade} rxjs * @returns {Promise} */ export declare function fetchAsPromise(input?: T[] | Promise | Observable | Subject, rxjs?: RxJsFacade): Promise; /** * Take all the columns defined in the datagrid and also the preset columns, * then sort by the original column definitions unless a different order is specified in the presets which is given precedence * @param allColumns * @param presetColumns * @returns */ export declare function sortPresetColumns(allColumns: Column[], presetColumns: Column[]): Column[]; /** * Unsubscribe all Subscriptions * It will return an empty array if it all went well * @param subscriptions */ export declare function unsubscribeAll(subscriptions: Array): Array; //# sourceMappingURL=utilities.d.ts.map