d2coreui 26.1.0 → 26.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 26.1.1
4
+
5
+ - `DataGrid`: a `getRowId` prop overrides the default row id `String(data.id)`.
6
+ - `DataGrid` / `ExtendedDataGrid`: `headerMenu` (`renderer`, `onClick`, both with the column) customizes the menu of a
7
+ column header, like `settingsMenu` the toolbar settings menu.
8
+
3
9
  ## 26.1.0
4
10
 
5
11
  - `DataGrid` / `ExtendedDataGrid`: `toolbar.compact` for a narrow (mobile) screen - the export and table settings
@@ -166,7 +166,7 @@ export type OnLoadDataCallback = (totalRecords: number) => void;
166
166
  * - `columnDefs` are {@link DataGridColDef}s, optionally wrapped in {@link DataGridColGroupDef}s;
167
167
  * - `paginationPageSize` is not available, use `paging.pageSize`;
168
168
  * - `getRowStyle` is combined with {@link DataGridProps.rowStyleRules};
169
- * - `getRowId` is fixed to `String(data.id)`, so every row object must have a unique `id`;
169
+ * - `getRowId` defaults to `String(data.id)`, so without it every row object must have a unique `id`;
170
170
  * - the pagination panel, overlays, header component, column types, `context` and several event handlers are provided
171
171
  * by DataGrid (the handlers listed here are still called).
172
172
  *
@@ -335,6 +335,27 @@ export interface DataGridProps<TData = any> extends Omit<GridOptions<TData>, "co
335
335
  /** Called with the key of a clicked custom (non built-in) menu item. */
336
336
  onClick?(key: string): void;
337
337
  };
338
+ /**
339
+ * Column header menu customization (right click or the menu button of a column header - pin, autosize, hide, reset
340
+ * columns, columns configuration). Applies to the columns with the built-in header component.
341
+ */
342
+ headerMenu?: {
343
+ /**
344
+ * Transforms the default menu items, e.g. to add or remove entries.
345
+ *
346
+ * @param menuElements The default items.
347
+ * @param column The column whose header the menu belongs to.
348
+ * @returns The items of the menu.
349
+ */
350
+ renderer?(menuElements: MenuElement[], column: Column): MenuElement[];
351
+ /**
352
+ * Called with the key of a clicked custom (non built-in) menu item.
353
+ *
354
+ * @param key The key of the item.
355
+ * @param column The column whose header the menu belongs to.
356
+ */
357
+ onClick?(key: string, column: Column): void;
358
+ };
338
359
  /** Row context menu (right click) customization; the built-in items export the selected rows to TXT, CSV, PDF or the clipboard. */
