@inceptionbg/iui 2.0.35 → 2.0.36

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 (241) hide show
  1. package/package.json +4 -1
  2. package/idea/GridTable/GridTable.tsx +0 -119
  3. package/idea/GridTable/gridTable.scss +0 -42
  4. package/idea/Menu/Menu.tsx +0 -121
  5. package/idea/Menu/MenuItem.tsx +0 -75
  6. package/idea/Menu/hooks/useMenuControl.ts +0 -13
  7. package/idea/Menu.tsx +0 -133
  8. package/idea/NoAccessInfo.tsx +0 -193
  9. package/idea/Table/Components/Edit/ItemActionsMenu.tsx +0 -85
  10. package/idea/Table/Components/Edit/ItemEditOptionsButtons.tsx +0 -31
  11. package/idea/Table/Components/Edit/TableEditRow.tsx +0 -57
  12. package/idea/Table/Components/FilterItem.tsx +0 -20
  13. package/idea/Table/Components/Header/TableHeader.tsx +0 -46
  14. package/idea/Table/Components/Header/TableHeaderRow.tsx +0 -37
  15. package/idea/Table/Components/Print/CustomTablePrint.tsx +0 -115
  16. package/idea/Table/Components/SetSortList.tsx +0 -30
  17. package/idea/Table/Components/SetTableFilter.tsx +0 -91
  18. package/idea/Table/Components/TableFooter.tsx +0 -137
  19. package/idea/Table/Components/TableOptions.tsx +0 -227
  20. package/idea/Table/Components/Templates/TemplateCreate.tsx +0 -80
  21. package/idea/Table/Components/Templates/TemplateCreateDefault.tsx +0 -45
  22. package/idea/Table/Components/Templates/TemplateList.tsx +0 -167
  23. package/idea/Table/Components/Templates/repo/TemplateRepo.ts +0 -53
  24. package/idea/Table/Table.tsx +0 -528
  25. package/idea/Table/hooks/useDefaultTemplate.ts +0 -20
  26. package/idea/Table/hooks/useTableKeyboard.ts +0 -137
  27. package/idea/Table/hooks/useTableSelect.ts +0 -11
  28. package/rollup.config.js +0 -52
  29. package/src/assets/icons/duotone/faBell.ts +0 -17
  30. package/src/assets/icons/duotone/faCircleUser.ts +0 -17
  31. package/src/assets/icons/regular/faArrowLeft.ts +0 -15
  32. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +0 -15
  33. package/src/assets/icons/regular/faCircleCheck.ts +0 -15
  34. package/src/assets/icons/regular/faCircleExclamation.ts +0 -15
  35. package/src/assets/icons/regular/faCircleInfo.ts +0 -15
  36. package/src/assets/icons/regular/faFileArrowDown.ts +0 -15
  37. package/src/assets/icons/regular/faFilterCircleXmark.ts +0 -15
  38. package/src/assets/icons/regular/faTriangleExclamation.ts +0 -15
  39. package/src/assets/icons/solid/faAngleLeft.ts +0 -15
  40. package/src/assets/icons/solid/faAngleRight.ts +0 -15
  41. package/src/assets/icons/solid/faArrowDownWideShort.ts +0 -15
  42. package/src/assets/icons/solid/faCaretDown.ts +0 -15
  43. package/src/assets/icons/solid/faCheck.ts +0 -15
  44. package/src/assets/icons/solid/faEllipsisVertical.ts +0 -15
  45. package/src/assets/icons/solid/faEnvelopeDot.ts +0 -15
  46. package/src/assets/icons/solid/faFilter.ts +0 -15
  47. package/src/assets/icons/solid/faFloppyDisk.ts +0 -15
  48. package/src/assets/icons/solid/faGripDotsVertical.ts +0 -15
  49. package/src/assets/icons/solid/faListUl.ts +0 -15
  50. package/src/assets/icons/solid/faMinus.ts +0 -15
  51. package/src/assets/icons/solid/faPlus.ts +0 -15
  52. package/src/assets/icons/solid/faPrint.ts +0 -15
  53. package/src/assets/icons/solid/faRotateRight.ts +0 -15
  54. package/src/assets/icons/solid/faXmark.ts +0 -15
  55. package/src/assets/images/logo/inception.svg +0 -22
  56. package/src/assets/images/logo/mts.svg +0 -5703
  57. package/src/assets/images/logo/paperless.svg +0 -21
  58. package/src/assets/images/logo/pismonosa.png +0 -0
  59. package/src/assets/images/not-found.svg +0 -19
  60. package/src/components/Accordions/Accordions.tsx +0 -74
  61. package/src/components/Alert/Alert.tsx +0 -31
  62. package/src/components/Badge/DotBadge.tsx +0 -16
  63. package/src/components/Badge/NotificationBadge.tsx +0 -29
  64. package/src/components/Badge/PillBadge.tsx +0 -13
  65. package/src/components/Button/Button.tsx +0 -56
  66. package/src/components/Button/IconButton.tsx +0 -51
  67. package/src/components/Button/SplitButton.tsx +0 -91
  68. package/src/components/Dashboard/Dashboard.tsx +0 -9
  69. package/src/components/Dashboard/DashboardWidget.tsx +0 -44
  70. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +0 -36
  71. package/src/components/Dialog/Dialog.tsx +0 -178
  72. package/src/components/Dialog/components/DialogFooter.tsx +0 -100
  73. package/src/components/Header/Components/EnvBadge.tsx +0 -17
  74. package/src/components/Header/Components/ModuleSelect.tsx +0 -68
  75. package/src/components/Header/Components/Notifications.tsx +0 -204
  76. package/src/components/Header/Components/UserMenu.tsx +0 -52
  77. package/src/components/Header/Header.tsx +0 -45
  78. package/src/components/Helper/Collapse.tsx +0 -53
  79. package/src/components/Inputs/Checkbox.tsx +0 -53
  80. package/src/components/Inputs/CurrencyInput.tsx +0 -124
  81. package/src/components/Inputs/DateInput/DateInput.tsx +0 -184
  82. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +0 -159
  83. package/src/components/Inputs/InputWrapper.tsx +0 -95
  84. package/src/components/Inputs/NumberInput.tsx +0 -86
  85. package/src/components/Inputs/PasswordInput.tsx +0 -39
  86. package/src/components/Inputs/PhoneInput/PhoneInput.tsx +0 -108
  87. package/src/components/Inputs/PhoneInput/utils/countryCode.ts +0 -20
  88. package/src/components/Inputs/Radio.tsx +0 -59
  89. package/src/components/Inputs/RadioGroup.tsx +0 -48
  90. package/src/components/Inputs/RadioLarge.tsx +0 -39
  91. package/src/components/Inputs/SearchInput.tsx +0 -46
  92. package/src/components/Inputs/Selects/Select.tsx +0 -17
  93. package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +0 -19
  94. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +0 -118
  95. package/src/components/Inputs/Selects/utils/selectStyles.ts +0 -101
  96. package/src/components/Inputs/TextAreaInput.tsx +0 -68
  97. package/src/components/Inputs/TextInput.tsx +0 -100
  98. package/src/components/Inputs/TimeInput/TimeInput.tsx +0 -81
  99. package/src/components/List/List.tsx +0 -21
  100. package/src/components/List/ListItem.tsx +0 -70
  101. package/src/components/Loader/Loader.tsx +0 -66
  102. package/src/components/Loader/ProgressBar.tsx +0 -41
  103. package/src/components/Menu/Menu.tsx +0 -81
  104. package/src/components/Menu/MenuItem.tsx +0 -46
  105. package/src/components/Menu/NewMenu.tsx +0 -63
  106. package/src/components/Menu/hooks/useMenuPosition.tsx +0 -116
  107. package/src/components/PageComponents/ScrollableContent.tsx +0 -11
  108. package/src/components/Pullover/Pullover.tsx +0 -197
  109. package/src/components/Router/Router.tsx +0 -52
  110. package/src/components/Sidebar/AddButton.tsx +0 -22
  111. package/src/components/Sidebar/Sidebar.tsx +0 -85
  112. package/src/components/Sidebar/SidebarItem.tsx +0 -84
  113. package/src/components/Sidebar/types/ISidebar.ts +0 -28
  114. package/src/components/Table/Table.tsx +0 -258
  115. package/src/components/Table/components/columns/ColumnsList.tsx +0 -60
  116. package/src/components/Table/components/columns/TableColumnsEdit.tsx +0 -114
  117. package/src/components/Table/components/edit/TableEditRow.tsx +0 -78
  118. package/src/components/Table/components/filters/FilterItem.tsx +0 -15
  119. package/src/components/Table/components/filters/TableFilters.tsx +0 -126
  120. package/src/components/Table/components/footer/TableFooter.tsx +0 -126
  121. package/src/components/Table/components/header/TableHeader.tsx +0 -40
  122. package/src/components/Table/components/header/TableHeaderRow.tsx +0 -57
  123. package/src/components/Table/components/items/TableItemActions.tsx +0 -78
  124. package/src/components/Table/components/print/TablePrint.tsx +0 -200
  125. package/src/components/Table/components/select/TableSelect.tsx +0 -50
  126. package/src/components/Table/components/sort/TableSort.tsx +0 -75
  127. package/src/components/Table/components/templates/CreateTemplateDialog.tsx +0 -58
  128. package/src/components/Table/components/templates/TableTemplates.tsx +0 -65
  129. package/src/components/Table/components/templates/TemplatesPullover.tsx +0 -88
  130. package/src/components/Table/contexts/TableContext.tsx +0 -117
  131. package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +0 -70
  132. package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +0 -82
  133. package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +0 -175
  134. package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +0 -12
  135. package/src/components/Table/hooks/useTableColumns.ts +0 -34
  136. package/src/components/Table/hooks/useTableEdit.tsx +0 -140
  137. package/src/components/Table/hooks/useTableFilterFields.tsx +0 -150
  138. package/src/components/Table/hooks/useTablePagination.ts +0 -19
  139. package/src/components/Table/hooks/useTablePrint.ts +0 -83
  140. package/src/components/Table/hooks/useTableSearch.ts +0 -31
  141. package/src/components/Table/hooks/useTableSelect.ts +0 -19
  142. package/src/components/Table/hooks/useTableSort.ts +0 -8
  143. package/src/components/Tabs/Tabs.tsx +0 -68
  144. package/src/components/Tooltip/Tooltip.tsx +0 -191
  145. package/src/components/Tree/Tree.tsx +0 -22
  146. package/src/components/Tree/TreeItem.tsx +0 -57
  147. package/src/components/Wrappers/AppLayout.tsx +0 -17
  148. package/src/components/Wrappers/ConditionalWrapper.tsx +0 -10
  149. package/src/components/Wrappers/FormWrapper.tsx +0 -84
  150. package/src/components/Wrappers/PageLayout.tsx +0 -168
  151. package/src/hooks/useBackgroundClose.ts +0 -19
  152. package/src/hooks/useGetFocusableElements.ts +0 -43
  153. package/src/hooks/useIsMenuOpen.ts +0 -11
  154. package/src/hooks/useLocalPopoverControl.ts +0 -63
  155. package/src/hooks/useOnEsc.ts +0 -14
  156. package/src/hooks/usePopupControl.ts +0 -22
  157. package/src/hooks/useZendesk.ts +0 -22
  158. package/src/index.ts +0 -387
  159. package/src/pages/NoAccessPage.tsx +0 -27
  160. package/src/pages/NotFoundPage.tsx +0 -26
  161. package/src/styles/App.scss +0 -47
  162. package/src/styles/common/_animations.scss +0 -58
  163. package/src/styles/common/_typography.scss +0 -91
  164. package/src/styles/common/helpers/_base.scss +0 -55
  165. package/src/styles/common/helpers/_color.scss +0 -10
  166. package/src/styles/common/helpers/_display.scss +0 -85
  167. package/src/styles/common/helpers/_size.scss +0 -25
  168. package/src/styles/common/maps/_align.scss +0 -21
  169. package/src/styles/common/maps/_buttonMaps.scss +0 -42
  170. package/src/styles/common/maps/_info-types.scss +0 -1
  171. package/src/styles/common/maps/_spacing.scss +0 -78
  172. package/src/styles/common/maps/_text.scss +0 -14
  173. package/src/styles/components/_accordions.scss +0 -51
  174. package/src/styles/components/_alert.scss +0 -23
  175. package/src/styles/components/_badge.scss +0 -84
  176. package/src/styles/components/_button.scss +0 -99
  177. package/src/styles/components/_buttonSplit.scss +0 -74
  178. package/src/styles/components/_card.scss +0 -24
  179. package/src/styles/components/_dialog.scss +0 -119
  180. package/src/styles/components/_form.scss +0 -8
  181. package/src/styles/components/_header.scss +0 -157
  182. package/src/styles/components/_input.scss +0 -167
  183. package/src/styles/components/_inputCheckbox.scss +0 -48
  184. package/src/styles/components/_inputDateTime.scss +0 -161
  185. package/src/styles/components/_inputRadio.scss +0 -83
  186. package/src/styles/components/_inputSelect.scss +0 -8
  187. package/src/styles/components/_list.scss +0 -58
  188. package/src/styles/components/_loader.scss +0 -55
  189. package/src/styles/components/_menu-v2.scss +0 -67
  190. package/src/styles/components/_menu.scss +0 -62
  191. package/src/styles/components/_notifications.scss +0 -71
  192. package/src/styles/components/_page.scss +0 -84
  193. package/src/styles/components/_portal.scss +0 -8
  194. package/src/styles/components/_print.scss +0 -77
  195. package/src/styles/components/_progressBar.scss +0 -83
  196. package/src/styles/components/_pullover.scss +0 -95
  197. package/src/styles/components/_scrollbar.scss +0 -18
  198. package/src/styles/components/_sidebar.scss +0 -204
  199. package/src/styles/components/_smallComponents.scss +0 -23
  200. package/src/styles/components/_table.scss +0 -340
  201. package/src/styles/components/_tabs.scss +0 -33
  202. package/src/styles/components/_tooltip.scss +0 -48
  203. package/src/styles/components/_tree.scss +0 -21
  204. package/src/styles/components/_widget.scss +0 -90
  205. package/src/styles/pages/_fullScreenPage.scss +0 -64
  206. package/src/styles/variables/_bp.scss +0 -6
  207. package/src/styles/variables/_variables.scss +0 -142
  208. package/src/types/Base/custom.d.ts +0 -9
  209. package/src/types/IBasic.ts +0 -32
  210. package/src/types/ICountryCode.ts +0 -5
  211. package/src/types/IError.ts +0 -5
  212. package/src/types/IHeader.ts +0 -40
  213. package/src/types/IInfo.ts +0 -1
  214. package/src/types/IKeyboard.ts +0 -33
  215. package/src/types/IMenu.ts +0 -19
  216. package/src/types/INotifications.ts +0 -15
  217. package/src/types/IPopup.ts +0 -17
  218. package/src/types/IRouter.ts +0 -6
  219. package/src/types/ISelect.ts +0 -54
  220. package/src/types/ITab.ts +0 -10
  221. package/src/types/ITable.ts +0 -291
  222. package/src/types/ITree.ts +0 -6
  223. package/src/utils/InputPatternValidation.ts +0 -12
  224. package/src/utils/dateUtils.ts +0 -32
  225. package/src/utils/fileUtils.ts +0 -177
  226. package/src/utils/i18n/i18nIUICyrilic.ts +0 -119
  227. package/src/utils/i18n/i18nIUILatin.ts +0 -120
  228. package/src/utils/i18n/i18nIUIMe.ts +0 -118
  229. package/src/utils/icons.ts +0 -13
  230. package/src/utils/localStorageHelper.ts +0 -24
  231. package/src/utils/logoUtils.ts +0 -7
  232. package/src/utils/numberUtils.ts +0 -21
  233. package/src/utils/objectUtils.ts +0 -114
  234. package/src/utils/popupUtils.ts +0 -82
  235. package/src/utils/rootDir.ts +0 -1
  236. package/src/utils/stringUtils.ts +0 -18
  237. package/src/utils/tableUtils.ts +0 -130
  238. package/src/utils/toasts.ts +0 -6
  239. package/src/utils/urlUtils.ts +0 -4
  240. package/tsconfig.icons.json +0 -5
  241. package/tsconfig.json +0 -22
