@inceptionbg/iui 2.0.5 → 2.0.7

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 (257) hide show
  1. package/dist/{NoAccessPage-C6nBt-PN.js → NoAccessPage-BozT_Suz.js} +2 -2
  2. package/dist/{NoAccessPage-C6nBt-PN.js.map → NoAccessPage-BozT_Suz.js.map} +1 -1
  3. package/dist/{NotFoundPage-DatmJOrr.js → NotFoundPage-WWiekDef.js} +2 -2
  4. package/dist/{NotFoundPage-DatmJOrr.js.map → NotFoundPage-WWiekDef.js.map} +1 -1
  5. package/dist/icons/index.d.ts +43 -0
  6. package/dist/icons/index.js +1 -0
  7. package/dist/index.d.ts +32 -20
  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/Menu/Menu.tsx +119 -0
  12. package/idea/Menu/MenuItem.tsx +74 -0
  13. package/idea/Menu/hooks/useMenuControl.ts +13 -0
  14. package/idea/Menu.tsx +132 -0
  15. package/idea/NoAccessInfo.tsx +193 -0
  16. package/idea/Notifications.tsx +245 -0
  17. package/idea/Table2/Components/Columns/ColumnsList.tsx +56 -0
  18. package/idea/Table2/Components/Columns/SetColumnsList.tsx +107 -0
  19. package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +87 -0
  20. package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +32 -0
  21. package/idea/Table2/Components/Edit/TableEditRow.tsx +56 -0
  22. package/idea/Table2/Components/FilterItem.tsx +20 -0
  23. package/idea/Table2/Components/Header/TableHeader.tsx +35 -0
  24. package/idea/Table2/Components/Header/TableHeaderRow.tsx +37 -0
  25. package/idea/Table2/Components/Print/CustomTablePrint.tsx +119 -0
  26. package/idea/Table2/Components/Print/TablePrint.tsx +208 -0
  27. package/idea/Table2/Components/SetSortList.tsx +33 -0
  28. package/idea/Table2/Components/SetTableFilter.tsx +90 -0
  29. package/idea/Table2/Components/TableFooter.tsx +107 -0
  30. package/idea/Table2/Components/TableOptions.tsx +211 -0
  31. package/idea/Table2/Components/Templates/TemplateCreate.tsx +75 -0
  32. package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +45 -0
  33. package/idea/Table2/Components/Templates/TemplateList.tsx +167 -0
  34. package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +51 -0
  35. package/idea/Table2/Table.tsx +657 -0
  36. package/idea/Table2/_table.scss +300 -0
  37. package/idea/Table2/hooks/useDefaultTemplate.ts +22 -0
  38. package/idea/Table2/hooks/useTableKeyboard.ts +115 -0
  39. package/package.json +9 -4
  40. package/rollup.config.js +80 -0
  41. package/src/assets/icons/duotone/faCircleUser.ts +17 -0
  42. package/src/assets/icons/index.ts +20 -0
  43. package/src/assets/icons/light/faArrowDownShortWide.ts +15 -0
  44. package/src/assets/icons/light/faArrowDownWideShort.ts +15 -0
  45. package/src/assets/icons/light/faArrowUpArrowDown.ts +15 -0
  46. package/src/assets/icons/light/faArrowUpRightFromSquare.ts +15 -0
  47. package/src/assets/icons/light/faArrowsToLine.ts +15 -0
  48. package/src/assets/icons/light/faArrowsUpDown.ts +15 -0
  49. package/src/assets/icons/light/faCalendarPlus.ts +15 -0
  50. package/src/assets/icons/light/faCheck.ts +15 -0
  51. package/src/assets/icons/light/faChevronDown.ts +15 -0
  52. package/src/assets/icons/light/faChevronRight.ts +15 -0
  53. package/src/assets/icons/light/faCircleInfo.ts +15 -0
  54. package/src/assets/icons/light/faCircleXmark.ts +15 -0
  55. package/src/assets/icons/light/faClockRotateLeft.ts +15 -0
  56. package/src/assets/icons/light/faEllipsisVertical.ts +15 -0
  57. package/src/assets/icons/light/faEye.ts +15 -0
  58. package/src/assets/icons/light/faEyeSlash.ts +15 -0
  59. package/src/assets/icons/light/faFilter.ts +15 -0
  60. package/src/assets/icons/light/faGear.ts +15 -0
  61. package/src/assets/icons/light/faHouse.ts +15 -0
  62. package/src/assets/icons/light/faIdBadge.ts +15 -0
  63. package/src/assets/icons/light/faLineColumns.ts +15 -0
  64. package/src/assets/icons/light/faLink.ts +15 -0
  65. package/src/assets/icons/light/faMagnifyingGlass.ts +15 -0
  66. package/src/assets/icons/light/faPenField.ts +15 -0
  67. package/src/assets/icons/light/faPrint.ts +15 -0
  68. package/src/assets/icons/light/faQuestion.ts +15 -0
  69. package/src/assets/icons/light/faRotateRight.ts +15 -0
  70. package/src/assets/icons/light/faTrashCan.ts +15 -0
  71. package/src/assets/icons/light/faTriangleExclamation.ts +15 -0
  72. package/src/assets/icons/light/faXmark.ts +15 -0
  73. package/src/assets/icons/regular/faArrowLeft.ts +15 -0
  74. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +15 -0
  75. package/src/assets/icons/regular/faCircleCheck.ts +15 -0
  76. package/src/assets/icons/regular/faCircleExclamation.ts +15 -0
  77. package/src/assets/icons/regular/faCircleInfo.ts +15 -0
  78. package/src/assets/icons/regular/faFileArrowDown.ts +15 -0
  79. package/src/assets/icons/regular/faFilterCircleXmark.ts +15 -0
  80. package/src/assets/icons/regular/faTriangleExclamation.ts +15 -0
  81. package/src/assets/icons/solid/faAngleLeft.ts +15 -0
  82. package/src/assets/icons/solid/faAngleRight.ts +15 -0
  83. package/src/assets/icons/solid/faArrowDownWideShort.ts +15 -0
  84. package/src/assets/icons/solid/faCaretDown.ts +15 -0
  85. package/src/assets/icons/solid/faCheck.ts +15 -0
  86. package/src/assets/icons/solid/faEllipsisVertical.ts +15 -0
  87. package/src/assets/icons/solid/faFilter.ts +15 -0
  88. package/src/assets/icons/solid/faFloppyDisk.ts +15 -0
  89. package/src/assets/icons/solid/faGripDotsVertical.ts +15 -0
  90. package/src/assets/icons/solid/faListUl.ts +15 -0
  91. package/src/assets/icons/solid/faMagnifyingGlass.ts +15 -0
  92. package/src/assets/icons/solid/faMinus.ts +15 -0
  93. package/src/assets/icons/solid/faPlus.ts +15 -0
  94. package/src/assets/icons/solid/faPrint.ts +15 -0
  95. package/src/assets/icons/solid/faRotateRight.ts +15 -0
  96. package/src/assets/icons/solid/faXmark.ts +15 -0
  97. package/src/assets/images/logo/mts.svg +5703 -0
  98. package/src/assets/images/logo/paperless.svg +21 -0
  99. package/src/assets/images/logo/pismonosa.png +0 -0
  100. package/src/assets/images/not-found.svg +19 -0
  101. package/src/components/Accordions/Accordions.tsx +64 -0
  102. package/src/components/Alert/Alert.tsx +31 -0
  103. package/src/components/Badge/DotBadge.tsx +16 -0
  104. package/src/components/Badge/NotificationBadge.tsx +29 -0
  105. package/src/components/Badge/PillBadge.tsx +13 -0
  106. package/src/components/Button/Button.tsx +56 -0
  107. package/src/components/Button/IconButton.tsx +49 -0
  108. package/src/components/Dashboard/Dashboard.tsx +9 -0
  109. package/src/components/Dashboard/DashboardWidget.tsx +44 -0
  110. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +37 -0
  111. package/src/components/Dialog/DeleteItemDialog.tsx +52 -0
  112. package/src/components/Dialog/Dialog.tsx +226 -0
  113. package/src/components/Dialog/hooks/useDialogKeyboard.ts +41 -0
  114. package/src/components/Dialog/hooks/useDialogObserver.ts +21 -0
  115. package/src/components/Header/Components/ModuleSelect.tsx +55 -0
  116. package/src/components/Header/Components/UserMenu.tsx +52 -0
  117. package/src/components/Header/Header.tsx +31 -0
  118. package/src/components/Helper/Collapse.tsx +52 -0
  119. package/src/components/Inputs/Checkbox.tsx +53 -0
  120. package/src/components/Inputs/CurrencyInput.tsx +123 -0
  121. package/src/components/Inputs/DateInput/DateInput.tsx +177 -0
  122. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +154 -0
  123. package/src/components/Inputs/InputWrapper.tsx +90 -0
  124. package/src/components/Inputs/NumberInput.tsx +83 -0
  125. package/src/components/Inputs/PasswordInput.tsx +38 -0
  126. package/src/components/Inputs/Radio.tsx +59 -0
  127. package/src/components/Inputs/RadioGroup.tsx +48 -0
  128. package/src/components/Inputs/RadioLarge.tsx +39 -0
  129. package/src/components/Inputs/SearchInput.tsx +40 -0
  130. package/src/components/Inputs/Select2/Select.tsx +224 -0
  131. package/src/components/Inputs/Select2/select.scss +43 -0
  132. package/src/components/Inputs/Selects/Select.tsx +17 -0
  133. package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +19 -0
  134. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +126 -0
  135. package/src/components/Inputs/Selects/utils/selectStyles.ts +104 -0
  136. package/src/components/Inputs/TextAreaInput.tsx +67 -0
  137. package/src/components/Inputs/TextInput.tsx +98 -0
  138. package/src/components/Inputs/TimeInput/TimeInput.tsx +81 -0
  139. package/src/components/Loader/Loader.tsx +53 -0
  140. package/src/components/Menu/Menu.tsx +68 -0
  141. package/src/components/Menu/MenuItem.tsx +47 -0
  142. package/src/components/Menu/NewMenu.tsx +66 -0
  143. package/src/components/Menu/hooks/useMenuPosition.tsx +80 -0
  144. package/src/components/Pullover/Pullover.tsx +89 -0
  145. package/src/components/Router/Router.tsx +51 -0
  146. package/src/components/Sidebar/AddButton.tsx +22 -0
  147. package/src/components/Sidebar/Sidebar.tsx +81 -0
  148. package/src/components/Sidebar/SidebarItem.tsx +84 -0
  149. package/src/components/Sidebar/types/ISidebar.ts +28 -0
  150. package/src/components/Table/Components/Columns/ColumnsList.tsx +61 -0
  151. package/src/components/Table/Components/Columns/SetColumnsList.tsx +113 -0
  152. package/src/components/Table/Components/Edit/ItemActionsMenu.tsx +84 -0
  153. package/src/components/Table/Components/Edit/ItemEditOptionsButtons.tsx +31 -0
  154. package/src/components/Table/Components/Edit/TableEditRow.tsx +56 -0
  155. package/src/components/Table/Components/FilterItem.tsx +20 -0
  156. package/src/components/Table/Components/Header/TableHeader.tsx +45 -0
  157. package/src/components/Table/Components/Header/TableHeaderRow.tsx +37 -0
  158. package/src/components/Table/Components/Print/CustomTablePrint.tsx +114 -0
  159. package/src/components/Table/Components/Print/TablePrint.tsx +207 -0
  160. package/src/components/Table/Components/SetSortList.tsx +30 -0
  161. package/src/components/Table/Components/SetTableFilter.tsx +90 -0
  162. package/src/components/Table/Components/TableFooter.tsx +135 -0
  163. package/src/components/Table/Components/TableOptions.tsx +226 -0
  164. package/src/components/Table/Components/Templates/TemplateCreate.tsx +80 -0
  165. package/src/components/Table/Components/Templates/TemplateCreateDefault.tsx +45 -0
  166. package/src/components/Table/Components/Templates/TemplateList.tsx +167 -0
  167. package/src/components/Table/Components/Templates/repo/TemplateRepo.ts +53 -0
  168. package/src/components/Table/Table.tsx +527 -0
  169. package/src/components/Table/hooks/useDefaultTemplate.ts +20 -0
  170. package/src/components/Table/hooks/useTableKeyboard.ts +138 -0
  171. package/src/components/Table/hooks/useTableSelect.ts +11 -0
  172. package/src/components/Tabs/Tabs.tsx +66 -0
  173. package/src/components/Tooltip/Tooltip.tsx +133 -0
  174. package/src/components/Tree/Tree.tsx +22 -0
  175. package/src/components/Tree/TreeItem.tsx +56 -0
  176. package/src/components/Wrappers/AppLayout.tsx +17 -0
  177. package/src/components/Wrappers/ConditionalWrapper.tsx +10 -0
  178. package/src/components/Wrappers/FormWrapper.tsx +81 -0
  179. package/src/components/Wrappers/PageLayout.tsx +152 -0
  180. package/src/hooks/useBackgroundClose.ts +18 -0
  181. package/src/hooks/useIsMenuOpen.ts +11 -0
  182. package/src/hooks/useOnEsc.ts +14 -0
  183. package/src/hooks/useZendesk.ts +21 -0
  184. package/src/index.ts +324 -0
  185. package/src/pages/NoAccessPage.tsx +27 -0
  186. package/src/pages/NotFoundPage.tsx +26 -0
  187. package/src/styles/App.scss +43 -0
  188. package/src/styles/common/_animations.scss +64 -0
  189. package/src/styles/common/_typography.scss +88 -0
  190. package/src/styles/common/helpers/_base.scss +55 -0
  191. package/src/styles/common/helpers/_color.scss +7 -0
  192. package/src/styles/common/helpers/_display.scss +85 -0
  193. package/src/styles/common/helpers/_size.scss +25 -0
  194. package/src/styles/common/maps/_align.scss +21 -0
  195. package/src/styles/common/maps/_info-types.scss +1 -0
  196. package/src/styles/common/maps/_spacing.scss +78 -0
  197. package/src/styles/common/maps/_text.scss +14 -0
  198. package/src/styles/components/_accordions.scss +46 -0
  199. package/src/styles/components/_alert.scss +23 -0
  200. package/src/styles/components/_badge.scss +76 -0
  201. package/src/styles/components/_button.scss +138 -0
  202. package/src/styles/components/_card.scss +24 -0
  203. package/src/styles/components/_dialog.scss +111 -0
  204. package/src/styles/components/_form.scss +8 -0
  205. package/src/styles/components/_header.scss +109 -0
  206. package/src/styles/components/_input.scss +158 -0
  207. package/src/styles/components/_inputCheckbox.scss +105 -0
  208. package/src/styles/components/_inputDateTime.scss +161 -0
  209. package/src/styles/components/_inputRadio.scss +83 -0
  210. package/src/styles/components/_inputSelect.scss +6 -0
  211. package/src/styles/components/_loader.scss +44 -0
  212. package/src/styles/components/_menu-v2.scss +67 -0
  213. package/src/styles/components/_menu.scss +53 -0
  214. package/src/styles/components/_page.scss +62 -0
  215. package/src/styles/components/_portal.scss +8 -0
  216. package/src/styles/components/_print.scss +87 -0
  217. package/src/styles/components/_pullover.scss +43 -0
  218. package/src/styles/components/_scrollbar.scss +18 -0
  219. package/src/styles/components/_sidebar.scss +206 -0
  220. package/src/styles/components/_smallComponents.scss +23 -0
  221. package/src/styles/components/_table.scss +270 -0
  222. package/src/styles/components/_tabs.scss +33 -0
  223. package/src/styles/components/_tooltip.scss +48 -0
  224. package/src/styles/components/_tree.scss +21 -0
  225. package/src/styles/components/_widget.scss +90 -0
  226. package/src/styles/pages/_fullScreenPage.scss +64 -0
  227. package/src/styles/variables/_bp.scss +5 -0
  228. package/src/styles/variables/_variables.scss +130 -0
  229. package/src/types/Base/custom.d.ts +9 -0
  230. package/src/types/IBasic.ts +31 -0
  231. package/src/types/IError.ts +5 -0
  232. package/src/types/IHeader.ts +34 -0
  233. package/src/types/IInfo.ts +1 -0
  234. package/src/types/IKeyboard.ts +37 -0
  235. package/src/types/IMenu.ts +18 -0
  236. package/src/types/IRouter.ts +6 -0
  237. package/src/types/ISelect.ts +52 -0
  238. package/src/types/ITab.ts +10 -0
  239. package/src/types/ITable.ts +249 -0
  240. package/src/types/ITree.ts +6 -0
  241. package/src/utils/DateUtils.ts +32 -0
  242. package/src/utils/InputPatternValidation.ts +12 -0
  243. package/src/utils/LocalStorageHelper.ts +24 -0
  244. package/src/utils/NumberUtils.ts +21 -0
  245. package/src/utils/ObjectUtils.ts +85 -0
  246. package/src/utils/RootDir.ts +1 -0
  247. package/src/utils/StringUtils.ts +18 -0
  248. package/src/utils/TableUtils.ts +130 -0
  249. package/src/utils/Toasts.ts +6 -0
  250. package/src/utils/UrlUtils.ts +4 -0
  251. package/src/utils/fileUtils.ts +176 -0
  252. package/src/utils/i18n/i18nIUICyrilic.ts +90 -0
  253. package/src/utils/i18n/i18nIUILatin.ts +90 -0
  254. package/src/utils/i18n/i18nIUIMe.ts +88 -0
  255. package/src/utils/icons.ts +13 -0
  256. package/tsconfig.icons.json +5 -0
  257. package/tsconfig.json +19 -0
