@inceptionbg/iui 2.0.11 → 2.0.12

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 (105) hide show
  1. package/dist/icons/index.d.ts +5 -1
  2. package/dist/icons/index.js +1 -1
  3. package/dist/index.d.ts +151 -80
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/iui.css +1 -1
  7. package/package.json +1 -1
  8. package/src/assets/icons/duotone/faCircleUser.ts +6 -6
  9. package/src/assets/icons/index.ts +2 -0
  10. package/src/assets/icons/light/faArrowDownShortWide.ts +1 -1
  11. package/src/assets/icons/light/faArrowDownWideShort.ts +1 -1
  12. package/src/assets/icons/light/faArrowUpArrowDown.ts +5 -5
  13. package/src/assets/icons/light/faArrowUpRightFromSquare.ts +1 -1
  14. package/src/assets/icons/light/faArrowsToLine.ts +1 -1
  15. package/src/assets/icons/light/faArrowsUpDown.ts +1 -1
  16. package/src/assets/icons/light/faBookmark.ts +15 -0
  17. package/src/assets/icons/light/faBookmarkSlash.ts +15 -0
  18. package/src/assets/icons/light/faCalendarPlus.ts +5 -5
  19. package/src/assets/icons/light/faCheck.ts +1 -1
  20. package/src/assets/icons/light/faChevronDown.ts +5 -5
  21. package/src/assets/icons/light/faChevronRight.ts +5 -5
  22. package/src/assets/icons/light/faCircleInfo.ts +5 -5
  23. package/src/assets/icons/light/faCircleXmark.ts +5 -5
  24. package/src/assets/icons/light/faClipboardCheck.ts +5 -5
  25. package/src/assets/icons/light/faClockRotateLeft.ts +1 -1
  26. package/src/assets/icons/light/faEllipsisVertical.ts +1 -1
  27. package/src/assets/icons/light/faEye.ts +5 -5
  28. package/src/assets/icons/light/faEyeSlash.ts +5 -5
  29. package/src/assets/icons/light/faFilter.ts +5 -5
  30. package/src/assets/icons/light/faGear.ts +1 -1
  31. package/src/assets/icons/light/faHouse.ts +5 -5
  32. package/src/assets/icons/light/faIdBadge.ts +5 -5
  33. package/src/assets/icons/light/faLineColumns.ts +5 -5
  34. package/src/assets/icons/light/faLink.ts +1 -1
  35. package/src/assets/icons/light/faMagnifyingGlass.ts +5 -5
  36. package/src/assets/icons/light/faPen.ts +5 -5
  37. package/src/assets/icons/light/faPrint.ts +5 -5
  38. package/src/assets/icons/light/faQuestion.ts +5 -5
  39. package/src/assets/icons/light/faRotateRight.ts +5 -5
  40. package/src/assets/icons/light/faTrashCan.ts +5 -5
  41. package/src/assets/icons/light/faTriangleExclamation.ts +5 -5
  42. package/src/assets/icons/light/faXmark.ts +1 -1
  43. package/src/assets/icons/regular/faArrowLeft.ts +6 -6
  44. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +1 -1
  45. package/src/assets/icons/regular/faCircleCheck.ts +1 -1
  46. package/src/assets/icons/regular/faCircleExclamation.ts +1 -1
  47. package/src/assets/icons/regular/faCircleInfo.ts +1 -1
  48. package/src/assets/icons/regular/faFileArrowDown.ts +1 -1
  49. package/src/assets/icons/regular/faFilterCircleXmark.ts +1 -1
  50. package/src/assets/icons/regular/faTriangleExclamation.ts +1 -1
  51. package/src/assets/icons/solid/faAngleLeft.ts +1 -1
  52. package/src/assets/icons/solid/faAngleRight.ts +1 -1
  53. package/src/assets/icons/solid/faArrowDownWideShort.ts +1 -1
  54. package/src/assets/icons/solid/faCaretDown.ts +1 -1
  55. package/src/assets/icons/solid/faCheck.ts +5 -5
  56. package/src/assets/icons/solid/faEllipsisVertical.ts +1 -1
  57. package/src/assets/icons/solid/faFilter.ts +1 -1
  58. package/src/assets/icons/solid/faFloppyDisk.ts +1 -1
  59. package/src/assets/icons/solid/faGripDotsVertical.ts +1 -1
  60. package/src/assets/icons/solid/faListUl.ts +1 -1
  61. package/src/assets/icons/solid/faMinus.ts +6 -6
  62. package/src/assets/icons/solid/faPlus.ts +6 -6
  63. package/src/assets/icons/solid/faPrint.ts +1 -1
  64. package/src/assets/icons/solid/faRotateRight.ts +1 -1
  65. package/src/assets/icons/solid/faXmark.ts +1 -1
  66. package/src/components/Button/Button.tsx +1 -1
  67. package/src/components/Button/IconButton.tsx +1 -1
  68. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +1 -1
  69. package/src/components/Dialog/components/DialogFooter.tsx +1 -1
  70. package/src/components/Header/Components/ModuleSelect.tsx +14 -6
  71. package/src/components/Inputs/InputWrapper.tsx +1 -1
  72. package/src/components/Inputs/TextInput.tsx +1 -1
  73. package/src/components/List/List.tsx +18 -0
  74. package/src/components/List/ListItem.tsx +24 -0
  75. package/src/components/Loader/ProgressBar.tsx +41 -0
  76. package/src/components/Menu/Menu.tsx +0 -3
  77. package/src/components/Menu/MenuItem.tsx +21 -23
  78. package/src/components/Menu/NewMenu.tsx +0 -3
  79. package/src/components/Pullover/Pullover.tsx +5 -4
  80. package/src/components/Sidebar/types/ISidebar.ts +1 -1
  81. package/src/components/Table/Table.tsx +18 -11
  82. package/src/components/Table/components/filters/TableFilters.tsx +3 -6
  83. package/src/components/Table/components/footer/TableFooter.tsx +6 -10
  84. package/src/components/Table/components/header/TableHeader.tsx +22 -24
  85. package/src/components/Table/components/header/TableHeaderRow.tsx +16 -7
  86. package/{idea/Table/Components/Print → src/components/Table/components/print}/TablePrint.tsx +89 -96
  87. package/src/components/Table/components/sort/TableSort.tsx +2 -0
  88. package/src/components/Table/components/templates/TableTemplates.tsx +81 -0
  89. package/src/components/Table/hooks/useTablePrint.ts +75 -0
  90. package/src/index.ts +8 -0
  91. package/src/styles/App.scss +2 -0
  92. package/src/styles/common/_animations.scss +8 -14
  93. package/src/styles/common/helpers/_base.scss +0 -4
  94. package/src/styles/components/_header.scss +21 -9
  95. package/src/styles/components/_list.scss +40 -0
  96. package/src/styles/components/_loader.scss +3 -1
  97. package/src/styles/components/_menu.scss +19 -18
  98. package/src/styles/components/_print.scss +36 -46
  99. package/src/styles/components/_progressBar.scss +83 -0
  100. package/src/styles/components/_table.scss +16 -22
  101. package/src/types/ITable.ts +55 -32
  102. package/src/utils/i18n/i18nIUICyrilic.ts +2 -1
  103. package/src/utils/i18n/i18nIUILatin.ts +16 -12
  104. package/src/utils/i18n/i18nIUIMe.ts +2 -1
  105. package/src/utils/icons.ts +1 -1
