@adaptabletools/adaptable-cjs 22.0.11 → 22.1.0-canary.1

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 (75) hide show
  1. package/index.css +19 -1
  2. package/index.css.map +1 -1
  3. package/package.json +3 -4
  4. package/src/AdaptableOptions/DashboardOptions.d.ts +2 -2
  5. package/src/AdaptableState/Common/AdaptablePredicate.js +1 -1
  6. package/src/AdaptableState/InitialState.d.ts +2 -2
  7. package/src/AdaptableState/LayoutState.d.ts +44 -0
  8. package/src/Api/CalendarApi.d.ts +15 -0
  9. package/src/Api/ColumnScopeApi.d.ts +5 -0
  10. package/src/Api/Implementation/CalendarApiImpl.d.ts +3 -0
  11. package/src/Api/Implementation/CalendarApiImpl.js +10 -0
  12. package/src/Api/Implementation/ColumnApiImpl.d.ts +1 -0
  13. package/src/Api/Implementation/ColumnApiImpl.js +15 -0
  14. package/src/Api/Implementation/ColumnScopeApiImpl.d.ts +1 -0
  15. package/src/Api/Implementation/ColumnScopeApiImpl.js +12 -0
  16. package/src/Api/Implementation/LayoutHelpers.js +12 -0
  17. package/src/Api/Internal/AlertInternalApi.js +4 -1
  18. package/src/Api/Internal/FormatColumnInternalApi.js +3 -3
  19. package/src/Strategy/FlashingCellModule.js +1 -0
  20. package/src/Strategy/PlusMinusModule.js +3 -3
  21. package/src/Strategy/SmartEditModule.js +1 -1
  22. package/src/Utilities/Constants/GeneralConstants.js +2 -1
  23. package/src/Utilities/ExpressionFunctions/booleanExpressionFunctions.d.ts +1 -1
  24. package/src/Utilities/ExpressionFunctions/booleanExpressionFunctions.js +41 -2
  25. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.d.ts +1 -1
  26. package/src/Utilities/ExpressionFunctions/scalarExpressionFunctions.js +31 -2
  27. package/src/Utilities/Helpers/AdaptableHelper.js +30 -4
  28. package/src/Utilities/Services/Interface/IQueryLanguageService.d.ts +1 -0
  29. package/src/Utilities/Services/MetamodelService.js +18 -18
  30. package/src/Utilities/Services/QueryLanguageService.d.ts +2 -0
  31. package/src/Utilities/Services/QueryLanguageService.js +20 -8
  32. package/src/Utilities/Services/ValidationService.js +3 -1
  33. package/src/View/Components/EntityRulesEditor/index.js +1 -1
  34. package/src/View/Components/ModuleValueSelector/index.js +9 -1
  35. package/src/View/Components/ReorderDraggable/index.js +21 -35
  36. package/src/View/Components/ValueSelector/index.js +45 -49
  37. package/src/View/Dashboard/PinnedToolbarsSelector.js +1 -1
  38. package/src/View/Layout/Wizard/LayoutWizard.js +16 -1
  39. package/src/View/Layout/Wizard/sections/ColumnsSection.js +30 -18
  40. package/src/View/Layout/Wizard/sections/RowGroupingSection.js +1 -1
  41. package/src/View/Layout/Wizard/sections/RowSelectionSection.d.ts +8 -0
  42. package/src/View/Layout/Wizard/sections/RowSelectionSection.js +146 -0
  43. package/src/View/NamedQuery/Wizard/NamedQuerySettingsWizardSection.js +0 -1
  44. package/src/agGrid/AdaptableAgGrid.js +10 -0
  45. package/src/components/Dashboard/Dashboard.js +1 -1
  46. package/src/components/DragAndDropContext/ModuleManager.d.ts +1 -0
  47. package/src/components/DragAndDropContext/ModuleManager.js +11 -36
  48. package/src/components/DragAndDropContext/TabList.d.ts +11 -6
  49. package/src/components/DragAndDropContext/TabList.js +77 -35
  50. package/src/components/DragAndDropContext/UnusedPanel.js +9 -20
  51. package/src/components/ExpressionEditor/BaseEditorInput.d.ts +2 -0
  52. package/src/components/ExpressionEditor/BaseEditorInput.js +4 -0
  53. package/src/components/ExpressionEditor/EditorInput.d.ts +3 -1
  54. package/src/components/ExpressionEditor/EditorInput.js +20 -9
  55. package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.d.ts +2 -1
  56. package/src/components/ExpressionEditor/QueryBuilder/QueryBuilder.js +1 -10
  57. package/src/components/ExpressionEditor/QueryBuilder/QueryPredicateBuilder.js +16 -18
  58. package/src/components/ExpressionEditor/index.d.ts +2 -1
  59. package/src/components/ExpressionEditor/index.js +1 -1
  60. package/src/components/Tree/TreeDropdown/index.js +37 -26
  61. package/src/components/dnd/index.d.ts +3 -13
  62. package/src/components/dnd/index.js +11 -59
  63. package/src/env.js +2 -2
  64. package/src/layout-manager/src/LayoutManagerModel.d.ts +2 -1
  65. package/src/layout-manager/src/index.d.ts +10 -0
  66. package/src/layout-manager/src/index.js +156 -4
  67. package/src/layout-manager/src/normalizeLayoutModel.js +8 -0
  68. package/src/layout-manager/src/simplifyLayoutModel.js +6 -0
  69. package/src/metamodel/adaptable-metamodel-model.d.ts +22 -13
  70. package/src/metamodel/adaptable.metamodel.d.ts +3792 -5143
  71. package/src/metamodel/adaptable.metamodel.js +1 -1
  72. package/src/parser/src/parser.js +55 -1218
  73. package/src/parser/src/types.d.ts +5 -0
  74. package/src/types.d.ts +1 -1
  75. package/tsconfig.cjs.tsbuildinfo +1 -1