@@ -0,0 +1,657 @@
1
+ import clsx from 'clsx';
2
+ import { FC, Fragment, useEffect, useState } from 'react';
3
+ import {
4
+ ITable,
5
+ ITableColumn,
6
+ ITableDataItem,
7
+ ITableSelectedActions,
8
+ } from '../../types/ITable';
9
+ import { Loader } from '../Loader/Loader';
10
+ import { Tooltip } from '../Tooltip/Tooltip';
11
+ import { ConditionalWrapper } from '../Wrappers/ConditionalWrapper';
12
+ import { TableFooter } from './Components/TableFooter';
13
+ import { HeaderTable } from './Components/Header/TableHeader';
14
+ import { TableOptions } from './Components/TableOptions';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { Checkbox } from '../Inputs/Checkbox';
17
+ import { Menu } from '../Menu/Menu';
18
+ import { faEllipsisVertical } from '../../icons/solid/faEllipsisVertical';
19
+ import { MenuItem } from '../Menu/MenuItem';
20
+ import { Button } from '../Button/Button';
21
+ import { useTableKeyboard } from './hooks/useTableKeyboard';
22
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
23
+ import { faPlus } from '../../icons/solid/faPlus';
24
+
25
+ import './table.scss';
26
+
27
+ export const Table: FC<ITable> = ({
28
+ columns,
29
+ setColumns,
30
+ withColumnsSearch,
31
+ customHeader,
32
+ data: tableData,
33
+ totals,
34
+ isLoading,
35
+ headerWrap,
36
+ serverSidePagination,
37
+ customPagination,
38
+ selectedRowUuid,
39
+ footerAction,
40
+ hideFooter,
41
+ noTotalRows,
42
+ showLastBorder,
43
+ className,
44
+ filterData,
45
+ sortData,
46
+ printData,
47
+ customPrintData,
48
+ templates,
49
+ additionsalOptions,
50
+ selectedOptions,
51
+ maxHeight,
52
+ editable,
53
+ keyboard,
54
+ }) => {
55
+ const [limit, setLimit] = useState(customPagination?.defaultLimit ?? 5);
56
+ const [offset, setOffset] = useState(0);
57
+ const [cols, setCols] = useState<ITableColumn[]>([]);
58
+ const [data, setData] = useState<ITableDataItem[]>([]);
59
+ const [extendedRow, setExtendedRow] = useState('');
60
+ const [editableData, setEditableData] = useState<object>({});
61
+ const [isAdding, setIsAdding] = useState(false);
62
+ const [selected, setSelected] = useState(new Set<string>());
63
+ const [selectedActionOpen, setSelectedActionOpen] = useState(false);
64
+ const [activeSelectOptions, setActiveSelectOptions] = useState<ITableSelectedActions[]>(
65
+ []
66
+ );
67
+
68
+ const { t } = useTranslation();
69
+
70
+ const pagination = {
71
+ limit: serverSidePagination?.limit || limit,
72
+ offset: serverSidePagination?.offset || offset,
73
+ setLimit: serverSidePagination?.setLimit || setLimit,
74
+ setOffset: serverSidePagination?.setOffset || setOffset,
75
+ totalRows: serverSidePagination?.totalRows || tableData.length,
76
+ };
77
+
78
+ const focusedRow = useTableKeyboard({
79
+ enabled: !!keyboard?.enabled,
80
+ rows: data,
81
+ actions: {
82
+ moveDisabled: !!keyboard?.actions?.moveDisabled || isAdding,
83
+ ...keyboard?.actions,
84
+ add: {
85
+ isAdding,
86
+ setIsAdding,
87
+ enabled: !!editable?.EditableRow && !editable.addDisabled,
88
+ },
89
+ edit: {
90
+ item: editable?.selectedItem,
91
+ setItem: editable?.setSelectedItem!,
92
+ enabled:
93
+ !!editable && !!editable!.setSelectedItem && !keyboard?.actions.editDisabled,
94
+ },
95
+ additional: additionalProps => [
96
+ ...(keyboard?.actions?.additional?.(additionalProps) || []),
97
+ {
98
+ key: 'PageUp',
99
+ isActive: !additionalProps.isEditing,
100
+ onAction: () =>
101
+ pagination.offset > 0 && pagination.setOffset(pagination.offset - 1),
102
+ },
103
+ {
104
+ key: 'PageDown',
105
+ isActive: !additionalProps.isEditing,
106
+ onAction: () => {
107
+ if (
108
+ noTotalRows
109
+ ? pagination.limit <= pagination.totalRows
110
+ : pagination.offset + 1 <
111
+ Math.ceil(pagination.totalRows / pagination.limit)
112
+ ) {
113
+ pagination.setOffset(pagination.offset + 1);
114
+ }
115
+ },
116
+ },
117
+ ],
118
+ },
119
+ });
120
+
121
+ // Set Active Select Options
122
+ useEffect(() => {
123
+ selectedOptions?.actions.length &&
124
+ setActiveSelectOptions(selectedOptions.actions.filter(e => !e.hidden) || []);
125
+ }, [selectedOptions?.actions]);
126
+
127
+ // Reset Selected Rows
128
+ useEffect(() => {
129
+ if (selectedOptions?.resetSelect) {
130
+ setSelected(new Set<string>());
131
+ }
132
+ }, [selectedOptions?.resetSelect]);
133
+
134
+ useEffect(() => {
135
+ // Active Column
136
+ const activeColumns = columns.filter(e => !e.hidden && !e.unavailable);
137
+
138
+ // Select Column
139
+ let selectCol;
140
+ if (activeSelectOptions.length) {
141
+ const selectableData = data.filter(e => !e.disableSelect);
142
+ const selectedSome =
143
+ !!selected.size && selectableData.some(e => !selected.has(e.uuid));
144
+ const selectedAll = !!selected.size && !selectedSome;
145
+ selectCol = {
146
+ id: 'select',
147
+ label: (
148
+ <Checkbox
149
+ value={selectedSome ? 'middle' : selectedAll}
150
+ // label={`${selected.size}`}
151
+ setValue={e => {
152
+ selectedAll
153
+ ? setSelected(new Set())
154
+ : setSelected(oldValue => {
155
+ let newSet = new Set(oldValue);
156
+ selectableData.forEach(e => newSet.add(e.uuid!));
157
+ return newSet;
158
+ });
159
+ }}
160
+ />
161
+ ),
162
+ width: '50px',
163
+ };
164
+ }
165
+
166
+ let newCols: ITableColumn[] = [];
167
+
168
+ selectCol && newCols.push(selectCol);
169
+ newCols = newCols.concat(activeColumns);
170
+
171
+ setCols(newCols);
172
+ }, [columns, editable, selected, activeSelectOptions, serverSidePagination]);
173
+
174
+ useEffect(() => {
175
+ // const data = editable
176
+ // ? tableData.map((e) => ({
177
+ // ...e,
178
+ // cells: {
179
+ // ...e.cells,
180
+ // actions: {
181
+ // value: (
182
+ // <ItemActionsMenu
183
+ // item={e}
184
+ // setSelectedItem={editable!.setSelectedItem}
185
+ // />
186
+ // ),
187
+ // },
188
+ // },
189
+ // }))
190
+ // : tableData;
191
+ const data =
192
+ serverSidePagination || limit <= 0
193
+ ? tableData
194
+ : tableData.slice(offset * limit, offset * limit + limit);
195
+
196
+ activeSelectOptions.length &&
197
+ data.map(
198
+ e =>
199
+ (e.cells.select = {
200
+ value: (
201
+ <Checkbox
202
+ value={selected.has(e.uuid!)}
203
+ setValue={checked => {
204
+ setSelected(oldSet => {
205
+ const newSet = new Set(oldSet);
206
+ checked ? newSet.add(e.uuid!) : newSet.delete(e.uuid!);
207
+ return newSet;
208
+ });
209
+ }}
210
+ disabled={e.disableSelect}
211
+ />
212
+ ),
213
+ unclickable: true,
214
+ })
215
+ );
216
+ setData(data);
217
+ }, [tableData, limit, offset, selected, activeSelectOptions, serverSidePagination]);
218
+
219
+ const EditableRow = editable?.EditableRow;
220
+
221
+ return (
222
+ <Loader isLoading={!!isLoading}>
223
+ <div className={clsx('iui-table', className, { 'pb-3': data.length === 0 })}>
224
+ <div className="flex column gap-2">
225
+ {(!!filterData ||
226
+ !!sortData ||
227
+ !!setColumns ||
228
+ !!printData ||
229
+ !!customPrintData) && (
230
+ <TableOptions
231
+ columns={cols}
232
+ columnsData={
233
+ setColumns
234
+ ? { columns, setColumns, withSearch: withColumnsSearch }
235
+ : undefined
236
+ }
237
+ filterData={filterData}
238
+ sortData={sortData}
239
+ printData={printData}
240
+ customPrintData={customPrintData}
241
+ templates={templates}
242
+ additionsalOptions={additionsalOptions}
243
+ />
244
+ )}
245
+ {/* ////// SELECT ////// */}
246
+ {!!activeSelectOptions?.length && (
247
+ <div className="flex gap-2 align-center pl-3">
248
+ <p className="fs-12">{`${t('Selected')}: ${selected.size}`}</p>
249
+ <Menu
250
+ isOpen={selectedActionOpen}
251
+ onClose={() => setSelectedActionOpen(false)}
252
+ placementX="left"
253
+ renderButton={ref => (
254
+ <Button
255
+ ref={ref}
256
+ label={t('Actions')}
257
+ icon={faEllipsisVertical}
258
+ active={selectedActionOpen}
259
+ disabled={!selected.size}
260
+ onClick={() => setSelectedActionOpen(!selectedActionOpen)}
261
+ size="s"
262
+ />
263
+ )}
264
+ >
265
+ {activeSelectOptions?.map(action => (
266
+ <MenuItem
267
+ key={action.label}
268
+ label={action.label}
269
+ disabled={action.disabled}
270
+ onClick={() => {
271
+ action.onClick!(selected);
272
+ setSelectedActionOpen(false);
273
+ action.clearSelected && setSelected(new Set<string>());
274
+ }}
275
+ />
276
+ ))}
277
+ </Menu>
278
+ </div>
279
+ )}
280
+ </div>
281
+ <div
282
+ className="table-container"
283
+ // style={{ maxHeight }}
284
+ >
285
+ <ConditionalWrapper
286
+ condition={!!editable}
287
+ wrapper={children => (
288
+ <form
289
+ onSubmit={e => {
290
+ e.preventDefault();
291
+ e.stopPropagation();
292
+ editable!.onSubmit(editableData, () => {
293
+ !editable?.keepEditOnSubmit &&
294
+ editable!.inputFocusRef?.current?.focus();
295
+ if (!editable?.selectedItem || !editable?.keepEditOnSubmit) {
296
+ setEditableData(editable!.defaultDataValue ?? {});
297
+ editable?.setSelectedItem && editable.setSelectedItem(null);
298
+ }
299
+ });
300
+ }}
301
+ >
302
+ {children}
303
+ </form>
304
+ )}
305
+ >
306
+ {/* <table className="full-width">
307
+ <HeaderTable
308
+ columns={cols}
309
+ headerWrap={headerWrap}
310
+ customHeader={customHeader}
311
+ sticky={!!maxHeight}
312
+ />
313
+ <tbody
314
+ className={hideFooter && !showLastBorder ? 'no-last-border' : undefined}
315
+ >
316
+ {data.length ? (
317
+ <>
318
+ {data.map(row => {
319
+ const isExtended =
320
+ row.extendable &&
321
+ !row.extendable.isLoading &&
322
+ extendedRow === row.uuid;
323
+ return (
324
+ <Fragment key={row.uuid}> */}
325
+ {/* ////// EDITABLE ROW ////// */}
326
+ {/* {!!EditableRow &&
327
+ row.uuid === editable?.selectedItem?.uuid &&
328
+ editable.setSelectedItem ? (
329
+ <EditableRow
330
+ columns={cols}
331
+ data={editableData}
332
+ setData={setEditableData}
333
+ item={editable.selectedItem}
334
+ clearItem={() => editable.setSelectedItem!(null)}
335
+ defaultDataValue={editable.defaultDataValue}
336
+ inputFocusRef={editable.inputFocusRef}
337
+ />
338
+ ) : (
339
+ ////// REGULAR ROW //////
340
+ <tr
341
+ data-id={row.uuid}
342
+ className={clsx(row.className, {
343
+ selected:
344
+ !!selectedRowUuid && selectedRowUuid === row.uuid,
345
+ clickable: !!row.onRowClick || !!row.extendable,
346
+ focused: !!focusedRow && focusedRow.uuid === row.uuid,
347
+ loading: row.extendable?.isLoading,
348
+ })}
349
+ onClick={e => {
350
+ row.onRowClick && row.onRowClick(e);
351
+ row.extendable &&
352
+ setExtendedRow(
353
+ extendedRow === row.uuid ? '' : row.uuid
354
+ );
355
+ }}
356
+ >
357
+ {cols.map(column => {
358
+ const cell = row.cells[column.id];
359
+ return (
360
+ <Tooltip
361
+ key={column.id}
362
+ label={cell?.tooltip!}
363
+ position="top"
364
+ disabled={!cell?.tooltip}
365
+ >
366
+ <td
367
+ data-th={
368
+ column.id === 'select'
369
+ ? t('Selected') + ':'
370
+ : column.label
371
+ ? column.label + ': '
372
+ : '/'
373
+ }
374
+ align={cell?.align || column.align}
375
+ onClick={
376
+ cell?.onClick || cell?.unclickable
377
+ ? e => {
378
+ e.stopPropagation();
379
+ cell?.onClick && cell?.onClick!(e);
380
+ }
381
+ : undefined
382
+ }
383
+ className={clsx(column.color, cell?.className, {
384
+ link: cell?.link,
385
+ 'p-0': !cell?.value && cell?.value !== 0,
386
+ 'clickable-column': cell?.onClick,
387
+ 'word-break': column.break,
388
+ 'no-border': isExtended,
389
+ })}
390
+ colSpan={cell?.span}
391
+ >
392
+ {cell?.value}
393
+ </td>
394
+ </Tooltip>
395
+ );
396
+ })}
397
+ </tr>
398
+ )} */}
399
+ {/* ////// EXTENDABLE ROW ////// */}
400
+ {/* {isExtended && (
401
+ <tr>
402
+ <td colSpan={cols.length}>{row.extendable!.element}</td>
403
+ </tr>
404
+ )}
405
+ </Fragment>
406
+ );
407
+ })}
408
+ </>
409
+ ) : (
410
+ <tr>
411
+ <td className="no-border" colSpan={cols.length}>
412
+ {t('NoResults')}
413
+ </td>
414
+ </tr>
415
+ )}
416
+ {!!EditableRow &&
417
+ !editable.selectedItem &&
418
+ !editable.addDisabled &&
419
+ // TO DO -> Remove keyboard condition to enable this for every table
420
+ (keyboard?.enabled && !isAdding ? (
421
+ ////// NEW ITEM ROW //////
422
+ <tr
423
+ data-id="add"
424
+ className={`clickable${
425
+ focusedRow?.uuid === 'add' ? ' focused' : ''
426
+ }`}
427
+ onClick={() => setIsAdding(true)}
428
+ >
429
+ <td className="text-center" colSpan={cols.length}>
430
+ <FontAwesomeIcon icon={faPlus} className="c-primary icon24" />
431
+ </td>
432
+ </tr>
433
+ ) : (
434
+ <EditableRow
435
+ columns={cols}
436
+ data={editableData}
437
+ setData={setEditableData}
438
+ defaultDataValue={editable.defaultDataValue}
439
+ clearItem={() => {
440
+ editable.setSelectedItem?.(null);
441
+ isAdding && setIsAdding(false);
442
+ }}
443
+ inputFocusRef={editable.inputFocusRef}
444
+ />
445
+ ))}
446
+ {!!totals && !!data.length && (
447
+ <tr>
448
+ {cols.map(({ id: columnId }) => (
449
+ <td
450
+ key={columnId}
451
+ align={totals.cells[columnId]?.align || 'right'}
452
+ colSpan={totals.cells[columnId]?.span}
453
+ >
454
+ <strong>{totals.cells[columnId]?.value}</strong>
455
+ </td>
456
+ ))}
457
+ </tr>
458
+ )}
459
+ </tbody>
460
+ </table> */}
461
+
462
+ <div className="grid-table">
463
+ <HeaderTable
464
+ columns={cols}
465
+ headerWrap={headerWrap}
466
+ customHeader={customHeader}
467
+ // sticky={!!maxHeight}
468
+ />
469
+ <div>
470
+ <tbody
471
+ className={clsx({
472
+ 'no-last-border': hideFooter && !showLastBorder,
473
+ })}
474
+ style={{ maxHeight }}
475
+ >
476
+ {data.length ? (
477
+ <>
478
+ {data.map(row => {
479
+ const isExtended =
480
+ row.extendable &&
481
+ !row.extendable.isLoading &&
482
+ extendedRow === row.uuid;
483
+ return (
484
+ <Fragment key={row.uuid}>
485
+ {/* ////// EDITABLE ROW ////// */}
486
+ {!!EditableRow &&
487
+ row.uuid === editable?.selectedItem?.uuid &&
488
+ editable.setSelectedItem ? (
489
+ <EditableRow
490
+ columns={cols}
491
+ data={editableData}
492
+ setData={setEditableData}
493
+ item={editable.selectedItem}
494
+ clearItem={() => editable.setSelectedItem!(null)}
495
+ defaultDataValue={editable.defaultDataValue}
496
+ inputFocusRef={editable.inputFocusRef}
497
+ />
498
+ ) : (
499
+ ////// REGULAR ROW //////
500
+ <tr
501
+ data-id={row.uuid}
502
+ className={clsx('row', row.className, {
503
+ selected:
504
+ !!selectedRowUuid && selectedRowUuid === row.uuid,
505
+ clickable: !!row.onRowClick || !!row.extendable,
506
+ focused: !!focusedRow && focusedRow.uuid === row.uuid,
507
+ loading: row.extendable?.isLoading,
508
+ })}
509
+ onClick={e => {
510
+ row.onRowClick && row.onRowClick(e);
511
+ row.extendable &&
512
+ setExtendedRow(
513
+ extendedRow === row.uuid ? '' : row.uuid
514
+ );
515
+ }}
516
+ >
517
+ {cols.map(column => {
518
+ const cell = row.cells[column.id];
519
+ return (
520
+ <Tooltip
521
+ key={column.id}
522
+ label={cell?.tooltip!}
523
+ position="top"
524
+ disabled={!cell?.tooltip}
525
+ >
526
+ <td
527
+ data-th={
528
+ column.id === 'select'
529
+ ? t('Selected') + ':'
530
+ : column.label
531
+ ? column.label + ': '
532
+ : '/'
533
+ }
534
+ style={
535
+ column.minWidth
536
+ ? { minWidth: column.minWidth }
537
+ : column.width
538
+ ? { width: column.width }
539
+ : undefined
540
+ }
541
+ align={cell?.align || column.align}
542
+ onClick={
543
+ cell?.onClick || cell?.unclickable
544
+ ? e => {
545
+ e.stopPropagation();
546
+ cell?.onClick && cell?.onClick!(e);
547
+ }
548
+ : undefined
549
+ }
550
+ className={clsx(column.color, cell?.className, {
551
+ link: cell?.link,
552
+ 'p-0': !cell?.value && cell?.value !== 0,
553
+ 'clickable-column': cell?.onClick,
554
+ 'word-break': column.break,
555
+ 'no-border': isExtended,
556
+ })}
557
+ colSpan={cell?.span}
558
+ >
559
+ {cell?.value}
560
+ </td>
561
+ </Tooltip>
562
+ );
563
+ })}
564
+ </tr>
565
+ )}
566
+ {/* ////// EXTENDABLE ROW ////// */}
567
+ {isExtended && (
568
+ <tr>
569
+ <td colSpan={cols.length}>{row.extendable!.element}</td>
570
+ </tr>
571
+ )}
572
+ </Fragment>
573
+ );
574
+ })}
575
+ </>
576
+ ) : (
577
+ <tr>
578
+ <td className="no-border" colSpan={cols.length}>
579
+ {t('NoResults')}
580
+ </td>
581
+ </tr>
582
+ )}
583
+ {!!EditableRow &&
584
+ !editable.selectedItem &&
585
+ !editable.addDisabled &&
586
+ // TO DO -> Remove keyboard condition to enable this for every table
587
+ (keyboard?.enabled && !isAdding ? (
588
+ ////// NEW ITEM ROW //////
589
+ <tr
590
+ data-id="add"
591
+ className={`clickable${
592
+ focusedRow?.uuid === 'add' ? ' focused' : ''
593
+ }`}
594
+ onClick={() => setIsAdding(true)}
595
+ >
596
+ {/* <td
597
+ className="justify-center"
598
+ // colSpan={cols.length}
599
+ style={{
600
+ gridColumn: `span ${cols.length}`,
601
+ }}
602
+ >
603
+ <FontAwesomeIcon icon={faPlus} className="c-primary icon24" />
604
+ </td> */}
605
+ </tr>
606
+ ) : (
607
+ <EditableRow
608
+ columns={cols}
609
+ data={editableData}
610
+ setData={setEditableData}
611
+ defaultDataValue={editable.defaultDataValue}
612
+ clearItem={() => {
613
+ editable.setSelectedItem?.(null);
614
+ isAdding && setIsAdding(false);
615
+ }}
616
+ inputFocusRef={editable.inputFocusRef}
617
+ />
618
+ ))}
619
+ {!!totals && !!data.length && (
620
+ <tr>
621
+ {cols.map(({ id: columnId, ...column }) => (
622
+ <td
623
+ key={columnId}
624
+ align={totals.cells[columnId]?.align || 'right'}
625
+ colSpan={totals.cells[columnId]?.span}
626
+ style={{
627
+ minWidth: column.minWidth,
628
+ width: column.width,
629
+ gridColumn: totals.cells[columnId]?.span
630
+ ? `span ${totals.cells[columnId].span}`
631
+ : undefined,
632
+ }}
633
+ >
634
+ <strong>{totals.cells[columnId]?.value}</strong>
635
+ </td>
636
+ ))}
637
+ </tr>
638
+ )}
639
+ </tbody>
640
+ </div>
641
+ </div>
642
+ </ConditionalWrapper>
643
+ </div>
644
+ {!hideFooter &&
645
+ (!!data.length ||
646
+ (noTotalRows && (serverSidePagination?.offset || offset) > 0)) && (
647
+ <TableFooter
648
+ customLimit={customPagination?.customLimit}
649
+ pagination={pagination}
650
+ footerAction={footerAction}
651
+ noTotalRows={noTotalRows}
652
+ />
653
+ )}
654
+ </div>
655
+ </Loader>
656
+ );
657
+ };