@redis-ui/table 2.23.2 → 2.25.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 (27) hide show
  1. package/dist/Table/Table.cjs +7 -1
  2. package/dist/Table/Table.d.ts +12 -12
  3. package/dist/Table/Table.js +7 -1
  4. package/dist/Table/Table.style.d.ts +1 -1
  5. package/dist/Table/components/Compose/Compose.cjs +2 -3
  6. package/dist/Table/components/Compose/Compose.d.ts +9 -8
  7. package/dist/Table/components/Compose/Compose.js +3 -4
  8. package/dist/Table/components/ExpandRowButton/useExpanderColumn.cjs +0 -1
  9. package/dist/Table/components/ExpandRowButton/useExpanderColumn.js +0 -1
  10. package/dist/Table/components/PluggableTable/compositionComponents.d.ts +2 -2
  11. package/dist/Table/components/RowSelection/useRowSelectionColumn.cjs +0 -1
  12. package/dist/Table/components/RowSelection/useRowSelectionColumn.js +0 -1
  13. package/dist/Table/components/TableHeaderCell/components/Heading/Heading.d.ts +2 -3
  14. package/dist/Table/components/TablePagination/TablePagination.d.ts +3 -2
  15. package/dist/Table/components/TablePagination/TablePagination.style.d.ts +3 -2
  16. package/dist/Table/plugins/ExpandableRowPlugin.cjs +16 -3
  17. package/dist/Table/plugins/ExpandableRowPlugin.d.ts +3 -1
  18. package/dist/Table/plugins/ExpandableRowPlugin.js +14 -1
  19. package/dist/Table/plugins/PaginationPlugin.d.ts +1 -1
  20. package/dist/Table/plugins/RowNavigationPlugin.d.ts +1 -1
  21. package/dist/Table/plugins/RowSelectionPlugin.cjs +11 -1
  22. package/dist/Table/plugins/RowSelectionPlugin.d.ts +3 -1
  23. package/dist/Table/plugins/RowSelectionPlugin.js +11 -1
  24. package/dist/Table/utils/plugin.utils.cjs +17 -2
  25. package/dist/Table/utils/plugin.utils.d.ts +5 -2
  26. package/dist/Table/utils/plugin.utils.js +18 -3
  27. package/package.json +4 -4
