@inceptionbg/iui 2.0.5 → 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 (253) hide show
  1. package/dist/icons/index.d.ts +43 -0
  2. package/dist/icons/index.js +1 -0
  3. package/dist/index.d.ts +24 -15
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/iui.css +1 -1
  7. package/idea/Menu/Menu.tsx +119 -0
  8. package/idea/Menu/MenuItem.tsx +74 -0
  9. package/idea/Menu/hooks/useMenuControl.ts +13 -0
  10. package/idea/Menu.tsx +132 -0
  11. package/idea/NoAccessInfo.tsx +193 -0
  12. package/idea/Notifications.tsx +245 -0
  13. package/idea/Table2/Components/Columns/ColumnsList.tsx +56 -0
  14. package/idea/Table2/Components/Columns/SetColumnsList.tsx +107 -0
  15. package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +87 -0
  16. package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +32 -0
  17. package/idea/Table2/Components/Edit/TableEditRow.tsx +56 -0
  18. package/idea/Table2/Components/FilterItem.tsx +20 -0
  19. package/idea/Table2/Components/Header/TableHeader.tsx +35 -0
  20. package/idea/Table2/Components/Header/TableHeaderRow.tsx +37 -0
  21. package/idea/Table2/Components/Print/CustomTablePrint.tsx +119 -0
  22. package/idea/Table2/Components/Print/TablePrint.tsx +208 -0
  23. package/idea/Table2/Components/SetSortList.tsx +33 -0
  24. package/idea/Table2/Components/SetTableFilter.tsx +90 -0
  25. package/idea/Table2/Components/TableFooter.tsx +107 -0
  26. package/idea/Table2/Components/TableOptions.tsx +211 -0
  27. package/idea/Table2/Components/Templates/TemplateCreate.tsx +75 -0
  28. package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +45 -0
  29. package/idea/Table2/Components/Templates/TemplateList.tsx +167 -0
  30. package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +51 -0
  31. package/idea/Table2/Table.tsx +657 -0
  32. package/idea/Table2/_table.scss +300 -0
  33. package/idea/Table2/hooks/useDefaultTemplate.ts +22 -0
  34. package/idea/Table2/hooks/useTableKeyboard.ts +115 -0
  35. package/package.json +8 -4
  36. package/rollup.config.js +80 -0
  37. package/src/assets/icons/duotone/faCircleUser.ts +17 -0
  38. package/src/assets/icons/index.ts +20 -0
  39. package/src/assets/icons/light/faArrowDownShortWide.ts +15 -0
  40. package/src/assets/icons/light/faArrowDownWideShort.ts +15 -0
  41. package/src/assets/icons/light/faArrowUpArrowDown.ts +15 -0
  42. package/src/assets/icons/light/faArrowUpRightFromSquare.ts +15 -0
  43. package/src/assets/icons/light/faArrowsToLine.ts +15 -0
  44. package/src/assets/icons/light/faArrowsUpDown.ts +15 -0
  45. package/src/assets/icons/light/faCalendarPlus.ts +15 -0
  46. package/src/assets/icons/light/faCheck.ts +15 -0
  47. package/src/assets/icons/light/faChevronDown.ts +15 -0
  48. package/src/assets/icons/light/faChevronRight.ts +15 -0
  49. package/src/assets/icons/light/faCircleInfo.ts +15 -0
  50. package/src/assets/icons/light/faCircleXmark.ts +15 -0
  51. package/src/assets/icons/light/faClockRotateLeft.ts +15 -0
  52. package/src/assets/icons/light/faEllipsisVertical.ts +15 -0
  53. package/src/assets/icons/light/faEye.ts +15 -0
  54. package/src/assets/icons/light/faEyeSlash.ts +15 -0
  55. package/src/assets/icons/light/faFilter.ts +15 -0
  56. package/src/assets/icons/light/faGear.ts +15 -0
  57. package/src/assets/icons/light/faHouse.ts +15 -0
  58. package/src/assets/icons/light/faIdBadge.ts +15 -0
  59. package/src/assets/icons/light/faLineColumns.ts +15 -0
  60. package/src/assets/icons/light/faLink.ts +15 -0
  61. package/src/assets/icons/light/faMagnifyingGlass.ts +15 -0
  62. package/src/assets/icons/light/faPenField.ts +15 -0
  63. package/src/assets/icons/light/faPrint.ts +15 -0
  64. package/src/assets/icons/light/faQuestion.ts +15 -0
  65. package/src/assets/icons/light/faRotateRight.ts +15 -0
  66. package/src/assets/icons/light/faTrashCan.ts +15 -0
  67. package/src/assets/icons/light/faTriangleExclamation.ts +15 -0
  68. package/src/assets/icons/light/faXmark.ts +15 -0
  69. package/src/assets/icons/regular/faArrowLeft.ts +15 -0
  70. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +15 -0
  71. package/src/assets/icons/regular/faCircleCheck.ts +15 -0
  72. package/src/assets/icons/regular/faCircleExclamation.ts +15 -0
  73. package/src/assets/icons/regular/faCircleInfo.ts +15 -0
  74. package/src/assets/icons/regular/faFileArrowDown.ts +15 -0
  75. package/src/assets/icons/regular/faFilterCircleXmark.ts +15 -0
  76. package/src/assets/icons/regular/faTriangleExclamation.ts +15 -0
  77. package/src/assets/icons/solid/faAngleLeft.ts +15 -0
  78. package/src/assets/icons/solid/faAngleRight.ts +15 -0
  79. package/src/assets/icons/solid/faArrowDownWideShort.ts +15 -0
  80. package/src/assets/icons/solid/faCaretDown.ts +15 -0
  81. package/src/assets/icons/solid/faCheck.ts +15 -0
  82. package/src/assets/icons/solid/faEllipsisVertical.ts +15 -0
  83. package/src/assets/icons/solid/faFilter.ts +15 -0
  84. package/src/assets/icons/solid/faFloppyDisk.ts +15 -0
  85. package/src/assets/icons/solid/faGripDotsVertical.ts +15 -0
  86. package/src/assets/icons/solid/faListUl.ts +15 -0
  87. package/src/assets/icons/solid/faMagnifyingGlass.ts +15 -0
  88. package/src/assets/icons/solid/faMinus.ts +15 -0
  89. package/src/assets/icons/solid/faPlus.ts +15 -0
  90. package/src/assets/icons/solid/faPrint.ts +15 -0
  91. package/src/assets/icons/solid/faRotateRight.ts +15 -0
  92. package/src/assets/icons/solid/faXmark.ts +15 -0
  93. package/src/assets/images/logo/mts.svg +5703 -0
  94. package/src/assets/images/logo/paperless.svg +21 -0
  95. package/src/assets/images/logo/pismonosa.png +0 -0
  96. package/src/assets/images/not-found.svg +19 -0
  97. package/src/components/Accordions/Accordions.tsx +64 -0
  98. package/src/components/Alert/Alert.tsx +31 -0
  99. package/src/components/Badge/DotBadge.tsx +16 -0
  100. package/src/components/Badge/NotificationBadge.tsx +29 -0
  101. package/src/components/Badge/PillBadge.tsx +13 -0
  102. package/src/components/Button/Button.tsx +56 -0
  103. package/src/components/Button/IconButton.tsx +49 -0
  104. package/src/components/Dashboard/Dashboard.tsx +9 -0
  105. package/src/components/Dashboard/DashboardWidget.tsx +44 -0
  106. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +37 -0
  107. package/src/components/Dialog/DeleteItemDialog.tsx +52 -0
  108. package/src/components/Dialog/Dialog.tsx +226 -0
  109. package/src/components/Dialog/hooks/useDialogKeyboard.ts +41 -0
  110. package/src/components/Dialog/hooks/useDialogObserver.ts +21 -0
  111. package/src/components/Header/Components/ModuleSelect.tsx +55 -0
  112. package/src/components/Header/Components/UserMenu.tsx +44 -0
  113. package/src/components/Header/Header.tsx +36 -0
  114. package/src/components/Helper/Collapse.tsx +52 -0
  115. package/src/components/Inputs/Checkbox.tsx +53 -0
  116. package/src/components/Inputs/CurrencyInput.tsx +123 -0
  117. package/src/components/Inputs/DateInput/DateInput.tsx +176 -0
  118. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +154 -0
  119. package/src/components/Inputs/InputWrapper.tsx +90 -0
  120. package/src/components/Inputs/NumberInput.tsx +83 -0
  121. package/src/components/Inputs/PasswordInput.tsx +38 -0
  122. package/src/components/Inputs/Radio.tsx +59 -0
  123. package/src/components/Inputs/RadioGroup.tsx +48 -0
  124. package/src/components/Inputs/RadioLarge.tsx +39 -0
  125. package/src/components/Inputs/SearchInput.tsx +40 -0
  126. package/src/components/Inputs/Select2/Select.tsx +224 -0
  127. package/src/components/Inputs/Select2/select.scss +43 -0
  128. package/src/components/Inputs/Selects/Select.tsx +17 -0
  129. package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +19 -0
  130. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +126 -0
  131. package/src/components/Inputs/Selects/utils/selectStyles.ts +104 -0
  132. package/src/components/Inputs/TextAreaInput.tsx +67 -0
  133. package/src/components/Inputs/TextInput.tsx +98 -0
  134. package/src/components/Inputs/TimeInput/TimeInput.tsx +81 -0
  135. package/src/components/Loader/Loader.tsx +53 -0
  136. package/src/components/Menu/Menu.tsx +68 -0
  137. package/src/components/Menu/MenuItem.tsx +47 -0
  138. package/src/components/Menu/NewMenu.tsx +66 -0
  139. package/src/components/Menu/hooks/useMenuPosition.tsx +80 -0
  140. package/src/components/Pullover/Pullover.tsx +89 -0
  141. package/src/components/Router/Router.tsx +51 -0
  142. package/src/components/Sidebar/AddButton.tsx +22 -0
  143. package/src/components/Sidebar/Sidebar.tsx +81 -0
  144. package/src/components/Sidebar/SidebarItem.tsx +84 -0
  145. package/src/components/Sidebar/types/ISidebar.ts +28 -0
  146. package/src/components/Table/Components/Columns/ColumnsList.tsx +61 -0
  147. package/src/components/Table/Components/Columns/SetColumnsList.tsx +113 -0
  148. package/src/components/Table/Components/Edit/ItemActionsMenu.tsx +84 -0
  149. package/src/components/Table/Components/Edit/ItemEditOptionsButtons.tsx +31 -0
  150. package/src/components/Table/Components/Edit/TableEditRow.tsx +56 -0
  151. package/src/components/Table/Components/FilterItem.tsx +20 -0
  152. package/src/components/Table/Components/Header/TableHeader.tsx +45 -0
  153. package/src/components/Table/Components/Header/TableHeaderRow.tsx +37 -0
  154. package/src/components/Table/Components/Print/CustomTablePrint.tsx +114 -0
  155. package/src/components/Table/Components/Print/TablePrint.tsx +207 -0
  156. package/src/components/Table/Components/SetSortList.tsx +30 -0
  157. package/src/components/Table/Components/SetTableFilter.tsx +90 -0
  158. package/src/components/Table/Components/TableFooter.tsx +135 -0
  159. package/src/components/Table/Components/TableOptions.tsx +226 -0
  160. package/src/components/Table/Components/Templates/TemplateCreate.tsx +80 -0
  161. package/src/components/Table/Components/Templates/TemplateCreateDefault.tsx +45 -0
  162. package/src/components/Table/Components/Templates/TemplateList.tsx +167 -0
  163. package/src/components/Table/Components/Templates/repo/TemplateRepo.ts +53 -0
  164. package/src/components/Table/Table.tsx +527 -0
  165. package/src/components/Table/hooks/useDefaultTemplate.ts +20 -0
  166. package/src/components/Table/hooks/useTableKeyboard.ts +138 -0
  167. package/src/components/Table/hooks/useTableSelect.ts +11 -0
  168. package/src/components/Tabs/Tabs.tsx +66 -0
  169. package/src/components/Tooltip/Tooltip.tsx +133 -0
  170. package/src/components/Tree/Tree.tsx +22 -0
  171. package/src/components/Tree/TreeItem.tsx +56 -0
  172. package/src/components/Wrappers/AppLayout.tsx +17 -0
  173. package/src/components/Wrappers/ConditionalWrapper.tsx +10 -0
  174. package/src/components/Wrappers/FormWrapper.tsx +81 -0
  175. package/src/components/Wrappers/PageLayout.tsx +152 -0
  176. package/src/hooks/useBackgroundClose.ts +18 -0
  177. package/src/hooks/useIsMenuOpen.ts +11 -0
  178. package/src/hooks/useOnEsc.ts +14 -0
  179. package/src/hooks/useZendesk.ts +21 -0
  180. package/src/index.ts +324 -0
  181. package/src/pages/NoAccessPage.tsx +27 -0
  182. package/src/pages/NotFoundPage.tsx +26 -0
  183. package/src/styles/App.scss +43 -0
  184. package/src/styles/common/_animations.scss +64 -0
  185. package/src/styles/common/_typography.scss +88 -0
  186. package/src/styles/common/helpers/_base.scss +55 -0
  187. package/src/styles/common/helpers/_color.scss +7 -0
  188. package/src/styles/common/helpers/_display.scss +85 -0
  189. package/src/styles/common/helpers/_size.scss +25 -0
  190. package/src/styles/common/maps/_align.scss +21 -0
  191. package/src/styles/common/maps/_info-types.scss +1 -0
  192. package/src/styles/common/maps/_spacing.scss +78 -0
  193. package/src/styles/common/maps/_text.scss +14 -0
  194. package/src/styles/components/_accordions.scss +46 -0
  195. package/src/styles/components/_alert.scss +23 -0
  196. package/src/styles/components/_badge.scss +76 -0
  197. package/src/styles/components/_button.scss +138 -0
  198. package/src/styles/components/_card.scss +24 -0
  199. package/src/styles/components/_dialog.scss +111 -0
  200. package/src/styles/components/_form.scss +8 -0
  201. package/src/styles/components/_header.scss +109 -0
  202. package/src/styles/components/_input.scss +158 -0
  203. package/src/styles/components/_inputCheckbox.scss +105 -0
  204. package/src/styles/components/_inputDateTime.scss +161 -0
  205. package/src/styles/components/_inputRadio.scss +83 -0
  206. package/src/styles/components/_inputSelect.scss +6 -0
  207. package/src/styles/components/_loader.scss +44 -0
  208. package/src/styles/components/_menu-v2.scss +67 -0
  209. package/src/styles/components/_menu.scss +53 -0
  210. package/src/styles/components/_page.scss +62 -0
  211. package/src/styles/components/_portal.scss +8 -0
  212. package/src/styles/components/_print.scss +87 -0
  213. package/src/styles/components/_pullover.scss +43 -0
  214. package/src/styles/components/_scrollbar.scss +18 -0
  215. package/src/styles/components/_sidebar.scss +206 -0
  216. package/src/styles/components/_smallComponents.scss +23 -0
  217. package/src/styles/components/_table.scss +270 -0
  218. package/src/styles/components/_tabs.scss +33 -0
  219. package/src/styles/components/_tooltip.scss +48 -0
  220. package/src/styles/components/_tree.scss +21 -0
  221. package/src/styles/components/_widget.scss +90 -0
  222. package/src/styles/pages/_fullScreenPage.scss +64 -0
  223. package/src/styles/variables/_bp.scss +5 -0
  224. package/src/styles/variables/_variables.scss +130 -0
  225. package/src/types/Base/custom.d.ts +9 -0
  226. package/src/types/IBasic.ts +31 -0
  227. package/src/types/IError.ts +5 -0
  228. package/src/types/IHeader.ts +24 -0
  229. package/src/types/IInfo.ts +1 -0
  230. package/src/types/IKeyboard.ts +37 -0
  231. package/src/types/IMenu.ts +18 -0
  232. package/src/types/IRouter.ts +6 -0
  233. package/src/types/ISelect.ts +52 -0
  234. package/src/types/ITab.ts +10 -0
  235. package/src/types/ITable.ts +249 -0
  236. package/src/types/ITree.ts +6 -0
  237. package/src/utils/DateUtils.ts +32 -0
  238. package/src/utils/InputPatternValidation.ts +12 -0
  239. package/src/utils/LocalStorageHelper.ts +24 -0
  240. package/src/utils/NumberUtils.ts +21 -0
  241. package/src/utils/ObjectUtils.ts +85 -0
  242. package/src/utils/RootDir.ts +1 -0
  243. package/src/utils/StringUtils.ts +18 -0
  244. package/src/utils/TableUtils.ts +130 -0
  245. package/src/utils/Toasts.ts +6 -0
  246. package/src/utils/UrlUtils.ts +4 -0
  247. package/src/utils/fileUtils.ts +176 -0
  248. package/src/utils/i18n/i18nIUICyrilic.ts +90 -0
  249. package/src/utils/i18n/i18nIUILatin.ts +90 -0
  250. package/src/utils/i18n/i18nIUIMe.ts +88 -0
  251. package/src/utils/icons.ts +13 -0
  252. package/tsconfig.icons.json +5 -0
  253. package/tsconfig.json +19 -0
