hrm_ui_lib 2.3.6 → 2.4.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.
@@ -0,0 +1,2 @@
1
+ import { IButtonGroup } from './types';
2
+ export declare const ButtonGroup: ({ buttons, activeIndex, className, type, size, disabled, onTabChange }: IButtonGroup) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import classNames from 'classnames';
4
+ import { ButtonGroupItem } from './ButtonGroupItem';
5
+ export const ButtonGroup = ({ buttons, activeIndex = 0, className, type, size, disabled, onTabChange }) => {
6
+ const [activeItem, setActiveItem] = useState(activeIndex);
7
+ const handleItemClick = (index) => {
8
+ if (disabled || activeItem === index)
9
+ return;
10
+ setActiveItem(index);
11
+ onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange(index);
12
+ };
13
+ return (_jsx("div", { className: classNames('button-group', className), children: buttons.map((button, index) => {
14
+ return (_jsx(ButtonGroupItem, Object.assign({}, button, { type: type, size: size, isActive: activeItem === index, disabled: disabled, onClick: () => handleItemClick(index) }), index));
15
+ }) }));
16
+ };
@@ -0,0 +1,2 @@
1
+ import { IButtonGroupItem } from './types';
2
+ export declare const ButtonGroupItem: ({ buttonText, size, type, isActive, disabled, onClick, className, icons }: IButtonGroupItem) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Text } from '../Text';
3
+ import classNames from 'classnames';
4
+ import { ICON_SIZE_MAPPING, TEXT_SIZE_MAPPING } from './consts';
5
+ export const ButtonGroupItem = ({ buttonText, size = 'medium', type = 'primary', isActive, disabled, onClick, className, icons }) => {
6
+ var _a, _b;
7
+ const onClickHandler = (event) => {
8
+ event.preventDefault();
9
+ event.stopPropagation();
10
+ onClick === null || onClick === void 0 ? void 0 : onClick();
11
+ };
12
+ return (_jsxs("div", { className: classNames('button-group-item', `button-group-item__${type}`, `button-group-item__${size}`, { active: isActive, disabled }, className), onClick: onClickHandler, children: [((_a = icons === null || icons === void 0 ? void 0 : icons.left) === null || _a === void 0 ? void 0 : _a.Component) ? (_jsx(icons.left.Component, { size: ICON_SIZE_MAPPING[size], type: disabled ? 'disabled' : 'primary' })) : null, _jsx(Text, { size: TEXT_SIZE_MAPPING[size], children: buttonText }), ((_b = icons === null || icons === void 0 ? void 0 : icons.right) === null || _b === void 0 ? void 0 : _b.Component) ? (_jsx(icons.right.Component, { size: ICON_SIZE_MAPPING[size], type: disabled ? 'disabled' : 'primary' })) : null] }));
13
+ };
@@ -0,0 +1,8 @@
1
+ import { TTextSize } from '../Text/types';
2
+ import { TSVGIconSize } from '../SVGIcons/types';
3
+ export declare const TEXT_SIZE_MAPPING: {
4
+ [key: string]: TTextSize;
5
+ };
6
+ export declare const ICON_SIZE_MAPPING: {
7
+ [key: string]: TSVGIconSize;
8
+ };
@@ -0,0 +1,10 @@
1
+ export const TEXT_SIZE_MAPPING = {
2
+ large: 'standard',
3
+ medium: 'standard',
4
+ small: 'small'
5
+ };
6
+ export const ICON_SIZE_MAPPING = {
7
+ large: 'small',
8
+ medium: 'small',
9
+ small: 'xsmall'
10
+ };
@@ -0,0 +1 @@
1
+ export * from './ButtonGroup';
@@ -0,0 +1 @@
1
+ export * from './ButtonGroup';
@@ -0,0 +1,23 @@
1
+ import { ISVGIconProps } from '../SVGIcons/types';
2
+ interface IButtonGroupBase {
3
+ type?: 'primary';
4
+ size?: 'small' | 'medium' | 'large';
5
+ disabled?: boolean;
6
+ className?: string;
7
+ }
8
+ export interface IButtonGroupItem extends IButtonGroupBase {
9
+ buttonText: string;
10
+ isActive?: boolean;
11
+ id?: string | number;
12
+ onClick?: () => void;
13
+ icons?: {
14
+ left?: ISVGIconProps;
15
+ right?: ISVGIconProps;
16
+ };
17
+ }
18
+ export interface IButtonGroup extends IButtonGroupBase {
19
+ buttons: IButtonGroupItem[];
20
+ activeIndex: number;
21
+ onTabChange?: (index: number) => void;
22
+ }
23
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -14,7 +14,7 @@ export function useTableControl({ withSelect, columns, data, tableSettings, tota
14
14
  const tableName = `${TABLE_NAME_PREFIX}-${tableSettings === null || tableSettings === void 0 ? void 0 : tableSettings.tableName}`;
15
15
  const savedSettings = shouldPersistToStorage && tableName
16
16
  ? loadTableSettings(tableName)
17
- : { columnVisibility: {}, columnSizing: {}, columnOrder: [] };
17
+ : { columnVisibility: {}, columnSizing: {}, columnOrder: [], columnPinning: {} };
18
18
  const [activeId, setActiveId] = useState(null);
19
19
  const [sorting, setSorting] = useState([]);
20
20
  const [rowSelection, setRowSelection] = useState({});
@@ -82,6 +82,18 @@ export function useTableControl({ withSelect, columns, data, tableSettings, tota
82
82
  acc[key] = false;
83
83
  return acc;
84
84
  }, {});
85
+ const columnPinning = useMemo(() => {
86
+ const left = [];
87
+ memoizedColumns.forEach((col) => {
88
+ if (col.enablePinning && col.id) {
89
+ left.push(col.id);
90
+ }
91
+ });
92
+ return {
93
+ left,
94
+ right: ['actions']
95
+ };
96
+ }, [memoizedColumns]);
85
97
  const table = useReactTable({
86
98
  data,
87
99
  columns: reorderedColumns,
@@ -93,15 +105,7 @@ export function useTableControl({ withSelect, columns, data, tableSettings, tota
93
105
  columnSizing,
94
106
  rowSelection,
95
107
  columnVisibility: Object.assign(Object.assign({}, hiddenColumns), columnVisibility),
96
- columnPinning: {
97
- left: ['select'],
98
- right: ['actions']
99
- }
100
- },
101
- defaultColumn: {
102
- minSize: 200,
103
- size: 150,
104
- maxSize: 400
108
+ columnPinning
105
109
  },
106
110
  onPaginationChange: handlePaginationChange,
107
111
  onColumnSizingChange: handleColumnSizingChange,
@@ -1,6 +1,6 @@
1
1
  import { ElementType, MouseEvent, ReactNode } from 'react';
2
2
  type TTextTypes = 'primary' | 'secondary' | 'tertiary' | 'disabled' | 'inverse' | 'selected' | 'brand' | 'danger' | 'warning' | 'success' | 'information' | 'discovery';
3
- type TTextSize = 'xxsmall' | 'xsmall' | 'small' | 'standard' | 'medium' | 'large' | 'xlarge';
3
+ export type TTextSize = 'xxsmall' | 'xsmall' | 'small' | 'standard' | 'medium' | 'large' | 'xlarge';
4
4
  type TTextWeight = 'regular' | 'semibold' | 'bold' | 'bolder';
5
5
  type TTextLineHeight = 'xsmall' | 'small' | 'medium' | 'large';
6
6
  export interface TextPropTypes {
package/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from './components/Badge';
5
5
  export * from './components/BadgeV2';
6
6
  export * from './components/Breadcrumb';
7
7
  export * from './components/Button';
8
+ export * from './components/ButtonGroup';
8
9
  export * from './components/Checkbox';
9
10
  export * from './components/Chips';
10
11
  export * from './components/Card';
package/index.js CHANGED
@@ -5,6 +5,7 @@ export * from './components/Badge';
5
5
  export * from './components/BadgeV2';
6
6
  export * from './components/Breadcrumb';
7
7
  export * from './components/Button';
8
+ export * from './components/ButtonGroup';
8
9
  export * from './components/Checkbox';
9
10
  export * from './components/Chips';
10
11
  export * from './components/Card';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrm_ui_lib",
3
- "version": "2.3.6",
3
+ "version": "2.4.0",
4
4
  "description": "UI library for Dino",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
File without changes