@redis-ui/table 2.4.0 → 2.12.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.
Files changed (47) hide show
  1. package/dist/Table/Table.cjs +58 -34
  2. package/dist/Table/Table.d.ts +3 -1
  3. package/dist/Table/Table.js +60 -36
  4. package/dist/Table/Table.style.cjs +24 -13
  5. package/dist/Table/Table.style.d.ts +4 -1
  6. package/dist/Table/Table.style.js +25 -14
  7. package/dist/Table/Table.types.d.ts +25 -8
  8. package/dist/Table/components/EmptyStateRow/EmptyStateRow.cjs +16 -0
  9. package/dist/Table/components/EmptyStateRow/EmptyStateRow.d.ts +8 -0
  10. package/dist/Table/components/EmptyStateRow/EmptyStateRow.js +16 -0
  11. package/dist/Table/components/ExpandRowButton/ExpandRowButton.cjs +1 -0
  12. package/dist/Table/components/ExpandRowButton/ExpandRowButton.js +1 -0
  13. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.cjs +29 -0
  14. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.d.ts +7 -0
  15. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.js +29 -0
  16. package/dist/Table/components/RowSelection/HeaderMultiRowSelectionButton.test.d.ts +1 -0
  17. package/dist/Table/components/RowSelection/RowSelectionButton.cjs +15 -0
  18. package/dist/Table/components/RowSelection/RowSelectionButton.d.ts +6 -0
  19. package/dist/Table/components/RowSelection/RowSelectionButton.js +15 -0
  20. package/dist/Table/components/RowSelection/RowSelectionButton.test.d.ts +1 -0
  21. package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.style.cjs +1 -1
  22. package/dist/Table/components/TableExpandedRow/TableAnimatedExpandedRow.style.js +1 -1
  23. package/dist/Table/components/TableExpandedRow/TableExpandedRow.style.cjs +2 -2
  24. package/dist/Table/components/TableExpandedRow/TableExpandedRow.style.js +2 -2
  25. package/dist/Table/components/TableHeaderCell/TableHeaderCell.cjs +37 -0
  26. package/dist/Table/components/TableHeaderCell/TableHeaderCell.d.ts +4 -0
  27. package/dist/Table/components/TableHeaderCell/TableHeaderCell.js +37 -0
  28. package/dist/Table/components/TableHeaderCell/TableHeaderCell.types.d.ts +13 -0
  29. package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.cjs +101 -0
  30. package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.d.ts +11 -0
  31. package/dist/Table/components/TableHeaderCell/TableHeaderCell.utils.js +101 -0
  32. package/dist/Table/components/TablePagination/TablePagination.cjs +27 -8
  33. package/dist/Table/components/TablePagination/TablePagination.js +26 -7
  34. package/dist/Table/components/TablePagination/TablePagination.style.cjs +14 -9
  35. package/dist/Table/components/TablePagination/TablePagination.style.d.ts +8 -7
  36. package/dist/Table/components/TablePagination/TablePagination.style.js +14 -9
  37. package/dist/node_modules/@radix-ui/react-id/dist/index.cjs +32 -0
  38. package/dist/node_modules/@radix-ui/react-id/dist/index.js +14 -0
  39. package/dist/node_modules/@radix-ui/react-primitive/dist/index.cjs +55 -0
  40. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +37 -0
  41. package/dist/node_modules/@radix-ui/react-slot/dist/index.cjs +100 -0
  42. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +82 -0
  43. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.cjs +24 -0
  44. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
  45. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.cjs +51 -0
  46. package/dist/node_modules/@radix-ui/react-visually-hidden/dist/index.js +33 -0
  47. package/package.json +5 -4
