d2coreui 23.0.60 → 23.0.61

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,136 +1,150 @@
1
- # Changelog
2
-
3
- ## 23.0.60
4
-
5
- - `ExtendedDataGrid`: `GridConfiguration.showUtcOffset` and `defaultShowUtcOffset` are no longer `true` by default -
6
- without them the grid follows the global mode of `LocaleHolder.setUtcOffsetMode`. Pass `showUtcOffset: true` in
7
- `defaultGridConfiguration` to keep the UTC offset in a grid.
8
- - `ExtendedDataGrid`: `getGridDateTimeFormat(configuration)` returns the date-time format the grid's date-time columns
9
- use (year, milliseconds and UTC offset of the table settings), for columns that format date-time values themselves.
10
- - `DataGrid`: the `dateColumn`, `dateTimeColumn` and `fromNowDateTimeColumn` columns show a missing value and the D2000
11
- null time as an empty cell (also in the copied and exported text) instead of `---`, `Null Time` or a date in 1972,
12
- and the column filters and the quick filter no longer match the null time by its 1972 date. The time `0` is shown
13
- as its date in 1970 in `dateTimeColumn` too, instead of an empty cell.
14
- - `DataGrid`: Ctrl+Enter in a cell editor works like Enter instead of ag-grid's bulk edit, which wrote the value into
15
- every cell of the selected rows.
16
- - `DateTimeInput`: the D2000 null time is recognized (shown empty with the `Null Time` placeholder) also after
17
- `setUnixTimeConversion(UnixTimeConversionEnum.FROM_MILIS)`, not only in the seconds mode.
18
- - `DateTimeInput` / `DateRangeInput`: with a `Z` / `ZZ` mask the UTC offset no longer has to be typed - an empty or
19
- mismatching offset is completed from the typed date and time (in the repeated hour of the daylight saving time to
20
- the second one, as `B` of `HH?`), instead of leaving the value invalid until the exact offset is typed.
21
- - `DurationInput`: no longer fails with `isDuration is not a function` in a Vite production build of an application,
22
- when the component is loaded before the dayjs duration plugin of `d2core/dayjs` is applied.
23
-
24
- ## 23.0.59
25
-
26
- - `DataGrid` / `ExtendedDataGrid`: `toolbar.compact` for a narrow (mobile) screen - the export and table settings
27
- buttons move into a popover opened by one button, the pager has only the previous, "page / pages" and next buttons,
28
- and a pager that still does not fit moves to a line of its own under the toolbar.
29
- - `DataGrid`: the toolbar line is aligned to the top, so the pager and the record range stay next to the toolbar
30
- buttons when `toolbar.renderToolbar` adds content under them; `toolbar.extraContent` lower than a button is now at the
31
- top of the line instead of in its middle.
32
-
33
- ## 23.0.58
34
-
35
- - `ModalDialog`: the maximize / restore button is shown only with `maximizable`, which is now `false` by default -
36
- pass `maximizable` to keep the button in a dialog.
37
- - `DataGrid` / `ExtendedDataGrid`: a column with ag-grid's `lockVisible` (also from `defaultColDef` or a column type)
38
- can no longer be hidden or shown from the column menu ("Hide Column" is disabled), the columns configuration dialog
39
- or the column tree of the table settings (the column is disabled there and left out when its whole group is moved
40
- or checked). ag-grid applies `lockVisible` only to its own UI, which the grid does not use.
41
- - `ColumnTransfer`: a column group in the tree (the `SIMPLE` layout and the hidden columns of the `FULL` layout) is
42
- shown as fully checked only when all its columns are checked, including locked ones; otherwise it is half checked.
43
- A click on a group checks its unlocked columns, or unchecks them when all of them are checked.
44
-
45
- ## 23.0.57
46
-
47
- - `DateTimeInput` / `DateRangeInput`: `autoWidth` measures the right width with a theme `fontFamily` that is not a
48
- valid unquoted CSS name (e.g. `"72"`); the input was too narrow and cut the value.
49
- - `DateRangeInput`: in the advanced popup the begin / both / end time shift icons sit below the duration buttons,
50
- so that "Now", "Hour" and "15 min" of the three columns are in one row.
51
- - `DataGrid` / `ExtendedDataGrid`: the `oddRowBackgroundColor` of a `theme` passed in is applied; rows without a
52
- background color from `rowStyleRules` no longer get an inline `background-color: inherit` that overrode it. The
53
- default theme keeps odd rows unstriped unless the new antd token `gridOddRowBg` is set (`ConfigProvider`
54
- `theme={{token: {gridOddRowBg: "#fafafa"}}}`).
55
- - `ModalDialog`: a dialog opened larger than the window is shrunk to the window minus the margin a maximized dialog
56
- keeps, and centred, instead of filling the window edge to edge.
57
- - `ModalDialog`: a dialog kept in the DOM (`destroyOnHidden={false}`) opens on top of the modals opened since its first
58
- opening, instead of under them.
59
- - `DataGrid` / `ExtendedDataGrid`: changing the table configuration (column order, width, sort, …) no longer makes
60
- ag-grid log `Updated property onShowUtcOffset` in development - the time format props stay out of `AgGridReact`.
61
- - `DataGrid`: `onLoadData`, `defaultRowStyleRules` and the time format props no longer reach `AgGridReact`, which
62
- warned about them as invalid grid options.
63
- - `DataGrid` / `ExtendedDataGrid`: `showUtcOffset` takes a `UtcOffsetMode` of `d2core/i18n/localeHolder` - besides
64
- `true` / `false` also `"hourLetter"` (the repeated hour at the end of the daylight saving time as `A2:00` / `B2:00`)
65
- and `"offsetInFold"` (the UTC offset only in that hour); the table settings offer all four. `DataGrid` without
66
- `showUtcOffset` follows the global mode of `LocaleHolder.setUtcOffsetMode`.
67
- - `DateTimeInput` / `DateRangeInput`: a mask with `HH?` shows and takes the repeated hour as `A2` / `B2` - an hour
68
- typed there without the letter is the second one (`B`) and a letter outside that hour is invalid; a mask with `Z?`
69
- shows the UTC offset at every time, so that the input keeps its layout.
70
- - `DateTimeInput` / `DateRangeInput`: a time skipped at the start of the daylight saving time (29.03. 02:30) and a day
71
- that does not exist (31.02.) are invalid with any mask, instead of being silently moved to another time; the input
72
- no longer keeps showing such a typed text while it holds the moved value.
73
-
74
- ## 23.0.56
75
-
76
- - Components styled through `WithCss` (`DateTimeInput`, `DateRangeInput`, `DurationInput`, grid, pagination, …) take
77
- the `componentSize` of an enclosing `ConfigProvider` when given no `size` and outside a `Space.Compact`, instead of
78
- `middle` - the box no longer stays taller than the small inputs inside it.
79
- - `DateTimeInput` / `DateRangeInput`: `autoWidth` measures the mask in the font of the resolved size, so a `large`
80
- size taken from a `ConfigProvider` or a `Space.Compact` no longer cuts the value off.
81
- - `WithCss`: the render function gets the resolved `size` and `variant` as its second argument.
82
- - `DateRangeInputConfirm`: the Revert/Apply buttons are 48 px wide for a `small` size taken from a `ConfigProvider` or a
83
- `Space.Compact` as well, not only for the `size` prop.
84
- - `DateTimeInput`: the calendar icon is centred on the input even when a flex parent stretches the component.
85
- - `DateRangeInput`: the inputs and the `⟷` separator of the advanced popup are vertically centred; `compact` and `ranges`
86
- no longer reach the DOM as attributes.
87
- - `DateRangeInput`: the inputs of the advanced popup are at least as wide as the mask, so the popup grows with a long
88
- mask instead of cutting the values off; `autoWidth` inputs fill a root stretched by their parent.
89
- - `DateRangeInput`: the three button columns of the advanced popup share the extra width of a popup widened by the
90
- mask; the popup inputs are `small` like the rest of its controls.
91
-
92
- ## 23.0.55
93
-
94
- - `DateTimeInput`, `DateRangeInput`: optional `autoWidth` prop sizes the component to the rendered mask instead of
95
- filling the parent.
96
- - `DateRangeInput`: the separator between the two inputs is the antd `SwapRightOutlined` icon with the antd range
97
- picker spacing instead of the `⟷` character.
98
-
99
- ## 23.0.54
100
-
101
- - `DataGrid` / `ExtendedDataGrid`: typed by the row data type. `DataGridProps<TData>` and
102
- `ExtendedDataGridProps<TData>` pass it to the ag-grid `GridOptions` (`rowData`, `getRowId`, events, `gridRef`), and
103
- `DataGrid<TData>` uses it for `gridApi` and `columnTypes`. Without an explicit type argument the type is inferred from
104
- `rowData` and the handlers, so rows must have an `id` of type `number | string`, and handlers typed for another row
105
- type no longer compile. The default type argument is `any`.
106
- - `DataGrid` / `ExtendedDataGrid`: `columnDefs` may contain column groups (`DataGridColGroupDef`). The group is only a
107
- header; its children are adapted like top-level columns (header menu, resizing, cell style, drag & drop in the grid
108
- header) and the columns configuration dialog lists them by their own `group`. Reordering in the dialog does not
109
- respect group boundaries.
110
- - `DataGrid`: the fill-handle highlight uses the displayed column order, the same as the filled range.
111
-
112
- ## 23.0.53
113
-
114
- - `DateRangeInput`: time shift by month or year keeps an interval end that lies at the end of a month at the end of
115
- the target month (30.09. 23:59:59.999 - 1 month = 31.08. 23:59:59.999, not 30.08.). Other values shift as before.
116
- - The public API is documented with JSDoc and the published declaration files (`.d.ts`) keep the comments.
117
- - The package ships `README.md` and `CHANGELOG.md`.
118
-
119
- ## 23.0.52
120
-
121
- - `ExtendedDataGrid`: optional `detailPanel.onVisibleChange(visible)` handler, called when the splitter collapses or
122
- expands the detail panel (collapse arrow or dragging the divider).
123
-
124
- ## 23.0.51
125
-
126
- - pdfmake 0.2.23: `pdfmake/build/vfs_fonts` is a regular CommonJS module, vite applications need no workaround for
127
- the PDF export worker anymore.
128
- - `style/index.less` imports `antd/dist/reset.css` without the webpack-only `~` prefix.
129
- - codemirror 5.65.20.
130
- - Removed the unused `react-codemirror-runmode` dependency.
131
- - The package no longer ships `tsconfig.json` and `tsconfig.build.json`.
132
-
133
- ## 23.0.50
134
-
135
- - Grid export workers are standard `new Worker(new URL(...))` entry points: a webpack application emitting its
136
- chunks into a subdirectory needs `output.publicPath: "auto"`.
1
+ # Changelog
2
+
3
+ ## 23.0.61
4
+
5
+ - `DataGrid` / `ExtendedDataGrid`: `exportData(exportType, options)` exports the grid to a TXT, CSV or PDF file or to
6
+ the clipboard the same way as the toolbar export menu, so that the export can be started from a custom button
7
+ outside the grid; `options.onlySelectedRows` exports only the selected rows and `options.pageOrientation` sets the
8
+ PDF page orientation. `toolbar.hideExportButton` hides the built-in export menu button.
9
+ - `grid/export/contextMenu`: `runExport(exportType, props)` runs one export of the menu built by `getContextMenu`.
10
+ - `grid/export/contextMenu` / `DataGrid`: a failed export no longer leaves the grid exporting with the export menu
11
+ items disabled - `onExport(false)` is called also after a failure, and the progress notification is replaced by an
12
+ error one. For the PDF export `onExport(false)` comes once the file is saved, not when its generation starts. Clicks
13
+ on custom menu items no longer call `onExport`.
14
+ - `DataGrid` / `grid/export/contextMenu`: the CSV export starts with a UTF-8 BOM, so that Excel shows characters with
15
+ diacritics correctly instead of opening the file in the ANSI code page.
16
+
17
+ ## 23.0.60
18
+
19
+ - `ExtendedDataGrid`: `GridConfiguration.showUtcOffset` and `defaultShowUtcOffset` are no longer `true` by default -
20
+ without them the grid follows the global mode of `LocaleHolder.setUtcOffsetMode`. Pass `showUtcOffset: true` in
21
+ `defaultGridConfiguration` to keep the UTC offset in a grid.
22
+ - `ExtendedDataGrid`: `getGridDateTimeFormat(configuration)` returns the date-time format the grid's date-time columns
23
+ use (year, milliseconds and UTC offset of the table settings), for columns that format date-time values themselves.
24
+ - `DataGrid`: the `dateColumn`, `dateTimeColumn` and `fromNowDateTimeColumn` columns show a missing value and the D2000
25
+ null time as an empty cell (also in the copied and exported text) instead of `---`, `Null Time` or a date in 1972,
26
+ and the column filters and the quick filter no longer match the null time by its 1972 date. The time `0` is shown
27
+ as its date in 1970 in `dateTimeColumn` too, instead of an empty cell.
28
+ - `DataGrid`: Ctrl+Enter in a cell editor works like Enter instead of ag-grid's bulk edit, which wrote the value into
29
+ every cell of the selected rows.
30
+ - `DateTimeInput`: the D2000 null time is recognized (shown empty with the `Null Time` placeholder) also after
31
+ `setUnixTimeConversion(UnixTimeConversionEnum.FROM_MILIS)`, not only in the seconds mode.
32
+ - `DateTimeInput` / `DateRangeInput`: with a `Z` / `ZZ` mask the UTC offset no longer has to be typed - an empty or
33
+ mismatching offset is completed from the typed date and time (in the repeated hour of the daylight saving time to
34
+ the second one, as `B` of `HH?`), instead of leaving the value invalid until the exact offset is typed.
35
+ - `DurationInput`: no longer fails with `isDuration is not a function` in a Vite production build of an application,
36
+ when the component is loaded before the dayjs duration plugin of `d2core/dayjs` is applied.
37
+
38
+ ## 23.0.59
39
+
40
+ - `DataGrid` / `ExtendedDataGrid`: `toolbar.compact` for a narrow (mobile) screen - the export and table settings
41
+ buttons move into a popover opened by one button, the pager has only the previous, "page / pages" and next buttons,
42
+ and a pager that still does not fit moves to a line of its own under the toolbar.
43
+ - `DataGrid`: the toolbar line is aligned to the top, so the pager and the record range stay next to the toolbar
44
+ buttons when `toolbar.renderToolbar` adds content under them; `toolbar.extraContent` lower than a button is now at the
45
+ top of the line instead of in its middle.
46
+
47
+ ## 23.0.58
48
+
49
+ - `ModalDialog`: the maximize / restore button is shown only with `maximizable`, which is now `false` by default -
50
+ pass `maximizable` to keep the button in a dialog.
51
+ - `DataGrid` / `ExtendedDataGrid`: a column with ag-grid's `lockVisible` (also from `defaultColDef` or a column type)
52
+ can no longer be hidden or shown from the column menu ("Hide Column" is disabled), the columns configuration dialog
53
+ or the column tree of the table settings (the column is disabled there and left out when its whole group is moved
54
+ or checked). ag-grid applies `lockVisible` only to its own UI, which the grid does not use.
55
+ - `ColumnTransfer`: a column group in the tree (the `SIMPLE` layout and the hidden columns of the `FULL` layout) is
56
+ shown as fully checked only when all its columns are checked, including locked ones; otherwise it is half checked.
57
+ A click on a group checks its unlocked columns, or unchecks them when all of them are checked.
58
+
59
+ ## 23.0.57
60
+
61
+ - `DateTimeInput` / `DateRangeInput`: `autoWidth` measures the right width with a theme `fontFamily` that is not a
62
+ valid unquoted CSS name (e.g. `"72"`); the input was too narrow and cut the value.
63
+ - `DateRangeInput`: in the advanced popup the begin / both / end time shift icons sit below the duration buttons,
64
+ so that "Now", "Hour" and "15 min" of the three columns are in one row.
65
+ - `DataGrid` / `ExtendedDataGrid`: the `oddRowBackgroundColor` of a `theme` passed in is applied; rows without a
66
+ background color from `rowStyleRules` no longer get an inline `background-color: inherit` that overrode it. The
67
+ default theme keeps odd rows unstriped unless the new antd token `gridOddRowBg` is set (`ConfigProvider`
68
+ `theme={{token: {gridOddRowBg: "#fafafa"}}}`).
69
+ - `ModalDialog`: a dialog opened larger than the window is shrunk to the window minus the margin a maximized dialog
70
+ keeps, and centred, instead of filling the window edge to edge.
71
+ - `ModalDialog`: a dialog kept in the DOM (`destroyOnHidden={false}`) opens on top of the modals opened since its first
72
+ opening, instead of under them.
73
+ - `DataGrid` / `ExtendedDataGrid`: changing the table configuration (column order, width, sort, …) no longer makes
74
+ ag-grid log `Updated property onShowUtcOffset` in development - the time format props stay out of `AgGridReact`.
75
+ - `DataGrid`: `onLoadData`, `defaultRowStyleRules` and the time format props no longer reach `AgGridReact`, which
76
+ warned about them as invalid grid options.
77
+ - `DataGrid` / `ExtendedDataGrid`: `showUtcOffset` takes a `UtcOffsetMode` of `d2core/i18n/localeHolder` - besides
78
+ `true` / `false` also `"hourLetter"` (the repeated hour at the end of the daylight saving time as `A2:00` / `B2:00`)
79
+ and `"offsetInFold"` (the UTC offset only in that hour); the table settings offer all four. `DataGrid` without
80
+ `showUtcOffset` follows the global mode of `LocaleHolder.setUtcOffsetMode`.
81
+ - `DateTimeInput` / `DateRangeInput`: a mask with `HH?` shows and takes the repeated hour as `A2` / `B2` - an hour
82
+ typed there without the letter is the second one (`B`) and a letter outside that hour is invalid; a mask with `Z?`
83
+ shows the UTC offset at every time, so that the input keeps its layout.
84
+ - `DateTimeInput` / `DateRangeInput`: a time skipped at the start of the daylight saving time (29.03. 02:30) and a day
85
+ that does not exist (31.02.) are invalid with any mask, instead of being silently moved to another time; the input
86
+ no longer keeps showing such a typed text while it holds the moved value.
87
+
88
+ ## 23.0.56
89
+
90
+ - Components styled through `WithCss` (`DateTimeInput`, `DateRangeInput`, `DurationInput`, grid, pagination, …) take
91
+ the `componentSize` of an enclosing `ConfigProvider` when given no `size` and outside a `Space.Compact`, instead of
92
+ `middle` - the box no longer stays taller than the small inputs inside it.
93
+ - `DateTimeInput` / `DateRangeInput`: `autoWidth` measures the mask in the font of the resolved size, so a `large`
94
+ size taken from a `ConfigProvider` or a `Space.Compact` no longer cuts the value off.
95
+ - `WithCss`: the render function gets the resolved `size` and `variant` as its second argument.
96
+ - `DateRangeInputConfirm`: the Revert/Apply buttons are 48 px wide for a `small` size taken from a `ConfigProvider` or a
97
+ `Space.Compact` as well, not only for the `size` prop.
98
+ - `DateTimeInput`: the calendar icon is centred on the input even when a flex parent stretches the component.
99
+ - `DateRangeInput`: the inputs and the `⟷` separator of the advanced popup are vertically centred; `compact` and `ranges`
100
+ no longer reach the DOM as attributes.
101
+ - `DateRangeInput`: the inputs of the advanced popup are at least as wide as the mask, so the popup grows with a long
102
+ mask instead of cutting the values off; `autoWidth` inputs fill a root stretched by their parent.
103
+ - `DateRangeInput`: the three button columns of the advanced popup share the extra width of a popup widened by the
104
+ mask; the popup inputs are `small` like the rest of its controls.
105
+
106
+ ## 23.0.55
107
+
108
+ - `DateTimeInput`, `DateRangeInput`: optional `autoWidth` prop sizes the component to the rendered mask instead of
109
+ filling the parent.
110
+ - `DateRangeInput`: the separator between the two inputs is the antd `SwapRightOutlined` icon with the antd range
111
+ picker spacing instead of the `⟷` character.
112
+
113
+ ## 23.0.54
114
+
115
+ - `DataGrid` / `ExtendedDataGrid`: typed by the row data type. `DataGridProps<TData>` and
116
+ `ExtendedDataGridProps<TData>` pass it to the ag-grid `GridOptions` (`rowData`, `getRowId`, events, `gridRef`), and
117
+ `DataGrid<TData>` uses it for `gridApi` and `columnTypes`. Without an explicit type argument the type is inferred from
118
+ `rowData` and the handlers, so rows must have an `id` of type `number | string`, and handlers typed for another row
119
+ type no longer compile. The default type argument is `any`.
120
+ - `DataGrid` / `ExtendedDataGrid`: `columnDefs` may contain column groups (`DataGridColGroupDef`). The group is only a
121
+ header; its children are adapted like top-level columns (header menu, resizing, cell style, drag & drop in the grid
122
+ header) and the columns configuration dialog lists them by their own `group`. Reordering in the dialog does not
123
+ respect group boundaries.
124
+ - `DataGrid`: the fill-handle highlight uses the displayed column order, the same as the filled range.
125
+
126
+ ## 23.0.53
127
+
128
+ - `DateRangeInput`: time shift by month or year keeps an interval end that lies at the end of a month at the end of
129
+ the target month (30.09. 23:59:59.999 - 1 month = 31.08. 23:59:59.999, not 30.08.). Other values shift as before.
130
+ - The public API is documented with JSDoc and the published declaration files (`.d.ts`) keep the comments.
131
+ - The package ships `README.md` and `CHANGELOG.md`.
132
+
133
+ ## 23.0.52
134
+
135
+ - `ExtendedDataGrid`: optional `detailPanel.onVisibleChange(visible)` handler, called when the splitter collapses or
136
+ expands the detail panel (collapse arrow or dragging the divider).
137
+
138
+ ## 23.0.51
139
+
140
+ - pdfmake 0.2.23: `pdfmake/build/vfs_fonts` is a regular CommonJS module, vite applications need no workaround for
141
+ the PDF export worker anymore.
142
+ - `style/index.less` imports `antd/dist/reset.css` without the webpack-only `~` prefix.
143
+ - codemirror 5.65.20.
144
+ - Removed the unused `react-codemirror-runmode` dependency.
145
+ - The package no longer ships `tsconfig.json` and `tsconfig.build.json`.
146
+
147
+ ## 23.0.50
148
+
149
+ - Grid export workers are standard `new Worker(new URL(...))` entry points: a webpack application emitting its
150
+ chunks into a subdirectory needs `output.publicPath: "auto"`.
package/README.md CHANGED
@@ -103,7 +103,7 @@ All paths are relative to `d2coreui/components/`.
103
103
  | `grid/cell/tableDefaultRowStyleRules` | `RowStyleRule`, `GridRowStyle` and the default row style rules. |
