@inceptionbg/iui 2.0.23 → 2.0.24

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 (232) hide show
  1. package/dist/NoAccessPage-CJisyKrk.js +2 -0
  2. package/dist/{NoAccessPage-BmizYfw0.js.map → NoAccessPage-CJisyKrk.js.map} +1 -1
  3. package/dist/NotFoundPage-BeRit0kr.js +2 -0
  4. package/dist/{NotFoundPage-Cv544vAr.js.map → NotFoundPage-BeRit0kr.js.map} +1 -1
  5. package/dist/index.d.ts +432 -430
  6. package/dist/index.js +1 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/iui.css +1 -1
  9. package/idea/GridTable/GridTable.tsx +1 -1
  10. package/idea/Menu/Menu.tsx +5 -3
  11. package/idea/Menu/MenuItem.tsx +3 -2
  12. package/idea/Menu/hooks/useMenuControl.ts +1 -1
  13. package/idea/Menu.tsx +3 -2
  14. package/idea/NoAccessInfo.tsx +1 -1
  15. package/idea/Table/Components/Edit/ItemActionsMenu.tsx +2 -1
  16. package/idea/Table/Components/Edit/ItemEditOptionsButtons.tsx +1 -1
  17. package/idea/Table/Components/Edit/TableEditRow.tsx +3 -2
  18. package/idea/Table/Components/FilterItem.tsx +2 -2
  19. package/idea/Table/Components/Header/TableHeader.tsx +3 -2
  20. package/idea/Table/Components/Header/TableHeaderRow.tsx +2 -2
  21. package/idea/Table/Components/Print/CustomTablePrint.tsx +3 -2
  22. package/idea/Table/Components/SetSortList.tsx +2 -2
  23. package/idea/Table/Components/SetTableFilter.tsx +3 -2
  24. package/idea/Table/Components/TableFooter.tsx +6 -4
  25. package/idea/Table/Components/TableOptions.tsx +3 -2
  26. package/idea/Table/Table.tsx +3 -2
  27. package/idea/Table/hooks/useTableKeyboard.ts +2 -2
  28. package/package.json +1 -1
  29. package/src/assets/icons/duotone/faBell.ts +17 -17
  30. package/src/assets/icons/duotone/faCircleUser.ts +17 -17
  31. package/src/assets/icons/index.ts +25 -25
  32. package/src/assets/icons/light/faArrowDownShortWide.ts +15 -15
  33. package/src/assets/icons/light/faArrowDownWideShort.ts +15 -15
  34. package/src/assets/icons/light/faArrowLeft.ts +5 -5
  35. package/src/assets/icons/light/faArrowRight.ts +5 -5
  36. package/src/assets/icons/light/faArrowUpArrowDown.ts +15 -15
  37. package/src/assets/icons/light/faArrowUpRightFromSquare.ts +15 -15
  38. package/src/assets/icons/light/faArrowsToLine.ts +15 -15
  39. package/src/assets/icons/light/faArrowsUpDown.ts +15 -15
  40. package/src/assets/icons/light/faBell.ts +15 -15
  41. package/src/assets/icons/light/faBookmark.ts +15 -15
  42. package/src/assets/icons/light/faBookmarkSlash.ts +15 -15
  43. package/src/assets/icons/light/faCalendarPlus.ts +15 -15
  44. package/src/assets/icons/light/faCheck.ts +15 -15
  45. package/src/assets/icons/light/faChevronDown.ts +15 -15
  46. package/src/assets/icons/light/faChevronRight.ts +15 -15
  47. package/src/assets/icons/light/faCircleInfo.ts +15 -15
  48. package/src/assets/icons/light/faCircleXmark.ts +15 -15
  49. package/src/assets/icons/light/faClipboardCheck.ts +15 -15
  50. package/src/assets/icons/light/faClockRotateLeft.ts +15 -15
  51. package/src/assets/icons/light/faEllipsisVertical.ts +15 -15
  52. package/src/assets/icons/light/faEnvelope.ts +15 -15
  53. package/src/assets/icons/light/faEye.ts +15 -15
  54. package/src/assets/icons/light/faEyeSlash.ts +15 -15
  55. package/src/assets/icons/light/faFilter.ts +15 -15
  56. package/src/assets/icons/light/faGear.ts +15 -15
  57. package/src/assets/icons/light/faHouse.ts +15 -15
  58. package/src/assets/icons/light/faIdBadge.ts +15 -15
  59. package/src/assets/icons/light/faLineColumns.ts +15 -15
  60. package/src/assets/icons/light/faLink.ts +15 -15
  61. package/src/assets/icons/light/faMagnifyingGlass.ts +15 -15
  62. package/src/assets/icons/light/faPen.ts +15 -15
  63. package/src/assets/icons/light/faPrint.ts +15 -15
  64. package/src/assets/icons/light/faQuestion.ts +15 -15
  65. package/src/assets/icons/light/faRotateRight.ts +15 -15
  66. package/src/assets/icons/light/faTrashCan.ts +15 -15
  67. package/src/assets/icons/light/faTriangleExclamation.ts +15 -15
  68. package/src/assets/icons/light/faXmark.ts +15 -15
  69. package/src/assets/icons/regular/faArrowLeft.ts +15 -15
  70. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +15 -15
  71. package/src/assets/icons/regular/faCircleCheck.ts +15 -15
  72. package/src/assets/icons/regular/faCircleExclamation.ts +15 -15
  73. package/src/assets/icons/regular/faCircleInfo.ts +15 -15
  74. package/src/assets/icons/regular/faFileArrowDown.ts +15 -15
  75. package/src/assets/icons/regular/faFilterCircleXmark.ts +15 -15
  76. package/src/assets/icons/regular/faTriangleExclamation.ts +15 -15
  77. package/src/assets/icons/solid/faAngleLeft.ts +15 -15
  78. package/src/assets/icons/solid/faAngleRight.ts +15 -15
  79. package/src/assets/icons/solid/faArrowDownWideShort.ts +15 -15
  80. package/src/assets/icons/solid/faCaretDown.ts +15 -15
  81. package/src/assets/icons/solid/faCheck.ts +15 -15
  82. package/src/assets/icons/solid/faEllipsisVertical.ts +15 -15
  83. package/src/assets/icons/solid/faEnvelopeDot.ts +15 -15
  84. package/src/assets/icons/solid/faFilter.ts +15 -15
  85. package/src/assets/icons/solid/faFloppyDisk.ts +15 -15
  86. package/src/assets/icons/solid/faGripDotsVertical.ts +15 -15
  87. package/src/assets/icons/solid/faListUl.ts +15 -15
  88. package/src/assets/icons/solid/faMinus.ts +15 -15
  89. package/src/assets/icons/solid/faPlus.ts +15 -15
  90. package/src/assets/icons/solid/faPrint.ts +15 -15
  91. package/src/assets/icons/solid/faRotateRight.ts +15 -15
  92. package/src/assets/icons/solid/faXmark.ts +15 -15
  93. package/src/components/Accordions/Accordions.tsx +75 -74
  94. package/src/components/Alert/Alert.tsx +31 -31
  95. package/src/components/Badge/DotBadge.tsx +16 -16
  96. package/src/components/Badge/NotificationBadge.tsx +29 -29
  97. package/src/components/Badge/PillBadge.tsx +13 -13
  98. package/src/components/Button/Button.tsx +56 -56
  99. package/src/components/Button/IconButton.tsx +51 -51
  100. package/src/components/Button/SplitButton.tsx +91 -91
  101. package/src/components/Dashboard/Dashboard.tsx +9 -9
  102. package/src/components/Dashboard/DashboardWidget.tsx +44 -44
  103. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +37 -37
  104. package/src/components/Dialog/Dialog.tsx +166 -164
  105. package/src/components/Dialog/components/DialogFooter.tsx +100 -98
  106. package/src/components/Header/Components/EnvBadge.tsx +17 -17
  107. package/src/components/Header/Components/ModuleSelect.tsx +68 -68
  108. package/src/components/Header/Components/Notifications.tsx +202 -208
  109. package/src/components/Header/Components/UserMenu.tsx +52 -52
  110. package/src/components/Header/Header.tsx +37 -36
  111. package/src/components/Helper/Collapse.tsx +53 -52
  112. package/src/components/Inputs/Checkbox.tsx +53 -53
  113. package/src/components/Inputs/CurrencyInput.tsx +124 -123
  114. package/src/components/Inputs/DateInput/DateInput.tsx +184 -183
  115. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +159 -158
  116. package/src/components/Inputs/InputWrapper.tsx +95 -95
  117. package/src/components/Inputs/NumberInput.tsx +86 -86
  118. package/src/components/Inputs/PasswordInput.tsx +40 -39
  119. package/src/components/Inputs/PhoneInput/PhoneInput.tsx +108 -108
  120. package/src/components/Inputs/PhoneInput/utils/countryCode.ts +20 -20
  121. package/src/components/Inputs/Radio.tsx +59 -59
  122. package/src/components/Inputs/RadioGroup.tsx +48 -48
  123. package/src/components/Inputs/RadioLarge.tsx +39 -39
  124. package/src/components/Inputs/SearchInput.tsx +46 -45
  125. package/src/components/Inputs/Selects/Select.tsx +17 -17
  126. package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +20 -19
  127. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +118 -118
  128. package/src/components/Inputs/Selects/utils/selectStyles.ts +101 -101
  129. package/src/components/Inputs/TextAreaInput.tsx +68 -67
  130. package/src/components/Inputs/TextInput.tsx +100 -99
  131. package/src/components/Inputs/TimeInput/TimeInput.tsx +81 -81
  132. package/src/components/List/List.tsx +21 -20
  133. package/src/components/List/ListItem.tsx +70 -69
  134. package/src/components/Loader/Loader.tsx +59 -53
  135. package/src/components/Loader/ProgressBar.tsx +41 -41
  136. package/src/components/Menu/Menu.tsx +81 -80
  137. package/src/components/Menu/MenuItem.tsx +46 -46
  138. package/src/components/Menu/NewMenu.tsx +63 -63
  139. package/src/components/Menu/hooks/useMenuPosition.tsx +116 -115
  140. package/src/components/Pullover/Pullover.tsx +197 -196
  141. package/src/components/Router/Router.tsx +52 -51
  142. package/src/components/Sidebar/AddButton.tsx +22 -22
  143. package/src/components/Sidebar/Sidebar.tsx +85 -83
  144. package/src/components/Sidebar/SidebarItem.tsx +84 -84
  145. package/src/components/Sidebar/types/ISidebar.ts +28 -28
  146. package/src/components/Table/Table.tsx +259 -258
  147. package/src/components/Table/components/columns/ColumnsList.tsx +60 -59
  148. package/src/components/Table/components/columns/TableColumnsEdit.tsx +114 -112
  149. package/src/components/Table/components/edit/TableEditRow.tsx +78 -77
  150. package/src/components/Table/components/filters/FilterItem.tsx +15 -15
  151. package/src/components/Table/components/filters/TableFilters.tsx +126 -125
  152. package/src/components/Table/components/footer/TableFooter.tsx +126 -124
  153. package/src/components/Table/components/header/TableHeader.tsx +40 -40
  154. package/src/components/Table/components/header/TableHeaderRow.tsx +57 -57
  155. package/src/components/Table/components/items/TableItemActions.tsx +78 -78
  156. package/src/components/Table/components/print/TablePrint.tsx +200 -199
  157. package/src/components/Table/components/select/TableSelect.tsx +50 -49
  158. package/src/components/Table/components/sort/TableSort.tsx +73 -72
  159. package/src/components/Table/components/templates/CreateTemplateDialog.tsx +58 -57
  160. package/src/components/Table/components/templates/TableTemplates.tsx +65 -64
  161. package/src/components/Table/components/templates/TemplatesPullover.tsx +88 -88
  162. package/src/components/Table/contexts/TableContext.tsx +116 -123
  163. package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +70 -70
  164. package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +84 -84
  165. package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +176 -177
  166. package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +12 -12
  167. package/src/components/Table/hooks/useTableColumns.ts +34 -34
  168. package/src/components/Table/hooks/useTableEdit.tsx +140 -140
  169. package/src/components/Table/hooks/useTableFilterFields.tsx +150 -150
  170. package/src/components/Table/hooks/useTablePagination.ts +19 -19
  171. package/src/components/Table/hooks/useTablePrint.ts +83 -83
  172. package/src/components/Table/hooks/useTableSearch.ts +31 -30
  173. package/src/components/Table/hooks/useTableSelect.ts +19 -19
  174. package/src/components/Table/hooks/useTableSort.ts +8 -8
  175. package/src/components/Tabs/Tabs.tsx +68 -67
  176. package/src/components/Tooltip/Tooltip.tsx +191 -200
  177. package/src/components/Tree/Tree.tsx +22 -22
  178. package/src/components/Tree/TreeItem.tsx +57 -56
  179. package/src/components/Wrappers/AppLayout.tsx +17 -17
  180. package/src/components/Wrappers/ConditionalWrapper.tsx +10 -10
  181. package/src/components/Wrappers/FormWrapper.tsx +84 -83
  182. package/src/components/Wrappers/PageLayout.tsx +156 -155
  183. package/src/hooks/useBackgroundClose.ts +19 -18
  184. package/src/hooks/useGetFocusableElements.ts +43 -42
  185. package/src/hooks/useIsMenuOpen.ts +11 -11
  186. package/src/hooks/useLocalPopoverControl.ts +32 -32
  187. package/src/hooks/useOnEsc.ts +14 -14
  188. package/src/hooks/usePopupControl.ts +22 -22
  189. package/src/hooks/useZendesk.ts +21 -21
  190. package/src/index.ts +379 -386
  191. package/src/pages/NoAccessPage.tsx +27 -27
  192. package/src/pages/NotFoundPage.tsx +26 -26
  193. package/src/styles/common/helpers/_size.scss +0 -3
  194. package/src/styles/components/_accordions.scss +1 -1
  195. package/src/styles/components/_buttonSplit.scss +4 -29
  196. package/src/types/IBasic.ts +32 -31
  197. package/src/types/ICountryCode.ts +5 -0
  198. package/src/types/IError.ts +5 -5
  199. package/src/types/IHeader.ts +40 -40
  200. package/src/types/IInfo.ts +1 -1
  201. package/src/types/IKeyboard.ts +33 -33
  202. package/src/types/IMenu.ts +19 -19
  203. package/src/types/INotifications.ts +15 -15
  204. package/src/types/IPopup.ts +17 -17
  205. package/src/types/IRouter.ts +6 -6
  206. package/src/types/ISelect.ts +54 -54
  207. package/src/types/ITab.ts +1 -1
  208. package/src/types/ITable.ts +290 -281
  209. package/src/types/ITree.ts +6 -6
  210. package/src/utils/InputPatternValidation.ts +12 -12
  211. package/src/utils/dateUtils.ts +32 -32
  212. package/src/utils/fileUtils.ts +177 -177
  213. package/src/utils/i18n/i18nIUICyrilic.ts +119 -119
  214. package/src/utils/i18n/i18nIUILatin.ts +120 -120
  215. package/src/utils/i18n/i18nIUIMe.ts +118 -118
  216. package/src/utils/icons.ts +13 -13
  217. package/src/utils/localStorageHelper.ts +24 -24
  218. package/src/utils/logoUtils.ts +7 -7
  219. package/src/utils/numberUtils.ts +21 -21
  220. package/src/utils/objectUtils.ts +114 -114
  221. package/src/utils/popupUtils.ts +82 -82
  222. package/src/utils/rootDir.ts +1 -1
  223. package/src/utils/stringUtils.ts +18 -18
  224. package/src/utils/tableUtils.ts +130 -130
  225. package/src/utils/toasts.ts +6 -6
  226. package/src/utils/urlUtils.ts +4 -4
  227. package/tsconfig.json +1 -0
  228. package/dist/NoAccessPage-BmizYfw0.js +0 -2
  229. package/dist/NotFoundPage-Cv544vAr.js +0 -2
  230. package/src/components/Dialog/hooks/useDialogKeyboard.ts +0 -42
  231. package/src/components/Inputs/Select2/Select.tsx +0 -258
  232. package/src/components/Inputs/Select2/select.scss +0 -42
