@inceptionbg/iui 2.0.4 → 2.0.6

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-BllwaG2u.js → NoAccessPage-C6nBt-PN.js} +2 -2
  2. package/dist/{NoAccessPage-BllwaG2u.js.map → NoAccessPage-C6nBt-PN.js.map} +1 -1
  3. package/dist/{NotFoundPage-DVm00-sr.js → NotFoundPage-DatmJOrr.js} +2 -2
  4. package/dist/{NotFoundPage-DVm00-sr.js.map → NotFoundPage-DatmJOrr.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 +57 -49
  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 +15 -11
  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 +44 -0
  117. package/src/components/Header/Header.tsx +36 -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 +176 -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 +24 -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,130 @@
1
+ import { IAnyObject } from '../types/IBasic';
2
+ import {
3
+ IReportTemplate,
4
+ IReportTemplateFilterValue,
5
+ ITableColumn,
6
+ ITableColumnsData,
7
+ } from '../types/ITable';
8
+
9
+ // FILTERS
10
+ export const getActiveFilterNumber = (obj: IAnyObject) => Object.keys(obj).length;
11
+
12
+ // COLUMNS
13
+ export const getVisibleColumnsIds = (tableCols: ITableColumn[], isPrint?: boolean) =>
14
+ tableCols.reduce(
15
+ (arr: string[], col) =>
16
+ col.hidden ||
17
+ col.unavailable ||
18
+ (isPrint && ['select', 'icons', 'actions'].includes(col.id))
19
+ ? arr
20
+ : arr.concat(col.id),
21
+ []
22
+ );
23
+
24
+ export const getVisibleColumnsFromList = (
25
+ tableCols: ITableColumn[],
26
+ visibleColumns: string[]
27
+ ) =>
28
+ tableCols
29
+ .map(e =>
30
+ visibleColumns.includes(e.id) ? { ...e, hidden: false } : { ...e, hidden: true }
31
+ )
32
+ .sort((e, f) =>
33
+ visibleColumns.indexOf(e.id) < visibleColumns.indexOf(f.id) ? -1 : 1
34
+ );
35
+
36
+ export const getPrintColumns = (tableCols: ITableColumn[]) =>
37
+ tableCols.reduce(
38
+ (arr: string[], col) => (col.hidden || col.unavailable ? arr : arr.concat(col.id)),
39
+ []
40
+ );
41
+
42
+ // TEMPLATES
43
+ export const convertSearchToReportTemplateFilter = (search: IAnyObject) =>
44
+ Object.entries(search)
45
+ .map(e =>
46
+ typeof e[1] === 'object'
47
+ ? Array.isArray(e[1])
48
+ ? { filter: e[0], type: 'ARRAY', value: JSON.stringify(e[1]) }
49
+ : {
50
+ filter: e[0],
51
+ type: 'OBJECT',
52
+ value: e[1].value,
53
+ name: e[1].label as string,
54
+ // value: e[1].uuid,
55
+ // name: (e[1].label ?? e[1].name) as string,
56
+ }
57
+ : {
58
+ filter: e[0],
59
+ type: typeof e[1] === 'boolean' ? 'BOOLEAN' : 'STRING',
60
+ value: e[1],
61
+ }
62
+ )
63
+ .filter(
64
+ e => ![null, undefined, ''].includes(e.value)
65
+ ) as IReportTemplateFilterValue[];
66
+
67
+ export const convertReportTemplateFilterToSearch = (
68
+ filterValues: IReportTemplateFilterValue[]
69
+ ) => {
70
+ let search: any = {};
71
+ filterValues?.forEach(template => {
72
+ search[template.filter] =
73
+ template.type === 'OBJECT'
74
+ ? {
75
+ value: template.value,
76
+ label: template.name,
77
+ }
78
+ : template.type === 'ARRAY'
79
+ ? JSON.parse(template.value)
80
+ : template.type === 'BOOLEAN'
81
+ ? template.value === 'true'
82
+ : template.value;
83
+ });
84
+ return search;
85
+ };
86
+
87
+ export const setTemplateData = ({
88
+ template,
89
+ columnsData,
90
+ setFilters,
91
+ setSort,
92
+ }: {
93
+ template: IReportTemplate;
94
+ columnsData?: ITableColumnsData;
95
+ setFilters?: (filters: IAnyObject) => void;
96
+ setSort?: (sort: string) => void;
97
+ }) => {
98
+ const newFilters =
99
+ template.filterValues && convertReportTemplateFilterToSearch(template.filterValues);
100
+ newFilters && setFilters && setFilters(newFilters);
101
+ template.columns &&
102
+ columnsData?.setColumns(
103
+ getVisibleColumnsFromList(columnsData.columns, template.columns)
104
+ );
105
+ template.sorts && setSort && setSort(template.sorts[0]);
106
+ };
107
+
108
+ export const scrollToRow = (uuid: string) => {
109
+ const rowElement = document.querySelector(`[data-id="${uuid}"]`) as HTMLTableRowElement;
110
+
111
+ if (!rowElement) {
112
+ return;
113
+ }
114
+
115
+ // rowElement.scrollIntoView({
116
+ // behavior: 'smooth',
117
+ // block: 'nearest',
118
+ // });
119
+
120
+ const tableContainer = rowElement?.closest('.table-container') as HTMLElement;
121
+ const tableHeadHeight =
122
+ tableContainer.querySelector('thead')?.getBoundingClientRect().height || 0;
123
+ const rowTop = rowElement.offsetTop;
124
+ const scrollTopTarget = Math.max(0, rowTop - tableHeadHeight);
125
+
126
+ tableContainer.scrollTo({
127
+ top: scrollTopTarget,
128
+ behavior: 'smooth',
129
+ });
130
+ };
@@ -0,0 +1,6 @@
1
+ import { toast } from 'react-toastify';
2
+
3
+ export const toastSuccess = (message: string) => toast.success(message);
4
+ export const toastError = (message: string) => toast.error(message, { autoClose: false });
5
+ // export const toastInfo = (message: string) => toast.info(message);
6
+ // export const toastWarn = (message: string) => toast.warn(message);
@@ -0,0 +1,4 @@
1
+ export const parseUrlSearch = (search: string) => {
2
+ const urlSearchParams = new URLSearchParams(search);
3
+ return Object.fromEntries(urlSearchParams.entries());
4
+ };
@@ -0,0 +1,176 @@
1
+ import i18next from 'i18next';
2
+ import { IBooleanObject } from '../types/IBasic';
3
+ import { lsGet } from './LocalStorageHelper';
4
+ import { convertBooleanObjectToArray } from './ObjectUtils';
5
+ import { toastError } from './Toasts';
6
+
7
+ export const sizeInBytesPretty = (bytes?: number) => {
8
+ if (bytes === 0) {
9
+ return '0.00 B';
10
+ } else if (bytes === undefined) {
11
+ return '/';
12
+ }
13
+ const e = Math.floor(Math.log(bytes) / Math.log(1024));
14
+ return (bytes / Math.pow(1024, e)).toFixed(2) + ' ' + ' KMGTP'.charAt(e) + 'B';
15
+ };
16
+
17
+ export const dataURLtoFile = (dataUrl: string, filename: string, fileExt: string) => {
18
+ const arr = dataUrl.split(',');
19
+ const mime = arr[0].match(/:(.*?);/)![1];
20
+ const bstr = window.atob(arr[1]);
21
+ let n = bstr.length;
22
+ const u8arr = new Uint8Array(n);
23
+
24
+ while (n--) {
25
+ u8arr[n] = bstr.charCodeAt(n);
26
+ }
27
+
28
+ return new File([u8arr], `${filename}.${fileExt}`, { type: mime });
29
+ };
30
+
31
+ export const getExtensionFromFilename = (filename?: string) =>
32
+ filename?.split('.').pop()?.toLowerCase() ?? '';
33
+
34
+ export const calculateFilesSize = (filesList: any[], selectedFiles: IBooleanObject) =>
35
+ filesList.reduce(
36
+ (prev, curr) =>
37
+ convertBooleanObjectToArray(selectedFiles).includes(curr.uuid)
38
+ ? prev + curr.storedFile.lengthInBytes
39
+ : prev,
40
+ 0
41
+ );
42
+
43
+ export const downloadDocumentFile = (
44
+ fileName: string,
45
+ url: string,
46
+ type: 'pdf' | 'xml' | 'xlsx',
47
+ apiUrl?: string,
48
+ search?: any
49
+ ) => {
50
+ let req = new XMLHttpRequest();
51
+ const params =
52
+ search &&
53
+ Object.keys(search)
54
+ .map(key => key + '=' + search[key])
55
+ .join('&');
56
+
57
+ req.open(
58
+ 'GET',
59
+ `${
60
+ apiUrl
61
+ // || api.apiUrl
62
+ }${url}${params ? `?${params}` : ''}`,
63
+ true
64
+ );
65
+ req.setRequestHeader('Authorization', 'Bearer ' + lsGet('token'));
66
+ req.responseType = 'blob';
67
+
68
+ req.onload = function () {
69
+ if (req.status === 200) {
70
+ var blob = req.response;
71
+ var link = document.createElement('a');
72
+ link.href = window.URL.createObjectURL(blob);
73
+ link.download = `${fileName}.${type}`;
74
+ link.click();
75
+ } else toastError(i18next.t('ErrorMessage'));
76
+ };
77
+
78
+ req.send();
79
+ };
80
+
81
+ export const getFileFromUrl = (url: string, name: string) =>
82
+ fetch(url)
83
+ .then(res => res.blob())
84
+ .then(data => {
85
+ const file = new File([data], name, {
86
+ type: data.type || 'image/png',
87
+ });
88
+ return file;
89
+ });
90
+
91
+ export const getBase64FromFile = (file: Blob): Promise<string> =>
92
+ new Promise((resolve, reject) => {
93
+ const reader = new FileReader();
94
+ reader.readAsDataURL(file);
95
+ reader.onload = () => resolve(reader.result as string);
96
+ reader.onerror = () => reject(new Error('Failed to read file'));
97
+ });
98
+
99
+ export const getBase64FromUrl = (url: string): Promise<string> =>
100
+ getFileFromUrl(url, url).then(file => {
101
+ if (file) {
102
+ return getBase64FromFile(file);
103
+ }
104
+ throw new Error('Failed to create file from URL');
105
+ });
106
+
107
+ export const splitBase64File = (base64: string, type?: 'img') => {
108
+ const regex =
109
+ type === 'img' ? /^data:([a-z]+\/[a-z]+);base64,(.+)$/ : /^data:(.+);base64,(.+)$/;
110
+ const match = base64.match(regex);
111
+ if (match) {
112
+ const contentType = match[1];
113
+ const base64Data = match[2];
114
+ return { contentType, base64Data };
115
+ } else {
116
+ throw new Error(type === 'img' ? 'Invalid base64 image format' : 'Invalid file');
117
+ }
118
+ };
119
+
120
+ export const rotateBase64Image = (
121
+ base64data: string,
122
+ angle: number,
123
+ callback: (data: string) => void
124
+ ) => {
125
+ const canvas = document.createElement('canvas');
126
+ let ctx = canvas.getContext('2d');
127
+ let image = new Image();
128
+
129
+ image.onload = function () {
130
+ canvas.width = angle % 180 === 0 ? image.width : image.height;
131
+ canvas.height = angle % 180 === 0 ? image.height : image.width;
132
+
133
+ ctx?.translate(canvas.width / 2, canvas.height / 2);
134
+ ctx?.rotate((angle * Math.PI) / 180);
135
+ ctx?.drawImage(image, image.width / -2, image.height / -2);
136
+
137
+ callback(canvas.toDataURL());
138
+ };
139
+ image.src = base64data;
140
+ };
141
+
142
+ export function downloadFile({
143
+ url,
144
+ fileName,
145
+ onSuccess,
146
+ setIsLoading,
147
+ }: {
148
+ url: string;
149
+ fileName: string;
150
+ setIsLoading?: (isLoading: boolean) => void;
151
+ onSuccess?: () => void;
152
+ }) {
153
+ setIsLoading?.(true);
154
+ //Create XMLHTTP Request.
155
+ const req = new XMLHttpRequest();
156
+ req.open('GET', url, true);
157
+ req.responseType = 'blob';
158
+ req.onload = function () {
159
+ //Convert the Byte Data to BLOB object.
160
+ const blob = new Blob([req.response], { type: 'application/octetstream' });
161
+ const url2 = window.URL || window.webkitURL;
162
+ const link = url2.createObjectURL(blob);
163
+ const a = document.createElement('a');
164
+ a.setAttribute('download', fileName);
165
+ a.setAttribute('href', link);
166
+ document.body.appendChild(a);
167
+ a.click();
168
+ document.body.removeChild(a);
169
+ };
170
+ req.onloadend = function () {
171
+ console.log('Finished downloading file');
172
+ onSuccess?.();
173
+ setIsLoading?.(false);
174
+ };
175
+ req.send();
176
+ }
@@ -0,0 +1,90 @@
1
+ export const i18nIUICyrilic = {
2
+ ////// BASIC //////
3
+ // Accept: 'Прихвати',
4
+ Actions: 'Акције',
5
+ Active: 'Активан',
6
+ AddInput: 'Унеси',
7
+ Back: 'Назад',
8
+ Cancel: 'Откажи',
9
+ Change: 'Промени',
10
+ Choose: 'Изабери',
11
+ Close: 'Затвори',
12
+ Confirm: 'Потврди',
13
+ Create: 'Креирај',
14
+ Delete: 'Избриши',
15
+ Edit: 'Измени',
16
+ FreeText: 'Слободан унос',
17
+ from: 'од',
18
+ Group: 'Група',
19
+ Groups: 'Групе',
20
+ Next: 'Даље',
21
+ No: 'Не',
22
+ Ok: 'У реду',
23
+ Options: 'Опције',
24
+ or: 'или',
25
+ Save: 'Сачувај',
26
+ Search: 'Претрага',
27
+ Selected: 'Означено',
28
+ Send: 'Пошаљи',
29
+ Sending: 'Слање',
30
+ Title: 'Наслов',
31
+ to: 'до',
32
+ Yes: 'Да',
33
+
34
+ ////// TABLE //////
35
+ RefreshData: 'Освежи податке',
36
+ allResults: 'Сви',
37
+ Columns: 'Колоне',
38
+ DragDropListsInfo:
39
+ 'Одаберите колоне за приказивање превлачењем са једне листе на другу',
40
+ Filter: 'Филтери',
41
+ HiddenColumns: 'Сакривене колоне',
42
+ NoResults: 'Нема резултата',
43
+ of: 'од',
44
+ page: 'Страна',
45
+ Print: 'Одштампај',
46
+ PrintDate: 'Датум извештаја',
47
+ PrintExport: 'Штампа/Извоз',
48
+ ResetFilter: 'Ресетуј филтере',
49
+ rowsPerPage: 'Број редова',
50
+ SaveXlsx: 'Сачувај XЛСX',
51
+ SelectedColumns: 'Одабране колоне',
52
+ Sort: 'Сортирање',
53
+ AddItem: 'Додај ставку',
54
+ Templates: 'Шаблони',
55
+ SelectTemplate: 'Изабери шаблон',
56
+ TemplateList: 'Листа шаблона',
57
+ PublicTemplate: 'Јавни шаблон',
58
+ PublicTemplates: 'Јавни шаблони',
59
+ DefaultTemplate: 'Основни шаблони',
60
+ RemoveFiltersAndLook: 'Поништи изглед и филтере',
61
+ CreateTemplateLong: 'Сачувај тренутни изглед као шаблон',
62
+ CreateDefaultTemplate: 'Сачувај тренутни изглед као подразумевани',
63
+ CreateTemplate: 'Сачувај шаблон',
64
+ DeleteTemplateDesc: 'Да ли сте сигурни да желите да избришете шаблон?',
65
+ DeleteTemplateTitle: 'Брисање шаблона',
66
+
67
+ FastLinks: 'Брзи приступ',
68
+
69
+ ////// INPUTS //////
70
+ CharMin: 'Минималан број карактера: {{from}}',
71
+ CharRange: 'Број карактера од {{from}} до {{-to}}',
72
+ CharNumber: 'Број карактера {{number}}',
73
+
74
+ ////// TOAST //////
75
+ Pending: 'У току',
76
+ Successfully: 'Успешно',
77
+ DeletedSuccessfully: 'Успешно избрисано',
78
+ ErrorMessage: 'Дошло је до грешке!',
79
+ TryAgain: 'Покушај поново',
80
+
81
+ ////// PAGES //////
82
+ ReturnToHomepage: 'Повратак на почетну страну',
83
+ FooterText: `<strong>Инцеп️тион ЦА</strong> је сертификационо тело <strong>акредитовано</strong> за услугу <strong>електронске доставе</strong> и <strong>издавања временских жигова.<strong>`,
84
+ PageNotFound: 'Страница није пронађена',
85
+ PageNotFoundInfo: `Страница коју тражите није пронађена или је премештена.
86
+ Можете се вратити на почетну страну.`,
87
+ NoAccessPage: 'Немате приступ страници',
88
+ NoAccessPageInfo: `Немате привилегију за приступ овој страници.
89
+ За више информација и доделу приступа, обратите се администратору.`,
90
+ };
@@ -0,0 +1,90 @@
1
+ export const i18nIUILatin = {
2
+ ////// BASIC //////
3
+ // Accept: 'Prihvati',
4
+ HomePage: 'Početna',
5
+
6
+ Actions: 'Akcije',
7
+ Active: 'Aktivan',
8
+ AddInput: 'Unesi',
9
+ Back: 'Nazad',
10
+ Cancel: 'Otkaži',
11
+ Change: 'Promeni',
12
+ Choose: 'Izaberi',
13
+ Close: 'Zatvori',
14
+ Confirm: 'Potvrdi',
15
+ Create: 'Kreiraj',
16
+ Delete: 'Izbriši',
17
+ Edit: 'Izmeni',
18
+ FreeText: 'Slobodan unos',
19
+ from: 'od',
20
+ Group: 'Grupa',
21
+ Groups: 'Grupe',
22
+ Next: 'Dalje',
23
+ No: 'Ne',
24
+ Ok: 'U redu',
25
+ Options: 'Opcije',
26
+ or: 'ili',
27
+ Save: 'Sačuvaj',
28
+ Search: 'Pretraga',
29
+ Selected: 'Označeno',
30
+ Send: 'Pošalji',
31
+ Sending: 'Slanje',
32
+ Title: 'Naslov',
33
+ to: 'do',
34
+ Yes: 'Da',
35
+
36
+ ////// TABLE //////
37
+ RefreshData: 'Osveži podatke',
38
+ allResults: 'Svi',
39
+ Columns: 'Kolone',
40
+ DragDropListsInfo:
41
+ 'Odaberite kolone za prikazivanje prevlačenjem sa jedne liste na drugu',
42
+ Filter: 'Filteri',
43
+ HiddenColumns: 'Sakrivene kolone',
44
+ NoResults: 'Nema rezultata',
45
+ of: 'od',
46
+ page: 'Strana',
47
+ Print: 'Odštampaj',
48
+ PrintDate: 'Datum izveštaja',
49
+ PrintExport: 'Štampa/Izvoz',
50
+ ResetFilter: 'Resetuj filtere',
51
+ rowsPerPage: 'Broj redova',
52
+ SaveXlsx: 'Sačuvaj XLSX',
53
+ SelectedColumns: 'Odabrane kolone',
54
+ Sort: 'Sortiranje',
55
+ AddItem: 'Dodaj stavku',
56
+ Templates: 'Šabloni',
57
+ SelectTemplate: 'Izaberi šablon',
58
+ TemplateList: 'Lista šablona',
59
+ PublicTemplate: 'Javni šablon',
60
+ PublicTemplates: 'Javni šabloni',
61
+ DefaultTemplate: 'Osnovni šabloni',
62
+ RemoveFiltersAndLook: 'Poništi izgled i filtere',
63
+ CreateTemplateLong: 'Sačuvaj trenutni izgled kao šablon',
64
+ CreateDefaultTemplate: 'Sačuvaj trenutni izgled kao podrazumevani',
65
+ CreateTemplate: 'Sačuvaj šablon',
66
+ DeleteTemplateDesc: 'Da li ste sigurni da želite da izbrišete šablon?',
67
+ DeleteTemplateTitle: 'Brisanje šablona',
68
+
69
+ FastLinks: 'Brzi pristup',
70
+
71
+ ////// INPUTS //////
72
+ CharMin: 'Minimalan broj karaktera: {{from}}',
73
+ CharRange: 'Broj karaktera od {{from}} do {{-to}}',
74
+ CharNumber: 'Broj karaktera {{number}}',
75
+
76
+ ////// TOAST //////
77
+ Successfully: 'Uspešno',
78
+ DeletedSuccessfully: 'Uspešno izbrisano',
79
+ ErrorMessage: 'Došlo je do greške!',
80
+
81
+ ////// PAGES //////
82
+ ReturnToHomepage: 'Povratak na početnu stranu',
83
+ FooterText: `<strong>Incep️tion CA</strong> je sertifikaciono telo <strong>akreditovano</strong> za uslugu <strong>elektronske dostave</strong> i <strong>izdavanja vremenskih žigova.<strong>`,
84
+ PageNotFound: 'Stranica nije pronadjena',
85
+ PageNotFoundInfo: `Stranica koju tražite nije pronadjena ili je premeštena.
86
+ Možete se vratiti na početnu stranu.`,
87
+ NoAccessPage: 'Nemate pristup stranici',
88
+ NoAccessPageInfo: `Nemate privilegiju za pristup ovoj stranici.
89
+ Za više informacija i dodelu pristupa, obratite se administratoru.`,
90
+ };
@@ -0,0 +1,88 @@
1
+ export const i18nIUIMe = {
2
+ ////// BASIC //////
3
+ Actions: 'Akcije',
4
+ Active: 'Aktivan',
5
+ AddInput: 'Unesi',
6
+ Back: 'Nazad',
7
+ Cancel: 'Otkaži',
8
+ Change: 'Promijeni',
9
+ Choose: 'Izaberi',
10
+ Close: 'Zatvori',
11
+ Confirm: 'Potvrdi',
12
+ Create: 'Kreiraj',
13
+ Delete: 'Izbriši',
14
+ Edit: 'Izmijeni',
15
+ FreeText: 'Slobodan unos',
16
+ from: 'od',
17
+ Group: 'Grupa',
18
+ Groups: 'Grupe',
19
+ Next: 'Dalje',
20
+ No: 'Ne',
21
+ Ok: 'U redu',
22
+ Options: 'Opcije',
23
+ or: 'ili',
24
+ Save: 'Sačuvaj',
25
+ Search: 'Pretraga',
26
+ Selected: 'Odabrano',
27
+ Send: 'Pošalji',
28
+ Sending: 'Slanje',
29
+ Title: 'Naslov',
30
+ to: 'do',
31
+ Yes: 'Da',
32
+
33
+ ////// TABLE //////
34
+ RefreshData: 'Osvježi podatke',
35
+ allResults: 'Svi',
36
+ Columns: 'Kolone',
37
+ DragDropListsInfo: 'Izaberite kolone za prikaz prevlačenjem sa jedne liste na drugu',
38
+ Filter: 'Filteri',
39
+ HiddenColumns: 'Skrivene kolone',
40
+ NoResults: 'Nema rezultata',
41
+ of: 'od',
42
+ page: 'Strana',
43
+ Print: 'Odštampaj',
44
+ PrintDate: 'Datum izvještaja',
45
+ PrintExport: 'Štampa/Izvoz',
46
+ ResetFilter: 'Resetuj filtere',
47
+ rowsPerPage: 'Broj redova',
48
+ SaveXlsx: 'Sačuvaj XLSX',
49
+ SelectedColumns: 'Odabrane kolone',
50
+ Sort: 'Sortiranje',
51
+ AddItem: 'Dodaj stavku',
52
+ Templates: 'Šabloni',
53
+ SelectTemplate: 'Izaberi šablon',
54
+ TemplateList: 'Lista šablona',
55
+ PublicTemplate: 'Javni šablon',
56
+ PublicTemplates: 'Javni šabloni',
57
+ DefaultTemplate: 'Podrazumijevani šabloni',
58
+ RemoveFiltersAndLook: 'Poništi izgled i filtere',
59
+ CreateTemplateLong: 'Sačuvaj trenutni izgled kao šablon',
60
+ CreateDefaultTemplate: 'Sačuvaj trenutni izgled kao podrazumijevani',
61
+ CreateTemplate: 'Sačuvaj šablon',
62
+ DeleteTemplateDesc: 'Da li ste sigurni da želite da izbrišete šablon?',
63
+ DeleteTemplateTitle: 'Brisanje šablona',
64
+
65
+ FastLinks: 'Brzi linkovi',
66
+
67
+ ////// INPUTS //////
68
+ CharMin: 'Minimalan broj karaktera: {{from}}',
69
+ CharRange: 'Broj karaktera od {{from}} do {{-to}}',
70
+ CharNumber: 'Broj karaktera {{number}}',
71
+
72
+ ////// TOAST //////
73
+ Pending: 'U toku',
74
+ Successfully: 'Uspješno',
75
+ DeletedSuccessfully: 'Uspješno izbrisano',
76
+ ErrorMessage: 'Došlo je do greške!',
77
+ TryAgain: 'Pokušajte ponovo',
78
+
79
+ ////// PAGES //////
80
+ ReturnToHomepage: 'Povratak na početnu stranicu',
81
+ FooterText: '',
82
+ PageNotFound: 'Stranica nije pronađena',
83
+ PageNotFoundInfo: `Stranica koju tražite nije pronađena ili je premještena.
84
+ Možete se vratiti na početnu stranicu.`,
85
+ NoAccessPage: 'Nemate pristup stranici',
86
+ NoAccessPageInfo: `Nemate privilegiju za pristup ovoj stranici.
87
+ Za više informacija i dodjelu pristupa, obratite se administratoru.`,
88
+ };
@@ -0,0 +1,13 @@
1
+ import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
+ import { faCircleCheck } from '../assets/icons/regular/faCircleCheck';
3
+ import { faCircleExclamation } from '../assets/icons/regular/faCircleExclamation';
4
+ import { faCircleInfo } from '../assets/icons/regular/faCircleInfo';
5
+ import { faTriangleExclamation } from '../assets/icons/regular/faTriangleExclamation';
6
+ import { IInfoType } from '../types/IInfo';
7
+
8
+ export const infoIcons: Record<IInfoType, IconDefinition> = {
9
+ info: faCircleInfo,
10
+ success: faCircleCheck,
11
+ warning: faTriangleExclamation,
12
+ danger: faCircleExclamation,
13
+ };
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src/assets/icons"],
4
+ "exclude": ["node_modules", "dist"]
5
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "module": "esnext",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "jsx": "react-jsx",
8
+ "rootDir": "src",
9
+ "sourceMap": true,
10
+ "moduleResolution": "node",
11
+ "forceConsistentCasingInFileNames": true,
12
+ "skipLibCheck": true,
13
+ "paths": {
14
+ "react": ["./node_modules/@types/react"]
15
+ }
16
+ },
17
+ "include": ["src"],
18
+ "exclude": ["node_modules", "idea", "dist"]
19
+ }