104
104
  | `grid/config/*` | Table configuration UI: `DataGridEditor`, `ColumnTransfer`, `RowStylePicker`, row height helpers. |
105
105
  | `grid/filter/*` | Column filters and `WildcardQuickFilterEngine` (`*` / `?` quick filter). |
106
- | `grid/export/contextMenu` | `getContextMenu` - row context menu with export (CSV, TXT, PDF, clipboard). |
106
+ | `grid/export/contextMenu` | `getContextMenu` - row context menu with export (CSV, TXT, PDF, clipboard); `runExport` - one export started outside the menu. |
107
107
  | `grid/export/progressPopup` | Export progress notification. |
108
108
  | `grid/header/simpleHeader`, `grid/panel/*`, `grid/detail/*` | Header, pagination, overlay and detail panel components used by the grids. |
109
109
  | `grid/columnUtils` | `ColumnUtils.mergeColumnsState`. |
@@ -2,7 +2,7 @@ import React, { ReactElement } from "react";
2
2
  import { MenuProps } from "antd";
3
3
  import { AgGridReact } from "ag-grid-react";
4
4
  import 'd2coreui/style/ag-grid/aggrid-adaptations.css';
5
- import { ContextMenuProps, PageOrientation } from "d2coreui/components/grid/export/contextMenu";
5
+ import { ContextMenuProps, ExportType, PageOrientation } from "d2coreui/components/grid/export/contextMenu";
6
6
  import { CellClassParams, CellFocusedEvent, CellMouseDownEvent, CellMouseOverEvent, ColDef, ColTypeDef, ColGroupDef, Column, ColumnEvent, NewColumnsLoadedEvent, ColumnState, FilterChangedEvent, FilterModifiedEvent, GridApi, GridOptions, GridReadyEvent, IRowNode, PaginationChangedEvent, RowClassParams, RowPinnedType, RowStyle, ViewportChangedEvent } from "ag-grid-community";