@@ -20,29 +20,27 @@ export const MenuItem: FC<IMenuItem> = ({
20
20
  className,
21
21
  }) =>
22
22
  hidden ? null : (
23
- <div
24
- className={clsx(className, {
25
- 'iui-menu-item': !className,
26
- clickable: !!onClick || !!to,
27
- disabled,
28
- active,
29
- 'with-devider': withDevider,
30
- })}
23
+ <ConditionalWrapper
24
+ condition={!disabled && !!to}
25
+ wrapper={children => <Link to={to!}>{children}</Link>}
31
26
  >
32
- <ConditionalWrapper
33
- condition={!disabled && !!to}
34
- wrapper={children => <Link to={to!}>{children}</Link>}
27
+ <div
28
+ className={clsx('iui-menu-item', className, {
29
+ clickable: !!onClick || !!to,
30
+ disabled,
31
+ active,
32
+ 'with-devider': withDevider,
33
+ })}
34
+ onClick={disabled ? undefined : onClick}
35
35
  >
36
- <div className="menu-item-content" onClick={disabled ? undefined : onClick}>
37
- {icon && (
38
- <div className="menu-item-icon">
39
- <FontAwesomeIcon icon={icon} rotation={iconRotation} />
40
- </div>
41
- )}
42
- <NotificationBadge number={badge} size="s" className="menu-item-badge">
43
- <p className="menu-item-label">{label}</p>
44
- </NotificationBadge>
45
- </div>
46
- </ConditionalWrapper>
47
- </div>
36
+ {icon && (
37
+ <div className="menu-item-icon">
38
+ <FontAwesomeIcon icon={icon} rotation={iconRotation} />
39
+ </div>
40
+ )}
41
+ <NotificationBadge number={badge} size="s" className="menu-item-badge">
42
+ <p className="menu-item-label">{label}</p>
43
+ </NotificationBadge>
44
+ </div>
45
+ </ConditionalWrapper>
48
46
  );
