hrm_ui_lib 2.4.7 → 2.4.8

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.
@@ -5,6 +5,7 @@ type Props = {
5
5
  withSelect: boolean;
6
6
  tableWidth: number;
7
7
  headerGroup: HeaderGroup;
8
+ uniqueKey: string;
8
9
  };
9
- export declare function Header({ headerGroup, tableWidth, withSelect, fixedHeader }: Props): ReactElement;
10
+ export declare function Header({ headerGroup, tableWidth, withSelect, uniqueKey, fixedHeader }: Props): ReactElement;
10
11
  export {};
@@ -4,7 +4,7 @@ import { calcColumnWidth, CHECKBOX_DEFAULT_WIDTH, CHECKBOX_HEADER_ID } from './u
4
4
  import { Text } from '../Text';
5
5
  import IconArrowDown from '../SVGIcons/IconArrowDown';
6
6
  import IconArrowUp from '../SVGIcons/IconArrowUp';
7
- export function Header({ headerGroup, tableWidth, withSelect, fixedHeader = false }) {
7
+ export function Header({ headerGroup, tableWidth, withSelect, uniqueKey, fixedHeader = false }) {
8
8
  return (_jsx("tr", Object.assign({}, headerGroup.getHeaderGroupProps(), { className: classNames({ fixed_header: fixedHeader }), children: headerGroup.headers.map(({ id, minWidth, maxWidth, width, widthInPercent, getHeaderProps, fixed, columnProps, render, isSorted, isSortedDesc, getSortByToggleProps }, i, arr) => {
9
9
  var _a;
10
10
  const isSelection = id === CHECKBOX_HEADER_ID;
@@ -16,6 +16,6 @@ export function Header({ headerGroup, tableWidth, withSelect, fixedHeader = fals
16
16
  fixed_column_right: fixed === 'right',
17
17
  fixed_checkbox: isSelection && ((_a = arr[i + 1]) === null || _a === void 0 ? void 0 : _a.fixed) === 'left',
18
18
  pointer: columnProps === null || columnProps === void 0 ? void 0 : columnProps.sortable
19
- }), style: style, children: _jsxs("div", { className: "flexbox align-items--center", children: [_jsx(Text, { weight: "bold", className: "table-header-title", children: render('Header') }), isSorted && isSortedDesc && _jsx(IconArrowDown, { size: "xsmall", className: "ml-4" }), isSorted && !isSortedDesc && _jsx(IconArrowUp, { size: "xsmall", className: "ml-4" }), !isSorted && (columnProps === null || columnProps === void 0 ? void 0 : columnProps.sortable) && (_jsx(IconArrowDown, { size: "xsmall", className: "ml-4 unsorted__icon" }))] }) }), i));
19
+ }), style: style, children: _jsxs("div", { className: "flexbox align-items--center", children: [_jsx(Text, { weight: "bold", className: "table-header-title", children: render('Header') }), isSorted && isSortedDesc && _jsx(IconArrowDown, { size: "xsmall", className: "ml-4" }), isSorted && !isSortedDesc && _jsx(IconArrowUp, { size: "xsmall", className: "ml-4" }), !isSorted && (columnProps === null || columnProps === void 0 ? void 0 : columnProps.sortable) && (_jsx(IconArrowDown, { size: "xsmall", className: "ml-4 unsorted__icon" }))] }) }), `table_head_${uniqueKey}_${i}`));
20
20
  }) })));
21
21
  }
@@ -5,6 +5,7 @@ type Props = {
5
5
  handleRowClick?: (row: any) => void;
6
6
  withSelect: boolean;
7
7
  selectedFlatRows: RowType[];
8
+ uniqueKey: string;
8
9
  };
