@inceptionbg/iui 2.0.5 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. package/dist/{NoAccessPage-C6nBt-PN.js → NoAccessPage-BozT_Suz.js} +2 -2
  2. package/dist/{NoAccessPage-C6nBt-PN.js.map → NoAccessPage-BozT_Suz.js.map} +1 -1
  3. package/dist/{NotFoundPage-DatmJOrr.js → NotFoundPage-WWiekDef.js} +2 -2
  4. package/dist/{NotFoundPage-DatmJOrr.js.map → NotFoundPage-WWiekDef.js.map} +1 -1
  5. package/dist/icons/index.d.ts +43 -0
  6. package/dist/icons/index.js +1 -0
  7. package/dist/index.d.ts +32 -20
  8. package/dist/index.js +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/iui.css +1 -1
  11. package/idea/Menu/Menu.tsx +119 -0
  12. package/idea/Menu/MenuItem.tsx +74 -0
  13. package/idea/Menu/hooks/useMenuControl.ts +13 -0
  14. package/idea/Menu.tsx +132 -0
  15. package/idea/NoAccessInfo.tsx +193 -0
  16. package/idea/Notifications.tsx +245 -0
  17. package/idea/Table2/Components/Columns/ColumnsList.tsx +56 -0
  18. package/idea/Table2/Components/Columns/SetColumnsList.tsx +107 -0
  19. package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +87 -0
  20. package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +32 -0
  21. package/idea/Table2/Components/Edit/TableEditRow.tsx +56 -0
  22. package/idea/Table2/Components/FilterItem.tsx +20 -0
  23. package/idea/Table2/Components/Header/TableHeader.tsx +35 -0
  24. package/idea/Table2/Components/Header/TableHeaderRow.tsx +37 -0
  25. package/idea/Table2/Components/Print/CustomTablePrint.tsx +119 -0
  26. package/idea/Table2/Components/Print/TablePrint.tsx +208 -0
  27. package/idea/Table2/Components/SetSortList.tsx +33 -0
  28. package/idea/Table2/Components/SetTableFilter.tsx +90 -0
  29. package/idea/Table2/Components/TableFooter.tsx +107 -0
  30. package/idea/Table2/Components/TableOptions.tsx +211 -0
  31. package/idea/Table2/Components/Templates/TemplateCreate.tsx +75 -0
  32. package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +45 -0
  33. package/idea/Table2/Components/Templates/TemplateList.tsx +167 -0
  34. package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +51 -0
  35. package/idea/Table2/Table.tsx +657 -0
  36. package/idea/Table2/_table.scss +300 -0
  37. package/idea/Table2/hooks/useDefaultTemplate.ts +22 -0
  38. package/idea/Table2/hooks/useTableKeyboard.ts +115 -0
  39. package/package.json +9 -4
  40. package/rollup.config.js +80 -0
  41. package/src/assets/icons/duotone/faCircleUser.ts +17 -0
  42. package/src/assets/icons/index.ts +20 -0
  43. package/src/assets/icons/light/faArrowDownShortWide.ts +15 -0
  44. package/src/assets/icons/light/faArrowDownWideShort.ts +15 -0
  45. package/src/assets/icons/light/faArrowUpArrowDown.ts +15 -0
  46. package/src/assets/icons/light/faArrowUpRightFromSquare.ts +15 -0
  47. package/src/assets/icons/light/faArrowsToLine.ts +15 -0
  48. package/src/assets/icons/light/faArrowsUpDown.ts +15 -0
  49. package/src/assets/icons/light/faCalendarPlus.ts +15 -0
  50. package/src/assets/icons/light/faCheck.ts +15 -0
  51. package/src/assets/icons/light/faChevronDown.ts +15 -0
  52. package/src/assets/icons/light/faChevronRight.ts +15 -0
  53. package/src/assets/icons/light/faCircleInfo.ts +15 -0
  54. package/src/assets/icons/light/faCircleXmark.ts +15 -0
  55. package/src/assets/icons/light/faClockRotateLeft.ts +15 -0
  56. package/src/assets/icons/light/faEllipsisVertical.ts +15 -0
  57. package/src/assets/icons/light/faEye.ts +15 -0
  58. package/src/assets/icons/light/faEyeSlash.ts +15 -0
  59. package/src/assets/icons/light/faFilter.ts +15 -0
  60. package/src/assets/icons/light/faGear.ts +15 -0
  61. package/src/assets/icons/light/faHouse.ts +15 -0
  62. package/src/assets/icons/light/faIdBadge.ts +15 -0
  63. package/src/assets/icons/light/faLineColumns.ts +15 -0
  64. package/src/assets/icons/light/faLink.ts +15 -0
  65. package/src/assets/icons/light/faMagnifyingGlass.ts +15 -0
  66. package/src/assets/icons/light/faPenField.ts +15 -0
  67. package/src/assets/icons/light/faPrint.ts +15 -0
  68. package/src/assets/icons/light/faQuestion.ts +15 -0
  69. package/src/assets/icons/light/faRotateRight.ts +15 -0
  70. package/src/assets/icons/light/faTrashCan.ts +15 -0
  71. package/src/assets/icons/light/faTriangleExclamation.ts +15 -0
  72. package/src/assets/icons/light/faXmark.ts +15 -0
  73. package/src/assets/icons/regular/faArrowLeft.ts +15 -0
  74. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +15 -0
  75. package/src/assets/icons/regular/faCircleCheck.ts +15 -0
  76. package/src/assets/icons/regular/faCircleExclamation.ts +15 -0
  77. package/src/assets/icons/regular/faCircleInfo.ts +15 -0
  78. package/src/assets/icons/regular/faFileArrowDown.ts +15 -0
  79. package/src/assets/icons/regular/faFilterCircleXmark.ts +15 -0
  80. package/src/assets/icons/regular/faTriangleExclamation.ts +15 -0
  81. package/src/assets/icons/solid/faAngleLeft.ts +15 -0
  82. package/src/assets/icons/solid/faAngleRight.ts +15 -0
  83. package/src/assets/icons/solid/faArrowDownWideShort.ts +15 -0
  84. package/src/assets/icons/solid/faCaretDown.ts +15 -0
  85. package/src/assets/icons/solid/faCheck.ts +15 -0
  86. package/src/assets/icons/solid/faEllipsisVertical.ts +15 -0
  87. package/src/assets/icons/solid/faFilter.ts +15 -0
  88. package/src/assets/icons/solid/faFloppyDisk.ts +15 -0
  89. package/src/assets/icons/solid/faGripDotsVertical.ts +15 -0
  90. package/src/assets/icons/solid/faListUl.ts +15 -0
  91. package/src/assets/icons/solid/faMagnifyingGlass.ts +15 -0
  92. package/src/assets/icons/solid/faMinus.ts +15 -0
  93. package/src/assets/icons/solid/faPlus.ts +15 -0
  94. package/src/assets/icons/solid/faPrint.ts +15 -0
  95. package/src/assets/icons/solid/faRotateRight.ts +15 -0
  96. package/src/assets/icons/solid/faXmark.ts +15 -0
  97. package/src/assets/images/logo/mts.svg +5703 -0
  98. package/src/assets/images/logo/paperless.svg +21 -0
  99. package/src/assets/images/logo/pismonosa.png +0 -0
  100. package/src/assets/images/not-found.svg +19 -0
  101. package/src/components/Accordions/Accordions.tsx +64 -0
  102. package/src/components/Alert/Alert.tsx +31 -0
  103. package/src/components/Badge/DotBadge.tsx +16 -0
  104. package/src/components/Badge/NotificationBadge.tsx +29 -0
  105. package/src/components/Badge/PillBadge.tsx +13 -0
  106. package/src/components/Button/Button.tsx +56 -0
  107. package/src/components/Button/IconButton.tsx +49 -0
  108. package/src/components/Dashboard/Dashboard.tsx +9 -0
  109. package/src/components/Dashboard/DashboardWidget.tsx +44 -0
  110. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +37 -0
  111. package/src/components/Dialog/DeleteItemDialog.tsx +52 -0
  112. package/src/components/Dialog/Dialog.tsx +226 -0
  113. package/src/components/Dialog/hooks/useDialogKeyboard.ts +41 -0
  114. package/src/components/Dialog/hooks/useDialogObserver.ts +21 -0
  115. package/src/components/Header/Components/ModuleSelect.tsx +55 -0
  116. package/src/components/Header/Components/UserMenu.tsx +52 -0
  117. package/src/components/Header/Header.tsx +31 -0
  118. package/src/components/Helper/Collapse.tsx +52 -0
  119. package/src/components/Inputs/Checkbox.tsx +53 -0
  120. package/src/components/Inputs/CurrencyInput.tsx +123 -0
  121. package/src/components/Inputs/DateInput/DateInput.tsx +177 -0
  122. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +154 -0
  123. package/src/components/Inputs/InputWrapper.tsx +90 -0
  124. package/src/components/Inputs/NumberInput.tsx +83 -0
  125. package/src/components/Inputs/PasswordInput.tsx +38 -0
  126. package/src/components/Inputs/Radio.tsx +59 -0
  127. package/src/components/Inputs/RadioGroup.tsx +48 -0
  128. package/src/components/Inputs/RadioLarge.tsx +39 -0
  129. package/src/components/Inputs/SearchInput.tsx +40 -0
  130. package/src/components/Inputs/Select2/Select.tsx +224 -0
  131. package/src/components/Inputs/Select2/select.scss +43 -0
  132. package/src/components/Inputs/Selects/Select.tsx +17 -0
  133. package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +19 -0
  134. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +126 -0
  135. package/src/components/Inputs/Selects/utils/selectStyles.ts +104 -0
  136. package/src/components/Inputs/TextAreaInput.tsx +67 -0
  137. package/src/components/Inputs/TextInput.tsx +98 -0
  138. package/src/components/Inputs/TimeInput/TimeInput.tsx +81 -0
  139. package/src/components/Loader/Loader.tsx +53 -0
  140. package/src/components/Menu/Menu.tsx +68 -0
  141. package/src/components/Menu/MenuItem.tsx +47 -0
  142. package/src/components/Menu/NewMenu.tsx +66 -0
  143. package/src/components/Menu/hooks/useMenuPosition.tsx +80 -0
  144. package/src/components/Pullover/Pullover.tsx +89 -0
  145. package/src/components/Router/Router.tsx +51 -0
  146. package/src/components/Sidebar/AddButton.tsx +22 -0
  147. package/src/components/Sidebar/Sidebar.tsx +81 -0
  148. package/src/components/Sidebar/SidebarItem.tsx +84 -0
  149. package/src/components/Sidebar/types/ISidebar.ts +28 -0
  150. package/src/components/Table/Components/Columns/ColumnsList.tsx +61 -0
  151. package/src/components/Table/Components/Columns/SetColumnsList.tsx +113 -0
  152. package/src/components/Table/Components/Edit/ItemActionsMenu.tsx +84 -0
  153. package/src/components/Table/Components/Edit/ItemEditOptionsButtons.tsx +31 -0
  154. package/src/components/Table/Components/Edit/TableEditRow.tsx +56 -0
  155. package/src/components/Table/Components/FilterItem.tsx +20 -0
  156. package/src/components/Table/Components/Header/TableHeader.tsx +45 -0
  157. package/src/components/Table/Components/Header/TableHeaderRow.tsx +37 -0
  158. package/src/components/Table/Components/Print/CustomTablePrint.tsx +114 -0
  159. package/src/components/Table/Components/Print/TablePrint.tsx +207 -0
  160. package/src/components/Table/Components/SetSortList.tsx +30 -0
  161. package/src/components/Table/Components/SetTableFilter.tsx +90 -0
  162. package/src/components/Table/Components/TableFooter.tsx +135 -0
  163. package/src/components/Table/Components/TableOptions.tsx +226 -0
  164. package/src/components/Table/Components/Templates/TemplateCreate.tsx +80 -0
  165. package/src/components/Table/Components/Templates/TemplateCreateDefault.tsx +45 -0
  166. package/src/components/Table/Components/Templates/TemplateList.tsx +167 -0
  167. package/src/components/Table/Components/Templates/repo/TemplateRepo.ts +53 -0
  168. package/src/components/Table/Table.tsx +527 -0
  169. package/src/components/Table/hooks/useDefaultTemplate.ts +20 -0
  170. package/src/components/Table/hooks/useTableKeyboard.ts +138 -0
  171. package/src/components/Table/hooks/useTableSelect.ts +11 -0
  172. package/src/components/Tabs/Tabs.tsx +66 -0
  173. package/src/components/Tooltip/Tooltip.tsx +133 -0
  174. package/src/components/Tree/Tree.tsx +22 -0
  175. package/src/components/Tree/TreeItem.tsx +56 -0
  176. package/src/components/Wrappers/AppLayout.tsx +17 -0
  177. package/src/components/Wrappers/ConditionalWrapper.tsx +10 -0
  178. package/src/components/Wrappers/FormWrapper.tsx +81 -0
  179. package/src/components/Wrappers/PageLayout.tsx +152 -0
  180. package/src/hooks/useBackgroundClose.ts +18 -0
  181. package/src/hooks/useIsMenuOpen.ts +11 -0
  182. package/src/hooks/useOnEsc.ts +14 -0
  183. package/src/hooks/useZendesk.ts +21 -0
  184. package/src/index.ts +324 -0
  185. package/src/pages/NoAccessPage.tsx +27 -0
  186. package/src/pages/NotFoundPage.tsx +26 -0
  187. package/src/styles/App.scss +43 -0
  188. package/src/styles/common/_animations.scss +64 -0
  189. package/src/styles/common/_typography.scss +88 -0
  190. package/src/styles/common/helpers/_base.scss +55 -0
  191. package/src/styles/common/helpers/_color.scss +7 -0
  192. package/src/styles/common/helpers/_display.scss +85 -0
  193. package/src/styles/common/helpers/_size.scss +25 -0
  194. package/src/styles/common/maps/_align.scss +21 -0
  195. package/src/styles/common/maps/_info-types.scss +1 -0
  196. package/src/styles/common/maps/_spacing.scss +78 -0
  197. package/src/styles/common/maps/_text.scss +14 -0
  198. package/src/styles/components/_accordions.scss +46 -0
  199. package/src/styles/components/_alert.scss +23 -0
  200. package/src/styles/components/_badge.scss +76 -0
  201. package/src/styles/components/_button.scss +138 -0
  202. package/src/styles/components/_card.scss +24 -0
  203. package/src/styles/components/_dialog.scss +111 -0
  204. package/src/styles/components/_form.scss +8 -0
  205. package/src/styles/components/_header.scss +109 -0
  206. package/src/styles/components/_input.scss +158 -0
  207. package/src/styles/components/_inputCheckbox.scss +105 -0
  208. package/src/styles/components/_inputDateTime.scss +161 -0
  209. package/src/styles/components/_inputRadio.scss +83 -0
  210. package/src/styles/components/_inputSelect.scss +6 -0
  211. package/src/styles/components/_loader.scss +44 -0
  212. package/src/styles/components/_menu-v2.scss +67 -0
  213. package/src/styles/components/_menu.scss +53 -0
  214. package/src/styles/components/_page.scss +62 -0
  215. package/src/styles/components/_portal.scss +8 -0
  216. package/src/styles/components/_print.scss +87 -0
  217. package/src/styles/components/_pullover.scss +43 -0
  218. package/src/styles/components/_scrollbar.scss +18 -0
  219. package/src/styles/components/_sidebar.scss +206 -0
  220. package/src/styles/components/_smallComponents.scss +23 -0
  221. package/src/styles/components/_table.scss +270 -0
  222. package/src/styles/components/_tabs.scss +33 -0
  223. package/src/styles/components/_tooltip.scss +48 -0
  224. package/src/styles/components/_tree.scss +21 -0
  225. package/src/styles/components/_widget.scss +90 -0
  226. package/src/styles/pages/_fullScreenPage.scss +64 -0
  227. package/src/styles/variables/_bp.scss +5 -0
  228. package/src/styles/variables/_variables.scss +130 -0
  229. package/src/types/Base/custom.d.ts +9 -0
  230. package/src/types/IBasic.ts +31 -0
  231. package/src/types/IError.ts +5 -0
  232. package/src/types/IHeader.ts +34 -0
  233. package/src/types/IInfo.ts +1 -0
  234. package/src/types/IKeyboard.ts +37 -0
  235. package/src/types/IMenu.ts +18 -0
  236. package/src/types/IRouter.ts +6 -0
  237. package/src/types/ISelect.ts +52 -0
  238. package/src/types/ITab.ts +10 -0
  239. package/src/types/ITable.ts +249 -0
  240. package/src/types/ITree.ts +6 -0
  241. package/src/utils/DateUtils.ts +32 -0
  242. package/src/utils/InputPatternValidation.ts +12 -0
  243. package/src/utils/LocalStorageHelper.ts +24 -0
  244. package/src/utils/NumberUtils.ts +21 -0
  245. package/src/utils/ObjectUtils.ts +85 -0
  246. package/src/utils/RootDir.ts +1 -0
  247. package/src/utils/StringUtils.ts +18 -0
  248. package/src/utils/TableUtils.ts +130 -0
  249. package/src/utils/Toasts.ts +6 -0
  250. package/src/utils/UrlUtils.ts +4 -0
  251. package/src/utils/fileUtils.ts +176 -0
  252. package/src/utils/i18n/i18nIUICyrilic.ts +90 -0
  253. package/src/utils/i18n/i18nIUILatin.ts +90 -0
  254. package/src/utils/i18n/i18nIUIMe.ts +88 -0
  255. package/src/utils/icons.ts +13 -0
  256. package/tsconfig.icons.json +5 -0
  257. package/tsconfig.json +19 -0