339
360
  contextMenu?: {
340
361
  /** Transforms the default menu items, e.g. to add or remove entries. */
@@ -653,6 +674,8 @@ export default class DataGrid<TData extends {
653
674
  private renderSearchButton;
654
675
  /** Builds the toolbar settings menu (keys `columnFilter`, `autosizeAllColumns`, `columnsConfig`, `advancedConfig`), passed through `settingsMenu.renderer`. */
655
676
  getSettingsMenu(): MenuProps;
677
+ /** @returns {@link DataGridProps.headerMenu} as it is now - the header components keep this function, not the props. */
678
+ getHeaderMenuCustomization(): DataGridProps["headerMenu"];
656
679
  private getAdaptedColumnDefs;
657
680
  private isInRange;
658
681
  render(): React.JSX.Element;
@@ -201,6 +201,7 @@ class DataGrid extends React.Component {
201
201
  this.onSortChanged = this.onSortChanged.bind(this);
202
202
  this.showTableConfiguration = this.showTableConfiguration.bind(this);
203
203
  this.showColumnsConfig = this.showColumnsConfig.bind(this);
204
+ this.getHeaderMenuCustomization = this.getHeaderMenuCustomization.bind(this);
204
205
  this.navigateToNextCell = this.navigateToNextCell.bind(this);
205
206
  this.suppressKeyboardEvent = this.suppressKeyboardEvent.bind(this);
206
207
  this.onRowDataUpdated = this.onRowDataUpdated.bind(this);
@@ -1871,6 +1872,10 @@ class DataGrid extends React.Component {
1871
1872
  }
1872
1873
  };
1873
1874
  }
1875
+ /** @returns {@link DataGridProps.headerMenu} as it is now - the header components keep this function, not the props. */
1876
+ getHeaderMenuCustomization() {
1877
+ return this.props.headerMenu;
1878
+ }
1874
1879
  getAdaptedColumnDefs(columnDefs, floatingFilterEnabled, disableColumnDefsPreprocessing) {
1875
1880
  if (columnDefs.length === 0) {
1876
1881
  return undefined;
@@ -1899,7 +1904,8 @@ class DataGrid extends React.Component {
1899
1904
  });
1900
1905
  }
1901
1906
  return Object.assign(Object.assign({}, rest), { floatingFilter: floatingFilterEnabledForColumn && floatingFilterEnabled, resizable: true, headerComponent: headerComponent !== null && headerComponent !== void 0 ? headerComponent : "simpleHeader", headerComponentParams: headerComponentParams !== null && headerComponentParams !== void 0 ? headerComponentParams : {
1902
- onColumnsConfigVisible: this.showColumnsConfig
1907
+ onColumnsConfigVisible: this.showColumnsConfig,
1908
+ getHeaderMenuCustomization: this.getHeaderMenuCustomization,
1903
1909
  }, hide: (_d = (_c = this.state.columnModel.find((c) => c.colId === columnDef.colId)) === null || _c === void 0 ? void 0 : _c.hide) !== null && _d !== void 0 ? _d : (hide === undefined ? rest.initialHide : hide), cellStyle: this._getCellStyle, cellRendererParams: columnDef.cellStyle ? Object.assign(columnDef.cellRendererParams !== undefined ? columnDef.cellRendererParams : {}, { originalCellStyle: columnDef.cellStyle }) : columnDef.cellRendererParams, editable: editable, cellEditorPopup: !editable ? undefined : cellEditorPopup !== false, cellClassRules: {
1904
1910
  'cell-has-handle': (p) => { var _a, _b; return ((_a = this.state.focusedCell) === null || _a === void 0 ? void 0 : _a.rowIndex) === p.rowIndex && ((_b = this.state.focusedCell) === null || _b === void 0 ? void 0 : _b.colId) === p.colDef.colId && !this.state.isDragging; },
1905
1911
  'cell-drag-selected': (params) => (this.state.startCoord !== null && this.state.endCoord !== null) ? this.isInRange(params.rowIndex, params.colDef.colId) : false,
@@ -1929,7 +1935,7 @@ class DataGrid extends React.Component {
1929
1935
  ;
1930
1936
  render() {
1931
1937
  var _a;
1932
- const _b = this.props, { onGridReady, columnDefs, disableColumnDefsPreprocessing, onColumnsChanged, paging, onPaginationChanged, onViewportChanged, selectedIds, search, toolbar, filter, onFilterChanged, onFilterModified, onCellFocused, onSortChanged, components, tableConfigVisible, onTableConfigVisible, noRecordsOverlayRenderer, loadingOverlayRenderer, onRowDataUpdated, onLoadData, rowStyleRules, defaultRowStyleRules, onChangeRowStyleRules, showMilliseconds, defaultShowMilliseconds, onShowMilliseconds, hideYear, defaultHideYear, onShowYear, showUtcOffset, defaultShowUtcOffset, onShowUtcOffset, suppressLoadingOverlay, defaultColDef, headerHeight, rowData, rowDataManualMode, gridRef, quickFilterParser, quickFilterMatcher, rowSelection, contextMenu, settingsMenu, exportMenu, panelStyle, tablePanelStyle, onColumnDefsAdapted, tableOverlayRenderer, onKeyPressed, theme } = _b, passedProperties = __rest(_b, ["onGridReady", "columnDefs", "disableColumnDefsPreprocessing", "onColumnsChanged", "paging", "onPaginationChanged", "onViewportChanged", "selectedIds", "search", "toolbar", "filter", "onFilterChanged", "onFilterModified", "onCellFocused", "onSortChanged", "components", "tableConfigVisible", "onTableConfigVisible", "noRecordsOverlayRenderer", "loadingOverlayRenderer", "onRowDataUpdated", "onLoadData", "rowStyleRules", "defaultRowStyleRules", "onChangeRowStyleRules", "showMilliseconds", "defaultShowMilliseconds", "onShowMilliseconds", "hideYear", "defaultHideYear", "onShowYear", "showUtcOffset", "defaultShowUtcOffset", "onShowUtcOffset", "suppressLoadingOverlay", "defaultColDef", "headerHeight", "rowData", "rowDataManualMode", "gridRef", "quickFilterParser", "quickFilterMatcher", "rowSelection", "contextMenu", "settingsMenu", "exportMenu", "panelStyle", "tablePanelStyle", "onColumnDefsAdapted", "tableOverlayRenderer", "onKeyPressed", "theme"]);
1938
+ const _b = this.props, { onGridReady, columnDefs, disableColumnDefsPreprocessing, onColumnsChanged, paging, onPaginationChanged, onViewportChanged, selectedIds, search, toolbar, filter, onFilterChanged, onFilterModified, onCellFocused, onSortChanged, components, tableConfigVisible, onTableConfigVisible, noRecordsOverlayRenderer, loadingOverlayRenderer, onRowDataUpdated, onLoadData, rowStyleRules, defaultRowStyleRules, onChangeRowStyleRules, showMilliseconds, defaultShowMilliseconds, onShowMilliseconds, hideYear, defaultHideYear, onShowYear, showUtcOffset, defaultShowUtcOffset, onShowUtcOffset, suppressLoadingOverlay, defaultColDef, headerHeight, rowData, rowDataManualMode, gridRef, quickFilterParser, quickFilterMatcher, rowSelection, contextMenu, settingsMenu, headerMenu, exportMenu, panelStyle, tablePanelStyle, onColumnDefsAdapted, tableOverlayRenderer, onKeyPressed, theme } = _b, passedProperties = __rest(_b, ["onGridReady", "columnDefs", "disableColumnDefsPreprocessing", "onColumnsChanged", "paging", "onPaginationChanged", "onViewportChanged", "selectedIds", "search", "toolbar", "filter", "onFilterChanged", "onFilterModified", "onCellFocused", "onSortChanged", "components", "tableConfigVisible", "onTableConfigVisible", "noRecordsOverlayRenderer", "loadingOverlayRenderer", "onRowDataUpdated", "onLoadData", "rowStyleRules", "defaultRowStyleRules", "onChangeRowStyleRules", "showMilliseconds", "defaultShowMilliseconds", "onShowMilliseconds", "hideYear", "defaultHideYear", "onShowYear", "showUtcOffset", "defaultShowUtcOffset", "onShowUtcOffset", "suppressLoadingOverlay", "defaultColDef", "headerHeight", "rowData", "rowDataManualMode", "gridRef", "quickFilterParser", "quickFilterMatcher", "rowSelection", "contextMenu", "settingsMenu", "headerMenu", "exportMenu", "panelStyle", "tablePanelStyle", "onColumnDefsAdapted", "tableOverlayRenderer", "onKeyPressed", "theme"]);
1933
1939
  let key;
1934
1940
  let paginationPageSize = undefined;
1935
1941
  if (paging.pageSize > 0) {
@@ -1994,7 +2000,7 @@ class DataGrid extends React.Component {
1994
2000
  React.createElement(ConfigProvider.ConfigContext.Consumer, null, (context) => {
1995
2001
  var _a;
1996
2002
  const defaultTheme = theme !== null && theme !== void 0 ? theme : this.getTheme((_a = context.theme) === null || _a === void 0 ? void 0 : _a.algorithm, styles.theme);
1997
- return (React.createElement(AgGridReact, Object.assign({ key: key, debug: debugMode, ref: gridRef, theme: defaultTheme, paginationPageSize: paginationPageSize, maxConcurrentDatasourceRequests: this.props.rowModelType === "infinite" ? 1 : undefined, onGridReady: this.onGridReady, onPaginationChanged: this.onPaginationChanged, onFilterModified: this.onFilterModified, onFilterChanged: this.onFilterChanged, onSortChanged: this.onSortChanged, defaultColDef: this.getDefaultColDefinition(defaultColDef), columnDefs: adaptedColumnDefs, rowData: !rowDataManualMode ? rowData : undefined }, passedProperties, { onCellFocused: this.onCellFocused, cellSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", rowSelection: rowSelection, suppressRowClickSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressRowDeselection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressPaginationPanel: true, getRowId: getRowId, maintainColumnOrder: true, components: customComponents, columnTypes: this.columnTypes, onColumnVisible: this.onColumnsChanged, onColumnPinned: this.onColumnsChanged, onColumnResized: this.onColumnsChanged, onColumnMoved: this.onColumnsChanged, onNewColumnsLoaded: this.onNewColumnsLoaded, onCellMouseOver: this.onCellMouseOver, onCellMouseDown: this.onCellMouseDown, navigateToNextCell: this.navigateToNextCell, onViewportChanged: this.onViewportChanged, onCellContextMenu: this.onCellContextMenu, loadingOverlayComponent: 'loadingOverlay', noRowsOverlayComponent: 'noRecordsOverlay', onRowDataUpdated: this.onRowDataUpdated, context: this.table_context, rowHeight: this.state.rowHeight, getRowStyle: this._getRowStyle, getRowHeight: this._getRowHeight, headerHeight: headerHeight !== undefined ? headerHeight : headerFilterRowHeight, floatingFiltersHeight: headerFilterRowHeight, suppressLoadingOverlay: this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay, quickFilterParser: this.wildcardQuickFilter.quickFilterParser, quickFilterMatcher: this.wildcardQuickFilter.quickFilterMatcher })));
2003
+ return (React.createElement(AgGridReact, Object.assign({ key: key, debug: debugMode, ref: gridRef, theme: defaultTheme, paginationPageSize: paginationPageSize, maxConcurrentDatasourceRequests: this.props.rowModelType === "infinite" ? 1 : undefined, onGridReady: this.onGridReady, onPaginationChanged: this.onPaginationChanged, onFilterModified: this.onFilterModified, onFilterChanged: this.onFilterChanged, onSortChanged: this.onSortChanged, defaultColDef: this.getDefaultColDefinition(defaultColDef), columnDefs: adaptedColumnDefs, rowData: !rowDataManualMode ? rowData : undefined, getRowId: getRowId }, passedProperties, { onCellFocused: this.onCellFocused, cellSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", rowSelection: rowSelection, suppressRowClickSelection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressRowDeselection: rowSelection === "multiple" || (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.mode) === "multiRow", suppressPaginationPanel: true, maintainColumnOrder: true, components: customComponents, columnTypes: this.columnTypes, onColumnVisible: this.onColumnsChanged, onColumnPinned: this.onColumnsChanged, onColumnResized: this.onColumnsChanged, onColumnMoved: this.onColumnsChanged, onNewColumnsLoaded: this.onNewColumnsLoaded, onCellMouseOver: this.onCellMouseOver, onCellMouseDown: this.onCellMouseDown, navigateToNextCell: this.navigateToNextCell, onViewportChanged: this.onViewportChanged, onCellContextMenu: this.onCellContextMenu, loadingOverlayComponent: 'loadingOverlay', noRowsOverlayComponent: 'noRecordsOverlay', onRowDataUpdated: this.onRowDataUpdated, context: this.table_context, rowHeight: this.state.rowHeight, getRowStyle: this._getRowStyle, getRowHeight: this._getRowHeight, headerHeight: headerHeight !== undefined ? headerHeight : headerFilterRowHeight, floatingFiltersHeight: headerFilterRowHeight, suppressLoadingOverlay: this.props.loadingOverlayRenderer ? true : this.props.suppressLoadingOverlay, quickFilterParser: this.wildcardQuickFilter.quickFilterParser, quickFilterMatcher: this.wildcardQuickFilter.quickFilterMatcher })));
1998
2004
  }),
1999
2005
  this.state.loading && this.props.loadingOverlayRenderer &&
2000
2006
  React.createElement("div", { className: "ag-overlay", "aria-hidden": "true" },