@@ -65,35 +65,46 @@ const getLabelColumn = (field, { includeExpandCollapseButton }) => {
65
65
  } }));
66
66
  },
67
67
  renderHeader: ({ dataSourceApi, api, allRowsSelected, someRowsSelected }) => {
68
- const { treeApi } = dataSourceApi;
69
- const allFirstLevelCollapsed = dataSourceApi
70
- .getOriginalDataArray()
71
- .every((item) => !treeApi.isNodeExpanded([item.id]));
72
- return (React.createElement(Flex_1.Flex, { flexDirection: 'row', alignItems: 'center', className: "twa:w-full", onMouseDown: (e) => {
73
- // so we can keep the focus on the Grid
74
- e.preventDefault();
75
- } },
76
- React.createElement(CheckBox_1.CheckBox, { checked: someRowsSelected && !allRowsSelected ? null : allRowsSelected, className: "twa:mr-2", onChange: () => {
77
- if (allRowsSelected) {
78
- dataSourceApi.treeApi.deselectAll();
79
- }
80
- else {
81
- dataSourceApi.treeApi.selectAll();
82
- }
83
- api.focus();
84
- } }, allRowsSelected ? '(Deselect All)' : '(Select All)'),
85
- React.createElement(Flex_1.Flex, { className: "twa:flex-1" }),
86
- includeExpandCollapseButton ? (React.createElement(SimpleButton_1.default, { label: "toggle-expand-collapse", icon: allFirstLevelCollapsed ? 'expand-all' : 'collapse-all', onMouseDown: () => {
87
- if (allFirstLevelCollapsed) {
88
- dataSourceApi.treeApi.expandAll();
89
- }
90
- else {
91
- dataSourceApi.treeApi.collapseAll();
92
- }
93
- }, iconPosition: "end" })) : null));
68
+ return (React.createElement(CustomHeader, { dataSourceApi: dataSourceApi, api: api, allRowsSelected: allRowsSelected, someRowsSelected: someRowsSelected, includeExpandCollapseButton: includeExpandCollapseButton }));
94
69
  },
95
70
  };
96
71
  };
