@uzum-tech/ui 2.0.0-beta.3 → 2.0.0-beta.5
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/index.js +2467 -1507
- package/dist/index.mjs +2461 -1506
- package/dist/index.prod.js +2 -2
- package/dist/index.prod.mjs +2 -2
- package/es/_internal/component-renderer/index.d.ts +2 -0
- package/es/_internal/component-renderer/index.mjs +1 -0
- package/es/_internal/component-renderer/src/interface.d.ts +29 -0
- package/es/_internal/component-renderer/src/interface.mjs +1 -0
- package/es/_internal/component-renderer/src/renderer.d.ts +3 -0
- package/es/_internal/component-renderer/src/renderer.mjs +20 -0
- package/es/_internal/select-menu/src/SelectOption.mjs +9 -5
- package/es/_internal/select-menu/src/styles/index.cssr.mjs +4 -3
- package/es/_internal/selection/src/styles/index.cssr.mjs +3 -0
- package/es/card-list/src/CardList.d.ts +1 -1
- package/es/checkbox/src/Checkbox.d.ts +2 -2
- package/es/components.d.ts +1 -0
- package/es/components.mjs +1 -0
- package/es/config-provider/src/internal-interface.d.ts +3 -1
- package/es/data-table/src/DataTable.d.ts +25 -5
- package/es/data-table/src/DataTable.mjs +125 -4
- package/es/data-table/src/HeaderButton/FilterMenu.mjs +1 -1
- package/es/data-table/src/TableParts/Body.d.ts +9 -6
- package/es/data-table/src/TableParts/Body.mjs +30 -6
- package/es/data-table/src/TableParts/Cell.mjs +17 -17
- package/es/data-table/src/TableParts/Header.d.ts +4 -2
- package/es/data-table/src/TableParts/Header.mjs +65 -22
- package/es/data-table/src/interface.d.ts +16 -0
- package/es/data-table/src/interface.mjs +9 -0
- package/es/data-table/src/use-group-header.mjs +2 -2
- package/es/data-table/src/use-mask.mjs +1 -1
- package/es/data-table/src/use-resizable.d.ts +1 -0
- package/es/data-table/src/use-resizable.mjs +5 -2
- package/es/data-table/src/use-scroll.d.ts +5 -4
- package/es/data-table/src/use-scroll.mjs +29 -25
- package/es/data-table/src/use-sorter.mjs +1 -1
- package/es/data-table/src/use-table-data.mjs +1 -1
- package/es/data-table/src/utils/column-utils.d.ts +13 -0
- package/es/data-table/src/utils/column-utils.mjs +84 -0
- package/es/data-table/src/utils/csv-utils.d.ts +3 -0
- package/es/data-table/src/utils/csv-utils.mjs +21 -0
- package/es/data-table/src/utils/index.d.ts +7 -0
- package/es/data-table/src/utils/index.mjs +7 -0
- package/es/data-table/src/utils/mask-defaults.d.ts +6 -0
- package/es/data-table/src/utils/mask-defaults.mjs +16 -0
- package/es/data-table/src/utils/resize-orchestrator-utils.d.ts +6 -0
- package/es/data-table/src/utils/resize-orchestrator-utils.mjs +21 -0
- package/es/data-table/src/utils/sort-filter-utils.d.ts +6 -0
- package/es/data-table/src/utils/sort-filter-utils.mjs +38 -0
- package/es/data-table/src/utils/width-utils.d.ts +20 -0
- package/es/data-table/src/utils/width-utils.mjs +174 -0
- package/es/data-table/src/utils.d.ts +1 -25
- package/es/data-table/src/utils.mjs +1 -165
- package/es/grid/src/Grid.d.ts +1 -1
- package/es/header/src/HeaderSearchResults.d.ts +1 -1
- package/es/icon-bar/src/IconBar.d.ts +1 -1
- package/es/input/src/Input.d.ts +1 -1
- package/es/list/src/ListItem.d.ts +2 -2
- package/es/list/src/ListItem.mjs +19 -12
- package/es/list/src/props.d.ts +3 -1
- package/es/list/src/styles/index.cssr.mjs +4 -2
- package/es/locales/common/enUS.d.ts +6 -0
- package/es/locales/common/enUS.mjs +6 -0
- package/es/locales/common/ruRU.mjs +6 -0
- package/es/mapping-card/index.d.ts +7 -0
- package/es/mapping-card/index.mjs +4 -0
- package/es/mapping-card/src/MappingCard.d.ts +2091 -0
- package/es/mapping-card/src/MappingCard.mjs +77 -0
- package/es/mapping-card/src/MappingCardList.d.ts +36 -0
- package/es/mapping-card/src/MappingCardList.mjs +50 -0
- package/es/mapping-card/src/MappingCardParts/Body.d.ts +4 -0
- package/es/mapping-card/src/MappingCardParts/Body.mjs +66 -0
- package/es/mapping-card/src/MappingCardParts/Header.d.ts +7 -0
- package/es/mapping-card/src/MappingCardParts/Header.mjs +147 -0
- package/es/mapping-card/src/injection.d.ts +17 -0
- package/es/mapping-card/src/injection.mjs +2 -0
- package/es/mapping-card/src/interface.d.ts +105 -0
- package/es/mapping-card/src/interface.mjs +45 -0
- package/es/mapping-card/src/styles/index.cssr.d.ts +2 -0
- package/es/mapping-card/src/styles/index.cssr.mjs +92 -0
- package/es/mapping-card/styles/dark.d.ts +337 -0
- package/es/mapping-card/styles/dark.mjs +22 -0
- package/es/mapping-card/styles/index.d.ts +3 -0
- package/es/mapping-card/styles/index.mjs +2 -0
- package/es/mapping-card/styles/light.d.ts +352 -0
- package/es/mapping-card/styles/light.mjs +45 -0
- package/es/progress/src/MultipleCircle.d.ts +1 -1
- package/es/radio/src/Radio.d.ts +1 -1
- package/es/radio/src/RadioButton.d.ts +3 -3
- package/es/tabs/src/Tabs.d.ts +2 -6
- package/es/themes/dark.mjs +2 -0
- package/es/themes/light.mjs +2 -0
- package/es/toggle-button/src/ToggleButton.d.ts +2 -2
- package/es/version.d.ts +1 -1
- package/es/version.mjs +1 -1
- package/lib/_internal/component-renderer/index.d.ts +2 -0
- package/lib/_internal/component-renderer/index.js +5 -0
- package/lib/_internal/component-renderer/src/interface.d.ts +29 -0
- package/lib/_internal/component-renderer/src/interface.js +2 -0
- package/lib/_internal/component-renderer/src/renderer.d.ts +3 -0
- package/lib/_internal/component-renderer/src/renderer.js +28 -0
- package/lib/_internal/select-menu/src/SelectOption.js +11 -12
- package/lib/_internal/select-menu/src/styles/index.cssr.js +4 -3
- package/lib/_internal/selection/src/styles/index.cssr.js +3 -0
- package/lib/card-list/src/CardList.d.ts +1 -1
- package/lib/checkbox/src/Checkbox.d.ts +2 -2
- package/lib/components.d.ts +1 -0
- package/lib/components.js +1 -0
- package/lib/config-provider/src/internal-interface.d.ts +3 -1
- package/lib/data-table/src/DataTable.d.ts +25 -5
- package/lib/data-table/src/DataTable.js +131 -4
- package/lib/data-table/src/TableParts/Body.d.ts +9 -6
- package/lib/data-table/src/TableParts/Body.js +30 -8
- package/lib/data-table/src/TableParts/Cell.js +16 -16
- package/lib/data-table/src/TableParts/Header.d.ts +4 -2
- package/lib/data-table/src/TableParts/Header.js +55 -23
- package/lib/data-table/src/interface.d.ts +16 -0
- package/lib/data-table/src/interface.js +6 -0
- package/lib/data-table/src/use-group-header.js +1 -1
- package/lib/data-table/src/use-resizable.d.ts +1 -0
- package/lib/data-table/src/use-resizable.js +5 -2
- package/lib/data-table/src/use-scroll.d.ts +5 -4
- package/lib/data-table/src/use-scroll.js +31 -28
- package/lib/data-table/src/utils/column-utils.d.ts +13 -0
- package/lib/data-table/src/utils/column-utils.js +116 -0
- package/lib/data-table/src/utils/csv-utils.d.ts +3 -0
- package/lib/data-table/src/utils/csv-utils.js +34 -0
- package/lib/data-table/src/utils/index.d.ts +7 -0
- package/lib/data-table/src/utils/index.js +26 -0
- package/lib/data-table/src/utils/mask-defaults.d.ts +6 -0
- package/lib/data-table/src/utils/mask-defaults.js +22 -0
- package/lib/data-table/src/utils/resize-orchestrator-utils.d.ts +6 -0
- package/lib/data-table/src/utils/resize-orchestrator-utils.js +35 -0
- package/lib/data-table/src/utils/sort-filter-utils.d.ts +6 -0
- package/lib/data-table/src/utils/sort-filter-utils.js +54 -0
- package/lib/data-table/src/utils/width-utils.d.ts +20 -0
- package/lib/data-table/src/utils/width-utils.js +182 -0
- package/lib/data-table/src/utils.d.ts +1 -25
- package/lib/data-table/src/utils.js +15 -229
- package/lib/grid/src/Grid.d.ts +1 -1
- package/lib/header/src/HeaderSearchResults.d.ts +1 -1
- package/lib/icon-bar/src/IconBar.d.ts +1 -1
- package/lib/input/src/Input.d.ts +1 -1
- package/lib/list/src/ListItem.d.ts +2 -2
- package/lib/list/src/ListItem.js +31 -10
- package/lib/list/src/props.d.ts +3 -1
- package/lib/list/src/styles/index.cssr.js +4 -2
- package/lib/locales/common/enUS.d.ts +6 -0
- package/lib/locales/common/enUS.js +6 -0
- package/lib/locales/common/ruRU.js +6 -0
- package/lib/mapping-card/index.d.ts +7 -0
- package/lib/mapping-card/index.js +15 -0
- package/lib/mapping-card/src/MappingCard.d.ts +2091 -0
- package/lib/mapping-card/src/MappingCard.js +58 -0
- package/lib/mapping-card/src/MappingCardList.d.ts +36 -0
- package/lib/mapping-card/src/MappingCardList.js +38 -0
- package/lib/mapping-card/src/MappingCardParts/Body.d.ts +4 -0
- package/lib/mapping-card/src/MappingCardParts/Body.js +48 -0
- package/lib/mapping-card/src/MappingCardParts/Header.d.ts +7 -0
- package/lib/mapping-card/src/MappingCardParts/Header.js +77 -0
- package/lib/mapping-card/src/injection.d.ts +17 -0
- package/lib/mapping-card/src/injection.js +5 -0
- package/lib/mapping-card/src/interface.d.ts +105 -0
- package/lib/mapping-card/src/interface.js +48 -0
- package/lib/mapping-card/src/styles/index.cssr.d.ts +2 -0
- package/lib/mapping-card/src/styles/index.cssr.js +97 -0
- package/lib/mapping-card/styles/dark.d.ts +337 -0
- package/lib/mapping-card/styles/dark.js +24 -0
- package/lib/mapping-card/styles/index.d.ts +3 -0
- package/lib/mapping-card/styles/index.js +10 -0
- package/lib/mapping-card/styles/light.d.ts +352 -0
- package/lib/mapping-card/styles/light.js +40 -0
- package/lib/progress/src/MultipleCircle.d.ts +1 -1
- package/lib/radio/src/Radio.d.ts +1 -1
- package/lib/radio/src/RadioButton.d.ts +3 -3
- package/lib/tabs/src/Tabs.d.ts +2 -6
- package/lib/themes/dark.js +84 -82
- package/lib/themes/light.js +82 -80
- package/lib/toggle-button/src/ToggleButton.d.ts +2 -2
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/volar.d.ts +2 -0
- package/web-types.json +207 -2
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { depx } from 'seemly';
|
|
2
|
+
import { formatLength } from "../../../_utils/index.mjs";
|
|
3
|
+
import { clampValueFollowCSSRules, parseLengthToNumber } from "./width-utils.mjs";
|
|
4
|
+
export const SELECTION_COL_WIDTH = 40;
|
|
5
|
+
export const EXPAND_COL_WIDTH = 40;
|
|
6
|
+
export function getNumberColWidth(column) {
|
|
7
|
+
if (column.type === 'selection') {
|
|
8
|
+
return column.width === undefined ? SELECTION_COL_WIDTH : depx(column.width);
|
|
9
|
+
}
|
|
10
|
+
if (column.type === 'expand') {
|
|
11
|
+
return column.width === undefined ? EXPAND_COL_WIDTH : depx(column.width);
|
|
12
|
+
}
|
|
13
|
+
if ('children' in column) return undefined;
|
|
14
|
+
if (typeof column.width === 'string') {
|
|
15
|
+
return depx(column.width);
|
|
16
|
+
}
|
|
17
|
+
return column.width;
|
|
18
|
+
}
|
|
19
|
+
export function getStringColWidth(column) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
if (column.type === 'selection') {
|
|
22
|
+
return formatLength((_a = column.width) !== null && _a !== void 0 ? _a : SELECTION_COL_WIDTH);
|
|
23
|
+
}
|
|
24
|
+
if (column.type === 'expand') {
|
|
25
|
+
return formatLength((_b = column.width) !== null && _b !== void 0 ? _b : EXPAND_COL_WIDTH);
|
|
26
|
+
}
|
|
27
|
+
if ('children' in column) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
return formatLength(column.width);
|
|
31
|
+
}
|
|
32
|
+
export function getColKey(column) {
|
|
33
|
+
if (column.type === 'selection') return '__n_selection__';
|
|
34
|
+
if (column.type === 'expand') return '__n_expand__';
|
|
35
|
+
return column.key;
|
|
36
|
+
}
|
|
37
|
+
export function createCustomWidthStyle(column, resizedWidth) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
if (resizedWidth !== undefined) {
|
|
40
|
+
const numericWidth = depx(resizedWidth);
|
|
41
|
+
const minMaxColumn = column && 'minWidth' in column && 'maxWidth' in column ? column : null;
|
|
42
|
+
const clampedNumber = minMaxColumn ? clampValueFollowCSSRules(numericWidth, minMaxColumn.minWidth, minMaxColumn.maxWidth) : numericWidth;
|
|
43
|
+
const clamped = formatLength(clampedNumber);
|
|
44
|
+
return {
|
|
45
|
+
width: clamped,
|
|
46
|
+
minWidth: clamped,
|
|
47
|
+
maxWidth: clamped
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const explicitNumber = getNumberColWidth(column);
|
|
51
|
+
const minWidth = 'minWidth' in column ? column.minWidth : undefined;
|
|
52
|
+
const maxWidth = 'maxWidth' in column ? column.maxWidth : undefined;
|
|
53
|
+
let widthNumber = explicitNumber;
|
|
54
|
+
if (widthNumber === undefined && (minWidth !== undefined || maxWidth !== undefined)) {
|
|
55
|
+
widthNumber = clampValueFollowCSSRules(maxWidth !== undefined ? (_a = parseLengthToNumber(maxWidth)) !== null && _a !== void 0 ? _a : 0 : minWidth !== undefined ? (_b = parseLengthToNumber(minWidth)) !== null && _b !== void 0 ? _b : 0 : 0, minWidth, maxWidth);
|
|
56
|
+
} else if (widthNumber !== undefined && (minWidth !== undefined || maxWidth !== undefined)) {
|
|
57
|
+
widthNumber = clampValueFollowCSSRules(widthNumber, minWidth, maxWidth);
|
|
58
|
+
}
|
|
59
|
+
const width = widthNumber !== undefined ? formatLength(widthNumber) : getStringColWidth(column);
|
|
60
|
+
return {
|
|
61
|
+
width,
|
|
62
|
+
minWidth: formatLength(minWidth) || width,
|
|
63
|
+
maxWidth: formatLength(maxWidth)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function createRowClassName(row, index, rowClassName) {
|
|
67
|
+
if (typeof rowClassName === 'function') return rowClassName(row, index);
|
|
68
|
+
return rowClassName || '';
|
|
69
|
+
}
|
|
70
|
+
export function isColumnSortable(column) {
|
|
71
|
+
if ('children' in column) return false;
|
|
72
|
+
return !!column.sorter;
|
|
73
|
+
}
|
|
74
|
+
export function isColumnEllipsisEnabled(column) {
|
|
75
|
+
return column.ellipsis !== false;
|
|
76
|
+
}
|
|
77
|
+
export function isColumnResizable(column) {
|
|
78
|
+
if ('children' in column && !!column.children.length) return false;
|
|
79
|
+
return !!column.resizable;
|
|
80
|
+
}
|
|
81
|
+
export function isColumnFilterable(column) {
|
|
82
|
+
if ('children' in column) return false;
|
|
83
|
+
return !!column.filter && (!!column.filterOptions || !!column.renderFilterMenu);
|
|
84
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RowData, TableColumn } from '../interface';
|
|
2
|
+
import type { DataTableGetCsvCell, DataTableGetCsvHeader } from '../public-types';
|
|
3
|
+
export declare function generateCsv(columns: TableColumn[], data: RowData[], getCsvCell: DataTableGetCsvCell | undefined, getCsvHeader: DataTableGetCsvHeader | undefined): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function formatCsvCell(value) {
|
|
2
|
+
if (typeof value === 'string') {
|
|
3
|
+
return value.replace(/,/g, '\\,');
|
|
4
|
+
} else if (value === null || value === undefined) {
|
|
5
|
+
return '';
|
|
6
|
+
} else {
|
|
7
|
+
return `${value}`.replace(/,/g, '\\,');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function generateCsv(columns, data, getCsvCell, getCsvHeader) {
|
|
11
|
+
const exportableColumns = columns.filter(column => column.type !== 'expand' && column.type !== 'selection' && column.allowExport !== false);
|
|
12
|
+
const header = exportableColumns.map(col => {
|
|
13
|
+
return getCsvHeader ? getCsvHeader(col) : col.title;
|
|
14
|
+
}).join(',');
|
|
15
|
+
const rows = data.map(row => {
|
|
16
|
+
return exportableColumns.map(col => {
|
|
17
|
+
return getCsvCell ? getCsvCell(row[col.key], row, col) : formatCsvCell(row[col.key]);
|
|
18
|
+
}).join(',');
|
|
19
|
+
});
|
|
20
|
+
return [header, ...rows].join('\n');
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './column-utils';
|
|
2
|
+
export * from './csv-utils';
|
|
3
|
+
export * from './mask-defaults';
|
|
4
|
+
export * from './resize-orchestrator-utils';
|
|
5
|
+
export * from './sort-filter-utils';
|
|
6
|
+
export * from './width-utils';
|
|
7
|
+
export { parseLengthToNumber as getLengthNumber, sanitizeColumnWidthMap as pickValidColumnWidths } from './width-utils';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./column-utils.mjs";
|
|
2
|
+
export * from "./csv-utils.mjs";
|
|
3
|
+
export * from "./mask-defaults.mjs";
|
|
4
|
+
export * from "./resize-orchestrator-utils.mjs";
|
|
5
|
+
export * from "./sort-filter-utils.mjs";
|
|
6
|
+
export * from "./width-utils.mjs";
|
|
7
|
+
export { parseLengthToNumber as getLengthNumber, sanitizeColumnWidthMap as pickValidColumnWidths } from "./width-utils.mjs";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const REGEX = {
|
|
2
|
+
ONLY_DIGITS: /\D/g,
|
|
3
|
+
ONLY_NUMERIC_AND_DOT: /[^\d.]/g
|
|
4
|
+
};
|
|
5
|
+
export const defaultNumericMask = {
|
|
6
|
+
postProcess: value => {
|
|
7
|
+
if (!value) return '';
|
|
8
|
+
const negative = value.trim().startsWith('-');
|
|
9
|
+
const cleaned = value.replace(/[^\d.,]/g, '').replace(',', '.');
|
|
10
|
+
const [integerPartRaw, decimalPartRaw = ''] = cleaned.split('.', 2);
|
|
11
|
+
const integerPart = integerPartRaw.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
12
|
+
const decimalPart = decimalPartRaw.slice(0, 2);
|
|
13
|
+
const result = cleaned.includes('.') ? `${integerPart}.${decimalPart}` : integerPart;
|
|
14
|
+
return negative ? `-${result}` : result;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ColumnWidthComputationItem, TableBaseColumn, TableExpandColumn, TableSelectionColumn } from '../interface';
|
|
2
|
+
type ResizableLeafColumn = TableSelectionColumn | TableBaseColumn | TableExpandColumn;
|
|
3
|
+
export declare function deriveVisibleLeafColumnWidthItems(columns: ResizableLeafColumn[]): ColumnWidthComputationItem[];
|
|
4
|
+
export declare function deriveResizableColumnWidthItems(columns: ResizableLeafColumn[]): ColumnWidthComputationItem[];
|
|
5
|
+
export declare function deriveColumnWidthSignature(columns: ColumnWidthComputationItem[]): string;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getColKey, isColumnResizable } from "./column-utils.mjs";
|
|
2
|
+
function toColumnWidthItem(column) {
|
|
3
|
+
return {
|
|
4
|
+
key: getColKey(column),
|
|
5
|
+
width: column.width,
|
|
6
|
+
minWidth: column.minWidth,
|
|
7
|
+
maxWidth: column.maxWidth
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function deriveVisibleLeafColumnWidthItems(columns) {
|
|
11
|
+
return columns.map(column => toColumnWidthItem(column));
|
|
12
|
+
}
|
|
13
|
+
export function deriveResizableColumnWidthItems(columns) {
|
|
14
|
+
return columns.filter(column => isColumnResizable(column)).map(column => toColumnWidthItem(column));
|
|
15
|
+
}
|
|
16
|
+
export function deriveColumnWidthSignature(columns) {
|
|
17
|
+
return columns.map(column => {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
return [String(column.key), String((_a = column.width) !== null && _a !== void 0 ? _a : ''), String((_b = column.minWidth) !== null && _b !== void 0 ? _b : ''), String((_c = column.maxWidth) !== null && _c !== void 0 ? _c : '')].join(':');
|
|
20
|
+
}).join('|');
|
|
21
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SortOrder, SortOrderFlag, SortState, TableBaseColumn, TableColumn } from '../interface';
|
|
2
|
+
export declare function createShallowClonedObject<T>(object: T): T;
|
|
3
|
+
export declare function getFlagOfOrder(order: SortOrder): SortOrderFlag;
|
|
4
|
+
export declare function shouldUseArrayInSingleMode(column: TableBaseColumn): boolean;
|
|
5
|
+
export declare function createNextSorter(column: TableBaseColumn, currentSortState: SortState | null): SortState | null;
|
|
6
|
+
export declare function isColumnSorting(column: TableColumn, mergedSortState: SortState[]): boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function createShallowClonedObject(object) {
|
|
2
|
+
if (!object) return object;
|
|
3
|
+
if (typeof object === 'object') {
|
|
4
|
+
return Object.assign({}, object);
|
|
5
|
+
}
|
|
6
|
+
return object;
|
|
7
|
+
}
|
|
8
|
+
export function getFlagOfOrder(order) {
|
|
9
|
+
if (order === 'ascend') return 1;else if (order === 'descend') return -1;
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
// for compatibility
|
|
13
|
+
// If column.filterOptionValues or column.defaultFilterOptionValues is set, use
|
|
14
|
+
// array value
|
|
15
|
+
export function shouldUseArrayInSingleMode(column) {
|
|
16
|
+
return column.filterOptionValues !== undefined || column.filterOptionValue === undefined && column.defaultFilterOptionValues !== undefined;
|
|
17
|
+
}
|
|
18
|
+
function getNextOrderOf(order) {
|
|
19
|
+
if (!order) return 'descend';else if (order === 'descend') return 'ascend';
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
export function createNextSorter(column, currentSortState) {
|
|
23
|
+
if (column.sorter === undefined) return null;
|
|
24
|
+
if (currentSortState === null || currentSortState.columnKey !== column.key) {
|
|
25
|
+
return {
|
|
26
|
+
columnKey: column.key,
|
|
27
|
+
sorter: column.sorter,
|
|
28
|
+
order: getNextOrderOf(false)
|
|
29
|
+
};
|
|
30
|
+
} else {
|
|
31
|
+
return Object.assign(Object.assign({}, currentSortState), {
|
|
32
|
+
order: getNextOrderOf(currentSortState.order)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function isColumnSorting(column, mergedSortState) {
|
|
37
|
+
return mergedSortState.some(state => state.columnKey === column.key && state.order);
|
|
38
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ColumnKey, ColumnWidthComputationItem, TableBaseColumn, TableExpandColumn, TableSelectionColumn } from '../interface';
|
|
2
|
+
export interface ColumnWidthConstraint {
|
|
3
|
+
min?: number;
|
|
4
|
+
max?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function clampValueFollowCSSRules(value: number, min?: number | string, max?: number | string): number;
|
|
7
|
+
export declare function parseLengthToNumber(value: number | string | undefined): number | undefined;
|
|
8
|
+
export declare function resolveColumnWidthConstraint(column: TableBaseColumn | TableSelectionColumn | TableExpandColumn | ColumnWidthComputationItem, systemMinWidth?: number | string, systemMaxWidth?: number | string): ColumnWidthConstraint;
|
|
9
|
+
export declare function computeFixedTableColumnWidths(columns: ColumnWidthComputationItem[], { containerWidth, systemMinWidth, systemMaxWidth, preferredWidths }: {
|
|
10
|
+
containerWidth?: number;
|
|
11
|
+
systemMinWidth?: number | string;
|
|
12
|
+
systemMaxWidth?: number | string;
|
|
13
|
+
preferredWidths?: Record<ColumnKey, number>;
|
|
14
|
+
}): Record<ColumnKey, number>;
|
|
15
|
+
export declare function sanitizeColumnWidthMap(columns: ColumnWidthComputationItem[], { systemMinWidth, systemMaxWidth, source }: {
|
|
16
|
+
systemMinWidth?: number | string;
|
|
17
|
+
systemMaxWidth?: number | string;
|
|
18
|
+
source: Record<ColumnKey, number> | undefined;
|
|
19
|
+
}): Record<ColumnKey, number>;
|
|
20
|
+
export declare function areColumnWidthMapsEqual(previousWidths: Record<ColumnKey, number>, nextWidths: Record<ColumnKey, number>, keys: ColumnKey[]): boolean;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const WIDTH_PRECISION = 1000;
|
|
2
|
+
const WIDTH_EPSILON = 1e-6;
|
|
3
|
+
// priority: min-width > max-width > width
|
|
4
|
+
export function clampValueFollowCSSRules(value, min, max) {
|
|
5
|
+
if (max !== undefined) {
|
|
6
|
+
value = Math.min(value, typeof max === 'number' ? max : Number.parseFloat(max));
|
|
7
|
+
}
|
|
8
|
+
if (min !== undefined) {
|
|
9
|
+
value = Math.max(value, typeof min === 'number' ? min : Number.parseFloat(min));
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
export function parseLengthToNumber(value) {
|
|
14
|
+
if (value === undefined) return;
|
|
15
|
+
const parsed = typeof value === 'number' ? value : Number.parseFloat(value);
|
|
16
|
+
if (!Number.isFinite(parsed)) return;
|
|
17
|
+
return parsed;
|
|
18
|
+
}
|
|
19
|
+
function roundWidth(width) {
|
|
20
|
+
return Math.round(width * WIDTH_PRECISION) / WIDTH_PRECISION;
|
|
21
|
+
}
|
|
22
|
+
function normalizeWidthConstraint(min, max) {
|
|
23
|
+
if (min !== undefined && max !== undefined && max < min) {
|
|
24
|
+
return {
|
|
25
|
+
min,
|
|
26
|
+
max: min
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
min,
|
|
31
|
+
max
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function resolveColumnWidthConstraint(column, systemMinWidth, systemMaxWidth) {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
const min = parseLengthToNumber((_a = column.minWidth) !== null && _a !== void 0 ? _a : systemMinWidth);
|
|
37
|
+
const max = parseLengthToNumber((_b = column.maxWidth) !== null && _b !== void 0 ? _b : systemMaxWidth);
|
|
38
|
+
return normalizeWidthConstraint(min, max);
|
|
39
|
+
}
|
|
40
|
+
function clampByConstraint(value, constraint) {
|
|
41
|
+
return clampValueFollowCSSRules(value, constraint.min, constraint.max);
|
|
42
|
+
}
|
|
43
|
+
function normalizeIncomingWidth(value, constraint) {
|
|
44
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) return;
|
|
45
|
+
if (value <= 0) return;
|
|
46
|
+
return roundWidth(clampByConstraint(value, constraint));
|
|
47
|
+
}
|
|
48
|
+
function fillRemainingWidthFrom(widths, constraints, delta, startIndex) {
|
|
49
|
+
if (delta <= 0 || widths.length === 0) return;
|
|
50
|
+
let remaining = delta;
|
|
51
|
+
let cursor = startIndex;
|
|
52
|
+
let blockedTurns = 0;
|
|
53
|
+
while (remaining > WIDTH_EPSILON && blockedTurns < widths.length) {
|
|
54
|
+
const index = (cursor + widths.length) % widths.length;
|
|
55
|
+
const {
|
|
56
|
+
max
|
|
57
|
+
} = constraints[index];
|
|
58
|
+
const current = widths[index];
|
|
59
|
+
const capacity = max === undefined ? Number.POSITIVE_INFINITY : max - current;
|
|
60
|
+
if (capacity > WIDTH_EPSILON) {
|
|
61
|
+
const append = capacity === Number.POSITIVE_INFINITY ? remaining : Math.min(capacity, remaining);
|
|
62
|
+
widths[index] = roundWidth(current + append);
|
|
63
|
+
remaining = roundWidth(remaining - append);
|
|
64
|
+
blockedTurns = 0;
|
|
65
|
+
} else {
|
|
66
|
+
blockedTurns += 1;
|
|
67
|
+
}
|
|
68
|
+
cursor += 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function assignFlexibleWidths(widths, constraints, target, flexibleIndexes) {
|
|
72
|
+
const unresolved = new Set(flexibleIndexes);
|
|
73
|
+
let remainingTarget = target;
|
|
74
|
+
while (unresolved.size > 0) {
|
|
75
|
+
const share = remainingTarget / unresolved.size;
|
|
76
|
+
let didClamp = false;
|
|
77
|
+
for (const index of Array.from(unresolved)) {
|
|
78
|
+
const limited = roundWidth(clampByConstraint(share, constraints[index]));
|
|
79
|
+
if (Math.abs(limited - share) > WIDTH_EPSILON) {
|
|
80
|
+
widths[index] = limited;
|
|
81
|
+
unresolved.delete(index);
|
|
82
|
+
remainingTarget = roundWidth(remainingTarget - limited);
|
|
83
|
+
didClamp = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!didClamp) {
|
|
87
|
+
unresolved.forEach(index => {
|
|
88
|
+
widths[index] = roundWidth(clampByConstraint(share, constraints[index]));
|
|
89
|
+
});
|
|
90
|
+
unresolved.clear();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function computeFixedTableColumnWidths(columns, {
|
|
95
|
+
containerWidth,
|
|
96
|
+
systemMinWidth,
|
|
97
|
+
systemMaxWidth,
|
|
98
|
+
preferredWidths
|
|
99
|
+
}) {
|
|
100
|
+
var _a;
|
|
101
|
+
const constraints = columns.map(column => resolveColumnWidthConstraint(column, systemMinWidth, systemMaxWidth));
|
|
102
|
+
const widths = columns.map((column, index) => {
|
|
103
|
+
const preferred = normalizeIncomingWidth(preferredWidths === null || preferredWidths === void 0 ? void 0 : preferredWidths[column.key], constraints[index]);
|
|
104
|
+
if (preferred !== undefined) return preferred;
|
|
105
|
+
const width = parseLengthToNumber(column.width);
|
|
106
|
+
if (width === undefined) return undefined;
|
|
107
|
+
return roundWidth(clampByConstraint(width, constraints[index]));
|
|
108
|
+
});
|
|
109
|
+
const canFitContainer = containerWidth !== undefined && Number.isFinite(containerWidth) && containerWidth > 0;
|
|
110
|
+
const flexibleIndexes = [];
|
|
111
|
+
widths.forEach((width, index) => {
|
|
112
|
+
if (width === undefined) flexibleIndexes.push(index);
|
|
113
|
+
});
|
|
114
|
+
if (flexibleIndexes.length) {
|
|
115
|
+
if (canFitContainer) {
|
|
116
|
+
const allocated = (_a = widths.reduce((accumulatedWidth = 0, width) => accumulatedWidth + (width !== null && width !== void 0 ? width : 0), 0)) !== null && _a !== void 0 ? _a : 0;
|
|
117
|
+
assignFlexibleWidths(widths, constraints, containerWidth - allocated, flexibleIndexes);
|
|
118
|
+
} else {
|
|
119
|
+
flexibleIndexes.forEach(index => {
|
|
120
|
+
const {
|
|
121
|
+
min,
|
|
122
|
+
max
|
|
123
|
+
} = constraints[index];
|
|
124
|
+
if (min !== undefined) {
|
|
125
|
+
widths[index] = roundWidth(min);
|
|
126
|
+
} else if (max !== undefined) {
|
|
127
|
+
widths[index] = roundWidth(max);
|
|
128
|
+
} else {
|
|
129
|
+
widths[index] = 0;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const normalizedWidths = widths.map((width, index) => {
|
|
135
|
+
const base = width !== null && width !== void 0 ? width : 0;
|
|
136
|
+
return roundWidth(clampByConstraint(base, constraints[index]));
|
|
137
|
+
});
|
|
138
|
+
if (canFitContainer) {
|
|
139
|
+
const totalWidth = normalizedWidths.reduce((accumulatedWidth, width) => accumulatedWidth + width, 0);
|
|
140
|
+
if (totalWidth < containerWidth) {
|
|
141
|
+
fillRemainingWidthFrom(normalizedWidths, constraints, containerWidth - totalWidth, normalizedWidths.length - 1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const result = {};
|
|
145
|
+
columns.forEach((column, index) => {
|
|
146
|
+
result[column.key] = roundWidth(normalizedWidths[index]);
|
|
147
|
+
});
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
export function sanitizeColumnWidthMap(columns, {
|
|
151
|
+
systemMinWidth,
|
|
152
|
+
systemMaxWidth,
|
|
153
|
+
source
|
|
154
|
+
}) {
|
|
155
|
+
if (!source) return {};
|
|
156
|
+
const result = {};
|
|
157
|
+
columns.forEach(column => {
|
|
158
|
+
const constraint = resolveColumnWidthConstraint(column, systemMinWidth, systemMaxWidth);
|
|
159
|
+
const sanitized = normalizeIncomingWidth(source[column.key], constraint);
|
|
160
|
+
if (sanitized !== undefined) {
|
|
161
|
+
result[column.key] = sanitized;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
export function areColumnWidthMapsEqual(previousWidths, nextWidths, keys) {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
for (const key of keys) {
|
|
169
|
+
if (((_a = previousWidths[key]) !== null && _a !== void 0 ? _a : undefined) !== ((_b = nextWidths[key]) !== null && _b !== void 0 ? _b : undefined)) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { CreateRowClassName, InternalRowData, RowData, SortOrder, SortOrderFlag, SortState, TableBaseColumn, TableColumn, TableColumnMaskObject, TableExpandColumn, TableSelectionColumn } from './interface';
|
|
3
|
-
import type { DataTableGetCsvCell, DataTableGetCsvHeader } from './public-types';
|
|
4
|
-
export declare const SELECTION_COL_WIDTH = 40;
|
|
5
|
-
export declare const EXPAND_COL_WIDTH = 40;
|
|
6
|
-
export declare const REGEX: {
|
|
7
|
-
ONLY_DIGITS: RegExp;
|
|
8
|
-
ONLY_NUMERIC_AND_DOT: RegExp;
|
|
9
|
-
};
|
|
10
|
-
export declare const defaultNumericMask: TableColumnMaskObject;
|
|
11
|
-
export declare function getNumberColWidth(col: TableColumn): number | undefined;
|
|
12
|
-
export declare function getStringColWidth(col: TableColumn): string | undefined;
|
|
13
|
-
export declare function getColKey(col: TableColumn): string | number;
|
|
14
|
-
export declare function createShallowClonedObject<T>(object: T): T;
|
|
15
|
-
export declare function getFlagOfOrder(order: SortOrder): SortOrderFlag;
|
|
16
|
-
export declare function clampValueFollowCSSRules(value: number, min?: number | string, max?: number | string): number;
|
|
17
|
-
export declare function createCustomWidthStyle(column: TableBaseColumn | TableSelectionColumn | TableExpandColumn, resizedWidth?: string): CSSProperties;
|
|
18
|
-
export declare function createRowClassName(row: InternalRowData, index: number, rowClassName?: string | CreateRowClassName): string;
|
|
19
|
-
export declare function shouldUseArrayInSingleMode(column: TableBaseColumn): boolean;
|
|
20
|
-
export declare function isColumnSortable(column: TableColumn): boolean;
|
|
21
|
-
export declare function isColumnResizable(column: TableColumn): boolean;
|
|
22
|
-
export declare function isColumnFilterable(column: TableColumn): boolean;
|
|
23
|
-
export declare function createNextSorter(column: TableBaseColumn, currentSortState: SortState | null): SortState | null;
|
|
24
|
-
export declare function isColumnSorting(column: TableColumn, mergedSortState: SortState[]): boolean;
|
|
25
|
-
export declare function generateCsv(columns: TableColumn[], data: RowData[], getCsvCell: DataTableGetCsvCell | undefined, getCsvHeader: DataTableGetCsvHeader | undefined): string;
|
|
1
|
+
export * from './utils/index';
|
|
@@ -1,165 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { formatLength } from "../../_utils/index.mjs";
|
|
3
|
-
export const SELECTION_COL_WIDTH = 40;
|
|
4
|
-
export const EXPAND_COL_WIDTH = 40;
|
|
5
|
-
export const REGEX = {
|
|
6
|
-
ONLY_DIGITS: /\D/g,
|
|
7
|
-
ONLY_NUMERIC_AND_DOT: /[^\d.]/g
|
|
8
|
-
};
|
|
9
|
-
export const defaultNumericMask = {
|
|
10
|
-
postProcess: value => {
|
|
11
|
-
if (!value) return '';
|
|
12
|
-
const isNegative = value.trim().startsWith('-');
|
|
13
|
-
const cleaned = value.replace(/[^\d.,]/g, '').replace(',', '.');
|
|
14
|
-
const [intPartRaw, decimalPartRaw = ''] = cleaned.split('.', 2);
|
|
15
|
-
const intPart = intPartRaw.replace(/\B(?=(\d{3})+(?!\d))/g, ' ');
|
|
16
|
-
const decimalPart = decimalPartRaw.slice(0, 2);
|
|
17
|
-
const result = cleaned.includes('.') ? `${intPart}.${decimalPart}` : intPart;
|
|
18
|
-
return isNegative ? `-${result}` : result;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export function getNumberColWidth(col) {
|
|
22
|
-
if (col.type === 'selection') {
|
|
23
|
-
return col.width === undefined ? SELECTION_COL_WIDTH : depx(col.width);
|
|
24
|
-
}
|
|
25
|
-
if (col.type === 'expand') {
|
|
26
|
-
return col.width === undefined ? EXPAND_COL_WIDTH : depx(col.width);
|
|
27
|
-
}
|
|
28
|
-
if ('children' in col) return undefined;
|
|
29
|
-
if (typeof col.width === 'string') {
|
|
30
|
-
return depx(col.width);
|
|
31
|
-
}
|
|
32
|
-
return col.width;
|
|
33
|
-
}
|
|
34
|
-
export function getStringColWidth(col) {
|
|
35
|
-
var _a, _b;
|
|
36
|
-
if (col.type === 'selection') {
|
|
37
|
-
return formatLength((_a = col.width) !== null && _a !== void 0 ? _a : SELECTION_COL_WIDTH);
|
|
38
|
-
}
|
|
39
|
-
if (col.type === 'expand') {
|
|
40
|
-
return formatLength((_b = col.width) !== null && _b !== void 0 ? _b : EXPAND_COL_WIDTH);
|
|
41
|
-
}
|
|
42
|
-
if ('children' in col) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
return formatLength(col.width);
|
|
46
|
-
}
|
|
47
|
-
export function getColKey(col) {
|
|
48
|
-
if (col.type === 'selection') return '__n_selection__';
|
|
49
|
-
if (col.type === 'expand') return '__n_expand__';
|
|
50
|
-
return col.key;
|
|
51
|
-
}
|
|
52
|
-
export function createShallowClonedObject(object) {
|
|
53
|
-
if (!object) return object;
|
|
54
|
-
if (typeof object === 'object') {
|
|
55
|
-
return Object.assign({}, object);
|
|
56
|
-
}
|
|
57
|
-
return object;
|
|
58
|
-
}
|
|
59
|
-
export function getFlagOfOrder(order) {
|
|
60
|
-
if (order === 'ascend') return 1;else if (order === 'descend') return -1;
|
|
61
|
-
return 0;
|
|
62
|
-
}
|
|
63
|
-
// priority: min-width > max-width > width
|
|
64
|
-
export function clampValueFollowCSSRules(value, min, max) {
|
|
65
|
-
if (max !== undefined) {
|
|
66
|
-
value = Math.min(value, typeof max === 'number' ? max : Number.parseFloat(max));
|
|
67
|
-
}
|
|
68
|
-
if (min !== undefined) {
|
|
69
|
-
value = Math.max(value, typeof min === 'number' ? min : Number.parseFloat(min));
|
|
70
|
-
}
|
|
71
|
-
return value;
|
|
72
|
-
}
|
|
73
|
-
export function createCustomWidthStyle(column, resizedWidth) {
|
|
74
|
-
var _a;
|
|
75
|
-
if (resizedWidth !== undefined) {
|
|
76
|
-
const numWidth = depx(resizedWidth);
|
|
77
|
-
const minMaxColumn = column && 'minWidth' in column && 'maxWidth' in column ? column : null;
|
|
78
|
-
const clampedNum = minMaxColumn ? clampValueFollowCSSRules(numWidth, minMaxColumn.minWidth, minMaxColumn.maxWidth) : numWidth;
|
|
79
|
-
const clamped = formatLength(clampedNum);
|
|
80
|
-
return {
|
|
81
|
-
width: clamped,
|
|
82
|
-
minWidth: clamped,
|
|
83
|
-
maxWidth: clamped
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
const explicitNum = (_a = getNumberColWidth(column)) !== null && _a !== void 0 ? _a : undefined;
|
|
87
|
-
const minWidth = column && 'minWidth' in column ? column.minWidth : undefined;
|
|
88
|
-
const maxWidth = column && 'maxWidth' in column ? column.maxWidth : undefined;
|
|
89
|
-
let widthNum = explicitNum;
|
|
90
|
-
if (widthNum === undefined && (minWidth !== undefined || maxWidth !== undefined)) {
|
|
91
|
-
widthNum = clampValueFollowCSSRules(maxWidth !== undefined ? typeof maxWidth === 'number' ? maxWidth : Number.parseFloat(maxWidth) : minWidth !== undefined ? typeof minWidth === 'number' ? minWidth : Number.parseFloat(minWidth) : 0, minWidth, maxWidth);
|
|
92
|
-
} else if (widthNum !== undefined && (minWidth !== undefined || maxWidth !== undefined)) {
|
|
93
|
-
widthNum = clampValueFollowCSSRules(widthNum, minWidth, maxWidth);
|
|
94
|
-
}
|
|
95
|
-
const width = widthNum !== undefined ? formatLength(widthNum) : getStringColWidth(column);
|
|
96
|
-
return {
|
|
97
|
-
width,
|
|
98
|
-
minWidth: formatLength(minWidth) || width,
|
|
99
|
-
maxWidth: formatLength(maxWidth)
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
export function createRowClassName(row, index, rowClassName) {
|
|
103
|
-
if (typeof rowClassName === 'function') return rowClassName(row, index);
|
|
104
|
-
return rowClassName || '';
|
|
105
|
-
}
|
|
106
|
-
// for compatibility
|
|
107
|
-
// If column.filterOptionValues or column.defaultFilterOptionValues is set, use
|
|
108
|
-
// array value
|
|
109
|
-
export function shouldUseArrayInSingleMode(column) {
|
|
110
|
-
return column.filterOptionValues !== undefined || column.filterOptionValue === undefined && column.defaultFilterOptionValues !== undefined;
|
|
111
|
-
}
|
|
112
|
-
export function isColumnSortable(column) {
|
|
113
|
-
if ('children' in column) return false;
|
|
114
|
-
return !!column.sorter;
|
|
115
|
-
}
|
|
116
|
-
export function isColumnResizable(column) {
|
|
117
|
-
if ('children' in column && !!column.children.length) return false;
|
|
118
|
-
return !!column.resizable;
|
|
119
|
-
}
|
|
120
|
-
export function isColumnFilterable(column) {
|
|
121
|
-
if ('children' in column) return false;
|
|
122
|
-
return !!column.filter && (!!column.filterOptions || !!column.renderFilterMenu);
|
|
123
|
-
}
|
|
124
|
-
function getNextOrderOf(order) {
|
|
125
|
-
if (!order) return 'descend';else if (order === 'descend') return 'ascend';
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
export function createNextSorter(column, currentSortState) {
|
|
129
|
-
if (column.sorter === undefined) return null;
|
|
130
|
-
if (currentSortState === null || currentSortState.columnKey !== column.key) {
|
|
131
|
-
return {
|
|
132
|
-
columnKey: column.key,
|
|
133
|
-
sorter: column.sorter,
|
|
134
|
-
order: getNextOrderOf(false)
|
|
135
|
-
};
|
|
136
|
-
} else {
|
|
137
|
-
return Object.assign(Object.assign({}, currentSortState), {
|
|
138
|
-
order: getNextOrderOf(currentSortState.order)
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
export function isColumnSorting(column, mergedSortState) {
|
|
143
|
-
return mergedSortState.find(state => state.columnKey === column.key && state.order) !== undefined;
|
|
144
|
-
}
|
|
145
|
-
function formatCsvCell(value) {
|
|
146
|
-
if (typeof value === 'string') {
|
|
147
|
-
return value.replace(/,/g, '\\,');
|
|
148
|
-
} else if (value === null || value === undefined) {
|
|
149
|
-
return '';
|
|
150
|
-
} else {
|
|
151
|
-
return `${value}`.replace(/,/g, '\\,');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
export function generateCsv(columns, data, getCsvCell, getCsvHeader) {
|
|
155
|
-
const exportableColumns = columns.filter(column => column.type !== 'expand' && column.type !== 'selection' && column.allowExport !== false);
|
|
156
|
-
const header = exportableColumns.map(col => {
|
|
157
|
-
return getCsvHeader ? getCsvHeader(col) : col.title;
|
|
158
|
-
}).join(',');
|
|
159
|
-
const rows = data.map(row => {
|
|
160
|
-
return exportableColumns.map(col => {
|
|
161
|
-
return getCsvCell ? getCsvCell(row[col.key], row, col) : formatCsvCell(row[col.key]);
|
|
162
|
-
}).join(',');
|
|
163
|
-
});
|
|
164
|
-
return [header, ...rows].join('\n');
|
|
165
|
-
}
|
|
1
|
+
export * from "./utils/index.mjs";
|
package/es/grid/src/Grid.d.ts
CHANGED
|
@@ -96,11 +96,11 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
96
96
|
readonly default: 0;
|
|
97
97
|
};
|
|
98
98
|
}>> & Readonly<{}>, {
|
|
99
|
+
readonly cols: string | number;
|
|
99
100
|
readonly responsive: "self" | "screen";
|
|
100
101
|
readonly collapsed: boolean;
|
|
101
102
|
readonly xGap: string | number;
|
|
102
103
|
readonly yGap: string | number;
|
|
103
|
-
readonly cols: string | number;
|
|
104
104
|
readonly layoutShiftDisabled: boolean;
|
|
105
105
|
readonly itemResponsive: boolean;
|
|
106
106
|
readonly collapsedRows: number;
|
|
@@ -75,7 +75,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
75
75
|
}>> & Readonly<{}>, {
|
|
76
76
|
readonly loading: boolean;
|
|
77
77
|
readonly results: HeaderSearchResult[];
|
|
78
|
-
readonly version: "
|
|
78
|
+
readonly version: "mobile" | "desktop";
|
|
79
79
|
readonly query: string;
|
|
80
80
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
81
81
|
export default _default;
|
|
@@ -119,7 +119,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
119
119
|
cols: number;
|
|
120
120
|
}, any>>>;
|
|
121
121
|
}>> & Readonly<{}>, {
|
|
122
|
-
readonly items: IconBarItemProps[];
|
|
123
122
|
readonly cols: number;
|
|
123
|
+
readonly items: IconBarItemProps[];
|
|
124
124
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
125
125
|
export default _default;
|
package/es/input/src/Input.d.ts
CHANGED
|
@@ -1134,10 +1134,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
1134
1134
|
defaultValue: string | [string, string] | null;
|
|
1135
1135
|
round: boolean;
|
|
1136
1136
|
loadingSkeleton: boolean;
|
|
1137
|
+
rows: string | number;
|
|
1137
1138
|
stateful: boolean;
|
|
1138
1139
|
resizable: boolean;
|
|
1139
1140
|
pair: boolean;
|
|
1140
|
-
rows: string | number;
|
|
1141
1141
|
autosize: boolean | {
|
|
1142
1142
|
minRows?: number;
|
|
1143
1143
|
maxRows?: number;
|