@inceptionbg/iui 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{NoAccessPage-BllwaG2u.js → NoAccessPage-C6nBt-PN.js} +2 -2
- package/dist/{NoAccessPage-BllwaG2u.js.map → NoAccessPage-C6nBt-PN.js.map} +1 -1
- package/dist/{NotFoundPage-DVm00-sr.js → NotFoundPage-DatmJOrr.js} +2 -2
- package/dist/{NotFoundPage-DVm00-sr.js.map → NotFoundPage-DatmJOrr.js.map} +1 -1
- package/dist/icons/index.d.ts +43 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +57 -49
- 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 +15 -11
- 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,154 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { FC, Ref, RefObject, useEffect, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
value: string;
|
|
6
|
+
setValue: (value: string) => void;
|
|
7
|
+
setDate: (value: string) => void;
|
|
8
|
+
values: { day: string; month: string; year: string };
|
|
9
|
+
required?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
autoFocus?: boolean;
|
|
12
|
+
min?: number;
|
|
13
|
+
max: number;
|
|
14
|
+
part: 'day' | 'month' | 'year';
|
|
15
|
+
previousInput?: HTMLInputElement | null;
|
|
16
|
+
nextInput?: HTMLInputElement | null;
|
|
17
|
+
ref?: Ref<HTMLInputElement>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const options = {
|
|
21
|
+
day: {
|
|
22
|
+
placeholder: 'dd',
|
|
23
|
+
regex: `^[0-9]{2}`,
|
|
24
|
+
},
|
|
25
|
+
month: {
|
|
26
|
+
placeholder: 'mm',
|
|
27
|
+
regex: `^[0-9]{2}`,
|
|
28
|
+
},
|
|
29
|
+
year: {
|
|
30
|
+
placeholder: 'yyyy',
|
|
31
|
+
regex: `^[0-9]{4}`,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const measureTextWidth = (text: string, font: string): number => {
|
|
36
|
+
const canvas = document.createElement('canvas');
|
|
37
|
+
const context = canvas.getContext('2d');
|
|
38
|
+
if (!context) return 0;
|
|
39
|
+
|
|
40
|
+
context.font = font;
|
|
41
|
+
const metrics = context.measureText(text ?? '00');
|
|
42
|
+
return Math.ceil(metrics.width);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const DatePartInput: FC<Props> = ({
|
|
46
|
+
value,
|
|
47
|
+
setValue,
|
|
48
|
+
setDate,
|
|
49
|
+
values,
|
|
50
|
+
required,
|
|
51
|
+
disabled,
|
|
52
|
+
autoFocus,
|
|
53
|
+
min = 1,
|
|
54
|
+
max,
|
|
55
|
+
part,
|
|
56
|
+
previousInput,
|
|
57
|
+
nextInput,
|
|
58
|
+
ref,
|
|
59
|
+
}) => {
|
|
60
|
+
const [isInvalid, setIsInvalid] = useState(false);
|
|
61
|
+
const localRef = useRef<HTMLInputElement>(null);
|
|
62
|
+
const inputRef = (ref || localRef) as RefObject<HTMLInputElement>;
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!value.length) {
|
|
66
|
+
setIsInvalid(false);
|
|
67
|
+
} else if ((part === 'year' && value.length !== 4) || +value > max || +value < min) {
|
|
68
|
+
setIsInvalid(true);
|
|
69
|
+
} else if (isInvalid) {
|
|
70
|
+
setIsInvalid(false);
|
|
71
|
+
}
|
|
72
|
+
}, [part, min, max, value, isInvalid]);
|
|
73
|
+
|
|
74
|
+
const regexTest = `^[0-9]{0,${max.toString().length}}$`;
|
|
75
|
+
|
|
76
|
+
const setValueHandler = (newValue: string) => {
|
|
77
|
+
if (!newValue) {
|
|
78
|
+
setValue('');
|
|
79
|
+
} else if (new RegExp(regexTest).test(newValue)) {
|
|
80
|
+
setValue(newValue);
|
|
81
|
+
const year = part === 'year' ? newValue : values.year;
|
|
82
|
+
const month = part === 'month' ? newValue : values.month;
|
|
83
|
+
const day = part === 'day' ? newValue : values.day;
|
|
84
|
+
|
|
85
|
+
if (day && month && year.length === 4) {
|
|
86
|
+
setDate(
|
|
87
|
+
`${year}-${month.length === 2 ? month : `0${month}`}-${
|
|
88
|
+
day.length === 2 ? day : `0${day}`
|
|
89
|
+
}`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (typeof window !== 'undefined') {
|
|
97
|
+
const element = inputRef?.current;
|
|
98
|
+
if (element) {
|
|
99
|
+
const computedStyle = window.getComputedStyle(element);
|
|
100
|
+
const font = computedStyle.font;
|
|
101
|
+
|
|
102
|
+
const displayValue = value || options[part].placeholder;
|
|
103
|
+
const measuredWidth = measureTextWidth(displayValue, font);
|
|
104
|
+
element.style.width = measuredWidth + 'px';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}, [inputRef, value, part]);
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<input
|
|
111
|
+
ref={inputRef}
|
|
112
|
+
value={value || ''}
|
|
113
|
+
onChange={e => setValueHandler(e.target.value)}
|
|
114
|
+
onClick={e => e.stopPropagation()}
|
|
115
|
+
onKeyDown={e => {
|
|
116
|
+
if (e.key === 'ArrowLeft') {
|
|
117
|
+
e.preventDefault();
|
|
118
|
+
previousInput?.select();
|
|
119
|
+
} else if (e.key === 'ArrowRight') {
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
nextInput?.select();
|
|
122
|
+
} else if (e.key === 'ArrowUp') {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
+value < max && setValueHandler(`${value ? +value + 1 : min}`);
|
|
125
|
+
} else if (e.key === 'ArrowDown') {
|
|
126
|
+
e.preventDefault();
|
|
127
|
+
+value > min && setValueHandler(`${value ? +value - 1 : min}`);
|
|
128
|
+
}
|
|
129
|
+
}}
|
|
130
|
+
onKeyUp={e => {
|
|
131
|
+
if (part !== 'year' && isFinite(+e.key) && value.length === 2) {
|
|
132
|
+
nextInput?.select();
|
|
133
|
+
}
|
|
134
|
+
}}
|
|
135
|
+
onFocus={e => e.target.select()}
|
|
136
|
+
onBlur={() => {
|
|
137
|
+
if (part !== 'year' && value && value.length < 2) {
|
|
138
|
+
setValueHandler(value.padStart(2, '0'));
|
|
139
|
+
}
|
|
140
|
+
}}
|
|
141
|
+
required={required}
|
|
142
|
+
disabled={disabled}
|
|
143
|
+
autoFocus={autoFocus}
|
|
144
|
+
min={min}
|
|
145
|
+
max={max}
|
|
146
|
+
inputMode="numeric"
|
|
147
|
+
type="text"
|
|
148
|
+
tabIndex={part !== 'day' ? -1 : undefined}
|
|
149
|
+
placeholder={options[part].placeholder}
|
|
150
|
+
pattern={options[part].regex}
|
|
151
|
+
className={clsx({ error: isInvalid })}
|
|
152
|
+
/>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
import { FC, ReactNode } from 'react';
|
|
5
|
+
import { faCircleXmark } from '../../assets/icons';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
label?: string;
|
|
9
|
+
required?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
className?: string;
|
|
12
|
+
minWidth?: number;
|
|
13
|
+
endText?: string;
|
|
14
|
+
endButton?: {
|
|
15
|
+
icon: IconDefinition;
|
|
16
|
+
onClick: () => void;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
onClearInput?: () => void;
|
|
20
|
+
helperText?: string;
|
|
21
|
+
errorText?: string;
|
|
22
|
+
error?: boolean;
|
|
23
|
+
focus?: boolean;
|
|
24
|
+
heightAuto?: boolean;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
}
|
|
27
|
+
export const InputWrapper: FC<Props> = ({
|
|
28
|
+
label,
|
|
29
|
+
required,
|
|
30
|
+
disabled,
|
|
31
|
+
className,
|
|
32
|
+
minWidth,
|
|
33
|
+
endText,
|
|
34
|
+
endButton,
|
|
35
|
+
onClearInput,
|
|
36
|
+
helperText,
|
|
37
|
+
errorText,
|
|
38
|
+
error,
|
|
39
|
+
focus,
|
|
40
|
+
heightAuto,
|
|
41
|
+
children,
|
|
42
|
+
}) => {
|
|
43
|
+
const withEndSection = !!(endText || endButton || onClearInput);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<div
|
|
47
|
+
className={clsx('iui-input-container', className, {
|
|
48
|
+
focus,
|
|
49
|
+
error,
|
|
50
|
+
disabled,
|
|
51
|
+
})}
|
|
52
|
+
style={{ minWidth }}
|
|
53
|
+
>
|
|
54
|
+
{label && <p className={clsx('input-label', { required })}>{label}</p>}
|
|
55
|
+
<div
|
|
56
|
+
className={clsx('iui-input-wrapper-field', {
|
|
57
|
+
'with-end-section': withEndSection,
|
|
58
|
+
'height-auto': heightAuto,
|
|
59
|
+
})}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
{withEndSection && (
|
|
63
|
+
<div className="end-section">
|
|
64
|
+
{endText && <p>{endText}</p>}
|
|
65
|
+
{!!onClearInput && (
|
|
66
|
+
<FontAwesomeIcon
|
|
67
|
+
icon={faCircleXmark}
|
|
68
|
+
className="icon"
|
|
69
|
+
onClick={onClearInput}
|
|
70
|
+
/>
|
|
71
|
+
)}
|
|
72
|
+
{endButton && (
|
|
73
|
+
<FontAwesomeIcon
|
|
74
|
+
className={clsx('icon', { disabled: endButton.disabled })}
|
|
75
|
+
icon={endButton.icon}
|
|
76
|
+
onClick={!endButton.disabled ? endButton.onClick : undefined}
|
|
77
|
+
/>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
{helperText && (
|
|
83
|
+
<p className={clsx('helper-text', { 'helper-hidden': errorText })}>
|
|
84
|
+
{helperText}
|
|
85
|
+
</p>
|
|
86
|
+
)}
|
|
87
|
+
{errorText && <p className="helper-text error-text">{errorText}</p>}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { FC, InputHTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { TextInput } from './TextInput';
|
|
3
|
+
|
|
4
|
+
export interface INumberInputProps {
|
|
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
|
+
endText?: string;
|
|
13
|
+
isClearable?: boolean;
|
|
14
|
+
helperText?: string;
|
|
15
|
+
errorText?: string;
|
|
16
|
+
error?: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
allowNegative?: boolean;
|
|
19
|
+
decimalPlaces?: number;
|
|
20
|
+
align?: 'left' | 'right';
|
|
21
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
22
|
+
ref?: Ref<HTMLInputElement>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const NumberInput: FC<INumberInputProps> = ({
|
|
26
|
+
value,
|
|
27
|
+
setValue,
|
|
28
|
+
label,
|
|
29
|
+
required,
|
|
30
|
+
disabled,
|
|
31
|
+
autoFocus,
|
|
32
|
+
placeholder,
|
|
33
|
+
endText,
|
|
34
|
+
isClearable,
|
|
35
|
+
helperText,
|
|
36
|
+
errorText,
|
|
37
|
+
error,
|
|
38
|
+
className,
|
|
39
|
+
allowNegative,
|
|
40
|
+
decimalPlaces,
|
|
41
|
+
align = 'left',
|
|
42
|
+
inputProps,
|
|
43
|
+
ref,
|
|
44
|
+
}) => {
|
|
45
|
+
const setValueHandler = (e: string) => {
|
|
46
|
+
if (decimalPlaces) {
|
|
47
|
+
(new RegExp(
|
|
48
|
+
`^${allowNegative ? '-?' : ''}\\d*(?:[.,])?(\\d{1,${decimalPlaces}})?$`
|
|
49
|
+
).test(e) ||
|
|
50
|
+
!e) &&
|
|
51
|
+
setValue(e ? e.replaceAll(',', '.') : e);
|
|
52
|
+
} else {
|
|
53
|
+
(new RegExp(`^${allowNegative ? '-?' : ''}\\d*$`).test(e) || !e) && setValue(e);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<TextInput
|
|
59
|
+
ref={ref}
|
|
60
|
+
value={value ? `${value}`.replaceAll('.', ',') : ''}
|
|
61
|
+
setValue={setValueHandler}
|
|
62
|
+
label={label}
|
|
63
|
+
required={required}
|
|
64
|
+
disabled={disabled}
|
|
65
|
+
endText={endText}
|
|
66
|
+
isClearable={isClearable}
|
|
67
|
+
placeholder={
|
|
68
|
+
placeholder ? placeholder : decimalPlaces ? `0.${'0'.repeat(decimalPlaces)}` : '0'
|
|
69
|
+
}
|
|
70
|
+
inputProps={{
|
|
71
|
+
className: `text-${align}`,
|
|
72
|
+
lang: 'sr-RS',
|
|
73
|
+
inputMode: 'numeric',
|
|
74
|
+
...inputProps,
|
|
75
|
+
}}
|
|
76
|
+
className={className}
|
|
77
|
+
autoFocus={autoFocus}
|
|
78
|
+
helperText={helperText}
|
|
79
|
+
errorText={errorText}
|
|
80
|
+
error={error}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FC, InputHTMLAttributes, useState } from 'react';
|
|
2
|
+
import { faEye } from '../../assets/icons/light/faEye';
|
|
3
|
+
import { faEyeSlash } from '../../assets/icons/light/faEyeSlash';
|
|
4
|
+
import { TextInput } from './TextInput';
|
|
5
|
+
|
|
6
|
+
export interface IPasswordInputProps {
|
|
7
|
+
label?: string;
|
|
8
|
+
value?: string;
|
|
9
|
+
setValue?: (value: string) => void;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
isClearable?: boolean;
|
|
13
|
+
pattern?: string;
|
|
14
|
+
helperText?: string;
|
|
15
|
+
errorText?: string;
|
|
16
|
+
error?: boolean;
|
|
17
|
+
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
18
|
+
newPassword?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const PasswordInput: FC<IPasswordInputProps> = props => {
|
|
22
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
23
|
+
return (
|
|
24
|
+
<TextInput
|
|
25
|
+
{...props}
|
|
26
|
+
isClearable={props.isClearable ?? false}
|
|
27
|
+
inputProps={{
|
|
28
|
+
type: showPassword ? 'text' : 'password',
|
|
29
|
+
autoComplete: props.newPassword ? 'new-password' : undefined,
|
|
30
|
+
...props.inputProps,
|
|
31
|
+
}}
|
|
32
|
+
endButton={{
|
|
33
|
+
icon: showPassword ? faEyeSlash : faEye,
|
|
34
|
+
onClick: () => setShowPassword(!showPassword),
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { FC, ReactNode, Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface IRadioProps {
|
|
5
|
+
label?: string;
|
|
6
|
+
desc?: string;
|
|
7
|
+
value: string | number | boolean;
|
|
8
|
+
selected: string | number | boolean | undefined | null;
|
|
9
|
+
setSelected: (selected: any) => void;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
groupName?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
className?: string;
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
ref?: Ref<HTMLDivElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Radio: FC<IRadioProps> = ({
|
|
19
|
+
label,
|
|
20
|
+
desc,
|
|
21
|
+
value,
|
|
22
|
+
selected,
|
|
23
|
+
setSelected,
|
|
24
|
+
required,
|
|
25
|
+
groupName,
|
|
26
|
+
disabled,
|
|
27
|
+
className,
|
|
28
|
+
children,
|
|
29
|
+
ref,
|
|
30
|
+
}) => (
|
|
31
|
+
<div
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={clsx(
|
|
34
|
+
'iui-radio',
|
|
35
|
+
className,
|
|
36
|
+
selected === value ? 'selected' : 'clickable',
|
|
37
|
+
{ disabled }
|
|
38
|
+
)}
|
|
39
|
+
onClick={selected !== value && !disabled ? () => setSelected(value) : undefined}
|
|
40
|
+
>
|
|
41
|
+
<div className={clsx('icon', { selected: selected === value })}>
|
|
42
|
+
<div className="dot" />
|
|
43
|
+
{required && !disabled && !selected && (
|
|
44
|
+
<input
|
|
45
|
+
className="fake-input"
|
|
46
|
+
type="radio"
|
|
47
|
+
name={groupName}
|
|
48
|
+
required
|
|
49
|
+
tabIndex={-1}
|
|
50
|
+
// onFocus={() => ref?.current?.focus()}
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
53
|
+
</div>
|
|
54
|
+
<div className="radio-content">
|
|
55
|
+
{label ? <p className="label">{label}</p> : children}
|
|
56
|
+
{desc && <p className="desc">{desc}</p>}
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
import { Radio } from './Radio';
|
|
4
|
+
|
|
5
|
+
interface IRadioGroupProps {
|
|
6
|
+
name: string;
|
|
7
|
+
items: {
|
|
8
|
+
value: string;
|
|
9
|
+
label: string;
|
|
10
|
+
desc?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
hidden?: boolean;
|
|
13
|
+
}[];
|
|
14
|
+
selected: string | number | boolean | undefined | null;
|
|
15
|
+
setSelected: (selected: any) => void;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
align?: 'column' | 'row';
|
|
18
|
+
className?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const RadioGroup: FC<IRadioGroupProps> = ({
|
|
22
|
+
name,
|
|
23
|
+
items,
|
|
24
|
+
selected,
|
|
25
|
+
setSelected,
|
|
26
|
+
required,
|
|
27
|
+
align = 'column',
|
|
28
|
+
className,
|
|
29
|
+
}) => (
|
|
30
|
+
<div className={clsx('radio-group', align, className)}>
|
|
31
|
+
{items.map(
|
|
32
|
+
e =>
|
|
33
|
+
!e.hidden && (
|
|
34
|
+
<Radio
|
|
35
|
+
key={e.value}
|
|
36
|
+
label={e.label}
|
|
37
|
+
desc={e.desc}
|
|
38
|
+
value={e.value}
|
|
39
|
+
disabled={e.disabled}
|
|
40
|
+
required={required}
|
|
41
|
+
groupName={name}
|
|
42
|
+
selected={selected}
|
|
43
|
+
setSelected={setSelected}
|
|
44
|
+
/>
|
|
45
|
+
)
|
|
46
|
+
)}
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Dispatch, FC, ReactElement, ReactNode, SetStateAction } from 'react';
|
|
2
|
+
import { Radio } from './Radio';
|
|
3
|
+
import clsx from 'clsx';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
title?: string | ReactElement;
|
|
7
|
+
desc?: string | ReactElement;
|
|
8
|
+
value: string;
|
|
9
|
+
selected: string;
|
|
10
|
+
setSelected: Dispatch<SetStateAction<any>>;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
className?: string;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const RadioLarge: FC<Props> = ({
|
|
17
|
+
title,
|
|
18
|
+
desc,
|
|
19
|
+
value,
|
|
20
|
+
selected,
|
|
21
|
+
setSelected,
|
|
22
|
+
disabled,
|
|
23
|
+
className,
|
|
24
|
+
children,
|
|
25
|
+
}) => (
|
|
26
|
+
<Radio
|
|
27
|
+
value={value}
|
|
28
|
+
selected={selected}
|
|
29
|
+
setSelected={setSelected}
|
|
30
|
+
disabled={disabled}
|
|
31
|
+
className={clsx('radio-large', className)}
|
|
32
|
+
>
|
|
33
|
+
<div className="full-width">
|
|
34
|
+
<p className="bold mb-3">{title}</p>
|
|
35
|
+
<p>{desc}</p>
|
|
36
|
+
<div>{children}</div>
|
|
37
|
+
</div>
|
|
38
|
+
</Radio>
|
|
39
|
+
);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FC, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { TextInput } from './TextInput';
|
|
4
|
+
import { faMagnifyingGlass } from '../../assets/icons';
|
|
5
|
+
|
|
6
|
+
interface IProps {
|
|
7
|
+
label?: string;
|
|
8
|
+
onSearch: (searchText: string) => void;
|
|
9
|
+
onClear?: () => void;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
export const SearchInput: FC<IProps> = ({ label, onSearch, onClear, className }) => {
|
|
13
|
+
const [text, setText] = useState('');
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<TextInput
|
|
18
|
+
className={className}
|
|
19
|
+
inputProps={{
|
|
20
|
+
'aria-label': 'search',
|
|
21
|
+
onKeyDown: (e: any) => {
|
|
22
|
+
if (e.key === 'Enter') {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
e.preventDefault();
|
|
25
|
+
onSearch(e.target.value);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
}}
|
|
29
|
+
label={label}
|
|
30
|
+
placeholder={t('Search')}
|
|
31
|
+
value={text}
|
|
32
|
+
setValue={setText}
|
|
33
|
+
onClear={onClear}
|
|
34
|
+
endButton={{
|
|
35
|
+
icon: faMagnifyingGlass,
|
|
36
|
+
onClick: () => onSearch(text),
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
};
|