@astral/ui 4.62.2 → 4.64.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/components/ConfirmDialog/ConfirmDialog.js +2 -2
- package/components/ConfirmDialog/types.d.ts +2 -2
- package/components/DataGrid/Body/styles.js +4 -0
- package/components/DataGrid/Cell/Cell.d.ts +6 -2
- package/components/DataGrid/Cell/Cell.js +18 -2
- package/components/DataGrid/Cell/constants.d.ts +6 -0
- package/components/DataGrid/Cell/constants.js +6 -0
- package/components/DataGrid/Cell/index.d.ts +1 -0
- package/components/DataGrid/Cell/index.js +1 -0
- package/components/DataGrid/Cell/styles.d.ts +1 -8
- package/components/DataGrid/Cell/styles.js +43 -8
- package/components/DataGrid/DataGrid.js +11 -2
- package/components/DataGrid/Head/Head.js +14 -30
- package/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.d.ts +14 -0
- package/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.js +4 -0
- package/components/DataGrid/Head/HeadColumns/GroupColumns/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/GroupColumns/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.d.ts +9 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.js +9 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.d.ts +5 -0
- package/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.js +9 -0
- package/components/DataGrid/Head/HeadColumns/HeadColumns.d.ts +41 -0
- package/components/DataGrid/Head/HeadColumns/HeadColumns.js +26 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.d.ts +13 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.js +3 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/SingleColumn/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/styles.d.ts +5 -0
- package/components/DataGrid/Head/HeadColumns/styles.js +9 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/useLogic.d.ts +12 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/useLogic.js +46 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.d.ts +6 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.js +19 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/useLogic/utils/index.js +1 -0
- package/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.d.ts +18 -0
- package/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.js +17 -0
- package/components/DataGrid/Head/HeadColumns/utils/index.d.ts +1 -0
- package/components/DataGrid/Head/HeadColumns/utils/index.js +1 -0
- package/components/DataGrid/Head/styles.d.ts +0 -4
- package/components/DataGrid/Head/styles.js +2 -8
- package/components/DataGrid/HeadCell/HeadCell.d.ts +11 -0
- package/components/DataGrid/HeadCell/HeadCell.js +21 -3
- package/components/DataGrid/HeadCell/constants.d.ts +11 -0
- package/components/DataGrid/HeadCell/constants.js +12 -0
- package/components/DataGrid/HeadCell/index.d.ts +1 -0
- package/components/DataGrid/HeadCell/index.js +1 -0
- package/components/DataGrid/HeadCell/styles.d.ts +1 -8
- package/components/DataGrid/HeadCell/styles.js +24 -7
- package/components/DataGrid/HeadCell/useLogic/useLogic.d.ts +5 -5
- package/components/DataGrid/HeadCell/useLogic/useLogic.js +8 -5
- package/components/DataGrid/PinnedSections/Section/styles.js +4 -0
- package/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +2 -2
- package/components/DataGrid/PinnedSections/styles.js +8 -4
- package/components/DataGrid/PinnedSections/useLogic/useLogic.js +10 -5
- package/components/DataGrid/Row/Row.js +22 -3
- package/components/DataGrid/Row/constants.d.ts +8 -0
- package/components/DataGrid/Row/constants.js +8 -0
- package/components/DataGrid/Row/styles.d.ts +10 -0
- package/components/DataGrid/Row/styles.js +15 -2
- package/components/DataGrid/constants.d.ts +4 -1
- package/components/DataGrid/constants.js +4 -1
- package/components/DataGrid/faker.js +13 -9
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/styles.js +84 -2
- package/components/DataGrid/types.d.ts +38 -1
- package/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.d.ts +2 -2
- package/components/DataGrid/useLogic/useLogic.d.ts +3 -1
- package/components/DataGrid/useLogic/useLogic.js +10 -6
- package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +1 -1
- package/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +17 -10
- package/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.d.ts +2 -0
- package/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.js +13 -0
- package/components/DataGrid/utils/getFlattenColumns/index.d.ts +1 -0
- package/components/DataGrid/utils/getFlattenColumns/index.js +1 -0
- package/components/DataGrid/utils/index.d.ts +2 -1
- package/components/DataGrid/utils/index.js +2 -1
- package/components/DataGrid/utils/isGroupColumns/index.d.ts +1 -0
- package/components/DataGrid/utils/isGroupColumns/index.js +1 -0
- package/components/DataGrid/utils/isGroupColumns/isGroupColumns.d.ts +2 -0
- package/components/DataGrid/utils/isGroupColumns/isGroupColumns.js +3 -0
- package/components/DataGridInfinite/DataGridInfinite.js +15 -3
- package/components/DataGridInfinite/useLogic/useLogic.d.ts +4 -1
- package/components/DataGridInfinite/useLogic/useLogic.js +10 -4
- package/components/Dialog/Dialog.d.ts +2 -24
- package/components/Dialog/Dialog.js +18 -11
- package/components/Dialog/constants.d.ts +5 -0
- package/components/Dialog/constants.js +6 -0
- package/components/Dialog/index.d.ts +2 -1
- package/components/Dialog/index.js +1 -1
- package/components/Dialog/public.d.ts +2 -1
- package/components/Dialog/public.js +1 -1
- package/components/Dialog/styles.js +11 -4
- package/components/Dialog/types.d.ts +23 -0
- package/components/Dialog/types.js +1 -0
- package/components/Dialog/useLogic/index.js +1 -0
- package/components/Dialog/useLogic/useLogic.d.ts +25 -0
- package/components/Dialog/useLogic/useLogic.js +19 -0
- package/components/PageLayoutContainer/PageLayoutContainer.js +2 -2
- package/components/PageLayoutContainer/styles.d.ts +1 -1
- package/components/PageLayoutContainer/styles.js +1 -1
- package/components/ResizingDataGrid/hooks/useComputedColumns/useComputedColumns.d.ts +1 -1
- package/components/ResizingDataGrid/hooks/useComputedColumns/utils/createComputedColumns/createComputedColumns.d.ts +2 -2
- package/components/ResizingDataGrid/types.d.ts +2 -2
- package/node/components/ConfirmDialog/ConfirmDialog.js +2 -2
- package/node/components/ConfirmDialog/types.d.ts +2 -2
- package/node/components/DataGrid/Body/styles.js +4 -0
- package/node/components/DataGrid/Cell/Cell.d.ts +6 -2
- package/node/components/DataGrid/Cell/Cell.js +18 -2
- package/node/components/DataGrid/Cell/constants.d.ts +6 -0
- package/node/components/DataGrid/Cell/constants.js +6 -0
- package/node/components/DataGrid/Cell/index.d.ts +1 -0
- package/node/components/DataGrid/Cell/index.js +3 -0
- package/node/components/DataGrid/Cell/styles.d.ts +1 -8
- package/node/components/DataGrid/Cell/styles.js +43 -8
- package/node/components/DataGrid/DataGrid.js +11 -2
- package/node/components/DataGrid/Head/Head.js +12 -28
- package/node/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.d.ts +14 -0
- package/node/components/DataGrid/Head/HeadColumns/GroupColumns/GroupColumns.js +8 -0
- package/node/components/DataGrid/Head/HeadColumns/GroupColumns/index.d.ts +1 -0
- package/node/components/DataGrid/{utils/alignToJustifyContent → Head/HeadColumns/GroupColumns}/index.js +1 -1
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.d.ts +9 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/HeadCellStartAdornment.js +13 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.d.ts +5 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadCellStartAdornment/styles.js +12 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadColumns.d.ts +41 -0
- package/node/components/DataGrid/Head/HeadColumns/HeadColumns.js +30 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.d.ts +13 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/SingleColumn.js +7 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/SingleColumn/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/styles.d.ts +5 -0
- package/node/components/DataGrid/Head/HeadColumns/styles.js +12 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/useLogic.d.ts +12 -0
- package/node/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/useLogic.js +25 -9
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.d.ts +6 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/getGridPositions.js +23 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/getGridPositions/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/useLogic/utils/index.js +17 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.d.ts +18 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/getHeadCellProps.js +21 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/index.d.ts +1 -0
- package/node/components/DataGrid/Head/HeadColumns/utils/index.js +17 -0
- package/node/components/DataGrid/Head/styles.d.ts +0 -4
- package/node/components/DataGrid/Head/styles.js +3 -9
- package/node/components/DataGrid/HeadCell/HeadCell.d.ts +11 -0
- package/node/components/DataGrid/HeadCell/HeadCell.js +21 -3
- package/node/components/DataGrid/HeadCell/constants.d.ts +11 -0
- package/node/components/DataGrid/HeadCell/constants.js +15 -0
- package/node/components/DataGrid/HeadCell/index.d.ts +1 -0
- package/node/components/DataGrid/HeadCell/index.js +3 -0
- package/node/components/DataGrid/HeadCell/styles.d.ts +1 -8
- package/node/components/DataGrid/HeadCell/styles.js +24 -7
- package/node/components/DataGrid/HeadCell/useLogic/useLogic.d.ts +5 -5
- package/node/components/DataGrid/HeadCell/useLogic/useLogic.js +8 -5
- package/node/components/DataGrid/PinnedSections/Section/styles.js +4 -0
- package/node/components/DataGrid/PinnedSections/Section/useLogic/useLogic.js +1 -1
- package/node/components/DataGrid/PinnedSections/styles.js +8 -4
- package/node/components/DataGrid/PinnedSections/useLogic/useLogic.js +10 -5
- package/node/components/DataGrid/Row/Row.js +21 -2
- package/node/components/DataGrid/Row/constants.d.ts +8 -0
- package/node/components/DataGrid/Row/constants.js +9 -1
- package/node/components/DataGrid/Row/styles.d.ts +10 -0
- package/node/components/DataGrid/Row/styles.js +15 -2
- package/node/components/DataGrid/constants.d.ts +4 -1
- package/node/components/DataGrid/constants.js +4 -1
- package/node/components/DataGrid/faker.js +13 -9
- package/node/components/DataGrid/index.d.ts +1 -1
- package/node/components/DataGrid/styles.js +93 -11
- package/node/components/DataGrid/types.d.ts +38 -1
- package/node/components/DataGrid/useLogic/hooks/useDataGridMobileLogic/useDataGridMobileLogic.d.ts +2 -2
- package/node/components/DataGrid/useLogic/useLogic.d.ts +3 -1
- package/node/components/DataGrid/useLogic/useLogic.js +9 -5
- package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.d.ts +1 -1
- package/node/components/DataGrid/useLogic/utils/getColumnSections/getColumnSections.js +17 -10
- package/node/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.d.ts +2 -0
- package/node/components/DataGrid/utils/getFlattenColumns/getFlattenColumns.js +17 -0
- package/node/components/DataGrid/utils/getFlattenColumns/index.d.ts +1 -0
- package/node/components/DataGrid/utils/getFlattenColumns/index.js +5 -0
- package/node/components/DataGrid/utils/index.d.ts +2 -1
- package/node/components/DataGrid/utils/index.js +5 -3
- package/node/components/DataGrid/utils/isGroupColumns/index.d.ts +1 -0
- package/node/components/DataGrid/utils/isGroupColumns/index.js +17 -0
- package/node/components/DataGrid/utils/isGroupColumns/isGroupColumns.d.ts +2 -0
- package/node/components/DataGrid/utils/isGroupColumns/isGroupColumns.js +7 -0
- package/node/components/DataGridInfinite/DataGridInfinite.js +15 -3
- package/node/components/DataGridInfinite/useLogic/useLogic.d.ts +4 -1
- package/node/components/DataGridInfinite/useLogic/useLogic.js +9 -3
- package/node/components/Dialog/Dialog.d.ts +2 -24
- package/node/components/Dialog/Dialog.js +18 -11
- package/node/components/Dialog/constants.d.ts +5 -0
- package/node/components/Dialog/constants.js +7 -1
- package/node/components/Dialog/index.d.ts +2 -1
- package/node/components/Dialog/index.js +2 -1
- package/node/components/Dialog/public.d.ts +2 -1
- package/node/components/Dialog/public.js +2 -1
- package/node/components/Dialog/styles.js +12 -25
- package/node/components/Dialog/types.d.ts +23 -0
- package/node/components/Dialog/types.js +2 -0
- package/node/components/Dialog/useLogic/index.d.ts +1 -0
- package/node/components/Dialog/useLogic/index.js +17 -0
- package/node/components/Dialog/useLogic/useLogic.d.ts +25 -0
- package/node/components/Dialog/useLogic/useLogic.js +23 -0
- package/node/components/PageLayoutContainer/PageLayoutContainer.js +1 -1
- package/node/components/PageLayoutContainer/styles.d.ts +1 -1
- package/node/components/PageLayoutContainer/styles.js +2 -2
- package/node/components/ResizingDataGrid/hooks/useComputedColumns/useComputedColumns.d.ts +1 -1
- package/node/components/ResizingDataGrid/hooks/useComputedColumns/utils/createComputedColumns/createComputedColumns.d.ts +2 -2
- package/node/components/ResizingDataGrid/types.d.ts +2 -2
- package/package.json +1 -1
- package/components/DataGrid/Head/useLogic/useLogic.d.ts +0 -12
- package/components/DataGrid/Head/useLogic/useLogic.js +0 -30
- package/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.d.ts +0 -5
- package/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.js +0 -7
- package/components/DataGrid/utils/alignToJustifyContent/constants.d.ts +0 -6
- package/components/DataGrid/utils/alignToJustifyContent/constants.js +0 -6
- package/components/DataGrid/utils/alignToJustifyContent/index.d.ts +0 -1
- package/components/DataGrid/utils/alignToJustifyContent/index.js +0 -1
- package/node/components/DataGrid/Head/useLogic/useLogic.d.ts +0 -12
- package/node/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.d.ts +0 -5
- package/node/components/DataGrid/utils/alignToJustifyContent/alignToJustifyContent.js +0 -11
- package/node/components/DataGrid/utils/alignToJustifyContent/constants.d.ts +0 -6
- package/node/components/DataGrid/utils/alignToJustifyContent/constants.js +0 -9
- package/node/components/DataGrid/utils/alignToJustifyContent/index.d.ts +0 -1
- /package/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/index.d.ts +0 -0
- /package/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/index.js +0 -0
- /package/{node/components/DataGrid/Head → components/Dialog}/useLogic/index.d.ts +0 -0
- /package/node/components/DataGrid/Head/{useLogic → HeadColumns/useLogic}/index.js +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ChangeEvent } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridColumns, type DataGridRow, type DataGridSort } from '../../types';
|
|
3
|
+
export type HeadColumnsProps<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = {
|
|
4
|
+
/**
|
|
5
|
+
* Конфигурация колонок для таблицы
|
|
6
|
+
*/
|
|
7
|
+
columns: DataGridColumns<TData>[];
|
|
8
|
+
/**
|
|
9
|
+
* Если true, то будет отображаться чекбокс для выбора элемента
|
|
10
|
+
*/
|
|
11
|
+
isSelectable: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Параметры сортируемой колонки
|
|
14
|
+
*/
|
|
15
|
+
sorting?: DataGridSort<TSortField>;
|
|
16
|
+
/**
|
|
17
|
+
* Общее количество строк, доступных для выбора
|
|
18
|
+
*/
|
|
19
|
+
rowsCount: number;
|
|
20
|
+
/**
|
|
21
|
+
* Количество строк, которые не выбраны
|
|
22
|
+
*/
|
|
23
|
+
uncheckedRowsCount: number;
|
|
24
|
+
/**
|
|
25
|
+
* Обработчик выбора всех строк
|
|
26
|
+
*/
|
|
27
|
+
onSelectAllRows: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Обработчик сортировки
|
|
30
|
+
*/
|
|
31
|
+
onSort?: (sorting: DataGridSort<TSortField> | undefined) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Используется для скрытия чекбокса "Выбрать все"
|
|
34
|
+
*/
|
|
35
|
+
isHideSelectAll?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Смещение секции
|
|
38
|
+
*/
|
|
39
|
+
sectionOffset?: number;
|
|
40
|
+
};
|
|
41
|
+
export declare const HeadColumns: <TData extends Record<string, unknown>, TSortField extends keyof TData>(props: HeadColumnsProps<TData, TSortField>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HeadColumns = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("../../utils");
|
|
6
|
+
const GroupColumns_1 = require("./GroupColumns");
|
|
7
|
+
const HeadCellStartAdornment_1 = require("./HeadCellStartAdornment");
|
|
8
|
+
const SingleColumn_1 = require("./SingleColumn");
|
|
9
|
+
const useLogic_1 = require("./useLogic");
|
|
10
|
+
const utils_2 = require("./utils");
|
|
11
|
+
const HeadColumns = (props) => {
|
|
12
|
+
const { checkboxProps, handleSort, gridPositions } = (0, useLogic_1.useLogic)(props);
|
|
13
|
+
const { columns, isSelectable, sorting, isHideSelectAll, sectionOffset } = props;
|
|
14
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: columns.map((column, index) => {
|
|
15
|
+
const { label, align, columnHint, field, sortable, showCheckbox } = (0, utils_2.getHeadCellProps)({
|
|
16
|
+
column,
|
|
17
|
+
index,
|
|
18
|
+
sectionOffset,
|
|
19
|
+
isSelectable,
|
|
20
|
+
isHideSelectAll,
|
|
21
|
+
});
|
|
22
|
+
const startAdornment = showCheckbox || columnHint ? ((0, jsx_runtime_1.jsx)(HeadCellStartAdornment_1.HeadCellStartAdornment, { showCheckbox: showCheckbox, columnHint: columnHint, checkboxProps: checkboxProps })) : undefined;
|
|
23
|
+
if ((0, utils_1.isGroupColumns)(column)) {
|
|
24
|
+
const position = gridPositions.get(column.label);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(GroupColumns_1.GroupColumns, { column: column, sorting: sorting, onSort: handleSort, gridPosition: position, startAdornment: startAdornment }, column.label));
|
|
26
|
+
}
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(SingleColumn_1.SingleColumn, { sorting: sorting, field: field, label: label, isSortable: sortable, align: align, startAdornment: startAdornment, onSort: handleSort }, label));
|
|
28
|
+
}) }));
|
|
29
|
+
};
|
|
30
|
+
exports.HeadColumns = HeadColumns;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type CellValue, type DataGridRow, type DataGridSort } from '../../../types';
|
|
3
|
+
type SingleColumnProps<TData extends Record<string, CellValue> = DataGridRow, TSortField extends keyof TData = keyof TData> = {
|
|
4
|
+
field?: keyof TData;
|
|
5
|
+
label?: string;
|
|
6
|
+
isSortable?: boolean;
|
|
7
|
+
align?: 'left' | 'center' | 'right';
|
|
8
|
+
sorting?: DataGridSort<TSortField>;
|
|
9
|
+
onSort: (field: TSortField) => void;
|
|
10
|
+
startAdornment?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare const SingleColumn: <TData extends Record<string, unknown>, TSortField extends keyof TData>({ field, label, isSortable, align, sorting, onSort, startAdornment, }: SingleColumnProps<TData, TSortField>) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SingleColumn = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const HeadCell_1 = require("../../../HeadCell");
|
|
6
|
+
const SingleColumn = ({ field, label, isSortable, align, sorting, onSort, startAdornment, }) => ((0, jsx_runtime_1.jsx)(HeadCell_1.HeadCell, { sorting: sorting, field: field, label: label, isSortable: isSortable, align: align, startAdornment: startAdornment, onSort: onSort, className: HeadCell_1.headCellClassnames.singleColumn }));
|
|
7
|
+
exports.SingleColumn = SingleColumn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SingleColumn';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./SingleColumn"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './HeadColumns';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./HeadColumns"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const CheckboxCell: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
3
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
4
|
+
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CheckboxCell = void 0;
|
|
4
|
+
const styled_1 = require("../../../styled");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
exports.CheckboxCell = styled_1.styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
|
|
11
|
+
width: ${constants_1.ROOT_ACTION_CELL_WIDTH}px;
|
|
12
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useLogic';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import { type CheckboxProps } from '../../../../Checkbox';
|
|
3
|
+
import { type DataGridRow } from '../../../types';
|
|
4
|
+
import { type HeadColumnsProps } from '../HeadColumns';
|
|
5
|
+
import { type GridPositions } from './utils';
|
|
6
|
+
export declare const useLogic: <TData extends Record<string, unknown> = DataGridRow, TSortField extends keyof TData = keyof TData>({ columns, onSort, sorting, uncheckedRowsCount, rowsCount, onSelectAllRows, }: HeadColumnsProps<TData, TSortField>) => {
|
|
7
|
+
checkboxProps: CheckboxProps;
|
|
8
|
+
handleSort: (field: TSortField) => void;
|
|
9
|
+
gridPositions: Map<string | keyof TData, GridPositions>;
|
|
10
|
+
headerCssVars: (position?: GridPositions) => CSSProperties;
|
|
11
|
+
hasGroupedColumns: boolean;
|
|
12
|
+
};
|
|
@@ -2,33 +2,49 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
const
|
|
5
|
+
const utils_1 = require("../../../utils");
|
|
6
|
+
const utils_2 = require("./utils");
|
|
7
|
+
const useLogic = ({ columns, onSort, sorting, uncheckedRowsCount, rowsCount, onSelectAllRows, }) => {
|
|
6
8
|
const isChecked = (0, react_1.useMemo)(() => !uncheckedRowsCount && rowsCount > 0, [uncheckedRowsCount, rowsCount]);
|
|
7
9
|
const isIndeterminate = (0, react_1.useMemo)(() => uncheckedRowsCount > 0 && uncheckedRowsCount < rowsCount, [uncheckedRowsCount, rowsCount]);
|
|
8
10
|
const isDisabled = !rowsCount;
|
|
11
|
+
const checkboxProps = (0, react_1.useMemo)(() => ({
|
|
12
|
+
checked: isChecked,
|
|
13
|
+
disabled: isDisabled,
|
|
14
|
+
indeterminate: isIndeterminate,
|
|
15
|
+
onChange: onSelectAllRows,
|
|
16
|
+
}), [isChecked, isDisabled, isIndeterminate, onSelectAllRows]);
|
|
9
17
|
const handleSort = (0, react_1.useCallback)((field) => {
|
|
10
18
|
if (!onSort) {
|
|
11
19
|
return;
|
|
12
20
|
}
|
|
13
21
|
const isCurrentField = sorting?.fieldId === field;
|
|
14
|
-
// если для выбранного столбца текущая сортировка ASC - меняем на DESC
|
|
15
22
|
if (isCurrentField && sorting?.sort === 'asc') {
|
|
16
23
|
return onSort({ fieldId: field, sort: 'desc' });
|
|
17
24
|
}
|
|
18
|
-
// если для выбранного столбца текущая сортировка DESC - убираем сортировку
|
|
19
25
|
if (isCurrentField && sorting?.sort === 'desc') {
|
|
20
26
|
return onSort(undefined);
|
|
21
27
|
}
|
|
22
|
-
// если для выбранного столбца нет сортировки - добавляем сортировку ASC
|
|
23
28
|
onSort({ fieldId: field, sort: 'asc' });
|
|
24
29
|
}, [sorting, onSort]);
|
|
30
|
+
const gridPositions = (0, react_1.useMemo)(() => {
|
|
31
|
+
return (0, utils_2.getGridPositions)(columns);
|
|
32
|
+
}, [columns]);
|
|
33
|
+
const headerCssVars = (0, react_1.useCallback)((position) => {
|
|
34
|
+
if (!position) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
'--grid-column-start': position.start,
|
|
39
|
+
'--grid-column-end': position.end,
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
25
42
|
return {
|
|
43
|
+
checkboxProps,
|
|
26
44
|
handleSort,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
indeterminate: isIndeterminate,
|
|
31
|
-
},
|
|
45
|
+
gridPositions,
|
|
46
|
+
headerCssVars,
|
|
47
|
+
hasGroupedColumns: columns.some(utils_1.isGroupColumns),
|
|
32
48
|
};
|
|
33
49
|
};
|
|
34
50
|
exports.useLogic = useLogic;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type DataGridColumns } from '../../../../../types';
|
|
2
|
+
export type GridPositions = {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const getGridPositions: <TData extends Record<string, unknown>>(columns: DataGridColumns<TData>[]) => Map<string | keyof TData, GridPositions>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGridPositions = void 0;
|
|
4
|
+
const utils_1 = require("../../../../../utils");
|
|
5
|
+
const getGridPositions = (columns) => {
|
|
6
|
+
const { positionsMap } = columns.reduce((acc, column) => {
|
|
7
|
+
// Ширина колонки: количество детей для группы или 1 для обычной ячейки
|
|
8
|
+
const width = (0, utils_1.isGroupColumns)(column) ? column.children.length : 1;
|
|
9
|
+
const start = acc.currentLine;
|
|
10
|
+
const end = start + width;
|
|
11
|
+
const key = (0, utils_1.isGroupColumns)(column)
|
|
12
|
+
? column.label
|
|
13
|
+
: column.field || column.label || '';
|
|
14
|
+
acc.positionsMap.set(key, { start, end });
|
|
15
|
+
acc.currentLine = end;
|
|
16
|
+
return acc;
|
|
17
|
+
}, {
|
|
18
|
+
positionsMap: new Map(),
|
|
19
|
+
currentLine: 1,
|
|
20
|
+
});
|
|
21
|
+
return positionsMap;
|
|
22
|
+
};
|
|
23
|
+
exports.getGridPositions = getGridPositions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getGridPositions';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getGridPositions"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getGridPositions';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getGridPositions"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { type CellValue, type DataGridColumns } from '../../../types';
|
|
3
|
+
type Params<TData extends Record<string, CellValue>> = {
|
|
4
|
+
column: DataGridColumns<TData>;
|
|
5
|
+
index: number;
|
|
6
|
+
sectionOffset?: number;
|
|
7
|
+
isSelectable: boolean;
|
|
8
|
+
isHideSelectAll?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const getHeadCellProps: <TData extends Record<string, unknown>>({ column, index, sectionOffset, isSelectable, isHideSelectAll, }: Params<TData>) => {
|
|
11
|
+
label: string | undefined;
|
|
12
|
+
align: import("../../../types").AlignVariant | undefined;
|
|
13
|
+
columnHint: import("react").ReactNode;
|
|
14
|
+
field: keyof TData | undefined;
|
|
15
|
+
sortable: boolean | undefined;
|
|
16
|
+
showCheckbox: boolean;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getHeadCellProps = void 0;
|
|
4
|
+
const utils_1 = require("../../../utils");
|
|
5
|
+
const getHeadCellProps = ({ column, index, sectionOffset, isSelectable, isHideSelectAll, }) => {
|
|
6
|
+
const { label, align, columnHint } = column;
|
|
7
|
+
const field = (0, utils_1.isGroupColumns)(column) ? undefined : column.field;
|
|
8
|
+
const sortable = (0, utils_1.isGroupColumns)(column) ? undefined : column.sortable;
|
|
9
|
+
const globalIndex = (sectionOffset ?? 0) + index;
|
|
10
|
+
const isFirstCell = globalIndex === 0;
|
|
11
|
+
const showCheckbox = isFirstCell && isSelectable && !isHideSelectAll;
|
|
12
|
+
return {
|
|
13
|
+
label,
|
|
14
|
+
align,
|
|
15
|
+
columnHint,
|
|
16
|
+
field,
|
|
17
|
+
sortable,
|
|
18
|
+
showCheckbox,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
exports.getHeadCellProps = getHeadCellProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './getHeadCellProps';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./getHeadCellProps"), exports);
|
|
@@ -5,7 +5,3 @@ export declare const Wrapper: import("@emotion/styled/dist/declarations/src/type
|
|
|
5
5
|
} & {
|
|
6
6
|
$gridColumns: string;
|
|
7
7
|
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLElement>, HTMLElement>, {}>;
|
|
8
|
-
export declare const CheckboxCell: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
9
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
10
|
-
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
11
|
-
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Wrapper = void 0;
|
|
4
|
+
const scrollbar_1 = require("../../constants/scrollbar");
|
|
4
5
|
const styled_1 = require("../../styled");
|
|
5
|
-
const constants_1 = require("../constants");
|
|
6
6
|
exports.Wrapper = (0, styled_1.styled)('header', {
|
|
7
7
|
shouldForwardProp: (prop) => !['$gridColumns'].includes(prop),
|
|
8
8
|
}) `
|
|
@@ -11,6 +11,7 @@ exports.Wrapper = (0, styled_1.styled)('header', {
|
|
|
11
11
|
|
|
12
12
|
width: fit-content;
|
|
13
13
|
min-width: 100%;
|
|
14
|
+
padding-right: ${scrollbar_1.SCROLLBAR_SIZE};
|
|
14
15
|
|
|
15
16
|
border-bottom: 1px solid ${({ theme }) => theme.palette.components.border.default};
|
|
16
17
|
|
|
@@ -18,10 +19,3 @@ exports.Wrapper = (0, styled_1.styled)('header', {
|
|
|
18
19
|
display: none;
|
|
19
20
|
}
|
|
20
21
|
`;
|
|
21
|
-
exports.CheckboxCell = styled_1.styled.div `
|
|
22
|
-
display: flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
|
|
26
|
-
width: ${constants_1.ROOT_ACTION_CELL_WIDTH}px;
|
|
27
|
-
`;
|
|
@@ -14,5 +14,16 @@ export type HeadCellProps<TData = DataGridRow, TSortField extends keyof TData =
|
|
|
14
14
|
* Дополнительное содержимое ячейки, которое будет распложено справа
|
|
15
15
|
*/
|
|
16
16
|
startAdornment?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Класс применяемый к корневому элементу
|
|
19
|
+
*/
|
|
20
|
+
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Позиция ячейки в сетке CSS Grid
|
|
23
|
+
*/
|
|
24
|
+
gridPosition?: {
|
|
25
|
+
start: number;
|
|
26
|
+
end: number;
|
|
27
|
+
};
|
|
17
28
|
};
|
|
18
29
|
export declare const HeadCell: <TData, TSortField extends keyof TData>(props: HeadCellProps<TData, TSortField>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,11 +7,29 @@ const SortDownFillSm_1 = require("../../../icons/SortDownFillSm");
|
|
|
7
7
|
const SortFillSm_1 = require("../../../icons/SortFillSm");
|
|
8
8
|
const SortUpFillSm_1 = require("../../../icons/SortUpFillSm");
|
|
9
9
|
const OverflowTypography_1 = require("../../OverflowTypography");
|
|
10
|
+
const classNames_1 = require("../../utils/classNames");
|
|
11
|
+
const cva_1 = require("../../utils/cva");
|
|
12
|
+
const constants_1 = require("./constants");
|
|
10
13
|
const styles_1 = require("./styles");
|
|
11
14
|
const useLogic_1 = require("./useLogic");
|
|
15
|
+
const headCellCva = (0, cva_1.cva)(constants_1.headCellClassnames.root, {
|
|
16
|
+
variants: {
|
|
17
|
+
isSortable: {
|
|
18
|
+
true: constants_1.headCellClassnames.sortable,
|
|
19
|
+
},
|
|
20
|
+
align: {
|
|
21
|
+
left: constants_1.headCellClassnames.alignLeft,
|
|
22
|
+
center: constants_1.headCellClassnames.alignCenter,
|
|
23
|
+
right: constants_1.headCellClassnames.alignRight,
|
|
24
|
+
},
|
|
25
|
+
hasStartAdornment: {
|
|
26
|
+
true: constants_1.headCellClassnames.hasStartAdornment,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
});
|
|
12
30
|
const HeadCell = (props) => {
|
|
13
|
-
const {
|
|
14
|
-
const { startAdornment, field, isSortable, align, label, sorting } = props;
|
|
31
|
+
const { hasStartAdornment, handleSortClick, headCellCssVars } = (0, useLogic_1.useLogic)(props);
|
|
32
|
+
const { startAdornment, field, isSortable, align, label, sorting, className, } = props;
|
|
15
33
|
const sortIcon = (0, react_1.useMemo)(() => {
|
|
16
34
|
if (!isSortable) {
|
|
17
35
|
return null;
|
|
@@ -28,6 +46,6 @@ const HeadCell = (props) => {
|
|
|
28
46
|
return (0, jsx_runtime_1.jsx)(SortFillSm_1.SortFillSm, {});
|
|
29
47
|
}
|
|
30
48
|
}, [sorting, isSortable, field]);
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, {
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(styles_1.Wrapper, { onClick: handleSortClick, className: (0, classNames_1.classNames)(className, headCellCva({ isSortable, align, hasStartAdornment })), style: headCellCssVars, children: [startAdornment && startAdornment, (0, jsx_runtime_1.jsx)(OverflowTypography_1.OverflowTypography, { rowsCount: 2, variant: "pointer", component: "p", children: label }), sortIcon] }));
|
|
32
50
|
};
|
|
33
51
|
exports.HeadCell = HeadCell;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.headCellClassnames = void 0;
|
|
4
|
+
const createUIKitClassname_1 = require("../../utils/createUIKitClassname");
|
|
5
|
+
exports.headCellClassnames = {
|
|
6
|
+
root: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell'),
|
|
7
|
+
groupParent: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_group-parent'),
|
|
8
|
+
groupChild: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_group-child'),
|
|
9
|
+
singleColumn: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_single-column'),
|
|
10
|
+
alignLeft: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_align-left'),
|
|
11
|
+
alignCenter: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_align-center'),
|
|
12
|
+
alignRight: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_align-right'),
|
|
13
|
+
hasStartAdornment: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_has-start-adornment'),
|
|
14
|
+
sortable: (0, createUIKitClassname_1.createUIKitClassname)('data-grid__head-cell_sortable'),
|
|
15
|
+
};
|
|
@@ -14,4 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.headCellClassnames = void 0;
|
|
17
18
|
__exportStar(require("./HeadCell"), exports);
|
|
19
|
+
var constants_1 = require("./constants");
|
|
20
|
+
Object.defineProperty(exports, "headCellClassnames", { enumerable: true, get: function () { return constants_1.headCellClassnames; } });
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { AlignVariant } from '../types';
|
|
3
|
-
type HeadCellProps = {
|
|
4
|
-
$align?: AlignVariant;
|
|
5
|
-
$isSortable?: boolean;
|
|
6
|
-
$hasStartAdornment?: boolean;
|
|
7
|
-
};
|
|
8
2
|
export declare const Wrapper: import("@emotion/styled/dist/declarations/src/types").StyledComponent<{
|
|
9
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
10
4
|
as?: import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
5
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
@@ -3,20 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Wrapper = void 0;
|
|
4
4
|
const HintIcon_1 = require("../../HintIcon");
|
|
5
5
|
const styled_1 = require("../../styled");
|
|
6
|
-
const
|
|
7
|
-
exports.Wrapper =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
exports.Wrapper = styled_1.styled.div `
|
|
8
|
+
--grid-column-start: 0;
|
|
9
|
+
--grid-column-end: 0;
|
|
10
|
+
|
|
11
|
+
cursor: initial;
|
|
11
12
|
user-select: none;
|
|
12
13
|
|
|
13
14
|
overflow: hidden;
|
|
14
15
|
display: flex;
|
|
15
16
|
align-items: center;
|
|
16
|
-
justify-content:
|
|
17
|
+
justify-content: flex-start;
|
|
17
18
|
|
|
18
19
|
height: 40px;
|
|
19
|
-
padding: ${({ theme
|
|
20
|
+
padding: ${({ theme }) => theme.spacing(1, 2)};
|
|
20
21
|
|
|
21
22
|
color: ${({ theme }) => theme.palette.grey[700]};
|
|
22
23
|
|
|
@@ -25,6 +26,22 @@ exports.Wrapper = (0, styled_1.styled)('div', {
|
|
|
25
26
|
height: 16px;
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
&.${constants_1.headCellClassnames.sortable} {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&.${constants_1.headCellClassnames.hasStartAdornment} {
|
|
34
|
+
padding: ${({ theme }) => theme.spacing(1, 2, 1, 0)};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&.${constants_1.headCellClassnames.alignCenter} {
|
|
38
|
+
justify-content: center;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.${constants_1.headCellClassnames.alignRight} {
|
|
42
|
+
justify-content: flex-end;
|
|
43
|
+
}
|
|
44
|
+
|
|
28
45
|
.${HintIcon_1.hintIconClassnames.iconWrapper} {
|
|
29
46
|
margin-right: ${({ theme }) => theme.spacing(1)};
|
|
30
47
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
1
2
|
import type { DataGridRow } from '../../types';
|
|
2
3
|
import { type HeadCellProps } from '../HeadCell';
|
|
3
4
|
type UseLogicParams<TData = DataGridRow, TSortField extends keyof TData = keyof TData> = HeadCellProps<TData, TSortField>;
|
|
4
|
-
export declare const useLogic: <TData, TSortField extends keyof TData>({ field, isSortable, startAdornment, onSort, }: UseLogicParams<TData, TSortField>) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
5
|
+
export declare const useLogic: <TData, TSortField extends keyof TData>({ gridPosition, field, isSortable, startAdornment, onSort, }: UseLogicParams<TData, TSortField>) => {
|
|
6
|
+
hasStartAdornment: boolean;
|
|
7
|
+
handleSortClick: () => void;
|
|
8
|
+
headCellCssVars: CSSProperties;
|
|
9
9
|
};
|
|
10
10
|
export {};
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useLogic = void 0;
|
|
4
|
-
const useLogic = ({ field, isSortable, startAdornment, onSort, }) => {
|
|
4
|
+
const useLogic = ({ gridPosition, field, isSortable, startAdornment, onSort, }) => {
|
|
5
5
|
const hasStartAdornment = Boolean(startAdornment);
|
|
6
6
|
const handleSortClick = () => {
|
|
7
7
|
if (field && isSortable) {
|
|
8
8
|
onSort(field);
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
|
+
const headCellCssVars = {
|
|
12
|
+
'--grid-column-start': gridPosition?.start,
|
|
13
|
+
'--grid-column-end': gridPosition?.end,
|
|
14
|
+
};
|
|
11
15
|
return {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
+
hasStartAdornment,
|
|
17
|
+
handleSortClick,
|
|
18
|
+
headCellCssVars,
|
|
16
19
|
};
|
|
17
20
|
};
|
|
18
21
|
exports.useLogic = useLogic;
|