72
+ function useAllFirstLevelCollapsed(treeApi) {
73
+ const { originalDataArray } = (0, InfiniteTable_1.useDataSourceState)((state) => {
74
+ return {
75
+ originalDataArray: state.originalDataArray,
76
+ treeExpandState: state.treeExpandState,
77
+ };
78
+ });
79
+ return originalDataArray.every((item) => !treeApi.isNodeExpanded([item.id]));
80
+ }
81
+ function CustomHeader({ dataSourceApi, api, allRowsSelected, someRowsSelected, includeExpandCollapseButton, }) {
82
+ const { treeApi } = dataSourceApi;
83
+ const allFirstLevelCollapsed = useAllFirstLevelCollapsed(treeApi);
84
+ const checked = someRowsSelected && !allRowsSelected ? null : allRowsSelected;
85
+ return (React.createElement(Flex_1.Flex, { flexDirection: 'row', alignItems: 'center', className: "twa:w-full", onMouseDown: (e) => {
86
+ // so we can keep the focus on the Grid
87
+ e.preventDefault();
88
+ } },
89
+ React.createElement(CheckBox_1.CheckBox, { checked: checked, className: "twa:mr-2", onChange: () => {
90
+ if (allRowsSelected) {
91
+ dataSourceApi.treeApi.deselectAll();
92
+ }
93
+ else {
94
+ dataSourceApi.treeApi.selectAll();
95
+ }
96
+ api.focus();
97
+ } }, allRowsSelected ? '(Deselect All)' : '(Select All)'),
98
+ React.createElement(Flex_1.Flex, { className: "twa:flex-1" }),
99
+ includeExpandCollapseButton ? (React.createElement(SimpleButton_1.default, { label: "toggle-expand-collapse", icon: allFirstLevelCollapsed ? 'expand-all' : 'collapse-all', onMouseDown: () => {
100
+ if (allFirstLevelCollapsed) {
101
+ dataSourceApi.treeApi.expandAll();
102
+ }
103
+ else {
104
+ dataSourceApi.treeApi.collapseAll();
105
+ }
106
+ }, iconPosition: "end" })) : null));
107
+ }
97
108
  const sizeFull = {
98
109
  width: '100%',
99
110
  height: '100%',
@@ -1,13 +1,3 @@
1
- import * as React from 'react';
2
- import { DropResult, Draggable, DroppableProps, DragDropContextProps } from '@adaptabletools/react-beautiful-dnd';
3
- /**
4
- * We're doing all this because the placeholder is not correctly displayed in react-beautiful-dnd
5
- * with React 19.
6
- * So we make sure it properly occupies the space of the dragged item, so the
7
- * container won't flicker when we're dragging an item (as the drag item receives
8
- * position: fixed while dragging, so content does not have the initial height anymore, therefore,
9
- * the placeholder is included, with the computed height of the dragging element)
10
- */
11
- declare const Droppable: (props: DroppableProps) => React.JSX.Element;
12
- declare const DragDropContext: (props: DragDropContextProps) => React.JSX.Element;
13
- export { type DropResult, Draggable, Droppable, DragDropContext };
1
+ import { DragProxyMoveParams } from '@infinite-table/infinite-react';
2
+ export { DragDropProvider, DragList, useDragDropProvider, useDragListContext, DRAG_ITEM_ATTRIBUTE, type DragListProps, type DragDropSourceAndTarget, } from '@infinite-table/infinite-react';
3
+ export declare function defaultDragProxyMove({ proxyElement, dx, dy }: DragProxyMoveParams): void;
@@ -1,61 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DragDropContext = exports.Droppable = exports.Draggable = void 0;
4
- const tslib_1 = require("tslib");
5
- const React = tslib_1.__importStar(require("react"));
6
- const react_beautiful_dnd_1 = require("@adaptabletools/react-beautiful-dnd");
7
- Object.defineProperty(exports, "Draggable", { enumerable: true, get: function () { return react_beautiful_dnd_1.Draggable; } });
8
- const react_1 = require("react");
9
- /**
10
- * We're doing all this because the placeholder is not correctly displayed in react-beautiful-dnd
11
- * with React 19.
12
- * So we make sure it properly occupies the space of the dragged item, so the
13
- * container won't flicker when we're dragging an item (as the drag item receives
14
- * position: fixed while dragging, so content does not have the initial height anymore, therefore,
15
- * the placeholder is included, with the computed height of the dragging element)
16
- */
17
- const Droppable = (props) => {
18
- const children = props.children;
19
- const { placeholderStyle } = React.useContext(AdaptableDDContext);
20
- return (React.createElement(react_beautiful_dnd_1.Droppable, { ...props }, (provided, snapshot) => {
21
- provided.placeholder = (React.createElement("div", { key: "placeholder", style: placeholderStyle || {
22
- visibility: 'hidden',
23
- pointerEvents: 'none',
24
- height: 0,
25
- } }));
26
- return children(provided, snapshot);
27
- }));
28
- };
29
- exports.Droppable = Droppable;
30
- const queryAttr = 'data-rbd-draggable-id';
31
- const AdaptableDDContext = React.createContext({
32
- placeholderStyle: null,
33
- });
34
- const DragDropContext = (props) => {
35
- const getDraggedDom = (draggableId) => {
36
- const domQuery = `[${queryAttr}='${draggableId}']`;
37
- const draggedDOM = document.querySelector(domQuery);
38
- return draggedDOM;
39
- };
40
- const [placeholderStyle, setPlaceholderStyle] = (0, react_1.useState)(null);
41
- const handleDragStart = (initial, provided) => {
42
- props.onDragStart?.(initial, provided);
43
- const draggedDOM = getDraggedDom(initial.draggableId);
44
- if (!draggedDOM) {
45
- return;
46
- }
47
- const { clientHeight, clientWidth } = draggedDOM;
48
- const computedStyle = window.getComputedStyle(draggedDOM);
49
- setPlaceholderStyle({
50
- height: clientHeight + parseFloat(computedStyle.marginTop) + parseFloat(computedStyle.marginBottom),
51
- width: clientWidth,
52
- });
53
- };
54
- const handleDragEnd = (result, provided) => {
55
- props.onDragEnd?.(result, provided);
56
- setPlaceholderStyle(null);
57
- };
58
- return (React.createElement(AdaptableDDContext.Provider, { value: { placeholderStyle } },
59
- React.createElement(react_beautiful_dnd_1.DragDropContext, { ...props, onDragStart: handleDragStart, onDragEnd: handleDragEnd })));
60
- };
61
- exports.DragDropContext = DragDropContext;
3
+ exports.DRAG_ITEM_ATTRIBUTE = exports.useDragListContext = exports.useDragDropProvider = exports.DragList = exports.DragDropProvider = void 0;
4
+ exports.defaultDragProxyMove = defaultDragProxyMove;
5
+ var infinite_react_1 = require("@infinite-table/infinite-react");
6
+ Object.defineProperty(exports, "DragDropProvider", { enumerable: true, get: function () { return infinite_react_1.DragDropProvider; } });
7
+ Object.defineProperty(exports, "DragList", { enumerable: true, get: function () { return infinite_react_1.DragList; } });
8
+ Object.defineProperty(exports, "useDragDropProvider", { enumerable: true, get: function () { return infinite_react_1.useDragDropProvider; } });
9
+ Object.defineProperty(exports, "useDragListContext", { enumerable: true, get: function () { return infinite_react_1.useDragListContext; } });
10
+ Object.defineProperty(exports, "DRAG_ITEM_ATTRIBUTE", { enumerable: true, get: function () { return infinite_react_1.DRAG_ITEM_ATTRIBUTE; } });
11
+ function defaultDragProxyMove({ proxyElement, dx, dy }) {
12
+ proxyElement.style.transform = `translate3d(${Math.round(dx)}px, ${Math.round(dy)}px, 0)`;
13
+ }
package/src/env.js CHANGED
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
4
  NEXT_PUBLIC_INFINITE_TABLE_LICENSE_KEY: "StartDate=2021-06-29|EndDate=2030-01-01|Owner=Adaptable|Type=distribution|TS=1624971462479|C=137829811,1004007071,2756196225,1839832928,3994409405,636616862" || '',
5
- PUBLISH_TIMESTAMP: 1775828219195 || Date.now(),
6
- VERSION: "22.0.11" || '--current-version--',
5
+ PUBLISH_TIMESTAMP: 1776672498444 || Date.now(),
6
+ VERSION: "22.1.0-canary.1" || '--current-version--',
7
7
  };