@@ -37,6 +37,8 @@ const Table = Object.assign(({
37
37
  manualSorting,
38
38
  // row expansion
39
39
  defaultExpanded,
40
+ expanded,
41
+ onExpandedChange,
40
42
  getIsRowExpandable,
41
43
  renderExpandedRow,
42
44
  expandRowOnClick,
@@ -57,6 +59,7 @@ const Table = Object.assign(({
57
59
  onRowSelectionChange,
58
60
  rowSelectionMode,
59
61
  getRowCanSelect,
62
+ selectRowOnClick,
60
63
  // row navigation
61
64
  enableRowNavigation = false
62
65
  }) => {
@@ -83,6 +86,8 @@ const Table = Object.assign(({
83
86
  });
84
87
  const expandableRowPluginData = ExpandableRowPlugin.useExpandableRowPlugin({
85
88
  defaultExpanded,
89
+ expanded,
90
+ onExpandedChange,
86
91
  expandRowOnClick,
87
92
  getRowCanExpand: getIsRowExpandable && ((row) => {
88
93
  var _a;
@@ -97,7 +102,8 @@ const Table = Object.assign(({
97
102
  defaultRowSelection,
98
103
  onRowSelectionChange,
99
104
  rowSelectionMode,
100
- getRowCanSelect
105
+ getRowCanSelect,
106
+ selectRowOnClick
101
107
  });
102
108
  const rowNavigationPluginData = RowNavigationPlugin.useRowNavigationPlugin({
103
109
  enableRowNavigation
@@ -2,7 +2,7 @@
2
2
  import './tanStackExtendedTypes';
3
3
  import type { Row } from '@tanstack/react-table';
4
4
  import { TableProps } from './Table.types';
5
- declare const Table: (<T extends object>({ columns, caption, onRowClick, data, getRowId, emptyState, maxHeight, minWidth, stripedRows, enableSorting, defaultSorting, onSortingChange, sorting, manualSorting, defaultExpanded, getIsRowExpandable, renderExpandedRow, expandRowOnClick, expandedRowComponent, getSubRows, pagination, defaultPagination, onPaginationChange, manualPagination, totalRowCount, totalPageCount, pageSizes, paginationEnabled, rowSelection, defaultRowSelection, onRowSelectionChange, rowSelectionMode, getRowCanSelect, enableRowNavigation }: TableProps<T>) => import("react/jsx-runtime").JSX.Element) & {
5
+ declare const Table: (<T extends object>({ columns, caption, onRowClick, data, getRowId, emptyState, maxHeight, minWidth, stripedRows, enableSorting, defaultSorting, onSortingChange, sorting, manualSorting, defaultExpanded, expanded, onExpandedChange, getIsRowExpandable, renderExpandedRow, expandRowOnClick, expandedRowComponent, getSubRows, pagination, defaultPagination, onPaginationChange, manualPagination, totalRowCount, totalPageCount, pageSizes, paginationEnabled, rowSelection, defaultRowSelection, onRowSelectionChange, rowSelectionMode, getRowCanSelect, selectRowOnClick, enableRowNavigation }: TableProps<T>) => import("react/jsx-runtime").JSX.Element) & {
6
6
  Compose: <T_1 extends object>({ data, columns, pluginsData, tableOptions, components, maxHeight, minWidth, stripedRows, ...restProps }: import("./components/Compose/Compose").TableComposeProps<T_1>) => import("react/jsx-runtime").JSX.Element;
7
7
  Root: (props: import("react").HTMLAttributes<HTMLTableElement>) => import("react/jsx-runtime").JSX.Element;
8
8
  SRCaption: ({ caption }: {
@@ -54,11 +54,11 @@ declare const Table: (<T extends object>({ columns, caption, onRowClick, data, g
54
54
  InfoLabel: import("styled-components").StyledComponent<({ renderer, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationInfoLabelProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
55
55
  PageSelect: import("styled-components").StyledComponent<{
56
56
  ({ ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSelectProps): import("react/jsx-runtime").JSX.Element;
57
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element;
57
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
58
58
  }, any, {}, never>;
59
59
  PageSizeSelect: import("styled-components").StyledComponent<{
60
60
  ({ pageSizes, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSizeSelectProps): import("react/jsx-runtime").JSX.Element | null;
61
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element | null;
61
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element | null;
62
62
  }, any, {}, never>;
63
63
  NavigationButton: import("styled-components").StyledComponent<({ navType, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationNavigationButtonProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
64
64
  PageSizeGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -77,16 +77,16 @@ declare const Table: (<T extends object>({ columns, caption, onRowClick, data, g
77
77
  ShowOnActiveRow: import("styled-components").StyledComponent<"div", any, {}, never>;
78
78
  useClickableRowPlugin: <T_18 extends object>({ getCanRowClick, onRowClick, shouldClickOnEnter }: Partial<import("./plugins/ClickableRowPlugin").TableClickableRowContext<T_18>>) => import(".").TablePluginData<T_18>;
79
79
  useSortingPlugin: <T_19 extends object>({ defaultSorting, onSortingChange, sorting, manualSorting, enableSorting }?: import("./plugins/SortingPlugin").TableSortingParams) => import(".").TablePluginData<T_19>;
80
- usePaginationPlugin: <T_20 extends object>({ pagination, defaultPagination, onPaginationChange, manualPagination, totalRowCount, totalPageCount, pageSizes, paginationEnabled }: import("./plugins/PaginationPlugin").TablePaginationParams) => import(".").TablePluginData<T_20>;
81
- useExpandableRowPlugin: <T_21 extends object>({ defaultExpanded, getRowCanExpand, renderExpandedRow, expandRowOnClick, expandedRowComponent, getSubRows }: import("./plugins/ExpandableRowPlugin").TableExpandableRowParams<T_21>) => import(".").TablePluginData<T_21>;
82
- useRowSelectionPlugin: <T_22 extends object>({ rowSelection, defaultRowSelection, onRowSelectionChange, rowSelectionMode, getRowCanSelect }: import("./plugins/RowSelectionPlugin").TableRowSelectionParams<T_22>) => import(".").TablePluginData<T_22>;
83
- useRowNavigationPlugin: <T_23 extends object>({ enableRowNavigation }: import("./plugins/RowNavigationPlugin").TableRowNavigationParams) => import(".").TablePluginData<T_23>;
84
- useTableContext: <T_24 extends object = object>() => import("./Table.context").TableContextProps<T_24>;
85
- useComposeContext: <T_25 extends object, C extends import("./Table.context").CompositionContextProps<T_25> = import("./Table.context").CompositionContextProps<T_25>>(defaults: Partial<C>) => C;
86
- useClickableRowContext: <T_26 extends object>() => import("./plugins/ClickableRowPlugin").TableClickableRowContext<T_26> | undefined;
87
- useExpandableRowContext: <T_27 extends object>() => import("./plugins/ExpandableRowPlugin").TableExpandableRowContext<T_27> | undefined;
80
+ usePaginationPlugin: ({ pagination, defaultPagination, onPaginationChange, manualPagination, totalRowCount, totalPageCount, pageSizes, paginationEnabled }: import("./plugins/PaginationPlugin").TablePaginationParams) => import(".").TablePluginData<any>;
81
+ useExpandableRowPlugin: <T_20 extends object>({ defaultExpanded, expanded, onExpandedChange, getRowCanExpand, renderExpandedRow, expandRowOnClick, expandedRowComponent, getSubRows }: import("./plugins/ExpandableRowPlugin").TableExpandableRowParams<T_20>) => import(".").TablePluginData<T_20>;
82
+ useRowSelectionPlugin: <T_21 extends object>({ rowSelection, defaultRowSelection, onRowSelectionChange, rowSelectionMode, getRowCanSelect, selectRowOnClick }: import("./plugins/RowSelectionPlugin").TableRowSelectionParams<T_21>) => import(".").TablePluginData<T_21>;
83
+ useRowNavigationPlugin: ({ enableRowNavigation }: import("./plugins/RowNavigationPlugin").TableRowNavigationParams) => import(".").TablePluginData<any>;
84
+ useTableContext: <T_22 extends object = object>() => import("./Table.context").TableContextProps<T_22>;
85
+ useComposeContext: <T_23 extends object, C extends import("./Table.context").CompositionContextProps<T_23> = import("./Table.context").CompositionContextProps<T_23>>(defaults: Partial<C>) => C;
86
+ useClickableRowContext: <T_24 extends object>() => import("./plugins/ClickableRowPlugin").TableClickableRowContext<T_24> | undefined;
87
+ useExpandableRowContext: <T_25 extends object>() => import("./plugins/ExpandableRowPlugin").TableExpandableRowContext<T_25> | undefined;
88
88
  usePaginationContext: () => import("./plugins/PaginationPlugin").TablePaginationContext | undefined;
89
89
  useSortingContext: () => import("./plugins/SortingPlugin").TableSortingContext | undefined;
90
- PluggableTable: <T_28 extends object>({ caption, emptyStateRender, ...restProps }: import("./components/PluggableTable/PluggableTable").PluggableTableProps<T_28>) => import("react/jsx-runtime").JSX.Element;
90
+ PluggableTable: <T_26 extends object>({ caption, emptyStateRender, ...restProps }: import("./components/PluggableTable/PluggableTable").PluggableTableProps<T_26>) => import("react/jsx-runtime").JSX.Element;
91
91
  };
92
92
  export default Table;
@@ -35,6 +35,8 @@ const Table = Object.assign(({
35
35
  manualSorting,
36
36
  // row expansion
37
37
  defaultExpanded,
38
+ expanded,
39
+ onExpandedChange,
38
40
  getIsRowExpandable,
39
41
  renderExpandedRow,
40
42
  expandRowOnClick,
@@ -55,6 +57,7 @@ const Table = Object.assign(({
55
57
  onRowSelectionChange,
56
58
  rowSelectionMode,
57
59
  getRowCanSelect,
60
+ selectRowOnClick,
58
61
  // row navigation
59
62
  enableRowNavigation = false
60
63
  }) => {
@@ -81,6 +84,8 @@ const Table = Object.assign(({
81
84
  });
82
85
  const expandableRowPluginData = useExpandableRowPlugin({
83
86
  defaultExpanded,
87
+ expanded,
88
+ onExpandedChange,
84
89
  expandRowOnClick,
85
90
  getRowCanExpand: getIsRowExpandable && ((row) => {
86
91
  var _a;
@@ -95,7 +100,8 @@ const Table = Object.assign(({
95
100
  defaultRowSelection,
96
101
  onRowSelectionChange,
97
102
  rowSelectionMode,
98
- getRowCanSelect
103
+ getRowCanSelect,
104
+ selectRowOnClick
99
105
  });
100
106
  const rowNavigationPluginData = useRowNavigationPlugin({
101
107
  enableRowNavigation
@@ -277,7 +277,7 @@ export declare const TableHeaderRow: import("styled-components").StyledComponent
277
277
  export declare const SortableHeadingCompose: import("styled-components").StyledComponent<"button", any, {
278
278
  $custom: boolean;
279
279
  }, never>;
280
- export declare const HeaderTitleWrapper: import("styled-components").StyledComponent<({ size, variant, color, component, ellipsis, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element, any, {
280
+ export declare const HeaderTitleWrapper: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>>, any, {
281
281
  $isTextual: boolean;
282
282
  }, never>;
283
283
  export declare const TableTh: import("styled-components").StyledComponent<"th", any, {}, never>;
@@ -17,14 +17,13 @@ const TableCompose = ({
17
17
  stripedRows,
18
18
  ...restProps
19
19
  }) => {
20
- const mergedPluginsData = plugin_utils.mergePluginsData(pluginsData);
20
+ const mergedPluginsData = plugin_utils.mergePluginsData(pluginsData, tableOptions);
21
21
  const table = index.useReactTable({
22
22
  data,
23
- columns,
23
+ columns: plugin_utils.normalizeColumns(columns),
24
24
  getCoreRowModel: index$1.getCoreRowModel(),
25
25
  enableSorting: false,
26
26
  enableColumnResizing: false,
27
- ...tableOptions,
28
27
  ...mergedPluginsData == null ? void 0 : mergedPluginsData.tableOptions
29
28
  });
30
29
  const tableContext = {
@@ -1,12 +1,13 @@
1
- import { SetOptional } from 'type-fest';
2
- import { TableOptions } from '@tanstack/table-core';
3
- import { ComposeElementProps } from '@redislabsdev/redis-ui-components';
4
- import { TablePluginData } from '../../utils/plugin.utils';
1
+ import { ColumnDef } from '@tanstack/react-table';
2
+ import { ComposeElementProps, NoInfer } from '@redislabsdev/redis-ui-components';
3
+ import { TablePluginData, UserTableOptions } from '../../utils/plugin.utils';
5
4
  import { CompositionContextProps, TableMainContextProps } from '../../Table.context';
6
- export type OwnTableComposeProps<T extends object> = TableMainContextProps & Pick<TableOptions<T>, 'data' | 'columns'> & {
7
- tableOptions?: Omit<SetOptional<TableOptions<T>, 'getCoreRowModel'>, 'data' | 'columns'>;
8
- pluginsData?: TablePluginData<T>[];
9
- components?: Partial<CompositionContextProps<T>>;
5
+ export type OwnTableComposeProps<T extends object> = TableMainContextProps & {
6
+ data: T[];
7
+ columns: ColumnDef<NoInfer<T>, any>[];
8
+ tableOptions?: UserTableOptions<T>;
9
+ pluginsData?: TablePluginData<NoInfer<T>>[];
10
+ components?: Partial<CompositionContextProps<any>>;
10
11
  };
11
12
  export type RestTableComposeProps = ComposeElementProps;
12
13
  export type TableComposeProps<T extends object> = OwnTableComposeProps<T> & RestTableComposeProps;
@@ -1,6 +1,6 @@
1
1
  import { j as jsxRuntimeExports } from "../../../node_modules/react/jsx-runtime.js";
2
2
  import { useReactTable } from "../../../node_modules/@tanstack/react-table/build/lib/index.js";
3
- import { mergePluginsData } from "../../utils/plugin.utils.js";
3
+ import { mergePluginsData, normalizeColumns } from "../../utils/plugin.utils.js";
4
4
  import { TableContextProvider } from "../../Table.context.js";
5
5
  import { TableContainer } from "../../Table.style.js";
6
6
  import { getCoreRowModel } from "../../../node_modules/@tanstack/table-core/build/lib/index.js";
@@ -15,14 +15,13 @@ const TableCompose = ({
15
15
  stripedRows,
16
16
  ...restProps
17
17
  }) => {
18
- const mergedPluginsData = mergePluginsData(pluginsData);
18
+ const mergedPluginsData = mergePluginsData(pluginsData, tableOptions);
19
19
  const table = useReactTable({
20
20
  data,
21
- columns,
21
+ columns: normalizeColumns(columns),
22
22
  getCoreRowModel: getCoreRowModel(),
23
23
  enableSorting: false,
24
24
  enableColumnResizing: false,
25
- ...tableOptions,
26
25
  ...mergedPluginsData == null ? void 0 : mergedPluginsData.tableOptions
27
26
  });
28
27
  const tableContext = {
@@ -8,7 +8,6 @@ const useExpanderColumn = ({
8
8
  } = {}) => ({
9
9
  id: "expander",
10
10
  size: 4,
11
- minSize: 4,
12
11
  sizeUnit: "rem",
13
12
  header: allowExpandAll ? ExpandAllRowsButton.ExpandAllRowsButton : "expander",
14
13
  isHeaderCustom: !!allowExpandAll,
@@ -6,7 +6,6 @@ const useExpanderColumn = ({
6
6
  } = {}) => ({
7
7
  id: "expander",
8
8
  size: 4,
9
- minSize: 4,
10
9
  sizeUnit: "rem",
11
10
  header: allowExpandAll ? ExpandAllRowsButton : "expander",
12
11
  isHeaderCustom: !!allowExpandAll,
@@ -52,11 +52,11 @@ export declare const compositionComponents: {
52
52
  InfoLabel: import("styled-components").StyledComponent<({ renderer, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationInfoLabelProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
53
53
  PageSelect: import("styled-components").StyledComponent<{
54
54
  ({ ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSelectProps): import("react/jsx-runtime").JSX.Element;
55
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element;
55
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
56
56
  }, any, {}, never>;
57
57
  PageSizeSelect: import("styled-components").StyledComponent<{
58
58
  ({ pageSizes, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSizeSelectProps): import("react/jsx-runtime").JSX.Element | null;
59
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element | null;
59
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element | null;
60
60
  }, any, {}, never>;
61
61
  NavigationButton: import("styled-components").StyledComponent<({ navType, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationNavigationButtonProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
62
62
  PageSizeGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -11,7 +11,6 @@ const useRowSelectionColumn = ({
11
11
  } = {}) => ({
12
12
  id: "row-selection",
13
13
  size: 4.2,
14
- minSize: 4.2,
15
14
  sizeUnit: "rem",
16
15
  header: (props) => !disableSelectAll && props.table.options.enableMultiRowSelection ? jsxRuntime.jsxRuntimeExports.jsx(HeaderMultiRowSelectionButton.HeaderMultiRowSelectionButton, {
17
16
  ...props,
@@ -9,7 +9,6 @@ const useRowSelectionColumn = ({
9
9
  } = {}) => ({
10
10
  id: "row-selection",
11
11
  size: 4.2,
12
- minSize: 4.2,
13
12
  sizeUnit: "rem",
14
13
  header: (props) => !disableSelectAll && props.table.options.enableMultiRowSelection ? jsxRuntimeExports.jsx(HeaderMultiRowSelectionButton, {
15
14
  ...props,
@@ -1,5 +1,4 @@
1
- import { ComponentProps } from 'react';
2
- import { ChildFree, Typography } from '@redislabsdev/redis-ui-components';
3
- export type RestTableHeaderCellHeadingProps = ChildFree<ComponentProps<typeof Typography.Body>>;
1
+ import { ChildFree, TypographyBodyProps } from '@redislabsdev/redis-ui-components';
2
+ export type RestTableHeaderCellHeadingProps = ChildFree<TypographyBodyProps>;
4
3
  export type TableHeaderCellHeadingProps = RestTableHeaderCellHeadingProps;
5
4
  export declare const TableHeaderCellHeading: (props: TableHeaderCellHeadingProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { PaginationInfoLabelProps } from '@redislabsdev/redis-ui-components';
2
3
  declare const TablePagination: (() => import("react/jsx-runtime").JSX.Element | null) & {
3
4
  Compose: ({ children }: import("@redislabsdev/redis-ui-components").ComposeChildrenProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -10,11 +11,11 @@ declare const TablePagination: (() => import("react/jsx-runtime").JSX.Element |
10
11
  InfoLabel: import("styled-components").StyledComponent<({ renderer, ...restProps }: PaginationInfoLabelProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
11
12
  PageSelect: import("styled-components").StyledComponent<{
12
13
  ({ ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSelectProps): import("react/jsx-runtime").JSX.Element;
13
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element;
14
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
14
15
  }, any, {}, never>;
15
16
  PageSizeSelect: import("styled-components").StyledComponent<{
16
17
  ({ pageSizes, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSizeSelectProps): import("react/jsx-runtime").JSX.Element | null;
17
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element | null;
18
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element | null;
18
19
  }, any, {}, never>;
19
20
  NavigationButton: import("styled-components").StyledComponent<({ navType, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationNavigationButtonProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
20
21
  PageSizeGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const NavigationButton: import("styled-components").StyledComponent<({ navType, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationNavigationButtonProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
2
3
  export declare const PaginationBar: import("styled-components").StyledComponent<"nav", any, {
3
4
  'aria-label': string;
@@ -7,11 +8,11 @@ export declare const PaginationBar: import("styled-components").StyledComponent<
7
8
  export declare const InfoLabel: import("styled-components").StyledComponent<({ renderer, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationInfoLabelProps) => import("react/jsx-runtime").JSX.Element, any, {}, never>;
8
9
  export declare const PageSizeSelect: import("styled-components").StyledComponent<{
9
10
  ({ pageSizes, ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSizeSelectProps): import("react/jsx-runtime").JSX.Element | null;
10
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element | null;
11
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element | null;
11
12
  }, any, {}, never>;
12
13
  export declare const PageSelect: import("styled-components").StyledComponent<{
13
14
  ({ ...restProps }: import("@redislabsdev/redis-ui-components").PaginationPageSelectProps): import("react/jsx-runtime").JSX.Element;
14
- Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps) => import("react/jsx-runtime").JSX.Element;
15
+ Label: ({ children, ...restProps }: import("@redislabsdev/redis-ui-components").TypographyBodyProps & import("react").RefAttributes<HTMLElement>) => import("react/jsx-runtime").JSX.Element;
15
16
  }, any, {}, never>;
16
17
  export declare const PageSizeGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
17
18
  export declare const PageNavGroup: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const index = require("../../node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs");
3
4
  const plugin_utils = require("../utils/plugin.utils.cjs");
4
5
  const ClickableRowPlugin = require("./ClickableRowPlugin.cjs");
5
6
  const Table_context = require("../Table.context.cjs");
6
- const index = require("../../node_modules/@tanstack/table-core/build/lib/index.cjs");
7
+ const index$1 = require("../../node_modules/@tanstack/table-core/build/lib/index.cjs");
8
+ const DEFAULT_EXPANDED = {};
7
9
  const getTrue = () => true;
8
10
  const TableExpandableRowContextKey = "expandableRow";
9
11
  const useExpandableRowPlugin = ({
10
12
  defaultExpanded,
13
+ expanded,
14
+ onExpandedChange,
11
15
  getRowCanExpand,
12
16
  renderExpandedRow,
13
17
  expandRowOnClick,
@@ -19,15 +23,24 @@ const useExpandableRowPlugin = ({
19
23
  onRowClick: (row) => row.toggleExpanded(),
20
24
  shouldClickOnEnter: true
21
25
  });
26
+ const [expandedState = DEFAULT_EXPANDED, setExpandedState] = index.useControllableState({
27
+ prop: expanded,
28
+ defaultProp: defaultExpanded,
29
+ onChange: onExpandedChange
30
+ });
22
31
  if (!renderExpandedRow && !getSubRows) return void 0;
23
32
  return {
24
33
  tableOptions: {
25
- getExpandedRowModel: index.getExpandedRowModel(),
34
+ getExpandedRowModel: index$1.getExpandedRowModel(),
26
35
  getRowCanExpand: getRowCanExpand || (getSubRows ? void 0 : getTrue),
27
36
  getSubRows,
28
37
  initialState: defaultExpanded ? {
29
38
  expanded: defaultExpanded
30
- } : void 0
39
+ } : void 0,
40
+ state: {
41
+ expanded: expandedState
42
+ },
43
+ onExpandedChange: setExpandedState
31
44
  },
32
45
  context: {
33
46
  ...plugin_utils.buildPluginContext(TableExpandableRowContextKey, {
@@ -23,6 +23,8 @@ export interface TableExpandableRowParams<T extends object> extends TableExpanda
23
23
  * When this prop is set, the `renderExpandedRow` and `expandedRowComponent` parameters are not used. */
24
24
  getSubRows?: (rowData: T, index: number) => T[] | undefined;
25
25
  defaultExpanded?: ExpandedState;
26
+ expanded?: ExpandedState;
27
+ onExpandedChange?: (state: ExpandedState) => void;
26
28
  }
27
- export declare const useExpandableRowPlugin: <T extends object>({ defaultExpanded, getRowCanExpand, renderExpandedRow, expandRowOnClick, expandedRowComponent, getSubRows }: TableExpandableRowParams<T>) => TablePluginData<T>;
29
+ export declare const useExpandableRowPlugin: <T extends object>({ defaultExpanded, expanded, onExpandedChange, getRowCanExpand, renderExpandedRow, expandRowOnClick, expandedRowComponent, getSubRows }: TableExpandableRowParams<T>) => TablePluginData<T>;
28
30
  export declare const useExpandableRowContext: <T extends object>() => TableExpandableRowContext<T> | undefined;
@@ -1,11 +1,15 @@
1
+ import { useControllableState } from "../../node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
1
2
  import { buildPluginContext } from "../utils/plugin.utils.js";
2
3
  import { useClickableRowPlugin } from "./ClickableRowPlugin.js";
3
4
  import { usePluginContext } from "../Table.context.js";
4
5
  import { getExpandedRowModel } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
6
+ const DEFAULT_EXPANDED = {};
5
7
  const getTrue = () => true;
6
8
  const TableExpandableRowContextKey = "expandableRow";
7
9
  const useExpandableRowPlugin = ({
8
10
  defaultExpanded,
11
+ expanded,
12
+ onExpandedChange,
9
13
  getRowCanExpand,
10
14
  renderExpandedRow,
11
15
  expandRowOnClick,
@@ -17,6 +21,11 @@ const useExpandableRowPlugin = ({
17
21
  onRowClick: (row) => row.toggleExpanded(),
18
22
  shouldClickOnEnter: true
19
23
  });
24
+ const [expandedState = DEFAULT_EXPANDED, setExpandedState] = useControllableState({
25
+ prop: expanded,
26
+ defaultProp: defaultExpanded,
27
+ onChange: onExpandedChange
28
+ });
20
29
  if (!renderExpandedRow && !getSubRows) return void 0;
21
30
  return {
22
31
  tableOptions: {
@@ -25,7 +34,11 @@ const useExpandableRowPlugin = ({
25
34
  getSubRows,
26
35
  initialState: defaultExpanded ? {
27
36
  expanded: defaultExpanded
28
- } : void 0
37
+ } : void 0,
38
+ state: {
39
+ expanded: expandedState
40
+ },
41
+ onExpandedChange: setExpandedState
29
42
  },
30
43
  context: {
31
44
  ...buildPluginContext(TableExpandableRowContextKey, {
@@ -13,5 +13,5 @@ export interface TablePaginationParams extends TablePaginationContext {
13
13
  totalRowCount?: number;
14
14
  totalPageCount?: number;
15
15
  }
16
- export declare const usePaginationPlugin: <T extends object>({ pagination, defaultPagination, onPaginationChange, manualPagination, totalRowCount, totalPageCount, pageSizes, paginationEnabled }: TablePaginationParams) => TablePluginData<T>;
16
+ export declare const usePaginationPlugin: ({ pagination, defaultPagination, onPaginationChange, manualPagination, totalRowCount, totalPageCount, pageSizes, paginationEnabled }: TablePaginationParams) => TablePluginData<any>;
17
17
  export declare const usePaginationContext: () => TablePaginationContext | undefined;
@@ -16,7 +16,7 @@ export type TableRowNavigationContext = {
16
16
  export type TableRowNavigationParams = {
17
17
  enableRowNavigation?: boolean;
18
18
  };
19
- export declare const useRowNavigationPlugin: <T extends object>({ enableRowNavigation }: TableRowNavigationParams) => TablePluginData<T>;
19
+ export declare const useRowNavigationPlugin: ({ enableRowNavigation }: TableRowNavigationParams) => TablePluginData<any>;
20
20
  export declare const useRowNavigationContext: () => TableRowNavigationContext | undefined;
21
21
  type UseHandleRowNavigationOnRowParams<T extends object> = {
22
22
  row: Row<T>;
@@ -1,14 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const index = require("../../node_modules/@radix-ui/react-use-controllable-state/dist/index.cjs");
4
+ const ClickableRowPlugin = require("./ClickableRowPlugin.cjs");
4
5
  const DEFAULT_ROW_SELECTION = {};
5
6
  const useRowSelectionPlugin = ({
6
7
  rowSelection,
7
8
  defaultRowSelection,
8
9
  onRowSelectionChange,
9
10
  rowSelectionMode,
10
- getRowCanSelect
11
+ getRowCanSelect,
12
+ selectRowOnClick
11
13
  }) => {
14
+ const clickablePluginData = ClickableRowPlugin.useClickableRowPlugin({
15
+ getCanRowClick: (row) => !!(selectRowOnClick && row.getCanSelect()),
16
+ onRowClick: (row) => row.toggleSelected(),
17
+ shouldClickOnEnter: true
18
+ });
12
19
  const [rowSelectionState = DEFAULT_ROW_SELECTION, setRowSelectionState] = index.useControllableState({
13
20
  prop: rowSelection,
14
21
  defaultProp: defaultRowSelection,
@@ -22,6 +29,9 @@ const useRowSelectionPlugin = ({
22
29
  enableRowSelection: getRowCanSelect ?? true,
23
30
  enableMultiRowSelection: rowSelectionMode === "multiple",
24
31
  onRowSelectionChange: setRowSelectionState
32
+ },
33
+ context: {
34
+ ...selectRowOnClick ? clickablePluginData == null ? void 0 : clickablePluginData.context : null
25
35
  }
26
36
  };
27
37
  };
@@ -8,5 +8,7 @@ export interface TableRowSelectionParams<T extends object> {
8
8
  rowSelectionMode?: 'single' | 'multiple';
9
9
  /** Allows individual rows to be selectable */
10
10
  getRowCanSelect?: (row: Row<T>) => boolean;
11
+ /** Allows selecting row by Click on whole row and by pressing Enter, when row is focused */
12
+ selectRowOnClick?: boolean;
11
13
  }
12
- export declare const useRowSelectionPlugin: <T extends object>({ rowSelection, defaultRowSelection, onRowSelectionChange, rowSelectionMode, getRowCanSelect }: TableRowSelectionParams<T>) => TablePluginData<T>;
14
+ export declare const useRowSelectionPlugin: <T extends object>({ rowSelection, defaultRowSelection, onRowSelectionChange, rowSelectionMode, getRowCanSelect, selectRowOnClick }: TableRowSelectionParams<T>) => TablePluginData<T>;
@@ -1,12 +1,19 @@
1
1
  import { useControllableState } from "../../node_modules/@radix-ui/react-use-controllable-state/dist/index.js";
2
+ import { useClickableRowPlugin } from "./ClickableRowPlugin.js";
2
3
  const DEFAULT_ROW_SELECTION = {};
3
4
  const useRowSelectionPlugin = ({
4
5
  rowSelection,
5
6
  defaultRowSelection,
6
7
  onRowSelectionChange,
7
8
  rowSelectionMode,
8
- getRowCanSelect
9
+ getRowCanSelect,
10
+ selectRowOnClick
9
11
  }) => {
12
+ const clickablePluginData = useClickableRowPlugin({
13
+ getCanRowClick: (row) => !!(selectRowOnClick && row.getCanSelect()),
14
+ onRowClick: (row) => row.toggleSelected(),
15
+ shouldClickOnEnter: true
16
+ });
10
17
  const [rowSelectionState = DEFAULT_ROW_SELECTION, setRowSelectionState] = useControllableState({
11
18
  prop: rowSelection,
12
19
  defaultProp: defaultRowSelection,
@@ -20,6 +27,9 @@ const useRowSelectionPlugin = ({
20
27
  enableRowSelection: getRowCanSelect ?? true,
21
28
  enableMultiRowSelection: rowSelectionMode === "multiple",
22
29
  onRowSelectionChange: setRowSelectionState
30
+ },
31
+ context: {
32
+ ...selectRowOnClick ? clickablePluginData == null ? void 0 : clickablePluginData.context : null
23
33
  }
24
34
  };
25
35
  };
@@ -17,9 +17,9 @@ const mergeObjects = (key, container1, container2) => {
17
17
  }
18
18
  } : null;
19
19
  };
20
- const mergePluginsData = (plugins) => {
20
+ const mergePluginsData = (plugins, tableOptions) => {
21
21
  const merged = {
22
- tableOptions: {},
22
+ tableOptions: tableOptions ?? {},
23
23
  context: {}
24
24
  };
25
25
  if (!(plugins == null ? void 0 : plugins.length)) {
@@ -45,5 +45,20 @@ const mergePluginsData = (plugins) => {
45
45
  const buildPluginContext = (key, context) => ({
46
46
  [key]: context
47
47
  });
48
+ const normalizeColumns = (columns) => columns.map((column) => {
49
+ const {
50
+ size,
51
+ minSize,
52
+ sizeUnit
53
+ } = column;
54
+ const sizeFix = !minSize && sizeUnit && sizeUnit !== "fraction" && typeof size === "number" && size < 20 ? {
55
+ minSize: size
56
+ } : {};
57
+ return {
58
+ ...column,
59
+ ...sizeFix
60
+ };
61
+ });
48
62
  exports.buildPluginContext = buildPluginContext;
49
63
  exports.mergePluginsData = mergePluginsData;
64
+ exports.normalizeColumns = normalizeColumns;
@@ -1,6 +1,8 @@
1
1
  import { TableOptions } from '@tanstack/table-core';
2
- import { RowData } from '@tanstack/react-table';
2
+ import { ColumnDef, RowData } from '@tanstack/react-table';
3
+ import { SetOptional } from 'type-fest';
3
4
  export type PartialTableOptions<T extends RowData> = Partial<Omit<TableOptions<T>, 'columns' | 'data' | 'getRowId' | 'onStateChange' | 'getCoreRowModel' | 'defaultColumn' | 'debugTable' | 'debugRows' | 'debugHeaders' | 'debugColumns' | 'debugCells' | 'debugAll' | 'autoResetAll' | 'meta'>>;
5
+ export type UserTableOptions<T extends RowData> = Omit<SetOptional<TableOptions<T>, 'getCoreRowModel'>, 'data' | 'columns'>;
4
6
  export type TablePluginData<T extends RowData> = {
5
7
  /** Partial table options that will be smartly merged with other table options */
6
8
  tableOptions: PartialTableOptions<T>;
@@ -13,5 +15,6 @@ export type TableMergedData<T extends RowData> = {
13
15
  tableOptions: PartialTableOptions<T>;
14
16
  context?: Record<string, Record<string, unknown>>;
15
17
  };
16
- export declare const mergePluginsData: <T extends unknown>(plugins?: TablePluginData<T>[] | undefined) => TableMergedData<T>;
18
+ export declare const mergePluginsData: <T extends unknown>(plugins?: TablePluginData<T>[] | undefined, tableOptions?: UserTableOptions<T> | undefined) => TableMergedData<T>;
17
19
  export declare const buildPluginContext: (key: string, context: Record<string, unknown>) => Record<string, Record<string, unknown>>;
20
+ export declare const normalizeColumns: <T extends object>(columns: ColumnDef<T, unknown>[]) => ColumnDef<T, unknown>[];
@@ -15,9 +15,9 @@ const mergeObjects = (key, container1, container2) => {
15
15
  }
16
16
  } : null;
17
17
  };
18
- const mergePluginsData = (plugins) => {
18
+ const mergePluginsData = (plugins, tableOptions) => {
19
19
  const merged = {
20
- tableOptions: {},
20
+ tableOptions: tableOptions ?? {},
21
21
  context: {}
22
22
  };
23
23
  if (!(plugins == null ? void 0 : plugins.length)) {
@@ -43,7 +43,22 @@ const mergePluginsData = (plugins) => {
43
43
  const buildPluginContext = (key, context) => ({
44
44
  [key]: context
45
45
  });
46
+ const normalizeColumns = (columns) => columns.map((column) => {
47
+ const {
48
+ size,
49
+ minSize,
50
+ sizeUnit
51
+ } = column;
52
+ const sizeFix = !minSize && sizeUnit && sizeUnit !== "fraction" && typeof size === "number" && size < 20 ? {
53
+ minSize: size
54
+ } : {};
55
+ return {
56
+ ...column,
57
+ ...sizeFix
58
+ };
59
+ });
46
60
  export {
47
61
  buildPluginContext,
48
- mergePluginsData
62
+ mergePluginsData,
63
+ normalizeColumns
49
64
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redis-ui/table",
3
3
  "license": "UNLICENSED",
4
- "version": "2.23.2",
4
+ "version": "2.25.0",
5
5
  "type": "module",
6
6
  "publishConfig": {
7
7
  "registry": "https://npm.pkg.github.com/"
@@ -29,11 +29,11 @@
29
29
  "react": "^17.0.0 || ^18.0.0",
30
30
  "react-dom": "^17.0.0 || ^18.0.0",
31
31
  "styled-components": "^5.0.0",
32
- "@redis-ui/styles": "^13.1.10"
32
+ "@redis-ui/styles": "^13.3.0"
33
33
  },
34
34
  "dependencies": {
35
- "@redis-ui/components": "^41.2.9",
36
- "@redis-ui/icons": "^6.3.11",
35
+ "@redis-ui/components": "^41.4.0",
36
+ "@redis-ui/icons": "^6.4.0",
37
37
  "@tanstack/react-table": "^8.9.8",
38
38
  "type-fest": "^3.13.1"
39
39
  },