@economic/taco 17.0.0-EC-00123-table3-bundle.1 → 17.0.0-alpha-rules.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/dist/charts/components/types.d.ts +1 -1
- package/dist/charts/components/useChartData.cjs +1 -2
- package/dist/charts/components/useChartData.js +1 -2
- package/dist/components/Datepicker/useDatepicker.cjs +3 -3
- package/dist/components/Datepicker/useDatepicker.js +3 -3
- package/dist/components/Provider/Localization.cjs +2 -18
- package/dist/components/Provider/Localization.d.ts +7 -14
- package/dist/components/Provider/Localization.js +2 -18
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.cjs +17 -16
- package/dist/components/Table3/components/Columns/Cell/EditingControlCell.js +18 -17
- package/dist/index.cjs +0 -4
- package/dist/index.js +1 -5
- package/dist/primitives/Table/Core/components/Body/Body.cjs +1 -1
- package/dist/primitives/Table/Core/components/Body/Body.js +1 -1
- package/dist/primitives/Table/Core/components/Footer/Summary.cjs +4 -6
- package/dist/primitives/Table/Core/components/Footer/Summary.js +4 -6
- package/dist/primitives/Table/Core/components/Header/Header.cjs +3 -7
- package/dist/primitives/Table/Core/components/Header/Header.d.ts +2 -4
- package/dist/primitives/Table/Core/components/Header/Header.js +4 -8
- package/dist/primitives/Table/Core/components/Header/components/Resizer.cjs +3 -11
- package/dist/primitives/Table/Core/components/Header/components/Resizer.d.ts +4 -6
- package/dist/primitives/Table/Core/components/Header/components/Resizer.js +3 -11
- package/dist/primitives/Table/Core/components/Header/util.d.ts +2 -3
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.cjs +4 -7
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +4 -7
- package/dist/primitives/Table/Core/features/useTableRenderer.cjs +0 -10
- package/dist/primitives/Table/Core/features/useTableRenderer.js +0 -10
- package/dist/primitives/Table/Core/features/useTableStyleGrid.cjs +2 -7
- package/dist/primitives/Table/Core/features/useTableStyleGrid.js +3 -8
- package/dist/primitives/Table/types.d.ts +2 -5
- package/dist/primitives/Table/useTableManager/listeners/useTableFontSizeListener.cjs +0 -3
- package/dist/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js +0 -3
- package/dist/primitives/Table/useTableManager/useTableManager.cjs +0 -3
- package/dist/primitives/Table/useTableManager/useTableManager.d.ts +2 -4
- package/dist/primitives/Table/useTableManager/useTableManager.js +0 -3
- package/dist/primitives/Table/useTableManager/util/columns.cjs +0 -8
- package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -5
- package/dist/primitives/Table/useTableManager/util/columns.js +0 -8
- package/dist/primitives/Table/useTableManager/util/dataTypes.cjs +10 -29
- package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +2 -5
- package/dist/primitives/Table/useTableManager/util/dataTypes.js +12 -31
- package/dist/primitives/Table/useTableManager/util/filtering.cjs +1 -1
- package/dist/primitives/Table/useTableManager/util/filtering.js +2 -2
- package/dist/primitives/Table/useTableManager/util/rows.cjs +2 -10
- package/dist/primitives/Table/useTableManager/util/rows.d.ts +4 -1
- package/dist/primitives/Table/useTableManager/util/rows.js +2 -10
- package/dist/primitives/Table/useTableManager/util/search.cjs +1 -1
- package/dist/primitives/Table/useTableManager/util/search.js +1 -1
- package/dist/primitives/Table/useTableManager/util/settings.cjs +1 -1
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +3 -4
- package/dist/primitives/Table/useTableManager/util/settings.js +1 -1
- package/dist/primitives/Table/useTableManager/util/setup.cjs +0 -1
- package/dist/primitives/Table/useTableManager/util/setup.d.ts +4 -4
- package/dist/primitives/Table/useTableManager/util/setup.js +0 -1
- package/dist/utils/dataTypes.cjs +34 -84
- package/dist/utils/dataTypes.d.ts +4 -28
- package/dist/utils/dataTypes.js +22 -72
- package/dist/utils/date.cjs +4 -47
- package/dist/utils/date.d.ts +0 -5
- package/dist/utils/date.js +4 -47
- package/package.json +4 -4
- package/dist/components/Table3/components/Columns/Cell/Editing/NumberInput.cjs +0 -39
- package/dist/components/Table3/components/Columns/Cell/Editing/NumberInput.d.ts +0 -10
- package/dist/components/Table3/components/Columns/Cell/Editing/NumberInput.js +0 -39
- package/dist/primitives/Table/useTableManager/features/useTableColumnSizing.cjs +0 -32
- package/dist/primitives/Table/useTableManager/features/useTableColumnSizing.d.ts +0 -5
- package/dist/primitives/Table/useTableManager/features/useTableColumnSizing.js +0 -32
|
@@ -3,7 +3,7 @@ import React__default from "react";
|
|
|
3
3
|
import { useLocalization } from "../../../../../../components/Provider/Localization.js";
|
|
4
4
|
import { Tooltip } from "../../../../../../components/Tooltip/Tooltip.js";
|
|
5
5
|
function Resizer(props) {
|
|
6
|
-
const {
|
|
6
|
+
const { headerRef, id, isResizing, onResetSize, onResize, setColumnSizing, width } = props;
|
|
7
7
|
const { texts } = useLocalization();
|
|
8
8
|
const handleClick = (event) => {
|
|
9
9
|
event.stopPropagation();
|
|
@@ -11,16 +11,8 @@ function Resizer(props) {
|
|
|
11
11
|
};
|
|
12
12
|
const handleResize = (event) => {
|
|
13
13
|
if (event.detail >= 2) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
onResetSize?.();
|
|
17
|
-
} else {
|
|
18
|
-
setColumnSizing((sizes) => ({ ...sizes, [id]: defaultWidth }));
|
|
19
|
-
}
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
setColumnResized(id, true);
|
|
23
|
-
if (!Number.isInteger(width) && headerRef) {
|
|
14
|
+
onResetSize();
|
|
15
|
+
} else if (!Number.isInteger(width) && headerRef) {
|
|
24
16
|
setColumnSizing((sizes) => ({
|
|
25
17
|
...sizes,
|
|
26
18
|
[id]: headerRef.getBoundingClientRect().width
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Header as ReactTableHeader, ColumnPinningPosition as ReactTableColumnPinningPosition } from '@tanstack/react-table';
|
|
1
|
+
import { Header as ReactTableHeader, ColumnPinningPosition as ReactTableColumnPinningPosition, Updater, ColumnSizingState } from '@tanstack/react-table';
|
|
2
2
|
import { TableColumnWidth } from '../../../types';
|
|
3
|
-
|
|
4
|
-
export declare function useSetInitialColumnSizing(id: string, defaultWidth: TableColumnWidth | undefined, width: TableColumnWidth | undefined, element: HTMLTableCellElement | null, canMeasureSize: boolean, setColumnSizing: TableColumnSizingSetter): void;
|
|
3
|
+
export declare function useSetInitialColumnSizing(id: string, defaultWidth: TableColumnWidth | undefined, width: TableColumnWidth | undefined, element: HTMLTableCellElement | null, canMeasureSize: boolean, setColumnSizing: (updater: Updater<ColumnSizingState>) => void): void;
|
|
5
4
|
export declare function getIsPinned<TType = unknown>(header: ReactTableHeader<TType, unknown>): ReactTableColumnPinningPosition | undefined;
|
package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const dataTypes = require("../../../../../../../utils/dataTypes.cjs");
|
|
5
4
|
const types = require("../../../../../types.cjs");
|
|
6
5
|
const columns = require("../../../../../useTableManager/util/columns.cjs");
|
|
7
6
|
const rows = require("../../../../../useTableManager/util/rows.cjs");
|
|
@@ -15,8 +14,7 @@ const Inline = require("../../../../../../../components/Inline/Inline.cjs");
|
|
|
15
14
|
const placeholderFilter = { id: "", value: { comparator: types.TableFilterComparator.Contains, value: void 0 } };
|
|
16
15
|
function ManageFiltersPopover(props) {
|
|
17
16
|
const { length, table, ...popoverProps } = props;
|
|
18
|
-
const
|
|
19
|
-
const { texts } = localization;
|
|
17
|
+
const { locale, texts } = Localization.useLocalization();
|
|
20
18
|
const allColumns = table.getAllLeafColumns().filter((column) => !columns.isInternalColumn(column.id)).sort(util.sortByHeader);
|
|
21
19
|
const columnFilters = table.getState().columnFilters;
|
|
22
20
|
const tableMeta = rows.getTableMeta(table);
|
|
@@ -78,12 +76,11 @@ function ManageFiltersPopover(props) {
|
|
|
78
76
|
};
|
|
79
77
|
return /* @__PURE__ */ React.createElement(Popover.Popover, { ...popoverProps, onChange: handleClose }, /* @__PURE__ */ React.createElement(Popover.Popover.Content, null, /* @__PURE__ */ React.createElement(FilterContext.FilterContext.Provider, { value: filters }, /* @__PURE__ */ React.createElement("div", { className: "flex w-[40rem] flex-col gap-4" }, /* @__PURE__ */ React.createElement("div", { className: "flex h-8" }, /* @__PURE__ */ React.createElement("div", { className: "flex w-full items-center gap-2" }, /* @__PURE__ */ React.createElement("h4", { className: "mb-0 inline-flex" }, texts.table.filters.button), /* @__PURE__ */ React.createElement("p", { className: "mb-0 mr-auto mt-px inline-flex text-gray-700" }, texts.table.filters.total.replace(
|
|
80
78
|
"[CURRENT]",
|
|
81
|
-
|
|
79
|
+
new Intl.NumberFormat(locale).format(
|
|
82
80
|
// dataloader2 doesn't fill in the data array with undefined like the standard dataloader, so we need to show the full length.
|
|
83
|
-
tableMeta.server._experimentalDataLoader2 ? length : table.getFilteredRowModel().rows.length
|
|
84
|
-
localization
|
|
81
|
+
tableMeta.server._experimentalDataLoader2 ? length : table.getFilteredRowModel().rows.length
|
|
85
82
|
)
|
|
86
|
-
).replace("[TOTAL]",
|
|
83
|
+
).replace("[TOTAL]", new Intl.NumberFormat(locale).format(length))))), /* @__PURE__ */ React.createElement("div", { className: "flex flex-col gap-2" }, filters.map((filter, index) => /* @__PURE__ */ React.createElement(
|
|
87
84
|
Filter.Filter,
|
|
88
85
|
{
|
|
89
86
|
key: `filter_${index}`,
|
package/dist/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { formatNumber } from "../../../../../../../utils/dataTypes.js";
|
|
3
2
|
import { TableFilterComparator } from "../../../../../types.js";
|
|
4
3
|
import { isInternalColumn } from "../../../../../useTableManager/util/columns.js";
|
|
5
4
|
import { getTableMeta } from "../../../../../useTableManager/util/rows.js";
|
|
@@ -13,8 +12,7 @@ import { Inline } from "../../../../../../../components/Inline/Inline.js";
|
|
|
13
12
|
const placeholderFilter = { id: "", value: { comparator: TableFilterComparator.Contains, value: void 0 } };
|
|
14
13
|
function ManageFiltersPopover(props) {
|
|
15
14
|
const { length, table, ...popoverProps } = props;
|
|
16
|
-
const
|
|
17
|
-
const { texts } = localization;
|
|
15
|
+
const { locale, texts } = useLocalization();
|
|
18
16
|
const allColumns = table.getAllLeafColumns().filter((column) => !isInternalColumn(column.id)).sort(sortByHeader);
|
|
19
17
|
const columnFilters = table.getState().columnFilters;
|
|
20
18
|
const tableMeta = getTableMeta(table);
|
|
@@ -76,12 +74,11 @@ function ManageFiltersPopover(props) {
|
|
|
76
74
|
};
|
|
77
75
|
return /* @__PURE__ */ React__default.createElement(Popover, { ...popoverProps, onChange: handleClose }, /* @__PURE__ */ React__default.createElement(Popover.Content, null, /* @__PURE__ */ React__default.createElement(FilterContext.Provider, { value: filters }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-[40rem] flex-col gap-4" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex h-8" }, /* @__PURE__ */ React__default.createElement("div", { className: "flex w-full items-center gap-2" }, /* @__PURE__ */ React__default.createElement("h4", { className: "mb-0 inline-flex" }, texts.table.filters.button), /* @__PURE__ */ React__default.createElement("p", { className: "mb-0 mr-auto mt-px inline-flex text-gray-700" }, texts.table.filters.total.replace(
|
|
78
76
|
"[CURRENT]",
|
|
79
|
-
|
|
77
|
+
new Intl.NumberFormat(locale).format(
|
|
80
78
|
// dataloader2 doesn't fill in the data array with undefined like the standard dataloader, so we need to show the full length.
|
|
81
|
-
tableMeta.server._experimentalDataLoader2 ? length : table.getFilteredRowModel().rows.length
|
|
82
|
-
localization
|
|
79
|
+
tableMeta.server._experimentalDataLoader2 ? length : table.getFilteredRowModel().rows.length
|
|
83
80
|
)
|
|
84
|
-
).replace("[TOTAL]",
|
|
81
|
+
).replace("[TOTAL]", new Intl.NumberFormat(locale).format(length))))), /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col gap-2" }, filters.map((filter, index) => /* @__PURE__ */ React__default.createElement(
|
|
85
82
|
Filter,
|
|
86
83
|
{
|
|
87
84
|
key: `filter_${index}`,
|
|
@@ -4,7 +4,6 @@ const reactVirtual = require("@tanstack/react-virtual");
|
|
|
4
4
|
const sortBy = require("lodash/sortBy");
|
|
5
5
|
const without = require("lodash/without");
|
|
6
6
|
const React = require("react");
|
|
7
|
-
const usePrevious = require("../../../../hooks/usePrevious.cjs");
|
|
8
7
|
const rows = require("../../useTableManager/util/rows.cjs");
|
|
9
8
|
const SkeletonRow = require("../components/Row/BuiltIns/SkeletonRow.cjs");
|
|
10
9
|
const Row = require("../components/Row/Row.cjs");
|
|
@@ -78,15 +77,6 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
|
|
|
78
77
|
},
|
|
79
78
|
[virtualItems.length, tableRef.current, totalSize, count]
|
|
80
79
|
);
|
|
81
|
-
const isLastRowLoaded = isServerDataLoader2 ? !!tableMeta.server.pages?.includes(tableMeta.server.pageCount - 1) : !!rows$2.at(-1)?.original;
|
|
82
|
-
const previousCount = usePrevious.usePreviousValue(count);
|
|
83
|
-
const wasLastRowLoaded = usePrevious.usePreviousValue(isLastRowLoaded);
|
|
84
|
-
React.useEffect(() => {
|
|
85
|
-
if (count > 0 && tableMeta.rowActive.rowActiveIndex === previousCount - 1 && !wasLastRowLoaded) {
|
|
86
|
-
tableMeta.rowActive.setRowActiveIndex(count - 1);
|
|
87
|
-
scrollToIndex(count - 1);
|
|
88
|
-
}
|
|
89
|
-
}, [count]);
|
|
90
80
|
const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;
|
|
91
81
|
const startValue = isTableRowGrouped ? (virtualItems[paddingStartIndex]?.start ?? 0) - (virtualItems[paddingStartIndex]?.size ?? 0) : virtualItems[paddingStartIndex]?.start;
|
|
92
82
|
const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems.at(-1)?.end ?? 0))] : [0, 0];
|
|
@@ -2,7 +2,6 @@ import { useVirtualizer, defaultRangeExtractor } from "@tanstack/react-virtual";
|
|
|
2
2
|
import sortBy from "lodash/sortBy";
|
|
3
3
|
import without from "lodash/without";
|
|
4
4
|
import React__default from "react";
|
|
5
|
-
import { usePreviousValue } from "../../../../hooks/usePrevious.js";
|
|
6
5
|
import { getTableMeta } from "../../useTableManager/util/rows.js";
|
|
7
6
|
import { SkeletonRow } from "../components/Row/BuiltIns/SkeletonRow.js";
|
|
8
7
|
import { Row } from "../components/Row/Row.js";
|
|
@@ -76,15 +75,6 @@ function useTableRenderer(renderers, table, tableRef, length, defaultRowActiveIn
|
|
|
76
75
|
},
|
|
77
76
|
[virtualItems.length, tableRef.current, totalSize, count]
|
|
78
77
|
);
|
|
79
|
-
const isLastRowLoaded = isServerDataLoader2 ? !!tableMeta.server.pages?.includes(tableMeta.server.pageCount - 1) : !!rows.at(-1)?.original;
|
|
80
|
-
const previousCount = usePreviousValue(count);
|
|
81
|
-
const wasLastRowLoaded = usePreviousValue(isLastRowLoaded);
|
|
82
|
-
React__default.useEffect(() => {
|
|
83
|
-
if (count > 0 && tableMeta.rowActive.rowActiveIndex === previousCount - 1 && !wasLastRowLoaded) {
|
|
84
|
-
tableMeta.rowActive.setRowActiveIndex(count - 1);
|
|
85
|
-
scrollToIndex(count - 1);
|
|
86
|
-
}
|
|
87
|
-
}, [count]);
|
|
88
78
|
const paddingStartIndex = isTableRowGrouped && count > 1 ? 1 : 0;
|
|
89
79
|
const startValue = isTableRowGrouped ? (virtualItems[paddingStartIndex]?.start ?? 0) - (virtualItems[paddingStartIndex]?.size ?? 0) : virtualItems[paddingStartIndex]?.start;
|
|
90
80
|
const [paddingTop, paddingBottom] = virtualItems.length > 0 ? [Math.max(0, startValue ?? 0), Math.max(0, totalSize - (virtualItems.at(-1)?.end ?? 0))] : [0, 0];
|
|
@@ -12,17 +12,12 @@ function useTableStyleGrid(tableId, table, fontSize) {
|
|
|
12
12
|
return React.useMemo(() => {
|
|
13
13
|
let printGridTemplateColumns = 0;
|
|
14
14
|
const printHiddenColumns = [];
|
|
15
|
-
const hasGrowingColumn = allVisibleColumns.some((column, index) => {
|
|
16
|
-
const width = columns.getColumnWidth(columnSizing, column.id);
|
|
17
|
-
return !columns.isInternalColumn(column.id) && // grouped columns are skipped below, so they never render a track to grow
|
|
18
|
-
!(table.options.enableGrouping && column.getIsGrouped()) && (width === "grow" || Number.isNaN(width)) && index !== allVisibleColumns.length - 1;
|
|
19
|
-
});
|
|
20
15
|
const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
|
|
21
16
|
if (table.options.enableGrouping && column.getIsGrouped()) {
|
|
22
17
|
return accum;
|
|
23
18
|
}
|
|
24
19
|
const minSize = column.columnDef.minSize ?? globalMinSize;
|
|
25
|
-
const width =
|
|
20
|
+
const width = columnSizing[column.id];
|
|
26
21
|
let size;
|
|
27
22
|
if (columns.isInternalColumn(column.id)) {
|
|
28
23
|
if (column.id === "__actions") {
|
|
@@ -37,7 +32,7 @@ function useTableStyleGrid(tableId, table, fontSize) {
|
|
|
37
32
|
size = "minmax(max-content, 1fr)";
|
|
38
33
|
} else {
|
|
39
34
|
const minWidth = width < minSize ? minSize : width;
|
|
40
|
-
if (isLastColumn
|
|
35
|
+
if (isLastColumn) {
|
|
41
36
|
size = `minmax(${minWidth}px, auto)`;
|
|
42
37
|
} else {
|
|
43
38
|
size = `${minWidth}px`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { isInternalColumn, CELL_MIN_WIDTH } from "../../useTableManager/util/columns.js";
|
|
3
3
|
import { getTableMeta } from "../../useTableManager/util/rows.js";
|
|
4
4
|
function useTableStyleGrid(tableId, table, fontSize) {
|
|
5
5
|
const tableMeta = getTableMeta(table);
|
|
@@ -10,17 +10,12 @@ function useTableStyleGrid(tableId, table, fontSize) {
|
|
|
10
10
|
return React__default.useMemo(() => {
|
|
11
11
|
let printGridTemplateColumns = 0;
|
|
12
12
|
const printHiddenColumns = [];
|
|
13
|
-
const hasGrowingColumn = allVisibleColumns.some((column, index) => {
|
|
14
|
-
const width = getColumnWidth(columnSizing, column.id);
|
|
15
|
-
return !isInternalColumn(column.id) && // grouped columns are skipped below, so they never render a track to grow
|
|
16
|
-
!(table.options.enableGrouping && column.getIsGrouped()) && (width === "grow" || Number.isNaN(width)) && index !== allVisibleColumns.length - 1;
|
|
17
|
-
});
|
|
18
13
|
const gridTemplateColumns = allVisibleColumns.reduce((accum, column, index) => {
|
|
19
14
|
if (table.options.enableGrouping && column.getIsGrouped()) {
|
|
20
15
|
return accum;
|
|
21
16
|
}
|
|
22
17
|
const minSize = column.columnDef.minSize ?? globalMinSize;
|
|
23
|
-
const width =
|
|
18
|
+
const width = columnSizing[column.id];
|
|
24
19
|
let size;
|
|
25
20
|
if (isInternalColumn(column.id)) {
|
|
26
21
|
if (column.id === "__actions") {
|
|
@@ -35,7 +30,7 @@ function useTableStyleGrid(tableId, table, fontSize) {
|
|
|
35
30
|
size = "minmax(max-content, 1fr)";
|
|
36
31
|
} else {
|
|
37
32
|
const minWidth = width < minSize ? minSize : width;
|
|
38
|
-
if (isLastColumn
|
|
33
|
+
if (isLastColumn) {
|
|
39
34
|
size = `minmax(${minWidth}px, auto)`;
|
|
40
35
|
} else {
|
|
41
36
|
size = `${minWidth}px`;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnFilter as ReactTableColumnFilter, ColumnFiltersState as ReactTableColumnFilterState, ColumnOrderState as ReactTableColumnOrderState, ColumnPinningState as ReactTableColumnPinningState, ColumnSort as ReactTableColumnSort, VisibilityState as ReactTableColumnVisibilityState, SortingState as ReactTableSortingState, BuiltInAggregationFn as ReactTableBuiltInAggregationFn, BuiltInSortingFn as ReactTableBuiltInSortingFn, Table as ReactTable } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnFilter as ReactTableColumnFilter, ColumnFiltersState as ReactTableColumnFilterState, ColumnOrderState as ReactTableColumnOrderState, ColumnPinningState as ReactTableColumnPinningState, ColumnSort as ReactTableColumnSort, ColumnSizingState as ReactTableColumnSizingState, VisibilityState as ReactTableColumnVisibilityState, SortingState as ReactTableSortingState, BuiltInAggregationFn as ReactTableBuiltInAggregationFn, BuiltInSortingFn as ReactTableBuiltInSortingFn, Table as ReactTable } from '@tanstack/react-table';
|
|
2
2
|
import { IconName, MenuItemProps } from '../../components';
|
|
3
3
|
import { DotNotationPaths, FontSize, FontSizes, DotNotationPathValue } from '../../types';
|
|
4
4
|
import { KeyDownHandlerOptions } from '../../utils/keyboard';
|
|
@@ -40,7 +40,6 @@ export type TableFilter = {
|
|
|
40
40
|
export type TableColumnAlignment = 'left' | 'center' | 'right';
|
|
41
41
|
export type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);
|
|
42
42
|
export type TableColumnDataType = 'text' | 'boolean' | 'date' | 'time' | 'datetime' | 'number' | 'amount' | 'percentage';
|
|
43
|
-
export type TableColumnNumericDataType = Extract<TableColumnDataType, 'number' | 'amount' | 'percentage'>;
|
|
44
43
|
export type TableColumnFilter = ReactTableColumnFilter;
|
|
45
44
|
export type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];
|
|
46
45
|
export type TableColumnRendererArgs<TType, TValue> = TValue extends undefined ? {
|
|
@@ -74,8 +73,6 @@ export type TableColumnSort = ReactTableColumnSort;
|
|
|
74
73
|
export type TableColumnSortDirection = 'asc' | 'desc';
|
|
75
74
|
export type TableColumnSortFn<TType = unknown> = ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1) | ReactTableBuiltInSortingFn | 'auto';
|
|
76
75
|
export type TableColumnWidth = number | 'grow';
|
|
77
|
-
/** TanStack Table types column sizing as pixel widths, but a column can also be sized by the 'grow' keyword */
|
|
78
|
-
export type TableColumnSizingState = Record<string, TableColumnWidth>;
|
|
79
76
|
export type TableRowActionHelpers<TType = unknown> = {
|
|
80
77
|
editing?: {
|
|
81
78
|
isEditing: boolean;
|
|
@@ -175,7 +172,7 @@ export type TableSettings = {
|
|
|
175
172
|
columnFilters?: ReactTableColumnFilterState;
|
|
176
173
|
columnOrder?: ReactTableColumnOrderState;
|
|
177
174
|
columnPinning?: ReactTableColumnPinningState;
|
|
178
|
-
columnSizing?:
|
|
175
|
+
columnSizing?: ReactTableColumnSizingState;
|
|
179
176
|
columnVisibility?: ReactTableColumnVisibilityState;
|
|
180
177
|
excludeUnmatchedRecordsInSearch?: boolean;
|
|
181
178
|
fontSize?: TableFontSize;
|
|
@@ -17,9 +17,6 @@ function useTableFontSizeListener(table) {
|
|
|
17
17
|
if (columns.isInternalColumn(columnName)) {
|
|
18
18
|
return [columnName, column?.getSize() ?? prevColumnSize];
|
|
19
19
|
}
|
|
20
|
-
if (typeof prevColumnSize !== "number") {
|
|
21
|
-
return [columnName, prevColumnSize];
|
|
22
|
-
}
|
|
23
20
|
const minColumnSize = column?.columnDef.minSize ?? globalMinSize;
|
|
24
21
|
const newSize = Math.max(minColumnSize, prevColumnSize + cellWidthDifference);
|
|
25
22
|
return [columnName, newSize];
|
|
@@ -15,9 +15,6 @@ function useTableFontSizeListener(table) {
|
|
|
15
15
|
if (isInternalColumn(columnName)) {
|
|
16
16
|
return [columnName, column?.getSize() ?? prevColumnSize];
|
|
17
17
|
}
|
|
18
|
-
if (typeof prevColumnSize !== "number") {
|
|
19
|
-
return [columnName, prevColumnSize];
|
|
20
|
-
}
|
|
21
18
|
const minColumnSize = column?.columnDef.minSize ?? globalMinSize;
|
|
22
19
|
const newSize = Math.max(minColumnSize, prevColumnSize + cellWidthDifference);
|
|
23
20
|
return [columnName, newSize];
|
|
@@ -4,7 +4,6 @@ const reactTable = require("@tanstack/react-table");
|
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const useTableColumnFreezing = require("./features/useTableColumnFreezing.cjs");
|
|
6
6
|
const useTableColumnOrdering = require("./features/useTableColumnOrdering.cjs");
|
|
7
|
-
const useTableColumnSizing = require("./features/useTableColumnSizing.cjs");
|
|
8
7
|
const useTableFontSize = require("./features/useTableFontSize.cjs");
|
|
9
8
|
const useTableFooter = require("./features/useTableFooter.cjs");
|
|
10
9
|
const useTablePrinting = require("./features/useTablePrinting.cjs");
|
|
@@ -98,7 +97,6 @@ function useTableManager(props, ref, meta, internalColumns) {
|
|
|
98
97
|
internalColumns,
|
|
99
98
|
localization
|
|
100
99
|
);
|
|
101
|
-
const columnSizing = useTableColumnSizing.useTableColumnSizing({ ...props.defaultSettings?.columnSizing, ...settings.columnSizing });
|
|
102
100
|
const initialState = setup.useReactTableInitialState(props, columns, settings, defaultState);
|
|
103
101
|
const instance = reactTable.useReactTable({
|
|
104
102
|
data,
|
|
@@ -129,7 +127,6 @@ function useTableManager(props, ref, meta, internalColumns) {
|
|
|
129
127
|
...meta,
|
|
130
128
|
columnFreezing,
|
|
131
129
|
columnOrdering,
|
|
132
|
-
columnSizing,
|
|
133
130
|
fontSize,
|
|
134
131
|
footer,
|
|
135
132
|
length,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { TableMeta as ReactTableMeta, RowData } from '@tanstack/react-table';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
|
-
import { TableColumnAlignment, TableColumnClassNameHandler, TableColumnDataType, TableColumnDataTypeOptions, TableColumnMenu, TableColumnRendererControl,
|
|
3
|
+
import { TableColumnAlignment, TableColumnClassNameHandler, TableColumnDataType, TableColumnDataTypeOptions, TableColumnMenu, TableColumnRendererControl, TableEventHandler, TableFilterComparator, TableProps, TableRef } from '../types';
|
|
4
4
|
import { useTableColumnFreezing } from './features/useTableColumnFreezing';
|
|
5
5
|
import { useTableColumnOrdering } from './features/useTableColumnOrdering';
|
|
6
|
-
import { useTableColumnSizing } from './features/useTableColumnSizing';
|
|
7
6
|
import { useTableFontSize } from './features/useTableFontSize';
|
|
8
7
|
import { useTableFooter } from './features/useTableFooter';
|
|
9
8
|
import { useTablePrinting } from './features/useTablePrinting';
|
|
@@ -24,7 +23,6 @@ declare module '@tanstack/table-core' {
|
|
|
24
23
|
interface TableMeta<TData extends RowData> {
|
|
25
24
|
columnFreezing: ReturnType<typeof useTableColumnFreezing>;
|
|
26
25
|
columnOrdering: ReturnType<typeof useTableColumnOrdering>;
|
|
27
|
-
columnSizing: ReturnType<typeof useTableColumnSizing>;
|
|
28
26
|
fontSize: ReturnType<typeof useTableFontSize>;
|
|
29
27
|
footer: ReturnType<typeof useTableFooter>;
|
|
30
28
|
length: number;
|
|
@@ -50,7 +48,7 @@ declare module '@tanstack/table-core' {
|
|
|
50
48
|
control?: TableColumnRendererControl<TData>;
|
|
51
49
|
dataType?: TableColumnDataType;
|
|
52
50
|
dataTypeOptions?: TableColumnDataTypeOptions;
|
|
53
|
-
defaultWidth?:
|
|
51
|
+
defaultWidth?: number;
|
|
54
52
|
emptyState?: React.ReactNode;
|
|
55
53
|
enableEditing?: boolean;
|
|
56
54
|
enableOrdering?: boolean;
|
|
@@ -2,7 +2,6 @@ import { useReactTable, getCoreRowModel } from "@tanstack/react-table";
|
|
|
2
2
|
import React__default from "react";
|
|
3
3
|
import { useTableColumnFreezing } from "./features/useTableColumnFreezing.js";
|
|
4
4
|
import { useTableColumnOrdering } from "./features/useTableColumnOrdering.js";
|
|
5
|
-
import { useTableColumnSizing } from "./features/useTableColumnSizing.js";
|
|
6
5
|
import { useTableFontSize } from "./features/useTableFontSize.js";
|
|
7
6
|
import { useTableFooter } from "./features/useTableFooter.js";
|
|
8
7
|
import { useTablePrinting } from "./features/useTablePrinting.js";
|
|
@@ -96,7 +95,6 @@ function useTableManager(props, ref, meta, internalColumns) {
|
|
|
96
95
|
internalColumns,
|
|
97
96
|
localization
|
|
98
97
|
);
|
|
99
|
-
const columnSizing = useTableColumnSizing({ ...props.defaultSettings?.columnSizing, ...settings.columnSizing });
|
|
100
98
|
const initialState = useReactTableInitialState(props, columns, settings, defaultState);
|
|
101
99
|
const instance = useReactTable({
|
|
102
100
|
data,
|
|
@@ -127,7 +125,6 @@ function useTableManager(props, ref, meta, internalColumns) {
|
|
|
127
125
|
...meta,
|
|
128
126
|
columnFreezing,
|
|
129
127
|
columnOrdering,
|
|
130
|
-
columnSizing,
|
|
131
128
|
fontSize,
|
|
132
129
|
footer,
|
|
133
130
|
length,
|
|
@@ -4,12 +4,6 @@ const search = require("./search.cjs");
|
|
|
4
4
|
function isInternalColumn(id) {
|
|
5
5
|
return id?.startsWith("__");
|
|
6
6
|
}
|
|
7
|
-
function getColumnSizingSetter(table) {
|
|
8
|
-
return table.setColumnSizing;
|
|
9
|
-
}
|
|
10
|
-
function getColumnWidth(columnSizing, id) {
|
|
11
|
-
return columnSizing[id];
|
|
12
|
-
}
|
|
13
7
|
const CELL_MIN_WIDTH = {
|
|
14
8
|
small: 57,
|
|
15
9
|
medium: 72,
|
|
@@ -90,8 +84,6 @@ function getHiddenColumns(columnVisibility = {}) {
|
|
|
90
84
|
exports.CELL_MIN_WIDTH = CELL_MIN_WIDTH;
|
|
91
85
|
exports.ensureOrdering = ensureOrdering;
|
|
92
86
|
exports.freezeUptoExternalColumn = freezeUptoExternalColumn;
|
|
93
|
-
exports.getColumnSizingSetter = getColumnSizingSetter;
|
|
94
|
-
exports.getColumnWidth = getColumnWidth;
|
|
95
87
|
exports.getHiddenColumns = getHiddenColumns;
|
|
96
88
|
exports.isCellHighlighted = isCellHighlighted;
|
|
97
89
|
exports.isInternalColumn = isInternalColumn;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { ColumnDef as ReactTableColumnDef,
|
|
1
|
+
import { ColumnDef as ReactTableColumnDef, VisibilityState as ReactTableVisibilityState } from '@tanstack/react-table';
|
|
2
2
|
import { Localization } from '../../../../components';
|
|
3
3
|
import { FontSize } from '../../../../types';
|
|
4
|
-
import { TableColumnDataType, TableColumnDataTypeOptions
|
|
4
|
+
import { TableColumnDataType, TableColumnDataTypeOptions } from '../../types';
|
|
5
5
|
export declare function isInternalColumn(id: string | undefined): boolean | undefined;
|
|
6
|
-
export type TableColumnSizingSetter = (updater: Updater<TableColumnSizingState>) => void;
|
|
7
|
-
export declare function getColumnSizingSetter<TType>(table: ReactTable<TType>): TableColumnSizingSetter;
|
|
8
|
-
export declare function getColumnWidth(columnSizing: TableColumnSizingState, id: string): TableColumnWidth | undefined;
|
|
9
6
|
export declare const CELL_MIN_WIDTH: Record<FontSize, number>;
|
|
10
7
|
export declare function isCellHighlighted<TType = unknown>(query: string, value: unknown, row: TType, dataType: TableColumnDataType | undefined, dataTypeOptions: TableColumnDataTypeOptions | undefined, localization: Localization): any;
|
|
11
8
|
export declare function ensureOrdering<TType = unknown>(columns: ReactTableColumnDef<TType>[], settingsOrder: string[] | undefined, pinnedOrder?: string[] | undefined, internalColumnsPinnedToTheRight?: string[]): string[];
|
|
@@ -2,12 +2,6 @@ import { isMatched } from "./search.js";
|
|
|
2
2
|
function isInternalColumn(id) {
|
|
3
3
|
return id?.startsWith("__");
|
|
4
4
|
}
|
|
5
|
-
function getColumnSizingSetter(table) {
|
|
6
|
-
return table.setColumnSizing;
|
|
7
|
-
}
|
|
8
|
-
function getColumnWidth(columnSizing, id) {
|
|
9
|
-
return columnSizing[id];
|
|
10
|
-
}
|
|
11
5
|
const CELL_MIN_WIDTH = {
|
|
12
6
|
small: 57,
|
|
13
7
|
medium: 72,
|
|
@@ -89,8 +83,6 @@ export {
|
|
|
89
83
|
CELL_MIN_WIDTH,
|
|
90
84
|
ensureOrdering,
|
|
91
85
|
freezeUptoExternalColumn,
|
|
92
|
-
getColumnSizingSetter,
|
|
93
|
-
getColumnWidth,
|
|
94
86
|
getHiddenColumns,
|
|
95
87
|
isCellHighlighted,
|
|
96
88
|
isInternalColumn,
|
|
@@ -34,16 +34,16 @@ const dataTypes = {
|
|
|
34
34
|
filterComparators: [types.TableFilterComparator.IsEqualTo, types.TableFilterComparator.IsNotEqualTo]
|
|
35
35
|
},
|
|
36
36
|
// dates
|
|
37
|
-
date: createDatetimeDataType(
|
|
37
|
+
date: createDatetimeDataType({
|
|
38
38
|
day: "2-digit",
|
|
39
39
|
month: "2-digit",
|
|
40
40
|
year: "2-digit"
|
|
41
41
|
}),
|
|
42
|
-
time: createDatetimeDataType(
|
|
42
|
+
time: createDatetimeDataType({
|
|
43
43
|
hour: "2-digit",
|
|
44
44
|
minute: "2-digit"
|
|
45
45
|
}),
|
|
46
|
-
datetime: createDatetimeDataType(
|
|
46
|
+
datetime: createDatetimeDataType({
|
|
47
47
|
day: "2-digit",
|
|
48
48
|
month: "2-digit",
|
|
49
49
|
year: "2-digit",
|
|
@@ -55,17 +55,7 @@ const dataTypes = {
|
|
|
55
55
|
amount: createNumberDataType("right", { decimals: 2, useGrouping: true }),
|
|
56
56
|
percentage: createNumberDataType("right", { useGrouping: true, percent: true })
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
switch (kind) {
|
|
60
|
-
case "date":
|
|
61
|
-
return { date: formatting.date };
|
|
62
|
-
case "time":
|
|
63
|
-
return { time: formatting.time };
|
|
64
|
-
default:
|
|
65
|
-
return { date: formatting.date, time: formatting.time };
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
function createDatetimeDataType(kind, defaultOptions) {
|
|
58
|
+
function createDatetimeDataType(defaultOptions) {
|
|
69
59
|
return {
|
|
70
60
|
align: "left",
|
|
71
61
|
sortingFn: "datetime",
|
|
@@ -84,17 +74,11 @@ function createDatetimeDataType(kind, defaultOptions) {
|
|
|
84
74
|
if (value === void 0) {
|
|
85
75
|
return "";
|
|
86
76
|
}
|
|
87
|
-
return dataTypes$1.DateTimeDataType.format(
|
|
88
|
-
value,
|
|
89
|
-
options?.localization.locale,
|
|
90
|
-
defaultOptions,
|
|
91
|
-
options?.localization ? getMasks(kind, options.localization) : void 0
|
|
92
|
-
);
|
|
77
|
+
return dataTypes$1.DateTimeDataType.format(value, options?.localization.locale, defaultOptions);
|
|
93
78
|
},
|
|
94
|
-
parse: (value,
|
|
79
|
+
parse: (value, locale) => dataTypes$1.DateTimeDataType.parse(value, locale)
|
|
95
80
|
};
|
|
96
81
|
}
|
|
97
|
-
const EDITABLE_NUMBER_FORMAT_OPTIONS = { useGrouping: false, maximumFractionDigits: 20 };
|
|
98
82
|
function createNumberDataType(align, defaultOptions) {
|
|
99
83
|
return {
|
|
100
84
|
align,
|
|
@@ -128,20 +112,17 @@ function createNumberDataType(align, defaultOptions) {
|
|
|
128
112
|
numberFormatOptions.currency = dataTypeOptions.currency;
|
|
129
113
|
numberFormatOptions.currencyDisplay = "code";
|
|
130
114
|
}
|
|
131
|
-
const localisedValue = dataTypes$1.
|
|
132
|
-
const
|
|
115
|
+
const localisedValue = dataTypes$1.NumericDataType.format(value, options?.localization.locale, numberFormatOptions);
|
|
116
|
+
const localisedValueWithoutThousandsSeperator = dataTypes$1.NumericDataType.format(value, options?.localization.locale, {
|
|
133
117
|
...numberFormatOptions,
|
|
134
118
|
useGrouping: false
|
|
135
119
|
});
|
|
136
|
-
return [localisedValue,
|
|
120
|
+
return [localisedValue, localisedValueWithoutThousandsSeperator];
|
|
137
121
|
},
|
|
138
|
-
|
|
139
|
-
parse: (value, localization) => dataTypes$1.parseNumber(value, localization)
|
|
122
|
+
parse: (value, locale) => dataTypes$1.NumericDataType.parse(value, locale)
|
|
140
123
|
};
|
|
141
124
|
}
|
|
142
125
|
function getDataTypeProperties(dataType) {
|
|
143
126
|
return dataTypes[dataType ?? "text"] ?? dataTypes.text;
|
|
144
127
|
}
|
|
145
|
-
const isNumericDataType = (dataType) => dataType === "number" || dataType === "amount" || dataType === "percentage";
|
|
146
128
|
exports.getDataTypeProperties = getDataTypeProperties;
|
|
147
|
-
exports.isNumericDataType = isNumericDataType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SortingFnOption as ReactTableSortingFnOption } from '@tanstack/react-table';
|
|
2
2
|
import { Localization } from '../../../../components';
|
|
3
|
-
import { TableColumnAlignment, TableColumnDataType, TableColumnDataTypeOptionsHandler,
|
|
3
|
+
import { TableColumnAlignment, TableColumnDataType, TableColumnDataTypeOptionsHandler, TableFilterComparator } from '../../types';
|
|
4
4
|
export type TableDataTypeDisplayValueOptions = {
|
|
5
5
|
dataTypeOptions?: TableColumnDataTypeOptionsHandler;
|
|
6
6
|
localization: Localization;
|
|
@@ -10,9 +10,6 @@ export type TableDataType<TType = unknown, TValue = unknown> = {
|
|
|
10
10
|
sortingFn: ReactTableSortingFnOption<TType>;
|
|
11
11
|
filterComparators: TableFilterComparator[];
|
|
12
12
|
getDisplayValue?(value: TValue, row: TType, options?: TableDataTypeDisplayValueOptions): string | string[];
|
|
13
|
-
|
|
14
|
-
getEditableValue?(value: TValue, localization: Localization): string;
|
|
15
|
-
parse?(value: string, localization: Localization): TValue | undefined;
|
|
13
|
+
parse?(value: string, locale: string): TValue | undefined;
|
|
16
14
|
};
|
|
17
15
|
export declare function getDataTypeProperties<TType = unknown>(dataType: TableColumnDataType | undefined): TableDataType<TType>;
|
|
18
|
-
export declare const isNumericDataType: (dataType: TableColumnDataType | undefined) => dataType is TableColumnNumericDataType;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NumericDataType, DateTimeDataType } from "../../../../utils/dataTypes.js";
|
|
2
2
|
import { TableFilterComparator } from "../../types.js";
|
|
3
3
|
const dataTypes = {
|
|
4
4
|
auto: {
|
|
@@ -32,16 +32,16 @@ const dataTypes = {
|
|
|
32
32
|
filterComparators: [TableFilterComparator.IsEqualTo, TableFilterComparator.IsNotEqualTo]
|
|
33
33
|
},
|
|
34
34
|
// dates
|
|
35
|
-
date: createDatetimeDataType(
|
|
35
|
+
date: createDatetimeDataType({
|
|
36
36
|
day: "2-digit",
|
|
37
37
|
month: "2-digit",
|
|
38
38
|
year: "2-digit"
|
|
39
39
|
}),
|
|
40
|
-
time: createDatetimeDataType(
|
|
40
|
+
time: createDatetimeDataType({
|
|
41
41
|
hour: "2-digit",
|
|
42
42
|
minute: "2-digit"
|
|
43
43
|
}),
|
|
44
|
-
datetime: createDatetimeDataType(
|
|
44
|
+
datetime: createDatetimeDataType({
|
|
45
45
|
day: "2-digit",
|
|
46
46
|
month: "2-digit",
|
|
47
47
|
year: "2-digit",
|
|
@@ -53,17 +53,7 @@ const dataTypes = {
|
|
|
53
53
|
amount: createNumberDataType("right", { decimals: 2, useGrouping: true }),
|
|
54
54
|
percentage: createNumberDataType("right", { useGrouping: true, percent: true })
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
switch (kind) {
|
|
58
|
-
case "date":
|
|
59
|
-
return { date: formatting.date };
|
|
60
|
-
case "time":
|
|
61
|
-
return { time: formatting.time };
|
|
62
|
-
default:
|
|
63
|
-
return { date: formatting.date, time: formatting.time };
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
function createDatetimeDataType(kind, defaultOptions) {
|
|
56
|
+
function createDatetimeDataType(defaultOptions) {
|
|
67
57
|
return {
|
|
68
58
|
align: "left",
|
|
69
59
|
sortingFn: "datetime",
|
|
@@ -82,17 +72,11 @@ function createDatetimeDataType(kind, defaultOptions) {
|
|
|
82
72
|
if (value === void 0) {
|
|
83
73
|
return "";
|
|
84
74
|
}
|
|
85
|
-
return DateTimeDataType.format(
|
|
86
|
-
value,
|
|
87
|
-
options?.localization.locale,
|
|
88
|
-
defaultOptions,
|
|
89
|
-
options?.localization ? getMasks(kind, options.localization) : void 0
|
|
90
|
-
);
|
|
75
|
+
return DateTimeDataType.format(value, options?.localization.locale, defaultOptions);
|
|
91
76
|
},
|
|
92
|
-
parse: (value,
|
|
77
|
+
parse: (value, locale) => DateTimeDataType.parse(value, locale)
|
|
93
78
|
};
|
|
94
79
|
}
|
|
95
|
-
const EDITABLE_NUMBER_FORMAT_OPTIONS = { useGrouping: false, maximumFractionDigits: 20 };
|
|
96
80
|
function createNumberDataType(align, defaultOptions) {
|
|
97
81
|
return {
|
|
98
82
|
align,
|
|
@@ -126,22 +110,19 @@ function createNumberDataType(align, defaultOptions) {
|
|
|
126
110
|
numberFormatOptions.currency = dataTypeOptions.currency;
|
|
127
111
|
numberFormatOptions.currencyDisplay = "code";
|
|
128
112
|
}
|
|
129
|
-
const localisedValue =
|
|
130
|
-
const
|
|
113
|
+
const localisedValue = NumericDataType.format(value, options?.localization.locale, numberFormatOptions);
|
|
114
|
+
const localisedValueWithoutThousandsSeperator = NumericDataType.format(value, options?.localization.locale, {
|
|
131
115
|
...numberFormatOptions,
|
|
132
116
|
useGrouping: false
|
|
133
117
|
});
|
|
134
|
-
return [localisedValue,
|
|
118
|
+
return [localisedValue, localisedValueWithoutThousandsSeperator];
|
|
135
119
|
},
|
|
136
|
-
|
|
137
|
-
parse: (value, localization) => parseNumber(value, localization)
|
|
120
|
+
parse: (value, locale) => NumericDataType.parse(value, locale)
|
|
138
121
|
};
|
|
139
122
|
}
|
|
140
123
|
function getDataTypeProperties(dataType) {
|
|
141
124
|
return dataTypes[dataType ?? "text"] ?? dataTypes.text;
|
|
142
125
|
}
|
|
143
|
-
const isNumericDataType = (dataType) => dataType === "number" || dataType === "amount" || dataType === "percentage";
|
|
144
126
|
export {
|
|
145
|
-
getDataTypeProperties
|
|
146
|
-
isNumericDataType
|
|
127
|
+
getDataTypeProperties
|
|
147
128
|
};
|
|
@@ -25,7 +25,7 @@ function columnFilterFn(row, cellValue, meta, filter, localization) {
|
|
|
25
25
|
const valueAsDate = new Date(cellValue);
|
|
26
26
|
const isNumberColumn = dataType === "number" || dataType === "amount";
|
|
27
27
|
const compareNumbers = (fn) => {
|
|
28
|
-
const input = typeof query === "number" ? query : dataTypes.
|
|
28
|
+
const input = typeof query === "number" ? query : dataTypes.NumericDataType.parse(query, localization.locale);
|
|
29
29
|
const value = cellValue;
|
|
30
30
|
if (input === void 0) {
|
|
31
31
|
return false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NumericDataType } from "../../../../utils/dataTypes.js";
|
|
2
2
|
import { isWeakEqual as isWeakEqual$1 } from "../../../../utils/date.js";
|
|
3
3
|
import { TableFilterComparator } from "../../types.js";
|
|
4
4
|
import { isMatched } from "./search.js";
|
|
@@ -23,7 +23,7 @@ function columnFilterFn(row, cellValue, meta, filter, localization) {
|
|
|
23
23
|
const valueAsDate = new Date(cellValue);
|
|
24
24
|
const isNumberColumn = dataType === "number" || dataType === "amount";
|
|
25
25
|
const compareNumbers = (fn) => {
|
|
26
|
-
const input = typeof query === "number" ? query :
|
|
26
|
+
const input = typeof query === "number" ? query : NumericDataType.parse(query, localization.locale);
|
|
27
27
|
const value = cellValue;
|
|
28
28
|
if (input === void 0) {
|
|
29
29
|
return false;
|