7
7
  import { UtcOffsetMode } from "d2core/i18n/localeHolder";
8
8
  import { GridRowStyle, RowStyleRule } from "d2coreui/components/grid/cell/tableDefaultRowStyleRules";
@@ -255,6 +255,11 @@ export interface DataGridProps<TData = any> extends Omit<GridOptions<TData>, "co
255
255
  toolbarButtons?: ReactElement;
256
256
  /** Hides the "first-last of total" record range shown when paging is disabled (`pageSize` -1). */
257
257
  hideRecordCount?: boolean;
258
+ /**
259
+ * Hides the export menu button, e.g. when the export is started by a custom button through
260
+ * {@link DataGrid.exportData}. The row context menu keeps its export items.
261
+ */
262
+ hideExportButton?: boolean;
258
263
  /** Extra content rendered at the end of the toolbar, after the pager or record count. */
259
264
  extraContent?: React.ReactNode;
260
265
  /**
@@ -442,6 +447,11 @@ export default class DataGrid<TData extends {
442
447
  lastNavigationEvent?: NavigationEventEnum;
443
448
  /** Pagination event received before the grid API was available, replayed once the grid is ready. */
444
449
  lastPaginationEvent?: PaginationChangedEvent | null;
450
+ /**
451
+ * Whether an export is running; unlike `state.exporting` it is set synchronously, so two {@link exportData}
452
+ * calls in one tick do not both start an export.
453
+ */
454
+ private exportRunning;
445
455
  /**
446
456
  * Object passed to ag-grid as `context`; the grid's overlays, header and filter components read the overlay
447
457
  * renderers, `onFilterConfirmed`, `fontSize` and `lineHeight` from it.
@@ -598,6 +608,28 @@ export default class DataGrid<TData extends {
598
608
  private getCustomComponents;
599
609
  private onPageOrientationChange;
600
610
  private onExport;
611
+ /**
612
+ * Properties of an export menu or of {@link runExport}: the date-time format of the grid, its export content and
613
+ * export state, with `overrides` applied.
614
+ */
615
+ private getExportProps;
616
+ /**
617
+ * Exports the grid the same way as the toolbar export menu, for an export started from a custom button (hide the
618
+ * built-in one with `toolbar.hideExportButton`). Rows are exported with the displayed columns, filter and sort, and
619
+ * the date-time format of the grid; `exportMenu.onExported` is called after a successful export.
620
+ *
621
+ * Nothing is exported before the grid is ready, while it is loading or while another export is running.
622
+ *
623
+ * @param exportType file type, or `"clipboard"` to copy the rows to the clipboard
624
+ * @param options.onlySelectedRows export only the selected rows, as the row context menu does
625
+ * @param options.pageOrientation page orientation of the PDF export; defaults to the one last chosen in the export menu
626
+ * @returns resolved once the content is saved or copied, rejected when the export fails (an error notification is
627
+ * shown as well)
628
+ */
629
+ exportData(exportType: ExportType, options?: {
630
+ onlySelectedRows?: boolean;
631
+ pageOrientation?: PageOrientation;
632
+ }): Promise<void>;
601
633
  /** Renders the toolbar row: toolbar with search, pager (or record range when paging is disabled) and `toolbar.extraContent`. */
