@cloud-ru/ds-table 2.2.9 → 2.2.11-preview-2f5fa273.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +14 -286
- package/dist/cjs/components/ServerTable/ServerTable.js +1 -1
- package/dist/cjs/components/Table/Table.d.ts +1 -1
- package/dist/cjs/components/Table/Table.js +3 -2
- package/dist/cjs/components/Table/hooks/useTableInstance.d.ts +2 -1
- package/dist/cjs/components/Table/hooks/useTableInstance.js +2 -1
- package/dist/cjs/components/Table/styles.module.css +3 -3
- package/dist/cjs/components/types.d.ts +4 -1
- package/dist/cjs/helperComponents/Cells/RowActionsCell/styles.module.css +2 -0
- package/dist/cjs/helperComponents/Cells/TreeCell/styles.module.css +1 -1
- package/dist/cjs/helperComponents/LoadMoreButton/styles.module.css +2 -1
- package/dist/cjs/helperComponents/TablePagination/TablePagination.js +24 -2
- package/dist/cjs/helperComponents/TablePagination/styles.module.css +7 -0
- package/dist/cjs/locale/index.d.ts +16 -0
- package/dist/cjs/locale/index.js +8 -0
- package/dist/cjs/presets/index.d.ts +0 -2
- package/dist/cjs/presets/index.js +0 -2
- package/dist/cjs/presets/simpleTable/toSimpleTableProps.d.ts +1 -3
- package/dist/cjs/presets/simpleTable/toSimpleTableProps.js +5 -5
- package/dist/cjs/presets/simpleTable/useSimpleTableProps.js +1 -4
- package/dist/cjs/style.css +15 -5
- package/dist/esm/components/ServerTable/ServerTable.js +1 -1
- package/dist/esm/components/Table/Table.d.ts +1 -1
- package/dist/esm/components/Table/Table.js +3 -2
- package/dist/esm/components/Table/hooks/useTableInstance.d.ts +2 -1
- package/dist/esm/components/Table/hooks/useTableInstance.js +2 -1
- package/dist/esm/components/Table/styles.module.css +3 -3
- package/dist/esm/components/types.d.ts +4 -1
- package/dist/esm/helperComponents/Cells/RowActionsCell/styles.module.css +2 -0
- package/dist/esm/helperComponents/Cells/TreeCell/styles.module.css +1 -1
- package/dist/esm/helperComponents/LoadMoreButton/styles.module.css +2 -1
- package/dist/esm/helperComponents/TablePagination/TablePagination.js +24 -2
- package/dist/esm/helperComponents/TablePagination/styles.module.css +7 -0
- package/dist/esm/locale/index.d.ts +16 -0
- package/dist/esm/locale/index.js +8 -0
- package/dist/esm/presets/index.d.ts +0 -2
- package/dist/esm/presets/index.js +0 -2
- package/dist/esm/presets/simpleTable/toSimpleTableProps.d.ts +1 -3
- package/dist/esm/presets/simpleTable/toSimpleTableProps.js +5 -5
- package/dist/esm/presets/simpleTable/useSimpleTableProps.js +1 -4
- package/dist/esm/style.css +15 -5
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/components/ServerTable/ServerTable.tsx +1 -0
- package/src/components/Table/STRUCTURE.md +12 -6
- package/src/components/Table/Table.tsx +3 -1
- package/src/components/Table/hooks/useTableInstance.tsx +3 -0
- package/src/components/types.ts +4 -1
- package/src/helperComponents/Cells/RowActionsCell/styles.module.scss +4 -0
- package/src/helperComponents/Cells/TreeCell/styles.module.scss +1 -11
- package/src/helperComponents/LoadMoreButton/styles.module.scss +2 -1
- package/src/helperComponents/TablePagination/TablePagination.tsx +64 -5
- package/src/helperComponents/TablePagination/styles.module.scss +7 -0
- package/src/locale/index.ts +8 -0
- package/src/presets/index.ts +0 -2
- package/src/presets/simpleTable/toSimpleTableProps.ts +6 -21
- package/src/presets/simpleTable/useSimpleTableProps.ts +1 -5
- package/dist/cjs/presets/adminTable/AdminTable.d.ts +0 -4
- package/dist/cjs/presets/adminTable/AdminTable.js +0 -11
- package/dist/cjs/presets/adminTable/index.d.ts +0 -4
- package/dist/cjs/presets/adminTable/index.js +0 -9
- package/dist/cjs/presets/adminTable/toAdminTableProps.d.ts +0 -31
- package/dist/cjs/presets/adminTable/toAdminTableProps.js +0 -57
- package/dist/cjs/presets/adminTable/useAdminTableProps.d.ts +0 -5
- package/dist/cjs/presets/adminTable/useAdminTableProps.js +0 -25
- package/dist/cjs/presets/serverAdminTable/ServerAdminTable.d.ts +0 -4
- package/dist/cjs/presets/serverAdminTable/ServerAdminTable.js +0 -11
- package/dist/cjs/presets/serverAdminTable/index.d.ts +0 -4
- package/dist/cjs/presets/serverAdminTable/index.js +0 -9
- package/dist/cjs/presets/serverAdminTable/toServerAdminTableProps.d.ts +0 -13
- package/dist/cjs/presets/serverAdminTable/toServerAdminTableProps.js +0 -25
- package/dist/cjs/presets/serverAdminTable/useServerAdminTableProps.d.ts +0 -5
- package/dist/cjs/presets/serverAdminTable/useServerAdminTableProps.js +0 -25
- package/dist/esm/presets/adminTable/AdminTable.d.ts +0 -4
- package/dist/esm/presets/adminTable/AdminTable.js +0 -8
- package/dist/esm/presets/adminTable/index.d.ts +0 -4
- package/dist/esm/presets/adminTable/index.js +0 -3
- package/dist/esm/presets/adminTable/toAdminTableProps.d.ts +0 -31
- package/dist/esm/presets/adminTable/toAdminTableProps.js +0 -54
- package/dist/esm/presets/adminTable/useAdminTableProps.d.ts +0 -5
- package/dist/esm/presets/adminTable/useAdminTableProps.js +0 -22
- package/dist/esm/presets/serverAdminTable/ServerAdminTable.d.ts +0 -4
- package/dist/esm/presets/serverAdminTable/ServerAdminTable.js +0 -8
- package/dist/esm/presets/serverAdminTable/index.d.ts +0 -4
- package/dist/esm/presets/serverAdminTable/index.js +0 -3
- package/dist/esm/presets/serverAdminTable/toServerAdminTableProps.d.ts +0 -13
- package/dist/esm/presets/serverAdminTable/toServerAdminTableProps.js +0 -22
- package/dist/esm/presets/serverAdminTable/useServerAdminTableProps.d.ts +0 -5
- package/dist/esm/presets/serverAdminTable/useServerAdminTableProps.js +0 -22
- package/src/presets/adminTable/AdminTable.tsx +0 -14
- package/src/presets/adminTable/index.ts +0 -4
- package/src/presets/adminTable/toAdminTableProps.ts +0 -140
- package/src/presets/adminTable/useAdminTableProps.ts +0 -35
- package/src/presets/serverAdminTable/ServerAdminTable.tsx +0 -14
- package/src/presets/serverAdminTable/index.ts +0 -4
- package/src/presets/serverAdminTable/toServerAdminTableProps.ts +0 -44
- package/src/presets/serverAdminTable/useServerAdminTableProps.ts +0 -35
|
@@ -5,12 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TablePagination = TablePagination;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const adaptive_1 = require("@cloud-ru/ds-adaptive");
|
|
9
|
+
const button_1 = require("@cloud-ru/ds-button");
|
|
8
10
|
const chips_1 = require("@cloud-ru/ds-chips");
|
|
11
|
+
const system_1 = require("@cloud-ru/ds-icons/interface/system");
|
|
9
12
|
const pagination_1 = require("@cloud-ru/ds-pagination");
|
|
10
13
|
const react_1 = require("react");
|
|
11
14
|
const locale_1 = require("../../locale");
|
|
12
15
|
const styles_module_scss_1 = __importDefault(require('./styles.module.css'));
|
|
16
|
+
const MAX_PAGE_OPTIONS = 1000;
|
|
13
17
|
function TablePagination({ table, options: optionsProp, optionsLabel: optionsLabelProp, optionsRender, view, }) {
|
|
18
|
+
const { layoutType } = (0, adaptive_1.useAdaptiveLayout)();
|
|
19
|
+
const mobile = (0, adaptive_1.isMobileLayout)(layoutType);
|
|
14
20
|
const { t } = locale_1.tableLocale.useTranslations();
|
|
15
21
|
const optionsLabel = optionsLabelProp ?? t('rowsOptionsLabel');
|
|
16
22
|
const handlePaginationOnChange = (0, react_1.useCallback)((pageIndex) => {
|
|
@@ -27,8 +33,24 @@ function TablePagination({ table, options: optionsProp, optionsLabel: optionsLab
|
|
|
27
33
|
value: String(value),
|
|
28
34
|
})), [optionsProp, optionsRender]);
|
|
29
35
|
const tablePaginationState = table.getState().pagination;
|
|
30
|
-
|
|
36
|
+
const pageCount = table.getPageCount();
|
|
37
|
+
const currentPage = tablePaginationState.pageIndex + 1;
|
|
38
|
+
const hasKnownPageCount = Number.isSafeInteger(pageCount) && pageCount >= 0;
|
|
39
|
+
const showPagination = !hasKnownPageCount || pageCount > 1;
|
|
40
|
+
const showPagePicker = mobile && hasKnownPageCount && pageCount > 1 && pageCount <= MAX_PAGE_OPTIONS;
|
|
41
|
+
const useCompactPagination = mobile || !hasKnownPageCount;
|
|
42
|
+
const pageOptions = (0, react_1.useMemo)(() => showPagePicker
|
|
43
|
+
? Array.from({ length: pageCount }, (_, index) => {
|
|
44
|
+
const page = String(index + 1);
|
|
45
|
+
return { label: page, value: page };
|
|
46
|
+
})
|
|
47
|
+
: [], [showPagePicker, pageCount]);
|
|
48
|
+
if (!showPagination && !options?.length) {
|
|
31
49
|
return null;
|
|
32
50
|
}
|
|
33
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.footer, "data-view": view, children: [
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: styles_module_scss_1.default.footer, "data-view": view, children: [showPagination && useCompactPagination && ((0, jsx_runtime_1.jsxs)("nav", { className: styles_module_scss_1.default.mobilePagination, "aria-label": t('pagination'), children: [(0, jsx_runtime_1.jsx)(button_1.Button, { size: 's', view: 'function', appearance: 'neutral', icon: (0, jsx_runtime_1.jsx)(system_1.ChevronLeftSVG, {}), "aria-label": t('previousPage'), disabled: !table.getCanPreviousPage(), onClick: () => table.previousPage() }), showPagePicker && ((0, jsx_runtime_1.jsx)(chips_1.ChipChoice.Single, { label: t('page'), value: String(currentPage), options: pageOptions, onChange: value => {
|
|
52
|
+
if (value !== undefined) {
|
|
53
|
+
handlePaginationOnChange(Number(value));
|
|
54
|
+
}
|
|
55
|
+
}, size: 's' })), (0, jsx_runtime_1.jsx)(button_1.Button, { size: 's', view: 'function', appearance: 'neutral', icon: (0, jsx_runtime_1.jsx)(system_1.ChevronRightSVG, {}), "aria-label": t('nextPage'), disabled: !table.getCanNextPage(), onClick: () => table.nextPage() })] })), showPagination && !useCompactPagination && ((0, jsx_runtime_1.jsx)(pagination_1.Pagination, { total: pageCount, page: currentPage, onChange: handlePaginationOnChange, size: 's', className: styles_module_scss_1.default.pagination })), options && options.length > 0 && (mobile || table.getRowCount() >= Number(options[0].value)) && ((0, jsx_runtime_1.jsx)(chips_1.ChipChoice.Single, { value: String(tablePaginationState.pageSize), onChange: value => handleRowsVolumeOnChange(String(value)), placement: 'top-end', options: options, label: optionsLabel, widthStrategy: 'eq', size: 's' }))] }));
|
|
34
56
|
}
|
|
@@ -2,6 +2,10 @@ declare const TABLE_MESSAGES: {
|
|
|
2
2
|
readonly 'en-GB': {
|
|
3
3
|
readonly searchPlaceholder: "Search";
|
|
4
4
|
readonly rowsOptionsLabel: "Rows volume";
|
|
5
|
+
readonly pagination: "Pagination";
|
|
6
|
+
readonly page: "Page";
|
|
7
|
+
readonly previousPage: "Previous page";
|
|
8
|
+
readonly nextPage: "Next page";
|
|
5
9
|
readonly settingsHeaderLabel: "Columns settings";
|
|
6
10
|
readonly sort: "Sort";
|
|
7
11
|
readonly clearSort: "Clear sorting";
|
|
@@ -26,6 +30,10 @@ declare const TABLE_MESSAGES: {
|
|
|
26
30
|
readonly 'ru-RU': {
|
|
27
31
|
readonly searchPlaceholder: "Поиск";
|
|
28
32
|
readonly rowsOptionsLabel: "Строк на странице";
|
|
33
|
+
readonly pagination: "Навигация по страницам";
|
|
34
|
+
readonly page: "Страница";
|
|
35
|
+
readonly previousPage: "Предыдущая страница";
|
|
36
|
+
readonly nextPage: "Следующая страница";
|
|
29
37
|
readonly settingsHeaderLabel: "Настройки колонок";
|
|
30
38
|
readonly sort: "Сортировка";
|
|
31
39
|
readonly clearSort: "Сбросить сортировку";
|
|
@@ -54,6 +62,10 @@ export declare const tableLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
|
54
62
|
readonly 'en-GB': {
|
|
55
63
|
readonly searchPlaceholder: "Search";
|
|
56
64
|
readonly rowsOptionsLabel: "Rows volume";
|
|
65
|
+
readonly pagination: "Pagination";
|
|
66
|
+
readonly page: "Page";
|
|
67
|
+
readonly previousPage: "Previous page";
|
|
68
|
+
readonly nextPage: "Next page";
|
|
57
69
|
readonly settingsHeaderLabel: "Columns settings";
|
|
58
70
|
readonly sort: "Sort";
|
|
59
71
|
readonly clearSort: "Clear sorting";
|
|
@@ -78,6 +90,10 @@ export declare const tableLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
|
78
90
|
readonly 'ru-RU': {
|
|
79
91
|
readonly searchPlaceholder: "Поиск";
|
|
80
92
|
readonly rowsOptionsLabel: "Строк на странице";
|
|
93
|
+
readonly pagination: "Навигация по страницам";
|
|
94
|
+
readonly page: "Страница";
|
|
95
|
+
readonly previousPage: "Предыдущая страница";
|
|
96
|
+
readonly nextPage: "Следующая страница";
|
|
81
97
|
readonly settingsHeaderLabel: "Настройки колонок";
|
|
82
98
|
readonly sort: "Сортировка";
|
|
83
99
|
readonly clearSort: "Сбросить сортировку";
|
package/dist/cjs/locale/index.js
CHANGED
|
@@ -6,6 +6,10 @@ const TABLE_MESSAGES = (0, locale_1.defineMessages)({
|
|
|
6
6
|
'en-GB': {
|
|
7
7
|
searchPlaceholder: 'Search',
|
|
8
8
|
rowsOptionsLabel: 'Rows volume',
|
|
9
|
+
pagination: 'Pagination',
|
|
10
|
+
page: 'Page',
|
|
11
|
+
previousPage: 'Previous page',
|
|
12
|
+
nextPage: 'Next page',
|
|
9
13
|
settingsHeaderLabel: 'Columns settings',
|
|
10
14
|
sort: 'Sort',
|
|
11
15
|
clearSort: 'Clear sorting',
|
|
@@ -30,6 +34,10 @@ const TABLE_MESSAGES = (0, locale_1.defineMessages)({
|
|
|
30
34
|
'ru-RU': {
|
|
31
35
|
searchPlaceholder: 'Поиск',
|
|
32
36
|
rowsOptionsLabel: 'Строк на странице',
|
|
37
|
+
pagination: 'Навигация по страницам',
|
|
38
|
+
page: 'Страница',
|
|
39
|
+
previousPage: 'Предыдущая страница',
|
|
40
|
+
nextPage: 'Следующая страница',
|
|
33
41
|
settingsHeaderLabel: 'Настройки колонок',
|
|
34
42
|
sort: 'Сортировка',
|
|
35
43
|
clearSort: 'Сбросить сортировку',
|
|
@@ -14,10 +14,8 @@ 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
|
-
__exportStar(require("./adminTable"), exports);
|
|
18
17
|
__exportStar(require("./entitiesTable"), exports);
|
|
19
18
|
__exportStar(require("./infiniteTable"), exports);
|
|
20
|
-
__exportStar(require("./serverAdminTable"), exports);
|
|
21
19
|
__exportStar(require("./serverSimpleTable"), exports);
|
|
22
20
|
__exportStar(require("./simpleTable"), exports);
|
|
23
21
|
__exportStar(require("./treeTable"), exports);
|
|
@@ -6,10 +6,8 @@ export type SimpleTableInput<TData extends object> = CardViewInput<TData> & {
|
|
|
6
6
|
data: TData[];
|
|
7
7
|
/** Декларативное описание колонок */
|
|
8
8
|
columns: SimpleColumnDef<TData>[];
|
|
9
|
-
/** Количество строк на страницу @default 10 */
|
|
10
|
-
pageSize?: number;
|
|
11
9
|
/** Стабильный идентификатор строки */
|
|
12
10
|
getRowId?: (row: TData) => string;
|
|
13
|
-
} & Omit<ClientTableProps<TData>, 'data' | 'columnDefinitions' | 'getRowId' | 'headlineId'>;
|
|
11
|
+
} & Omit<ClientTableProps<TData>, 'data' | 'columnDefinitions' | 'getRowId' | 'headlineId' | 'pageSize'>;
|
|
14
12
|
/** Маппинг упрощённых пропсов в `ClientTableProps` для `Table` */
|
|
15
13
|
export declare function toSimpleTableProps<TData extends object>(input: SimpleTableInput<TData>): ClientTableProps<TData>;
|
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toSimpleTableProps = toSimpleTableProps;
|
|
4
4
|
const columnUtils_1 = require("../../columnUtils");
|
|
5
|
-
const constants_1 = require("../../constants");
|
|
6
|
-
const constants_2 = require("../constants");
|
|
7
5
|
const wrapGetRowId_1 = require("../wrapGetRowId");
|
|
8
6
|
/** Маппинг упрощённых пропсов в `ClientTableProps` для `Table` */
|
|
9
7
|
function toSimpleTableProps(input) {
|
|
10
|
-
const { data, columns,
|
|
8
|
+
const { data, columns, getRowId, headlineKey, defaultView, view, onViewChange, renderCard, outline, ...rest } = input;
|
|
11
9
|
return {
|
|
12
10
|
...rest,
|
|
13
11
|
...(0, columnUtils_1.mapCardViewProps)({ headlineKey, defaultView, view, onViewChange, renderCard }),
|
|
14
12
|
data,
|
|
15
13
|
columnDefinitions: (0, columnUtils_1.defineColumns)(columns),
|
|
16
14
|
outline: outline ?? true,
|
|
17
|
-
pageSize:
|
|
18
|
-
|
|
15
|
+
pageSize: Math.max(data.length, 1),
|
|
16
|
+
manualPagination: true,
|
|
17
|
+
suppressToolbar: true,
|
|
18
|
+
suppressPagination: true,
|
|
19
19
|
getRowId: (0, wrapGetRowId_1.wrapGetRowId)(getRowId),
|
|
20
20
|
};
|
|
21
21
|
}
|
|
@@ -3,19 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useSimpleTableProps = useSimpleTableProps;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const columnUtils_1 = require("../../columnUtils");
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
6
|
const wrapGetRowId_1 = require("../wrapGetRowId");
|
|
8
7
|
const toSimpleTableProps_1 = require("./toSimpleTableProps");
|
|
9
8
|
/** Возвращает готовые пропсы для `Table` из упрощённого API `SimpleTable` */
|
|
10
9
|
function useSimpleTableProps(input) {
|
|
11
|
-
const { columns, getRowId
|
|
10
|
+
const { columns, getRowId } = input;
|
|
12
11
|
const columnDefinitions = (0, react_1.useMemo)(() => (0, columnUtils_1.defineColumns)(columns), [columns]);
|
|
13
12
|
const wrappedGetRowId = (0, react_1.useMemo)(() => (0, wrapGetRowId_1.wrapGetRowId)(getRowId), [getRowId]);
|
|
14
|
-
const defaultPagination = (0, react_1.useMemo)(() => ({ options: [...constants_1.DEFAULT_PRESET_PAGINATION_OPTIONS] }), []);
|
|
15
13
|
return {
|
|
16
14
|
...(0, toSimpleTableProps_1.toSimpleTableProps)(input),
|
|
17
15
|
columnDefinitions,
|
|
18
16
|
getRowId: wrappedGetRowId,
|
|
19
|
-
pagination: pagination ?? defaultPagination,
|
|
20
17
|
};
|
|
21
18
|
}
|
package/dist/cjs/style.css
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
max-width:100%;
|
|
9
9
|
min-height:0;
|
|
10
10
|
max-height:100%;
|
|
11
|
-
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-
|
|
11
|
+
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-8, 8px));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.wrapper[data-view=cards]{
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.wrapper[data-sticky-controls][data-layout-type=mobile] .stickyFooter{
|
|
56
|
-
padding-top:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-
|
|
56
|
+
padding-top:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-8, 8px));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.wrapper[data-sticky-controls][data-layout-type=mobile][data-view=cards] .stickyFooter{
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
flex-direction:column;
|
|
67
67
|
min-width:0;
|
|
68
68
|
min-height:0;
|
|
69
|
-
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-
|
|
69
|
+
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-8, 8px));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
.wrapper[data-view=cards] .tableView{
|
|
@@ -798,6 +798,7 @@
|
|
|
798
798
|
height:var(--sn-density-icon-xs, var(--sn-platform-comfort-icon-xs, var(--sn-primitive-dimension-24, 24px))) !important;
|
|
799
799
|
}
|
|
800
800
|
.rowActionsHeader{
|
|
801
|
+
max-width:var(--sn-table-anatomy-content-headLine-actionWrapper-maxWidth, var(--sn-table-anatomy-content-tableLine-actionWrapper-maxWidth, var(--sn-primitive-dimension-40, 40px)));
|
|
801
802
|
padding:0 !important;
|
|
802
803
|
}
|
|
803
804
|
|
|
@@ -808,6 +809,7 @@
|
|
|
808
809
|
|
|
809
810
|
.rowActionsCell{
|
|
810
811
|
position:relative;
|
|
812
|
+
max-width:var(--sn-table-anatomy-content-tableLine-actionWrapper-maxWidth, var(--sn-primitive-dimension-40, 40px));
|
|
811
813
|
}
|
|
812
814
|
|
|
813
815
|
.rowActionsCellWrap{
|
|
@@ -990,7 +992,7 @@
|
|
|
990
992
|
flex-shrink:0;
|
|
991
993
|
align-items:center;
|
|
992
994
|
box-sizing:border-box;
|
|
993
|
-
width:var(--sn-table-anatomy-content-
|
|
995
|
+
width:var(--sn-table-anatomy-content-tableLineTree-pinnedWrapper-elementWrapper-cellToggles-width, var(--sn-density-icon-s, var(--sn-platform-comfort-icon-s, var(--sn-primitive-dimension-24, 24px))));
|
|
994
996
|
height:100%;
|
|
995
997
|
padding-left:var(--sn-table-anatomy-content-tableLine-pinnedWrapper-elementWrapper-cellToggles-paddingLeft, var(--sn-density-table-headToggleOffset, var(--sn-platform-comfort-spacing-headToggleOffset, var(--sn-primitive-dimension-0, 0px))));
|
|
996
998
|
}
|
|
@@ -1235,7 +1237,8 @@
|
|
|
1235
1237
|
display:flex;
|
|
1236
1238
|
justify-content:center;
|
|
1237
1239
|
box-sizing:border-box;
|
|
1238
|
-
padding:var(--sn-primitive-dimension-8, 8px)
|
|
1240
|
+
padding-top:var(--sn-table-anatomy-view-loadTrigger-paddingVertical, var(--sn-primitive-dimension-8, 8px));
|
|
1241
|
+
padding-bottom:var(--sn-table-anatomy-view-loadTrigger-paddingVertical, var(--sn-primitive-dimension-8, 8px));
|
|
1239
1242
|
}
|
|
1240
1243
|
.tableRow[data-fit-content]{
|
|
1241
1244
|
width:-moz-fit-content;
|
|
@@ -1560,6 +1563,13 @@
|
|
|
1560
1563
|
.footer[data-view=cards] .pagination{
|
|
1561
1564
|
flex:1;
|
|
1562
1565
|
}
|
|
1566
|
+
|
|
1567
|
+
.mobilePagination{
|
|
1568
|
+
display:flex;
|
|
1569
|
+
gap:var(--sn-primitive-dimension-4, 4px);
|
|
1570
|
+
align-items:center;
|
|
1571
|
+
margin-right:auto;
|
|
1572
|
+
}
|
|
1563
1573
|
@charset "UTF-8";
|
|
1564
1574
|
.root{
|
|
1565
1575
|
cursor:pointer;
|
|
@@ -33,7 +33,7 @@ export function ServerTable({ items, total = DEFAULT_PAGINATION_LIMIT, limit = D
|
|
|
33
33
|
onChange: handleSearch,
|
|
34
34
|
loading: searchProp?.loading,
|
|
35
35
|
placeholder: searchProp?.placeholder,
|
|
36
|
-
}, columnFilters: columnFilters, pageCount: pageCount, pagination: {
|
|
36
|
+
}, columnFilters: columnFilters, pageCount: pageCount, rowCount: total, pagination: {
|
|
37
37
|
...pagination,
|
|
38
38
|
state: {
|
|
39
39
|
pageIndex,
|
|
@@ -4,7 +4,7 @@ import { TableLayoutDefaults, TableProps } from '../types.js';
|
|
|
4
4
|
/** DS-пресет адаптива `Table`: mobile-дефолты sticky-хрома, `fullWidth` и стартовый вид `cards`. Desktop — `BASE_TABLE_LAYOUT_DEFAULTS`. */
|
|
5
5
|
export declare const TABLE_LAYOUT_PRESETS: LayoutPresets<TableLayoutDefaults>;
|
|
6
6
|
/** Компонент таблицы */
|
|
7
|
-
export declare function Table<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize, pageCount, loading, infiniteLoading, onLoadMore, hasMore, loadMoreTrigger, outline, fullWidth, moreActions, onExport, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, suppressHeader, suppressSearch, toolbarAfter, suppressPagination, manualSorting, manualPagination: manualPaginationProp, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, stickyControls: stickyControlsProp, layoutPresets, getRowId, enableFuzzySearch, savedState, expanding: expandingProp, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, headerRowBackgroundColor, toolbarCheckBoxMode, view: viewProp, defaultView: defaultViewProp, onViewChange, showDataView, headlineId, cardColumns, cardMinWidth, renderCard, enableRowVirtualization, rowVirtualizerOptions, rowVirtualizerInstanceRef, enableColumnVirtualization, columnVirtualizerOptions, columnVirtualizerInstanceRef, ...rest }: TableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function Table<TData extends object, TFilters extends FiltersState = Record<string, unknown>>({ data, rowPinning, columnDefinitions, keepPinnedRows, copyPinnedRows, enableSelectPinned, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize, pageCount, rowCount, loading, infiniteLoading, onLoadMore, hasMore, loadMoreTrigger, outline, fullWidth, moreActions, onExport, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar, suppressHeader, suppressSearch, toolbarAfter, suppressPagination, manualSorting, manualPagination: manualPaginationProp, manualFiltering, autoResetPageIndex, scrollRef, scrollContainerRef, stickyControls: stickyControlsProp, layoutPresets, getRowId, enableFuzzySearch, savedState, expanding: expandingProp, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, headerRowBackgroundColor, toolbarCheckBoxMode, view: viewProp, defaultView: defaultViewProp, onViewChange, showDataView, headlineId, cardColumns, cardMinWidth, renderCard, enableRowVirtualization, rowVirtualizerOptions, rowVirtualizerInstanceRef, enableColumnVirtualization, columnVirtualizerOptions, columnVirtualizerInstanceRef, ...rest }: TableProps<TData, TFilters>): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export declare namespace Table {
|
|
9
9
|
var getStatusColumnDef: typeof import("../..").getStatusColumnDef;
|
|
10
10
|
var statusAppearances: {
|
|
@@ -47,7 +47,7 @@ export const TABLE_LAYOUT_PRESETS = {
|
|
|
47
47
|
/** Компонент таблицы */
|
|
48
48
|
export function Table({ data, rowPinning = {
|
|
49
49
|
top: [],
|
|
50
|
-
}, columnDefinitions, keepPinnedRows = false, copyPinnedRows = false, enableSelectPinned = false, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize = DEFAULT_PAGE_SIZE, pageCount, loading = false, infiniteLoading = false, onLoadMore, hasMore, loadMoreTrigger = 'scroll', outline = false, fullWidth, moreActions, onExport, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar = false, suppressHeader = false, suppressSearch = false, toolbarAfter, suppressPagination = false, manualSorting = false, manualPagination: manualPaginationProp = false, manualFiltering = false, autoResetPageIndex = false, scrollRef, scrollContainerRef, stickyControls: stickyControlsProp, layoutPresets, getRowId, enableFuzzySearch, savedState, expanding: expandingProp, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, headerRowBackgroundColor, toolbarCheckBoxMode, view: viewProp, defaultView: defaultViewProp, onViewChange, showDataView = false, headlineId, cardColumns, cardMinWidth, renderCard, enableRowVirtualization = false, rowVirtualizerOptions, rowVirtualizerInstanceRef, enableColumnVirtualization = false, columnVirtualizerOptions, columnVirtualizerInstanceRef, ...rest }) {
|
|
50
|
+
}, columnDefinitions, keepPinnedRows = false, copyPinnedRows = false, enableSelectPinned = false, rowSelection: rowSelectionProp, search, sorting: sortingProp, columnFilters, pagination: paginationProp, className, onRowClick, onRefresh, pageSize = DEFAULT_PAGE_SIZE, pageCount, rowCount, loading = false, infiniteLoading = false, onLoadMore, hasMore, loadMoreTrigger = 'scroll', outline = false, fullWidth, moreActions, onExport, dataFiltered, dataError, noDataState, noResultsState, errorDataState, suppressToolbar = false, suppressHeader = false, suppressSearch = false, toolbarAfter, suppressPagination = false, manualSorting = false, manualPagination: manualPaginationProp = false, manualFiltering = false, autoResetPageIndex = false, scrollRef, scrollContainerRef, stickyControls: stickyControlsProp, layoutPresets, getRowId, enableFuzzySearch, savedState, expanding: expandingProp, bulkActions: bulkActionsProp, rowAutoHeight, columnsSettings: columnsSettingsProp, getRowBackgroundColor, headerRowBackgroundColor, toolbarCheckBoxMode, view: viewProp, defaultView: defaultViewProp, onViewChange, showDataView = false, headlineId, cardColumns, cardMinWidth, renderCard, enableRowVirtualization = false, rowVirtualizerOptions, rowVirtualizerInstanceRef, enableColumnVirtualization = false, columnVirtualizerOptions, columnVirtualizerInstanceRef, ...rest }) {
|
|
51
51
|
const { layoutType } = useAdaptiveLayout();
|
|
52
52
|
const isMobile = isMobileLayout(layoutType);
|
|
53
53
|
const expanding = useMemo(() => expandingProp && {
|
|
@@ -131,6 +131,7 @@ export function Table({ data, rowPinning = {
|
|
|
131
131
|
pagination,
|
|
132
132
|
onPaginationChange,
|
|
133
133
|
pageCount,
|
|
134
|
+
rowCount,
|
|
134
135
|
pageSize,
|
|
135
136
|
manualSorting,
|
|
136
137
|
manualPagination,
|
|
@@ -335,7 +336,7 @@ export function Table({ data, rowPinning = {
|
|
|
335
336
|
paginationChrome =
|
|
336
337
|
isStickyControls && controlsAcrylic ? (_jsx(TableChrome, { variant: 'footer', acrylic: controlsAcrylic, children: pagination })) : (pagination);
|
|
337
338
|
}
|
|
338
|
-
return (_jsx("div", { ref: wrapperRef, className: cn(styles.wrapper, className), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...extractSupportProps(rest), children: _jsxs(TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, _jsxs("div", { className: styles.tableView, children: [_jsxs("div", { className: styles.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? _jsx("span", { className: styles.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? (_jsx("div", { className: styles.mobileToolbarMounts, children: columnsSettingsToolbarSlot.mobileMount })) : null, _jsxs(DndContext, { ...dndContextProps, children: [draggingColumnPreview,
|
|
339
|
+
return (_jsx("div", { ref: wrapperRef, className: cn(styles.wrapper, className), "data-view": view, "data-layout-type": layoutType, "data-sticky-controls": isStickyControls || undefined, "data-with-toolbar": showToolbar || undefined, "data-empty-body": isEmptyBody || undefined, "data-fit-content": !resolvedFullWidth || undefined, ...extractSupportProps(rest), children: _jsxs(TableContext.Provider, { value: tableContextValue, children: [toolbarChrome, _jsxs("div", { className: styles.tableView, children: [_jsxs("div", { className: styles.content, "data-outline": !isCardsView && outline ? true : undefined, "data-page-sticky-header": !isCardsView && usePageStickyHeader ? true : undefined, ...(!isCardsView ? TABLE_CONTENT_ACRYLIC : {}), children: [!isCardsView ? _jsx("span", { className: styles.contentAcrylic, "data-acrylic-background": true, "aria-hidden": true }) : null, hasMobileToolbarMounts ? (_jsx("div", { className: styles.mobileToolbarMounts, children: columnsSettingsToolbarSlot.mobileMount })) : null, _jsxs(DndContext, { ...dndContextProps, children: [draggingColumnPreview, _jsxs(TableScrollHost, { view: view, isMobile: isMobile, isCardsView: isCardsView, usePageStickyHeader: usePageStickyHeader, scrollOverflow: scrollOverflow, scrollPaddingAbsolute: scrollPaddingAbsolute, internalScrollRef: internalScrollRef, scrollRef: scrollRef, scrollContainerRef: scrollContainerRef, handleScrollInitialized: handleScrollInitialized, syncHeaderHorizontalScroll: syncHeaderHorizontalScroll, tableHeaderElement: tableHeaderElement, columnSizeVars: columnSizes.vars, children: [scrollContent, loadMoreButtonNode] })] }), !isCardsView && outline ? _jsx("span", { className: styles.contentBorder, "aria-hidden": true }) : null] }), paginationChrome] })] }) }));
|
|
339
340
|
}
|
|
340
341
|
Table.getStatusColumnDef = getStatusColumnDef;
|
|
341
342
|
Table.statusAppearances = STATUS_APPEARANCE;
|
|
@@ -20,6 +20,7 @@ type UseTableInstanceParams<TData extends object> = {
|
|
|
20
20
|
pagination: PaginationState;
|
|
21
21
|
onPaginationChange: OnChangeFn<PaginationState>;
|
|
22
22
|
pageCount?: number;
|
|
23
|
+
rowCount?: number;
|
|
23
24
|
pageSize: number;
|
|
24
25
|
manualSorting: boolean;
|
|
25
26
|
manualPagination: boolean;
|
|
@@ -41,7 +42,7 @@ type UseTableInstanceParams<TData extends object> = {
|
|
|
41
42
|
onRefresh?: () => void;
|
|
42
43
|
bulkActionsProp?: TableProps<TData>['bulkActions'];
|
|
43
44
|
};
|
|
44
|
-
export declare function useTableInstance<TData extends object>({ data, rowPinning, keepPinnedRows, enableSelectPinned, rowSelectionProp, globalFilter, onGlobalFilterChange, rowSelection, onRowSelectionChange, sorting, onSortingChange, expanded, onExpandedChange, pagination, onPaginationChange, pageCount, pageSize, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, getRowId, enableFuzzySearch, expanding, rowAutoHeight, enabledTableColumns, enabledColumnsDefinitions, columnPinning, columnOrder, enableColumnsOrderSortByDrag, setColumnOrder, masterSelection, infiniteLoading, loading, onRefresh, bulkActionsProp, }: UseTableInstanceParams<TData>): {
|
|
45
|
+
export declare function useTableInstance<TData extends object>({ data, rowPinning, keepPinnedRows, enableSelectPinned, rowSelectionProp, globalFilter, onGlobalFilterChange, rowSelection, onRowSelectionChange, sorting, onSortingChange, expanded, onExpandedChange, pagination, onPaginationChange, pageCount, rowCount, pageSize, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, getRowId, enableFuzzySearch, expanding, rowAutoHeight, enabledTableColumns, enabledColumnsDefinitions, columnPinning, columnOrder, enableColumnsOrderSortByDrag, setColumnOrder, masterSelection, infiniteLoading, loading, onRefresh, bulkActionsProp, }: UseTableInstanceParams<TData>): {
|
|
45
46
|
table: import("@tanstack/react-table").Table<TData>;
|
|
46
47
|
loadingTable: import("@tanstack/react-table").Table<TData>;
|
|
47
48
|
enableSelection: boolean;
|
|
@@ -7,7 +7,7 @@ import { getColumnId, toggleMasterSelection } from '../../../helpers/index.js';
|
|
|
7
7
|
import { fuzzyFilter } from '../../../utils.js';
|
|
8
8
|
import { getTableColumnsDefinitions } from '../utils/index.js';
|
|
9
9
|
import { useLoadingTable } from './useLoadingTable.js';
|
|
10
|
-
export function useTableInstance({ data, rowPinning, keepPinnedRows, enableSelectPinned, rowSelectionProp, globalFilter, onGlobalFilterChange, rowSelection, onRowSelectionChange, sorting, onSortingChange, expanded, onExpandedChange, pagination, onPaginationChange, pageCount, pageSize, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, getRowId, enableFuzzySearch, expanding, rowAutoHeight, enabledTableColumns, enabledColumnsDefinitions, columnPinning, columnOrder, enableColumnsOrderSortByDrag, setColumnOrder, masterSelection, infiniteLoading, loading, onRefresh, bulkActionsProp, }) {
|
|
10
|
+
export function useTableInstance({ data, rowPinning, keepPinnedRows, enableSelectPinned, rowSelectionProp, globalFilter, onGlobalFilterChange, rowSelection, onRowSelectionChange, sorting, onSortingChange, expanded, onExpandedChange, pagination, onPaginationChange, pageCount, rowCount, pageSize, manualSorting, manualPagination, manualFiltering, autoResetPageIndex, getRowId, enableFuzzySearch, expanding, rowAutoHeight, enabledTableColumns, enabledColumnsDefinitions, columnPinning, columnOrder, enableColumnsOrderSortByDrag, setColumnOrder, masterSelection, infiniteLoading, loading, onRefresh, bulkActionsProp, }) {
|
|
11
11
|
const enableSelection = Boolean(rowSelectionProp?.enable);
|
|
12
12
|
const enableRowSelection = useCallback((row) => {
|
|
13
13
|
const parent = row.getParentRow();
|
|
@@ -33,6 +33,7 @@ export function useTableInstance({ data, rowPinning, keepPinnedRows, enableSelec
|
|
|
33
33
|
expanded,
|
|
34
34
|
},
|
|
35
35
|
pageCount,
|
|
36
|
+
rowCount,
|
|
36
37
|
defaultColumn: {
|
|
37
38
|
enableSorting: false,
|
|
38
39
|
enableResizing: false,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
max-width:100%;
|
|
9
9
|
min-height:0;
|
|
10
10
|
max-height:100%;
|
|
11
|
-
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-
|
|
11
|
+
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-8, 8px));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
.wrapper[data-view=cards]{
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
.wrapper[data-sticky-controls][data-layout-type=mobile] .stickyFooter{
|
|
56
|
-
padding-top:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-
|
|
56
|
+
padding-top:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-8, 8px));
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.wrapper[data-sticky-controls][data-layout-type=mobile][data-view=cards] .stickyFooter{
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
flex-direction:column;
|
|
67
67
|
min-width:0;
|
|
68
68
|
min-height:0;
|
|
69
|
-
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-
|
|
69
|
+
gap:var(--sn-table-anatomy-view-line-gap, var(--sn-primitive-dimension-8, 8px));
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
.wrapper[data-view=cards] .tableView{
|
|
@@ -328,6 +328,7 @@ export type InfiniteTableProps<TData extends object, TFilters extends FiltersSta
|
|
|
328
328
|
pagination?: never;
|
|
329
329
|
autoResetPageIndex?: never;
|
|
330
330
|
pageCount?: never;
|
|
331
|
+
rowCount?: never;
|
|
331
332
|
/** Режим работы "бесконечной" загрузки */
|
|
332
333
|
infiniteLoading?: boolean;
|
|
333
334
|
suppressPagination?: never;
|
|
@@ -363,6 +364,8 @@ export type ClientTableProps<TData extends object, TFilters extends FiltersState
|
|
|
363
364
|
autoResetPageIndex?: boolean;
|
|
364
365
|
/** Кол-во страниц (для внешнего управления) */
|
|
365
366
|
pageCount?: number;
|
|
367
|
+
/** Общее количество строк при внешнем управлении пагинацией. */
|
|
368
|
+
rowCount?: number;
|
|
366
369
|
/** Отключение пагинации */
|
|
367
370
|
suppressPagination?: boolean;
|
|
368
371
|
manualPagination?: boolean;
|
|
@@ -374,7 +377,7 @@ export type ClientTableProps<TData extends object, TFilters extends FiltersState
|
|
|
374
377
|
toolbarCheckBoxMode?: ToolbarCheckBoxMode;
|
|
375
378
|
};
|
|
376
379
|
export type TableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = InfiniteTableProps<TData, TFilters> | ClientTableProps<TData, TFilters>;
|
|
377
|
-
export type ServerTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = Omit<ClientTableProps<TData, TFilters>, 'pageSize' | 'pageCount' | 'pagination' | 'search' | 'data' | 'toolbarCheckBoxMode'> & {
|
|
380
|
+
export type ServerTableProps<TData extends object, TFilters extends FiltersState = Record<string, unknown>> = Omit<ClientTableProps<TData, TFilters>, 'pageSize' | 'pageCount' | 'rowCount' | 'pagination' | 'search' | 'data' | 'toolbarCheckBoxMode'> & {
|
|
378
381
|
/** Данные для отрисовки */
|
|
379
382
|
items?: TData[];
|
|
380
383
|
/** Общее кол-во строк @default 10 */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
.rowActionsHeader{
|
|
2
|
+
max-width:var(--sn-table-anatomy-content-headLine-actionWrapper-maxWidth, var(--sn-table-anatomy-content-tableLine-actionWrapper-maxWidth, var(--sn-primitive-dimension-40, 40px)));
|
|
2
3
|
padding:0 !important;
|
|
3
4
|
}
|
|
4
5
|
|
|
@@ -9,6 +10,7 @@
|
|
|
9
10
|
|
|
10
11
|
.rowActionsCell{
|
|
11
12
|
position:relative;
|
|
13
|
+
max-width:var(--sn-table-anatomy-content-tableLine-actionWrapper-maxWidth, var(--sn-primitive-dimension-40, 40px));
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
.rowActionsCellWrap{
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
flex-shrink:0;
|
|
91
91
|
align-items:center;
|
|
92
92
|
box-sizing:border-box;
|
|
93
|
-
width:var(--sn-table-anatomy-content-
|
|
93
|
+
width:var(--sn-table-anatomy-content-tableLineTree-pinnedWrapper-elementWrapper-cellToggles-width, var(--sn-density-icon-s, var(--sn-platform-comfort-icon-s, var(--sn-primitive-dimension-24, 24px))));
|
|
94
94
|
height:100%;
|
|
95
95
|
padding-left:var(--sn-table-anatomy-content-tableLine-pinnedWrapper-elementWrapper-cellToggles-paddingLeft, var(--sn-density-table-headToggleOffset, var(--sn-platform-comfort-spacing-headToggleOffset, var(--sn-primitive-dimension-0, 0px))));
|
|
96
96
|
}
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
display:flex;
|
|
3
3
|
justify-content:center;
|
|
4
4
|
box-sizing:border-box;
|
|
5
|
-
padding:var(--sn-primitive-dimension-8, 8px)
|
|
5
|
+
padding-top:var(--sn-table-anatomy-view-loadTrigger-paddingVertical, var(--sn-primitive-dimension-8, 8px));
|
|
6
|
+
padding-bottom:var(--sn-table-anatomy-view-loadTrigger-paddingVertical, var(--sn-primitive-dimension-8, 8px));
|
|
6
7
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isMobileLayout, useAdaptiveLayout } from '@cloud-ru/ds-adaptive';
|
|
3
|
+
import { Button } from '@cloud-ru/ds-button';
|
|
2
4
|
import { ChipChoice } from '@cloud-ru/ds-chips';
|
|
5
|
+
import { ChevronLeftSVG, ChevronRightSVG } from '@cloud-ru/ds-icons/interface/system';
|
|
3
6
|
import { Pagination } from '@cloud-ru/ds-pagination';
|
|
4
7
|
import { useCallback, useMemo } from 'react';
|
|
5
8
|
import { tableLocale } from '../../locale/index.js';
|
|
6
9
|
import styles from './styles.module.css';
|
|
10
|
+
const MAX_PAGE_OPTIONS = 1000;
|
|
7
11
|
export function TablePagination({ table, options: optionsProp, optionsLabel: optionsLabelProp, optionsRender, view, }) {
|
|
12
|
+
const { layoutType } = useAdaptiveLayout();
|
|
13
|
+
const mobile = isMobileLayout(layoutType);
|
|
8
14
|
const { t } = tableLocale.useTranslations();
|
|
9
15
|
const optionsLabel = optionsLabelProp ?? t('rowsOptionsLabel');
|
|
10
16
|
const handlePaginationOnChange = useCallback((pageIndex) => {
|
|
@@ -21,8 +27,24 @@ export function TablePagination({ table, options: optionsProp, optionsLabel: opt
|
|
|
21
27
|
value: String(value),
|
|
22
28
|
})), [optionsProp, optionsRender]);
|
|
23
29
|
const tablePaginationState = table.getState().pagination;
|
|
24
|
-
|
|
30
|
+
const pageCount = table.getPageCount();
|
|
31
|
+
const currentPage = tablePaginationState.pageIndex + 1;
|
|
32
|
+
const hasKnownPageCount = Number.isSafeInteger(pageCount) && pageCount >= 0;
|
|
33
|
+
const showPagination = !hasKnownPageCount || pageCount > 1;
|
|
34
|
+
const showPagePicker = mobile && hasKnownPageCount && pageCount > 1 && pageCount <= MAX_PAGE_OPTIONS;
|
|
35
|
+
const useCompactPagination = mobile || !hasKnownPageCount;
|
|
36
|
+
const pageOptions = useMemo(() => showPagePicker
|
|
37
|
+
? Array.from({ length: pageCount }, (_, index) => {
|
|
38
|
+
const page = String(index + 1);
|
|
39
|
+
return { label: page, value: page };
|
|
40
|
+
})
|
|
41
|
+
: [], [showPagePicker, pageCount]);
|
|
42
|
+
if (!showPagination && !options?.length) {
|
|
25
43
|
return null;
|
|
26
44
|
}
|
|
27
|
-
return (_jsxs("div", { className: styles.footer, "data-view": view, children: [
|
|
45
|
+
return (_jsxs("div", { className: styles.footer, "data-view": view, children: [showPagination && useCompactPagination && (_jsxs("nav", { className: styles.mobilePagination, "aria-label": t('pagination'), children: [_jsx(Button, { size: 's', view: 'function', appearance: 'neutral', icon: _jsx(ChevronLeftSVG, {}), "aria-label": t('previousPage'), disabled: !table.getCanPreviousPage(), onClick: () => table.previousPage() }), showPagePicker && (_jsx(ChipChoice.Single, { label: t('page'), value: String(currentPage), options: pageOptions, onChange: value => {
|
|
46
|
+
if (value !== undefined) {
|
|
47
|
+
handlePaginationOnChange(Number(value));
|
|
48
|
+
}
|
|
49
|
+
}, size: 's' })), _jsx(Button, { size: 's', view: 'function', appearance: 'neutral', icon: _jsx(ChevronRightSVG, {}), "aria-label": t('nextPage'), disabled: !table.getCanNextPage(), onClick: () => table.nextPage() })] })), showPagination && !useCompactPagination && (_jsx(Pagination, { total: pageCount, page: currentPage, onChange: handlePaginationOnChange, size: 's', className: styles.pagination })), options && options.length > 0 && (mobile || table.getRowCount() >= Number(options[0].value)) && (_jsx(ChipChoice.Single, { value: String(tablePaginationState.pageSize), onChange: value => handleRowsVolumeOnChange(String(value)), placement: 'top-end', options: options, label: optionsLabel, widthStrategy: 'eq', size: 's' }))] }));
|
|
28
50
|
}
|
|
@@ -2,6 +2,10 @@ declare const TABLE_MESSAGES: {
|
|
|
2
2
|
readonly 'en-GB': {
|
|
3
3
|
readonly searchPlaceholder: "Search";
|
|
4
4
|
readonly rowsOptionsLabel: "Rows volume";
|
|
5
|
+
readonly pagination: "Pagination";
|
|
6
|
+
readonly page: "Page";
|
|
7
|
+
readonly previousPage: "Previous page";
|
|
8
|
+
readonly nextPage: "Next page";
|
|
5
9
|
readonly settingsHeaderLabel: "Columns settings";
|
|
6
10
|
readonly sort: "Sort";
|
|
7
11
|
readonly clearSort: "Clear sorting";
|
|
@@ -26,6 +30,10 @@ declare const TABLE_MESSAGES: {
|
|
|
26
30
|
readonly 'ru-RU': {
|
|
27
31
|
readonly searchPlaceholder: "Поиск";
|
|
28
32
|
readonly rowsOptionsLabel: "Строк на странице";
|
|
33
|
+
readonly pagination: "Навигация по страницам";
|
|
34
|
+
readonly page: "Страница";
|
|
35
|
+
readonly previousPage: "Предыдущая страница";
|
|
36
|
+
readonly nextPage: "Следующая страница";
|
|
29
37
|
readonly settingsHeaderLabel: "Настройки колонок";
|
|
30
38
|
readonly sort: "Сортировка";
|
|
31
39
|
readonly clearSort: "Сбросить сортировку";
|
|
@@ -54,6 +62,10 @@ export declare const tableLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
|
54
62
|
readonly 'en-GB': {
|
|
55
63
|
readonly searchPlaceholder: "Search";
|
|
56
64
|
readonly rowsOptionsLabel: "Rows volume";
|
|
65
|
+
readonly pagination: "Pagination";
|
|
66
|
+
readonly page: "Page";
|
|
67
|
+
readonly previousPage: "Previous page";
|
|
68
|
+
readonly nextPage: "Next page";
|
|
57
69
|
readonly settingsHeaderLabel: "Columns settings";
|
|
58
70
|
readonly sort: "Sort";
|
|
59
71
|
readonly clearSort: "Clear sorting";
|
|
@@ -78,6 +90,10 @@ export declare const tableLocale: import("@cloud-ru/ds-locale").DefinedLocale<{
|
|
|
78
90
|
readonly 'ru-RU': {
|
|
79
91
|
readonly searchPlaceholder: "Поиск";
|
|
80
92
|
readonly rowsOptionsLabel: "Строк на странице";
|
|
93
|
+
readonly pagination: "Навигация по страницам";
|
|
94
|
+
readonly page: "Страница";
|
|
95
|
+
readonly previousPage: "Предыдущая страница";
|
|
96
|
+
readonly nextPage: "Следующая страница";
|
|
81
97
|
readonly settingsHeaderLabel: "Настройки колонок";
|
|
82
98
|
readonly sort: "Сортировка";
|
|
83
99
|
readonly clearSort: "Сбросить сортировку";
|
package/dist/esm/locale/index.js
CHANGED
|
@@ -3,6 +3,10 @@ const TABLE_MESSAGES = defineMessages({
|
|
|
3
3
|
'en-GB': {
|
|
4
4
|
searchPlaceholder: 'Search',
|
|
5
5
|
rowsOptionsLabel: 'Rows volume',
|
|
6
|
+
pagination: 'Pagination',
|
|
7
|
+
page: 'Page',
|
|
8
|
+
previousPage: 'Previous page',
|
|
9
|
+
nextPage: 'Next page',
|
|
6
10
|
settingsHeaderLabel: 'Columns settings',
|
|
7
11
|
sort: 'Sort',
|
|
8
12
|
clearSort: 'Clear sorting',
|
|
@@ -27,6 +31,10 @@ const TABLE_MESSAGES = defineMessages({
|
|
|
27
31
|
'ru-RU': {
|
|
28
32
|
searchPlaceholder: 'Поиск',
|
|
29
33
|
rowsOptionsLabel: 'Строк на странице',
|
|
34
|
+
pagination: 'Навигация по страницам',
|
|
35
|
+
page: 'Страница',
|
|
36
|
+
previousPage: 'Предыдущая страница',
|
|
37
|
+
nextPage: 'Следующая страница',
|
|
30
38
|
settingsHeaderLabel: 'Настройки колонок',
|
|
31
39
|
sort: 'Сортировка',
|
|
32
40
|
clearSort: 'Сбросить сортировку',
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export * from './adminTable/index.js';
|
|
2
1
|
export * from './entitiesTable/index.js';
|
|
3
2
|
export * from './infiniteTable/index.js';
|
|
4
|
-
export * from './serverAdminTable/index.js';
|
|
5
3
|
export * from './serverSimpleTable/index.js';
|
|
6
4
|
export * from './simpleTable/index.js';
|
|
7
5
|
export * from './treeTable/index.js';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export * from './adminTable/index.js';
|
|
2
1
|
export * from './entitiesTable/index.js';
|
|
3
2
|
export * from './infiniteTable/index.js';
|
|
4
|
-
export * from './serverAdminTable/index.js';
|
|
5
3
|
export * from './serverSimpleTable/index.js';
|
|
6
4
|
export * from './simpleTable/index.js';
|
|
7
5
|
export * from './treeTable/index.js';
|