@@ -0,0 +1,66 @@
1
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
+ import clsx from 'clsx';
3
+ import { FC, useMemo, useState } from 'react';
4
+ import { ITab } from '../../types/ITab';
5
+
6
+ interface Props {
7
+ tabs: ITab[];
8
+ initialValue?: string;
9
+ control?: {
10
+ value: string;
11
+ setValue: (value: string) => void;
12
+ };
13
+ onChange?: (value: string) => void;
14
+ noWrap?: boolean;
15
+ className?: string;
16
+ classNameContent?: string;
17
+ }
18
+
19
+ export const Tabs: FC<Props> = ({
20
+ tabs,
21
+ initialValue,
22
+ control,
23
+ onChange,
24
+ noWrap,
25
+ className,
26
+ classNameContent,
27
+ }) => {
28
+ const filteredTabs = useMemo(() => tabs.filter(e => !e.hidden), [tabs]);
29
+
30
+ const [selected, setSelected] = useState(initialValue || filteredTabs[0].value);
31
+
32
+ const activeTab = filteredTabs.find(tab => (control?.value || selected) === tab.value);
33
+
34
+ return filteredTabs.length > 0 ? (
35
+ <div className={className}>
36
+ <div className="iui-tabs">
37
+ {filteredTabs.map(tab => (
38
+ <div
39
+ key={tab.value}
40
+ className={clsx('iui-tab clickable', {
41
+ selected: (control?.value || selected) === tab.value,
42
+ disabled: tab.disabled,
43
+ 'no-wrap': noWrap,
44
+ })}
45
+ onClick={
46
+ tab.disabled
47
+ ? undefined
48
+ : () => {
49
+ !!control ? control.setValue(tab.value) : setSelected(tab.value);
50
+ onChange?.(tab.value);
51
+ }
52
+ }
53
+ >
54
+ {tab.icon && <FontAwesomeIcon icon={tab.icon} />}
55
+ {tab.label}
56
+ </div>
57
+ ))}
58
+ </div>
59
+ {activeTab && (
60
+ <div key={activeTab.value} className={clsx('iui-tab-content', classNameContent)}>
61
+ {activeTab.component}
62
+ </div>
63
+ )}
64
+ </div>
65
+ ) : null;
66
+ };
@@ -0,0 +1,133 @@
1
+ import clsx from 'clsx';
2
+ import {
3
+ cloneElement,
4
+ Dispatch,
5
+ FC,
6
+ ReactElement,
7
+ Ref,
8
+ SetStateAction,
9
+ useEffect,
10
+ useRef,
11
+ useState,
12
+ } from 'react';
13
+ import { createPortal } from 'react-dom';
14
+ import { rootDir } from '../../utils/RootDir';
15
+
16
+ export type TooltipPosition = 'left' | 'right' | 'top' | 'bottom';
17
+
18
+ interface Props {
19
+ label?: string;
20
+ position?: TooltipPosition;
21
+ disabled?: boolean;
22
+ singleLine?: boolean;
23
+ className?: string;
24
+ children: ReactElement;
25
+ ref?: Ref<HTMLElement> | null;
26
+ }
27
+
28
+ export const Tooltip: FC<Props> = ({
29
+ label,
30
+ position = 'top',
31
+ disabled,
32
+ singleLine,
33
+ className,
34
+ children,
35
+ ref,
36
+ }) => {
37
+ const [newPosition, setNewPosition] = useState<TooltipPosition | ''>('');
38
+
39
+ const internalRef = useRef<HTMLElement>(null);
40
+ const tooltipRef = useRef<HTMLDivElement>(null);
41
+
42
+ useEffect(() => {
43
+ if (!disabled && !!label) {
44
+ const getContainer = () => {
45
+ if (ref && 'current' in ref) {
46
+ return ref.current;
47
+ }
48
+ return internalRef.current;
49
+ };
50
+
51
+ const container = getContainer();
52
+ const tooltip = tooltipRef.current;
53
+
54
+ const onMouseEnter = () => {
55
+ if (container && tooltip) {
56
+ setAbsolutePosition(container, tooltip, position, setNewPosition);
57
+ tooltip.classList.add('visible');
58
+ }
59
+ };
60
+ const onMouseLeave = () => tooltip?.classList.remove('visible');
61
+
62
+ if (container) {
63
+ container.addEventListener('mouseenter', onMouseEnter);
64
+ container.addEventListener('mouseleave', onMouseLeave);
65
+
66
+ return () => {
67
+ container.removeEventListener('mouseenter', onMouseEnter);
68
+ container.removeEventListener('mouseleave', onMouseLeave);
69
+ };
70
+ }
71
+ }
72
+ }, [disabled, label, position, ref]);
73
+
74
+ return !!label && !disabled ? (
75
+ <>
76
+ {/* @ts-ignore */}
77
+ {cloneElement(children, { ref: ref || internalRef })}
78
+ {createPortal(
79
+ <div
80
+ ref={tooltipRef}
81
+ className={clsx('tooltip-container', className, {
82
+ 'no-wrap': singleLine,
83
+ })}
84
+ >
85
+ <div className="tooltip">
86
+ <div className={clsx('arrow', newPosition || position)} />
87
+ <div>{label}</div>
88
+ </div>
89
+ </div>,
90
+ rootDir
91
+ )}
92
+ </>
93
+ ) : (
94
+ children
95
+ );
96
+ };
97
+
98
+ const setAbsolutePosition = (
99
+ containerEl: HTMLElement,
100
+ targetEl: HTMLDivElement,
101
+ position: TooltipPosition,
102
+ setNewPosition: Dispatch<SetStateAction<TooltipPosition | ''>>
103
+ ) => {
104
+ const containerRect = containerEl.getBoundingClientRect();
105
+ const tooltipRect = targetEl.getBoundingClientRect();
106
+
107
+ if (position === 'bottom' || position === 'top') {
108
+ const bottom = Math.floor(containerRect.bottom + 16);
109
+ const top = Math.floor(containerRect.top - tooltipRect.height - 16);
110
+ const leftCenter = Math.floor(
111
+ containerRect.left + containerRect.width / 2 - tooltipRect.width / 2
112
+ );
113
+ const reverse =
114
+ position === 'top' ? top < 0 : bottom + tooltipRect.height > window.innerHeight;
115
+
116
+ setNewPosition(reverse ? (position === 'bottom' ? 'top' : 'bottom') : '');
117
+
118
+ targetEl.style.top = `${
119
+ position === 'bottom' ? (reverse ? top : bottom) : reverse ? bottom : top
120
+ }px`;
121
+ targetEl.style.left = `${leftCenter}px`;
122
+ } else if (position === 'right') {
123
+ targetEl.style.top =
124
+ Math.floor(containerRect.top + containerRect.height / 2 - tooltipRect.height / 2) +
125
+ 'px';
126
+ targetEl.style.left = Math.floor(containerRect.right + 16) + 'px';
127
+ } else if (position === 'left') {
128
+ targetEl.style.top =
129
+ Math.floor(containerRect.top + containerRect.height / 2 - tooltipRect.height / 2) +
130
+ 'px';
131
+ targetEl.style.left = Math.floor(containerRect.left - tooltipRect.width - 16) + 'px';
132
+ }
133
+ };
@@ -0,0 +1,22 @@
1
+ import { FC } from 'react';
2
+ import { TreeItem } from './TreeItem';
3
+ import { ITreeItem } from '../../types/ITree';
4
+
5
+ interface Props {
6
+ data: ITreeItem[];
7
+ selectedItemUuid?: string;
8
+ onClick: (itemUuid: string) => void;
9
+ }
10
+
11
+ export const Tree: FC<Props> = ({ data, selectedItemUuid, onClick }) => (
12
+ <div>
13
+ {data.map(item => (
14
+ <TreeItem
15
+ key={item.uuid}
16
+ item={item}
17
+ onClick={onClick}
18
+ selectedItemUuid={selectedItemUuid}
19
+ />
20
+ ))}
21
+ </div>
22
+ );
@@ -0,0 +1,56 @@
1
+ import { FC, useState } from 'react';
2
+ import { ITreeItem } from '../../types/ITree';
3
+ import clsx from 'clsx';
4
+ import { IconButton } from '../Button/IconButton';
5
+ import { Collapse } from '../Helper/Collapse';
6
+ import { faChevronRight } from '../../assets/icons';
7
+
8
+ interface Props {
9
+ item: ITreeItem;
10
+ onClick: (itemUuid: string) => void;
11
+ selectedItemUuid?: string;
12
+ className?: string;
13
+ }
14
+
15
+ export const TreeItem: FC<Props> = ({ item, onClick, selectedItemUuid, className }) => {
16
+ const [isOpen, setIsOpen] = useState(false);
17
+
18
+ const hasChildren = !!item.children?.length;
19
+ return (
20
+ <div className={clsx('tree-item', className)}>
21
+ <div className="flex align-center">
22
+ <div className="extendable-icon">
23
+ {hasChildren && (
24
+ <IconButton
25
+ icon={faChevronRight}
26
+ onClick={() => setIsOpen(!isOpen)}
27
+ size="s"
28
+ className={clsx('rotate', { rotate90: isOpen })}
29
+ />
30
+ )}
31
+ </div>
32
+ <div
33
+ className={clsx('tree-item-name clickable', {
34
+ active: selectedItemUuid === item.uuid,
35
+ })}
36
+ onClick={() => onClick(item.uuid)}
37
+ >
38
+ {item.name}
39
+ </div>
40
+ </div>
41
+ {hasChildren && (
42
+ <Collapse isOpen={isOpen}>
43
+ {item.children?.map((child: ITreeItem) => (
44
+ <TreeItem
45
+ key={child.uuid}
46
+ item={child}
47
+ onClick={onClick}
48
+ className={clsx('ml-3', className)}
49
+ selectedItemUuid={selectedItemUuid}
50
+ />
51
+ ))}
52
+ </Collapse>
53
+ )}
54
+ </div>
55
+ );
56
+ };
@@ -0,0 +1,17 @@
1
+ import { ComponentProps, FC, ReactNode } from 'react';
2
+ import { Header } from '../Header/Header';
3
+ import { Sidebar } from '../Sidebar/Sidebar';
4
+
5
+ interface Props {
6
+ header: ComponentProps<typeof Header>;
7
+ sidebar: ComponentProps<typeof Sidebar>;
8
+ children: ReactNode;
9
+ }
10
+
11
+ export const AppLayout: FC<Props> = ({ header, sidebar, children }) => (
12
+ <div className="app-layout">
13
+ <Header {...header} />
14
+ <Sidebar {...sidebar} />
15
+ <div className="app-content">{children}</div>
16
+ </div>
17
+ );
@@ -0,0 +1,10 @@
1
+ import { FC, ReactNode } from 'react';
2
+
3
+ interface Props {
4
+ condition: boolean;
5
+ wrapper: (children: ReactNode) => ReactNode;
6
+ children: ReactNode;
7
+ }
8
+
9
+ export const ConditionalWrapper: FC<Props> = ({ condition, wrapper, children }) =>
10
+ condition ? wrapper(children) : children;
@@ -0,0 +1,81 @@
1
+ import { FC, FormEvent, ReactNode } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Button, IButtonColor, IButtonVariant } from '../Button/Button';
4
+ import { Loader } from '../Loader/Loader';
5
+
6
+ export interface IFormWrapper {
7
+ isLoading: boolean;
8
+ className?: string;
9
+ submitButton: {
10
+ label?: string;
11
+ icon?: any;
12
+ disabled?: boolean;
13
+ onSubmit: (e: FormEvent<HTMLFormElement>) => void;
14
+ variant?: IButtonVariant;
15
+ color?: IButtonColor;
16
+ };
17
+ otherButtons?: {
18
+ label: string;
19
+ icon?: any;
20
+ onClick: () => void;
21
+ variant?: IButtonVariant;
22
+ color?: IButtonColor;
23
+ disabled?: boolean;
24
+ hidden?: boolean;
25
+ }[];
26
+ noAccess?: boolean;
27
+ children: ReactNode;
28
+ }
29
+
30
+ export const FormWrapper: FC<IFormWrapper> = ({
31
+ isLoading,
32
+ noAccess,
33
+ submitButton,
34
+ otherButtons,
35
+ className,
36
+ children,
37
+ }) => {
38
+ const { t } = useTranslation();
39
+
40
+ return (
41
+ <Loader isLoading={isLoading}>
42
+ <form
43
+ className={className}
44
+ onSubmit={e => {
45
+ e.preventDefault();
46
+ e.stopPropagation();
47
+ !submitButton.disabled && submitButton.onSubmit(e);
48
+ }}
49
+ >
50
+ {children}
51
+ {(!noAccess || otherButtons) && (
52
+ <div className="iui-form-actions">
53
+ {otherButtons?.map(
54
+ e =>
55
+ !e.hidden && (
56
+ <Button
57
+ key={e.label}
58
+ label={e.label}
59
+ icon={e.icon}
60
+ disabled={isLoading || e.disabled}
61
+ variant={e.variant}
62
+ color={e.color}
63
+ onClick={e.onClick}
64
+ />
65
+ )
66
+ )}
67
+ {!noAccess && (
68
+ <Button
69
+ label={submitButton.label ?? t('Save')}
70
+ icon={submitButton.icon}
71
+ disabled={isLoading || submitButton.disabled}
72
+ variant={submitButton.variant}
73
+ color={submitButton.color}
74
+ />
75
+ )}
76
+ </div>
77
+ )}
78
+ </form>
79
+ </Loader>
80
+ );
81
+ };
@@ -0,0 +1,152 @@
1
+ import { FC, ReactNode, useLayoutEffect, useState } from 'react';
2
+ import { IHeaderAction } from '../../types/IHeader';
3
+ import { Button } from '../Button/Button';
4
+ import { Loader } from '../Loader/Loader';
5
+ import { ConditionalWrapper } from './ConditionalWrapper';
6
+ import { IconButton } from '../Button/IconButton';
7
+ import { faArrowLeft } from '../../assets/icons/regular/faArrowLeft';
8
+ import { faEllipsisVertical, faQuestion } from '../../assets/icons';
9
+ import { Trans } from 'react-i18next';
10
+ import { Pullover } from '../Pullover/Pullover';
11
+ import { Alert } from '../Alert/Alert';
12
+ import { Link, useNavigate } from 'react-router';
13
+ import { IMenuItem } from '../../types/IMenu';
14
+ import { Menu } from '../Menu/Menu';
15
+
16
+ export interface IPageLayoutProps {
17
+ breadcrumbs?: (string | undefined)[];
18
+ actions?: IHeaderAction[];
19
+ moreActions?: IMenuItem[];
20
+ backButton?: {
21
+ url?: string;
22
+ active: boolean;
23
+ };
24
+ help?: {
25
+ title: string;
26
+ descEl: ReactNode;
27
+ };
28
+ noAccess?: boolean;
29
+ isInitiallyLoading?: boolean;
30
+ isLoading?: boolean;
31
+ children?: ReactNode;
32
+ }
33
+
34
+ export const PageLayout: FC<IPageLayoutProps> = ({
35
+ breadcrumbs,
36
+ actions,
37
+ moreActions,
38
+ backButton,
39
+ help,
40
+ noAccess,
41
+ isLoading,
42
+ isInitiallyLoading,
43
+ children,
44
+ }) => {
45
+ const [isMoreActionsOpen, setIsMoreActionsOpen] = useState(false);
46
+ const [isHelpOpen, setIsHelpOpen] = useState(false);
47
+
48
+ const navigate = useNavigate();
49
+ const filteredActions = moreActions?.filter(e => !e.hidden);
50
+
51
+ useLayoutEffect(() => {
52
+ noAccess && navigate('/no-access', { replace: true });
53
+ }, [noAccess, navigate]);
54
+
55
+ if (noAccess) {
56
+ return null;
57
+ }
58
+
59
+ return isInitiallyLoading ? (
60
+ <Loader isLoading isFullPage />
61
+ ) : (
62
+ <Loader isLoading={!!isLoading}>
63
+ <div className="page-container">
64
+ {breadcrumbs && (
65
+ <div className="page-header">
66
+ <div className="flex align-center gap-2">
67
+ {backButton?.active && (
68
+ <IconButton
69
+ icon={faArrowLeft}
70
+ onClick={() =>
71
+ backButton.url ? navigate(backButton.url) : navigate(-1)
72
+ }
73
+ // outlined
74
+ // size="s"
75
+ />
76
+ )}
77
+ {/* ////// BREADCRUMBS ////// */}
78
+ <h3 className="breadcrumbs">
79
+ {breadcrumbs.reduce(
80
+ (acc: string, e) => (e ? (acc ? `${acc} / ${e}` : e) : acc),
81
+ ''
82
+ )}
83
+ </h3>
84
+ </div>
85
+ {/* ////// ACTIONS ////// */}
86
+ <div className="flex align-center gap-2">
87
+ {help && (
88
+ <>
89
+ <IconButton
90
+ icon={faQuestion}
91
+ onClick={() => setIsHelpOpen(!isHelpOpen)}
92
+ variant="outlined"
93
+ size="s"
94
+ />
95
+ <Pullover
96
+ isOpen={isHelpOpen}
97
+ onClose={() => setIsHelpOpen(false)}
98
+ size="m"
99
+ >
100
+ <Alert severity="info">
101
+ <div>
102
+ <p className="bold mb-3">{help.title}</p>
103
+ <p>{help.descEl}</p>
104
+ </div>
105
+ </Alert>
106
+ </Pullover>
107
+ </>
108
+ )}
109
+ {!!filteredActions?.length && (
110
+ <Menu
111
+ // id="page-more-actions"
112
+ isOpen={isMoreActionsOpen}
113
+ onClose={() => setIsMoreActionsOpen(false)}
114
+ placement="bottom-right"
115
+ renderButton={ref => (
116
+ <IconButton
117
+ ref={ref}
118
+ icon={faEllipsisVertical}
119
+ active={isMoreActionsOpen}
120
+ onClick={() => setIsMoreActionsOpen(!isMoreActionsOpen)}
121
+ variant="outlined"
122
+ size="s"
123
+ />
124
+ )}
125
+ items={filteredActions}
126
+ />
127
+ )}
128
+ {actions?.map(
129
+ action =>
130
+ !action.hidden && (
131
+ <ConditionalWrapper
132
+ key={action.label}
133
+ condition={!!action.to}
134
+ wrapper={children => <Link to={action.to!}>{children}</Link>}
135
+ >
136
+ <Button key={action.label} {...action} className="ml-2" />
137
+ </ConditionalWrapper>
138
+ )
139
+ )}
140
+ </div>
141
+ </div>
142
+ )}
143
+ <div className="page-content">
144
+ <div className="flex-grow">{children}</div>
145
+ <p className="footer">
146
+ <Trans i18nKey="FooterText" />
147
+ </p>
148
+ </div>
149
+ </div>
150
+ </Loader>
151
+ );
152
+ };
@@ -0,0 +1,18 @@
1
+ import { RefObject, useEffect } from 'react';
2
+
3
+ interface Props {
4
+ disabled?: boolean;
5
+ portalRef: RefObject<HTMLDivElement | null>;
6
+ handleClose: () => void;
7
+ }
8
+
9
+ export const useBackgroundClose = ({ portalRef, disabled, handleClose }: Props) => {
10
+ useEffect(() => {
11
+ if (!disabled) {
12
+ const portal = portalRef.current;
13
+ const handleClick = (ev: MouseEvent) => ev.target === portal && handleClose();
14
+ portal?.addEventListener('click', handleClick);
15
+ return () => portal?.removeEventListener('click', handleClick);
16
+ }
17
+ }, [portalRef, disabled, handleClose]);
18
+ };
@@ -0,0 +1,11 @@
1
+ import { useState } from 'react';
2
+
3
+ export const useIsMenuOpen = () => {
4
+ const [isOpen, setIsOpen] = useState(false);
5
+
6
+ return {
7
+ isMenuOpen: isOpen,
8
+ onMenuOpen: () => setIsOpen(true),
9
+ onMenuClose: () => setTimeout(() => setIsOpen(false)),
10
+ };
11
+ };
@@ -0,0 +1,14 @@
1
+ import { useEffect } from 'react';
2
+
3
+ export const useOnEsc = (onEsc: () => void, disabled?: boolean) => {
4
+ useEffect(() => {
5
+ if (!disabled) {
6
+ const onEscPress = (e: KeyboardEvent) => {
7
+ e.code === 'Escape' && onEsc();
8
+ };
9
+
10
+ document.body.addEventListener('keyup', onEscPress);
11
+ return () => document.body.removeEventListener('keyup', onEscPress);
12
+ }
13
+ }, [onEsc, disabled]);
14
+ };
@@ -0,0 +1,21 @@
1
+ import { useEffect } from 'react';
2
+
3
+ declare global {
4
+ var zE: {
5
+ show: () => void;
6
+ hide: () => void;
7
+ activate: () => void;
8
+ setLocale: (locale: string) => void;
9
+ };
10
+ }
11
+
12
+ export const useHideZendesk = () => {
13
+ useEffect(() => {
14
+ const zendesk = window.zE ?? null;
15
+ if (zendesk) {
16
+ // zendesk.setLocale('sr');
17
+ zendesk.hide();
18
+ return () => zendesk.show();
19
+ }
20
+ }, []);
21
+ };