@@ -1,59 +1,60 @@
1
- import { useEffect, useState, type FC } from 'react';
2
- import { Draggable, Droppable } from '@hello-pangea/dnd';
3
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { ITableColumn } from '../../../../types/ITable';
5
- import { faGripDotsVertical } from '../../../../assets/icons/solid/faGripDotsVertical';
6
-
7
- interface Props {
8
- id: 'hidden' | 'visible';
9
- items: ITableColumn[];
10
- search: string;
11
- }
12
-
13
- export const ColumnsList: FC<Props> = ({ id, items, search }) => {
14
- const [filteredItems, setFilteredItems] = useState<ITableColumn[]>([]);
15
-
16
- useEffect(() => {
17
- if (search.length) {
18
- setFilteredItems(
19
- items.filter(e =>
20
- (typeof e.label === 'string' ? e.label : (e.labelForFilter ?? ''))
21
- .toLocaleLowerCase()
22
- .includes(search.toLocaleLowerCase())
23
- )
24
- );
25
- }
26
- }, [search, items]);
27
-
28
- const list = search.length ? filteredItems : items;
29
-
30
- return (
31
- <Droppable droppableId={id}>
32
- {({ droppableProps, innerRef, placeholder }) => (
33
- <div {...droppableProps} ref={innerRef} className="list-box">
34
- {list.map(c => (
35
- <Draggable key={c.id} draggableId={c.id} index={items.indexOf(c)}>
36
- {({ innerRef, draggableProps, dragHandleProps }, snapshot) => (
37
- <div
38
- className={`item ${snapshot.isDragging ? 'dragging' : ''}`}
39
- ref={innerRef}
40
- {...draggableProps}
41
- {...dragHandleProps}
42
- style={{
43
- ...draggableProps.style,
44
- top: 'unset',
45
- left: 'unset',
46
- }}
47
- >
48
- {c.label}
49
- <FontAwesomeIcon icon={faGripDotsVertical} />
50
- </div>
51
- )}
52
- </Draggable>
53
- ))}
54
- {placeholder}
55
- </div>
56
- )}
57
- </Droppable>
58
- );
59
- };
1
+ import type { FC } from 'react';
2
+ import type { ITableColumn } from '../../../../types/ITable';
3
+ import { useEffect, useState } from 'react';
4
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
+ import { Draggable, Droppable } from '@hello-pangea/dnd';
6
+ import { faGripDotsVertical } from '../../../../assets/icons/solid/faGripDotsVertical';
7
+
8
+ interface Props {
9
+ id: 'hidden' | 'visible';
10
+ items: ITableColumn[];
11
+ search: string;
12
+ }
13
+
14
+ export const ColumnsList: FC<Props> = ({ id, items, search }) => {
15
+ const [filteredItems, setFilteredItems] = useState<ITableColumn[]>([]);
16
+
17
+ useEffect(() => {
18
+ if (search.length) {
19
+ setFilteredItems(
20
+ items.filter(e =>
21
+ (typeof e.label === 'string' ? e.label : (e.labelForFilter ?? ''))
22
+ .toLocaleLowerCase()
23
+ .includes(search.toLocaleLowerCase())
24
+ )
25
+ );
26
+ }
27
+ }, [search, items]);
28
+
29
+ const list = search.length ? filteredItems : items;
30
+
31
+ return (
32
+ <Droppable droppableId={id}>
33
+ {({ droppableProps, innerRef, placeholder }) => (
34
+ <div {...droppableProps} ref={innerRef} className="list-box">
35
+ {list.map(c => (
36
+ <Draggable key={c.id} draggableId={c.id} index={items.indexOf(c)}>
37
+ {({ innerRef, draggableProps, dragHandleProps }, snapshot) => (
38
+ <div
39
+ className={`item ${snapshot.isDragging ? 'dragging' : ''}`}
40
+ ref={innerRef}
41
+ {...draggableProps}
42
+ {...dragHandleProps}
43
+ style={{
44
+ ...draggableProps.style,
45
+ top: 'unset',
46
+ left: 'unset',
47
+ }}
48
+ >
49
+ {c.label}
50
+ <FontAwesomeIcon icon={faGripDotsVertical} />
51
+ </div>
52
+ )}
53
+ </Draggable>
54
+ ))}
55
+ {placeholder}
56
+ </div>
57
+ )}
58
+ </Droppable>
59
+ );
60
+ };
@@ -1,112 +1,114 @@
1
- import { FC, useEffect, useState } from 'react';
2
- import { DragDropContext, DropResult } from '@hello-pangea/dnd';
3
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
- import { ITableColumn } from '../../../../types/ITable';
5
- import { faArrowRightArrowLeft } from '../../../../assets/icons/regular/faArrowRightArrowLeft';
6
- import { useTranslation } from 'react-i18next';
7
- import { ColumnsList } from './ColumnsList';
8
- import { SearchInput } from '../../../Inputs/SearchInput';
9
- import { Pullover } from '../../../Pullover/Pullover';
10
- import { useTableContext } from '../../contexts/TableContext';
11
- import { usePopupControl } from '../../../../hooks/usePopupControl';
12
- import { IconButton } from '../../../Button/IconButton';
13
- import { faLineColumns } from '../../../../assets/icons/light/faLineColumns';
14
-
15
- export const TableColumnsEdit: FC = () => {
16
- const [hidden, setHidden] = useState<ITableColumn[]>([]);
17
- const [visible, setVisible] = useState<ITableColumn[]>([]);
18
- const [searchHidden, setSearchHidden] = useState('');
19
- const [searchVisible, setSearchVisible] = useState('');
20
-
21
- const { t } = useTranslation();
22
- const {
23
- columnData: { columns, setColumns },
24
- } = useTableContext();
25
- const { control, onClose, onOpen } = usePopupControl();
26
-
27
- useEffect(() => {
28
- if (control.isOpen) {
29
- let hiddenCols: ITableColumn[] = [];
30
- let visibleCols: ITableColumn[] = [];
31
- columns.forEach(col =>
32
- !!col.hidden ? hiddenCols.push(col) : visibleCols.push(col)
33
- );
34
- setHidden(hiddenCols);
35
- setVisible(visibleCols);
36
- }
37
- }, [control.isOpen, columns]);
38
-
39
- const onDragEnd = ({ source, destination }: DropResult) => {
40
- if (!destination) return;
41
- const hiddenCols = [...hidden];
42
- const visibleCols = [...visible];
43
- const destinationIsHidden = destination.droppableId === 'hidden';
44
-
45
- const sourceList = source.droppableId === 'hidden' ? hiddenCols : visibleCols;
46
- const destinationList = destinationIsHidden ? hiddenCols : visibleCols;
47
-
48
- const [removed] = sourceList.splice(source.index, 1);
49
- destinationList.splice(destination.index, 0, removed);
50
- if (source.droppableId !== destination.droppableId) {
51
- destinationList[destination.index].hidden = destinationIsHidden;
52
- setHidden(hiddenCols);
53
- setVisible(visibleCols);
54
- } else {
55
- destinationIsHidden ? setHidden(hiddenCols) : setVisible(visibleCols);
56
- }
57
- };
58
-
59
- const onSubmit = () => {
60
- if (setColumns) {
61
- const newColumns = [...visible, ...hidden];
62
- setColumns(newColumns);
63
- onClose();
64
- }
65
- };
66
-
67
- return (
68
- <>
69
- <IconButton
70
- tooltip={t('Columns')}
71
- icon={faLineColumns}
72
- active={control.isOpen}
73
- onClick={onOpen}
74
- size="s"
75
- variant="outlined"
76
- />
77
-
78
- <DragDropContext onDragEnd={onDragEnd}>
79
- <Pullover
80
- control={control}
81
- header={{ title: t('Columns') }}
82
- className="column-pullover"
83
- footer={{
84
- confirmButton: {
85
- label: t('Confirm'),
86
- onClick: onSubmit,
87
- },
88
- }}
89
- >
90
- <div className="dual-list-container">
91
- <p className="pb-3">{t('DragDropListsInfo')}</p>
92
- <div className="dual-list-content">
93
- <p className="bold ml-2">{t('HiddenColumns')}:</p>
94
- <div />
95
- <p className="bold ml-2">{t('SelectedColumns')}:</p>
96
-
97
- <SearchInput onSearch={setSearchHidden} />
98
- <div />
99
- <SearchInput onSearch={setSearchVisible} />
100
-
101
- <ColumnsList id="hidden" items={hidden} search={searchHidden} />
102
- <div className="exchange-icon">
103
- <FontAwesomeIcon icon={faArrowRightArrowLeft} />
104
- </div>
105
- <ColumnsList id="visible" items={visible} search={searchVisible} />
106
- </div>
107
- </div>
108
- </Pullover>
109
- </DragDropContext>
110
- </>
111
- );
112
- };
1
+ import type { DropResult } from '@hello-pangea/dnd';
2
+ import type { FC } from 'react';
3
+ import type { ITableColumn } from '../../../../types/ITable';
4
+ import { useEffect, useState } from 'react';
5
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
+ import { DragDropContext } from '@hello-pangea/dnd';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { faLineColumns } from '../../../../assets/icons/light/faLineColumns';
9
+ import { faArrowRightArrowLeft } from '../../../../assets/icons/regular/faArrowRightArrowLeft';
10
+ import { usePopupControl } from '../../../../hooks/usePopupControl';
11
+ import { IconButton } from '../../../Button/IconButton';
12
+ import { SearchInput } from '../../../Inputs/SearchInput';
13
+ import { Pullover } from '../../../Pullover/Pullover';
14
+ import { useTableContext } from '../../contexts/TableContext';
15
+ import { ColumnsList } from './ColumnsList';
16
+
17
+ export const TableColumnsEdit: FC = () => {
18
+ const [hidden, setHidden] = useState<ITableColumn[]>([]);
19
+ const [visible, setVisible] = useState<ITableColumn[]>([]);
20
+ const [searchHidden, setSearchHidden] = useState('');
21
+ const [searchVisible, setSearchVisible] = useState('');
22
+
23
+ const { t } = useTranslation();
24
+ const {
25
+ columnData: { columns, setColumns },
26
+ } = useTableContext();
27
+ const { control, onClose, onOpen } = usePopupControl();
28
+
29
+ useEffect(() => {
30
+ if (control.isOpen) {
31
+ let hiddenCols: ITableColumn[] = [];
32
+ let visibleCols: ITableColumn[] = [];
33
+ columns.forEach(col =>
34
+ !!col.hidden ? hiddenCols.push(col) : visibleCols.push(col)
35
+ );
36
+ setHidden(hiddenCols);
37
+ setVisible(visibleCols);
38
+ }
39
+ }, [control.isOpen, columns]);
40
+
41
+ const onDragEnd = ({ source, destination }: DropResult) => {
42
+ if (!destination) return;
43
+ const hiddenCols = [...hidden];
44
+ const visibleCols = [...visible];
45
+ const destinationIsHidden = destination.droppableId === 'hidden';
46
+
47
+ const sourceList = source.droppableId === 'hidden' ? hiddenCols : visibleCols;
48
+ const destinationList = destinationIsHidden ? hiddenCols : visibleCols;
49
+
50
+ const [removed] = sourceList.splice(source.index, 1);
51
+ destinationList.splice(destination.index, 0, removed);
52
+ if (source.droppableId !== destination.droppableId) {
53
+ destinationList[destination.index].hidden = destinationIsHidden;
54
+ setHidden(hiddenCols);
55
+ setVisible(visibleCols);
56
+ } else {
57
+ destinationIsHidden ? setHidden(hiddenCols) : setVisible(visibleCols);
58
+ }
59
+ };
60
+
61
+ const onSubmit = () => {
62
+ if (setColumns) {
63
+ const newColumns = [...visible, ...hidden];
64
+ setColumns(newColumns);
65
+ onClose();
66
+ }
67
+ };
68
+
69
+ return (
70
+ <>
71
+ <IconButton
72
+ tooltip={t('Columns')}
73
+ icon={faLineColumns}
74
+ active={control.isOpen}
75
+ onClick={onOpen}
76
+ size="s"
77
+ variant="outlined"
78
+ />
79
+
80
+ <DragDropContext onDragEnd={onDragEnd}>
81
+ <Pullover
82
+ control={control}
83
+ header={{ title: t('Columns') }}
84
+ className="column-pullover"
85
+ footer={{
86
+ confirmButton: {
87
+ label: t('Confirm'),
88
+ onClick: onSubmit,
89
+ },
90
+ }}
91
+ >
92
+ <div className="dual-list-container">
93
+ <p className="pb-3">{t('DragDropListsInfo')}</p>
94
+ <div className="dual-list-content">
95
+ <p className="bold ml-2">{t('HiddenColumns')}:</p>
96
+ <div />
97
+ <p className="bold ml-2">{t('SelectedColumns')}:</p>
98
+
99
+ <SearchInput onSearch={setSearchHidden} />
100
+ <div />
101
+ <SearchInput onSearch={setSearchVisible} />
102
+
103
+ <ColumnsList id="hidden" items={hidden} search={searchHidden} />
104
+ <div className="exchange-icon">
105
+ <FontAwesomeIcon icon={faArrowRightArrowLeft} />
106
+ </div>
107
+ <ColumnsList id="visible" items={visible} search={searchVisible} />
108
+ </div>
109
+ </div>
110
+ </Pullover>
111
+ </DragDropContext>
112
+ </>
113
+ );
114
+ };
@@ -1,77 +1,78 @@
1
- import { FC, useEffect, useRef } from 'react';
2
- import { ITableColumn, ITableDataItem } from '../../../../types/ITable';
3
- import { IconButton } from '../../../Button/IconButton';
4
- import { faCheck, faXmark } from '../../../../assets/icons';
5
- import { useTableContext } from '../../contexts/TableContext';
6
- import { useGetFocusableElements } from '../../../../hooks/useGetFocusableElements';
7
- import clsx from 'clsx';
8
-
9
- export const TableEditRow: FC<{ columns: ITableColumn[] }> = ({ columns }) => {
10
- const { editable } = useTableContext();
11
-
12
- const elementRef = useRef(null);
13
-
14
- const focusableElements = useGetFocusableElements({
15
- elementRef,
16
- isOpen: true,
17
- });
18
-
19
- useEffect(() => {
20
- focusableElements[0]?.focus();
21
- }, [focusableElements]);
22
-
23
- useEffect(() => {
24
- editable!.setEditData(
25
- editable!.selectedItem?.item ?? editable!.defaultDataValue ?? {}
26
- );
27
- // eslint-disable-next-line
28
- }, [editable?.setEditData, editable?.selectedItem, editable?.defaultDataValue]);
29
-
30
- let rowCells = {
31
- ...editable?.cells,
32
- actions: {
33
- value: (
34
- <div className="flex center gap-1">
35
- <IconButton icon={faCheck} size="s" type="submit" />
36
- <IconButton
37
- icon={faXmark}
38
- size="s"
39
- onClick={() => {
40
- editable?.setEditData(editable?.defaultDataValue || {});
41
- if (editable?.isAdding) {
42
- editable.setIsAdding(false);
43
- } else {
44
- editable?.setSelectedItem(null);
45
- }
46
- }}
47
- />
48
- </div>
49
- ),
50
- },
51
- };
52
-
53
- const rowData: ITableDataItem = {
54
- uuid: editable?.selectedItem?.uuid as string,
55
- cells: rowCells,
56
- };
57
-
58
- return (
59
- <tr ref={elementRef} data-id={rowData.uuid} className="edit-row">
60
- {columns.map(column => {
61
- const item = rowData.cells[column.id];
62
- return (
63
- <td
64
- key={column.id}
65
- align={column.align}
66
- colSpan={item?.span}
67
- className={clsx(item?.className, {
68
- editable: typeof item?.value === 'object',
69
- })}
70
- >
71
- {item?.value ?? ''}
72
- </td>
73
- );
74
- })}
75
- </tr>
76
- );
77
- };
1
+ import type { FC } from 'react';
2
+ import type { ITableColumn, ITableDataItem } from '../../../../types/ITable';
3
+ import { useEffect, useRef } from 'react';
4
+ import clsx from 'clsx';
5
+ import { faCheck, faXmark } from '../../../../assets/icons';
6
+ import { useGetFocusableElements } from '../../../../hooks/useGetFocusableElements';
7
+ import { IconButton } from '../../../Button/IconButton';
8
+ import { useTableContext } from '../../contexts/TableContext';
9
+
10
+ export const TableEditRow: FC<{ columns: ITableColumn[] }> = ({ columns }) => {
11
+ const { editable } = useTableContext();
12
+
13
+ const elementRef = useRef(null);
14
+
15
+ const focusableElements = useGetFocusableElements({
16
+ elementRef,
17
+ isOpen: true,
18
+ });
19
+
20
+ useEffect(() => {
21
+ focusableElements[0]?.focus();
22
+ }, [focusableElements]);
23
+
24
+ useEffect(() => {
25
+ editable!.setEditData(
26
+ editable!.selectedItem?.item ?? editable!.defaultDataValue ?? {}
27
+ );
28
+ // eslint-disable-next-line
29
+ }, [editable?.setEditData, editable?.selectedItem, editable?.defaultDataValue]);
30
+
31
+ let rowCells = {
32
+ ...editable?.cells,
33
+ actions: {
34
+ value: (
35
+ <div className="flex center gap-1">
36
+ <IconButton icon={faCheck} size="s" type="submit" />
37
+ <IconButton
38
+ icon={faXmark}
39
+ size="s"
40
+ onClick={() => {
41
+ editable?.setEditData(editable?.defaultDataValue || {});
42
+ if (editable?.isAdding) {
43
+ editable.setIsAdding(false);
44
+ } else {
45
+ editable?.setSelectedItem(null);
46
+ }
47
+ }}
48
+ />
49
+ </div>
50
+ ),
51
+ },
52
+ };
53
+
54
+ const rowData: ITableDataItem = {
55
+ uuid: editable?.selectedItem?.uuid as string,
56
+ cells: rowCells,
57
+ };
58
+
59
+ return (
60
+ <tr ref={elementRef} data-id={rowData.uuid} className="edit-row">
61
+ {columns.map(column => {
62
+ const item = rowData.cells[column.id];
63
+ return (
64
+ <td
65
+ key={column.id}
66
+ align={column.align}
67
+ colSpan={item?.span}
68
+ className={clsx(item?.className, {
69
+ editable: typeof item?.value === 'object',
70
+ })}
71
+ >
72
+ {item?.value ?? ''}
73
+ </td>
74
+ );
75
+ })}
76
+ </tr>
77
+ );
78
+ };
@@ -1,15 +1,15 @@
1
- import { FC } from 'react';
2
- import { ITableFilterItem } from '../../../../types/ITable';
3
-
4
- interface Props {
5
- item: ITableFilterItem;
6
- }
7
- export const FilterItem: FC<Props> = ({ item }) => (
8
- <div className="table-filter-item">
9
- {/* Added zero-width non-breaking space symbol (&#8288;)
10
- because of losing focus from input field when first letter of the label is pressed. */}
11
- {/* <p className="filter-item-label">&#8288;{item.label}</p> */}
12
- <p className="filter-item-label">{item.label}</p>
13
- {item.field}
14
- </div>
15
- );
1
+ import type { FC } from 'react';
2
+ import type { ITableFilterItem } from '../../../../types/ITable';
3
+
4
+ interface Props {
5
+ item: ITableFilterItem;
6
+ }
7
+ export const FilterItem: FC<Props> = ({ item }) => (
8
+ <div className="table-filter-item">
9
+ {/* Added zero-width non-breaking space symbol (&#8288;)
10
+ because of losing focus from input field when first letter of the label is pressed. */}
11
+ {/* <p className="filter-item-label">&#8288;{item.label}</p> */}
12
+ <p className="filter-item-label">{item.label}</p>
13
+ {item.field}
14
+ </div>
15
+ );