@revolist/revogrid 4.10.2 → 4.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/cjs/{column.drag.plugin-08ca04f4.js → column.drag.plugin-1005d5e5.js} +3 -3
  2. package/dist/cjs/{column.drag.plugin-08ca04f4.js.map → column.drag.plugin-1005d5e5.js.map} +1 -1
  3. package/dist/cjs/{column.service-2670e6e7.js → column.service-07fca9ee.js} +13 -7
  4. package/dist/cjs/column.service-07fca9ee.js.map +1 -0
  5. package/dist/cjs/{header-cell-renderer-db089f54.js → header-cell-renderer-452be4b4.js} +2 -2
  6. package/dist/cjs/{header-cell-renderer-db089f54.js.map → header-cell-renderer-452be4b4.js.map} +1 -1
  7. package/dist/cjs/index.cjs.js +4 -3
  8. package/dist/cjs/index.cjs.js.map +1 -1
  9. package/dist/cjs/revo-grid.cjs.entry.js +9 -8
  10. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  11. package/dist/cjs/revogr-attribution_7.cjs.entry.js +1 -1
  12. package/dist/cjs/revogr-data_4.cjs.entry.js +17 -18
  13. package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
  14. package/dist/collection/components/data/cell-renderer.js +11 -9
  15. package/dist/collection/components/data/cell-renderer.js.map +1 -1
  16. package/dist/collection/components/data/column.service.js +5 -5
  17. package/dist/collection/components/data/column.service.js.map +1 -1
  18. package/dist/collection/components/data/revogr-data.js +10 -13
  19. package/dist/collection/components/data/revogr-data.js.map +1 -1
  20. package/dist/collection/components/revoGrid/revo-grid.js +3 -3
  21. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  22. package/dist/collection/plugins/sorting/sorting.plugin.js +7 -6
  23. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  24. package/dist/collection/serve/data.js +12 -9
  25. package/dist/collection/types/interfaces.js.map +1 -1
  26. package/dist/collection/utils/column.utils.js +7 -2
  27. package/dist/collection/utils/column.utils.js.map +1 -1
  28. package/dist/esm/{column.drag.plugin-b7bba0da.js → column.drag.plugin-8ea8fdab.js} +3 -3
  29. package/dist/esm/{column.drag.plugin-b7bba0da.js.map → column.drag.plugin-8ea8fdab.js.map} +1 -1
  30. package/dist/esm/{column.service-9b0603f4.js → column.service-5d1cf29d.js} +13 -8
  31. package/dist/esm/column.service-5d1cf29d.js.map +1 -0
  32. package/dist/esm/{header-cell-renderer-fce020c3.js → header-cell-renderer-49cd23aa.js} +2 -2
  33. package/dist/esm/{header-cell-renderer-fce020c3.js.map → header-cell-renderer-49cd23aa.js.map} +1 -1
  34. package/dist/esm/index.js +3 -3
  35. package/dist/esm/revo-grid.entry.js +9 -8
  36. package/dist/esm/revo-grid.entry.js.map +1 -1
  37. package/dist/esm/revogr-attribution_7.entry.js +1 -1
  38. package/dist/esm/revogr-data_4.entry.js +17 -18
  39. package/dist/esm/revogr-data_4.entry.js.map +1 -1
  40. package/dist/revo-grid/{column.drag.plugin-b7bba0da.js → column.drag.plugin-8ea8fdab.js} +2 -2
  41. package/dist/revo-grid/column.service-5d1cf29d.js +5 -0
  42. package/dist/revo-grid/column.service-5d1cf29d.js.map +1 -0
  43. package/dist/revo-grid/{header-cell-renderer-fce020c3.js → header-cell-renderer-49cd23aa.js} +2 -2
  44. package/dist/revo-grid/index.esm.js +1 -1
  45. package/dist/revo-grid/index.esm.js.map +1 -1
  46. package/dist/revo-grid/revo-grid.entry.js +1 -1
  47. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  48. package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
  49. package/dist/revo-grid/revogr-data_4.entry.js +1 -1
  50. package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
  51. package/dist/types/components/data/cell-renderer.d.ts +2 -4
  52. package/dist/types/components/data/column.service.d.ts +2 -2
  53. package/dist/types/components/data/revogr-data.d.ts +4 -4
  54. package/dist/types/components/revoGrid/revo-grid.d.ts +3 -3
  55. package/dist/types/components.d.ts +16 -16
  56. package/dist/types/plugins/sorting/sorting.plugin.d.ts +3 -1
  57. package/dist/types/types/interfaces.d.ts +5 -5
  58. package/dist/types/utils/column.utils.d.ts +1 -0
  59. package/hydrate/index.js +35 -30
  60. package/hydrate/index.mjs +35 -30
  61. package/package.json +1 -1
  62. package/readme.md +3 -3
  63. package/standalone/column.service.js +12 -7
  64. package/standalone/column.service.js.map +1 -1
  65. package/standalone/index.js +1 -1
  66. package/standalone/revo-grid.js +7 -6
  67. package/standalone/revo-grid.js.map +1 -1
  68. package/standalone/revogr-data2.js +17 -18
  69. package/standalone/revogr-data2.js.map +1 -1
  70. package/standalone/revogr-header2.js +1 -1
  71. package/standalone/revogr-overlay-selection2.js +1 -1
  72. package/dist/cjs/column.service-2670e6e7.js.map +0 -1
  73. package/dist/esm/column.service-9b0603f4.js.map +0 -1
  74. package/dist/revo-grid/column.service-9b0603f4.js +0 -5
  75. package/dist/revo-grid/column.service-9b0603f4.js.map +0 -1
  76. /package/dist/revo-grid/{column.drag.plugin-b7bba0da.js.map → column.drag.plugin-8ea8fdab.js.map} +0 -0
  77. /package/dist/revo-grid/{header-cell-renderer-fce020c3.js.map → header-cell-renderer-49cd23aa.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { VNode } from '@stencil/core';\n\nimport {\n DimensionCols,\n DimensionRows,\n DimensionColPin,\n DimensionType,\n MultiDimensionType,\n} from './dimension';\nimport {\n Cell,\n EditorCtr,\n FocusedCells,\n OldNewRangeMapping,\n RangeArea,\n SelectionStoreState,\n} from './selection';\nimport type { Observable } from '../utils/store.utils';\nimport { JSXBase } from '@stencil/core/internal';\n\nexport type Nullable<T> = {\n [P in keyof T]: T[P] | null;\n};\n\n/**\n * Advanced column data schema model.\n * Used for transpassing data to cell renderer and editor.\n */\nexport type ColumnDataSchemaModel = {\n /**\n * Column prop used for mapping value to cell from data source model/row\n */\n prop: ColumnProp;\n /**\n * Row data object\n */\n model: DataType;\n /**\n * Column data object\n */\n column: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n /**\n * Column type based on viewport\n */\n colType: DimensionCols;\n /**\n * Row type based on viewport\n */\n type: DimensionRows;\n /**\n * Row models based on viewport\n */\n data: DataType[];\n /**\n * Current cell data\n */\n value: any;\n};\n/**\n * Template property for each cell, extends the column data schema model.\n * Additionally, it provides access to the providers injected into the template.\n */\nexport interface CellTemplateProp extends ColumnDataSchemaModel {\n /**\n * Providers injected into the template\n */\n providers: Providers;\n}\n/**\n * The ReadOnlyFormat type is a boolean value or a function that takes ColumnDataSchemaModel\n * as a parameter and returns a boolean value.\n *\n * If it is a boolean value, it represents whether the cell in question is read-only.\n * If it is a function, it returns whether the cell in question is read-only based on the provided\n * ColumnDataSchemaModel.\n */\nexport type ReadOnlyFormat =\n | boolean\n | ((params: ColumnDataSchemaModel) => boolean);\nexport type RowDrag =\n | boolean\n | {\n (params: ColumnDataSchemaModel): boolean;\n };\n/**\n * `ColumnGrouping` type is used to define a grouping in a column.\n */\nexport type ColumnGrouping<T = any> = {\n /**\n * An array of objects that represent the children of the grouping.\n */\n children: (ColumnGrouping<T> | ColumnRegular)[];\n /**\n * A `DataFormat` object that represents the name of the grouping.\n */\n name: DataFormat<T>;\n};\n/**\n * Configuration for header inner template properties\n */\nexport interface ColumnProperties {\n /**\n * Header inner template\n * Function/component to render custom header content\n */\n columnTemplate?: ColumnTemplateFunc;\n /**\n * Header Cell properties\n * Custom function/component to render header properties\n */\n columnProperties?: ColPropertiesFunc;\n}\n/**\n * Type that represents a collection of column types.\n * The keys are the names of the column types and the values are the corresponding column type objects.\n */\nexport type ColumnTypes = {\n /**\n * The name of the column type.\n */\n [name: string]: ColumnType;\n};\n\n/**\n * Interface for custom cell renderer.\n */\nexport interface CellTemplate {\n // TODO: Add Promise support for template and all custom function so user will be able to use async render on the light speed\n (\n createElement: HyperFunc<VNode>,\n props: CellTemplateProp,\n additionalData?: any,\n ): any;\n}\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnType extends ColumnProperties {\n /**\n * Represents whether the column or cell is read-only.\n * Can be a boolean or a function that returns a boolean.\n * The function receives column data as a parameter.\n */\n readonly?: ReadOnlyFormat;\n /**\n * Represents the default column size.\n */\n size?: number;\n /**\n * Represents the minimal column size.\n * This property cannot be less than cell padding\n * in order to keep performance on top and minimize DOM elements number.\n */\n minSize?: number;\n /**\n * Represents the maximum column size.\n */\n maxSize?: number;\n /**\n * Represents a custom editor defined in @editors property.\n * Can be a string or an editor constructor function.\n */\n editor?: string | EditorCtr;\n /**\n * Represents cell properties for custom styling, classes, and events.\n */\n cellProperties?: PropertiesFunc;\n /**\n * Represents the cell template for custom rendering.\n */\n cellTemplate?: CellTemplate;\n /**\n * Represents the cell compare function for custom sorting.\n */\n cellCompare?: CellCompareFunc;\n\n /**\n * Represents the cell value parse function for custom parsing.\n * Currently only used for filtering.\n */\n cellParser?: (model: DataType, column: ColumnRegular) => any;\n}\nexport type Order = 'asc' | 'desc' | undefined;\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n *\n */\n/**\n * ColumnRegular interface represents regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnRegular extends ColumnType {\n /**\n * Column prop used for mapping value to cell from data source model/row, used for indexing.\n */\n prop: ColumnProp;\n /**\n * Column pin 'colPinStart'|'colPinEnd'.\n */\n pin?: DimensionColPin;\n /**\n * Column header text.\n */\n name?: any;\n /**\n * Column size would be changed based on space left.\n */\n autoSize?: boolean;\n /**\n * Filter. Require filter plugin to be installed and activated through grid config @filter.\n */\n filter?: boolean | string | string[];\n /**\n * Is column can be sorted, check @cellCompare function for custom sorting.\n */\n sortable?: boolean;\n /**\n * Sort order.\n */\n order?: Order;\n /**\n * Is cell in column or individual can be dragged.\n */\n rowDrag?: RowDrag;\n /**\n * Represents type defined in @columnTypes property through grid config.\n */\n columnType?: string;\n /**\n * Function called before column applied to the store.\n */\n beforeSetup?(rgCol: ColumnRegular): void;\n /**\n * Additional properties can be added to the column definition.\n */\n [key: string]: any;\n}\n\nexport type ColumnData = (ColumnGrouping | ColumnRegular)[];\n/**\n * Column template property.\n * Contains extended properties for column.\n */\nexport interface ColumnTemplateProp extends ColumnRegular {\n /**\n * Providers injected into the template.\n */\n providers: Providers<DimensionCols | 'rowHeaders'>;\n /**\n * Index of the column, used for mapping value to cell from data source model/row.\n */\n index: number;\n}\n\nexport type ColumnPropProp = ColumnGrouping | ColumnTemplateProp;\n// Column prop used for mapping value to cell from data source model/row, used for indexing.\nexport type ColumnProp = string | number;\n\nexport type DataFormat<T = any> = T;\n\n/**\n * Additional properties applied to the cell.\n * Contains properties for custom cell rendering.\n */\nexport type CellProps = JSXBase.HTMLAttributes<HTMLDivElement> & {\n className?: JSXBase.HTMLAttributes<HTMLDivElement>['class'];\n // Additional properties for custom cell rendering\n [attr: string]: string | number | object | boolean | undefined;\n};\n\n\n/**\n * Providers for grid which are going to be injected into each cell template\n */\nexport type Providers<T = DimensionRows> = {\n /**\n * Dimension type (e.g. row or column)\n */\n type: T;\n /**\n * Flag indicating if grid is in readonly mode\n */\n readonly: boolean;\n /**\n * Data source store\n */\n data: Observable<DataSourceState<any, any>> | ColumnRegular[];\n /**\n * Viewport store\n */\n viewport: Observable<ViewportState>;\n /**\n * Dimension store\n */\n dimension: Observable<DimensionSettingsState>;\n /**\n * Selection store\n */\n selection: Observable<SelectionStoreState>;\n};\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n // (tag: any): T;\n (tag: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, data: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: T): T;\n}\n/**\n * `FocusTemplateFunc` is a function that takes an HTML tag or component, and\n * returns a JSX element. This function is used to create JSX elements in a\n * context where JSX is not valid.\n */\nexport type FocusTemplateFunc = (\n createElement: HyperFunc<VNode>,\n detail: FocusRenderEvent,\n) => any;\n\n/**\n * `CellCompareFunc` is a function that takes the column property to compare,\n * the data of the first cell, and the data of the second cell. It returns a\n * number indicating the relative order of the two cells.\n */\nexport type CellCompareFunc = (\n // The column property to compare.\n prop: ColumnProp,\n // The data of the first cell.\n a: DataType,\n // The data of the second cell.\n b: DataType,\n) => number;\nexport type ColumnTemplateFunc = (\n createElement: HyperFunc<VNode>,\n props: ColumnTemplateProp,\n additionalData?: any,\n) => any;\nexport type PropertiesFunc = (\n props: ColumnDataSchemaModel,\n) => CellProps | void | undefined;\nexport type ColPropertiesFunc = (\n props: ColumnPropProp,\n) => CellProps | void | undefined;\nexport type DataType<D = any> = {\n [T in ColumnProp]: DataFormat<D>;\n};\n\nexport type DataLookup<T = any> = {\n [rowIndex: number]: DataType<T>;\n};\n/**\n * `RowDefinition` is a type that represents a row definition in the\n * viewport.\n */\nexport type RowDefinition = {\n /**\n * The type of the row.\n */\n type: DimensionRows;\n /**\n * The size of the row.\n */\n size: number;\n /**\n * The index of the row.\n */\n index: number;\n};\nexport interface RowHeaders extends ColumnRegular {}\n/**\n * `ViewPortResizeEvent` is an object that contains information about a resize\n * event in the viewport.\n */\nexport type ViewPortResizeEvent = {\n /* The dimension of the viewport being resized. */\n dimension: DimensionType;\n /* The new size of the viewport. */\n size: number;\n /* Indicates whether the resize event is for a row header. */\n rowHeader?: boolean;\n};\n\n/**\n * `ViewPortScrollEvent` is an object that contains information about a scroll\n * event in the viewport.\n */\nexport type ViewPortScrollEvent = {\n /**\n * The dimension of the viewport being scrolled.\n */\n dimension: DimensionType;\n /**\n * The coordinate of the scroll event.\n */\n coordinate: number;\n /**\n * The change in coordinate between scroll events.\n */\n delta?: number;\n /**\n * Indicates whether the scroll event occurred outside the viewport.\n */\n outside?: boolean;\n};\n\n/**\n * `InitialHeaderClick` represents the information needed to handle a click\n * event on the initial column header.\n */\nexport type InitialHeaderClick = {\n /**\n * The index of the column header that was clicked.\n */\n index: number;\n /**\n * The original mouse event that triggered the click.\n */\n originalEvent: MouseEvent;\n /**\n * The column that was clicked.\n */\n column: ColumnRegular;\n providers: Providers<DimensionCols | 'rowHeaders'>;\n};\n\n/**\n * `Range` is an object that represents a range of values.\n */\nexport type Range = {\n /**\n * The start of the range.\n */\n start: number;\n /**\n * The end of the range.\n */\n end: number;\n};\n\n/**\n * `ViewportStateItems` is an object that represents the items in a viewport\n * along with their corresponding range.\n */\nexport type ViewportStateItems = {\n /**\n * The items in the viewport.\n */\n items: VirtualPositionItem[];\n} & Range;\n\n/**\n * `ViewportState` is an object that represents the state of a viewport.\n */\nexport interface ViewportState extends ViewportStateItems {\n /**\n * The number of real items in the viewport.\n */\n realCount: number;\n /**\n * The virtual size of the viewport.\n */\n virtualSize: number;\n}\n\n/**\n * `ViewSettingSizeProp` is a record that maps column or row indexes to their\n * corresponding sizes.\n */\nexport type ViewSettingSizeProp = Record<string, number>;\n\n/**\n * `VirtualPositionItem` is an object that represents a virtual position item\n * in the viewport.\n */\nexport interface VirtualPositionItem extends PositionItem {\n /**\n * The size of the virtual position item.\n */\n size: number;\n}\nexport type DataSourceState<\n T extends DataType | ColumnRegular,\n ST extends DimensionRows | DimensionCols,\n> = {\n // items - index based array for mapping to source tree\n items: number[];\n // all items, used as proxy for sorting, trimming and others manipulations\n proxyItems: number[];\n // original data source\n source: T[];\n // grouping\n groupingDepth: number;\n groups: Record<any, any>;\n // data source type\n type: ST;\n // trim data, to hide entities from visible data source\n trimmed: Record<any, any>;\n};\nexport interface PositionItem {\n itemIndex: number;\n start: number;\n end: number;\n}\n/**\n * Object containing information about calculated dimensions.\n * Used for both columns and rows.\n */\nexport interface DimensionCalc {\n /**\n * Array of indexes of visible items.\n */\n indexes: number[];\n\n /**\n * Count of visible items.\n */\n count: number;\n\n /**\n * Array of indexes of visible items.\n * Used for mapping items to their position in DOM.\n */\n positionIndexes: number[];\n\n /**\n * Mapping of position to item.\n * Used for mapping position in DOM to item.\n */\n positionIndexToItem: {\n /**\n * Position in DOM.\n */\n [position: number]: PositionItem;\n };\n\n /**\n * Mapping of index to item.\n * Used for mapping index in data source to item.\n */\n indexToItem: {\n /**\n * Index in data source.\n */\n [index: number]: PositionItem;\n };\n\n /**\n * Object containing information about trimmed data.\n * Used for hiding entities from visible data source.\n */\n trimmed: { [index: number]: number} | null;\n\n /**\n * Object containing size for each visible item.\n * provider stores only changed sizes, not all of them\n * same as indexes but for sizes and positions\n * virtual item index to size\n */\n sizes: ViewSettingSizeProp;\n}\n/**\n * Represents the settings state of a dimension.\n * It extends the calculation properties of a dimension.\n * It also includes the real size and origin item size of the dimension.\n */\nexport interface DimensionSettingsState extends DimensionCalc {\n /**\n * Represents the real size of the dimension.\n */\n realSize: number;\n\n /**\n * Represents the origin item size of the dimension.\n */\n originItemSize: number;\n}\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores.\n */\nexport type DimensionStores = {\n [T in MultiDimensionType]: Observable<DimensionSettingsState>;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores for the viewport.\n */\nexport type ViewportStores = {\n [T in MultiDimensionType]: Observable<ViewportState>;\n};\n\n/**\n * Represents the event object that is emitted when the drag operation starts.\n */\nexport interface DragStartEvent {\n /**\n * Represents the original mouse event that triggered the drag operation.\n */\n originalEvent: MouseEvent;\n\n /**\n * Represents the model of the column being dragged.\n */\n model: ColumnDataSchemaModel;\n}\n\n/**\n * Represents the event object that is emitted before cell rendering.\n * It includes information about the dimension type, column, row, and model.\n */\nexport interface BeforeCellRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the column being rendered.\n */\n column: VirtualPositionItem;\n\n /**\n * Represents the row being rendered.\n */\n row: VirtualPositionItem;\n\n /**\n * Represents the model being rendered.\n */\n model: T;\n}\n\n/**\n * Represents the event object that is emitted before row rendering.\n * It includes information about the dimension type, data item, item, and node.\n */\nexport interface BeforeRowRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the data item being rendered.\n */\n model: T;\n\n /**\n * Represents the item being rendered.\n */\n item: VirtualPositionItem;\n\n /**\n * Represents the node being rendered.\n */\n node: VNode;\n}\n\n/**\n * Represents the event object that is emitted after rendering.\n * It includes information about the dimension type.\n */\nexport type AfterRendererEvent = {\n /**\n * Represents the type of dimension being rendered.\n */\n type: DimensionType;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding dimension types.\n */\nexport interface AllDimensionType {\n /**\n * Represents the dimension type for rows.\n */\n rowType: DimensionRows;\n\n /**\n * Represents the dimension type for columns.\n */\n colType: DimensionCols;\n}\n\n/**\n * Represents the event object that is emitted when applying focus.\n * It includes information about the dimension type and focused cells.\n */\nexport interface ApplyFocusEvent extends AllDimensionType, FocusedCells {}\n\n/**\n * Represents the event object that is emitted before focus rendering.\n * It includes information about the dimension type and range area.\n */\nexport interface FocusRenderEvent extends AllDimensionType {\n /**\n * Represents the range area of the focus.\n */\n range: RangeArea;\n\n rowDimension: DimensionSettingsState;\n\n colDimension: DimensionSettingsState;\n\n /**\n * Changes for the next cell to focus. @example { y: -1 }\n */\n next?: Partial<Cell>;\n}\n\nexport interface FocusAfterRenderEvent extends AllDimensionType {\n model?: any;\n column?: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n}\n/**\n * Represents the event object that is emitted when scrolling occurs.\n * The `type` property indicates the type of dimension (row or column) being scrolled.\n * The `coordinate` property represents the current scroll position in that dimension.\n */\nexport type ScrollCoordinateEvent = {\n /**\n * Represents the type of dimension being scrolled.\n * Possible values are 'rgRow' and 'rgCol'.\n */\n type: DimensionType;\n\n /**\n * Represents the current scroll position in the specified dimension.\n * The value is a number representing the coordinate in pixels.\n */\n coordinate: number;\n};\n\n/** Range paste. */\nexport type RangeClipboardPasteEvent = {\n data: DataLookup;\n models: Partial<DataLookup>;\n range: RangeArea | null;\n} & AllDimensionType;\n\n/** Range copy. */\nexport type RangeClipboardCopyEventProps<T = any> = {\n data: DataFormat<T>[][];\n range: RangeArea;\n mapping: OldNewRangeMapping;\n} & AllDimensionType;\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { VNode } from '@stencil/core';\n\nimport {\n DimensionCols,\n DimensionRows,\n DimensionColPin,\n DimensionType,\n MultiDimensionType,\n} from './dimension';\nimport {\n Cell,\n EditorCtr,\n FocusedCells,\n OldNewRangeMapping,\n RangeArea,\n SelectionStoreState,\n} from './selection';\nimport type { Observable } from '../utils/store.utils';\nimport { JSXBase } from '@stencil/core/internal';\n\nexport type Nullable<T> = {\n [P in keyof T]: T[P] | null;\n};\n\n/**\n * Advanced column data schema model.\n * Used for transpassing data to cell renderer and editor.\n */\nexport type ColumnDataSchemaModel = {\n /**\n * Column prop used for mapping value to cell from data source model/row\n */\n prop: ColumnProp;\n /**\n * Row data object\n */\n model: DataType;\n /**\n * Column data object\n */\n column: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n /**\n * Column type based on viewport\n */\n colType: DimensionCols;\n /**\n * Row type based on viewport\n */\n type: DimensionRows;\n /**\n * Row models based on viewport\n */\n data: DataType[];\n /**\n * Current cell data\n */\n value: any;\n};\n/**\n * Template property for each cell, extends the column data schema model.\n * Additionally, it provides access to the providers injected into the template.\n */\nexport interface CellTemplateProp extends ColumnDataSchemaModel {\n /**\n * Providers injected into the template\n */\n providers: Providers;\n}\n/**\n * The ReadOnlyFormat type is a boolean value or a function that takes ColumnDataSchemaModel\n * as a parameter and returns a boolean value.\n *\n * If it is a boolean value, it represents whether the cell in question is read-only.\n * If it is a function, it returns whether the cell in question is read-only based on the provided\n * ColumnDataSchemaModel.\n */\nexport type ReadOnlyFormat =\n | boolean\n | ((params: ColumnDataSchemaModel) => boolean);\nexport type RowDrag =\n | boolean\n | {\n (params: ColumnDataSchemaModel): boolean;\n };\n/**\n * `ColumnGrouping` type is used to define a grouping in a column.\n */\nexport type ColumnGrouping<T = any> = {\n /**\n * An array of objects that represent the children of the grouping.\n */\n children: (ColumnGrouping<T> | ColumnRegular)[];\n /**\n * A `DataFormat` object that represents the name of the grouping.\n */\n name: DataFormat<T>;\n};\n/**\n * Configuration for header inner template properties\n */\nexport interface ColumnProperties {\n /**\n * Header inner template\n * Function/component to render custom header content\n */\n columnTemplate?: ColumnTemplateFunc;\n /**\n * Header Cell properties\n * Custom function/component to render header properties\n */\n columnProperties?: ColPropertiesFunc;\n}\n/**\n * Type that represents a collection of column types.\n * The keys are the names of the column types and the values are the corresponding column type objects.\n */\nexport type ColumnTypes = {\n /**\n * The name of the column type.\n */\n [name: string]: ColumnType;\n};\n\n/**\n * Interface for custom cell renderer.\n */\nexport interface CellTemplate {\n // TODO: Add Promise support for template and all custom function so user will be able to use async render on the light speed\n (\n createElement: HyperFunc<VNode>,\n props: CellTemplateProp,\n additionalData?: any,\n ): any;\n}\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnType extends ColumnProperties {\n /**\n * Represents whether the column or cell is read-only.\n * Can be a boolean or a function that returns a boolean.\n * The function receives column data as a parameter.\n */\n readonly?: ReadOnlyFormat;\n /**\n * Represents the default column size.\n */\n size?: number;\n /**\n * Represents the minimal column size.\n * This property cannot be less than cell padding\n * in order to keep performance on top and minimize DOM elements number.\n */\n minSize?: number;\n /**\n * Represents the maximum column size.\n */\n maxSize?: number;\n /**\n * Represents a custom editor defined in editors property.\n * Can be a string or an editor constructor function.\n */\n editor?: string | EditorCtr;\n /**\n * Represents cell properties for custom styling, classes, and events.\n */\n cellProperties?: PropertiesFunc;\n /**\n * Represents the cell template for custom rendering.\n */\n cellTemplate?: CellTemplate;\n /**\n * Represents the cell compare function for custom sorting.\n */\n cellCompare?: CellCompareFunc;\n\n /**\n * Represents the cell value parse function for custom parsing.\n * Currently only used for filtering.\n */\n cellParser?: (model: DataType, column: ColumnRegular) => any;\n}\nexport type Order = 'asc' | 'desc' | undefined;\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n *\n */\n/**\n * ColumnRegular interface represents regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnRegular extends ColumnType {\n /**\n * Column prop used for mapping value to cell from data source model/row, used for indexing.\n */\n prop: ColumnProp;\n /**\n * Column pin 'colPinStart'|'colPinEnd'.\n */\n pin?: DimensionColPin;\n /**\n * Column header text.\n */\n name?: any;\n /**\n * Column size would be changed based on space left.\n */\n autoSize?: boolean;\n /**\n * Filter. Require filter plugin to be installed and activated through grid config filter.\n */\n filter?: boolean | string | string[];\n /**\n * Is column can be sorted, check cellCompare function for custom sorting.\n */\n sortable?: boolean;\n /**\n * Sort order.\n */\n order?: Order;\n /**\n * Is cell in column or individual can be dragged.\n */\n rowDrag?: RowDrag;\n /**\n * Represents type defined in columnTypes property through grid config.\n */\n columnType?: string;\n /**\n * Function called before column applied to the store.\n */\n beforeSetup?(rgCol: ColumnRegular): void;\n /**\n * Additional properties can be added to the column definition.\n */\n [key: string]: any;\n}\n\nexport type ColumnData = (ColumnGrouping | ColumnRegular)[];\n/**\n * Column template property.\n * Contains extended properties for column.\n */\nexport interface ColumnTemplateProp extends ColumnRegular {\n /**\n * Providers injected into the template.\n */\n providers: Providers<DimensionCols | 'rowHeaders'>;\n /**\n * Index of the column, used for mapping value to cell from data source model/row.\n */\n index: number;\n}\n\nexport type ColumnPropProp = ColumnGrouping | ColumnTemplateProp;\n// Column prop used for mapping value to cell from data source model/row, used for indexing.\nexport type ColumnProp = string | number;\n\nexport type DataFormat<T = any> = T;\n\n/**\n * Additional properties applied to the cell.\n * Contains properties for custom cell rendering.\n */\nexport type CellProps = JSXBase.HTMLAttributes<HTMLDivElement> & {\n className?: JSXBase.HTMLAttributes<HTMLDivElement>['class'];\n // Additional properties for custom cell rendering\n [attr: string]: string | number | object | boolean | undefined;\n};\n\n\n/**\n * Providers for grid which are going to be injected into each cell template\n */\nexport type Providers<T = DimensionRows> = {\n /**\n * Dimension type (e.g. row or column)\n */\n type: T;\n /**\n * Flag indicating if grid is in readonly mode\n */\n readonly: boolean;\n /**\n * Data source store\n */\n data: Observable<DataSourceState<any, any>> | ColumnRegular[];\n /**\n * Viewport store\n */\n viewport: Observable<ViewportState>;\n /**\n * Dimension store\n */\n dimension: Observable<DimensionSettingsState>;\n /**\n * Selection store\n */\n selection: Observable<SelectionStoreState>;\n};\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n // (tag: any): T;\n (tag: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, data: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: T): T;\n}\n/**\n * `FocusTemplateFunc` is a function that takes an HTML tag or component, and\n * returns a JSX element. This function is used to create JSX elements in a\n * context where JSX is not valid.\n */\nexport type FocusTemplateFunc = (\n createElement: HyperFunc<VNode>,\n detail: FocusRenderEvent,\n) => any;\n\n/**\n * `CellCompareFunc` is a function that takes the column property to compare,\n * the data of the first cell, and the data of the second cell. It returns a\n * number indicating the relative order of the two cells.\n */\nexport type CellCompareFunc = (\n // The column property to compare.\n prop: ColumnProp,\n // The data of the first cell.\n a: DataType,\n // The data of the second cell.\n b: DataType,\n) => number;\nexport type ColumnTemplateFunc = (\n createElement: HyperFunc<VNode>,\n props: ColumnTemplateProp,\n additionalData?: any,\n) => any;\nexport type PropertiesFunc = (\n props: CellTemplateProp,\n) => CellProps | void | undefined;\nexport type ColPropertiesFunc = (\n props: ColumnPropProp,\n) => CellProps | void | undefined;\nexport type DataType<D = any> = {\n [T in ColumnProp]: DataFormat<D>;\n};\n\nexport type DataLookup<T = any> = {\n [rowIndex: number]: DataType<T>;\n};\n/**\n * `RowDefinition` is a type that represents a row definition in the\n * viewport.\n */\nexport type RowDefinition = {\n /**\n * The type of the row.\n */\n type: DimensionRows;\n /**\n * The size of the row.\n */\n size: number;\n /**\n * The index of the row.\n */\n index: number;\n};\nexport interface RowHeaders extends ColumnRegular {}\n/**\n * `ViewPortResizeEvent` is an object that contains information about a resize\n * event in the viewport.\n */\nexport type ViewPortResizeEvent = {\n /* The dimension of the viewport being resized. */\n dimension: DimensionType;\n /* The new size of the viewport. */\n size: number;\n /* Indicates whether the resize event is for a row header. */\n rowHeader?: boolean;\n};\n\n/**\n * `ViewPortScrollEvent` is an object that contains information about a scroll\n * event in the viewport.\n */\nexport type ViewPortScrollEvent = {\n /**\n * The dimension of the viewport being scrolled.\n */\n dimension: DimensionType;\n /**\n * The coordinate of the scroll event.\n */\n coordinate: number;\n /**\n * The change in coordinate between scroll events.\n */\n delta?: number;\n /**\n * Indicates whether the scroll event occurred outside the viewport.\n */\n outside?: boolean;\n};\n\n/**\n * `InitialHeaderClick` represents the information needed to handle a click\n * event on the initial column header.\n */\nexport type InitialHeaderClick = {\n /**\n * The index of the column header that was clicked.\n */\n index: number;\n /**\n * The original mouse event that triggered the click.\n */\n originalEvent: MouseEvent;\n /**\n * The column that was clicked.\n */\n column: ColumnRegular;\n providers: Providers<DimensionCols | 'rowHeaders'>;\n};\n\n/**\n * `Range` is an object that represents a range of values.\n */\nexport type Range = {\n /**\n * The start of the range.\n */\n start: number;\n /**\n * The end of the range.\n */\n end: number;\n};\n\n/**\n * `ViewportStateItems` is an object that represents the items in a viewport\n * along with their corresponding range.\n */\nexport type ViewportStateItems = {\n /**\n * The items in the viewport.\n */\n items: VirtualPositionItem[];\n} & Range;\n\n/**\n * `ViewportState` is an object that represents the state of a viewport.\n */\nexport interface ViewportState extends ViewportStateItems {\n /**\n * The number of real items in the viewport.\n */\n realCount: number;\n /**\n * The virtual size of the viewport.\n */\n virtualSize: number;\n}\n\n/**\n * `ViewSettingSizeProp` is a record that maps column or row indexes to their\n * corresponding sizes.\n */\nexport type ViewSettingSizeProp = Record<string, number>;\n\n/**\n * `VirtualPositionItem` is an object that represents a virtual position item\n * in the viewport.\n */\nexport interface VirtualPositionItem extends PositionItem {\n /**\n * The size of the virtual position item.\n */\n size: number;\n}\nexport type DataSourceState<\n T extends DataType | ColumnRegular,\n ST extends DimensionRows | DimensionCols,\n> = {\n // items - index based array for mapping to source tree\n items: number[];\n // all items, used as proxy for sorting, trimming and others manipulations\n proxyItems: number[];\n // original data source\n source: T[];\n // grouping\n groupingDepth: number;\n groups: Record<any, any>;\n // data source type\n type: ST;\n // trim data, to hide entities from visible data source\n trimmed: Record<any, any>;\n};\nexport interface PositionItem {\n itemIndex: number;\n start: number;\n end: number;\n}\n/**\n * Object containing information about calculated dimensions.\n * Used for both columns and rows.\n */\nexport interface DimensionCalc {\n /**\n * Array of indexes of visible items.\n */\n indexes: number[];\n\n /**\n * Count of visible items.\n */\n count: number;\n\n /**\n * Array of indexes of visible items.\n * Used for mapping items to their position in DOM.\n */\n positionIndexes: number[];\n\n /**\n * Mapping of position to item.\n * Used for mapping position in DOM to item.\n */\n positionIndexToItem: {\n /**\n * Position in DOM.\n */\n [position: number]: PositionItem;\n };\n\n /**\n * Mapping of index to item.\n * Used for mapping index in data source to item.\n */\n indexToItem: {\n /**\n * Index in data source.\n */\n [index: number]: PositionItem;\n };\n\n /**\n * Object containing information about trimmed data.\n * Used for hiding entities from visible data source.\n */\n trimmed: { [index: number]: number} | null;\n\n /**\n * Object containing size for each visible item.\n * provider stores only changed sizes, not all of them\n * same as indexes but for sizes and positions\n * virtual item index to size\n */\n sizes: ViewSettingSizeProp;\n}\n/**\n * Represents the settings state of a dimension.\n * It extends the calculation properties of a dimension.\n * It also includes the real size and origin item size of the dimension.\n */\nexport interface DimensionSettingsState extends DimensionCalc {\n /**\n * Represents the real size of the dimension.\n */\n realSize: number;\n\n /**\n * Represents the origin item size of the dimension.\n */\n originItemSize: number;\n}\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores.\n */\nexport type DimensionStores = {\n [T in MultiDimensionType]: Observable<DimensionSettingsState>;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores for the viewport.\n */\nexport type ViewportStores = {\n [T in MultiDimensionType]: Observable<ViewportState>;\n};\n\n/**\n * Represents the event object that is emitted when the drag operation starts.\n */\nexport interface DragStartEvent {\n /**\n * Represents the original mouse event that triggered the drag operation.\n */\n originalEvent: MouseEvent;\n\n /**\n * Represents the model of the column being dragged.\n */\n model: ColumnDataSchemaModel;\n}\n\n/**\n * Represents the event object that is emitted before cell rendering.\n * It includes information about the dimension type, column, row, and model.\n */\nexport interface BeforeCellRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the column being rendered.\n */\n column: VirtualPositionItem;\n\n /**\n * Represents the row being rendered.\n */\n row: VirtualPositionItem;\n\n /**\n * Represents the model being rendered.\n */\n model: T;\n}\n\n/**\n * Represents the event object that is emitted before row rendering.\n * It includes information about the dimension type, data item, item, and node.\n */\nexport interface BeforeRowRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the data item being rendered.\n */\n model: T;\n\n /**\n * Represents the item being rendered.\n */\n item: VirtualPositionItem;\n\n /**\n * Represents the node being rendered.\n */\n node: VNode;\n}\n\n/**\n * Represents the event object that is emitted after rendering.\n * It includes information about the dimension type.\n */\nexport type AfterRendererEvent = {\n /**\n * Represents the type of dimension being rendered.\n */\n type: DimensionType;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding dimension types.\n */\nexport interface AllDimensionType {\n /**\n * Represents the dimension type for rows.\n */\n rowType: DimensionRows;\n\n /**\n * Represents the dimension type for columns.\n */\n colType: DimensionCols;\n}\n\n/**\n * Represents the event object that is emitted when applying focus.\n * It includes information about the dimension type and focused cells.\n */\nexport interface ApplyFocusEvent extends AllDimensionType, FocusedCells {}\n\n/**\n * Represents the event object that is emitted before focus rendering.\n * It includes information about the dimension type and range area.\n */\nexport interface FocusRenderEvent extends AllDimensionType {\n /**\n * Represents the range area of the focus.\n */\n range: RangeArea;\n\n rowDimension: DimensionSettingsState;\n\n colDimension: DimensionSettingsState;\n\n /**\n * Changes for the next cell to focus. @example { y: -1 }\n */\n next?: Partial<Cell>;\n}\n\nexport interface FocusAfterRenderEvent extends AllDimensionType {\n model?: any;\n column?: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n}\n/**\n * Represents the event object that is emitted when scrolling occurs.\n * The `type` property indicates the type of dimension (row or column) being scrolled.\n * The `coordinate` property represents the current scroll position in that dimension.\n */\nexport type ScrollCoordinateEvent = {\n /**\n * Represents the type of dimension being scrolled.\n * Possible values are 'rgRow' and 'rgCol'.\n */\n type: DimensionType;\n\n /**\n * Represents the current scroll position in the specified dimension.\n * The value is a number representing the coordinate in pixels.\n */\n coordinate: number;\n};\n\n/** Range paste. */\nexport type RangeClipboardPasteEvent = {\n data: DataLookup;\n models: Partial<DataLookup>;\n range: RangeArea | null;\n} & AllDimensionType;\n\n/** Range copy. */\nexport type RangeClipboardCopyEventProps<T = any> = {\n data: DataFormat<T>[][];\n range: RangeArea;\n mapping: OldNewRangeMapping;\n} & AllDimensionType;\n"]}
@@ -9,9 +9,14 @@ export function getCellData(val) {
9
9
  }
10
10
  return val;
11
11
  }
12
+ export function getCellRaw(model, column) {
13
+ if (column.cellParser) {
14
+ return column.cellParser(model, column);
15
+ }
16
+ return model[column.prop];
17
+ }
12
18
  export function getCellDataParsed(model, column) {
13
- const val = column.cellParser ? column.cellParser(model, column) : model[column.prop];
14
- return getCellData(val);
19
+ return getCellData(getCellRaw(model, column));
15
20
  }
16
21
  /**
17
22
  * Get column type from column data
@@ -1 +1 @@
1
- {"version":3,"file":"column.utils.js","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umnProp,\n ColumnRegular,\n ColumnTypes,\n DataType,\n DimensionCols,\n ViewSettingSizeProp,\n} from '@type';\nimport { Group as StoreGroup } from '@store';\n\nexport type ColumnItems = Record<DimensionCols, ColumnRegular[]>;\nexport interface ColumnGroup extends StoreGroup {\n level: number;\n}\nexport type ColumnGroupingCollection = Record<DimensionCols, ColumnGroup[]>;\n\nexport function getCellData(val?: any) {\n if (typeof val === 'undefined' || val === null) {\n return '';\n }\n return val;\n}\n\nexport function getCellDataParsed(model: DataType, column: ColumnRegular) {\n const val = column.cellParser ? column.cellParser(model, column) : model[column.prop];\n return getCellData(val);\n}\n\n/**\n * Column collection definition.\n * Used to access indexed data for columns.\n * Can be accessed via different events.\n */\nexport type ColumnCollection = {\n /**\n * Columns as they are in stores\n */\n columns: Record<DimensionCols, ColumnRegular[]>;\n /**\n * Columns indexed by prop for quick access, it's possible to have multiple columns with same prop but not recommended\n */\n columnByProp: Record<ColumnProp, ColumnRegular[]>;\n /**\n * Grouped columns\n */\n columnGrouping: ColumnGroupingCollection;\n /**\n * Max level of grouping\n */\n maxLevel: number;\n /**\n * Sorting\n */\n sort: Record<ColumnProp, ColumnRegular>;\n};\n\n/**\n * Get column type from column data\n */\nexport function getColumnType(rgCol: ColumnRegular): DimensionCols {\n if (rgCol.pin) {\n return rgCol.pin;\n }\n return 'rgCol';\n}\n\nexport function getColumnSizes(cols: ColumnRegular[]): ViewSettingSizeProp {\n const res: ViewSettingSizeProp = {};\n for (const [i, c] of cols.entries()) {\n if (c.size) {\n res[i] = c.size;\n }\n }\n return res;\n}\n\n\n/**\n * Check if column is grouping column\n */\nexport function isColGrouping(\n colData: ColumnGrouping | ColumnRegular,\n): colData is ColumnGrouping {\n return !!(colData as ColumnGrouping).children;\n}\n\n/**\n * This function is used to create a collection of columns.\n */\nexport function getColumns(\n columns: ColumnData,\n level = 0,\n types?: ColumnTypes,\n): ColumnCollection {\n const collection: ColumnCollection = {\n // columns as they are in stores per type\n columns: {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n // columns indexed by prop for quick access\n columnByProp: {},\n // column grouping\n columnGrouping: {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n // max depth level for column grouping\n maxLevel: level,\n // sorting\n sort: {},\n };\n\n return reduce(\n columns,\n (res: ColumnCollection, colData: ColumnGrouping | ColumnRegular) => {\n // Grouped column\n if (isColGrouping(colData)) {\n return gatherGroup(\n res,\n colData,\n getColumns(colData.children, level + 1, types),\n level,\n );\n }\n // Column type\n const columnDefinitionFromType = colData.columnType && types?.[colData.columnType];\n // Regular column\n const regularColumn = {\n ...columnDefinitionFromType,\n ...colData,\n };\n // Regular column, no Pin\n if (!regularColumn.pin) {\n res.columns.rgCol.push(regularColumn);\n // Pin\n } else {\n res.columns[regularColumn.pin].push(regularColumn);\n }\n if (regularColumn.order) {\n res.sort[regularColumn.prop] = regularColumn;\n }\n // it's possible that some columns have same prop, but better to avoid it\n if (!res.columnByProp[regularColumn.prop]) {\n res.columnByProp[regularColumn.prop] = [];\n }\n res.columnByProp[regularColumn.prop].push(regularColumn);\n\n // trigger setup hook if present\n regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);\n return res;\n },\n collection,\n );\n}\n\nexport function gatherGroup<T extends ColumnCollection>(\n res: T,\n colData: ColumnGrouping,\n collection: T,\n level = 0,\n): T {\n // group template\n const group: ColumnGroup = {\n ...colData,\n level,\n ids: [],\n };\n\n // check columns for update\n for (let k in collection.columns) {\n const key = k as keyof ColumnCollection['columns'];\n const resultItem = res.columns[key];\n const collectionItem = collection.columns[key];\n\n // if column data\n if (isArray(resultItem) && isArray(collectionItem)) {\n // fill columns\n resultItem.push(...collectionItem);\n\n // fill grouping\n if (collectionItem.length) {\n res.columnGrouping[key].push({\n ...group,\n ids: collectionItem.map(item => item.prop),\n });\n }\n }\n }\n // merge column groupings\n for (let k in collection.columnGrouping) {\n const key = k as DimensionCols;\n const collectionItem = collection.columnGrouping[key];\n res.columnGrouping[key].push(...collectionItem);\n }\n res.maxLevel = Math.max(res.maxLevel, collection.maxLevel);\n res.sort = { ...res.sort, ...collection.sort };\n return res;\n}\n\nfunction findColumn(\n columns: ColumnData,\n prop: ColumnProp,\n): ColumnRegular | undefined {\n for (const c of columns) {\n if (isColGrouping(c)) {\n const found = findColumn(c.children, prop);\n if (found) {\n return found;\n }\n } else if (c.prop === prop) {\n return c;\n }\n }\n return undefined;\n}\n\nexport function getColumnByProp(\n columns: ColumnData,\n prop: ColumnProp,\n): ColumnRegular | undefined {\n return findColumn(columns, prop);\n}\n"]}
1
+ {"version":3,"file":"column.utils.js","sourceRoot":"","sources":["../../src/utils/column.utils.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,MAAM,MAAM,eAAe,CAAC;AAoBnC,MAAM,UAAU,WAAW,CAAC,GAAS;IACnC,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC/C,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAe,EAAE,MAAqB;IAC/D,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAAe,EAAE,MAAqB;IACtE,OAAO,WAAW,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAChD,CAAC;AA8BD;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAoB;IAChD,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;QACd,OAAO,KAAK,CAAC,GAAG,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,U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,CAAC,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAC3C,IAAI,KAAK,EAAE,CAAC;gBACV,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,OAAmB,EACnB,IAAgB;IAEhB,OAAO,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACnC,CAAC","sourcesContent":["import isArray from 'lodash/isArray';\nimport reduce from 'lodash/reduce';\n\nimport {\n ColumnData,\n ColumnGrouping,\n ColumnProp,\n ColumnRegular,\n ColumnTypes,\n DataType,\n DimensionCols,\n ViewSettingSizeProp,\n} from '@type';\nimport { Group as StoreGroup } from '@store';\n\nexport type ColumnItems = Record<DimensionCols, ColumnRegular[]>;\nexport interface ColumnGroup extends StoreGroup {\n level: number;\n}\nexport type ColumnGroupingCollection = Record<DimensionCols, ColumnGroup[]>;\n\nexport function getCellData(val?: any) {\n if (typeof val === 'undefined' || val === null) {\n return '';\n }\n return val;\n}\n\nexport function getCellRaw(model: DataType, column: ColumnRegular) {\n if (column.cellParser) {\n return column.cellParser(model, column);\n }\n return model[column.prop];\n}\n\nexport function getCellDataParsed(model: DataType, column: ColumnRegular) {\n return getCellData(getCellRaw(model, column));\n}\n\n/**\n * Column collection definition.\n * Used to access indexed data for columns.\n * Can be accessed via different events.\n */\nexport type ColumnCollection = {\n /**\n * Columns as they are in stores\n */\n columns: Record<DimensionCols, ColumnRegular[]>;\n /**\n * Columns indexed by prop for quick access, it's possible to have multiple columns with same prop but not recommended\n */\n columnByProp: Record<ColumnProp, ColumnRegular[]>;\n /**\n * Grouped columns\n */\n columnGrouping: ColumnGroupingCollection;\n /**\n * Max level of grouping\n */\n maxLevel: number;\n /**\n * Sorting\n */\n sort: Record<ColumnProp, ColumnRegular>;\n};\n\n/**\n * Get column type from column data\n */\nexport function getColumnType(rgCol: ColumnRegular): DimensionCols {\n if (rgCol.pin) {\n return rgCol.pin;\n }\n return 'rgCol';\n}\n\nexport function getColumnSizes(cols: ColumnRegular[]): ViewSettingSizeProp {\n const res: ViewSettingSizeProp = {};\n for (const [i, c] of cols.entries()) {\n if (c.size) {\n res[i] = c.size;\n }\n }\n return res;\n}\n\n\n/**\n * Check if column is grouping column\n */\nexport function isColGrouping(\n colData: ColumnGrouping | ColumnRegular,\n): colData is ColumnGrouping {\n return !!(colData as ColumnGrouping).children;\n}\n\n/**\n * This function is used to create a collection of columns.\n */\nexport function getColumns(\n columns: ColumnData,\n level = 0,\n types?: ColumnTypes,\n): ColumnCollection {\n const collection: ColumnCollection = {\n // columns as they are in stores per type\n columns: {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n // columns indexed by prop for quick access\n columnByProp: {},\n // column grouping\n columnGrouping: {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n // max depth level for column grouping\n maxLevel: level,\n // sorting\n sort: {},\n };\n\n return reduce(\n columns,\n (res: ColumnCollection, colData: ColumnGrouping | ColumnRegular) => {\n // Grouped column\n if (isColGrouping(colData)) {\n return gatherGroup(\n res,\n colData,\n getColumns(colData.children, level + 1, types),\n level,\n );\n }\n // Column type\n const columnDefinitionFromType = colData.columnType && types?.[colData.columnType];\n // Regular column\n const regularColumn = {\n ...columnDefinitionFromType,\n ...colData,\n };\n // Regular column, no Pin\n if (!regularColumn.pin) {\n res.columns.rgCol.push(regularColumn);\n // Pin\n } else {\n res.columns[regularColumn.pin].push(regularColumn);\n }\n if (regularColumn.order) {\n res.sort[regularColumn.prop] = regularColumn;\n }\n // it's possible that some columns have same prop, but better to avoid it\n if (!res.columnByProp[regularColumn.prop]) {\n res.columnByProp[regularColumn.prop] = [];\n }\n res.columnByProp[regularColumn.prop].push(regularColumn);\n\n // trigger setup hook if present\n regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);\n return res;\n },\n collection,\n );\n}\n\nexport function gatherGroup<T extends ColumnCollection>(\n res: T,\n colData: ColumnGrouping,\n collection: T,\n level = 0,\n): T {\n // group template\n const group: ColumnGroup = {\n ...colData,\n level,\n ids: [],\n };\n\n // check columns for update\n for (let k in collection.columns) {\n const key = k as keyof ColumnCollection['columns'];\n const resultItem = res.columns[key];\n const collectionItem = collection.columns[key];\n\n // if column data\n if (isArray(resultItem) && isArray(collectionItem)) {\n // fill columns\n resultItem.push(...collectionItem);\n\n // fill grouping\n if (collectionItem.length) {\n res.columnGrouping[key].push({\n ...group,\n ids: collectionItem.map(item => item.prop),\n });\n }\n }\n }\n // merge column groupings\n for (let k in collection.columnGrouping) {\n const key = k as DimensionCols;\n const collectionItem = collection.columnGrouping[key];\n res.columnGrouping[key].push(...collectionItem);\n }\n res.maxLevel = Math.max(res.maxLevel, collection.maxLevel);\n res.sort = { ...res.sort, ...collection.sort };\n return res;\n}\n\nfunction findColumn(\n columns: ColumnData,\n prop: ColumnProp,\n): ColumnRegular | undefined {\n for (const c of columns) {\n if (isColGrouping(c)) {\n const found = findColumn(c.children, prop);\n if (found) {\n return found;\n }\n } else if (c.prop === prop) {\n return c;\n }\n }\n return undefined;\n}\n\nexport function getColumnByProp(\n columns: ColumnData,\n prop: ColumnProp,\n): ColumnRegular | undefined {\n return findColumn(columns, prop);\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import { r as reduce, m as baseEach, e as getColumnType, o as isGrouping, p as getGroupingName, d as getCellDataParsed, h as isColGrouping } from './column.service-9b0603f4.js';
4
+ import { r as reduce, o as baseEach, f as getColumnType, p as isGrouping, q as getGroupingName, e as getCellDataParsed, j as isColGrouping } from './column.service-5d1cf29d.js';
5
5
  import { W as createStore, w as setStore, i as calculateDimensionData, X as identity, Y as isArray, b as getSourceItem, o as getScrollbarSize, Z as toInteger, _ as isIterateeCall, u as timeout, j as getItemByPosition } from './index-b1e05212.js';
6
6
  import { f as calculateRowHeaderSize } from './row-header-utils-7af8fcbf.js';
7
7
  import { h } from './index-a61f225b.js';
8
8
  import { b as FILTER_PROP, i as isFilterBtn } from './filter.button-d40ab17b.js';
9
9
  import { d as debounce } from './debounce-7b511afc.js';
10
- import { d as dispatch, O as ON_COLUMN_CLICK } from './header-cell-renderer-fce020c3.js';
10
+ import { d as dispatch, O as ON_COLUMN_CLICK } from './header-cell-renderer-49cd23aa.js';
11
11
 
12
12
  /**
13
13
  * Plugin which recalculates realSize on changes of sizes, originItemSize and count
@@ -1727,4 +1727,4 @@ function getLeftRelative(absoluteX, gridPos, offset) {
1727
1727
 
1728
1728
  export { AutoSizeColumnPlugin as A, BasePlugin as B, ColumnPlugin as C, DimensionStore as D, ExportFilePlugin as E, FILTER_TRIMMED_TYPE as F, StretchColumn as S, isStretchPlugin as a, FILTER_CONFIG_CHANGED_EVENT as b, columnTypes as c, FILTE_PANEL as d, FilterPlugin as e, filterCoreFunctionsIndexedByType as f, filterTypes as g, filterNames as h, isRowType as i, getLeftRelative as j, forEach as k, rowTypes as r };
1729
1729
 
1730
- //# sourceMappingURL=column.drag.plugin-b7bba0da.js.map
1730
+ //# sourceMappingURL=column.drag.plugin-8ea8fdab.js.map