hrm_ui_lib 2.4.7 → 2.4.9

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 {};
@@ -1,21 +1,33 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
13
  import classNames from 'classnames';
3
14
  import { calcColumnWidth, CHECKBOX_DEFAULT_WIDTH, CHECKBOX_HEADER_ID } from './utils';
4
15
  import { Text } from '../Text';
5
16
  import IconArrowDown from '../SVGIcons/IconArrowDown';
6
17
  import IconArrowUp from '../SVGIcons/IconArrowUp';
7
- export function Header({ headerGroup, tableWidth, withSelect, fixedHeader = false }) {
18
+ export function Header({ headerGroup, tableWidth, withSelect, uniqueKey, fixedHeader = false }) {
8
19
  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
20
  var _a;
10
21
  const isSelection = id === CHECKBOX_HEADER_ID;
11
22
  const style = Object.assign(Object.assign(Object.assign({ width: isSelection
12
23
  ? CHECKBOX_DEFAULT_WIDTH
13
24
  : calcColumnWidth(widthInPercent, tableWidth), left: !isSelection && withSelect && fixed === 'left' ? CHECKBOX_DEFAULT_WIDTH : 0 }, (!isSelection && minWidth ? { minWidth } : {})), (!isSelection && maxWidth ? { maxWidth } : {})), (!isSelection && width ? { width } : {}));
14
- return (_jsx("th", Object.assign({}, getHeaderProps((columnProps === null || columnProps === void 0 ? void 0 : columnProps.sortable) ? getSortByToggleProps() : undefined), { className: classNames({
25
+ const _b = getHeaderProps((columnProps === null || columnProps === void 0 ? void 0 : columnProps.sortable) ? getSortByToggleProps() : undefined), { key: keyHead } = _b, headProps = __rest(_b, ["key"]);
26
+ return (_jsx("th", Object.assign({}, headProps, { className: classNames({
15
27
  fixed_column_left: fixed === 'left',
16
28
  fixed_column_right: fixed === 'right',
17
29
  fixed_checkbox: isSelection && ((_a = arr[i + 1]) === null || _a === void 0 ? void 0 : _a.fixed) === 'left',
18
30
  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));
31
+ }), 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
32
  }) })));
21
33
  }
@@ -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 {};
@@ -1,18 +1,31 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
1
12
  import { jsx as _jsx } from "react/jsx-runtime";
2
13
  import { useMemo } from 'react';
3
14
  import classNames from 'classnames';
4
15
  import { CHECKBOX_DEFAULT_WIDTH, CHECKBOX_HEADER_ID } from './utils';
5
- export function Row({ row, selectedFlatRows, withSelect, handleRowClick }) {
16
+ export function Row({ row, selectedFlatRows, withSelect, uniqueKey, handleRowClick }) {
6
17
  const isRowSelected = useMemo(() => selectedFlatRows.find((r) => r.id === row.id), [selectedFlatRows]);
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) => {
18
+ const _a = row.getRowProps(), { key: keyRow } = _a, rowProps = __rest(_a, ["key"]);
19
+ return (_jsx("tr", Object.assign({}, rowProps, { 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
20
  var _a;
9
21
  const isSelection = column.id === CHECKBOX_HEADER_ID;
10
- return (_jsx("td", Object.assign({}, getCellProps(), { style: {
22
+ const _b = getCellProps(), { key: keycell } = _b, cellProps = __rest(_b, ["key"]);
23
+ return (_jsx("td", Object.assign({}, cellProps, { style: {
11
24
  left: !isSelection && withSelect && (column === null || column === void 0 ? void 0 : column.fixed) === 'left' ? CHECKBOX_DEFAULT_WIDTH : 0
12
25
  }, className: classNames({
13
26
  fixed_column_left: (column === null || column === void 0 ? void 0 : column.fixed) === 'left',
14
27
  fixed_column_right: (column === null || column === void 0 ? void 0 : column.fixed) === 'right',
15
28
  fixed_checkbox: isSelection && ((_a = arr[i + 1].column) === null || _a === void 0 ? void 0 : _a.fixed) === 'left'
16
- }), children: render('Cell') }), i));
29
+ }), children: render('Cell') }), `table_cell_${uniqueKey}_${i}`));
17
30
  }) })));
18
31
  }
@@ -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.9",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",