@@ -11,6 +11,7 @@ const ExpandRowButton = ({
11
11
  }) => row.getCanExpand() ? jsxRuntime.jsxRuntimeExports.jsx(redisUiComponents.IconButton, {
12
12
  ...restProps,
13
13
  icon: row.getIsExpanded() ? expandedIcon ?? redisUiIcons.ChevronUpIcon : collapsedIcon ?? redisUiIcons.ChevronDownIcon,
14
+ "aria-label": row.getIsExpanded() ? "expanded" : "collapsed",
14
15
  onClick: (e) => {
15
16
  var _a;
16
17
  e.stopPropagation();
@@ -9,6 +9,7 @@ const ExpandRowButton = ({
9
9
  }) => row.getCanExpand() ? jsxRuntimeExports.jsx(IconButton, {
10
10
  ...restProps,
11
11
  icon: row.getIsExpanded() ? expandedIcon ?? ChevronUpIcon : collapsedIcon ?? ChevronDownIcon,
12
+ "aria-label": row.getIsExpanded() ? "expanded" : "collapsed",
12
13
  onClick: (e) => {
13
14
  var _a;
14
15
  e.stopPropagation();
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
4
+ const redisUiComponents = require("@redislabsdev/redis-ui-components");
5
+ const HeaderMultiRowSelectionButton = ({
6
+ table,
7
+ managePage,
8
+ ...restProps
9
+ }) => {
10
+ const props = {
11
+ checked: false,
12
+ label: "unselected all rows",
13
+ onCheckedChange: managePage ? table.toggleAllPageRowsSelected : table.toggleAllRowsSelected
14
+ };
15
+ if (managePage ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected()) {
16
+ props.checked = true;
17
+ props.label = "selected all rows";
18
+ } else if (managePage ? table.getIsSomePageRowsSelected() : table.getIsSomeRowsSelected()) {
19
+ props.checked = "indeterminate";
20
+ props.label = "selected some rows";
21
+ }
22
+ return jsxRuntime.jsxRuntimeExports.jsx(redisUiComponents.Checkbox, {
23
+ ...restProps,
24
+ checked: props.checked,
25
+ onCheckedChange: props.onCheckedChange,
26
+ "aria-label": props.label
27
+ });
28
+ };
29
+ exports.HeaderMultiRowSelectionButton = HeaderMultiRowSelectionButton;
@@ -0,0 +1,7 @@
1
+ import { CheckboxProps } from '@redislabsdev/redis-ui-components';
2
+ import { Table } from '@tanstack/react-table';
3
+ export interface HeaderMultiRowSelectionButtonProps<T extends object> extends Omit<CheckboxProps, 'onClick'> {
4
+ table: Table<T>;
5
+ managePage?: boolean;
6
+ }
7
+ export declare const HeaderMultiRowSelectionButton: <T extends object>({ table, managePage, ...restProps }: HeaderMultiRowSelectionButtonProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
2
+ import { Checkbox } from "@redislabsdev/redis-ui-components";
3
+ const HeaderMultiRowSelectionButton = ({
4
+ table,
5
+ managePage,
6
+ ...restProps
7
+ }) => {
8
+ const props = {
9
+ checked: false,
10
+ label: "unselected all rows",
11
+ onCheckedChange: managePage ? table.toggleAllPageRowsSelected : table.toggleAllRowsSelected
12
+ };
13
+ if (managePage ? table.getIsAllPageRowsSelected() : table.getIsAllRowsSelected()) {
14
+ props.checked = true;
15
+ props.label = "selected all rows";
16
+ } else if (managePage ? table.getIsSomePageRowsSelected() : table.getIsSomeRowsSelected()) {
17
+ props.checked = "indeterminate";
18
+ props.label = "selected some rows";
19
+ }
20
+ return jsxRuntimeExports.jsx(Checkbox, {
21
+ ...restProps,
22
+ checked: props.checked,
23
+ onCheckedChange: props.onCheckedChange,
24
+ "aria-label": props.label
25
+ });
26
+ };
27
+ export {
28
+ HeaderMultiRowSelectionButton
29
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
4
+ const redisUiComponents = require("@redislabsdev/redis-ui-components");
5
+ const RowSelectionButton = ({
6
+ row,
7
+ ...restProps
8
+ }) => jsxRuntime.jsxRuntimeExports.jsx(redisUiComponents.Checkbox, {
9
+ ...restProps,
10
+ disabled: !row.getCanSelect(),
11
+ checked: row.getIsSelected(),
12
+ onCheckedChange: (checked) => row.toggleSelected(checked),
13
+ "aria-label": row.getIsSelected() ? "selected" : "unselected"
14
+ });
15
+ exports.RowSelectionButton = RowSelectionButton;
@@ -0,0 +1,6 @@
1
+ import { CheckboxProps } from '@redislabsdev/redis-ui-components';
2
+ import { Row } from '@tanstack/react-table';
3
+ export interface RowSelectionButtonProps<T extends object> extends Omit<CheckboxProps, 'onClick'> {
4
+ row: Row<T>;
5
+ }
6
+ export declare const RowSelectionButton: <T extends object>({ row, ...restProps }: RowSelectionButtonProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
2
+ import { Checkbox } from "@redislabsdev/redis-ui-components";
3
+ const RowSelectionButton = ({
4
+ row,
5
+ ...restProps
6
+ }) => jsxRuntimeExports.jsx(Checkbox, {
7
+ ...restProps,
8
+ disabled: !row.getCanSelect(),
9
+ checked: row.getIsSelected(),
10
+ onCheckedChange: (checked) => row.toggleSelected(checked),
11
+ "aria-label": row.getIsSelected() ? "selected" : "unselected"
12
+ });
13
+ export {
14
+ RowSelectionButton
15
+ };
@@ -6,6 +6,6 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
6
6
  const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
7
7
  const AnimatedExpandedRow = _styled__default.default(TableExpandedRow.TableExpandedRow).withConfig({
8
8
  displayName: "TableAnimatedExpandedRowstyle__AnimatedExpandedRow",
9
- componentId: "sc-l3awb3-0"
9
+ componentId: "RedisUI__sc-l3awb3-0"
10
10
  })(["&&{display:grid;}visibility:hidden;grid-template-rows:0fr;transition:all 0.5s;&[data-expanded='true']{visibility:visible;grid-template-rows:1fr;}"]);
11
11
  exports.AnimatedExpandedRow = AnimatedExpandedRow;
@@ -2,7 +2,7 @@ import _styled from "styled-components";
2
2
  import { TableExpandedRow } from "./TableExpandedRow.js";
3
3
  const AnimatedExpandedRow = _styled(TableExpandedRow).withConfig({
4
4
  displayName: "TableAnimatedExpandedRowstyle__AnimatedExpandedRow",
5
- componentId: "sc-l3awb3-0"
5
+ componentId: "RedisUI__sc-l3awb3-0"
6
6
  })(["&&{display:grid;}visibility:hidden;grid-template-rows:0fr;transition:all 0.5s;&[data-expanded='true']{visibility:visible;grid-template-rows:1fr;}"]);
7
7
  export {
8
8
  AnimatedExpandedRow
@@ -5,11 +5,11 @@ const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
5
5
  const _styled__default = /* @__PURE__ */ _interopDefault(_styled);
6
6
  const ExpandedRow = _styled__default.default.tr.withConfig({
7
7
  displayName: "TableExpandedRowstyle__ExpandedRow",
8
- componentId: "sc-2hwl98-0"
8
+ componentId: "RedisUI__sc-2hwl98-0"
9
9
  })(["display:grid;width:100%;&[data-expanded='false']{display:none;}"]);
10
10
  const ExpandedCell = _styled__default.default.td.withConfig({
11
11
  displayName: "TableExpandedRowstyle__ExpandedCell",
12
- componentId: "sc-2hwl98-1"
12
+ componentId: "RedisUI__sc-2hwl98-1"
13
13
  })(["width:100%;padding:0;overflow:hidden;"]);
14
14
  exports.ExpandedCell = ExpandedCell;
15
15
  exports.ExpandedRow = ExpandedRow;
@@ -1,11 +1,11 @@
1
1
  import _styled from "styled-components";
2
2
  const ExpandedRow = _styled.tr.withConfig({
3
3
  displayName: "TableExpandedRowstyle__ExpandedRow",
4
- componentId: "sc-2hwl98-0"
4
+ componentId: "RedisUI__sc-2hwl98-0"
5
5
  })(["display:grid;width:100%;&[data-expanded='false']{display:none;}"]);
6
6
  const ExpandedCell = _styled.td.withConfig({
7
7
  displayName: "TableExpandedRowstyle__ExpandedCell",
8
- componentId: "sc-2hwl98-1"
8
+ componentId: "RedisUI__sc-2hwl98-1"
9
9
  })(["width:100%;padding:0;overflow:hidden;"]);
10
10
  export {
11
11
  ExpandedCell,
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
4
+ const index = require("../../../node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
5
+ const TableHeaderCell_utils = require("./TableHeaderCell.utils.cjs");
6
+ const Table_style = require("../../Table.style.cjs");
7
+ const TableHeaderCell = ({
8
+ header
9
+ }) => {
10
+ const colSpan = TableHeaderCell_utils.normalizeCellSpan(header.colSpan);
11
+ const rowSpan = TableHeaderCell_utils.normalizeCellSpan(header.rowSpan);
12
+ return header.isPlaceholder ? jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableTh, {
13
+ colSpan,
14
+ rowSpan,
15
+ style: {
16
+ width: header.column.getSize()
17
+ },
18
+ "aria-hidden": true,
19
+ children: jsxRuntime.jsxRuntimeExports.jsx(index.VisuallyHidden, {
20
+ children: "Placeholder"
21
+ })
22
+ }, header.placeholderId) : jsxRuntime.jsxRuntimeExports.jsx(Table_style.TableTh, {
23
+ colSpan,
24
+ rowSpan,
25
+ onClick: header.column.getToggleSortingHandler(),
26
+ style: {
27
+ width: header.column.getSize()
28
+ },
29
+ "aria-sort": TableHeaderCell_utils.getCurrentAriaSort(header),
30
+ children: jsxRuntime.jsxRuntimeExports.jsxs(Table_style.HeaderCellInnerWrapper, {
31
+ as: header.column.getCanSort() ? void 0 : "div",
32
+ "aria-description": TableHeaderCell_utils.getColumnSortLabel(header, TableHeaderCell_utils.formatColumnSortNotification),
33
+ children: [TableHeaderCell_utils.getHeaderContent(header), TableHeaderCell_utils.getSortSign(header)]
34
+ })
35
+ }, header.id);
36
+ };
37
+ exports.TableHeaderCell = TableHeaderCell;
@@ -0,0 +1,4 @@
1
+ import { Header } from '@tanstack/react-table';
2
+ export declare const TableHeaderCell: <T extends object>({ header }: {
3
+ header: Header<T, unknown>;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
2
+ import { VisuallyHidden } from "../../../node_modules/@radix-ui/react-visually-hidden/dist/index.js";
3
+ import { normalizeCellSpan, getCurrentAriaSort, getColumnSortLabel, getHeaderContent, getSortSign, formatColumnSortNotification } from "./TableHeaderCell.utils.js";
4
+ import { TableTh, HeaderCellInnerWrapper } from "../../Table.style.js";
5
+ const TableHeaderCell = ({
6
+ header
7
+ }) => {
8
+ const colSpan = normalizeCellSpan(header.colSpan);
9
+ const rowSpan = normalizeCellSpan(header.rowSpan);
10
+ return header.isPlaceholder ? jsxRuntimeExports.jsx(TableTh, {
11
+ colSpan,
12
+ rowSpan,
13
+ style: {
14
+ width: header.column.getSize()
15
+ },
16
+ "aria-hidden": true,
17
+ children: jsxRuntimeExports.jsx(VisuallyHidden, {
18
+ children: "Placeholder"
19
+ })
20
+ }, header.placeholderId) : jsxRuntimeExports.jsx(TableTh, {
21
+ colSpan,
22
+ rowSpan,
23
+ onClick: header.column.getToggleSortingHandler(),
24
+ style: {
25
+ width: header.column.getSize()
26
+ },
27
+ "aria-sort": getCurrentAriaSort(header),
28
+ children: jsxRuntimeExports.jsxs(HeaderCellInnerWrapper, {
29
+ as: header.column.getCanSort() ? void 0 : "div",
30
+ "aria-description": getColumnSortLabel(header, formatColumnSortNotification),
31
+ children: [getHeaderContent(header), getSortSign(header)]
32
+ })
33
+ }, header.id);
34
+ };
35
+ export {
36
+ TableHeaderCell
37
+ };
@@ -0,0 +1,13 @@
1
+ import { Header } from '@tanstack/react-table';
2
+ import { AriaAttributes } from 'react';
3
+ export type CommonHeader = Header<any, any>;
4
+ export type AllowedAriaSort = Exclude<AriaAttributes['aria-sort'], 'other'>;
5
+ export type FormatColumnSortNotification = (params: {
6
+ title: string;
7
+ direction: AllowedAriaSort;
8
+ nextDirection: AllowedAriaSort;
9
+ }) => string;
10
+ export type FormatTableSortNotification = (params: {
11
+ title: string;
12
+ direction: 'descending' | 'ascending';
13
+ }[] | undefined) => string;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
4
+ const index = require("../../../node_modules/@tanstack/react-table/build/lib/index.cjs");
5
+ const redisUiComponents = require("@redislabsdev/redis-ui-components");
6
+ const redisUiIcons = require("@redislabsdev/redis-ui-icons");
7
+ const index$1 = require("../../../node_modules/@radix-ui/react-visually-hidden/dist/index.cjs");
8
+ const Table_style = require("../../Table.style.cjs");
9
+ const sortSign = {
10
+ asc: jsxRuntime.jsxRuntimeExports.jsx(redisUiIcons.ArrowUpIcon, {
11
+ size: "S",
12
+ color: "neutral700",
13
+ "aria-hidden": true
14
+ }),
15
+ desc: jsxRuntime.jsxRuntimeExports.jsx(redisUiIcons.ArrowDownIcon, {
16
+ size: "S",
17
+ color: "neutral700",
18
+ "aria-hidden": true
19
+ })
20
+ };
21
+ const getSortSign = (header) => sortSign[header.column.getIsSorted()] ?? null;
22
+ const ariaSort = {
23
+ asc: "ascending",
24
+ desc: "descending"
25
+ };
26
+ const getAriaSort = (sort) => ariaSort[sort] ?? "none";
27
+ const getCurrentAriaSort = (header) => getAriaSort(header.column.getIsSorted());
28
+ const formatColumnSortNotification = ({
29
+ title,
30
+ nextDirection
31
+ }) => `Sort by ${title}, activate to ${nextDirection === "none" ? "unsort" : `sort ${nextDirection}`}`;
32
+ const getColumnSortLabel = (header, formatLabel) => {
33
+ var _a;
34
+ if (header.column.getCanSort()) {
35
+ const content = index.flexRender(header.column.columnDef.header, header.getContext());
36
+ const text = (_a = redisUiComponents.childrenToString(content)) == null ? void 0 : _a.trim();
37
+ return formatLabel({
38
+ title: text || "actions",
39
+ direction: getAriaSort(header.column.getIsSorted()),
40
+ nextDirection: getAriaSort(header.column.getNextSortingOrder())
41
+ });
42
+ }
43
+ return void 0;
44
+ };
45
+ const DEFAULT_HIDDEN_HEADER = "Actions";
46
+ const getHeaderContent = (header) => {
47
+ var _a;
48
+ const content = index.flexRender(header.column.columnDef.header, header.getContext());
49
+ if (header.column.columnDef.isHeaderCustom) return content;
50
+ const text = (_a = redisUiComponents.childrenToString(content)) == null ? void 0 : _a.trim();
51
+ if (!text || header.column.columnDef.isHeaderHidden) {
52
+ return jsxRuntime.jsxRuntimeExports.jsx(index$1.VisuallyHidden, {
53
+ children: text || DEFAULT_HIDDEN_HEADER
54
+ });
55
+ }
56
+ return jsxRuntime.jsxRuntimeExports.jsx(Table_style.HeaderTitleWrapper, {
57
+ variant: "semiBold",
58
+ ellipsis: true,
59
+ tooltipOnEllipsis: true,
60
+ "$isTextual": redisUiComponents.isTextualNode(content),
61
+ children: content
62
+ });
63
+ };
64
+ const formatTableSortNotification = (sortings) => {
65
+ if (!(sortings == null ? void 0 : sortings.length)) {
66
+ return "Unsorted";
67
+ }
68
+ const parts = sortings.map(({
69
+ title,
70
+ direction
71
+ }) => `by ${title} ${direction}`);
72
+ return `Sorted ${parts.join(", then ")}`;
73
+ };
74
+ const getTableSortLabel = (table, formatLabel) => {
75
+ var _a;
76
+ return formatLabel((_a = table.getState().sorting) == null ? void 0 : _a.map(({
77
+ desc,
78
+ id
79
+ }) => {
80
+ var _a2, _b;
81
+ const column = table.getColumn(id);
82
+ const header = (_a2 = column == null ? void 0 : column.columnDef) == null ? void 0 : _a2.header;
83
+ const title = column && (header && ((_b = redisUiComponents.childrenToString(index.flexRender(header, {
84
+ table,
85
+ column
86
+ }))) == null ? void 0 : _b.trim()) || `column ${column.getIndex() + 1} `) || "unknown column";
87
+ return {
88
+ direction: desc ? "descending" : "ascending",
89
+ title
90
+ };
91
+ }).filter((sort) => sort.title));
92
+ };
93
+ const normalizeCellSpan = (span) => span > 1 ? span : void 0;
94
+ exports.formatColumnSortNotification = formatColumnSortNotification;
95
+ exports.formatTableSortNotification = formatTableSortNotification;
96
+ exports.getColumnSortLabel = getColumnSortLabel;
97
+ exports.getCurrentAriaSort = getCurrentAriaSort;
98
+ exports.getHeaderContent = getHeaderContent;
99
+ exports.getSortSign = getSortSign;
100
+ exports.getTableSortLabel = getTableSortLabel;
101
+ exports.normalizeCellSpan = normalizeCellSpan;
@@ -0,0 +1,11 @@
1
+ import { Table } from '@tanstack/react-table';
2
+ import { ReactElement } from 'react';
3
+ import { AllowedAriaSort, CommonHeader, FormatColumnSortNotification, FormatTableSortNotification } from './TableHeaderCell.types';
4
+ export declare const getSortSign: (header: CommonHeader) => ReactElement<any, string | import("react").JSXElementConstructor<any>>;
5
+ export declare const getCurrentAriaSort: (header: CommonHeader) => AllowedAriaSort;
6
+ export declare const formatColumnSortNotification: FormatColumnSortNotification;
7
+ export declare const getColumnSortLabel: (header: CommonHeader, formatLabel: FormatColumnSortNotification) => string | undefined;
8
+ export declare const getHeaderContent: (header: CommonHeader) => string | number | boolean | Iterable<import("react").ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
9
+ export declare const formatTableSortNotification: FormatTableSortNotification;
10
+ export declare const getTableSortLabel: <T extends object>(table: Table<T>, formatLabel: FormatTableSortNotification) => string;
11
+ export declare const normalizeCellSpan: (span: number) => number | undefined;
@@ -0,0 +1,101 @@
1
+ import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
2
+ import { flexRender } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
3
+ import { childrenToString, isTextualNode } from "@redislabsdev/redis-ui-components";
4
+ import { ArrowUpIcon, ArrowDownIcon } from "@redislabsdev/redis-ui-icons";
5
+ import { VisuallyHidden } from "../../../node_modules/@radix-ui/react-visually-hidden/dist/index.js";
6
+ import { HeaderTitleWrapper } from "../../Table.style.js";
7
+ const sortSign = {
8
+ asc: jsxRuntimeExports.jsx(ArrowUpIcon, {
9
+ size: "S",
10
+ color: "neutral700",
11
+ "aria-hidden": true
12
+ }),
13
+ desc: jsxRuntimeExports.jsx(ArrowDownIcon, {
14
+ size: "S",
15
+ color: "neutral700",
16
+ "aria-hidden": true
17
+ })
18
+ };
19
+ const getSortSign = (header) => sortSign[header.column.getIsSorted()] ?? null;
20
+ const ariaSort = {
21
+ asc: "ascending",
22
+ desc: "descending"
23
+ };
24
+ const getAriaSort = (sort) => ariaSort[sort] ?? "none";
25
+ const getCurrentAriaSort = (header) => getAriaSort(header.column.getIsSorted());
26
+ const formatColumnSortNotification = ({
27
+ title,
28
+ nextDirection
29
+ }) => `Sort by ${title}, activate to ${nextDirection === "none" ? "unsort" : `sort ${nextDirection}`}`;
30
+ const getColumnSortLabel = (header, formatLabel) => {
31
+ var _a;
32
+ if (header.column.getCanSort()) {
33
+ const content = flexRender(header.column.columnDef.header, header.getContext());
34
+ const text = (_a = childrenToString(content)) == null ? void 0 : _a.trim();
35
+ return formatLabel({
36
+ title: text || "actions",
37
+ direction: getAriaSort(header.column.getIsSorted()),
38
+ nextDirection: getAriaSort(header.column.getNextSortingOrder())
39
+ });
40
+ }
41
+ return void 0;
42
+ };
43
+ const DEFAULT_HIDDEN_HEADER = "Actions";
44
+ const getHeaderContent = (header) => {
45
+ var _a;
46
+ const content = flexRender(header.column.columnDef.header, header.getContext());
47
+ if (header.column.columnDef.isHeaderCustom) return content;
48
+ const text = (_a = childrenToString(content)) == null ? void 0 : _a.trim();
49
+ if (!text || header.column.columnDef.isHeaderHidden) {
50
+ return jsxRuntimeExports.jsx(VisuallyHidden, {
51
+ children: text || DEFAULT_HIDDEN_HEADER
52
+ });
53
+ }
54
+ return jsxRuntimeExports.jsx(HeaderTitleWrapper, {
55
+ variant: "semiBold",
56
+ ellipsis: true,
57
+ tooltipOnEllipsis: true,
58
+ "$isTextual": isTextualNode(content),
59
+ children: content
60
+ });
61
+ };
62
+ const formatTableSortNotification = (sortings) => {
63
+ if (!(sortings == null ? void 0 : sortings.length)) {
64
+ return "Unsorted";
65
+ }
66
+ const parts = sortings.map(({
67
+ title,
68
+ direction
69
+ }) => `by ${title} ${direction}`);
70
+ return `Sorted ${parts.join(", then ")}`;
71
+ };
72
+ const getTableSortLabel = (table, formatLabel) => {
73
+ var _a;
74
+ return formatLabel((_a = table.getState().sorting) == null ? void 0 : _a.map(({
75
+ desc,
76
+ id
77
+ }) => {
78
+ var _a2, _b;
79
+ const column = table.getColumn(id);
80
+ const header = (_a2 = column == null ? void 0 : column.columnDef) == null ? void 0 : _a2.header;
81
+ const title = column && (header && ((_b = childrenToString(flexRender(header, {
82
+ table,
83
+ column
84
+ }))) == null ? void 0 : _b.trim()) || `column ${column.getIndex() + 1} `) || "unknown column";
85
+ return {
86
+ direction: desc ? "descending" : "ascending",
87
+ title
88
+ };
89
+ }).filter((sort) => sort.title));
90
+ };
91
+ const normalizeCellSpan = (span) => span > 1 ? span : void 0;
92
+ export {
93
+ formatColumnSortNotification,
94
+ formatTableSortNotification,
95
+ getColumnSortLabel,
96
+ getCurrentAriaSort,
97
+ getHeaderContent,
98
+ getSortSign,
99
+ getTableSortLabel,
100
+ normalizeCellSpan
101
+ };
@@ -2,6 +2,7 @@
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
3
  const jsxRuntime = require("../../../node_modules/react/jsx-runtime.cjs");
4
4
  const redisUiIcons = require("@redislabsdev/redis-ui-icons");
5
+ const index = require("../../../node_modules/@radix-ui/react-id/dist/index.cjs");
5
6
  const Table_context = require("../../Table.context.cjs");
6
7
  const TablePagination_style = require("./TablePagination.style.cjs");
7
8
  const DEFAULT_PAGE_SIZES = [10, 25, 50, 100];
@@ -11,6 +12,8 @@ const TablePagination = ({
11
12
  const {
12
13
  table
13
14
  } = Table_context.useTableContext();
15
+ const perPageId = index.useId();
16
+ const pageNumId = index.useId();
14
17
  if (!table._getPaginationRowModel) {
15
18
  return null;
16
19
  }
@@ -23,8 +26,8 @@ const TablePagination = ({
23
26
  const handlePageSizeChange = (value) => {
24
27
  table.setPageSize(Number(value));
25
28
  };
26
- const handlePageIndexChange = (index) => {
27
- table.setPageIndex(index);
29
+ const handlePageIndexChange = (index2) => {
30
+ table.setPageIndex(index2);
28
31
  };
29
32
  return jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.PaginationRow, {
30
33
  "data-role": "pagination",
@@ -38,8 +41,12 @@ const TablePagination = ({
38
41
  gap: "1rem"
39
42
  },
40
43
  children: [jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.ItemPerPageText, {
41
- children: "Items per page:"
44
+ children: jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.Label, {
45
+ htmlFor: perPageId,
46
+ children: "Items per page:"
47
+ })
42
48
  }), jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.Select, {
49
+ id: perPageId,
43
50
  value: pageSize.toString(),
44
51
  onChange: handlePageSizeChange,
45
52
  disabled: pageSizes[0] > totalRowCount,
@@ -52,12 +59,16 @@ const TablePagination = ({
52
59
  icon: redisUiIcons.DoubleChevronLeftIcon,
53
60
  size: "S",
54
61
  onClick: () => handlePageIndexChange(0),
55
- disabled: pageIndex === 0
62
+ disabled: pageIndex === 0,
63
+ title: "First page",
64
+ "aria-label": "first page"
56
65
  }), jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.PaginationIconButton, {
57
66
  icon: redisUiIcons.ChevronLeftIcon,
58
67
  size: "S",
59
68
  onClick: () => handlePageIndexChange(pageIndex - 1),
60
- disabled: pageIndex === 0
69
+ disabled: pageIndex === 0,
70
+ title: "Previous page",
71
+ "aria-label": "previous page"
61
72
  }), jsxRuntime.jsxRuntimeExports.jsxs(TablePagination_style.PaginationIndexText, {
62
73
  size: "S",
63
74
  children: [pageIndex + 1, " of ", pageCount]
@@ -65,17 +76,25 @@ const TablePagination = ({
65
76
  icon: redisUiIcons.ChevronRightIcon,
66
77
  size: "S",
67
78
  onClick: () => handlePageIndexChange(pageIndex + 1),
68
- disabled: pageIndex === pageCount - 1
79
+ disabled: pageIndex === pageCount - 1,
80
+ title: "Next page",
81
+ "aria-label": "next page"
69
82
  }), jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.PaginationIconButton, {
70
83
  icon: redisUiIcons.DoubleChevronRightIcon,
71
84
  size: "S",
72
85
  onClick: () => handlePageIndexChange(pageCount - 1),
73
- disabled: pageIndex === pageCount - 1
86
+ disabled: pageIndex === pageCount - 1,
87
+ title: "Last page",
88
+ "aria-label": "last page"
74
89
  })]
75
90
  }), jsxRuntime.jsxRuntimeExports.jsxs(TablePagination_style.PaginationActions, {
76
91
  children: [jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.PageLabelText, {
77
- children: "Page"
92
+ children: jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.Label, {
93
+ htmlFor: pageNumId,
94
+ children: "Page"
95
+ })
78
96
  }), jsxRuntime.jsxRuntimeExports.jsx(TablePagination_style.Select, {
97
+ id: pageNumId,
79
98
  value: (pageIndex + 1).toString(),
80
99
  onChange: (value) => handlePageIndexChange(Number(value) - 1),
81
100
  options: Array.from({