@inceptionbg/iui 2.0.7 → 2.0.10

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 (148) hide show
  1. package/dist/NoAccessPage-DBq5IzIf.js +2 -0
  2. package/dist/{NoAccessPage-BozT_Suz.js.map → NoAccessPage-DBq5IzIf.js.map} +1 -1
  3. package/dist/NotFoundPage-DM-I96ar.js +2 -0
  4. package/dist/{NotFoundPage-WWiekDef.js.map → NotFoundPage-DM-I96ar.js.map} +1 -1
  5. package/dist/icons/index.d.ts +2 -2
  6. package/dist/icons/index.js +1 -1
  7. package/dist/index.d.ts +286 -259
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/iui.css +1 -1
  11. package/idea/GridTable/GridTable.tsx +119 -0
  12. package/idea/GridTable/gridTable.scss +42 -0
  13. package/{src/components → idea}/Table/Components/Print/CustomTablePrint.tsx +2 -2
  14. package/{src/components → idea}/Table/Components/Print/TablePrint.tsx +2 -2
  15. package/{src/components → idea}/Table/Components/SetTableFilter.tsx +1 -1
  16. package/{src/components → idea}/Table/Components/TableOptions.tsx +4 -4
  17. package/idea/{Table2 → Table}/Table.tsx +151 -281
  18. package/idea/Table/hooks/useDefaultTemplate.ts +20 -0
  19. package/{src/components → idea}/Table/hooks/useTableKeyboard.ts +1 -2
  20. package/idea/Table/hooks/useTableSelect.ts +11 -0
  21. package/package.json +3 -2
  22. package/src/assets/icons/index.ts +1 -1
  23. package/src/assets/icons/light/faClipboardCheck.ts +15 -0
  24. package/src/assets/icons/light/faHouse.ts +15 -15
  25. package/src/assets/icons/light/faIdBadge.ts +15 -15
  26. package/src/assets/icons/light/faPen.ts +15 -0
  27. package/src/components/Button/IconButton.tsx +3 -1
  28. package/src/components/Dialog/Dialog.tsx +60 -124
  29. package/src/components/Dialog/components/DialogFooter.tsx +92 -0
  30. package/src/components/Dialog/hooks/useDialogKeyboard.ts +6 -5
  31. package/src/components/Header/Components/ModuleSelect.tsx +1 -1
  32. package/src/components/Header/Header.tsx +1 -1
  33. package/src/components/Inputs/DateInput/DateInput.tsx +108 -101
  34. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +7 -3
  35. package/src/components/Inputs/InputWrapper.tsx +6 -1
  36. package/src/components/Inputs/SearchInput.tsx +9 -4
  37. package/src/components/Inputs/Select2/Select.tsx +65 -30
  38. package/src/components/Inputs/Select2/select.scss +13 -14
  39. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +4 -2
  40. package/src/components/Inputs/Selects/utils/selectStyles.ts +9 -12
  41. package/src/components/Menu/Menu.tsx +10 -2
  42. package/src/components/Menu/MenuItem.tsx +11 -10
  43. package/src/components/Menu/hooks/useMenuPosition.tsx +23 -6
  44. package/src/components/Pullover/Pullover.tsx +122 -59
  45. package/src/components/Table/Table.tsx +78 -342
  46. package/src/components/Table/components/edit/TableEditRow.tsx +69 -0
  47. package/src/components/Table/components/filters/FilterItem.tsx +15 -0
  48. package/src/components/Table/components/filters/TableFilters.tsx +125 -0
  49. package/src/components/Table/components/footer/TableFooter.tsx +128 -0
  50. package/src/components/Table/components/header/TableHeader.tsx +42 -0
  51. package/src/components/Table/components/header/TableHeaderRow.tsx +47 -0
  52. package/src/components/Table/components/items/TableItemActions.tsx +66 -0
  53. package/src/components/Table/components/select/TableSelect.tsx +49 -0
  54. package/src/components/Table/components/sort/TableSort.tsx +52 -0
  55. package/src/components/Table/contexts/TableContext.tsx +123 -0
  56. package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +73 -0
  57. package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +78 -0
  58. package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +173 -0
  59. package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +12 -0
  60. package/src/components/Table/hooks/useTableEdit.tsx +111 -0
  61. package/src/components/Table/hooks/useTableFilterFields.tsx +150 -0
  62. package/src/components/Table/hooks/useTablePagination.ts +16 -0
  63. package/src/components/Table/hooks/useTableSearch.ts +29 -0
  64. package/src/components/Table/hooks/useTableSort.ts +8 -0
  65. package/src/components/Tooltip/Tooltip.tsx +1 -1
  66. package/src/components/Wrappers/PageLayout.tsx +13 -18
  67. package/src/hooks/useGetFocusableElements.ts +42 -0
  68. package/src/hooks/useLocalPopoverControl.ts +38 -0
  69. package/src/hooks/usePopupControl.ts +13 -0
  70. package/src/index.ts +53 -39
  71. package/src/styles/common/_typography.scss +3 -0
  72. package/src/styles/common/helpers/_size.scss +1 -1
  73. package/src/styles/components/_accordions.scss +1 -1
  74. package/src/styles/components/_badge.scss +4 -3
  75. package/src/styles/components/_card.scss +1 -1
  76. package/src/styles/components/_dialog.scss +15 -13
  77. package/src/styles/components/_input.scss +1 -1
  78. package/src/styles/components/_inputCheckbox.scss +1 -1
  79. package/src/styles/components/_inputDateTime.scss +2 -2
  80. package/src/styles/components/_inputRadio.scss +1 -1
  81. package/src/styles/components/_inputSelect.scss +6 -4
  82. package/src/styles/components/_menu-v2.scss +1 -1
  83. package/src/styles/components/_menu.scss +23 -15
  84. package/src/styles/components/_page.scss +3 -2
  85. package/src/styles/components/_pullover.scss +74 -18
  86. package/src/styles/components/_table.scss +151 -142
  87. package/src/styles/components/_widget.scss +1 -1
  88. package/src/styles/variables/_bp.scss +1 -0
  89. package/src/styles/variables/_variables.scss +4 -2
  90. package/src/types/IKeyboard.ts +2 -1
  91. package/src/types/IMenu.ts +1 -0
  92. package/src/types/ISelect.ts +1 -0
  93. package/src/types/ITable.ts +87 -80
  94. package/src/utils/fileUtils.ts +7 -6
  95. package/src/utils/i18n/i18nIUICyrilic.ts +4 -0
  96. package/src/utils/i18n/i18nIUILatin.ts +3 -1
  97. package/src/utils/i18n/i18nIUIMe.ts +4 -0
  98. package/src/utils/{ObjectUtils.ts → objectUtils.ts} +8 -8
  99. package/src/utils/popupUtils.ts +82 -0
  100. package/src/utils/{TableUtils.ts → tableUtils.ts} +5 -5
  101. package/src/utils/{Toasts.ts → toasts.ts} +6 -6
  102. package/src/utils/{UrlUtils.ts → urlUtils.ts} +4 -4
  103. package/dist/NoAccessPage-BozT_Suz.js +0 -2
  104. package/dist/NotFoundPage-WWiekDef.js +0 -2
  105. package/idea/Table2/Components/Columns/ColumnsList.tsx +0 -56
  106. package/idea/Table2/Components/Columns/SetColumnsList.tsx +0 -107
  107. package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +0 -87
  108. package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +0 -32
  109. package/idea/Table2/Components/Edit/TableEditRow.tsx +0 -56
  110. package/idea/Table2/Components/FilterItem.tsx +0 -20
  111. package/idea/Table2/Components/Header/TableHeader.tsx +0 -35
  112. package/idea/Table2/Components/Header/TableHeaderRow.tsx +0 -37
  113. package/idea/Table2/Components/Print/CustomTablePrint.tsx +0 -119
  114. package/idea/Table2/Components/Print/TablePrint.tsx +0 -208
  115. package/idea/Table2/Components/SetSortList.tsx +0 -33
  116. package/idea/Table2/Components/SetTableFilter.tsx +0 -90
  117. package/idea/Table2/Components/TableFooter.tsx +0 -107
  118. package/idea/Table2/Components/TableOptions.tsx +0 -211
  119. package/idea/Table2/Components/Templates/TemplateCreate.tsx +0 -75
  120. package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +0 -45
  121. package/idea/Table2/Components/Templates/TemplateList.tsx +0 -167
  122. package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +0 -51
  123. package/idea/Table2/_table.scss +0 -300
  124. package/idea/Table2/hooks/useDefaultTemplate.ts +0 -22
  125. package/idea/Table2/hooks/useTableKeyboard.ts +0 -115
  126. package/src/assets/icons/light/faPenField.ts +0 -15
  127. package/src/assets/icons/solid/faMagnifyingGlass.ts +0 -15
  128. package/src/components/Dialog/DeleteItemDialog.tsx +0 -52
  129. package/src/components/Dialog/hooks/useDialogObserver.ts +0 -21
  130. /package/{src/components → idea}/Table/Components/Columns/ColumnsList.tsx +0 -0
  131. /package/{src/components → idea}/Table/Components/Columns/SetColumnsList.tsx +0 -0
  132. /package/{src/components → idea}/Table/Components/Edit/ItemActionsMenu.tsx +0 -0
  133. /package/{src/components → idea}/Table/Components/Edit/ItemEditOptionsButtons.tsx +0 -0
  134. /package/{src/components → idea}/Table/Components/Edit/TableEditRow.tsx +0 -0
  135. /package/{src/components → idea}/Table/Components/FilterItem.tsx +0 -0
  136. /package/{src/components → idea}/Table/Components/Header/TableHeader.tsx +0 -0
  137. /package/{src/components → idea}/Table/Components/Header/TableHeaderRow.tsx +0 -0
  138. /package/{src/components → idea}/Table/Components/SetSortList.tsx +0 -0
  139. /package/{src/components → idea}/Table/Components/TableFooter.tsx +0 -0
  140. /package/{src/components → idea}/Table/Components/Templates/TemplateCreate.tsx +0 -0
  141. /package/{src/components → idea}/Table/Components/Templates/TemplateCreateDefault.tsx +0 -0
  142. /package/{src/components → idea}/Table/Components/Templates/TemplateList.tsx +0 -0
  143. /package/{src/components → idea}/Table/Components/Templates/repo/TemplateRepo.ts +0 -0
  144. /package/src/utils/{DateUtils.ts → dateUtils.ts} +0 -0
  145. /package/src/utils/{LocalStorageHelper.ts → localStorageHelper.ts} +0 -0
  146. /package/src/utils/{NumberUtils.ts → numberUtils.ts} +0 -0
  147. /package/src/utils/{RootDir.ts → rootDir.ts} +0 -0
  148. /package/src/utils/{StringUtils.ts → stringUtils.ts} +0 -0
