@synerise/ds-table 1.1.14 → 1.2.1

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 CHANGED
@@ -3,6 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.1](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@1.2.0...@synerise/ds-table@1.2.1) (2025-06-11)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-table
9
+
10
+
11
+
12
+
13
+
14
+ # [1.2.0](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@1.1.14...@synerise/ds-table@1.2.0) (2025-06-05)
15
+
16
+
17
+ ### Features
18
+
19
+ * **column-manager:** removed unnecessary features ([152d3c0](https://github.com/synerise/synerise-design/commit/152d3c0d87449977f8c4264bb7abd278210470e9))
20
+ * **table:** isCounterLoading prop added ([3fec1ec](https://github.com/synerise/synerise-design/commit/3fec1ec07d1cc9c5b7fe320dc03a21f12be3cc40))
21
+
22
+
23
+
24
+
25
+
6
26
  ## [1.1.14](https://github.com/synerise/synerise-design/compare/@synerise/ds-table@1.1.13...@synerise/ds-table@1.1.14) (2025-06-03)
7
27
 
8
28
  **Note:** Version bump only for package @synerise/ds-table
package/README.md CHANGED
@@ -14,13 +14,14 @@ Table UI Component
14
14
  ### Table
15
15
 
16
16
  | Property | Description | Type | Default |
17
- |-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
17
+ | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
18
18
  | bordered | Whether to show all table borders | boolean | `false` |
19
19
  | childrenColumnName | The column contains children to display | string / [] | children |
20
20
  | columns | Columns of table | [ColumnProps](https://git.io/vMMXC)\[] | - |
21
21
  | components | Override default table elements | [TableComponents](https://git.io/fANxz) | - |
22
22
  | dataSource | Data record array to be displayed | any / [] | - |
23
23
  | dataSourceFull | If `dataSource` prop is a subset of a larger array (via search component for example), but you want selection row to operate on the full data array (selection onChange handler will return keys that are not in the current subset but have been selected prior to searching) | same as `dataSource` | - |
24
+ | isCounterLoading | displays a skeleton loader in place of total counter | boolean | - |
24
25
  | defaultExpandAllRows | Expand all rows initially | boolean | `false` |
25
26
  | defaultExpandedRowKeys | Initial expanded row keys | string / [] | - |
26
27
  | disableColumnNamesLineBreak | Disable line break when rendering column names | boolean | false |
@@ -62,8 +63,6 @@ Table UI Component
62
63
  | rowStar | Configuration of row starring | RowStar | - |
63
64
  | maxHeight | Defines the max height to which table skeleton (when loading) should be filled with rows. If undefined 10 skeleton rows will be rendered | number | - |
64
65
 
65
-
66
-
67
66
  ### VirtualTable
68
67
 
69
68
  | Property | Description | Type | Default |
@@ -94,7 +93,7 @@ This type of table requires a specific type of dataSource which has to contain a
94
93
  #### RowSelection
95
94
 
96
95
  | Property | Description | Type | Default |
97
- | --------------- | ------------------------------------------------ | --------------------------------------------------------------- | ------- |
96
+ | -------------------------------- | ---------------------------------------------------- | --------------------------------------------------------------- | ------- |
98
97
  | fixed | Whether to show selection column as fixed or not | boolean | - |
99
98
  | selectedRowKeys | Array of selected row keys | React.ReactText | [] |
100
99
  | selections | Selections options available in table title | SelectionItem[] | - |
@@ -105,19 +104,18 @@ This type of table requires a specific type of dataSource which has to contain a
105
104
 
106
105
  #### SelectionStatus
107
106
 
108
- | Property | Description | Type | Default |
109
- | --------------- | ------------------------------------------------ | --------------------------------------------------------------- | ------- |
110
- | unavailable | Skips rendering checkbox if true | boolean | - |
111
- | disabled | Renders checkbox in disabled state | boolean | - |
112
-
107
+ | Property | Description | Type | Default |
108
+ | ----------- | ---------------------------------- | ------- | ------- |
109
+ | unavailable | Skips rendering checkbox if true | boolean | - |
110
+ | disabled | Renders checkbox in disabled state | boolean | - |
113
111
 
114
112
  #### RowStar
115
113
 
116
114
  | Property | Description | Type | Default |
117
- | --------------- | ------------------------------------------------ | --------------------------------------------------------------- | ------- |
115
+ | ---------------------- | ------------------------------------------------------ | -------------------------------------------------------------------------- | ------- |
118
116
  | className | Classname of star component | string | - |
119
117
  | starredRowKeys | Array of keys of starred rows | string[] | - |
120
- | renderCell | Overrides render method | `ColumnType<T>['render']` | - |
118
+ | renderCell | Overrides render method | `ColumnType<T>['render']` | - |
121
119
  | onClick | Callback called when user clicks on star component | (e: React.MouseEvent<HTMLElement, MouseEvent>) => void | - |
122
120
  | onChange | Callback called when user change starred status of row | (starredRowKeys: string[], starredKey: string, isStarred: boolean) => void | - |
123
121
  | disableForExpandedRows | Hides star components on child rows | boolean | - |
@@ -177,38 +175,38 @@ Same as `onRow` `onHeaderRow` `onCell` `onHeaderCell`
177
175
 
178
176
  One of the Table `columns` prop for describing the table's columns, Column has the same API.
179
177
 
180
- | Property | Description | Type | Default | Version |
181
- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- | ----------------------- | ----------- |
182
- | align | specify which way that column is aligned | `left` / `right` / `center` | `left` | 3.3.2 |
183
- | className | className of this column | string | - | |
184
- | colSpan | Span of this column's title | number | | |
185
- | dataIndex | Display field of the data record, could be set like `a.b.c`, `a[0].b.c[1]` | string | - | |
186
- | defaultSortOrder | Default order of sorted values | `ascend` / `descend` | - | |
187
- | filterDropdown | Customized filter overlay | ReactNode | - | |
188
- | filterDropdownVisible | Whether `filterDropdown` is visible | boolean | - | |
189
- | filtered | Whether the `dataSource` is filtered | boolean | `false` | |
190
- | filteredValue | Controlled filtered value, filter icon will highlight | string / [] | - | |
191
- | filterIcon | Customized filter icon | React.ReactNode / (filtered: boolean) => React.ReactNode | `false` | |
192
- | filterMultiple | Whether multiple filters can be selected | boolean | `true` | |
193
- | filters | Filter menu config | object / [] | - | |
194
- | fixed | Set column to be fixed: `true`(same as left) `'left'` `'right'` | boolean / string | `false` | |
195
- | itemsMenu | Component with menu for selected items | React.ReactNode | - | |
196
- | key | Unique key of this column, you can ignore this prop if you've set a unique `dataIndex` | string | - | |
197
- | maxWidth | Maximal width of this column | string / number | - | |
198
- | minWidth | Minimal of this column. If not provided, defaults to `width` property. | string / number | - | |
199
- | render | Renderer of the table cell. The return value should be a ReactNode, or an object for [colSpan/rowSpan config](#components-table-demo-colspan-rowspan) | (value, record, index) => React.ReactNode | - | |
200
- | childRender | Renderer of the table cell in child row - available only on virtual tables. The return value should be a ReactNode, or an object for [colSpan/rowSpan config](#components-table-demo-colspan-rowspan) | (value, record, index) => React.ReactNode | - | |
201
- | search | Search input value | string | - | |
202
- | sorter | Sort function for local sort, see [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)'s compareFunction. If you need sort buttons only, set to `true`.<br />Use `object` for multi sorting:<br />`{ compare: (a, b) => a.math - b.math, <br />multiple: 2 }` | `function / boolean / object` | - | |
203
- | sortOrder | Order of sorted values: `'ascend'` `'descend'` `false` | boolean / string | - | |
204
- | sortDirections | supported sort way, could be `'ascend'`, `'descend'` | Array | `['ascend', 'descend']` | 3.15.2 |
205
- | sortRender | How to render sort buttons and options. Values: `'default'`, `'string'`, `(sortStateApi: SortStateAPI, column: DSColumnType<T>) => React.ReactElement` | `string / function / 'default'` | `'default'` | |
206
- | title | Title of this column | React.ReactNode / ({ sortOrder, filters }) => React.ReactNode | - | |
207
- | width | Width of this column | string / number | - | |
208
- | onCell | Set props on per cell | (record, rowIndex: number) => object | - | |
209
- | onFilter | Callback executed when the confirm filter button is clicked | () => void | - | |
210
- | onFilterDropdownVisibleChange | Callback executed when `filterDropdownVisible` is changed | (visible: boolean) => void | - | |
211
- | onHeaderCell | Set props on per header cell | (column) => object | - | |
178
+ | Property | Description | Type | Default | Version |
179
+ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- | ----------------------- | ------- |
180
+ | align | specify which way that column is aligned | `left` / `right` / `center` | `left` | 3.3.2 |
181
+ | className | className of this column | string | - | |
182
+ | colSpan | Span of this column's title | number | | |
183
+ | dataIndex | Display field of the data record, could be set like `a.b.c`, `a[0].b.c[1]` | string | - | |
184
+ | defaultSortOrder | Default order of sorted values | `ascend` / `descend` | - | |
185
+ | filterDropdown | Customized filter overlay | ReactNode | - | |
186
+ | filterDropdownVisible | Whether `filterDropdown` is visible | boolean | - | |
187
+ | filtered | Whether the `dataSource` is filtered | boolean | `false` | |
188
+ | filteredValue | Controlled filtered value, filter icon will highlight | string / [] | - | |
189
+ | filterIcon | Customized filter icon | React.ReactNode / (filtered: boolean) => React.ReactNode | `false` | |
190
+ | filterMultiple | Whether multiple filters can be selected | boolean | `true` | |
191
+ | filters | Filter menu config | object / [] | - | |
192
+ | fixed | Set column to be fixed: `true`(same as left) `'left'` `'right'` | boolean / string | `false` | |
193
+ | itemsMenu | Component with menu for selected items | React.ReactNode | - | |
194
+ | key | Unique key of this column, you can ignore this prop if you've set a unique `dataIndex` | string | - | |
195
+ | maxWidth | Maximal width of this column | string / number | - | |
196
+ | minWidth | Minimal of this column. If not provided, defaults to `width` property. | string / number | - | |
197
+ | render | Renderer of the table cell. The return value should be a ReactNode, or an object for [colSpan/rowSpan config](#components-table-demo-colspan-rowspan) | (value, record, index) => React.ReactNode | - | |
198
+ | childRender | Renderer of the table cell in child row - available only on virtual tables. The return value should be a ReactNode, or an object for [colSpan/rowSpan config](#components-table-demo-colspan-rowspan) | (value, record, index) => React.ReactNode | - | |
199
+ | search | Search input value | string | - | |
200
+ | sorter | Sort function for local sort, see [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort)'s compareFunction. If you need sort buttons only, set to `true`.<br />Use `object` for multi sorting:<br />`{ compare: (a, b) => a.math - b.math, <br />multiple: 2 }` | `function / boolean / object` | - | |
201
+ | sortOrder | Order of sorted values: `'ascend'` `'descend'` `false` | boolean / string | - | |
202
+ | sortDirections | supported sort way, could be `'ascend'`, `'descend'` | Array | `['ascend', 'descend']` | 3.15.2 |
203
+ | sortRender | How to render sort buttons and options. Values: `'default'`, `'string'`, `(sortStateApi: SortStateAPI, column: DSColumnType<T>) => React.ReactElement` | `string / function / 'default'` | `'default'` | |
204
+ | title | Title of this column | React.ReactNode / ({ sortOrder, filters }) => React.ReactNode | - | |
205
+ | width | Width of this column | string / number | - | |
206
+ | onCell | Set props on per cell | (record, rowIndex: number) => object | - | |
207
+ | onFilter | Callback executed when the confirm filter button is clicked | () => void | - | |
208
+ | onFilterDropdownVisibleChange | Callback executed when `filterDropdownVisible` is changed | (visible: boolean) => void | - | |
209
+ | onHeaderCell | Set props on per header cell | (column) => object | - | |
212
210
 
213
211
  ### ColumnGroup
214
212
 
@@ -1,17 +1,19 @@
1
- import { ColumnsType } from 'antd/lib/table';
2
- import React from 'react';
3
- import { GroupType as GroupByType } from '@synerise/ds-column-manager/dist/ColumnManager.types';
1
+ import type { ColumnsType } from 'antd/lib/table';
2
+ export type GroupByType = 'value' | 'ranges' | 'interval' | string | undefined;
4
3
  export type SortOrderType = 'ascend' | 'descend' | boolean;
5
4
  export type GroupColumnsType<T> = ColumnsType<T> & {
6
5
  sortOrder: SortOrderType;
7
- key: React.ReactText;
6
+ key: string | number;
8
7
  render: Function;
9
- dataIndex: React.ReactText;
8
+ dataIndex: string | number;
10
9
  };
11
10
  export type GroupType<T> = {
12
11
  column: string;
13
- value: React.ReactText | boolean | object;
14
- key: React.ReactText;
12
+ value: string | number | boolean | object;
13
+ key: string | number;
15
14
  rows: T[];
16
15
  groupType: GroupByType;
17
16
  };
17
+ export declare const GROUP_BY: {
18
+ [key: string]: string;
19
+ };
@@ -1 +1,6 @@
1
- export {};
1
+ export var GROUP_BY = {
2
+ value: 'value',
3
+ ranges: 'ranges',
4
+ interval: 'interval',
5
+ disabled: 'disabled'
6
+ };
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import Checkbox from '@synerise/ds-checkbox/dist';
2
+ import Checkbox from '@synerise/ds-checkbox';
3
3
  import Status from '@synerise/ds-status';
4
4
  import Button from '@synerise/ds-button';
5
5
  import Icon, { AddS } from '@synerise/ds-icon';
6
- import { GROUP_BY } from '@synerise/ds-column-manager/dist/ColumnManagerGroupSettings/ColumnManagerGroupSettings.types';
7
6
  import * as S from '../GroupTable.styles';
7
+ import { GROUP_BY } from '../GroupTable.types';
8
8
  import { useRowKey } from '../../hooks/useRowKey';
9
9
  function GroupTableBody(_ref) {
10
10
  var group = _ref.group,
package/dist/Table.d.ts CHANGED
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  import '@synerise/ds-core/dist/js/style';
3
3
  import './style/index.less';
4
4
  import { DSTableProps } from './Table.types';
5
- export declare const SELECTION_ALL = "SELECTION_ALL";
6
- export declare const SELECTION_INVERT = "SELECTION_INVERT";
7
5
  declare const DSTable: {
8
6
  <T extends object>(props: DSTableProps<T>): React.JSX.Element;
9
7
  SELECTION_ALL: string;
package/dist/Table.js CHANGED
@@ -11,15 +11,8 @@ import * as S from './Table.styles';
11
11
  import TableHeader from './TableHeader/TableHeader';
12
12
  import DefaultTable from './DefaultTable/DefaultTable';
13
13
  import GroupTable from './GroupTable/GroupTable';
14
- import { useTableLocale, TableLocaleContext } from './utils/locale';
15
- import { getChildrenColumnName } from './utils/getChildrenColumnName';
16
- import { getSkeletonProps } from './utils/getSkeletonProps';
17
- export var SELECTION_ALL = 'SELECTION_ALL';
18
- export var SELECTION_INVERT = 'SELECTION_INVERT';
19
- var ITEM_RENDER_TYPE = {
20
- prev: 'prev',
21
- next: 'next'
22
- };
14
+ import { useTableLocale, TableLocaleContext, getChildrenColumnName, getSkeletonProps, isGrouped } from './utils';
15
+ import { SELECTION_INVERT, SELECTION_ALL, ITEM_RENDER_TYPE } from './constants/Table.constants';
23
16
  var DSTable = function DSTable(props) {
24
17
  var intl = useIntl();
25
18
  var title = props.title,
@@ -47,18 +40,20 @@ var DSTable = function DSTable(props) {
47
40
  disableColumnNamesLineBreak = props.disableColumnNamesLineBreak,
48
41
  expandable = props.expandable,
49
42
  columns = props.columns,
50
- skeletonProps = props.skeletonProps;
43
+ skeletonProps = props.skeletonProps,
44
+ isCounterLoading = props.isCounterLoading;
51
45
  var tableLocale = useTableLocale(intl, locale);
52
46
  var _useDataFormat = useDataFormat(),
53
47
  formatValue = _useDataFormat.formatValue;
54
48
  var renderHeader = useCallback(function () {
55
49
  var size = selection && (selection == null ? void 0 : selection.selectedRowKeys) && (selection == null ? void 0 : selection.selectedRowKeys.length);
56
- var data = grouped ? // @ts-ignore
57
- dataSource == null ? void 0 : dataSource.reduce(function (items, group) {
50
+ var data = grouped && isGrouped(dataSource) ? dataSource == null ? void 0 : dataSource.reduce(function (items, group) {
58
51
  if (group.rows) {
59
- return [].concat(items, group.rows);
52
+ var merged = [].concat(items, group.rows);
53
+ return merged;
60
54
  }
61
- return [].concat(items);
55
+ var result = [].concat(items);
56
+ return result;
62
57
  }, []) : dataSource;
63
58
  var totalCount = dataSourceTotalCount || (dataSource == null ? void 0 : dataSource.length) || (dataSourceFull == null ? void 0 : dataSourceFull.length);
64
59
  return !hideTitleBar ? /*#__PURE__*/React.createElement(TableHeader, {
@@ -71,6 +66,7 @@ var DSTable = function DSTable(props) {
71
66
  dataSource: data,
72
67
  dataSourceFull: dataSourceFull,
73
68
  dataSourceTotalCount: totalCount,
69
+ isCounterLoading: isCounterLoading,
74
70
  searchComponent: searchComponent,
75
71
  filterComponent: filterComponent,
76
72
  headerButton: headerButton,
@@ -81,7 +77,7 @@ var DSTable = function DSTable(props) {
81
77
  childrenColumnName: getChildrenColumnName(expandable == null ? void 0 : expandable.childrenColumnName),
82
78
  isLoading: loading
83
79
  }) : /*#__PURE__*/React.createElement(React.Fragment, null);
84
- }, [selection, grouped, dataSource, dataSourceTotalCount, dataSourceFull, hideTitleBar, headerWithBorderTop, title, filters, itemsMenu, searchComponent, filterComponent, headerButton, rowKey, tableLocale, renderSelectionTitle, hideTitlePart, expandable == null ? void 0 : expandable.childrenColumnName, loading]);
80
+ }, [selection, grouped, dataSource, dataSourceTotalCount, dataSourceFull, hideTitleBar, headerWithBorderTop, title, filters, itemsMenu, searchComponent, filterComponent, headerButton, rowKey, tableLocale, renderSelectionTitle, hideTitlePart, expandable == null ? void 0 : expandable.childrenColumnName, loading, isCounterLoading]);
85
81
  var footerPagination = useMemo(function () {
86
82
  return _extends({
87
83
  showTotal: function showTotal(total, range) {
@@ -31,7 +31,9 @@ export declare const TableWrapper: import("styled-components").StyledComponent<"
31
31
  hideColumnNames?: boolean | undefined;
32
32
  disableColumnNamesLineBreak?: boolean | undefined;
33
33
  }, never>;
34
- export declare const Skeleton: import("styled-components").StyledComponent<({ size, numberOfSkeletons, width, height, className }: import("@synerise/ds-skeleton").SkeletonProps) => import("react").JSX.Element, any, {}, never>;
34
+ export declare const Skeleton: import("styled-components").StyledComponent<({ size, numberOfSkeletons, width, height, className }: import("@synerise/ds-skeleton").SkeletonProps) => import("react").JSX.Element, any, {
35
+ skeletonWidth?: string | undefined;
36
+ }, never>;
35
37
  export declare const TableSkeletonCell: import("styled-components").StyledComponent<"div", any, {
36
38
  height?: number | undefined;
37
39
  width?: string | undefined;
@@ -29,7 +29,7 @@ export var TitlePartEllipsis = styled(Text).withConfig({
29
29
  export var TitlePart = styled.span.withConfig({
30
30
  displayName: "Tablestyles__TitlePart",
31
31
  componentId: "sc-dacfhr-4"
32
- })(["flex-shrink:0;"]);
32
+ })(["display:flex;align-items:center;gap:4px;"]);
33
33
  export var TitleSeparator = styled.span.withConfig({
34
34
  displayName: "Tablestyles__TitleSeparator",
35
35
  componentId: "sc-dacfhr-5"
@@ -142,7 +142,9 @@ export var TableWrapper = styled.div.withConfig({
142
142
  export var Skeleton = styled(DSSkeleton).withConfig({
143
143
  displayName: "Tablestyles__Skeleton",
144
144
  componentId: "sc-dacfhr-16"
145
- })(["padding:0;"]);
145
+ })(["padding:0;", ""], function (props) {
146
+ return props.skeletonWidth && "width: " + props.skeletonWidth + ";";
147
+ });
146
148
  export var TableSkeletonCell = styled.div.withConfig({
147
149
  displayName: "Tablestyles__TableSkeletonCell",
148
150
  componentId: "sc-dacfhr-17"
@@ -7,7 +7,7 @@ import type { GroupType } from './GroupTable/GroupTable.types';
7
7
  import type { RowStar } from './hooks/useRowStar';
8
8
  import type { SortRender } from './ColumnSortMenu/TitleWithSort';
9
9
  import type { ColumnSortOrder, ColumnsSortState } from './ColumnSortMenu/useSortState';
10
- export type AntTableProps<T> = Omit<TableProps<T>, 'title' | 'subTitle' | 'onSearch' | 'itemsMenu' | 'search' | 'locale' | 'columns'>;
10
+ export type AntTableProps<T> = Omit<TableProps<T>, 'title' | 'subTitle' | 'onSearch' | 'itemsMenu' | 'search' | 'locale' | 'columns' | 'loading'>;
11
11
  export type Selection = {
12
12
  key: string;
13
13
  label: string;
@@ -101,6 +101,7 @@ export type OnSortFn = (singleColumnSort: SingleColumnSort, sortState: ColumnsSo
101
101
  export type DSTableProps<T extends any & GroupType<T>> = AntTableProps<T> & {
102
102
  title?: ReactNode | (() => ReactNode);
103
103
  hideTitleBar?: boolean;
104
+ loading?: boolean;
104
105
  headerWithBorderTop?: boolean;
105
106
  itemsMenu?: string | ReactNode;
106
107
  search?: string;
@@ -126,6 +127,7 @@ export type DSTableProps<T extends any & GroupType<T>> = AntTableProps<T> & {
126
127
  onSort?: OnSortFn;
127
128
  dataSourceFull?: T[];
128
129
  dataSourceTotalCount?: number;
130
+ isCounterLoading?: boolean;
129
131
  skeletonProps?: {
130
132
  maxHeight?: number;
131
133
  headerHeight?: number;
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
- declare const TableHeader: ({ title, filters, searchComponent, filterComponent, selectedRows, itemsMenu, selection, dataSource, dataSourceFull, dataSourceTotalCount, rowKey, withBorderTop, headerButton, locale, renderSelectionTitle, hideTitlePart, childrenColumnName, isLoading, }: any) => React.JSX.Element;
2
+ import { Props } from './TableHeader.types';
3
+ declare const TableHeader: <T extends object>({ title, filters, searchComponent, filterComponent, selectedRows, itemsMenu, selection, dataSource, dataSourceFull, dataSourceTotalCount, isCounterLoading, rowKey, withBorderTop, headerButton, locale, renderSelectionTitle, hideTitlePart, childrenColumnName, isLoading, }: Props<T>) => React.JSX.Element;
3
4
  export default TableHeader;
@@ -1,3 +1,4 @@
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
1
2
  import React, { useMemo } from 'react';
2
3
  import { useDataFormat } from '@synerise/ds-data-format';
3
4
  import * as S from '../Table.styles';
@@ -12,9 +13,11 @@ var TableHeader = function TableHeader(_ref) {
12
13
  selectedRows = _ref.selectedRows,
13
14
  itemsMenu = _ref.itemsMenu,
14
15
  selection = _ref.selection,
15
- dataSource = _ref.dataSource,
16
+ _ref$dataSource = _ref.dataSource,
17
+ dataSource = _ref$dataSource === void 0 ? [] : _ref$dataSource,
16
18
  dataSourceFull = _ref.dataSourceFull,
17
19
  dataSourceTotalCount = _ref.dataSourceTotalCount,
20
+ isCounterLoading = _ref.isCounterLoading,
18
21
  rowKey = _ref.rowKey,
19
22
  withBorderTop = _ref.withBorderTop,
20
23
  headerButton = _ref.headerButton,
@@ -28,9 +31,8 @@ var TableHeader = function TableHeader(_ref) {
28
31
  var renderLeftSide = useMemo(function () {
29
32
  var _locale$pagination;
30
33
  var _ref2 = selection || {},
31
- limit = _ref2.limit,
32
34
  hideSelectAll = _ref2.hideSelectAll;
33
- if (limit) {
35
+ if (selection && selection.limit) {
34
36
  return /*#__PURE__*/React.createElement(S.Left, {
35
37
  "data-testid": "ds-table-selection"
36
38
  }, selection && !hideSelectAll && /*#__PURE__*/React.createElement(TableSelection, {
@@ -43,9 +45,12 @@ var TableHeader = function TableHeader(_ref) {
43
45
  childrenColumnName: childrenColumnName
44
46
  }), /*#__PURE__*/React.createElement(TableLimit, {
45
47
  total: dataSourceTotalCount || dataSource.length,
46
- selection: selection,
48
+ selection: _extends({}, selection, {
49
+ limit: selection.limit
50
+ }),
47
51
  itemsMenu: itemsMenu,
48
- locale: locale
52
+ locale: locale,
53
+ isCounterLoading: isCounterLoading
49
54
  }));
50
55
  }
51
56
  return selectedRows && selectedRows > 0 ? /*#__PURE__*/React.createElement(S.Left, {
@@ -72,18 +77,23 @@ var TableHeader = function TableHeader(_ref) {
72
77
  }
73
78
  }, /*#__PURE__*/React.createElement(S.Skeleton, {
74
79
  width: "L",
75
- numberOfSkeletons: 1
80
+ numberOfSkeletons: 1,
81
+ skeletonWidth: "100px"
76
82
  })), !isLoading && title && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.TitlePartEllipsis, {
77
83
  ellipsis: {
78
84
  tooltipProps: {
79
- description: title,
85
+ description: /*#__PURE__*/React.createElement(React.Fragment, null, title),
80
86
  type: 'largeSimple',
81
87
  offset: 'small',
82
88
  autoAdjustOverflow: true
83
89
  }
84
90
  }
85
- }, title), !hideTitlePart && /*#__PURE__*/React.createElement(S.TitleSeparator, null)), !isLoading && !hideTitlePart && /*#__PURE__*/React.createElement(S.TitlePart, null, /*#__PURE__*/React.createElement("strong", null, formatValue(dataSourceTotalCount || dataSource.length)), ' ', /*#__PURE__*/React.createElement("span", null, locale == null || (_locale$pagination = locale.pagination) == null ? void 0 : _locale$pagination.items))));
86
- }, [selection, dataSourceTotalCount, dataSource, itemsMenu, locale, selectedRows, rowKey, dataSourceFull, childrenColumnName, renderSelectionTitle, filters, formatValue, title, hideTitlePart, isLoading]);
91
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, title)), !hideTitlePart && /*#__PURE__*/React.createElement(S.TitleSeparator, null)), !isLoading && !hideTitlePart && /*#__PURE__*/React.createElement(S.TitlePart, null, isCounterLoading ? /*#__PURE__*/React.createElement(S.Skeleton, {
92
+ numberOfSkeletons: 1,
93
+ size: "S",
94
+ skeletonWidth: "100px"
95
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("strong", null, formatValue(dataSourceTotalCount || dataSource.length)), /*#__PURE__*/React.createElement("span", null, locale == null || (_locale$pagination = locale.pagination) == null ? void 0 : _locale$pagination.items)))));
96
+ }, [selection, dataSourceTotalCount, dataSource, itemsMenu, locale, selectedRows, rowKey, dataSourceFull, isCounterLoading, childrenColumnName, renderSelectionTitle, filters, formatValue, title, hideTitlePart, isLoading]);
87
97
  return /*#__PURE__*/React.createElement(S.Header, {
88
98
  withBorderTop: withBorderTop
89
99
  }, renderLeftSide, /*#__PURE__*/React.createElement(S.Right, null, headerButton, filters == null ? void 0 : filters.map(function (filter) {
@@ -1,15 +1,14 @@
1
- import { ReactText, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { Filter, Locale, RowSelection } from '../Table.types';
3
- export type Props<T extends {
4
- key: ReactText;
5
- }> = {
6
- title?: ReactNode;
3
+ export type Props<T extends object> = {
4
+ title?: ReactNode | (() => ReactNode);
7
5
  filters?: Filter[];
8
6
  selectedRows?: number;
9
7
  itemsMenu: ReactNode;
10
8
  selection?: RowSelection<T>;
11
- dataSource: T[];
9
+ dataSource?: readonly T[];
12
10
  dataSourceFull?: T[];
11
+ isCounterLoading?: boolean;
13
12
  searchComponent?: ReactNode;
14
13
  filterComponent?: ReactNode;
15
14
  rowKey?: Function | string;
@@ -1,6 +1,5 @@
1
- import React, { ReactText } from 'react';
1
+ import React from 'react';
2
2
  import { TableLimitProps } from './TableLimit.types';
3
3
  export declare function TableLimit<T extends {
4
- key: ReactText;
5
4
  children?: T[];
6
- }>({ total, locale, itemsMenu, selection, }: TableLimitProps<T>): React.JSX.Element;
5
+ }>({ total, locale, itemsMenu, selection, isCounterLoading, }: TableLimitProps<T>): React.JSX.Element;
@@ -2,11 +2,13 @@ import React, { useMemo } from 'react';
2
2
  import Alert from '@synerise/ds-alert';
3
3
  import { useDataFormat } from '@synerise/ds-data-format';
4
4
  import * as S from './TableLimit.styles';
5
+ import { Skeleton } from '../../Table.styles';
5
6
  export function TableLimit(_ref) {
6
7
  var total = _ref.total,
7
8
  locale = _ref.locale,
8
9
  itemsMenu = _ref.itemsMenu,
9
- selection = _ref.selection;
10
+ selection = _ref.selection,
11
+ isCounterLoading = _ref.isCounterLoading;
10
12
  var _useDataFormat = useDataFormat(),
11
13
  formatValue = _useDataFormat.formatValue;
12
14
  var selectedRowKeys = selection.selectedRowKeys,
@@ -22,7 +24,11 @@ export function TableLimit(_ref) {
22
24
  }, [locale, selectedRows, limit]);
23
25
  var selected = useMemo(function () {
24
26
  var _locale$pagination;
25
- return selectedRows > 0 ? /*#__PURE__*/React.createElement(S.Title, null, /*#__PURE__*/React.createElement("strong", null, formatValue(selectedRows) + " / " + formatValue(limit)), " ", locale.selected) : /*#__PURE__*/React.createElement(S.Title, null, /*#__PURE__*/React.createElement("strong", null, formatValue(total)), " ", (_locale$pagination = locale.pagination) == null ? void 0 : _locale$pagination.items);
26
- }, [formatValue, limit, locale.pagination, locale.selected, selectedRows, total]);
27
+ return selectedRows > 0 ? /*#__PURE__*/React.createElement(S.Title, null, /*#__PURE__*/React.createElement("strong", null, formatValue(selectedRows) + " / " + formatValue(limit)), " ", locale.selected) : /*#__PURE__*/React.createElement(S.Title, null, isCounterLoading ? /*#__PURE__*/React.createElement(Skeleton, {
28
+ numberOfSkeletons: 1,
29
+ size: "S",
30
+ skeletonWidth: "100px"
31
+ }) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("strong", null, formatValue(total)), " ", (_locale$pagination = locale.pagination) == null ? void 0 : _locale$pagination.items));
32
+ }, [formatValue, limit, locale.pagination, locale.selected, isCounterLoading, selectedRows, total]);
27
33
  return /*#__PURE__*/React.createElement(S.TableLimit, null, selected, limitReachedInfo, selectedRows > 0 && /*#__PURE__*/React.createElement(S.ItemsMenu, null, itemsMenu));
28
34
  }
@@ -7,7 +7,7 @@ export var TableLimit = styled.div.withConfig({
7
7
  export var Title = styled.div.withConfig({
8
8
  displayName: "TableLimitstyles__Title",
9
9
  componentId: "sc-8y43k7-1"
10
- })(["", ";color:", ";strong{font-weight:500;}"], macro.small, function (props) {
10
+ })(["", ";color:", ";strong{font-weight:500;}display:flex;align-items:center;gap:4px;"], macro.small, function (props) {
11
11
  return props.theme.palette['grey-700'];
12
12
  });
13
13
  export var Alert = styled.div.withConfig({
@@ -1,11 +1,10 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { RequiredProps } from '@synerise/ds-utils';
3
3
  import { Locale, RowSelection } from '../../Table.types';
4
- export type TableLimitProps<T extends {
5
- key: string | number;
6
- }> = {
4
+ export type TableLimitProps<T extends object> = {
7
5
  selection: RequiredProps<RowSelection<T>, 'limit'>;
8
6
  total: number;
9
7
  itemsMenu: ReactNode;
10
8
  locale: Locale;
9
+ isCounterLoading?: boolean;
11
10
  };
@@ -1,8 +1,6 @@
1
1
  import React from 'react';
2
- import type { ReactText } from 'react';
3
2
  import type { TableSelectionProps } from './TableSelection.types';
4
3
  declare const TableSelection: <T extends {
5
- key: ReactText;
6
4
  children?: T[] | undefined;
7
5
  }>({ dataSource, dataSourceFull, selection, rowKey, locale, hasSelectionLimit, childrenColumnName, }: TableSelectionProps<T>) => React.JSX.Element | null;
8
6
  export default TableSelection;
@@ -5,7 +5,7 @@ import Button from '@synerise/ds-button';
5
5
  import Tooltip from '@synerise/ds-tooltip';
6
6
  import Icon, { OptionVerticalM } from '@synerise/ds-icon';
7
7
  import * as S from '../Table.styles';
8
- import { SELECTION_ALL, SELECTION_INVERT } from '../Table';
8
+ import { SELECTION_ALL, SELECTION_INVERT } from '../constants/Table.constants';
9
9
  import { isRecordSelectable } from '../utils';
10
10
  import { useRowKey } from '../hooks/useRowKey';
11
11
  import { useBulkSelectionCount } from '../hooks/useBulkSelection';
@@ -1,9 +1,7 @@
1
1
  import type { RowSelection, Locale } from '../Table.types';
2
- export type TableSelectionProps<T extends {
3
- key: string | number;
4
- }> = {
2
+ export type TableSelectionProps<T extends object> = {
5
3
  selection?: RowSelection<T>;
6
- dataSource: T[];
4
+ dataSource: readonly T[];
7
5
  dataSourceFull?: T[];
8
6
  locale?: Locale;
9
7
  rowKey?: Function | string;
@@ -13,6 +11,4 @@ export type TableSelectionProps<T extends {
13
11
  /**
14
12
  * @deprecated use TableSelectionProps instead
15
13
  */
16
- export type Props<T extends {
17
- key: string | number;
18
- }> = TableSelectionProps<T>;
14
+ export type Props<T extends object> = TableSelectionProps<T>;
@@ -41,7 +41,6 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
41
41
  _props$dataSource = props.dataSource,
42
42
  dataSource = _props$dataSource === void 0 ? [] : _props$dataSource,
43
43
  dataSourceFull = props.dataSourceFull,
44
- dataSourceTotalCount = props.dataSourceTotalCount,
45
44
  expandable = props.expandable,
46
45
  locale = props.locale,
47
46
  loading = props.loading,
@@ -540,7 +539,6 @@ var VirtualTable = function VirtualTable(props, forwardedRef) {
540
539
  components: {
541
540
  body: renderBody
542
541
  },
543
- dataSourceTotalCount: dataSourceTotalCount,
544
542
  locale: tableLocale
545
543
  }))), !!(infiniteScroll != null && infiniteScroll.showBackToTopButton) && /*#__PURE__*/React.createElement(BackToTopButton, {
546
544
  onClick: scrollToTop
@@ -0,0 +1,6 @@
1
+ export declare const SELECTION_ALL = "SELECTION_ALL";
2
+ export declare const SELECTION_INVERT = "SELECTION_INVERT";
3
+ export declare const ITEM_RENDER_TYPE: {
4
+ prev: string;
5
+ next: string;
6
+ };
@@ -0,0 +1,6 @@
1
+ export var SELECTION_ALL = 'SELECTION_ALL';
2
+ export var SELECTION_INVERT = 'SELECTION_INVERT';
3
+ export var ITEM_RENDER_TYPE = {
4
+ prev: 'prev',
5
+ next: 'next'
6
+ };
@@ -1,4 +1,3 @@
1
- import { ReactText } from 'react';
2
1
  import { Props as TableSelectionType } from '../../TableHeader/TableSelection.types';
3
2
  type BulkSelectionType = {
4
3
  allRecordsCount: number;
@@ -6,7 +5,5 @@ type BulkSelectionType = {
6
5
  selectableAndSelectedRecordsCount: number;
7
6
  selectedRecordsCount: number;
8
7
  };
9
- export declare const useBulkSelectionCount: <T extends {
10
- key: ReactText;
11
- }>({ dataSource, selection, childrenColumnName, rowKey, }: TableSelectionType<T>) => BulkSelectionType;
8
+ export declare const useBulkSelectionCount: <T extends object>({ dataSource, selection, childrenColumnName, rowKey, }: TableSelectionType<T>) => BulkSelectionType;
12
9
  export {};
package/dist/index.d.ts CHANGED
@@ -8,3 +8,4 @@ export { GroupedTable, VirtualTable, TableCell, ItemsMenu, TreeTable };
8
8
  export { default as BackToTopButton } from './InfiniteScroll/BackToTopButton';
9
9
  export type { Props as VirtualTableProps, VirtualTableRef, VirtualColumnType } from './VirtualTable/VirtualTable.types';
10
10
  export type { RowSelection, RowType, SingleColumnSort, OnSortFn, Locale, DSColumnType, DSTableProps, ScrollProxyType, Selection, SelectionItem, CustomizeScrollBodyInfo, } from './Table.types';
11
+ export { GROUP_BY } from './GroupTable/GroupTable.types';
package/dist/index.js CHANGED
@@ -5,4 +5,5 @@ import ItemsMenu from './ItemsMenu/ItemsMenu';
5
5
  import TreeTable from './TreeTable/TreeTable';
6
6
  export { default } from './Table';
7
7
  export { GroupedTable, VirtualTable, TableCell, ItemsMenu, TreeTable };
8
- export { default as BackToTopButton } from './InfiniteScroll/BackToTopButton';
8
+ export { default as BackToTopButton } from './InfiniteScroll/BackToTopButton';
9
+ export { GROUP_BY } from './GroupTable/GroupTable.types';
@@ -1,8 +1,9 @@
1
- export * from './getValueFromPath';
2
- export * from './locale';
3
- export * from './locale';
4
- export * from './calculatePixels';
5
- export * from './getRecordSelectionStatus';
6
1
  export * from './calculateColumnWidths';
2
+ export * from './calculatePixels';
7
3
  export * from './getChildrenColumnName';
4
+ export * from './getRecordSelectionStatus';
5
+ export * from './getSkeletonProps';
6
+ export * from './getValueFromPath';
7
+ export * from './isGrouped';
8
8
  export * from './isRecordSelectable';
9
+ export * from './locale';
@@ -1,8 +1,9 @@
1
- export * from './getValueFromPath';
2
- export * from './locale';
3
- export * from './locale';
4
- export * from './calculatePixels';
5
- export * from './getRecordSelectionStatus';
6
1
  export * from './calculateColumnWidths';
2
+ export * from './calculatePixels';
7
3
  export * from './getChildrenColumnName';
8
- export * from './isRecordSelectable';
4
+ export * from './getRecordSelectionStatus';
5
+ export * from './getSkeletonProps';
6
+ export * from './getValueFromPath';
7
+ export * from './isGrouped';
8
+ export * from './isRecordSelectable';
9
+ export * from './locale';
@@ -0,0 +1,2 @@
1
+ import type { GroupType } from '../GroupTable/GroupTable.types';
2
+ export declare const isGrouped: <T extends object>(dataSource?: readonly T[] | GroupType<T>[] | undefined) => dataSource is GroupType<T>[];
@@ -0,0 +1,3 @@
1
+ export var isGrouped = function isGrouped(dataSource) {
2
+ return !!(dataSource != null && dataSource.length && 'rows' in dataSource[0]);
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-table",
3
- "version": "1.1.14",
3
+ "version": "1.2.1",
4
4
  "description": "Table UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "synerise/synerise-design",
@@ -34,31 +34,31 @@
34
34
  ],
35
35
  "types": "dist/index.d.ts",
36
36
  "dependencies": {
37
- "@synerise/ds-alert": "^1.1.3",
38
- "@synerise/ds-badge": "^1.0.9",
39
- "@synerise/ds-button": "^1.3.2",
40
- "@synerise/ds-button-group": "^1.1.2",
41
- "@synerise/ds-checkbox": "^1.0.9",
42
- "@synerise/ds-column-manager": "^1.0.13",
37
+ "@synerise/ds-alert": "^1.1.4",
38
+ "@synerise/ds-badge": "^1.0.10",
39
+ "@synerise/ds-button": "^1.3.3",
40
+ "@synerise/ds-button-group": "^1.1.3",
41
+ "@synerise/ds-checkbox": "^1.0.10",
42
+ "@synerise/ds-column-manager": "^1.1.1",
43
43
  "@synerise/ds-data-format": "^1.0.0",
44
- "@synerise/ds-dropdown": "^1.0.9",
44
+ "@synerise/ds-dropdown": "^1.0.11",
45
45
  "@synerise/ds-flag": "^1.0.0",
46
- "@synerise/ds-icon": "^1.5.1",
47
- "@synerise/ds-input": "^1.1.4",
48
- "@synerise/ds-loader": "^1.0.3",
49
- "@synerise/ds-menu": "^1.0.10",
50
- "@synerise/ds-modal": "^1.1.3",
51
- "@synerise/ds-pagination": "^1.0.10",
52
- "@synerise/ds-result": "^1.0.10",
53
- "@synerise/ds-scrollbar": "^1.0.9",
54
- "@synerise/ds-search": "^1.1.7",
55
- "@synerise/ds-select": "^1.1.4",
56
- "@synerise/ds-skeleton": "^1.0.10",
57
- "@synerise/ds-status": "^1.2.4",
58
- "@synerise/ds-tag": "^1.1.8",
59
- "@synerise/ds-tooltip": "^1.1.8",
60
- "@synerise/ds-typography": "^1.0.9",
61
- "@synerise/ds-utils": "^1.1.1",
46
+ "@synerise/ds-icon": "^1.5.2",
47
+ "@synerise/ds-input": "^1.2.0",
48
+ "@synerise/ds-loader": "^1.0.4",
49
+ "@synerise/ds-menu": "^1.0.11",
50
+ "@synerise/ds-modal": "^1.1.5",
51
+ "@synerise/ds-pagination": "^1.0.11",
52
+ "@synerise/ds-result": "^1.0.11",
53
+ "@synerise/ds-scrollbar": "^1.0.10",
54
+ "@synerise/ds-search": "^1.1.8",
55
+ "@synerise/ds-select": "^1.1.5",
56
+ "@synerise/ds-skeleton": "^1.0.11",
57
+ "@synerise/ds-status": "^1.2.5",
58
+ "@synerise/ds-tag": "^1.1.9",
59
+ "@synerise/ds-tooltip": "^1.1.9",
60
+ "@synerise/ds-typography": "^1.0.10",
61
+ "@synerise/ds-utils": "^1.2.0",
62
62
  "@types/react-window": "^1.8.5",
63
63
  "classnames": "2.3.2",
64
64
  "copy-to-clipboard": "^3.3.1",
@@ -77,5 +77,5 @@
77
77
  "react-intl": ">=3.12.0 <= 6.8",
78
78
  "styled-components": "^5.3.3"
79
79
  },
80
- "gitHead": "12eaee0c6431aac9a7b2dbc42e0f8567b3de7244"
80
+ "gitHead": "35c8f09d6a248f199237766c1f5181f4b3fc88af"
81
81
  }