@@ -0,0 +1,64 @@
1
+ import { FC, useState } from 'react';
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import clsx from 'clsx';
4
+ import { ITab } from '../../types/ITab';
5
+ import { Collapse } from '../Helper/Collapse';
6
+ import { faArrowsToLine } from '../../assets/icons/light/faArrowsToLine';
7
+ import { faArrowsUpDown } from '../../assets/icons/light/faArrowsUpDown';
8
+
9
+ interface Props {
10
+ tabs: ITab[];
11
+ initialValue?: string;
12
+ compact?: boolean;
13
+ keepContentInDom?: boolean;
14
+ className?: string;
15
+ }
16
+ export const Accordions: FC<Props> = ({
17
+ tabs: allTabs,
18
+ initialValue,
19
+ compact,
20
+ keepContentInDom,
21
+ className,
22
+ }) => {
23
+ const tabs = allTabs.filter(tab => !tab.hidden);
24
+ const [selected, setSelected] = useState(initialValue || '');
25
+
26
+ return tabs.length > 0 ? (
27
+ <div className={className}>
28
+ <div className="iui-accordions">
29
+ {tabs.map(tab => (
30
+ <div
31
+ key={tab.value}
32
+ className={clsx('iui-accordion', {
33
+ selected: selected === tab.value,
34
+ compact,
35
+ })}
36
+ >
37
+ <div
38
+ className={clsx('summary clickable', {
39
+ disabled: tab.disabled,
40
+ })}
41
+ onClick={
42
+ tab.disabled
43
+ ? undefined
44
+ : () => setSelected(selected === tab.value ? '' : tab.value)
45
+ }
46
+ >
47
+ <div className="flex center">
48
+ {tab.icon && <FontAwesomeIcon icon={tab.icon} className="iui-icon" />}
49
+ {tab.label}
50
+ </div>
51
+ <FontAwesomeIcon
52
+ icon={tab.value === selected ? faArrowsToLine : faArrowsUpDown}
53
+ className="collapse-icon"
54
+ />
55
+ </div>
56
+ <Collapse isOpen={selected === tab.value} keepContentInDom={keepContentInDom}>
57
+ <div className="p-4">{tab.component}</div>
58
+ </Collapse>
59
+ </div>
60
+ ))}
61
+ </div>
62
+ </div>
63
+ ) : null;
64
+ };
@@ -0,0 +1,31 @@
1
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
+ import clsx from 'clsx';
3
+ import { FC, ReactNode } from 'react';
4
+ import { infoIcons } from '../../utils/icons';
5
+ import { IInfoType } from '../../types/IInfo';
6
+
7
+ export interface IAlertProps {
8
+ text?: string;
9
+ severity: IInfoType;
10
+ fitContent?: boolean;
11
+ className?: string;
12
+ children?: ReactNode;
13
+ }
14
+
15
+ export const Alert: FC<IAlertProps> = ({
16
+ text,
17
+ severity,
18
+ fitContent,
19
+ className,
20
+ children,
21
+ }) => (
22
+ <div
23
+ className={clsx('iui-alert', severity, className, {
24
+ 'width-fit': fitContent,
25
+ })}
26
+ >
27
+ <FontAwesomeIcon icon={infoIcons[severity]} />
28
+ {text && <p>{text}</p>}
29
+ {children}
30
+ </div>
31
+ );
@@ -0,0 +1,16 @@
1
+ import clsx from 'clsx';
2
+ import { FC } from 'react';
3
+ import { IInfoType } from '../../types/IInfo';
4
+
5
+ interface Props {
6
+ label: string;
7
+ color: IInfoType | 'gray';
8
+ className?: string;
9
+ }
10
+
11
+ export const DotBadge: FC<Props> = ({ label, color, className }) => (
12
+ <div className="flex align-center gap-2">
13
+ <div className={clsx('iui-dot-badge', color, className)} />
14
+ {label}
15
+ </div>
16
+ );
@@ -0,0 +1,29 @@
1
+ import clsx from 'clsx';
2
+ import { FC, ReactNode } from 'react';
3
+ import { IInfoType } from '../../types/IInfo';
4
+
5
+ interface Props {
6
+ number?: number;
7
+ className?: string;
8
+ size?: 's' | 'm';
9
+ children?: ReactNode;
10
+ color?: IInfoType | 'primary';
11
+ }
12
+
13
+ export const NotificationBadge: FC<Props> = ({
14
+ number,
15
+ className,
16
+ size = 'm',
17
+ children,
18
+ color = 'primary',
19
+ }) =>
20
+ !!number && number > 0 ? (
21
+ <div className="iui-badge-parent">
22
+ {children}
23
+ <div className={clsx('iui-badge', color, className, size)}>
24
+ {number > 99 ? '99+' : number}
25
+ </div>
26
+ </div>
27
+ ) : (
28
+ children
29
+ );
@@ -0,0 +1,13 @@
1
+ import clsx from 'clsx';
2
+ import { IInfoType } from '../../types/IInfo';
3
+ import { FC } from 'react';
4
+
5
+ interface Props {
6
+ label: string;
7
+ color: IInfoType | 'gray';
8
+ className?: string;
9
+ }
10
+
11
+ export const PillBadge: FC<Props> = ({ label, color, className }) => (
12
+ <div className={clsx('iui-pill-badge', color, className)}>{label}</div>
13
+ );
@@ -0,0 +1,56 @@
1
+ import type { ButtonHTMLAttributes, FC, MouseEventHandler, Ref } from 'react';
2
+ import clsx from 'clsx';
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
+ import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
5
+
6
+ export type IButtonColor = 'primary' | 'neutral' | 'danger';
7
+ export type IButtonVariant = 'solid' | 'outlined' | 'simple';
8
+
9
+ export interface IButtonProps {
10
+ label: string;
11
+ icon?: IconDefinition;
12
+ iconEnd?: IconDefinition;
13
+ onClick?: MouseEventHandler<HTMLButtonElement>;
14
+ variant?: IButtonVariant;
15
+ color?: IButtonColor;
16
+ size?: 'xs' | 's' | 'm' | 'l';
17
+ disabled?: boolean;
18
+ active?: boolean;
19
+ type?: ButtonHTMLAttributes<HTMLButtonElement>['type'];
20
+ className?: string;
21
+ buttonProps?: ButtonHTMLAttributes<HTMLButtonElement>;
22
+ ref?: Ref<HTMLButtonElement>;
23
+ }
24
+
25
+ export const Button: FC<IButtonProps> = ({
26
+ label,
27
+ icon,
28
+ iconEnd,
29
+ onClick,
30
+ variant = 'solid',
31
+ color,
32
+ size = 'm',
33
+ disabled,
34
+ active,
35
+ type = 'button',
36
+ className,
37
+ buttonProps,
38
+ ref,
39
+ }) => (
40
+ <button
41
+ ref={ref}
42
+ disabled={disabled}
43
+ className={clsx('iui-btn iui-text-btn', variant, color, size, className, {
44
+ active,
45
+ primary: !color && variant === 'solid',
46
+ neutral: !color && variant === 'outlined',
47
+ })}
48
+ onClick={onClick}
49
+ type={type}
50
+ {...buttonProps}
51
+ >
52
+ {icon && <FontAwesomeIcon icon={icon} />}
53
+ <div className="iui-btn-label">{label}</div>
54
+ {iconEnd && <FontAwesomeIcon icon={iconEnd} />}
55
+ </button>
56
+ );
@@ -0,0 +1,49 @@
1
+ import { ButtonHTMLAttributes, FC, MouseEventHandler, Ref } from 'react';
2
+ import clsx from 'clsx';
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4
+ import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
5
+ import { IButtonColor, IButtonVariant } from './Button';
6
+ import { Tooltip } from '../Tooltip/Tooltip';
7
+
8
+ export interface IIconButtonProps {
9
+ icon: IconDefinition;
10
+ onClick?: MouseEventHandler<HTMLButtonElement>;
11
+ variant?: IButtonVariant;
12
+ color?: IButtonColor;
13
+ size?: 's' | 'm' | 'l';
14
+ disabled?: boolean;
15
+ active?: boolean;
16
+ tooltip?: string;
17
+ className?: string;
18
+ buttonProps?: ButtonHTMLAttributes<HTMLButtonElement>;
19
+ ref?: Ref<HTMLButtonElement>;
20
+ }
21
+
22
+ export const IconButton: FC<IIconButtonProps> = ({
23
+ icon,
24
+ onClick,
25
+ variant = 'simple',
26
+ color = 'primary',
27
+ size = 'm',
28
+ disabled,
29
+ active,
30
+ tooltip,
31
+ className,
32
+ buttonProps,
33
+ ref,
34
+ }) => (
35
+ <Tooltip label={tooltip} disabled={disabled}>
36
+ <button
37
+ ref={ref}
38
+ disabled={disabled}
39
+ className={clsx('iui-btn iui-icon-btn', variant, color, size, className, {
40
+ active,
41
+ })}
42
+ onClick={onClick}
43
+ type={buttonProps?.type || onClick ? 'button' : 'submit'}
44
+ {...buttonProps}
45
+ >
46
+ <FontAwesomeIcon icon={icon} />
47
+ </button>
48
+ </Tooltip>
49
+ );
@@ -0,0 +1,9 @@
1
+ import { FC, ReactNode } from 'react';
2
+
3
+ export const Dashboard: FC<{ children: ReactNode }> = ({ children }) => (
4
+ <div className="page-container">
5
+ <div className="page-content">
6
+ <div className="widget-container">{children}</div>
7
+ </div>
8
+ </div>
9
+ );
@@ -0,0 +1,44 @@
1
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
+ import clsx from 'clsx';
3
+ import { FC, ReactNode } from 'react';
4
+ import { Loader } from '../Loader/Loader';
5
+ import { faCircleInfo, faTriangleExclamation } from '../../assets/icons';
6
+
7
+ const Icons = {
8
+ warning: faTriangleExclamation,
9
+ info: faCircleInfo,
10
+ };
11
+ interface Props {
12
+ title: string;
13
+ icon?: any;
14
+ type?: 'warning' | 'info';
15
+ span?: 2 | 3 | 4;
16
+ isLoading?: boolean;
17
+ children: ReactNode;
18
+ }
19
+ export const DashboardWidget: FC<Props> = ({
20
+ title,
21
+ icon,
22
+ type,
23
+ span,
24
+ isLoading,
25
+ children,
26
+ }) => (
27
+ <Loader isLoading={!!isLoading}>
28
+ <div
29
+ className={clsx('dashboard-widget', type, {
30
+ [`grid-span${span}`]: !!span,
31
+ })}
32
+ >
33
+ <div className="flex gap-3 mb-3">
34
+ {icon && (
35
+ <div className="widget-icon">
36
+ <FontAwesomeIcon icon={icon || Icons[type!]} />
37
+ </div>
38
+ )}
39
+ <h1>{title}</h1>
40
+ </div>
41
+ {children}
42
+ </div>
43
+ </Loader>
44
+ );
@@ -0,0 +1,37 @@
1
+ import type { FC } from 'react';
2
+ import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { DashboardWidget } from '../DashboardWidget';
5
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
+ import { faLink } from '../../../assets/icons/light/faLink';
7
+ import { faArrowUpRightFromSquare } from '../../../assets/icons/light/faArrowUpRightFromSquare';
8
+
9
+ interface Props {
10
+ links: {
11
+ icon?: IconDefinition;
12
+ label: string;
13
+ onClick: () => void;
14
+ }[];
15
+ }
16
+
17
+ export const FastLinksWidget: FC<Props> = ({ links }) => {
18
+ const { t } = useTranslation();
19
+
20
+ return (
21
+ <DashboardWidget title={t('FastLinks')} icon={faLink}>
22
+ <div className="short-links-widget mt-4">
23
+ <ul>
24
+ {links.map((l, i) => (
25
+ <li onClick={l.onClick} className="clickable" key={`short-links-${i}`}>
26
+ <FontAwesomeIcon
27
+ icon={l.icon || faArrowUpRightFromSquare}
28
+ className="mr-3"
29
+ />
30
+ {l.label}
31
+ </li>
32
+ ))}
33
+ </ul>
34
+ </div>
35
+ </DashboardWidget>
36
+ );
37
+ };
@@ -0,0 +1,52 @@
1
+ import { Dispatch, FC, SetStateAction, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Dialog } from './Dialog';
4
+ import { faTrashCan } from '../../assets/icons';
5
+
6
+ interface Props {
7
+ textId: string;
8
+ itemUuid: string;
9
+ setItemUuid: Dispatch<SetStateAction<string>>;
10
+ reloadItems: () => void;
11
+ deleteItemFunction: (itemUuid: string) => Promise<any>;
12
+ }
13
+
14
+ export const DeleteItemDialog: FC<Props> = ({
15
+ textId,
16
+ itemUuid,
17
+ setItemUuid,
18
+ reloadItems,
19
+ deleteItemFunction,
20
+ }) => {
21
+ const [isLoading, setIsLoading] = useState(false);
22
+
23
+ const { t } = useTranslation();
24
+
25
+ const handOnDelete = () => {
26
+ setIsLoading(true);
27
+ deleteItemFunction(itemUuid)
28
+ .then(() => {
29
+ reloadItems();
30
+ setItemUuid('');
31
+ })
32
+ .catch(() => {})
33
+ .finally(() => setIsLoading(false));
34
+ };
35
+
36
+ return (
37
+ <Dialog
38
+ isOpen={!!itemUuid}
39
+ onClose={() => setItemUuid('')}
40
+ title={t(`Delete${textId}Title`)}
41
+ desc={t(`Delete${textId}Desc`)}
42
+ isLoading={isLoading}
43
+ type="info"
44
+ confirmButton={{
45
+ label: t('Delete'),
46
+ icon: faTrashCan,
47
+ keepOpen: true,
48
+ onClick: handOnDelete,
49
+ }}
50
+ />
51
+ );
52
+ };
@@ -0,0 +1,226 @@
1
+ import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
+ import clsx from 'clsx';
4
+ import { FC, ReactNode, useCallback, useRef } from 'react';
5
+ import { createPortal } from 'react-dom';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { rootDir } from '../../utils/RootDir';
8
+ import { Button, IButtonColor, IButtonVariant } from '../Button/Button';
9
+ import { Loader } from '../Loader/Loader';
10
+ import { ConditionalWrapper } from '../Wrappers/ConditionalWrapper';
11
+ import { useDialogKeyboard } from './hooks/useDialogKeyboard';
12
+ import { faXmark } from '../../assets/icons';
13
+ import { IconButton } from '../Button/IconButton';
14
+ import { infoIcons } from '../../utils/icons';
15
+ import { IInfoType } from '../../types/IInfo';
16
+ import { useBackgroundClose } from '../../hooks/useBackgroundClose';
17
+
18
+ interface Props {
19
+ title?: string;
20
+ titleEl?: ReactNode;
21
+ desc?: string;
22
+ descEl?: ReactNode;
23
+ isOpen: boolean;
24
+ onClose: () => void;
25
+ isLoading?: boolean;
26
+ confirmButton?: {
27
+ label?: string;
28
+ icon?: IconDefinition;
29
+ onClick?: () => void;
30
+ onFormSubmit?: () => void;
31
+ disabled?: boolean;
32
+ keepOpen?: boolean;
33
+ isKeyboardDisabled?: boolean;
34
+ };
35
+ cancelButton?: {
36
+ label?: string;
37
+ icon?: IconDefinition;
38
+ onClick?: () => void;
39
+ };
40
+ additionalButton?: {
41
+ label: string;
42
+ icon?: IconDefinition;
43
+ onClick?: () => void;
44
+ disabled?: boolean;
45
+ keepOpen?: boolean;
46
+ color?: IButtonColor;
47
+ variant?: IButtonVariant;
48
+ };
49
+ hideActionButtons?: boolean;
50
+ isKeyboardDisabled?: boolean;
51
+ noBackgroundClick?: boolean;
52
+ noOverflow?: boolean;
53
+ type?: IInfoType;
54
+ size?: 'm' | 'l' | 'xl';
55
+ className?: string;
56
+ children?: ReactNode;
57
+ }
58
+
59
+ export const Dialog: FC<Props> = ({
60
+ title,
61
+ titleEl,
62
+ desc,
63
+ descEl,
64
+ isOpen,
65
+ onClose,
66
+ isLoading,
67
+ confirmButton,
68
+ cancelButton,
69
+ additionalButton,
70
+ isKeyboardDisabled,
71
+ hideActionButtons,
72
+ noBackgroundClick,
73
+ noOverflow,
74
+ type,
75
+ size = 'm',
76
+ className,
77
+ children,
78
+ }) => {
79
+ const { t } = useTranslation();
80
+
81
+ const portalRef = useRef<HTMLDivElement>(null);
82
+ const formRef = useRef<HTMLFormElement>(null);
83
+
84
+ const handleClose = useCallback(() => {
85
+ portalRef.current?.classList.add('closing');
86
+ setTimeout(onClose, 200);
87
+ }, [portalRef, onClose]);
88
+
89
+ useDialogKeyboard({
90
+ isOpen,
91
+ isDisabled: isKeyboardDisabled,
92
+ onClose: handleClose,
93
+ submit: {
94
+ onEnter: () => {
95
+ if (confirmButton) {
96
+ if (confirmButton.onFormSubmit) {
97
+ formRef.current?.requestSubmit();
98
+ } else {
99
+ confirmButton.onClick?.();
100
+ !confirmButton.keepOpen && handleClose();
101
+ }
102
+ } else {
103
+ cancelButton?.onClick ? cancelButton.onClick() : handleClose();
104
+ }
105
+ },
106
+ isDisabled: !confirmButton?.disabled && !confirmButton?.isKeyboardDisabled,
107
+ },
108
+ });
109
+
110
+ useBackgroundClose({
111
+ portalRef,
112
+ disabled: noBackgroundClick || !isOpen,
113
+ handleClose,
114
+ });
115
+
116
+ return isOpen
117
+ ? createPortal(
118
+ <div ref={portalRef} className="iui-dialog">
119
+ <Loader isLoading={!!isLoading}>
120
+ <div className={clsx('iui-dialog-container', size, type, className)}>
121
+ <ConditionalWrapper
122
+ condition={!!confirmButton?.onFormSubmit}
123
+ wrapper={children => (
124
+ <form
125
+ ref={formRef}
126
+ onSubmit={e => {
127
+ e.preventDefault();
128
+ e.stopPropagation();
129
+ confirmButton?.onFormSubmit?.();
130
+ !confirmButton?.keepOpen && handleClose();
131
+ }}
132
+ >
133
+ {children}
134
+ </form>
135
+ )}
136
+ >
137
+ <div
138
+ className={clsx('iui-dialog-content', {
139
+ 'no-overflow': noOverflow,
140
+ })}
141
+ >
142
+ <div className="iui-dialog-header">
143
+ {type && (
144
+ <FontAwesomeIcon
145
+ icon={infoIcons[type]}
146
+ className={clsx('dialog-type-icon', type)}
147
+ />
148
+ )}
149
+ <div className="full-width">
150
+ <div className="iui-dialog-title">
151
+ {title ? <h1>{title}</h1> : titleEl}
152
+ <IconButton
153
+ icon={faXmark}
154
+ onClick={handleClose}
155
+ color="neutral"
156
+ size="l"
157
+ className="close-icon"
158
+ />
159
+ </div>
160
+ {desc ? <p className="iui-dialog-desc">{desc}</p> : descEl}
161
+ </div>
162
+ </div>
163
+ {children}
164
+ </div>
165
+ {!hideActionButtons && (
166
+ <div className="iui-dialog-actions">
167
+ <Button
168
+ label={
169
+ cancelButton?.label || (confirmButton ? t('Cancel') : t('Close'))
170
+ }
171
+ icon={cancelButton?.icon}
172
+ variant={confirmButton ? 'outlined' : 'solid'}
173
+ onClick={e => {
174
+ e.stopPropagation();
175
+ cancelButton?.onClick ? cancelButton.onClick() : handleClose();
176
+ }}
177
+ type="button"
178
+ />
179
+ {additionalButton && (
180
+ <Button
181
+ label={additionalButton.label}
182
+ icon={additionalButton.icon}
183
+ onClick={
184
+ !!additionalButton.onClick
185
+ ? e => {
186
+ e.stopPropagation();
187
+ additionalButton.onClick!();
188
+ !additionalButton.keepOpen && handleClose();
189
+ }
190
+ : undefined
191
+ }
192
+ type="button"
193
+ variant={additionalButton.variant ?? 'outlined'}
194
+ color={additionalButton.color}
195
+ disabled={additionalButton.disabled}
196
+ />
197
+ )}
198
+ {confirmButton && (
199
+ <Button
200
+ label={confirmButton.label || 'Potvrdi'}
201
+ icon={confirmButton.icon}
202
+ variant="solid"
203
+ type={confirmButton.onFormSubmit ? 'submit' : 'button'}
204
+ onClick={
205
+ !!confirmButton.onClick
206
+ ? e => {
207
+ e.stopPropagation();
208
+ confirmButton.onClick!();
209
+ !confirmButton.keepOpen && handleClose();
210
+ }
211
+ : undefined
212
+ }
213
+ color={type === 'danger' ? 'danger' : undefined}
214
+ disabled={confirmButton.disabled}
215
+ />
216
+ )}
217
+ </div>
218
+ )}
219
+ </ConditionalWrapper>
220
+ </div>
221
+ </Loader>
222
+ </div>,
223
+ rootDir
224
+ )
225
+ : null;
226
+ };
@@ -0,0 +1,41 @@
1
+ import { useEffect } from 'react';
2
+ import { IKeyboardAction } from '../../../types/IKeyboard';
3
+
4
+ export const useDialogKeyboard = ({
5
+ isOpen,
6
+ onClose,
7
+ submit,
8
+ isDisabled,
9
+ }: {
10
+ isOpen: boolean;
11
+ onClose: () => void;
12
+ submit: {
13
+ onEnter: () => void;
14
+ isDisabled?: boolean;
15
+ };
16
+ isDisabled?: boolean;
17
+ }) => {
18
+ useEffect(() => {
19
+ if (isOpen && !isDisabled) {
20
+ const handleKeyDown = (event: KeyboardEvent) => {
21
+ const actions: IKeyboardAction[] = [
22
+ { key: 'Enter', onAction: submit.onEnter!, disabled: submit.isDisabled },
23
+ { key: 'Escape', onAction: onClose },
24
+ ];
25
+
26
+ actions.forEach(item => {
27
+ if (!item.disabled && item.key === event.key) {
28
+ event.preventDefault();
29
+ event.stopPropagation();
30
+ item.onAction();
31
+ }
32
+ });
33
+ };
34
+
35
+ window.addEventListener('keydown', handleKeyDown);
36
+ return () => {
37
+ window.removeEventListener('keydown', handleKeyDown);
38
+ };
39
+ }
40
+ }, [isOpen, submit, onClose, isDisabled]);
41
+ };