@@ -1,65 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { IReportTemplate } from '../../../../types/ITable';
3
- import { useEffect } from 'react';
4
- import { faBookmark } from '@inceptionbg/icons';
5
- import { useTranslation } from 'react-i18next';
6
- import { setTemplateData } from '../../../../utils/tableUtils';
7
- import { IconButton } from '../../../Button/IconButton';
8
- import { useTableContext } from '../../contexts/TableContext';
9
- import { TemplatesPullover } from './TemplatesPullover';
10
-
11
- export const TableTemplates: FC = () => {
12
- const { t } = useTranslation();
13
- const { templateData, columnData, filterData, sortData } = useTableContext();
14
-
15
- useEffect(() => {
16
- if (templateData?.defaultTemplate) {
17
- setTemplateData({
18
- template: templateData.defaultTemplate,
19
- columnData,
20
- setFilters: e => {
21
- filterData?.setSearchData(e);
22
- filterData?.onSearch(e);
23
- },
24
- setSort: sortData?.setSort,
25
- });
26
- }
27
- // eslint-disable-next-line
28
- }, [templateData?.defaultTemplate]);
29
-
30
- if (!templateData) return null;
31
-
32
- return (
33
- <>
34
- <IconButton
35
- tooltip={t('Templates')}
36
- icon={faBookmark}
37
- active={templateData.popupController.control.isOpen}
38
- onClick={templateData.popupController.onOpen}
39
- size="s"
40
- variant="outlined"
41
- />
42
- <TemplatesPullover
43
- templateData={templateData}
44
- onResetTemplate={() => {
45
- columnData?.setColumns?.(columnData.defaultColumns);
46
- filterData?.setSearchData(filterData.defaultSearch ?? {});
47
- filterData?.onSearch(filterData.defaultSearch ?? {});
48
- sortData?.setSort('');
49
- templateData.popupController.onClose();
50
- }}
51
- onItemClick={(item: IReportTemplate) => {
52
- setTemplateData({
53
- template: item,
54
- columnData,
55
- setFilters: e => {
56
- filterData?.setSearchData(e);
57
- filterData?.onSearch(e);
58
- },
59
- setSort: sortData?.setSort,
60
- });
61
- }}
62
- />
63
- </>
64
- );
65
- };
@@ -1,88 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { IReportTemplate, ITableTemplateData } from '../../../../types/ITable';
3
- import { faBookmark, faBookmarkSlash, faTrashCan } from '@inceptionbg/icons';
4
- import { useTranslation } from 'react-i18next';
5
- import { usePopupControl } from '../../../../hooks/usePopupControl';
6
- import { List } from '../../../List/List';
7
- import { Pullover } from '../../../Pullover/Pullover';
8
- import { CreateTemplateDialog } from './CreateTemplateDialog';
9
-
10
- interface Props {
11
- templateData: ITableTemplateData;
12
- onItemClick: (item: IReportTemplate) => void;
13
- onResetTemplate?: () => void;
14
- createDialogTitle?: string;
15
- hideDefaultTemplateOption?: boolean;
16
- }
17
-
18
- export const TemplatesPullover: FC<Props> = ({
19
- templateData,
20
- onItemClick,
21
- onResetTemplate,
22
- createDialogTitle,
23
- hideDefaultTemplateOption,
24
- }) => {
25
- const { t } = useTranslation();
26
- const createTemplatePopupController = usePopupControl();
27
-
28
- return (
29
- <>
30
- <Pullover
31
- isLoading={templateData.isLoading}
32
- isFetching={templateData.isFetching}
33
- control={templateData.popupController.control}
34
- header={{
35
- title: t('Templates'),
36
- onSearch: templateData.setSearch,
37
- }}
38
- footer={{
39
- confirmButton: {
40
- label: t('CreateTemplate'),
41
- onClick: createTemplatePopupController.onOpen,
42
- splitActions: [
43
- {
44
- label: t('CreateDefaultTemplate'),
45
- icon: faBookmark,
46
- onClick: templateData.createItem.onCreateDefault,
47
- hidden: hideDefaultTemplateOption,
48
- },
49
- ],
50
- },
51
- additionalButton: onResetTemplate && {
52
- label: t('ResetTemplate'),
53
- icon: faBookmarkSlash,
54
- onClick: onResetTemplate,
55
- },
56
- }}
57
- onCloseCallback={() => templateData.setSearch?.('')}
58
- size="w600"
59
- >
60
- <List
61
- items={templateData.items.map(item => ({
62
- id: item.uuid,
63
- label: item.name,
64
- desc: item.isPublic ? t('PublicTemplate') : t('PrivateTemplate'),
65
- onClick: () => {
66
- onItemClick(item);
67
- templateData.popupController.onClose();
68
- },
69
- actions: [
70
- {
71
- icon: faTrashCan,
72
- onClick: () => templateData.setItemToDeleteUuids([item.uuid]),
73
- color: 'danger',
74
- },
75
- ],
76
- }))}
77
- noItemsMessage={t('NoTemplatesAvailable')}
78
- />
79
- </Pullover>
80
- <CreateTemplateDialog
81
- control={createTemplatePopupController.control}
82
- createItem={templateData.createItem}
83
- title={createDialogTitle}
84
- />
85
- {templateData.DeleteDialog}
86
- </>
87
- );
88
- };
@@ -1,117 +0,0 @@
1
- import type { Dispatch, ReactNode, SetStateAction } from 'react';
2
- import type {
3
- IPaginationControl,
4
- ITable,
5
- ITableColumnsData,
6
- ITableDataActions,
7
- ITableEdit,
8
- ITableSelectedAction,
9
- } from '../../../types/ITable';
10
- import { createContext, useContext, useMemo, useState } from 'react';
11
- import { useTranslation } from 'react-i18next';
12
- import { useLocalTableData } from '../hooks/localHooks/useLocalTableData';
13
- import { useLocalTablePagination } from '../hooks/localHooks/useLocalTablePagination';
14
-
15
- interface ITableContext<T = unknown> extends ITable<T> {
16
- columnData: ITableColumnsData;
17
- selectActions: ITableSelectedAction[];
18
- dataActions?: ITableDataActions<T> & {
19
- hasItemActions: boolean;
20
- isEditable: boolean;
21
- isDeletable: boolean;
22
- };
23
- editable?: ITableEdit<T> & {
24
- isAdding: boolean;
25
- setIsAdding: Dispatch<SetStateAction<boolean>>;
26
- };
27
- footer?: ITable['footer'] & {
28
- paginationControl: IPaginationControl;
29
- noTotalRows: boolean;
30
- };
31
- }
32
-
33
- const TableContext = createContext<ITableContext<any>>({
34
- columnData: { columns: [], defaultColumns: [] },
35
- data: [],
36
- selectActions: [],
37
- });
38
-
39
- export const TableProvider = <T,>({
40
- columnData,
41
- data: initialData,
42
- dataActions,
43
- editable,
44
- footer,
45
- children,
46
- rowSelect,
47
- ...rest
48
- }: ITable<T> & { children: ReactNode }) => {
49
- const { t } = useTranslation();
50
- const [isAdding, setIsAdding] = useState(false);
51
-
52
- const selectActions = useMemo(() => {
53
- const actions = (rowSelect?.actions ?? []).filter(e => !e.hidden);
54
- if (rest.itemDeleteData?.hasAccess) {
55
- actions.push({
56
- label: t('Delete'),
57
- onClick: e => rest.itemDeleteData!.setItemToDeleteUuids([...e]),
58
- });
59
- }
60
- return actions;
61
- }, [rowSelect?.actions, rest.itemDeleteData, t]);
62
-
63
- const updatedDataActions = useMemo(() => {
64
- const isEditable = Boolean(dataActions?.hasEditAccess);
65
- const isDeletable = Boolean(rest.itemDeleteData?.hasAccess);
66
-
67
- const hasCustomActions = initialData.some(({ item }) => {
68
- const actions = dataActions?.actions?.(item).filter(e => e.hasAccess) ?? [];
69
- return actions.length > 0;
70
- });
71
-
72
- return {
73
- hasEditAccess: isEditable,
74
- actions: dataActions?.actions,
75
- hasItemActions: isEditable || isDeletable || hasCustomActions,
76
- isEditable,
77
- isDeletable,
78
- };
79
- }, [dataActions, initialData, rest.itemDeleteData?.hasAccess]);
80
-
81
- const localPagination = useLocalTablePagination({
82
- defaultLimit: footer?.customPagination?.defaultLimit,
83
- });
84
- const data = useLocalTableData<T>({
85
- initialData,
86
- noPagination: !footer || !!footer.hidden,
87
- controledPagination: !!footer?.paginationControl,
88
- localPagination,
89
- dataActions: updatedDataActions,
90
- isDeletable: updatedDataActions.isDeletable,
91
- rowSelect,
92
- });
93
-
94
- const tableContextValue: ITableContext<T> = {
95
- ...rest,
96
- data,
97
- dataActions: updatedDataActions,
98
- columnData,
99
- selectActions,
100
- rowSelect,
101
- };
102
-
103
- if (editable) tableContextValue.editable = { ...editable, isAdding, setIsAdding };
104
- if (footer)
105
- tableContextValue.footer = {
106
- ...footer,
107
- paginationControl: footer?.paginationControl ?? localPagination,
108
- totalRows: footer?.totalRows ?? initialData?.length ?? 0,
109
- noTotalRows: footer?.totalRows === undefined,
110
- };
111
-
112
- return (
113
- <TableContext.Provider value={tableContextValue}>{children}</TableContext.Provider>
114
- );
115
- };
116
-
117
- export const useTableContext = () => useContext(TableContext);
@@ -1,70 +0,0 @@
1
- import type { ITableColumn } from '../../../../types/ITable';
2
- import { useMemo } from 'react';
3
- import { useTranslation } from 'react-i18next';
4
- import { Checkbox } from '../../../Inputs/Checkbox';
5
- import { useTableContext } from '../../contexts/TableContext';
6
-
7
- export const useLocalTableColumns = () => {
8
- const { t } = useTranslation();
9
-
10
- const {
11
- columnData: { columns },
12
- selectActions,
13
- data,
14
- rowSelect,
15
- dataActions: { hasItemActions } = {},
16
- } = useTableContext();
17
-
18
- const visibleColumns = useMemo(() => {
19
- const hasSelect = rowSelect && selectActions.length > 0;
20
- const filteredColumns = columns.filter(column => !column.hidden);
21
-
22
- let newCols: ITableColumn[] = [];
23
-
24
- // Select Column
25
- if (hasSelect) {
26
- const selectableData = data.filter(e => !e.disableSelect);
27
- const selectedSome =
28
- !!rowSelect?.selectedRows.size &&
29
- selectableData.some(e => !rowSelect.selectedRows.has(e.uuid));
30
- const selectedAll = !!rowSelect?.selectedRows.size && !selectedSome;
31
-
32
- const selectColumn: ITableColumn = {
33
- id: 'select',
34
- label: (
35
- <Checkbox
36
- value={selectedSome ? 'middle' : selectedAll}
37
- setValue={() => {
38
- selectedAll
39
- ? rowSelect.setSelectedRows(new Set<string>())
40
- : rowSelect?.setSelectedRows(oldValue => {
41
- let newSet = new Set(oldValue);
42
- selectableData.forEach(e => newSet.add(e.uuid!));
43
- return newSet;
44
- });
45
- }}
46
- />
47
- ),
48
- align: 'center',
49
- className: 'select-col',
50
- };
51
-
52
- newCols.push(selectColumn);
53
- }
54
-
55
- newCols = newCols.concat(filteredColumns);
56
- // Actions Column
57
- if (hasItemActions) {
58
- newCols.push({
59
- id: 'actions',
60
- label: t('Actions'),
61
- align: 'center',
62
- className: 'actions-col',
63
- });
64
- }
65
-
66
- return newCols;
67
- }, [columns, selectActions.length, data, rowSelect, hasItemActions, t]);
68
-
69
- return { visibleColumns };
70
- };
@@ -1,82 +0,0 @@
1
- import type {
2
- IPaginationControl,
3
- ITable,
4
- ITableDataActions,
5
- ITableDataItem,
6
- } from '../../../../types/ITable';
7
- import { useMemo } from 'react';
8
- import { Checkbox } from '../../../Inputs/Checkbox';
9
- import { TableItemActions } from '../../components/items/TableItemActions';
10
-
11
- interface Props<T> {
12
- initialData: ITableDataItem<T>[];
13
- noPagination: boolean;
14
- controledPagination: boolean;
15
- localPagination: IPaginationControl;
16
- dataActions?: ITableDataActions<T>;
17
- isDeletable: boolean;
18
- rowSelect: ITable['rowSelect'];
19
- }
20
-
21
- export const useLocalTableData = <T,>({
22
- initialData,
23
- noPagination,
24
- controledPagination,
25
- localPagination,
26
- dataActions,
27
- isDeletable,
28
- rowSelect,
29
- }: Props<T>) =>
30
- useMemo(() => {
31
- const newData =
32
- noPagination || controledPagination || localPagination.limit <= 0
33
- ? initialData
34
- : initialData.slice(
35
- localPagination.offset * localPagination.limit,
36
- localPagination.offset * localPagination.limit + localPagination.limit
37
- );
38
-
39
- const additionalDataActions = dataActions?.actions?.() ?? [];
40
- const withActions = Boolean(
41
- dataActions?.hasEditAccess || isDeletable || additionalDataActions.length
42
- );
43
-
44
- const withAdditionalColumns = Boolean(rowSelect || withActions);
45
- const finalData = !withAdditionalColumns
46
- ? newData
47
- : newData.map(e => {
48
- if (rowSelect) {
49
- e.cells.select = {
50
- value: (
51
- <Checkbox
52
- value={rowSelect.selectedRows.has(e.uuid!)}
53
- setValue={checked => {
54
- rowSelect.setSelectedRows(oldSet => {
55
- const newSet = new Set(oldSet);
56
- checked ? newSet.add(e.uuid!) : newSet.delete(e.uuid!);
57
- return newSet;
58
- });
59
- }}
60
- disabled={e.disableSelect}
61
- />
62
- ),
63
- unclickable: true,
64
- };
65
- }
66
- if (dataActions) {
67
- e.cells.actions = { value: <TableItemActions tableDataItem={e} /> };
68
- }
69
- return e;
70
- });
71
-
72
- return finalData;
73
- }, [
74
- initialData,
75
- noPagination,
76
- controledPagination,
77
- localPagination.limit,
78
- localPagination.offset,
79
- rowSelect,
80
- isDeletable,
81
- dataActions,
82
- ]);
@@ -1,175 +0,0 @@
1
- import type { IKeyboardAction } from '../../../../types/IKeyboard';
2
- import type { ITableDataItem } from '../../../../types/ITable';
3
- import { useEffect, useState } from 'react';
4
- import { scrollToRow } from '../../../../utils/tableUtils';
5
- import { useTableContext } from '../../contexts/TableContext';
6
-
7
- export const useLocalTableKeyboard = () => {
8
- const [focusedRow, setFocusedRow] = useState<ITableDataItem | null>(null);
9
-
10
- const { keyboard, data, editable, itemDeleteData, dataActions, rowSelect, footer } =
11
- useTableContext();
12
-
13
- useEffect(() => {
14
- if (keyboard?.enabled) {
15
- const isEditing = !!editable?.selectedItem;
16
- const isAdding = !!editable?.isAdding;
17
- const isEditDisabled = !editable || keyboard?.actions?.editDisabled;
18
- const isAddDisabled = !!editable?.addDisabled;
19
- const isMoveDisabled = !!keyboard?.actions?.moveDisabled;
20
- const isBulkAction =
21
- dataActions?.hasItemActions &&
22
- rowSelect?.selectedRows &&
23
- rowSelect.selectedRows.size > 0;
24
-
25
- const handleKeyDown = (event: KeyboardEvent) => {
26
- const rowIndex = focusedRow
27
- ? data.findIndex(row => row.uuid === focusedRow.uuid)
28
- : -1;
29
-
30
- const allActions: IKeyboardAction[] = [
31
- {
32
- code: 'ArrowDown',
33
- disabled: isEditing || isAdding || isMoveDisabled,
34
- onAction: () => {
35
- const nextRow = rowIndex + 1;
36
- if (nextRow < data.length) {
37
- // rowIndex will be -1 if no row is selected so the next row will be 0
38
- setFocusedRow(data[nextRow]);
39
- scrollToRow(data[nextRow].uuid);
40
- }
41
- },
42
- },
43
- {
44
- code: 'ArrowUp',
45
- disabled: isEditing || isAdding || isMoveDisabled,
46
- onAction: () => {
47
- if (rowIndex !== 0) {
48
- const prevRow = rowIndex > 0 ? rowIndex - 1 : data.length - 1;
49
- setFocusedRow(data[prevRow]);
50
- scrollToRow(data[prevRow].uuid);
51
- }
52
- },
53
- },
54
- {
55
- code: 'KeyE',
56
- ctrl: true,
57
- disabled: isEditing || isEditDisabled || !focusedRow,
58
- onAction: () => {
59
- editable?.setSelectedItem(focusedRow);
60
- },
61
- },
62
- {
63
- code: 'Enter',
64
- disabled: isEditing || isAdding || !focusedRow?.onRowClick,
65
- onAction: focusedRow?.onRowClick!,
66
- },
67
- {
68
- code: 'Escape',
69
- disabled: !focusedRow && !isAdding && !isEditing,
70
- onAction: () =>
71
- isAdding
72
- ? editable?.setIsAdding(false)
73
- : editable?.selectedItem
74
- ? editable?.setSelectedItem?.(null)
75
- : setFocusedRow(null),
76
- },
77
- {
78
- code: 'Insert',
79
- disabled: isAddDisabled || isAdding || isEditing,
80
- onAction: () => {
81
- editable?.setIsAdding(true);
82
- setFocusedRow(null);
83
- },
84
- },
85
- {
86
- code: 'Delete',
87
- disabled: !dataActions?.isDeletable || isEditing || !focusedRow,
88
- onAction: () =>
89
- itemDeleteData?.setItemToDeleteUuids(
90
- isBulkAction ? Array.from(rowSelect.selectedRows) : [focusedRow!.uuid]
91
- ),
92
- },
93
- {
94
- code: 'ArrowLeft',
95
- ctrl: true,
96
- disabled: isEditing || isAdding || !footer || footer.hidden,
97
- onAction: () =>
98
- footer?.paginationControl &&
99
- footer.paginationControl.setOffset(offset => (offset > 0 ? offset - 1 : 0)),
100
- },
101
- {
102
- code: 'ArrowRight',
103
- ctrl: true,
104
- disabled: isEditing || isAdding || !footer || footer.hidden,
105
- onAction: () => {
106
- if (
107
- footer?.paginationControl &&
108
- (footer.noTotalRows
109
- ? footer.paginationControl.limit <= data.length
110
- : footer.paginationControl.offset + 1 <
111
- Math.ceil(footer.totalRows! / footer.paginationControl.limit))
112
- ) {
113
- footer.paginationControl.setOffset(offset => offset + 1);
114
- }
115
- },
116
- },
117
- {
118
- code: 'Space',
119
- disabled:
120
- !dataActions?.hasItemActions || !focusedRow?.uuid || isEditing || isAdding,
121
- onAction: () => {
122
- const rowUuid = focusedRow?.uuid!;
123
- const isRowSelected = rowSelect?.selectedRows.has(rowUuid);
124
- rowSelect?.setSelectedRows(oldSet => {
125
- const newSet = new Set(oldSet);
126
- newSet[isRowSelected ? 'delete' : 'add'](rowUuid);
127
- return newSet;
128
- });
129
- },
130
- },
131
- ];
132
-
133
- allActions.forEach(action => {
134
- if (
135
- !action.disabled &&
136
- action.code === event.code &&
137
- !!action.ctrl === (event.ctrlKey || event.metaKey)
138
- ) {
139
- event.preventDefault();
140
- event.stopPropagation();
141
- if (
142
- action.onBulkAction &&
143
- dataActions?.hasItemActions &&
144
- rowSelect?.selectedRows &&
145
- rowSelect.selectedRows.size > 0
146
- ) {
147
- action.onBulkAction(Array.from(rowSelect.selectedRows));
148
- } else {
149
- action.onAction();
150
- }
151
- }
152
- });
153
- };
154
-
155
- document.addEventListener('keydown', handleKeyDown);
156
- return () => {
157
- document.removeEventListener('keydown', handleKeyDown);
158
- };
159
- }
160
- }, [
161
- data,
162
- editable,
163
- keyboard,
164
- dataActions?.hasItemActions,
165
- dataActions?.isDeletable,
166
- itemDeleteData,
167
- focusedRow,
168
- footer,
169
- rowSelect,
170
- ]);
171
- return {
172
- focusedRow,
173
- // handleKeyDown,
174
- };
175
- };
@@ -1,12 +0,0 @@
1
- import { useState } from 'react';
2
-
3
- interface Props {
4
- defaultLimit?: number;
5
- }
6
-
7
- export const useLocalTablePagination = ({ defaultLimit }: Props) => {
8
- const [limit, setLimit] = useState(defaultLimit ?? 5);
9
- const [offset, setOffset] = useState(0);
10
-
11
- return { limit, offset, setLimit, setOffset };
12
- };
@@ -1,34 +0,0 @@
1
- import type { ITableColumn, ITableColumnsData } from '../../../types/ITable';
2
- import { useLayoutEffect, useMemo, useState } from 'react';
3
-
4
- export interface ITableColumnsProps {
5
- defaultColumns: ITableColumn[];
6
- enableEdit?: boolean;
7
- }
8
-
9
- export const useTableColumns = ({
10
- defaultColumns,
11
- enableEdit,
12
- }: ITableColumnsProps): ITableColumnsData => {
13
- const [columns, setColumns] = useState<ITableColumn[]>([]);
14
-
15
- const availableColumns = useMemo(
16
- () => defaultColumns.filter(e => !e.unavailable),
17
- [defaultColumns]
18
- );
19
-
20
- useLayoutEffect(() => {
21
- setColumns(availableColumns);
22
- }, [availableColumns]);
23
-
24
- const columnData = useMemo(
25
- () => ({
26
- defaultColumns: availableColumns,
27
- columns,
28
- setColumns: enableEdit ? setColumns : undefined,
29
- }),
30
- [availableColumns, columns, enableEdit]
31
- );
32
-
33
- return columnData;
34
- };