@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.
- package/dist/icons/index.d.ts +43 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +24 -15
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/iui.css +1 -1
- package/idea/Menu/Menu.tsx +119 -0
- package/idea/Menu/MenuItem.tsx +74 -0
- package/idea/Menu/hooks/useMenuControl.ts +13 -0
- package/idea/Menu.tsx +132 -0
- package/idea/NoAccessInfo.tsx +193 -0
- package/idea/Notifications.tsx +245 -0
- package/idea/Table2/Components/Columns/ColumnsList.tsx +56 -0
- package/idea/Table2/Components/Columns/SetColumnsList.tsx +107 -0
- package/idea/Table2/Components/Edit/ItemActionsMenu.tsx +87 -0
- package/idea/Table2/Components/Edit/ItemEditOptionsButtons.tsx +32 -0
- package/idea/Table2/Components/Edit/TableEditRow.tsx +56 -0
- package/idea/Table2/Components/FilterItem.tsx +20 -0
- package/idea/Table2/Components/Header/TableHeader.tsx +35 -0
- package/idea/Table2/Components/Header/TableHeaderRow.tsx +37 -0
- package/idea/Table2/Components/Print/CustomTablePrint.tsx +119 -0
- package/idea/Table2/Components/Print/TablePrint.tsx +208 -0
- package/idea/Table2/Components/SetSortList.tsx +33 -0
- package/idea/Table2/Components/SetTableFilter.tsx +90 -0
- package/idea/Table2/Components/TableFooter.tsx +107 -0
- package/idea/Table2/Components/TableOptions.tsx +211 -0
- package/idea/Table2/Components/Templates/TemplateCreate.tsx +75 -0
- package/idea/Table2/Components/Templates/TemplateCreateDefault.tsx +45 -0
- package/idea/Table2/Components/Templates/TemplateList.tsx +167 -0
- package/idea/Table2/Components/Templates/repo/TemplateRepo.ts +51 -0
- package/idea/Table2/Table.tsx +657 -0
- package/idea/Table2/_table.scss +300 -0
- package/idea/Table2/hooks/useDefaultTemplate.ts +22 -0
- package/idea/Table2/hooks/useTableKeyboard.ts +115 -0
- package/package.json +8 -4
- package/rollup.config.js +80 -0
- package/src/assets/icons/duotone/faCircleUser.ts +17 -0
- package/src/assets/icons/index.ts +20 -0
- package/src/assets/icons/light/faArrowDownShortWide.ts +15 -0
- package/src/assets/icons/light/faArrowDownWideShort.ts +15 -0
- package/src/assets/icons/light/faArrowUpArrowDown.ts +15 -0
- package/src/assets/icons/light/faArrowUpRightFromSquare.ts +15 -0
- package/src/assets/icons/light/faArrowsToLine.ts +15 -0
- package/src/assets/icons/light/faArrowsUpDown.ts +15 -0
- package/src/assets/icons/light/faCalendarPlus.ts +15 -0
- package/src/assets/icons/light/faCheck.ts +15 -0
- package/src/assets/icons/light/faChevronDown.ts +15 -0
- package/src/assets/icons/light/faChevronRight.ts +15 -0
- package/src/assets/icons/light/faCircleInfo.ts +15 -0
- package/src/assets/icons/light/faCircleXmark.ts +15 -0
- package/src/assets/icons/light/faClockRotateLeft.ts +15 -0
- package/src/assets/icons/light/faEllipsisVertical.ts +15 -0
- package/src/assets/icons/light/faEye.ts +15 -0
- package/src/assets/icons/light/faEyeSlash.ts +15 -0
- package/src/assets/icons/light/faFilter.ts +15 -0
- package/src/assets/icons/light/faGear.ts +15 -0
- package/src/assets/icons/light/faHouse.ts +15 -0
- package/src/assets/icons/light/faIdBadge.ts +15 -0
- package/src/assets/icons/light/faLineColumns.ts +15 -0
- package/src/assets/icons/light/faLink.ts +15 -0
- package/src/assets/icons/light/faMagnifyingGlass.ts +15 -0
- package/src/assets/icons/light/faPenField.ts +15 -0
- package/src/assets/icons/light/faPrint.ts +15 -0
- package/src/assets/icons/light/faQuestion.ts +15 -0
- package/src/assets/icons/light/faRotateRight.ts +15 -0
- package/src/assets/icons/light/faTrashCan.ts +15 -0
- package/src/assets/icons/light/faTriangleExclamation.ts +15 -0
- package/src/assets/icons/light/faXmark.ts +15 -0
- package/src/assets/icons/regular/faArrowLeft.ts +15 -0
- package/src/assets/icons/regular/faArrowRightArrowLeft.ts +15 -0
- package/src/assets/icons/regular/faCircleCheck.ts +15 -0
- package/src/assets/icons/regular/faCircleExclamation.ts +15 -0
- package/src/assets/icons/regular/faCircleInfo.ts +15 -0
- package/src/assets/icons/regular/faFileArrowDown.ts +15 -0
- package/src/assets/icons/regular/faFilterCircleXmark.ts +15 -0
- package/src/assets/icons/regular/faTriangleExclamation.ts +15 -0
- package/src/assets/icons/solid/faAngleLeft.ts +15 -0
- package/src/assets/icons/solid/faAngleRight.ts +15 -0
- package/src/assets/icons/solid/faArrowDownWideShort.ts +15 -0
- package/src/assets/icons/solid/faCaretDown.ts +15 -0
- package/src/assets/icons/solid/faCheck.ts +15 -0
- package/src/assets/icons/solid/faEllipsisVertical.ts +15 -0
- package/src/assets/icons/solid/faFilter.ts +15 -0
- package/src/assets/icons/solid/faFloppyDisk.ts +15 -0
- package/src/assets/icons/solid/faGripDotsVertical.ts +15 -0
- package/src/assets/icons/solid/faListUl.ts +15 -0
- package/src/assets/icons/solid/faMagnifyingGlass.ts +15 -0
- package/src/assets/icons/solid/faMinus.ts +15 -0
- package/src/assets/icons/solid/faPlus.ts +15 -0
- package/src/assets/icons/solid/faPrint.ts +15 -0
- package/src/assets/icons/solid/faRotateRight.ts +15 -0
- package/src/assets/icons/solid/faXmark.ts +15 -0
- package/src/assets/images/logo/mts.svg +5703 -0
- package/src/assets/images/logo/paperless.svg +21 -0
- package/src/assets/images/logo/pismonosa.png +0 -0
- package/src/assets/images/not-found.svg +19 -0
- package/src/components/Accordions/Accordions.tsx +64 -0
- package/src/components/Alert/Alert.tsx +31 -0
- package/src/components/Badge/DotBadge.tsx +16 -0
- package/src/components/Badge/NotificationBadge.tsx +29 -0
- package/src/components/Badge/PillBadge.tsx +13 -0
- package/src/components/Button/Button.tsx +56 -0
- package/src/components/Button/IconButton.tsx +49 -0
- package/src/components/Dashboard/Dashboard.tsx +9 -0
- package/src/components/Dashboard/DashboardWidget.tsx +44 -0
- package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +37 -0
- package/src/components/Dialog/DeleteItemDialog.tsx +52 -0
- package/src/components/Dialog/Dialog.tsx +226 -0
- package/src/components/Dialog/hooks/useDialogKeyboard.ts +41 -0
- package/src/components/Dialog/hooks/useDialogObserver.ts +21 -0
- package/src/components/Header/Components/ModuleSelect.tsx +55 -0
- package/src/components/Header/Components/UserMenu.tsx +44 -0
- package/src/components/Header/Header.tsx +36 -0
- package/src/components/Helper/Collapse.tsx +52 -0
- package/src/components/Inputs/Checkbox.tsx +53 -0
- package/src/components/Inputs/CurrencyInput.tsx +123 -0
- package/src/components/Inputs/DateInput/DateInput.tsx +176 -0
- package/src/components/Inputs/DateInput/components/DatePartInput.tsx +154 -0
- package/src/components/Inputs/InputWrapper.tsx +90 -0
- package/src/components/Inputs/NumberInput.tsx +83 -0
- package/src/components/Inputs/PasswordInput.tsx +38 -0
- package/src/components/Inputs/Radio.tsx +59 -0
- package/src/components/Inputs/RadioGroup.tsx +48 -0
- package/src/components/Inputs/RadioLarge.tsx +39 -0
- package/src/components/Inputs/SearchInput.tsx +40 -0
- package/src/components/Inputs/Select2/Select.tsx +224 -0
- package/src/components/Inputs/Select2/select.scss +43 -0
- package/src/components/Inputs/Selects/Select.tsx +17 -0
- package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +19 -0
- package/src/components/Inputs/Selects/components/SelectWrapper.tsx +126 -0
- package/src/components/Inputs/Selects/utils/selectStyles.ts +104 -0
- package/src/components/Inputs/TextAreaInput.tsx +67 -0
- package/src/components/Inputs/TextInput.tsx +98 -0
- package/src/components/Inputs/TimeInput/TimeInput.tsx +81 -0
- package/src/components/Loader/Loader.tsx +53 -0
- package/src/components/Menu/Menu.tsx +68 -0
- package/src/components/Menu/MenuItem.tsx +47 -0
- package/src/components/Menu/NewMenu.tsx +66 -0
- package/src/components/Menu/hooks/useMenuPosition.tsx +80 -0
- package/src/components/Pullover/Pullover.tsx +89 -0
- package/src/components/Router/Router.tsx +51 -0
- package/src/components/Sidebar/AddButton.tsx +22 -0
- package/src/components/Sidebar/Sidebar.tsx +81 -0
- package/src/components/Sidebar/SidebarItem.tsx +84 -0
- package/src/components/Sidebar/types/ISidebar.ts +28 -0
- package/src/components/Table/Components/Columns/ColumnsList.tsx +61 -0
- package/src/components/Table/Components/Columns/SetColumnsList.tsx +113 -0
- package/src/components/Table/Components/Edit/ItemActionsMenu.tsx +84 -0
- package/src/components/Table/Components/Edit/ItemEditOptionsButtons.tsx +31 -0
- package/src/components/Table/Components/Edit/TableEditRow.tsx +56 -0
- package/src/components/Table/Components/FilterItem.tsx +20 -0
- package/src/components/Table/Components/Header/TableHeader.tsx +45 -0
- package/src/components/Table/Components/Header/TableHeaderRow.tsx +37 -0
- package/src/components/Table/Components/Print/CustomTablePrint.tsx +114 -0
- package/src/components/Table/Components/Print/TablePrint.tsx +207 -0
- package/src/components/Table/Components/SetSortList.tsx +30 -0
- package/src/components/Table/Components/SetTableFilter.tsx +90 -0
- package/src/components/Table/Components/TableFooter.tsx +135 -0
- package/src/components/Table/Components/TableOptions.tsx +226 -0
- package/src/components/Table/Components/Templates/TemplateCreate.tsx +80 -0
- package/src/components/Table/Components/Templates/TemplateCreateDefault.tsx +45 -0
- package/src/components/Table/Components/Templates/TemplateList.tsx +167 -0
- package/src/components/Table/Components/Templates/repo/TemplateRepo.ts +53 -0
- package/src/components/Table/Table.tsx +527 -0
- package/src/components/Table/hooks/useDefaultTemplate.ts +20 -0
- package/src/components/Table/hooks/useTableKeyboard.ts +138 -0
- package/src/components/Table/hooks/useTableSelect.ts +11 -0
- package/src/components/Tabs/Tabs.tsx +66 -0
- package/src/components/Tooltip/Tooltip.tsx +133 -0
- package/src/components/Tree/Tree.tsx +22 -0
- package/src/components/Tree/TreeItem.tsx +56 -0
- package/src/components/Wrappers/AppLayout.tsx +17 -0
- package/src/components/Wrappers/ConditionalWrapper.tsx +10 -0
- package/src/components/Wrappers/FormWrapper.tsx +81 -0
- package/src/components/Wrappers/PageLayout.tsx +152 -0
- package/src/hooks/useBackgroundClose.ts +18 -0
- package/src/hooks/useIsMenuOpen.ts +11 -0
- package/src/hooks/useOnEsc.ts +14 -0
- package/src/hooks/useZendesk.ts +21 -0
- package/src/index.ts +324 -0
- package/src/pages/NoAccessPage.tsx +27 -0
- package/src/pages/NotFoundPage.tsx +26 -0
- package/src/styles/App.scss +43 -0
- package/src/styles/common/_animations.scss +64 -0
- package/src/styles/common/_typography.scss +88 -0
- package/src/styles/common/helpers/_base.scss +55 -0
- package/src/styles/common/helpers/_color.scss +7 -0
- package/src/styles/common/helpers/_display.scss +85 -0
- package/src/styles/common/helpers/_size.scss +25 -0
- package/src/styles/common/maps/_align.scss +21 -0
- package/src/styles/common/maps/_info-types.scss +1 -0
- package/src/styles/common/maps/_spacing.scss +78 -0
- package/src/styles/common/maps/_text.scss +14 -0
- package/src/styles/components/_accordions.scss +46 -0
- package/src/styles/components/_alert.scss +23 -0
- package/src/styles/components/_badge.scss +76 -0
- package/src/styles/components/_button.scss +138 -0
- package/src/styles/components/_card.scss +24 -0
- package/src/styles/components/_dialog.scss +111 -0
- package/src/styles/components/_form.scss +8 -0
- package/src/styles/components/_header.scss +109 -0
- package/src/styles/components/_input.scss +158 -0
- package/src/styles/components/_inputCheckbox.scss +105 -0
- package/src/styles/components/_inputDateTime.scss +161 -0
- package/src/styles/components/_inputRadio.scss +83 -0
- package/src/styles/components/_inputSelect.scss +6 -0
- package/src/styles/components/_loader.scss +44 -0
- package/src/styles/components/_menu-v2.scss +67 -0
- package/src/styles/components/_menu.scss +53 -0
- package/src/styles/components/_page.scss +62 -0
- package/src/styles/components/_portal.scss +8 -0
- package/src/styles/components/_print.scss +87 -0
- package/src/styles/components/_pullover.scss +43 -0
- package/src/styles/components/_scrollbar.scss +18 -0
- package/src/styles/components/_sidebar.scss +206 -0
- package/src/styles/components/_smallComponents.scss +23 -0
- package/src/styles/components/_table.scss +270 -0
- package/src/styles/components/_tabs.scss +33 -0
- package/src/styles/components/_tooltip.scss +48 -0
- package/src/styles/components/_tree.scss +21 -0
- package/src/styles/components/_widget.scss +90 -0
- package/src/styles/pages/_fullScreenPage.scss +64 -0
- package/src/styles/variables/_bp.scss +5 -0
- package/src/styles/variables/_variables.scss +130 -0
- package/src/types/Base/custom.d.ts +9 -0
- package/src/types/IBasic.ts +31 -0
- package/src/types/IError.ts +5 -0
- package/src/types/IHeader.ts +24 -0
- package/src/types/IInfo.ts +1 -0
- package/src/types/IKeyboard.ts +37 -0
- package/src/types/IMenu.ts +18 -0
- package/src/types/IRouter.ts +6 -0
- package/src/types/ISelect.ts +52 -0
- package/src/types/ITab.ts +10 -0
- package/src/types/ITable.ts +249 -0
- package/src/types/ITree.ts +6 -0
- package/src/utils/DateUtils.ts +32 -0
- package/src/utils/InputPatternValidation.ts +12 -0
- package/src/utils/LocalStorageHelper.ts +24 -0
- package/src/utils/NumberUtils.ts +21 -0
- package/src/utils/ObjectUtils.ts +85 -0
- package/src/utils/RootDir.ts +1 -0
- package/src/utils/StringUtils.ts +18 -0
- package/src/utils/TableUtils.ts +130 -0
- package/src/utils/Toasts.ts +6 -0
- package/src/utils/UrlUtils.ts +4 -0
- package/src/utils/fileUtils.ts +176 -0
- package/src/utils/i18n/i18nIUICyrilic.ts +90 -0
- package/src/utils/i18n/i18nIUILatin.ts +90 -0
- package/src/utils/i18n/i18nIUIMe.ts +88 -0
- package/src/utils/icons.ts +13 -0
- package/tsconfig.icons.json +5 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { rootDir } from '../../../utils/RootDir';
|
|
3
|
+
|
|
4
|
+
export const useDialogObserver = () => {
|
|
5
|
+
const [isDialogOpen, setIsDialogOpen] = useState(false);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const observer = new MutationObserver(mutationsList => {
|
|
9
|
+
if (mutationsList.find(mutation => mutation.type === 'childList')) {
|
|
10
|
+
const isDialogInRoot = rootDir.getElementsByClassName('iui-dialog').length > 0;
|
|
11
|
+
setIsDialogOpen(isDialogInRoot);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
observer.observe(rootDir, { childList: true });
|
|
16
|
+
|
|
17
|
+
return () => observer.disconnect();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
return isDialogOpen;
|
|
21
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Link } from 'react-router';
|
|
3
|
+
import { Menu } from '../../Menu/Menu';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
6
|
+
import { useIsMenuOpen } from '../../../hooks/useIsMenuOpen';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
modules: { name: string; icon: IconDefinition; disabled?: boolean; url: string }[];
|
|
10
|
+
activeModule: { name: string; icon: IconDefinition } | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const ModuleSelect: FC<Props> = ({ modules, activeModule }) => {
|
|
14
|
+
const { isMenuOpen, onMenuOpen, onMenuClose } = useIsMenuOpen();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="flex align-center gap-1">
|
|
18
|
+
{!!modules.length && (
|
|
19
|
+
<Menu
|
|
20
|
+
isOpen={isMenuOpen}
|
|
21
|
+
onClose={onMenuClose}
|
|
22
|
+
// id="headerModuleSelect"
|
|
23
|
+
renderButton={ref => (
|
|
24
|
+
<button ref={ref} className="header-button clickable" onClick={onMenuOpen}>
|
|
25
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
|
|
26
|
+
<rect width="256" height="256" fill="none" />
|
|
27
|
+
<circle fill="var(--neutral-500)" cx="60" cy="60" r="20" />
|
|
28
|
+
<circle fill="var(--neutral-500)" cx="128" cy="60" r="20" />
|
|
29
|
+
<circle fill="var(--neutral-500)" cx="196" cy="60" r="20" />
|
|
30
|
+
<circle fill="var(--neutral-500)" cx="60" cy="128" r="20" />
|
|
31
|
+
<circle fill="var(--neutral-500)" cx="128" cy="128" r="20" />
|
|
32
|
+
<circle fill="var(--neutral-500)" cx="196" cy="128" r="20" />
|
|
33
|
+
<circle fill="var(--neutral-500)" cx="60" cy="196" r="20" />
|
|
34
|
+
<circle fill="var(--neutral-500)" cx="128" cy="196" r="20" />
|
|
35
|
+
<circle fill="var(--neutral-500)" cx="196" cy="196" r="20" />
|
|
36
|
+
</svg>
|
|
37
|
+
</button>
|
|
38
|
+
)}
|
|
39
|
+
items={modules.map(e => ({ ...e, label: e.name }))}
|
|
40
|
+
className="grid fr-2 p-2"
|
|
41
|
+
classNameItem="module-item hover-neutral"
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
|
|
45
|
+
{activeModule && (
|
|
46
|
+
<Link className="module-name clickable" to="/">
|
|
47
|
+
<div className="module-icon">
|
|
48
|
+
<FontAwesomeIcon icon={activeModule.icon} />
|
|
49
|
+
</div>
|
|
50
|
+
<h3>{activeModule.name}</h3>
|
|
51
|
+
</Link>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
+
import { faCircleUser } from '../../../assets/icons/duotone/faCircleUser';
|
|
4
|
+
import { Tooltip } from '../../Tooltip/Tooltip';
|
|
5
|
+
import { Menu } from '../../Menu/Menu';
|
|
6
|
+
import { IHeaderUserMenuProps } from '../../../types/IHeader';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
useHeaderUserContext: () => IHeaderUserMenuProps;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const UserMenu: FC<Props> = ({ useHeaderUserContext }) => {
|
|
13
|
+
const { isOpen, setIsOpen, userName, organizationName, menuItems, showBadge } =
|
|
14
|
+
useHeaderUserContext();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<Menu
|
|
19
|
+
isOpen={isOpen}
|
|
20
|
+
onClose={() => setIsOpen(false)}
|
|
21
|
+
placement="bottom-right"
|
|
22
|
+
size="m"
|
|
23
|
+
items={menuItems}
|
|
24
|
+
renderButton={ref => (
|
|
25
|
+
<button ref={ref} className="user-box" onClick={() => setIsOpen(true)}>
|
|
26
|
+
{showBadge && <div className="user-badge" />}
|
|
27
|
+
<FontAwesomeIcon icon={faCircleUser} className="user-icon" />
|
|
28
|
+
<div className="user-info">
|
|
29
|
+
{userName && <p className="user-name">{userName}</p>}
|
|
30
|
+
{organizationName && (
|
|
31
|
+
<Tooltip
|
|
32
|
+
label={(organizationName?.length || 0) > 20 ? organizationName : ''}
|
|
33
|
+
position="bottom"
|
|
34
|
+
>
|
|
35
|
+
<p className="org-name">{organizationName}</p>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
</button>
|
|
40
|
+
)}
|
|
41
|
+
/>
|
|
42
|
+
</>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentProps, FC, ReactNode } from 'react';
|
|
2
|
+
import { UserMenu } from './Components/UserMenu';
|
|
3
|
+
import { ModuleSelect } from './Components/ModuleSelect';
|
|
4
|
+
import { IHeaderUserMenuProps } from '../../types/IHeader';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
customTitle?: string;
|
|
8
|
+
modulesProps?: ComponentProps<typeof ModuleSelect>;
|
|
9
|
+
// actions: {
|
|
10
|
+
// icon: IconDefinition;
|
|
11
|
+
// };
|
|
12
|
+
userMenuProps: {
|
|
13
|
+
HeaderUserProvider: ({ children }: { children: ReactNode }) => React.JSX.Element;
|
|
14
|
+
useHeaderUserContext: () => IHeaderUserMenuProps;
|
|
15
|
+
};
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Header: FC<Props> = ({
|
|
20
|
+
customTitle,
|
|
21
|
+
modulesProps,
|
|
22
|
+
userMenuProps: { HeaderUserProvider, useHeaderUserContext },
|
|
23
|
+
children,
|
|
24
|
+
}) => (
|
|
25
|
+
<div className="iui-header">
|
|
26
|
+
{modulesProps && <ModuleSelect {...modulesProps} />}
|
|
27
|
+
{customTitle && <h3 className="p-3">{customTitle}</h3>}
|
|
28
|
+
<div className="flex gap-2 align-center">
|
|
29
|
+
{children}
|
|
30
|
+
{/* {!hideNotifications && <Notifications />} */}
|
|
31
|
+
<HeaderUserProvider>
|
|
32
|
+
<UserMenu useHeaderUserContext={useHeaderUserContext} />
|
|
33
|
+
</HeaderUserProvider>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { FC, ReactNode, useEffect, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
keepContentInDom?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Collapse: FC<Props> = ({
|
|
12
|
+
isOpen,
|
|
13
|
+
children,
|
|
14
|
+
keepContentInDom,
|
|
15
|
+
className,
|
|
16
|
+
}) => {
|
|
17
|
+
const [height, setHeight] = useState<number>();
|
|
18
|
+
const [isVisible, setIsVisible] = useState(isOpen);
|
|
19
|
+
|
|
20
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
isOpen && setIsVisible(true);
|
|
24
|
+
}, [isOpen]);
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const observer = new ResizeObserver(entries => {
|
|
28
|
+
const newHeight = Math.ceil(entries[0].contentRect.height);
|
|
29
|
+
setHeight(newHeight);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let observerRefValue: HTMLDivElement;
|
|
33
|
+
if (ref.current) {
|
|
34
|
+
observerRefValue = ref.current;
|
|
35
|
+
observer.observe(observerRefValue);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return () => {
|
|
39
|
+
observerRefValue && observer.unobserve(observerRefValue);
|
|
40
|
+
};
|
|
41
|
+
}, [ref]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div
|
|
45
|
+
className={clsx('iui-collapse', className)}
|
|
46
|
+
style={{ maxHeight: isOpen ? height : 0 }}
|
|
47
|
+
onTransitionEnd={() => !isOpen && setIsVisible(false)}
|
|
48
|
+
>
|
|
49
|
+
<div ref={ref}>{(keepContentInDom || isVisible) && children}</div>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { FC, ReactNode, Ref } from 'react';
|
|
3
|
+
import { Tooltip } from '../Tooltip/Tooltip';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import { faCheck } from '../../assets/icons/solid/faCheck';
|
|
6
|
+
import { faMinus } from '../../assets/icons/solid/faMinus';
|
|
7
|
+
|
|
8
|
+
export interface ICheckboxProps {
|
|
9
|
+
label?: string;
|
|
10
|
+
value?: boolean | 'middle';
|
|
11
|
+
setValue: (checked: boolean) => void;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
className?: string;
|
|
15
|
+
tooltip?: string;
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
ref?: Ref<HTMLLabelElement>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const Checkbox: FC<ICheckboxProps> = ({
|
|
21
|
+
label,
|
|
22
|
+
value = false,
|
|
23
|
+
setValue,
|
|
24
|
+
required,
|
|
25
|
+
disabled,
|
|
26
|
+
className,
|
|
27
|
+
tooltip,
|
|
28
|
+
children,
|
|
29
|
+
ref,
|
|
30
|
+
}) => (
|
|
31
|
+
<Tooltip label={tooltip || ''}>
|
|
32
|
+
<label ref={ref} className={clsx('iui-checkbox', className, { disabled })}>
|
|
33
|
+
<div className={clsx('box', { selected: value })}>
|
|
34
|
+
{value && (
|
|
35
|
+
<FontAwesomeIcon
|
|
36
|
+
icon={value === 'middle' ? faMinus : faCheck}
|
|
37
|
+
height={14}
|
|
38
|
+
width={14}
|
|
39
|
+
/>
|
|
40
|
+
)}
|
|
41
|
+
<input
|
|
42
|
+
required={required}
|
|
43
|
+
disabled={disabled}
|
|
44
|
+
className="fake-input"
|
|
45
|
+
type="checkbox"
|
|
46
|
+
checked={value && value !== 'middle'}
|
|
47
|
+
onChange={() => setValue(!value)}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
{label ? <p>{label}</p> : children}
|
|
51
|
+
</label>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
);
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { FC, InputHTMLAttributes, Ref, useState } from 'react';
|
|
2
|
+
import { TextInput } from './TextInput';
|
|
3
|
+
|
|
4
|
+
export interface ICurrencyInputProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
value?: string | number;
|
|
7
|
+
setValue: (value: string) => void;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
autoFocus?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
helperText?: string;
|
|
13
|
+
errorText?: string;
|
|
14
|
+
error?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
allowNegative?: boolean;
|
|
17
|
+
decimalPlaces?: number;
|
|
18
|
+
align?: 'left' | 'right';
|
|
19
|
+
endText?: string;
|
|
20
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
21
|
+
isClearable?: boolean;
|
|
22
|
+
ref?: Ref<HTMLInputElement>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const formatCurrency = (number?: string | number) => {
|
|
26
|
+
if (!number) return '';
|
|
27
|
+
|
|
28
|
+
const value = number.toString();
|
|
29
|
+
let [intiger, decimal] = value.split('.');
|
|
30
|
+
const formatedInt = intiger.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
|
|
31
|
+
|
|
32
|
+
return decimal
|
|
33
|
+
? `${formatedInt},${decimal}`
|
|
34
|
+
: value.endsWith('.')
|
|
35
|
+
? `${formatedInt},`
|
|
36
|
+
: formatedInt;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const CurrencyInput: FC<ICurrencyInputProps> = ({
|
|
40
|
+
value,
|
|
41
|
+
setValue,
|
|
42
|
+
label,
|
|
43
|
+
required,
|
|
44
|
+
disabled,
|
|
45
|
+
autoFocus,
|
|
46
|
+
placeholder,
|
|
47
|
+
helperText,
|
|
48
|
+
errorText,
|
|
49
|
+
error,
|
|
50
|
+
className,
|
|
51
|
+
allowNegative,
|
|
52
|
+
decimalPlaces = 2,
|
|
53
|
+
align = 'right',
|
|
54
|
+
endText,
|
|
55
|
+
inputProps,
|
|
56
|
+
isClearable,
|
|
57
|
+
ref,
|
|
58
|
+
}) => {
|
|
59
|
+
const [formatedInput, setFormatedInput] = useState('');
|
|
60
|
+
|
|
61
|
+
const inputElement = document.activeElement as HTMLInputElement;
|
|
62
|
+
|
|
63
|
+
const setValueHandler = (e: string) => {
|
|
64
|
+
const cursorPosition = inputElement.selectionStart;
|
|
65
|
+
let inputValue = decimalPlaces
|
|
66
|
+
? e.replace(/\.$/, ',').replaceAll('.', '').replace(',', '.')
|
|
67
|
+
: e.replaceAll('.', '');
|
|
68
|
+
|
|
69
|
+
if (
|
|
70
|
+
// Check if the input is valid
|
|
71
|
+
new RegExp(
|
|
72
|
+
`^${allowNegative ? '-?' : ''}\\d*${
|
|
73
|
+
decimalPlaces ? `(?:[.,])?(\\d{1,${decimalPlaces}})?` : ''
|
|
74
|
+
}$`
|
|
75
|
+
).test(inputValue) ||
|
|
76
|
+
!e
|
|
77
|
+
) {
|
|
78
|
+
const newValue = formatCurrency(inputValue);
|
|
79
|
+
|
|
80
|
+
setFormatedInput(newValue);
|
|
81
|
+
setValue(inputValue);
|
|
82
|
+
|
|
83
|
+
// Adjust cursor position
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
const isDotAdded = newValue.length - formatedInput.length > 1;
|
|
86
|
+
|
|
87
|
+
const adjustedCursorPosition = isDotAdded
|
|
88
|
+
? (cursorPosition as number) + 1
|
|
89
|
+
: cursorPosition;
|
|
90
|
+
|
|
91
|
+
inputElement.setSelectionRange &&
|
|
92
|
+
inputElement.setSelectionRange(adjustedCursorPosition, adjustedCursorPosition);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<TextInput
|
|
99
|
+
ref={ref}
|
|
100
|
+
value={formatCurrency(value)}
|
|
101
|
+
setValue={setValueHandler}
|
|
102
|
+
label={label}
|
|
103
|
+
required={required}
|
|
104
|
+
disabled={disabled}
|
|
105
|
+
endText={endText}
|
|
106
|
+
isClearable={isClearable}
|
|
107
|
+
placeholder={
|
|
108
|
+
placeholder ? placeholder : decimalPlaces ? `0,${'0'.repeat(decimalPlaces)}` : '0'
|
|
109
|
+
}
|
|
110
|
+
inputProps={{
|
|
111
|
+
className: `text-${align}`,
|
|
112
|
+
lang: 'sr-RS',
|
|
113
|
+
inputMode: 'numeric',
|
|
114
|
+
...inputProps,
|
|
115
|
+
}}
|
|
116
|
+
className={className}
|
|
117
|
+
autoFocus={autoFocus}
|
|
118
|
+
helperText={helperText}
|
|
119
|
+
errorText={errorText}
|
|
120
|
+
error={error}
|
|
121
|
+
/>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
+
import { FC, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Calendar } from 'react-calendar';
|
|
4
|
+
import { Menu } from '../../Menu/Menu';
|
|
5
|
+
import { InputWrapper } from '../InputWrapper';
|
|
6
|
+
import { DatePartInput } from './components/DatePartInput';
|
|
7
|
+
import { faCalendarPlus } from '../../../assets/icons/light/faCalendarPlus';
|
|
8
|
+
import dayjs from 'dayjs';
|
|
9
|
+
import { IMenuPlacement } from '../../../types/IMenu';
|
|
10
|
+
import i18next from 'i18next';
|
|
11
|
+
import { formatDateYMD } from '../../../utils/DateUtils';
|
|
12
|
+
|
|
13
|
+
export interface IDateInputProps {
|
|
14
|
+
label?: string;
|
|
15
|
+
date?: string;
|
|
16
|
+
setDate: (date: string) => void;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
autoFocus?: boolean;
|
|
20
|
+
error?: boolean;
|
|
21
|
+
helperText?: string;
|
|
22
|
+
errorText?: string;
|
|
23
|
+
isClearable?: boolean;
|
|
24
|
+
className?: string;
|
|
25
|
+
calendarPlacement?: IMenuPlacement;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const DateInput: FC<IDateInputProps> = ({
|
|
29
|
+
label,
|
|
30
|
+
date,
|
|
31
|
+
setDate,
|
|
32
|
+
required,
|
|
33
|
+
disabled,
|
|
34
|
+
autoFocus,
|
|
35
|
+
error,
|
|
36
|
+
helperText,
|
|
37
|
+
errorText,
|
|
38
|
+
isClearable = true,
|
|
39
|
+
className,
|
|
40
|
+
calendarPlacement,
|
|
41
|
+
}) => {
|
|
42
|
+
const [day, setDay] = useState(date?.split('-')[2] ?? '');
|
|
43
|
+
const [month, setMonth] = useState(date?.split('-')[1] ?? '');
|
|
44
|
+
const [year, setYear] = useState(date?.split('-')[0] ?? '');
|
|
45
|
+
|
|
46
|
+
const [isCalendarOpen, setIsCalendarOpen] = useState(false);
|
|
47
|
+
|
|
48
|
+
const inputsRef = useRef<HTMLDivElement>(null);
|
|
49
|
+
const dayRef = useRef<HTMLInputElement>(null);
|
|
50
|
+
const monthRef = useRef<HTMLInputElement>(null);
|
|
51
|
+
const yearRef = useRef<HTMLInputElement>(null);
|
|
52
|
+
|
|
53
|
+
const maxDay = year && month ? new Date(+year, +month, 0).getDate() : 31;
|
|
54
|
+
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
if (!date) {
|
|
57
|
+
setYear('');
|
|
58
|
+
setMonth('');
|
|
59
|
+
setDay('');
|
|
60
|
+
} else if (
|
|
61
|
+
![dayRef.current, monthRef.current, yearRef.current].includes(
|
|
62
|
+
document.activeElement as HTMLInputElement
|
|
63
|
+
)
|
|
64
|
+
) {
|
|
65
|
+
setYear(date.split('-')[0] ?? '');
|
|
66
|
+
setMonth(date.split('-')[1] ?? '');
|
|
67
|
+
setDay(date.split('-')[2] ?? '');
|
|
68
|
+
}
|
|
69
|
+
}, [date]);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<InputWrapper
|
|
73
|
+
label={label}
|
|
74
|
+
focus={isCalendarOpen}
|
|
75
|
+
required={required}
|
|
76
|
+
className={className}
|
|
77
|
+
disabled={disabled}
|
|
78
|
+
onClearInput={
|
|
79
|
+
isClearable && (day || month || year) && !disabled
|
|
80
|
+
? () => {
|
|
81
|
+
setDay('');
|
|
82
|
+
setMonth('');
|
|
83
|
+
setYear('');
|
|
84
|
+
setDate('');
|
|
85
|
+
}
|
|
86
|
+
: undefined
|
|
87
|
+
}
|
|
88
|
+
helperText={helperText}
|
|
89
|
+
error={error}
|
|
90
|
+
errorText={errorText}
|
|
91
|
+
>
|
|
92
|
+
<div className="date-input">
|
|
93
|
+
<Menu
|
|
94
|
+
isOpen={isCalendarOpen}
|
|
95
|
+
onClose={() => setIsCalendarOpen(false)}
|
|
96
|
+
placement={calendarPlacement ?? 'bottom-left'}
|
|
97
|
+
renderButton={ref => (
|
|
98
|
+
<div
|
|
99
|
+
ref={ref}
|
|
100
|
+
className="calendar-btn"
|
|
101
|
+
onClick={() => !disabled && setIsCalendarOpen(!isCalendarOpen)}
|
|
102
|
+
>
|
|
103
|
+
<FontAwesomeIcon icon={faCalendarPlus} className="icon" />
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
106
|
+
>
|
|
107
|
+
<Calendar
|
|
108
|
+
value={
|
|
109
|
+
date && dayjs(date, 'YYYY-MM-DD', true).isValid()
|
|
110
|
+
? new Date(date)
|
|
111
|
+
: new Date()
|
|
112
|
+
}
|
|
113
|
+
onChange={e => {
|
|
114
|
+
const newDate = formatDateYMD(e as Date);
|
|
115
|
+
setDate(newDate);
|
|
116
|
+
setIsCalendarOpen(false);
|
|
117
|
+
}}
|
|
118
|
+
locale={
|
|
119
|
+
i18next.language === 'sr_RS_Latn'
|
|
120
|
+
? 'sr-Latn-RS'
|
|
121
|
+
: i18next.language === 'sr_RS_Cyrl'
|
|
122
|
+
? 'sr-RS'
|
|
123
|
+
: i18next.language
|
|
124
|
+
}
|
|
125
|
+
formatShortWeekday={(locale, date) =>
|
|
126
|
+
new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date)
|
|
127
|
+
}
|
|
128
|
+
/>
|
|
129
|
+
</Menu>
|
|
130
|
+
<div ref={inputsRef} className="inputs" onClick={() => dayRef.current?.focus()}>
|
|
131
|
+
<DatePartInput
|
|
132
|
+
ref={dayRef}
|
|
133
|
+
value={day}
|
|
134
|
+
setValue={setDay}
|
|
135
|
+
setDate={setDate}
|
|
136
|
+
values={{ day, month, year }}
|
|
137
|
+
required={required || !!month || !!year}
|
|
138
|
+
disabled={disabled}
|
|
139
|
+
autoFocus={autoFocus}
|
|
140
|
+
max={maxDay}
|
|
141
|
+
part="day"
|
|
142
|
+
nextInput={monthRef.current}
|
|
143
|
+
/>
|
|
144
|
+
<span>.</span>
|
|
145
|
+
<DatePartInput
|
|
146
|
+
ref={monthRef}
|
|
147
|
+
value={month}
|
|
148
|
+
setValue={setMonth}
|
|
149
|
+
setDate={setDate}
|
|
150
|
+
values={{ day, month, year }}
|
|
151
|
+
required={required || !!day || !!year}
|
|
152
|
+
disabled={disabled}
|
|
153
|
+
max={12}
|
|
154
|
+
part="month"
|
|
155
|
+
previousInput={dayRef.current}
|
|
156
|
+
nextInput={yearRef.current}
|
|
157
|
+
/>
|
|
158
|
+
<span>.</span>
|
|
159
|
+
<DatePartInput
|
|
160
|
+
ref={yearRef}
|
|
161
|
+
value={year}
|
|
162
|
+
setValue={setYear}
|
|
163
|
+
setDate={setDate}
|
|
164
|
+
values={{ day, month, year }}
|
|
165
|
+
required={required || !!day || !!month}
|
|
166
|
+
disabled={disabled}
|
|
167
|
+
min={1500}
|
|
168
|
+
max={2500}
|
|
169
|
+
part="year"
|
|
170
|
+
previousInput={monthRef.current}
|
|
171
|
+
/>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
</InputWrapper>
|
|
175
|
+
);
|
|
176
|
+
};
|