@@ -14,7 +14,6 @@ interface Props {
14
14
  placement?: IMenuPlacement;
15
15
  size?: 's' | 'm' | 'l';
16
16
  className?: string;
17
- classNameItem?: string;
18
17
  }
19
18
 
20
19
  export const MenuV2: FC<Props> = ({
@@ -24,7 +23,6 @@ export const MenuV2: FC<Props> = ({
24
23
  placement = 'bottom-left',
25
24
  size,
26
25
  className,
27
- classNameItem,
28
26
  }) => {
29
27
  const buttonRef = useRef<HTMLButtonElement>(null);
30
28
  const popoverRef = useRef<HTMLDivElement>(null);
@@ -52,7 +50,6 @@ export const MenuV2: FC<Props> = ({
52
50
  <MenuItem
53
51
  {...item}
54
52
  key={item.label}
55
- className={classNameItem}
56
53
  onClick={e => {
57
54
  item.onClick?.(e);
58
55
  !item.keepOpen && popoverRef.current?.hidePopover();
@@ -27,9 +27,9 @@ interface Props {
27
27
  size?: 'vw25' | 'vw50' | 'vw75' | 'vw100' | 'w500' | 'w600';
28
28
  className?: string;
29
29
  contentClassName?: string;
30
+ portalTarget?: HTMLElement;
30
31
  children: ReactNode;
31
32
  }
32
-
33
33
  export const Pullover: FC<Props> = ({
34
34
  id,
35
35
  control,
@@ -41,6 +41,7 @@ export const Pullover: FC<Props> = ({
41
41
  size = 'vw50',
42
42
  className,
43
43
  contentClassName,
44
+ portalTarget,
44
45
  children,
45
46
  }) => {
46
47
  const { t } = useTranslation();
@@ -98,7 +99,7 @@ export const Pullover: FC<Props> = ({
98
99
  <div className={clsx('container', size)} onClick={e => e.stopPropagation()}>
99
100
  <div className={clsx('content', className)}>
100
101
  {header && (
101
- <div className="pullover-header">
102
+ <div className="pullover-header no-print">
102
103
  <h3>{header.title}</h3>
103
104
  {header.onSearch && (
104
105
  <SearchInput
@@ -133,7 +134,7 @@ export const Pullover: FC<Props> = ({
133
134
 
134
135
  {/* FOOTER */}
135
136
  {footer && (
136
- <div className={clsx('pullover-footer', className)}>
137
+ <div className={clsx('pullover-footer no-print', className)}>
137
138
  {footer.additionalButton && (
138
139
  <Button
139
140
  {...footer.additionalButton}
@@ -162,7 +163,7 @@ export const Pullover: FC<Props> = ({
162
163
  </div>
163
164
  </div>
164
165
  </div>,
165
- rootDir
166
+ portalTarget ?? rootDir
166
167
  )
167
168
  : null;
168
169
  };
@@ -1,4 +1,4 @@
1
- import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
1
+ import type { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
2
 
3
3
  export interface ISidebarItem {
4
4
  label: string;
@@ -15,27 +15,28 @@ import { TableSelect } from './components/select/TableSelect';
15
15
  import { TableSort } from './components/sort/TableSort';
16
16
  import { TableFilters } from './components/filters/TableFilters';
17
17
  import { TableEditRow } from './components/edit/TableEditRow';
18
+ import { TablePrint } from './components/print/TablePrint';
19
+ import { TableTemplates } from './components/templates/TableTemplates';
18
20
 
19
21
  export const TableContent: FC = () => {
20
22
  const {
21
23
  columns,
24
+ customHeader,
25
+ headerWrap,
22
26
  // setColumns,
23
27
  // withColumnsSearch,
24
28
  data,
25
29
  sumRows,
26
30
  isLoading,
27
-
28
- // filterData,
29
31
  selectedRowUuid,
30
- // printData,
31
32
  // customPrintData,
32
33
  // templates,
33
34
  // additionsalOptions,
34
35
  footer,
35
- className,
36
36
  rowHeight = 'm',
37
37
  maxHeight,
38
38
  editable,
39
+ ...props
39
40
  } = useTableContext();
40
41
 
41
42
  const [extendedRow, setExtendedRow] = useState('');
@@ -48,7 +49,7 @@ export const TableContent: FC = () => {
48
49
  <Loader isLoading={!!isLoading}>
49
50
  <div
50
51
  // onKeyDown={handleKeyDown}
51
- className={clsx('iui-table', className, {
52
+ className={clsx('iui-table', props.className, {
52
53
  'pb-3': data.length === 0,
53
54
  })}
54
55
  // tabIndex={-1}
@@ -74,9 +75,11 @@ export const TableContent: FC = () => {
74
75
  additionsalOptions={additionsalOptions}
75
76
  />
76
77
  )} */}
77
- <TableSelect />
78
- <TableFilters />
79
- <TableSort />
78
+ {props.selectActions.length > 0 && <TableSelect />}
79
+ {props.filterData && <TableFilters />}
80
+ {props.sortData && <TableSort />}
81
+ {props.templates && <TableTemplates />}
82
+ {props.printData && <TablePrint />}
80
83
  </div>
81
84
  <div className="table-container" style={{ maxHeight }}>
82
85
  <ConditionalWrapper
@@ -99,7 +102,12 @@ export const TableContent: FC = () => {
99
102
  )}
100
103
  >
101
104
  <table className="full-width">
102
- <HeaderTable />
105
+ <HeaderTable
106
+ columns={columns}
107
+ customHeader={customHeader}
108
+ headerWrap={headerWrap}
109
+ maxHeight={maxHeight}
110
+ />
103
111
  <tbody>
104
112
  {data.length ? (
105
113
  <>
@@ -167,7 +175,6 @@ export const TableContent: FC = () => {
167
175
  link: cell?.link,
168
176
  'clickable-column': cell?.onClick,
169
177
  'word-break': column.break,
170
- 'no-border': isExtended,
171
178
  }
172
179
  )}
173
180
  colSpan={cell?.span}
@@ -247,7 +254,7 @@ export const TableContent: FC = () => {
247
254
  totalRows={footer.totalRows}
248
255
  noTotalRows={noTotalRows}
249
256
  customLimit={footer.customPagination?.customLimit}
250
- footerAction={footer.footerAction}
257
+ refetch={footer.refetch}
251
258
  dataLength={data.length}
252
259
  />
253
260
  )}
@@ -19,15 +19,13 @@ import { faFilterCircleXmark } from '../../../../assets/icons/regular/faFilterCi
19
19
  import { usePopupControl } from '../../../../hooks/usePopupControl';
20
20
 
21
21
  export const TableFilters: FC = () => {
22
- const { control, onClose, onOpen } = usePopupControl();
23
-
24
- const [filterSearch, setFilterSearch] = useState('');
25
-
26
22
  const { t } = useTranslation();
27
23
  const { columns, filterData } = useTableContext();
28
-
24
+ const { control, onClose, onOpen } = usePopupControl();
29
25
  const columnIds = getVisibleColumnsIds(columns);
30
26
 
27
+ const [filterSearch, setFilterSearch] = useState('');
28
+
31
29
  const {
32
30
  filters,
33
31
  additionalFilters,
@@ -102,7 +100,6 @@ export const TableFilters: FC = () => {
102
100
  ? JSON.stringify(searchData) === JSON.stringify(defaultSearch)
103
101
  : Object.keys(searchData).length === 0,
104
102
  },
105
- // onClose,
106
103
  }}
107
104
  contentClassName="iui-filters-list"
108
105
  onCloseCallback={() => setFilterSearch('')}
@@ -1,4 +1,3 @@
1
- import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
1
  import { FC, MouseEventHandler, useEffect, useState } from 'react';
3
2
  import { faAngleLeft } from '../../../../assets/icons/solid/faAngleLeft';
4
3
  import { faAngleRight } from '../../../../assets/icons/solid/faAngleRight';
@@ -15,10 +14,7 @@ interface Props {
15
14
  pagination: IPaginationControl;
16
15
  noTotalRows?: boolean;
17
16
  dataLength: number;
18
- footerAction?: {
19
- icon?: IconDefinition;
20
- onClick: MouseEventHandler<HTMLButtonElement>;
21
- };
17
+ refetch?: MouseEventHandler<HTMLButtonElement>;
22
18
  totalRows?: number;
23
19
  customLimit?: number[];
24
20
  }
@@ -28,7 +24,7 @@ export const TableFooter: FC<Props> = ({
28
24
  totalRows = 0,
29
25
  noTotalRows,
30
26
  dataLength,
31
- footerAction,
27
+ refetch,
32
28
  customLimit,
33
29
  }) => {
34
30
  const [tempOffset, setTempOffset] = useState(offset + 1);
@@ -48,11 +44,11 @@ export const TableFooter: FC<Props> = ({
48
44
  const maxOffset = Math.ceil(totalRows / limit);
49
45
 
50
46
  return (
51
- <div className={`table-footer ${footerAction ? 'justify-between' : 'justify-right'}`}>
52
- {!!footerAction && (
47
+ <div className={`table-footer ${refetch ? 'justify-between' : 'justify-right'}`}>
48
+ {!!refetch && (
53
49
  <IconButton
54
- icon={footerAction.icon || faRotateRight}
55
- onClick={footerAction.onClick}
50
+ icon={faRotateRight}
51
+ onClick={refetch}
56
52
  tooltip={t('RefreshData')}
57
53
  variant="outlined"
58
54
  size="s"
@@ -1,11 +1,24 @@
1
- import { FC, Fragment } from 'react';
1
+ import { FC } from 'react';
2
2
  import clsx from 'clsx';
3
3
  import { TableHeaderRow } from './TableHeaderRow';
4
- import { useTableContext } from '../../contexts/TableContext';
4
+ import { ITableColumn } from '../../../../types/ITable';
5
5
 
6
- export const HeaderTable: FC = () => {
7
- const { columns, customHeader, headerWrap, maxHeight } = useTableContext();
8
- const isSticky = !!maxHeight;
6
+ type Props = {
7
+ columns: ITableColumn[];
8
+ customHeader?: ITableColumn[][];
9
+ headerWrap?: boolean;
10
+ maxHeight?: number | string;
11
+ print?: boolean;
12
+ };
13
+
14
+ export const HeaderTable: FC<Props> = ({
15
+ columns,
16
+ customHeader,
17
+ headerWrap,
18
+ maxHeight,
19
+ print,
20
+ }) => {
21
+ const isSticky = !print && !!maxHeight;
9
22
 
10
23
  return (
11
24
  <thead
@@ -14,29 +27,14 @@ export const HeaderTable: FC = () => {
14
27
  'sticky-header': isSticky,
15
28
  })}
16
29
  >
17
- <BorderRow span={columns.length} />
18
30
  {customHeader ? (
19
- customHeader?.map((row, i) => (
20
- // No array manipulation will be performed, so using key 'i' is acceptable.
21
- <Fragment key={i}>
22
- <TableHeaderRow row={row} />
23
- {(isSticky || i + 1 < customHeader.length) && (
24
- <BorderRow span={columns.length} />
25
- )}
26
- </Fragment>
31
+ customHeader.map((row, i) => (
32
+ // No array manipulation will be performed, so using key 'i' is fine.
33
+ <TableHeaderRow key={i} row={row} print={print} />
27
34
  ))
28
35
  ) : (
29
- <>
30
- <TableHeaderRow row={columns} />
31
- <BorderRow span={columns.length} />
32
- </>
36
+ <TableHeaderRow row={columns} print={print} />
33
37
  )}
34
38
  </thead>
35
39
  );
36
40
  };
37
-
38
- const BorderRow: FC<{ span?: number }> = ({ span }) => (
39
- <tr>
40
- <th className="border-row" colSpan={span} />
41
- </tr>
42
- );
@@ -4,9 +4,10 @@ import clsx from 'clsx';
4
4
 
5
5
  interface Props {
6
6
  row: ITableColumn[];
7
+ print?: boolean;
7
8
  }
8
9
 
9
- export const TableHeaderRow: FC<Props> = ({ row }) => {
10
+ export const TableHeaderRow: FC<Props> = ({ row, print }) => {
10
11
  // const { sortData } = useTableContext();
11
12
  // const { sort, setSort, sortOptions } = sortData ?? {};
12
13
  // const activeSortOption = sortOptions?.find(e => sort?.startsWith(e.value));
@@ -18,18 +19,26 @@ export const TableHeaderRow: FC<Props> = ({ row }) => {
18
19
  key={col.id}
19
20
  colSpan={col.colSpan}
20
21
  rowSpan={col.rowSpan}
21
- className={clsx(col.color, col.className)}
22
+ className={
23
+ print
24
+ ? undefined
25
+ : clsx(col.color, col.className, {
26
+ 'not-first-cell': col.notFirstCell,
27
+ })
28
+ }
22
29
  // onClick={() => {
23
30
  // const sortValue = sortOptions?.find(e => col.label === e.label)?.value;
24
31
  // sortValue &&
25
32
  // setSort?.(sort === sortValue + desc ? sortValue + asc : sortValue + desc);
26
33
  // }}
27
34
  style={
28
- col.minWidth
29
- ? { minWidth: col.minWidth }
30
- : col.width
31
- ? { width: col.width }
32
- : undefined
35
+ print
36
+ ? undefined
37
+ : col.minWidth
38
+ ? { minWidth: col.minWidth }
39
+ : col.width
40
+ ? { width: col.width }
41
+ : undefined
33
42
  }
34
43
  hidden={col.hidden}
35
44
  >
@@ -1,77 +1,84 @@
1
- import { FC, useEffect, useState } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { faFileArrowDown } from '../../../../assets/icons/regular/faFileArrowDown';
4
- import { faPrint } from '../../../../assets/icons/solid/faPrint';
5
- import { faXmark } from '../../../../assets/icons/solid/faXmark';
6
- import { IPrintData, ITableColumn, ITableDataItem } from '../../../../types/ITable';
7
- import { formatDate, getCurrentDateFormatted } from '../../../../utils/dateUtils';
8
- import { Button } from '../../../Button/Button';
9
- import { FullScreenLoader } from '../../../Loader/Loader';
1
+ import { useEffect, useMemo, type FC } from 'react';
2
+ import { IconButton } from '../../../Button/IconButton';
3
+ import { faPrint } from '../../../../assets/icons';
10
4
  import { useTranslation } from 'react-i18next';
11
- import { rootDir } from '../../../../utils/rootDir';
12
- import clsx from 'clsx';
13
- import { HeaderTable } from '../Header/TableHeader';
5
+ import { Pullover } from '../../../Pullover/Pullover';
6
+ import { useTableContext } from '../../contexts/TableContext';
7
+ import { IPrintData } from '../../../../types/ITable';
14
8
  import { useHideZendesk } from '../../../../hooks/useZendesk';
9
+ import { formatDate, getCurrentDateFormatted } from '../../../../utils/dateUtils';
10
+ import { HeaderTable } from '../header/TableHeader';
11
+ import clsx from 'clsx';
12
+ import { faFileArrowDown } from '../../../../assets/icons/regular/faFileArrowDown';
13
+ import { ProgressBar } from '../../../Loader/ProgressBar';
15
14
 
16
- interface Props extends IPrintData {
17
- isOpen: boolean;
18
- onClose: () => void;
19
- columns: ITableColumn[];
20
- excludeColumnIds?: string[];
21
- }
22
- export const TablePrint: FC<Props> = ({
23
- isOpen,
24
- onClose,
25
- columns,
26
- excludeColumnIds = [],
27
- customHeader,
28
- organization,
29
- filters,
30
- label,
31
- optionalNode,
32
- getPrintData,
33
- formatPrintData,
34
- saveXlsx,
35
- totals,
36
- }) => {
37
- const [data, setData] = useState<ITableDataItem[]>([]);
38
- const [offset, setOffset] = useState(0);
39
- const [isLoading, setIsLoading] = useState(false);
40
-
15
+ export const TablePrint: FC = () => {
41
16
  const { t } = useTranslation();
42
17
  useHideZendesk();
18
+ const { columns, printData } = useTableContext();
19
+
20
+ const {
21
+ label,
22
+ tableData: data,
23
+ isLoading,
24
+ progress,
25
+ paginationControl,
26
+ printPopupControl,
27
+ customHeader,
28
+ excludeColumnIds,
29
+ filters,
30
+ optionalNode,
31
+ organization,
32
+ saveXlsx,
33
+ totals,
34
+ } = useMemo(() => (printData ?? {}) as IPrintData, [printData]);
35
+ const { control, onOpen } = printPopupControl;
43
36
 
44
- const cols = columns.filter(
45
- e => !['actions', 'select', ...excludeColumnIds].includes(e.id)
37
+ const cols = useMemo(
38
+ () => columns.filter(e => !['actions', 'select', excludeColumnIds].includes(e.id)),
39
+ [columns, excludeColumnIds]
46
40
  );
47
41
 
48
42
  useEffect(() => {
49
- rootDir?.classList.add('hidden');
50
- return () => {
51
- rootDir?.classList.remove('hidden');
52
- };
53
- }, []);
43
+ if (control.isOpen) {
44
+ paginationControl?.setLimit(1000);
45
+ paginationControl?.setOffset(0);
46
+ }
47
+ }, [paginationControl, control.isOpen]);
54
48
 
55
- useEffect(() => {
56
- setIsLoading(true);
57
- getPrintData({ limit: 1000, offset })
58
- .then(e => {
59
- setData(prevState => {
60
- const data = !!e.data.length ? formatPrintData(e.data) : [];
61
- const newState = [...prevState, ...data];
62
- e.totalRows && e.totalRows > newState.length
63
- ? setOffset(offset + 1)
64
- : setIsLoading(false);
65
- return e.totalRows && e.totalRows > prevState.length ? newState : prevState;
66
- });
67
- })
68
- .catch(() => setIsLoading(false));
69
- }, [offset, formatPrintData, getPrintData]);
49
+ return (
50
+ printData && (
51
+ <>
52
+ <IconButton
53
+ tooltip={t('PrintExport')}
54
+ icon={faPrint}
55
+ onClick={onOpen}
56
+ size="s"
57
+ variant="outlined"
58
+ />
70
59
 
71
- return isOpen
72
- ? createPortal(
73
- <div className="iui-print-dialog">
74
- <div className="content">
60
+ <Pullover
61
+ control={control}
62
+ header={{ title: t('PrintExport') }}
63
+ footer={{
64
+ confirmButton: {
65
+ label: t('Print'),
66
+ onClick: window.print,
67
+ // type: 'submit',
68
+ },
69
+ additionalButton: saveXlsx
70
+ ? {
71
+ label: t('SaveXlsx'),
72
+ icon: faFileArrowDown,
73
+ onClick: saveXlsx,
74
+ }
75
+ : undefined,
76
+ }}
77
+ contentClassName="iui-print"
78
+ size="vw100"
79
+ portalTarget={document.body}
80
+ >
81
+ <div className="print-content">
75
82
  <div className="flex justify-between">
76
83
  {organization ? (
77
84
  <div>
@@ -121,11 +128,18 @@ export const TablePrint: FC<Props> = ({
121
128
  </div>
122
129
  )}
123
130
  {optionalNode?.aboveTable}
124
- {data && (
125
- <table width="100%" className="print-table">
126
- <HeaderTable columns={cols} customHeader={customHeader} headerWrap />
127
- <tbody>
128
- <>
131
+ {isLoading ? (
132
+ <ProgressBar progress={progress} />
133
+ ) : (
134
+ data && (
135
+ <table width="100%" className="print-table">
136
+ <HeaderTable
137
+ columns={cols}
138
+ customHeader={customHeader}
139
+ headerWrap
140
+ print
141
+ />
142
+ <tbody>
129
143
  {data.map(row => {
130
144
  let totalColsSpan = 0;
131
145
  return (
@@ -173,35 +187,14 @@ export const TablePrint: FC<Props> = ({
173
187
  ))}
174
188
  </tr>
175
189
  )}
176
- </>
177
- </tbody>
178
- </table>
190
+ </tbody>
191
+ </table>
192
+ )
179
193
  )}
180
194
  {optionalNode?.bellowTable}
181
195
  </div>
182
- <div className="iui-print-actions no-print">
183
- <Button
184
- label={t('Cancel')}
185
- icon={faXmark}
186
- onClick={e => {
187
- e.stopPropagation();
188
- onClose();
189
- }}
190
- className="mr-3"
191
- />
192
- {!!saveXlsx && (
193
- <Button
194
- label={t('SaveXlsx')}
195
- icon={faFileArrowDown}
196
- onClick={() => saveXlsx()}
197
- className="mr-3"
198
- />
199
- )}
200
- <Button label={t('Print')} icon={faPrint} onClick={() => window.print()} />
201
- </div>
202
- <FullScreenLoader isLoading={isLoading} />
203
- </div>,
204
- document.body
205
- )
206
- : null;
196
+ </Pullover>
197
+ </>
198
+ )
199
+ );
207
200
  };
@@ -39,6 +39,8 @@ export const TableSort: FC = () => {
39
39
  label: e.label,
40
40
  onClick: () => setSort?.(sort === valueDesc ? valueAsc : valueDesc),
41
41
  active: sort?.startsWith(e.value),
42
+ className: 'table-sort-item',
43
+ keepOpen: true,
42
44
  icon:
43
45
  sort === valueDesc
44
46
  ? faArrowDownWideShort