602
634
  renderNavigationPanel(): ReactElement;
603
635
  /**
@@ -21,7 +21,7 @@ import DataGridEditor from "d2coreui/components/grid/config/dataGridEditor";
21
21
  import i18n from "d2core/i18n/i18n";
22
22
  import AutoCompleteInput from "d2coreui/components/input/autoCompleteInput";
23
23
  import isEqual from "lodash/isEqual";
24
- import getContextMenu from "d2coreui/components/grid/export/contextMenu";
24
+ import getContextMenu, { runExport } from "d2coreui/components/grid/export/contextMenu";
25
25
  import LoadingOverlay from "d2coreui/components/grid/panel/loadingOverlay";
26
26
  import NoRecordsOverlay from "d2coreui/components/grid/panel/noRecordsOverlay";
27
27
  import at from "lodash/at";
@@ -153,6 +153,11 @@ class DataGrid extends React.Component {
153
153
  this.firstLoadDone = false;
154
154
  /** Pagination event received before the grid API was available, replayed once the grid is ready. */
155
155
  this.lastPaginationEvent = null;
156
+ /**
157
+ * Whether an export is running; unlike `state.exporting` it is set synchronously, so two {@link exportData}
158
+ * calls in one tick do not both start an export.
159
+ */
160
+ this.exportRunning = false;
156
161
  this.state = {
157
162
  pageIndex: 0,
158
163
  pageSize: null,
@@ -1687,8 +1692,40 @@ class DataGrid extends React.Component {
1687
1692
  this.setState({ pageOrientation: pageOrientation });
1688
1693
  }
1689
1694
  onExport(start) {
1695
+ this.exportRunning = start;
1690
1696
  this.setState({ exporting: start });
1691
1697
  }
1698
+ /**
1699
+ * Properties of an export menu or of {@link runExport}: the date-time format of the grid, its export content and
1700
+ * export state, with `overrides` applied.
1701
+ */
1702
+ getExportProps(overrides) {
1703
+ return Object.assign({ showMilliseconds: !!this.props.showMilliseconds, showYear: !this.props.hideYear, showUtcOffset: LocaleHolder.resolveUtcOffsetMode(this.props.showUtcOffset), getExportContent: this.getExportContent, pageOrientation: this.state.pageOrientation, exporting: this.state.exporting, onPageOrientationChange: this.onPageOrientationChange, onExport: this.onExport }, overrides);
1704
+ }
1705
+ /**
1706
+ * Exports the grid the same way as the toolbar export menu, for an export started from a custom button (hide the
1707
+ * built-in one with `toolbar.hideExportButton`). Rows are exported with the displayed columns, filter and sort, and
1708
+ * the date-time format of the grid; `exportMenu.onExported` is called after a successful export.
1709
+ *
1710
+ * Nothing is exported before the grid is ready, while it is loading or while another export is running.
1711
+ *
1712
+ * @param exportType file type, or `"clipboard"` to copy the rows to the clipboard
1713
+ * @param options.onlySelectedRows export only the selected rows, as the row context menu does
1714
+ * @param options.pageOrientation page orientation of the PDF export; defaults to the one last chosen in the export menu
1715
+ * @returns resolved once the content is saved or copied, rejected when the export fails (an error notification is
1716
+ * shown as well)
1717
+ */
1718
+ async exportData(exportType, options) {
1719
+ var _a, _b;
1720
+ if (!this.isActive() || this.state.loading || this.exportRunning) {
1721
+ return;
1722
+ }
1723
+ await runExport(exportType, this.getExportProps({
1724
+ onlySelectedNodes: options === null || options === void 0 ? void 0 : options.onlySelectedRows,
1725
+ onExported: (_a = this.props.exportMenu) === null || _a === void 0 ? void 0 : _a.onExported,
1726
+ pageOrientation: (_b = options === null || options === void 0 ? void 0 : options.pageOrientation) !== null && _b !== void 0 ? _b : this.state.pageOrientation,
1727
+ }));
1728
+ }
1692
1729
  /** Renders the toolbar row: toolbar with search, pager (or record range when paging is disabled) and `toolbar.extraContent`. */
1693
1730
  renderNavigationPanel() {
1694
1731
  var _a, _b, _c, _d;
@@ -1713,16 +1750,16 @@ class DataGrid extends React.Component {
1713
1750
  * With `toolbar.compact` the export and settings buttons move into a popover opened by one button.
1714
1751
  */
1715
1752
  renderToolBarWithSearch() {
1716
- var _a, _b, _c, _d;
1753
+ var _a, _b, _c, _d, _e;
1717
1754
  const compact = (_a = this.props.toolbar) === null || _a === void 0 ? void 0 : _a.compact;
1718
1755
  const search = this.props.search;
1719
1756
  return (React.createElement(Space.Compact, { key: "filter-panel", className: "datagrid-autocomplete-input-group", style: { whiteSpace: "nowrap", flexGrow: 1, display: "flex" } }, (_b = this.props.toolbar) === null || _b === void 0 ? void 0 :
1720
1757
  _b.toolbarButtons,
1721
1758
  compact ? this.renderCompactMenu() : React.createElement(React.Fragment, null,
1722
- this.renderExportButton(),
1759
+ !((_c = this.props.toolbar) === null || _c === void 0 ? void 0 : _c.hideExportButton) && this.renderExportButton(),
1723
1760
  this.renderSettingsButton()),
1724
- !(search === null || search === void 0 ? void 0 : search.hidden) && !(search === null || search === void 0 ? void 0 : search.searchRenderer) && React.createElement(AutoCompleteInput, { style: { minWidth: 100, flexGrow: 1 }, placeholder: search === null || search === void 0 ? void 0 : search.placeholder, stringFormatter: search === null || search === void 0 ? void 0 : search.stringFormatter, value: search === null || search === void 0 ? void 0 : search.searchString, options: search === null || search === void 0 ? void 0 : search.searchHistory, onChange: search === null || search === void 0 ? void 0 : search.onChange, onSearch: search === null || search === void 0 ? void 0 : search.onSearch, disabled: this.state.loading || ((_c = this.props.filter) === null || _c === void 0 ? void 0 : _c.columnSearchVisible) }), (_d = search === null || search === void 0 ? void 0 : search.searchRenderer) === null || _d === void 0 ? void 0 :
1725
- _d.call(search),
1761
+ !(search === null || search === void 0 ? void 0 : search.hidden) && !(search === null || search === void 0 ? void 0 : search.searchRenderer) && React.createElement(AutoCompleteInput, { style: { minWidth: 100, flexGrow: 1 }, placeholder: search === null || search === void 0 ? void 0 : search.placeholder, stringFormatter: search === null || search === void 0 ? void 0 : search.stringFormatter, value: search === null || search === void 0 ? void 0 : search.searchString, options: search === null || search === void 0 ? void 0 : search.searchHistory, onChange: search === null || search === void 0 ? void 0 : search.onChange, onSearch: search === null || search === void 0 ? void 0 : search.onSearch, disabled: this.state.loading || ((_d = this.props.filter) === null || _d === void 0 ? void 0 : _d.columnSearchVisible) }), (_e = search === null || search === void 0 ? void 0 : search.searchRenderer) === null || _e === void 0 ? void 0 :
1762
+ _e.call(search),
1726
1763
  !(search === null || search === void 0 ? void 0 : search.searchButtonHidden) && this.renderSearchButton()));
1727
1764
  }
1728
1765
  /**
@@ -1733,27 +1770,22 @@ class DataGrid extends React.Component {
1733
1770
  const close = () => this.setState({ compactMenuOpen: false });
1734
1771
  return (React.createElement(Popover, { open: this.state.compactMenuOpen, onOpenChange: open => this.setState({ compactMenuOpen: open }), trigger: "click", placement: "bottomLeft",
1735
1772
  // the menus are built only while the popover is open - the grid renders often, e.g. while scrolling
1736
- destroyOnHidden: true, content: React.createElement(RenderLater, null, () => React.createElement(Space.Compact, null,
1737
- this.renderExportButton(close),
1738
- this.renderSettingsButton(close))) },
1773
+ destroyOnHidden: true, content: React.createElement(RenderLater, null, () => {
1774
+ var _a;
1775
+ return React.createElement(Space.Compact, null,
1776
+ !((_a = this.props.toolbar) === null || _a === void 0 ? void 0 : _a.hideExportButton) && this.renderExportButton(close),
1777
+ this.renderSettingsButton(close));
1778
+ }) },
1739
1779
  React.createElement(Button, { title: i18n("Extended table features") }, this.state.loading ? React.createElement(LoadingOutlined, null) : React.createElement(EllipsisOutlined, null))));
1740
1780
  }
1741
1781
  /** Export button with the export menu; `onUsed` is called after a menu item is clicked. */
1742
1782
  renderExportButton(onUsed) {
1743
1783
  var _a, _b, _c;
1744
- const exportMenu = getContextMenu({
1745
- showMilliseconds: !!this.props.showMilliseconds,
1746
- showYear: !this.props.hideYear,
1747
- showUtcOffset: LocaleHolder.resolveUtcOffsetMode(this.props.showUtcOffset),
1784
+ const exportMenu = getContextMenu(this.getExportProps({
1748
1785
  renderer: (_a = this.props.exportMenu) === null || _a === void 0 ? void 0 : _a.renderer,
1749
1786
  onClick: (_b = this.props.exportMenu) === null || _b === void 0 ? void 0 : _b.onClick,
1750
1787
  onExported: (_c = this.props.exportMenu) === null || _c === void 0 ? void 0 : _c.onExported,
1751
- getExportContent: this.getExportContent,
1752
- pageOrientation: this.state.pageOrientation,
1753
- exporting: this.state.exporting,
1754
- onPageOrientationChange: this.onPageOrientationChange,
1755
- onExport: this.onExport
1756
- });
1788
+ }));
1757
1789
  return (React.createElement(Dropdown, { trigger: ["click"], menu: withOnUsed(exportMenu, onUsed), disabled: this.state.loading },
1758
1790
  React.createElement(Button, { title: i18n("Export") },
1759
1791
  React.createElement(DownloadOutlined, null))));
@@ -1945,20 +1977,12 @@ class DataGrid extends React.Component {
1945
1977
  // very nasty trick how remove error of ResizeObservers infinite cycling - because popover (with dynamic size) is placed in in resizable panel
1946
1978
  const parentNode = ((_a = triggerNode === null || triggerNode === void 0 ? void 0 : triggerNode.parentNode) !== null && _a !== void 0 ? _a : document.body);
1947
1979
  return parentNode;
1948
- }, menu: getContextMenu({
1980
+ }, menu: getContextMenu(this.getExportProps({
1949
1981
  onlySelectedNodes: true,
1950
- showMilliseconds: !!this.props.showMilliseconds,
1951
- showYear: !this.props.hideYear,
1952
- showUtcOffset: LocaleHolder.resolveUtcOffsetMode(this.props.showUtcOffset),
1953
1982
  renderer: (_a = this.props.contextMenu) === null || _a === void 0 ? void 0 : _a.renderer,
1954
1983
  onClick: (_b = this.props.contextMenu) === null || _b === void 0 ? void 0 : _b.onClick,
1955
- getExportContent: this.getExportContent,
1956
1984
  hideNotificationOnClipboardCopy: true,
1957
- pageOrientation: this.state.pageOrientation,
1958
- exporting: this.state.exporting,
1959
- onPageOrientationChange: this.onPageOrientationChange,
1960
- onExport: this.onExport
1961
- }), open: this.state.contextMenuVisible, onOpenChange: (visible) => {
1985
+ })), open: this.state.contextMenuVisible, onOpenChange: (visible) => {
1962
1986
  if (!visible) {
1963
1987
  this.setState({ contextMenuVisible: false });
1964
1988
  }