@@ -1,4 +1,4 @@
1
- import { ColumnSizingMap } from '../../AdaptableState/LayoutState';
1
+ import { ColumnSizingMap, LayoutRowSelection } from '../../AdaptableState/LayoutState';
2
2
  import { XOR } from '../../Utilities/Extensions/TypeExtensions';
3
3
  /**
4
4
  * Defines how a Column is sorted
@@ -112,6 +112,7 @@ export interface BaseLayoutModel {
112
112
  ColumnPinning?: {
113
113
  [columnId: string]: 'left' | 'right';
114
114
  };
115
+ RowSelection?: LayoutRowSelection | false;
115
116
  /**
116
117
  * Display Grand Total Row of the Pivot Table
117
118
  */
@@ -1,6 +1,7 @@
1
1
  import { ColumnState, GridApi, GridOptions, GridState } from 'ag-grid-enterprise';
2
2
  import { PivotLayoutModel, TableLayoutModel } from './LayoutManagerModel';
3
3
  import { LMEmitter } from './LMEmitter';
4
+ import { LayoutRowSelection } from '../../AdaptableState/LayoutState';
4
5
  export declare const PIVOT_ANY_TOTAL_COL_TYPE = "pivotAnyTotal";
5
6
  export declare const PIVOT_GRAND_TOTAL_COL_TYPE = "pivotGrandTotal";
6
7
  export declare const PIVOT_COLUMN_TOTAL_COL_TYPE = "pivotColumnTotal";
@@ -9,6 +10,7 @@ export type LayoutManagerOptions = {
9
10
  gridApi: GridApi;
10
11
  debugId: string;
11
12
  layoutChangeDebounce?: number;
13
+ initialRowSelection?: GridOptions['rowSelection'];
12
14
  };