@@ -1,208 +0,0 @@
1
- import { FC, useEffect, useState } from 'react';
2
- import { createPortal } from 'react-dom';
3
- import { faFileArrowDown } from '../../../../icons/regular/faFileArrowDown';
4
- import { faPrint } from '../../../../icons/solid/faPrint';
5
- import { faXmark } from '../../../../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';
10
- import { useTranslation } from 'react-i18next';
11
- import { rootDir } from '../../../../utils/RootDir';
12
- import clsx from 'clsx';
13
- import { HeaderTable } from '../Header/TableHeader';
14
- import { useHideZendesk } from '../../../../hooks/useZendesk';
15
-
16
- interface Props extends IPrintData {
17
- isOpen: boolean;
18
- onClose: () => void;
19
- columns: ITableColumn[];
20
- }
21
- export const TablePrint: FC<Props> = ({
22
- isOpen,
23
- onClose,
24
- columns,
25
- customHeader,
26
- organization,
27
- filters,
28
- label,
29
- optionalNode,
30
- getPrintData,
31
- formatPrintData,
32
- saveXlsx,
33
- totals,
34
- }) => {
35
- const [data, setData] = useState<ITableDataItem[]>([]);
36
- const [offset, setOffset] = useState(0);
37
- const [isLoading, setIsLoading] = useState(false);
38
-
39
- const { t } = useTranslation();
40
- useHideZendesk();
41
-
42
- const cols = columns.filter(e => e.id !== 'actions');
43
-
44
- useEffect(() => {
45
- rootDir?.classList.add('hidden');
46
- return () => {
47
- rootDir?.classList.remove('hidden');
48
- };
49
- }, []);
50
-
51
- useEffect(() => {
52
- setIsLoading(true);
53
- getPrintData({ limit: 1000, offset })
54
- .then(e => {
55
- setData(prevState => {
56
- const data = !!e.data.length ? formatPrintData(e.data) : [];
57
- const newState = [...prevState, ...data];
58
- e.totalRows && e.totalRows > newState.length
59
- ? setOffset(offset + 1)
60
- : setIsLoading(false);
61
- return e.totalRows && e.totalRows > prevState.length ? newState : prevState;
62
- });
63
- })
64
- .catch(() => setIsLoading(false));
65
- }, [offset, formatPrintData, getPrintData]);
66
-
67
- return isOpen
68
- ? createPortal(
69
- <div className="iui-print-dialog">
70
- <div className="content">
71
- <div className="flex justify-between">
72
- {organization ? (
73
- <div>
74
- <p className="name">{organization.name}</p>
75
- {organization.taxId && <p>{`${t('TaxId')}: ${organization.taxId}`}</p>}
76
- {organization.registrationNumber && (
77
- <p>{`${t('BusinessCode')}: ${organization.registrationNumber}`}</p>
78
- )}
79
- {organization.jbkjs && <p>JBKJS: {organization.jbkjs}</p>}
80
- {organization.email && <p>Email: {organization.email}</p>}
81
- </div>
82
- ) : (
83
- <div />
84
- )}
85
- <div className="text-right">
86
- <p>{`${t('PrintDate')}: ${getCurrentDateFormatted()}`}</p>
87
- </div>
88
- </div>
89
- <h4 className="my-3 text-center">{label}</h4>
90
- {filters && (
91
- <div className="flex justify-between">
92
- <div>
93
- {filters.basic?.map(
94
- e =>
95
- !!e.value && (
96
- <div key={e.value} className="mb-2">
97
- <p>{`${e.label}: ${e.value}`}</p>
98
- </div>
99
- )
100
- )}
101
- </div>
102
- {filters.date && (
103
- <div>
104
- {filters.date.map(
105
- e =>
106
- (!!e.from || !!e.to) && (
107
- <div key={e.label} className="mb-2 text-right">
108
- <p>
109
- {e.label} {!!e.from && `${t('from')} ${formatDate(e.from)}`}{' '}
110
- {`${t('to')} ${formatDate(e.to || new Date().toString())}`}
111
- </p>
112
- </div>
113
- )
114
- )}
115
- </div>
116
- )}
117
- </div>
118
- )}
119
- {optionalNode?.aboveTable}
120
- {data && (
121
- <table width="100%" className="print-table">
122
- <HeaderTable columns={cols} customHeader={customHeader} headerWrap />
123
- <tbody>
124
- <>
125
- {data.map(row => {
126
- let totalColsSpan = 0;
127
- return (
128
- <tr key={row.uuid} className={row.className}>
129
- {cols.map(column => {
130
- const cell = row.cells[column.id];
131
-
132
- totalColsSpan += cell?.span
133
- ? // If span is -1 or larger then the number of columns
134
- cell.span === -1 || cell.span > cols.length
135
- ? // ...fill the rest of the table
136
- cols.length - totalColsSpan
137
- : cell.span
138
- : 1;
139
-
140
- return (
141
- cols.length >= totalColsSpan && (
142
- <td
143
- key={column.id}
144
- align={cell?.align || column.align}
145
- className={clsx(column.color, cell?.className, {
146
- 'word-break': column.break,
147
- })}
148
- colSpan={cell?.span === -1 ? cols.length : cell?.span}
149
- >
150
- {cell?.printValue ?? cell?.value}
151
- </td>
152
- )
153
- );
154
- })}
155
- </tr>
156
- );
157
- })}
158
- {!!totals && (
159
- <tr>
160
- {cols.map(({ id: columnId }) => (
161
- <td
162
- key={columnId}
163
- align={totals.cells[columnId]?.align || 'right'}
164
- colSpan={totals.cells[columnId]?.span}
165
- className="py-3"
166
- >
167
- <strong>{totals.cells[columnId]?.value}</strong>
168
- </td>
169
- ))}
170
- </tr>
171
- )}
172
- </>
173
- </tbody>
174
- </table>
175
- )}
176
- {optionalNode?.bellowTable}
177
- </div>
178
- <div className="iui-print-actions no-print">
179
- <Button
180
- label={t('Cancel')}
181
- icon={faXmark}
182
- onClick={e => {
183
- e.stopPropagation();
184
- onClose();
185
- }}
186
- className="mr-3"
187
- />
188
- {!!saveXlsx && (
189
- <Button
190
- label={t('SaveXlsx')}
191
- icon={faFileArrowDown}
192
- onClick={() => saveXlsx()}
193
- className="mr-3"
194
- />
195
- )}
196
- <Button
197
- label={t('Print')}
198
- icon={faPrint}
199
- solid
200
- onClick={() => window.print()}
201
- />
202
- </div>
203
- <FullScreenLoader isLoading={isLoading} />
204
- </div>,
205
- document.body
206
- )
207
- : null;
208
- };
@@ -1,33 +0,0 @@
1
- import { FC } from 'react';
2
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
- import { ITableSort } from '../../../types/ITable';
4
- import { faArrowDownWideShort } from '../../../icons/light/faArrowDownWideShort';
5
- import { faArrowDownShortWide } from '../../../icons/light/faArrowDownShortWide';
6
- import { MenuItem } from '../../Menu/MenuItem';
7
- import { useTranslation } from 'react-i18next';
8
-
9
- interface Props {
10
- sort: string;
11
- setSort: (sort: string) => void;
12
- sortOptions: ITableSort[];
13
- }
14
- export const SetSortList: FC<Props> = ({ sortOptions, sort, setSort }) => {
15
- const { t } = useTranslation();
16
- return (
17
- <>
18
- {sortOptions.map(e => (
19
- <MenuItem
20
- key={e.label}
21
- className="menu-item-m"
22
- onClick={() => setSort(sort === e.desc ? e.asc : e.desc)}
23
- >
24
- <div className="flex center justify-between full-width">
25
- <p className="mr-5 mb-0">{e.label}</p>
26
- {sort === e.desc && <FontAwesomeIcon icon={faArrowDownWideShort} />}
27
- {sort === e.asc && <FontAwesomeIcon icon={faArrowDownShortWide} />}
28
- </div>
29
- </MenuItem>
30
- ))}
31
- </>
32
- );
33
- };
@@ -1,90 +0,0 @@
1
- import { FC, useMemo, useState } from 'react';
2
- import { faFilterCircleXmark } from '../../../icons/regular/faFilterCircleXmark';
3
- import { faMagnifyingGlass } from '../../../icons/solid/faMagnifyingGlass';
4
- import { faXmark } from '../../../icons/solid/faXmark';
5
- import { ITableFilterData, ITableFilterItem } from '../../../types/ITable';
6
- import { deleteEmptyPropsIncludingArray, deleteProps } from '../../../utils/ObjectUtils';
7
- import { Dialog } from '../../Dialog/Dialog';
8
- import { FilterItem } from './FilterItem';
9
- import { useTranslation } from 'react-i18next';
10
- import { SearchInput } from '../../Inputs/SearchInput';
11
-
12
- interface Props extends ITableFilterData {
13
- isOpen: boolean;
14
- onClose: () => void;
15
- }
16
-
17
- export const SetTableFilter: FC<Props> = ({
18
- columns,
19
- filters,
20
- additionalFilters,
21
- excludeFromSearch,
22
- searchData,
23
- setSearchData,
24
- onSubmit,
25
- resetData,
26
- isOpen,
27
- onClose,
28
- }) => {
29
- const [search, setSearch] = useState('');
30
-
31
- const { t } = useTranslation();
32
-
33
- const visibleFilters = useMemo(
34
- () =>
35
- columns.reduce(
36
- (arr: ITableFilterItem[], col) =>
37
- !!filters[col] ? arr.concat(filters[col]) : arr,
38
- []
39
- ),
40
- [columns, filters]
41
- );
42
-
43
- const filteredFilters = useMemo(
44
- () =>
45
- visibleFilters.filter(e => e?.label.toLowerCase().includes(search.toLowerCase())),
46
- [visibleFilters, search]
47
- );
48
-
49
- return (
50
- <Dialog
51
- className="iui-table-filter"
52
- titleEl={
53
- <div className="filters-search">
54
- <h1>{t('Filter')}</h1>
55
- <SearchInput onSearch={setSearch} className="search-input" />
56
- </div>
57
- }
58
- isOpen={isOpen}
59
- onClose={() => {
60
- setSearch('');
61
- onClose();
62
- }}
63
- cancelButton={{ icon: faXmark }}
64
- additionalButton={{
65
- label: t('ResetFilter'),
66
- icon: faFilterCircleXmark,
67
- onClick: () => {
68
- setSearchData(resetData || {});
69
- onSubmit(resetData || {});
70
- },
71
- disabled: resetData
72
- ? JSON.stringify(searchData) === JSON.stringify(resetData)
73
- : Object.keys(searchData).length === 0,
74
- }}
75
- confirmButton={{
76
- label: t('Search'),
77
- icon: faMagnifyingGlass,
78
- onFormSubmit: () => {
79
- const data = deleteEmptyPropsIncludingArray(searchData);
80
- onSubmit(excludeFromSearch ? deleteProps(data, excludeFromSearch) : data);
81
- },
82
- }}
83
- >
84
- {filteredFilters?.map(item => (
85
- <FilterItem key={item.label} item={item} />
86
- ))}
87
- {additionalFilters && <div className="pb-1">{additionalFilters}</div>}
88
- </Dialog>
89
- );
90
- };
@@ -1,107 +0,0 @@
1
- import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
- import { ChangeEvent, FC, MouseEventHandler } from 'react';
3
- import { faAngleLeft } from '../../../icons/solid/faAngleLeft';
4
- import { faAngleRight } from '../../../icons/solid/faAngleRight';
5
- import { faRotateRight } from '../../../icons/solid/faRotateRight';
6
- import { IconButton } from '../../Button/IconButton';
7
- import { useTranslation } from 'react-i18next';
8
- import { IServerSidePagination } from '../../../types/ITable';
9
-
10
- interface Props {
11
- pagination: IServerSidePagination;
12
- noTotalRows?: boolean;
13
- footerAction?: {
14
- icon?: IconDefinition;
15
- onClick: MouseEventHandler<HTMLButtonElement>;
16
- };
17
- customLimit?: number[];
18
- }
19
-
20
- export const TableFooter: FC<Props> = ({
21
- pagination: { limit, offset, setLimit, setOffset, totalRows },
22
- noTotalRows,
23
- footerAction,
24
- customLimit,
25
- }) => {
26
- const { t } = useTranslation();
27
-
28
- const handleChangeLimit = (event: ChangeEvent<HTMLSelectElement>) => {
29
- const newLimit = Math.floor(+event.target.value);
30
- setLimit(newLimit);
31
- setOffset(0);
32
- };
33
-
34
- const maxOffset = Math.ceil(totalRows / limit);
35
-
36
- return (
37
- <div className={`table-footer ${footerAction ? 'justify-between' : 'justify-right'}`}>
38
- {!!footerAction && (
39
- <IconButton
40
- icon={footerAction.icon || faRotateRight}
41
- onClick={footerAction.onClick}
42
- />
43
- )}
44
- <div className="pagination">
45
- <div className="flex align-center">
46
- <p>{t('rowsPerPage')}</p>
47
-
48
- <select value={limit} onChange={handleChangeLimit}>
49
- {(customLimit || [5, 10, 25, 50, 100]).map(e => (
50
- <option key={e} value={e}>
51
- {e ? e : t('allResults')}
52
- </option>
53
- ))}
54
- </select>
55
- {!noTotalRows && (
56
- <p className="mr-4">
57
- {limit
58
- ? `${offset * limit + 1}-${
59
- offset * limit + limit <= totalRows
60
- ? offset * limit + limit
61
- : totalRows
62
- } ${t('of')} ${totalRows}`
63
- : `${t('allResults')} ${t('of')} ${totalRows} `}
64
- </p>
65
- )}
66
- </div>
67
- <div className="flex gap-1 align-center">
68
- {noTotalRows ? (
69
- <p>{`${t('page')}: ${offset + 1}`}</p>
70
- ) : (
71
- <p>{`${t('page')}: ${offset + 1}/${maxOffset}`}</p>
72
- )}
73
- <IconButton
74
- disabled={offset < 1}
75
- icon={faAngleLeft}
76
- onClick={() => setOffset(offset - 1)}
77
- size="s"
78
- />
79
- {!noTotalRows && (
80
- <input
81
- className="offset-input"
82
- placeholder={`1-${maxOffset}`}
83
- onKeyUp={e => {
84
- if (e.key === 'Enter') {
85
- const value = +(e.target as HTMLInputElement).value;
86
- if (typeof value === 'number' && value >= 0 && value <= maxOffset)
87
- setOffset(value - 1);
88
- (e.target as HTMLInputElement).value = '';
89
- }
90
- }}
91
- />
92
- )}
93
- <IconButton
94
- disabled={
95
- noTotalRows /* && serverSidePagination */
96
- ? limit > totalRows
97
- : offset + 1 >= maxOffset
98
- }
99
- icon={faAngleRight}
100
- onClick={() => setOffset(offset + 1)}
101
- size="s"
102
- />
103
- </div>
104
- </div>
105
- </div>
106
- );
107
- };
@@ -1,211 +0,0 @@
1
- import { FC, ReactNode, useState } from 'react';
2
- import { faPrint } from '../../../icons/solid/faPrint';
3
- import {
4
- ITableSortData,
5
- ITableColumn,
6
- ITableFilterData,
7
- IPrintData,
8
- ITableColumnsData,
9
- ITable,
10
- ICustomPrintData,
11
- } from '../../../types/ITable';
12
- import { getActiveFilterNumber, setTemplateData } from '../../../utils/TableUtils';
13
- import { NotificationBadge } from '../../Badge/NotificationBadge';
14
- import { Button } from '../../Button/Button';
15
- import { Menu } from '../../Menu/Menu';
16
- import { TablePrint } from './Print/TablePrint';
17
- import { SetColumnsList } from './Columns/SetColumnsList';
18
- import { SetSortList } from './SetSortList';
19
- import { SetTableFilter } from './SetTableFilter';
20
- import { faCaretDown } from '../../../icons/solid/faCaretDown';
21
- import { useTranslation } from 'react-i18next';
22
- import { TemplateList } from './Templates/TemplateList';
23
- import { MenuItem } from '../../Menu/MenuItem';
24
- import { TemplateCreate } from './Templates/TemplateCreate';
25
- import { maxChar } from '../../../utils/StringUtils';
26
- import { TemplateCreateDefault } from './Templates/TemplateCreateDefault';
27
- import { deletePropsThatEndsWith } from '../../../utils/ObjectUtils';
28
- import { CustomTablePrint } from './Print/CustomTablePrint';
29
-
30
- interface Props {
31
- columns: ITableColumn[];
32
- columnsData?: ITableColumnsData;
33
- filterData?: ITableFilterData;
34
- sortData?: ITableSortData;
35
- printData?: IPrintData;
36
- customPrintData?: ICustomPrintData;
37
- templates?: ITable['templates'];
38
- additionsalOptions?: ReactNode;
39
- }
40
- export const TableOptions: FC<Props> = ({
41
- columns,
42
- columnsData,
43
- filterData,
44
- sortData,
45
- printData,
46
- customPrintData,
47
- templates,
48
- additionsalOptions,
49
- }) => {
50
- const [selectedTemplateName, setSelectedTemplateName] = useState('');
51
- const [opened, setOpened] = useState<
52
- 'filter' | 'sort' | 'columns' | 'print' | 'templates' | ''
53
- >('');
54
-
55
- const { t } = useTranslation();
56
-
57
- const onClose = () => setOpened('');
58
-
59
- return (
60
- <div className="table-options gap-2">
61
- <div className="flex align-center gap-2">
62
- {filterData && (
63
- <>
64
- <NotificationBadge number={getActiveFilterNumber(filterData.search)} small>
65
- <Button
66
- label={t('Filter')}
67
- active={opened === 'filter'}
68
- onClick={() => setOpened('filter')}
69
- className="table-options-btn"
70
- size="s"
71
- />
72
- </NotificationBadge>
73
- <SetTableFilter
74
- {...filterData}
75
- onSubmit={search => {
76
- filterData.onSubmit(search);
77
- setSelectedTemplateName('');
78
- }}
79
- isOpen={opened === 'filter'}
80
- onClose={onClose}
81
- />
82
- </>
83
- )}
84
- {columnsData && (
85
- <>
86
- <Button
87
- label={t('Columns')}
88
- active={opened === 'columns'}
89
- onClick={() => setOpened('columns')}
90
- className="table-options-btn"
91
- size="s"
92
- />
93
- {opened === 'columns' && (
94
- <SetColumnsList
95
- columns={columnsData.columns}
96
- setColumns={data => {
97
- columnsData.setColumns(data);
98
- setSelectedTemplateName('');
99
- }}
100
- isOpen={true}
101
- onClose={onClose}
102
- withSearch={columnsData.withSearch}
103
- />
104
- )}
105
- </>
106
- )}
107
- {sortData && (
108
- <Menu
109
- renderButton={ref => (
110
- <Button
111
- label={t('Sort')}
112
- iconEnd={faCaretDown}
113
- active={opened === 'sort'}
114
- onClick={() => setOpened('sort')}
115
- ref={ref}
116
- className="table-options-btn"
117
- size="s"
118
- />
119
- )}
120
- isOpen={opened === 'sort'}
121
- onClose={onClose}
122
- size={sortData.menuSize}
123
- >
124
- <SetSortList
125
- {...sortData}
126
- setSort={data => {
127
- sortData.setSort(data);
128
- setSelectedTemplateName('');
129
- }}
130
- />
131
- </Menu>
132
- )}
133
- {templates && (
134
- <Menu
135
- renderButton={ref => (
136
- <Button
137
- label={
138
- selectedTemplateName
139
- ? `${t('Templates')} (${maxChar(selectedTemplateName, 30)})`
140
- : t('Templates')
141
- }
142
- iconEnd={faCaretDown}
143
- active={opened === 'templates'}
144
- onClick={() => setOpened('templates')}
145
- ref={ref}
146
- className="table-options-btn"
147
- size="s"
148
- />
149
- )}
150
- isOpen={opened === 'templates'}
151
- onClose={onClose}
152
- >
153
- <TemplateList
154
- identifier={templates.identifier}
155
- onSelect={template => {
156
- setTemplateData({
157
- template,
158
- columnsData,
159
- setFilters: e => {
160
- filterData?.setSearchData(e);
161
- filterData?.onSubmit(deletePropsThatEndsWith(e, 'Obj'));
162
- },
163
- setSort: sortData?.setSort,
164
- });
165
- setSelectedTemplateName(template.name);
166
- onClose();
167
- }}
168
- />
169
- <MenuItem
170
- label={t('RemoveFiltersAndLook')}
171
- onClick={() => {
172
- templates.onClearFilters();
173
- setSelectedTemplateName('');
174
- onClose();
175
- }}
176
- />
177
- <TemplateCreate
178
- identifier={templates.identifier}
179
- data={templates.data}
180
- onSubmitCallback={onClose}
181
- />
182
- <TemplateCreateDefault
183
- identifier={templates.identifier}
184
- data={templates.data}
185
- onClose={onClose}
186
- />
187
- </Menu>
188
- )}
189
- {additionsalOptions}
190
- </div>
191
- {(printData ?? customPrintData) && (
192
- <>
193
- <Button
194
- label={t('PrintExport')}
195
- icon={faPrint}
196
- onClick={() => setOpened('print')}
197
- size="s"
198
- />
199
- {opened === 'print' &&
200
- (printData ? (
201
- <TablePrint {...printData} isOpen onClose={onClose} columns={columns} />
202
- ) : (
203
- customPrintData && (
204
- <CustomTablePrint {...customPrintData} isOpen onClose={onClose} />
205
- )
206
- ))}
207
- </>
208
- )}
209
- </div>
210
- );
211
- };