9
- export declare function Row({ row, selectedFlatRows, withSelect, handleRowClick }: Props): ReactElement;
10
+ export declare function Row({ row, selectedFlatRows, withSelect, uniqueKey, handleRowClick }: Props): ReactElement;
10
11
  export {};
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { CHECKBOX_DEFAULT_WIDTH, CHECKBOX_HEADER_ID } from './utils';
5
- export function Row({ row, selectedFlatRows, withSelect, handleRowClick }) {
5
+ export function Row({ row, selectedFlatRows, withSelect, uniqueKey, handleRowClick }) {
6
6
  const isRowSelected = useMemo(() => selectedFlatRows.find((r) => r.id === row.id), [selectedFlatRows]);
7
7
  return (_jsx("tr", Object.assign({}, row.getRowProps(), { className: classNames({ selected: Boolean(isRowSelected) }), onClick: () => handleRowClick === null || handleRowClick === void 0 ? void 0 : handleRowClick(row.original), children: row.cells.map(({ getCellProps, column, render }, i, arr) => {
8
8
  var _a;
@@ -13,6 +13,6 @@ export function Row({ row, selectedFlatRows, withSelect, handleRowClick }) {
13
13
  fixed_column_left: (column === null || column === void 0 ? void 0 : column.fixed) === 'left',
14
14
  fixed_column_right: (column === null || column === void 0 ? void 0 : column.fixed) === 'right',
15
15
  fixed_checkbox: isSelection && ((_a = arr[i + 1].column) === null || _a === void 0 ? void 0 : _a.fixed) === 'left'
16
- }), children: render('Cell') }), i));
16
+ }), children: render('Cell') }), `table_cell_${uniqueKey}_${i}`));
17
17
  }) })));
18
18
  }
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useEffect, useMemo, useRef, useState, useId } from 'react';
3
3
  import { useSortBy, useTable, useRowSelect } from 'react-table';
4
4
  import { setSelectedRows } from './utils';
5
5
  import { Row } from './Row';
@@ -9,6 +9,7 @@ import { useDispatchEventOnScroll } from '../../hooks/useDispatchEventOnScroll';
9
9
  export function Table({ columns, data, onChange, fixedHeader, withSelect = false, handleRowClick, className, containerRefHandler }) {
10
10
  const tableRef = useRef(null);
11
11
  const [tableWidth, setTableWidth] = useState(400);
12
+ const uniqueKey = useId();
12
13
  const dispatchScrollEvent = useDispatchEventOnScroll();
13
14
  const sortedColumns = useMemo(() => {
14
15
  const condition1 = (item) => item.fixed === 'left'; // Move even numbers to the start
@@ -56,8 +57,8 @@ export function Table({ columns, data, onChange, fixedHeader, withSelect = false
56
57
  window.removeEventListener('resize', handleResize);
57
58
  };
58
59
  }, [tableRef.current]);
59
- return (_jsx("div", { onScroll: dispatchScrollEvent, ref: containerRefHandler, className: classNames('table-wrapper scrollbar scrollbar--horizontal scrollbar--vertical', className), style: { maxHeight: fixedHeader === null || fixedHeader === void 0 ? void 0 : fixedHeader.y }, children: _jsxs("table", Object.assign({}, getTableProps(), { ref: tableRef, children: [_jsx("thead", { children: headerGroups.map((headerGroup, i) => (_jsx(Header, { withSelect: withSelect, fixedHeader: Boolean(fixedHeader), headerGroup: headerGroup, tableWidth: tableWidth }, i))) }), _jsx("tbody", Object.assign({}, getTableBodyProps(), { children: rows.map((row) => {
60
+ return (_jsx("div", { onScroll: dispatchScrollEvent, ref: containerRefHandler, className: classNames('table-wrapper scrollbar scrollbar--horizontal scrollbar--vertical', className), style: { maxHeight: fixedHeader === null || fixedHeader === void 0 ? void 0 : fixedHeader.y }, children: _jsxs("table", Object.assign({}, getTableProps(), { ref: tableRef, children: [_jsx("thead", { children: headerGroups.map((headerGroup, i) => (_jsx(Header, { withSelect: withSelect, fixedHeader: Boolean(fixedHeader), headerGroup: headerGroup, tableWidth: tableWidth, uniqueKey: uniqueKey }, `table_head_${uniqueKey}_${i}`))) }), _jsx("tbody", Object.assign({}, getTableBodyProps(), { children: rows.map((row) => {
60
61
  prepareRow(row);
61
- return (_jsx(Row, { handleRowClick: handleRowClick, withSelect: withSelect, selectedFlatRows: selectedFlatRows, row: row }, row.id));
62
+ return (_jsx(Row, { handleRowClick: handleRowClick, withSelect: withSelect, selectedFlatRows: selectedFlatRows, row: row, uniqueKey: uniqueKey }, `table_row_${uniqueKey}_${row.id}`));
62
63
  }) }))] })) }));
63
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "2.4.7",
3
+ "version": "2.4.8",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",