13
15
  type ApplyLayoutOptions = {
14
16
  skipApplyRowGroupsExpandedState?: boolean;
@@ -26,6 +28,7 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
26
28
  private suppressGlobalAgGridEventListener;
27
29
  private supressGlobalAgGridEventTimeoutId;
28
30
  private layoutManagerDebugId;
31
+ private initialRowSelection;
29
32
  constructor(options: LayoutManagerOptions);
30
33
  destroy(): void;
31
34
  private setupEvents;
@@ -69,6 +72,13 @@ export declare class LayoutManager<DATA_TYPE = any> extends LMEmitter {
69
72
  private getLayoutDetailsAsString;
70
73
  applyColumnDefsChanges(layout: TableLayoutModel | PivotLayoutModel): boolean;
71
74
  private applyColumnSizingColumnDefsChanges;
75
+ static readonly SELECTION_COLUMN_ID = "ag-Grid-SelectionColumn";
76
+ static getGridOptionForRowSelectionFromLayout(layoutRowSelection: LayoutRowSelection | false | undefined, baseGridRowSelection: GridOptions['rowSelection']): GridOptions['rowSelection'] | undefined;
77
+ static isSelectionColumnInNonFirstPosition(tableColumns: string[] | undefined): boolean;
78
+ static shouldUnlockSelectionColumnPosition(layout: TableLayoutModel): boolean;
79
+ private ensureSelectionColumnPositionUnlocked;
80
+ private getRowSelectionFromGrid;
81
+ private applyRowSelection;
72
82
  private applyTableLayout;
73
83
  private getRowGroupNodePathsAs;
74
84
  applyRowGroupValues(RowGroupValues: TableLayoutModel['RowGroupValues'], rowGroupedColumns: string[]): void;
@@ -141,6 +141,19 @@ function getDefaultColumnSizeStateForColDef(colId, colDef, options) {
141
141
  }
142
142
  return undefined;
143
143
  }
144
+ function adjustColumnIdsForSelection(columnIds, layout) {
145
+ const selectionColPinning = layout.ColumnPinning?.[LayoutManager.SELECTION_COLUMN_ID];
146
+ if ((layout.RowSelection || selectionColPinning) &&
147
+ !columnIds.includes(LayoutManager.SELECTION_COLUMN_ID)) {
148
+ if (selectionColPinning === 'right') {
149
+ columnIds = [...columnIds, LayoutManager.SELECTION_COLUMN_ID];
150
+ }
151
+ else {
152
+ columnIds = [LayoutManager.SELECTION_COLUMN_ID, ...columnIds];
153
+ }
154
+ }
155
+ return columnIds;
156
+ }
144
157
  class LayoutManager extends LMEmitter_1.LMEmitter {
145
158
  gridApi;
146
159
  fieldsToIds = {};
@@ -154,6 +167,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
154
167
  suppressGlobalAgGridEventListener = false;
155
168
  supressGlobalAgGridEventTimeoutId = null;
156
169
  layoutManagerDebugId;
170
+ initialRowSelection;
157
171
  constructor(options) {
158
172
  super({ debugId: options.debugId });
159
173
  this.layoutChangeDebounce = options.layoutChangeDebounce ?? 0;
@@ -162,6 +176,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
162
176
  wait: this.layoutChangeDebounce,
163
177
  }).bind(this);
164
178
  }
179
+ this.initialRowSelection = options.initialRowSelection;
165
180
  this.setOptions(options);
166
181
  // this ensures the grand total columns are positioned correctly (before/after) even when changed at runtime
167
182
  // see https://www.ag-grid.com/react-data-grid/pivoting-column-groups/#changing-data-filters-and-configurations
@@ -403,6 +418,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
403
418
  PivotGroupedColumns: layout.RowGroupedColumns,
404
419
  PivotAggregationColumns: layout.TableAggregationColumns,
405
420
  GrandTotalRow: layout.GrandTotalRow,
421
+ RowSelection: layout.RowSelection,
406
422
  PivotExpandLevel: prevLayout?.PivotExpandLevel ?? -1,
407
423
  };
408
424
  if (storePivotResultColumns) {
@@ -434,7 +450,6 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
434
450
  }
435
451
  getUndecidedLayoutModelFromGrid(columnState) {
436
452
  let TableColumns = columnState.map((c) => c.colId);
437
- // .filter((colId) => colId !== 'ag-Grid-SelectionColumn');
438
453
  let ColumnSorts = [];
439
454
  const RowGroupedColumns = [];
440
455
  let RowGroupValues = undefined;
@@ -742,6 +757,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
742
757
  GrandTotalRow: this.gridApi.getGridOption('grandTotalRow'),
743
758
  SuppressAggFuncInHeader: this.gridApi.getGridOption('suppressAggFuncInHeader'),
744
759
  RowGroupDisplayType: this.gridApi.getGridOption('groupDisplayType') === 'multipleColumns' ? 'multi' : 'single',
760
+ RowSelection: this.getRowSelectionFromGrid(),
745
761
  });
