d2coreui 23.0.61 → 26.1.0

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,21 +1,13 @@
1
1
  # Changelog
2
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
3
+ ## 26.1.0
18
4
 
5
+ - `DataGrid` / `ExtendedDataGrid`: `toolbar.compact` for a narrow (mobile) screen - the export and table settings
6
+ buttons move into a popover opened by one button, the pager has only the previous, "page / pages" and next buttons,
7
+ and a pager that still does not fit moves to a line of its own under the toolbar.
8
+ - `DataGrid`: the toolbar line is aligned to the top, so the pager and the record range stay next to the toolbar
9
+ buttons when `toolbar.renderToolbar` adds content under them; `toolbar.extraContent` lower than a button is now at the
10
+ top of the line instead of in its middle.
19
11
  - `ExtendedDataGrid`: `GridConfiguration.showUtcOffset` and `defaultShowUtcOffset` are no longer `true` by default -
20
12
  without them the grid follows the global mode of `LocaleHolder.setUtcOffsetMode`. Pass `showUtcOffset: true` in
21
13
  `defaultGridConfiguration` to keep the UTC offset in a grid.
@@ -34,15 +26,20 @@
34
26
  the second one, as `B` of `HH?`), instead of leaving the value invalid until the exact offset is typed.
35
27
  - `DurationInput`: no longer fails with `isDuration is not a function` in a Vite production build of an application,
36
28
  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.
29
+ - `DataGrid` / `ExtendedDataGrid`: `exportData(exportType, options)` exports the grid to a TXT, CSV or PDF file or to
30
+ the clipboard the same way as the toolbar export menu, so that the export can be started from a custom button
31
+ outside the grid; `options.onlySelectedRows` exports only the selected rows and `options.pageOrientation` sets the
32
+ PDF page orientation. `toolbar.hideExportButton` hides the built-in export menu button.
33
+ - `grid/export/contextMenu`: `runExport(exportType, props)` runs one export of the menu built by `getContextMenu`.
34
+ - `grid/export/contextMenu` / `DataGrid`: a failed export no longer leaves the grid exporting with the export menu
35
+ items disabled - `onExport(false)` is called also after a failure, and the progress notification is replaced by an
36
+ error one. For the PDF export `onExport(false)` comes once the file is saved, not when its generation starts. Clicks
37
+ on custom menu items no longer call `onExport`.
38
+ - `DataGrid` / `grid/export/contextMenu`: the CSV export starts with a UTF-8 BOM, so that Excel shows characters with
39
+ diacritics correctly instead of opening the file in the ANSI code page.
40
+ - `DataGrid`: the `numberColumn` type takes also `cellRendererParams.minFractionDigits` (capped at `fractionDigits`)
41
+ and `omitGrouping`, in the cells, the export and the filters. `minFractionDigits` needs `d2core` 23.0.22 or newer -
42
+ with an older one, columns of the same `fractionDigits` share the minimum of the first one rendered.
46
43
 
47
44
  ## 23.0.58
48
45
 
@@ -70,8 +70,10 @@ export type FilterRenderer = (value: string, changeValue: (newValue: string) =>
70
70
  * search is visible, and takes `hide` from the current column state when the column is already known.
71
71
  * ag-grid's `lockVisible` is honoured by the grid's own column menu and columns configuration dialog.
72
72
  *
73
- * Besides ag-grid's own, these values can be used in `type`: `numberColumn` (localized number, fraction digits from
74
- * `cellRendererParams.fractionDigits`), `dateColumn`, `dateTimeColumn`, `fromNowDateTimeColumn` (D2000 unix time values,
73
+ * Besides ag-grid's own, these values can be used in `type`: `numberColumn` (localized number - in the cells, the export
74
+ * and the filters - with the maximum of fraction digits from `cellRendererParams.fractionDigits`, the minimum (capped
75
+ * at the maximum) from `cellRendererParams.minFractionDigits` and without grouping separators by
76
+ * `cellRendererParams.omitGrouping`), `dateColumn`, `dateTimeColumn`, `fromNowDateTimeColumn` (D2000 unix time values,
75
77
  * formatted according to `hideYear`/`showMilliseconds`/`showUtcOffset`), `localizedArrayColumn` (array of i18n keys),
76
78
  * `escapedValueColumn` (line breaks shown as spaces), `alignRight`, and the filter types `textColumnFilter`
77
79
  * (client-side text filter), `textColumnServerFilter` and `customColumnServerFilter` (filter applied explicitly, the latter
@@ -459,6 +461,7 @@ export default class DataGrid<TData extends {
459
461
  table_context: any;
460
462
  private readonly getTheme;
461
463
  constructor(props: Readonly<DataGridProps<TData>>);
464
+ private static formatNumberCell;
462
465
  private static getTimeCellValue;
463
466
  private static getCellValue;
464
467
  /**
@@ -254,20 +254,18 @@ class DataGrid extends React.Component {
254
254
  },
255
255
  "numberColumn": {
256
256
  cellRenderer: (params) => {
257
- var _a, _b;
258
257
  const value = DataGrid.getCellValue(params);
259
258
  if (value !== undefined && value !== null) {
260
- return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
259
+ return DataGrid.formatNumberCell(value, params.colDef);
261
260
  }
262
261
  else {
263
262
  return "";
264
263
  }
265
264
  },
266
265
  valueFormatter: (params) => {
267
- var _a, _b;
268
266
  const value = DataGrid.getCellValue(params);
269
267
  if (value !== undefined && value !== null) {
270
- return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
268
+ return DataGrid.formatNumberCell(value, params.colDef);
271
269
  }
272
270
  else {
273
271
  return "";
@@ -277,20 +275,18 @@ class DataGrid extends React.Component {
277
275
  textCustomComparator: this.textCustomComparator
278
276
  },
279
277
  filterValueGetter: function (params) {
280
- var _a, _b;
281
278
  const value = DataGrid.getCellValue(params);
282
279
  if (value) {
283
- return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
280
+ return DataGrid.formatNumberCell(value, params.colDef);
284
281
  }
285
282
  else {
286
283
  return "";
287
284
  }
288
285
  },
289
286
  getQuickFilterText: function (params) {
290
- var _a, _b;
291
287
  const value = DataGrid.getCellValue(params);
292
288
  if (value !== undefined) {
293
- return LocaleHolder.formatNumber(value, (_b = (_a = params.colDef) === null || _a === void 0 ? void 0 : _a.cellRendererParams) === null || _b === void 0 ? void 0 : _b.fractionDigits);
289
+ return DataGrid.formatNumberCell(value, params.colDef);
294
290
  }
295
291
  else {
296
292
  return "";
@@ -462,6 +458,13 @@ class DataGrid extends React.Component {
462
458
  "alignRight": {}
463
459
  };
464
460
  }
461
+ static formatNumberCell(value, colDef) {
462
+ var _a;
463
+ const { fractionDigits, minFractionDigits, omitGrouping } = (_a = colDef === null || colDef === void 0 ? void 0 : colDef.cellRendererParams) !== null && _a !== void 0 ? _a : {};
464
+ // Intl throws a RangeError when the minimum exceeds the maximum
465
+ const minimum = fractionDigits !== undefined && minFractionDigits !== undefined ? Math.min(minFractionDigits, fractionDigits) : minFractionDigits;
466
+ return LocaleHolder.getNumberFormatter(fractionDigits, omitGrouping, minimum).format(value);
467
+ }
465
468
  static getTimeCellValue(props) {
466
469
  const value = DataGrid.getCellValue(props);
467
470
  return value === undefined || value === null || value === D2000UnixTimeNullValue ? undefined : value;