746
762
  return layout;
747
763
  }
@@ -809,13 +825,15 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
809
825
  layout.TableColumns = layout.TableColumns.filter((colId) => colId != undefined);
810
826
  layout = (0, normalizeLayoutModel_1.normalizeTableLayoutModel)(layout, { isTree: _options?.isTree ?? false });
811
827
  const agGridState = {};
812
- const columnIds = getColumnOrderIdsForAllColDefs(layout.TableColumns, colDefs);
828
+ const columnIds = adjustColumnIdsForSelection(getColumnOrderIdsForAllColDefs(layout.TableColumns, colDefs), layout);
813
829
  agGridState.columnOrder = {
814
830
  orderedColIds: columnIds,
815
831
  };
816
832
  const flatColDefs = flattenColDefs(colDefs);
817
833
  const colDefsById = new Map(flatColDefs.map((colDef) => [colDef.colId ?? colDef.field, colDef]));
818
834
  const getColDef = (colId) => colDefsById.get(colId);
835
+ // TODO to implement support for row selection in server-side row model
836
+ // agGridState.rowSelection = { ... }
819
837
  agGridState.columnVisibility = {
820
838
  hiddenColIds: flatColDefs
821
839
  .filter((colDef) => {
@@ -1104,6 +1122,7 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1104
1122
  else {
1105
1123
  this.gridApi.setGridOption('grandTotalRow', null);
1106
1124
  }
1125
+ this.applyRowSelection(layout);
1107
1126
  this.applyColumnDefsChanges(layout);
1108
1127
  if ((0, isPivotLayoutModel_1.isPivotLayoutModel)(layout)) {
1109
1128
  try {
@@ -1161,8 +1180,131 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1161
1180
  }
1162
1181
  return false;
1163
1182
  }
1183
+ static SELECTION_COLUMN_ID = 'ag-Grid-SelectionColumn';
1184
+ static getGridOptionForRowSelectionFromLayout(layoutRowSelection, baseGridRowSelection) {
1185
+ if (layoutRowSelection === false) {
1186
+ return undefined;
1187
+ }
1188
+ if (layoutRowSelection == null) {
1189
+ return baseGridRowSelection;
1190
+ }
1191
+ const current = baseGridRowSelection && typeof baseGridRowSelection !== 'string'
1192
+ ? baseGridRowSelection
1193
+ : {};
1194
+ const updated = { ...current };
1195
+ if (layoutRowSelection.Mode != null) {
1196
+ updated.mode = layoutRowSelection.Mode;
1197
+ }
1198
+ if (layoutRowSelection.Checkboxes != null) {
1199
+ updated.checkboxes = layoutRowSelection.Checkboxes;
1200
+ }
1201
+ if (layoutRowSelection.GroupSelectMode != null) {
1202
+ updated.groupSelects = layoutRowSelection.GroupSelectMode;
1203
+ }
1204
+ if (layoutRowSelection.SelectAllMode != null) {
1205
+ updated.selectAll = layoutRowSelection.SelectAllMode;
1206
+ }
1207
+ if (layoutRowSelection.HeaderCheckbox != null) {
1208
+ updated.headerCheckbox = layoutRowSelection.HeaderCheckbox;
1209
+ }
1210
+ if (layoutRowSelection.EnableClickSelection != null) {
1211
+ updated.enableClickSelection = layoutRowSelection.EnableClickSelection;
1212
+ }
1213
+ if (layoutRowSelection.CheckboxInGroupColumn != null) {
1214
+ updated.checkboxLocation = layoutRowSelection.CheckboxInGroupColumn
1215
+ ? 'autoGroupColumn'
1216
+ : 'selectionColumn';
1217
+ }
1218
+ return updated;
1219
+ }
1220
+ static isSelectionColumnInNonFirstPosition(tableColumns) {
1221
+ if (!tableColumns) {
1222
+ return false;
1223
+ }
1224
+ const index = tableColumns.indexOf(LayoutManager.SELECTION_COLUMN_ID);
1225
+ return index > 0;
1226
+ }
1227
+ static shouldUnlockSelectionColumnPosition(layout) {
1228
+ const tableColumns = layout.TableColumns;
1229
+ if (!tableColumns) {
1230
+ return false;
1231
+ }
1232
+ const index = tableColumns.indexOf(LayoutManager.SELECTION_COLUMN_ID);
1233
+ if (index > 0) {
1234
+ return true;
1235
+ }
1236
+ const columnPinning = layout.ColumnPinning;
1237
+ if (columnPinning && columnPinning[LayoutManager.SELECTION_COLUMN_ID]) {
1238
+ return true;
1239
+ }
1240
+ return false;
1241
+ }
1242
+ ensureSelectionColumnPositionUnlocked(layout) {
1243
+ if (LayoutManager.shouldUnlockSelectionColumnPosition(layout)) {
1244
+ const current = this.gridApi.getGridOption('selectionColumnDef');
1245
+ if (!current || current.lockPosition !== false) {
1246
+ this.gridApi.setGridOption('selectionColumnDef', {
1247
+ ...current,
1248
+ lockPosition: false,
1249
+ });
1250
+ }
1251
+ }
1252
+ }
1253
+ getRowSelectionFromGrid() {
1254
+ const gridRowSelection = this.gridApi.getGridOption('rowSelection');
1255
+ if (!gridRowSelection || typeof gridRowSelection === 'string') {
1256
+ return this.currentLayout?.RowSelection === false ? false : undefined;
1257
+ }
1258
+ const rs = gridRowSelection;
1259
+ const result = {
1260
+ Mode: rs.mode ?? 'singleRow',
1261
+ };
1262
+ if (rs.checkboxes != null) {
1263
+ result.Checkboxes = rs.checkboxes;
1264
+ }
1265
+ if (rs.mode === 'multiRow' && rs.groupSelects != null) {
1266
+ result.GroupSelectMode = rs.groupSelects;
1267
+ }
1268
+ if (rs.mode === 'multiRow' && rs.selectAll != null) {
1269
+ result.SelectAllMode = rs.selectAll;
1270
+ }
1271
+ if (rs.mode === 'multiRow' && rs.headerCheckbox != null) {
1272
+ result.HeaderCheckbox = rs.headerCheckbox;
1273
+ }
1274
+ if (rs.enableClickSelection != null) {
1275
+ result.EnableClickSelection =
1276
+ rs.enableClickSelection;
1277
+ }
1278
+ if (rs.checkboxLocation != null) {
1279
+ result.CheckboxInGroupColumn = rs.checkboxLocation === 'autoGroupColumn';
1280
+ }
1281
+ return result;
1282
+ }
1283
+ applyRowSelection(layout) {
1284
+ const rowSelection = LayoutManager.getGridOptionForRowSelectionFromLayout(layout.RowSelection, this.initialRowSelection);
1285
+ const prevRowSelection = this.gridApi.getGridOption('rowSelection');
1286
+ this.gridApi.setGridOption('rowSelection', rowSelection);
1287
+ // AG Grid does not always refresh already-rendered cells in the selection
1288
+ // column when `rowSelection.checkboxes` is changed at runtime via setGridOption
1289
+ // (e.g. toggling `checkboxes` or `headerCheckbox`).
1290
+ // In the React wrapper this is masked by React-driven re-renders, but in the vanilla integration
1291
+ // the selection column keeps showing stale content until a manual
1292
+ // `refreshCells` is triggered. We force the refresh here so
1293
+ // all integrations behave consistently.
1294
+ if (typeof prevRowSelection === 'object' &&
1295
+ typeof rowSelection === 'object' &&
1296
+ rowSelection.checkboxes !== prevRowSelection.checkboxes) {
1297
+ const selectionColumn = this.gridApi.getColumn(LayoutManager.SELECTION_COLUMN_ID);
1298
+ if (selectionColumn) {
1299
+ this.gridApi.refreshCells({
1300
+ columns: [LayoutManager.SELECTION_COLUMN_ID],
1301
+ });
1302
+ }
1303
+ }
1304
+ }
1164
1305
  applyTableLayout(layout, options) {
1165
1306
  this.withSuppressColumnAnimation(() => {
1307
+ this.ensureSelectionColumnPositionUnlocked(layout);
1166
1308
  // if we apply the state here, before calling setGridOption for groupDisplayType
1167
1309
  // the order is not always correctly applied
1168
1310
  // this.gridApi.applyColumnState(state);
@@ -1480,10 +1622,20 @@ class LayoutManager extends LMEmitter_1.LMEmitter {
1480
1622
  computeColumnOrderAndVisibility(layout, columnState) {
1481
1623
  const visibility = layout.ColumnVisibility || {};
1482
1624
  const columnOrderSet = new Set(layout.TableColumns);
1483
- const isColHidden = (colId) => visibility[colId] === false || !columnOrderSet.has(colId);
1625
+ const isColHidden = (colId) => {
1626
+ if (visibility[colId] === false) {
1627
+ return true;
1628
+ }
1629
+ // for the selection column, return true even
1630
+ // if not explicitly listed in the TableColumns
1631
+ if (colId === LayoutManager.SELECTION_COLUMN_ID && layout.RowSelection) {
1632
+ return false;
1633
+ }
1634
+ return !columnOrderSet.has(colId);
1635
+ };
1484
1636
  columnState = columnState ?? {};
1485
1637
  columnState.applyOrder = true;
1486
- const columnIds = getColumnOrderIdsForAllColDefs(layout.TableColumns, this.gridApi.getColumnDefs());
1638
+ const columnIds = adjustColumnIdsForSelection(getColumnOrderIdsForAllColDefs(layout.TableColumns, this.gridApi.getColumnDefs()), layout);
1487
1639
  columnState.state = columnIds.map((columnId) => {
1488
1640
  return {
1489
1641
  colId: columnId,
@@ -41,6 +41,10 @@ function normalizeTableLayoutModel(layout, options) {
41
41
  // make it an own property
42
42
  layout.GrandTotalRow = undefined;
43
43
  }
44
+ if (!('RowSelection' in layout)) {
45
+ // make it an own property
46
+ layout.RowSelection = undefined;
47
+ }
44
48
  const ColumnOrderSet = new Set(layout.TableColumns);
45
49
  if (layout.RowGroupedColumns && layout.RowGroupedColumns.length && layout.TableColumns) {
46
50
  // the layout.TableColumns might not include the group columns
@@ -174,6 +178,10 @@ function normalizePivotLayoutModel(layout) {
174
178
  // make it an own property
175
179
  layout.PivotColumnTotal = undefined;
176
180
  }
181
+ if (!('RowSelection' in layout)) {
182
+ // make it an own property
183
+ layout.RowSelection = undefined;
184
+ }
177
185
  // if (layout.PivotGroupedColumns && layout.PivotGroupedColumns.length) {
178
186
  layout.RowGroupDisplayType = layout.RowGroupDisplayType || 'single';
179
187
  // }
@@ -13,6 +13,9 @@ function simplifyTableLayoutModel(layout) {
13
13
  if (layout.ColumnSizing && !Object.keys(layout.ColumnSizing).length) {
14
14
  delete layout.ColumnSizing;
15
15
  }
16
+ if (layout.RowSelection == undefined) {
17
+ delete layout.RowSelection;
18
+ }
16
19
  if (layout.ColumnSorts && !layout.ColumnSorts.length) {
17
20
  delete layout.ColumnSorts;
18
21
  }
@@ -77,6 +80,9 @@ function simplifyPivotLayoutModel(layout) {
77
80
  if (layout.ColumnSizing && !Object.keys(layout.ColumnSizing).length) {
78
81
  delete layout.ColumnSizing;
79
82
  }
83
+ if (layout.RowSelection == undefined) {
84
+ delete layout.RowSelection;
85
+ }
80
86
  if (!layout.SuppressAggFuncInHeader) {
81
87
  delete layout.SuppressAggFuncInHeader;
82
88
  }
@@ -1,19 +1,28 @@
1
1
  export type AdaptableMetamodel = Record<string, MetamodelItem>;
2
2
  export interface MetamodelItem {
3
- name: string;
4
- kind: 'A' | 'I' | 'C';
5
- desc: string;
6
- props?: MetamodelItemProperty[];
3
+ /** Item kind: 'A' (type alias), 'I' (interface), 'C' (class) */
4
+ k: 'A' | 'I' | 'C';
5
+ /** Description (only present for noCode-tagged items) */
6
+ d?: string;
7
+ /** Properties of this item */
8
+ p?: MetamodelItemProperty[];
7
9
  }
8
10
  export interface MetamodelItemProperty {
9
- name: string;
10
- kind: MetamodelItemPropertyKind;
11
- desc: string;
12
- uiLabel?: string;
13
- ref?: string;
14
- isOpt?: boolean;
15
- defVal?: unknown;
16
- gridInfo?: 'item' | 'container';
17
- noCode?: 'item' | 'container';
11
+ /** Property name */
12
+ n: string;
13
+ /** Property kind / type */
14
+ k: MetamodelItemPropertyKind;
15
+ /** Description (only present for noCode-tagged properties) */
16
+ d?: string;
17
+ /** UI label override for display */
18
+ l?: string;
19
+ /** Reference to another MetamodelItem key */
20
+ r?: string;
21
+ /** Whether the property is optional */
22
+ o?: boolean;
23
+ /** Grid Info role: 'item' or 'container' */
24
+ g?: 'item' | 'container';
25
+ /** No-Code role: 'item' or 'container' */
26
+ nC?: 'item' | 'container';
18
27
  }
19
28
  export type MetamodelItemPropertyKind = 'R' | 'n' | 's' | 'b' | 'd' | 'f' | 'a' | 'i' | 'u';