@inceptionbg/iui 2.0.34 → 2.0.36

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 (244) hide show
  1. package/dist/index.d.ts +7 -6
  2. package/dist/index.js.map +1 -1
  3. package/dist/iui.css +1 -1
  4. package/package.json +25 -22
  5. package/idea/GridTable/GridTable.tsx +0 -119
  6. package/idea/GridTable/gridTable.scss +0 -42
  7. package/idea/Menu/Menu.tsx +0 -121
  8. package/idea/Menu/MenuItem.tsx +0 -75
  9. package/idea/Menu/hooks/useMenuControl.ts +0 -13
  10. package/idea/Menu.tsx +0 -133
  11. package/idea/NoAccessInfo.tsx +0 -193
  12. package/idea/Table/Components/Edit/ItemActionsMenu.tsx +0 -85
  13. package/idea/Table/Components/Edit/ItemEditOptionsButtons.tsx +0 -31
  14. package/idea/Table/Components/Edit/TableEditRow.tsx +0 -57
  15. package/idea/Table/Components/FilterItem.tsx +0 -20
  16. package/idea/Table/Components/Header/TableHeader.tsx +0 -46
  17. package/idea/Table/Components/Header/TableHeaderRow.tsx +0 -37
  18. package/idea/Table/Components/Print/CustomTablePrint.tsx +0 -115
  19. package/idea/Table/Components/SetSortList.tsx +0 -30
  20. package/idea/Table/Components/SetTableFilter.tsx +0 -91
  21. package/idea/Table/Components/TableFooter.tsx +0 -137
  22. package/idea/Table/Components/TableOptions.tsx +0 -227
  23. package/idea/Table/Components/Templates/TemplateCreate.tsx +0 -80
  24. package/idea/Table/Components/Templates/TemplateCreateDefault.tsx +0 -45
  25. package/idea/Table/Components/Templates/TemplateList.tsx +0 -167
  26. package/idea/Table/Components/Templates/repo/TemplateRepo.ts +0 -53
  27. package/idea/Table/Table.tsx +0 -528
  28. package/idea/Table/hooks/useDefaultTemplate.ts +0 -20
  29. package/idea/Table/hooks/useTableKeyboard.ts +0 -137
  30. package/idea/Table/hooks/useTableSelect.ts +0 -11
  31. package/rollup.config.js +0 -52
  32. package/src/assets/icons/duotone/faBell.ts +0 -17
  33. package/src/assets/icons/duotone/faCircleUser.ts +0 -17
  34. package/src/assets/icons/regular/faArrowLeft.ts +0 -15
  35. package/src/assets/icons/regular/faArrowRightArrowLeft.ts +0 -15
  36. package/src/assets/icons/regular/faCircleCheck.ts +0 -15
  37. package/src/assets/icons/regular/faCircleExclamation.ts +0 -15
  38. package/src/assets/icons/regular/faCircleInfo.ts +0 -15
  39. package/src/assets/icons/regular/faFileArrowDown.ts +0 -15
  40. package/src/assets/icons/regular/faFilterCircleXmark.ts +0 -15
  41. package/src/assets/icons/regular/faTriangleExclamation.ts +0 -15
  42. package/src/assets/icons/solid/faAngleLeft.ts +0 -15
  43. package/src/assets/icons/solid/faAngleRight.ts +0 -15
  44. package/src/assets/icons/solid/faArrowDownWideShort.ts +0 -15
  45. package/src/assets/icons/solid/faCaretDown.ts +0 -15
  46. package/src/assets/icons/solid/faCheck.ts +0 -15
  47. package/src/assets/icons/solid/faEllipsisVertical.ts +0 -15
  48. package/src/assets/icons/solid/faEnvelopeDot.ts +0 -15
  49. package/src/assets/icons/solid/faFilter.ts +0 -15
  50. package/src/assets/icons/solid/faFloppyDisk.ts +0 -15
  51. package/src/assets/icons/solid/faGripDotsVertical.ts +0 -15
  52. package/src/assets/icons/solid/faListUl.ts +0 -15
  53. package/src/assets/icons/solid/faMinus.ts +0 -15
  54. package/src/assets/icons/solid/faPlus.ts +0 -15
  55. package/src/assets/icons/solid/faPrint.ts +0 -15
  56. package/src/assets/icons/solid/faRotateRight.ts +0 -15
  57. package/src/assets/icons/solid/faXmark.ts +0 -15
  58. package/src/assets/images/logo/inception.svg +0 -22
  59. package/src/assets/images/logo/mts.svg +0 -5703
  60. package/src/assets/images/logo/paperless.svg +0 -21
  61. package/src/assets/images/logo/pismonosa.png +0 -0
  62. package/src/assets/images/not-found.svg +0 -19
  63. package/src/components/Accordions/Accordions.tsx +0 -74
  64. package/src/components/Alert/Alert.tsx +0 -31
  65. package/src/components/Badge/DotBadge.tsx +0 -16
  66. package/src/components/Badge/NotificationBadge.tsx +0 -29
  67. package/src/components/Badge/PillBadge.tsx +0 -13
  68. package/src/components/Button/Button.tsx +0 -56
  69. package/src/components/Button/IconButton.tsx +0 -51
  70. package/src/components/Button/SplitButton.tsx +0 -91
  71. package/src/components/Dashboard/Dashboard.tsx +0 -9
  72. package/src/components/Dashboard/DashboardWidget.tsx +0 -44
  73. package/src/components/Dashboard/FastLinksWidget/FastLinksWidget.tsx +0 -36
  74. package/src/components/Dialog/Dialog.tsx +0 -178
  75. package/src/components/Dialog/components/DialogFooter.tsx +0 -100
  76. package/src/components/Header/Components/EnvBadge.tsx +0 -17
  77. package/src/components/Header/Components/ModuleSelect.tsx +0 -68
  78. package/src/components/Header/Components/Notifications.tsx +0 -204
  79. package/src/components/Header/Components/UserMenu.tsx +0 -52
  80. package/src/components/Header/Header.tsx +0 -45
  81. package/src/components/Helper/Collapse.tsx +0 -53
  82. package/src/components/Inputs/Checkbox.tsx +0 -53
  83. package/src/components/Inputs/CurrencyInput.tsx +0 -124
  84. package/src/components/Inputs/DateInput/DateInput.tsx +0 -184
  85. package/src/components/Inputs/DateInput/components/DatePartInput.tsx +0 -159
  86. package/src/components/Inputs/InputWrapper.tsx +0 -95
  87. package/src/components/Inputs/NumberInput.tsx +0 -86
  88. package/src/components/Inputs/PasswordInput.tsx +0 -39
  89. package/src/components/Inputs/PhoneInput/PhoneInput.tsx +0 -108
  90. package/src/components/Inputs/PhoneInput/utils/countryCode.ts +0 -20
  91. package/src/components/Inputs/Radio.tsx +0 -59
  92. package/src/components/Inputs/RadioGroup.tsx +0 -48
  93. package/src/components/Inputs/RadioLarge.tsx +0 -39
  94. package/src/components/Inputs/SearchInput.tsx +0 -46
  95. package/src/components/Inputs/Selects/Select.tsx +0 -17
  96. package/src/components/Inputs/Selects/components/CustomSelectComponents.tsx +0 -19
  97. package/src/components/Inputs/Selects/components/SelectWrapper.tsx +0 -118
  98. package/src/components/Inputs/Selects/utils/selectStyles.ts +0 -101
  99. package/src/components/Inputs/TextAreaInput.tsx +0 -68
  100. package/src/components/Inputs/TextInput.tsx +0 -100
  101. package/src/components/Inputs/TimeInput/TimeInput.tsx +0 -81
  102. package/src/components/List/List.tsx +0 -21
  103. package/src/components/List/ListItem.tsx +0 -70
  104. package/src/components/Loader/Loader.tsx +0 -66
  105. package/src/components/Loader/ProgressBar.tsx +0 -41
  106. package/src/components/Menu/Menu.tsx +0 -81
  107. package/src/components/Menu/MenuItem.tsx +0 -46
  108. package/src/components/Menu/NewMenu.tsx +0 -63
  109. package/src/components/Menu/hooks/useMenuPosition.tsx +0 -116
  110. package/src/components/PageComponents/ScrollableContent.tsx +0 -11
  111. package/src/components/Pullover/Pullover.tsx +0 -197
  112. package/src/components/Router/Router.tsx +0 -52
  113. package/src/components/Sidebar/AddButton.tsx +0 -22
  114. package/src/components/Sidebar/Sidebar.tsx +0 -85
  115. package/src/components/Sidebar/SidebarItem.tsx +0 -84
  116. package/src/components/Sidebar/types/ISidebar.ts +0 -28
  117. package/src/components/Table/Table.tsx +0 -258
  118. package/src/components/Table/components/columns/ColumnsList.tsx +0 -60
  119. package/src/components/Table/components/columns/TableColumnsEdit.tsx +0 -114
  120. package/src/components/Table/components/edit/TableEditRow.tsx +0 -78
  121. package/src/components/Table/components/filters/FilterItem.tsx +0 -15
  122. package/src/components/Table/components/filters/TableFilters.tsx +0 -126
  123. package/src/components/Table/components/footer/TableFooter.tsx +0 -126
  124. package/src/components/Table/components/header/TableHeader.tsx +0 -40
  125. package/src/components/Table/components/header/TableHeaderRow.tsx +0 -57
  126. package/src/components/Table/components/items/TableItemActions.tsx +0 -78
  127. package/src/components/Table/components/print/TablePrint.tsx +0 -200
  128. package/src/components/Table/components/select/TableSelect.tsx +0 -50
  129. package/src/components/Table/components/sort/TableSort.tsx +0 -75
  130. package/src/components/Table/components/templates/CreateTemplateDialog.tsx +0 -58
  131. package/src/components/Table/components/templates/TableTemplates.tsx +0 -65
  132. package/src/components/Table/components/templates/TemplatesPullover.tsx +0 -88
  133. package/src/components/Table/contexts/TableContext.tsx +0 -117
  134. package/src/components/Table/hooks/localHooks/useLocalTableColumns.tsx +0 -70
  135. package/src/components/Table/hooks/localHooks/useLocalTableData.tsx +0 -82
  136. package/src/components/Table/hooks/localHooks/useLocalTableKeyboard.ts +0 -175
  137. package/src/components/Table/hooks/localHooks/useLocalTablePagination.ts +0 -12
  138. package/src/components/Table/hooks/useTableColumns.ts +0 -34
  139. package/src/components/Table/hooks/useTableEdit.tsx +0 -140
  140. package/src/components/Table/hooks/useTableFilterFields.tsx +0 -150
  141. package/src/components/Table/hooks/useTablePagination.ts +0 -19
  142. package/src/components/Table/hooks/useTablePrint.ts +0 -83
  143. package/src/components/Table/hooks/useTableSearch.ts +0 -31
  144. package/src/components/Table/hooks/useTableSelect.ts +0 -19
  145. package/src/components/Table/hooks/useTableSort.ts +0 -8
  146. package/src/components/Tabs/Tabs.tsx +0 -68
  147. package/src/components/Tooltip/Tooltip.tsx +0 -191
  148. package/src/components/Tree/Tree.tsx +0 -22
  149. package/src/components/Tree/TreeItem.tsx +0 -57
  150. package/src/components/Wrappers/AppLayout.tsx +0 -17
  151. package/src/components/Wrappers/ConditionalWrapper.tsx +0 -10
  152. package/src/components/Wrappers/FormWrapper.tsx +0 -84
  153. package/src/components/Wrappers/PageLayout.tsx +0 -168
  154. package/src/hooks/useBackgroundClose.ts +0 -19
  155. package/src/hooks/useGetFocusableElements.ts +0 -43
  156. package/src/hooks/useIsMenuOpen.ts +0 -11
  157. package/src/hooks/useLocalPopoverControl.ts +0 -63
  158. package/src/hooks/useOnEsc.ts +0 -14
  159. package/src/hooks/usePopupControl.ts +0 -22
  160. package/src/hooks/useZendesk.ts +0 -21
  161. package/src/index.ts +0 -387
  162. package/src/pages/NoAccessPage.tsx +0 -27
  163. package/src/pages/NotFoundPage.tsx +0 -26
  164. package/src/styles/App.scss +0 -47
  165. package/src/styles/common/_animations.scss +0 -58
  166. package/src/styles/common/_typography.scss +0 -91
  167. package/src/styles/common/helpers/_base.scss +0 -55
  168. package/src/styles/common/helpers/_color.scss +0 -10
  169. package/src/styles/common/helpers/_display.scss +0 -85
  170. package/src/styles/common/helpers/_size.scss +0 -25
  171. package/src/styles/common/maps/_align.scss +0 -21
  172. package/src/styles/common/maps/_buttonMaps.scss +0 -42
  173. package/src/styles/common/maps/_info-types.scss +0 -1
  174. package/src/styles/common/maps/_spacing.scss +0 -78
  175. package/src/styles/common/maps/_text.scss +0 -14
  176. package/src/styles/components/_accordions.scss +0 -51
  177. package/src/styles/components/_alert.scss +0 -23
  178. package/src/styles/components/_badge.scss +0 -84
  179. package/src/styles/components/_button.scss +0 -99
  180. package/src/styles/components/_buttonSplit.scss +0 -65
  181. package/src/styles/components/_card.scss +0 -24
  182. package/src/styles/components/_dialog.scss +0 -119
  183. package/src/styles/components/_form.scss +0 -8
  184. package/src/styles/components/_header.scss +0 -157
  185. package/src/styles/components/_input.scss +0 -167
  186. package/src/styles/components/_inputCheckbox.scss +0 -48
  187. package/src/styles/components/_inputDateTime.scss +0 -161
  188. package/src/styles/components/_inputRadio.scss +0 -83
  189. package/src/styles/components/_inputSelect.scss +0 -8
  190. package/src/styles/components/_list.scss +0 -58
  191. package/src/styles/components/_loader.scss +0 -55
  192. package/src/styles/components/_menu-v2.scss +0 -67
  193. package/src/styles/components/_menu.scss +0 -62
  194. package/src/styles/components/_notifications.scss +0 -71
  195. package/src/styles/components/_page.scss +0 -84
  196. package/src/styles/components/_portal.scss +0 -8
  197. package/src/styles/components/_print.scss +0 -77
  198. package/src/styles/components/_progressBar.scss +0 -83
  199. package/src/styles/components/_pullover.scss +0 -95
  200. package/src/styles/components/_scrollbar.scss +0 -18
  201. package/src/styles/components/_sidebar.scss +0 -204
  202. package/src/styles/components/_smallComponents.scss +0 -23
  203. package/src/styles/components/_table.scss +0 -340
  204. package/src/styles/components/_tabs.scss +0 -33
  205. package/src/styles/components/_tooltip.scss +0 -48
  206. package/src/styles/components/_tree.scss +0 -21
  207. package/src/styles/components/_widget.scss +0 -90
  208. package/src/styles/pages/_fullScreenPage.scss +0 -64
  209. package/src/styles/variables/_bp.scss +0 -6
  210. package/src/styles/variables/_variables.scss +0 -142
  211. package/src/types/Base/custom.d.ts +0 -9
  212. package/src/types/IBasic.ts +0 -32
  213. package/src/types/ICountryCode.ts +0 -5
  214. package/src/types/IError.ts +0 -5
  215. package/src/types/IHeader.ts +0 -40
  216. package/src/types/IInfo.ts +0 -1
  217. package/src/types/IKeyboard.ts +0 -33
  218. package/src/types/IMenu.ts +0 -19
  219. package/src/types/INotifications.ts +0 -15
  220. package/src/types/IPopup.ts +0 -17
  221. package/src/types/IRouter.ts +0 -6
  222. package/src/types/ISelect.ts +0 -54
  223. package/src/types/ITab.ts +0 -10
  224. package/src/types/ITable.ts +0 -291
  225. package/src/types/ITree.ts +0 -6
  226. package/src/utils/InputPatternValidation.ts +0 -12
  227. package/src/utils/dateUtils.ts +0 -32
  228. package/src/utils/fileUtils.ts +0 -177
  229. package/src/utils/i18n/i18nIUICyrilic.ts +0 -119
  230. package/src/utils/i18n/i18nIUILatin.ts +0 -120
  231. package/src/utils/i18n/i18nIUIMe.ts +0 -118
  232. package/src/utils/icons.ts +0 -13
  233. package/src/utils/localStorageHelper.ts +0 -24
  234. package/src/utils/logoUtils.ts +0 -7
  235. package/src/utils/numberUtils.ts +0 -21
  236. package/src/utils/objectUtils.ts +0 -114
  237. package/src/utils/popupUtils.ts +0 -82
  238. package/src/utils/rootDir.ts +0 -1
  239. package/src/utils/stringUtils.ts +0 -18
  240. package/src/utils/tableUtils.ts +0 -130
  241. package/src/utils/toasts.ts +0 -6
  242. package/src/utils/urlUtils.ts +0 -4
  243. package/tsconfig.icons.json +0 -5
  244. package/tsconfig.json +0 -22
@@ -1,124 +0,0 @@
1
- import type { FC, InputHTMLAttributes, Ref } from 'react';
2
- import { useState } from 'react';
3
- import { TextInput } from './TextInput';
4
-
5
- export interface ICurrencyInputProps {
6
- label?: string;
7
- value?: string | number;
8
- setValue: (value: string) => void;
9
- required?: boolean;
10
- disabled?: boolean;
11
- autoFocus?: boolean;
12
- placeholder?: string;
13
- helperText?: string;
14
- errorText?: string;
15
- error?: boolean;
16
- className?: string;
17
- allowNegative?: boolean;
18
- decimalPlaces?: number;
19
- align?: 'left' | 'right';
20
- endText?: string;
21
- inputProps?: InputHTMLAttributes<HTMLInputElement>;
22
- isClearable?: boolean;
23
- ref?: Ref<HTMLInputElement>;
24
- }
25
-
26
- const formatCurrency = (number?: string | number) => {
27
- if (!number) return '';
28
-
29
- const value = number.toString();
30
- let [intiger, decimal] = value.split('.');
31
- const formatedInt = intiger.replace(/\B(?=(\d{3})+(?!\d))/g, '.');
32
-
33
- return decimal
34
- ? `${formatedInt},${decimal}`
35
- : value.endsWith('.')
36
- ? `${formatedInt},`
37
- : formatedInt;
38
- };
39
-
40
- export const CurrencyInput: FC<ICurrencyInputProps> = ({
41
- value,
42
- setValue,
43
- label,
44
- required,
45
- disabled,
46
- autoFocus,
47
- placeholder,
48
- helperText,
49
- errorText,
50
- error,
51
- className,
52
- allowNegative,
53
- decimalPlaces = 2,
54
- align = 'right',
55
- endText,
56
- inputProps,
57
- isClearable,
58
- ref,
59
- }) => {
60
- const [formatedInput, setFormatedInput] = useState('');
61
-
62
- const inputElement = document.activeElement as HTMLInputElement;
63
-
64
- const setValueHandler = (e: string) => {
65
- const cursorPosition = inputElement.selectionStart;
66
- let inputValue = decimalPlaces
67
- ? e.replace(/\.$/, ',').replaceAll('.', '').replace(',', '.')
68
- : e.replaceAll('.', '');
69
-
70
- if (
71
- // Check if the input is valid
72
- new RegExp(
73
- `^${allowNegative ? '-?' : ''}\\d*${
74
- decimalPlaces ? `(?:[.,])?(\\d{1,${decimalPlaces}})?` : ''
75
- }$`
76
- ).test(inputValue) ||
77
- !e
78
- ) {
79
- const newValue = formatCurrency(inputValue);
80
-
81
- setFormatedInput(newValue);
82
- setValue(inputValue);
83
-
84
- // Adjust cursor position
85
- setTimeout(() => {
86
- const isDotAdded = newValue.length - formatedInput.length > 1;
87
-
88
- const adjustedCursorPosition = isDotAdded
89
- ? (cursorPosition as number) + 1
90
- : cursorPosition;
91
-
92
- inputElement.setSelectionRange &&
93
- inputElement.setSelectionRange(adjustedCursorPosition, adjustedCursorPosition);
94
- });
95
- }
96
- };
97
-
98
- return (
99
- <TextInput
100
- ref={ref}
101
- value={formatCurrency(value)}
102
- setValue={setValueHandler}
103
- label={label}
104
- required={required}
105
- disabled={disabled}
106
- endText={endText}
107
- isClearable={isClearable}
108
- placeholder={
109
- placeholder ? placeholder : decimalPlaces ? `0,${'0'.repeat(decimalPlaces)}` : '0'
110
- }
111
- inputProps={{
112
- className: `text-${align}`,
113
- lang: 'sr-RS',
114
- inputMode: 'numeric',
115
- ...inputProps,
116
- }}
117
- className={className}
118
- autoFocus={autoFocus}
119
- helperText={helperText}
120
- errorText={errorText}
121
- error={error}
122
- />
123
- );
124
- };
@@ -1,184 +0,0 @@
1
- import type { FC } from 'react';
2
- import type { IMenuPlacement } from '../../../types/IMenu';
3
- import { useEffect, useRef, useState } from 'react';
4
- import { faCalendarPlus } from '@inceptionbg/icons';
5
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
- import dayjs from 'dayjs';
7
- import { Calendar } from 'react-calendar';
8
- import { useTranslation } from 'react-i18next';
9
- import { formatDateYMD } from '../../../utils/dateUtils';
10
- import { Menu } from '../../Menu/Menu';
11
- import { InputWrapper } from '../InputWrapper';
12
- import { DatePartInput } from './components/DatePartInput';
13
-
14
- export interface IDateInputProps {
15
- label?: string;
16
- date?: string;
17
- setDate: (date: string) => void;
18
- required?: boolean;
19
- disabled?: boolean;
20
- autoFocus?: boolean;
21
- error?: boolean;
22
- helperText?: string;
23
- errorText?: string;
24
- isClearable?: boolean;
25
- onClear?: () => void;
26
- className?: string;
27
- calendarPlacement?: IMenuPlacement;
28
- }
29
-
30
- export const DateInput: FC<IDateInputProps> = ({
31
- label,
32
- date,
33
- setDate,
34
- required,
35
- disabled,
36
- autoFocus,
37
- error,
38
- helperText,
39
- errorText,
40
- isClearable = true,
41
- onClear,
42
- className,
43
- calendarPlacement,
44
- }) => {
45
- const [day, setDay] = useState(date?.split('-')[2] ?? '');
46
- const [month, setMonth] = useState(date?.split('-')[1] ?? '');
47
- const [year, setYear] = useState(date?.split('-')[0] ?? '');
48
- const { i18n } = useTranslation();
49
-
50
- const [isCalendarOpen, setIsCalendarOpen] = useState(false);
51
-
52
- const inputsRef = useRef<HTMLDivElement>(null);
53
- const dayRef = useRef<HTMLInputElement>(null);
54
- const monthRef = useRef<HTMLInputElement>(null);
55
- const yearRef = useRef<HTMLInputElement>(null);
56
-
57
- const maxDay = year && month ? new Date(+year, +month, 0).getDate() : 31;
58
-
59
- useEffect(() => {
60
- if (!date) {
61
- setYear('');
62
- setMonth('');
63
- setDay('');
64
- } else if (
65
- ![dayRef.current, monthRef.current, yearRef.current].includes(
66
- document.activeElement as HTMLInputElement
67
- )
68
- ) {
69
- setYear(date.split('-')[0] ?? '');
70
- setMonth(date.split('-')[1] ?? '');
71
- setDay(date.split('-')[2] ?? '');
72
- }
73
- }, [date]);
74
-
75
- return (
76
- <Menu
77
- isOpen={isCalendarOpen}
78
- onClose={() => setIsCalendarOpen(false)}
79
- placement={calendarPlacement}
80
- renderButton={ref => (
81
- <div ref={ref} className="full-width">
82
- <InputWrapper
83
- label={label}
84
- focus={isCalendarOpen}
85
- required={required}
86
- className={className}
87
- disabled={disabled}
88
- onClearInput={
89
- isClearable && (day || month || year) && !disabled
90
- ? () => {
91
- setDay('');
92
- setMonth('');
93
- setYear('');
94
- setDate('');
95
- onClear?.();
96
- }
97
- : undefined
98
- }
99
- helperText={helperText}
100
- error={error}
101
- errorText={errorText}
102
- >
103
- <div className="date-input">
104
- <div
105
- className="calendar-btn"
106
- onClick={() => !disabled && setIsCalendarOpen(!isCalendarOpen)}
107
- >
108
- <FontAwesomeIcon icon={faCalendarPlus} className="icon" />
109
- </div>
110
- <div
111
- ref={inputsRef}
112
- className="inputs"
113
- onClick={() => dayRef.current?.focus()}
114
- >
115
- <DatePartInput
116
- ref={dayRef}
117
- value={day}
118
- setValue={setDay}
119
- setDate={setDate}
120
- values={{ day, month, year }}
121
- required={required || !!month || !!year}
122
- disabled={disabled}
123
- autoFocus={autoFocus}
124
- max={maxDay}
125
- part="day"
126
- nextInput={monthRef.current}
127
- />
128
- <span>.</span>
129
- <DatePartInput
130
- ref={monthRef}
131
- value={month}
132
- setValue={setMonth}
133
- setDate={setDate}
134
- values={{ day, month, year }}
135
- required={required || !!day || !!year}
136
- disabled={disabled}
137
- max={12}
138
- part="month"
139
- previousInput={dayRef.current}
140
- nextInput={yearRef.current}
141
- />
142
- <span>.</span>
143
- <DatePartInput
144
- ref={yearRef}
145
- value={year}
146
- setValue={setYear}
147
- setDate={setDate}
148
- values={{ day, month, year }}
149
- required={required || !!day || !!month}
150
- disabled={disabled}
151
- min={1500}
152
- max={2500}
153
- part="year"
154
- previousInput={monthRef.current}
155
- />
156
- </div>
157
- </div>
158
- </InputWrapper>
159
- </div>
160
- )}
161
- >
162
- <Calendar
163
- value={
164
- date && dayjs(date, 'YYYY-MM-DD', true).isValid() ? new Date(date) : new Date()
165
- }
166
- onChange={e => {
167
- const newDate = formatDateYMD(e as Date);
168
- setDate(newDate);
169
- setIsCalendarOpen(false);
170
- }}
171
- locale={
172
- i18n.language === 'sr_RS_Latn'
173
- ? 'sr-Latn-RS'
174
- : i18n.language === 'sr_RS_Cyrl'
175
- ? 'sr-RS'
176
- : i18n.language
177
- }
178
- formatShortWeekday={(locale, date) =>
179
- new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date)
180
- }
181
- />
182
- </Menu>
183
- );
184
- };
@@ -1,159 +0,0 @@
1
- import type { FC, Ref, RefObject } from 'react';
2
- import { useEffect, useRef, useState } from 'react';
3
- import clsx from 'clsx';
4
-
5
- interface Props {
6
- value: string;
7
- setValue: (value: string) => void;
8
- setDate: (value: string) => void;
9
- values: { day: string; month: string; year: string };
10
- required?: boolean;
11
- disabled?: boolean;
12
- autoFocus?: boolean;
13
- min?: number;
14
- max: number;
15
- part: 'day' | 'month' | 'year';
16
- previousInput?: HTMLInputElement | null;
17
- nextInput?: HTMLInputElement | null;
18
- ref?: Ref<HTMLInputElement>;
19
- }
20
-
21
- const options = {
22
- day: {
23
- placeholder: '31',
24
- regex: `^[0-9]{2}`,
25
- },
26
- month: {
27
- placeholder: '12',
28
- regex: `^[0-9]{2}`,
29
- },
30
- year: {
31
- placeholder: '2000',
32
- regex: `^[0-9]{4}`,
33
- },
34
- };
35
-
36
- const measureTextWidth = (text: string, font: string): number => {
37
- const canvas = document.createElement('canvas');
38
- const context = canvas.getContext('2d');
39
- if (!context) return 0;
40
-
41
- context.font = font;
42
- const metrics = context.measureText(text ?? '00');
43
- return Math.ceil(metrics.width);
44
- };
45
-
46
- export const DatePartInput: FC<Props> = ({
47
- value,
48
- setValue,
49
- setDate,
50
- values,
51
- required,
52
- disabled,
53
- autoFocus,
54
- min = 1,
55
- max,
56
- part,
57
- previousInput,
58
- nextInput,
59
- ref,
60
- }) => {
61
- const [isInvalid, setIsInvalid] = useState(false);
62
- const localRef = useRef<HTMLInputElement>(null);
63
- const inputRef = (ref || localRef) as RefObject<HTMLInputElement>;
64
-
65
- useEffect(() => {
66
- if (!value.length) {
67
- setIsInvalid(false);
68
- } else if ((part === 'year' && value.length !== 4) || +value > max || +value < min) {
69
- setIsInvalid(true);
70
- } else if (isInvalid) {
71
- setIsInvalid(false);
72
- }
73
- }, [part, min, max, value, isInvalid]);
74
-
75
- const regexTest = `^[0-9]{0,${max.toString().length}}$`;
76
-
77
- const setValueHandler = (newValue: string) => {
78
- if (!newValue) {
79
- setValue('');
80
- } else if (new RegExp(regexTest).test(newValue)) {
81
- setValue(newValue);
82
- const year = part === 'year' ? newValue : values.year;
83
- const month = part === 'month' ? newValue : values.month;
84
- const day = part === 'day' ? newValue : values.day;
85
-
86
- if (day && month && year.length === 4) {
87
- setDate(
88
- `${year}-${month.length === 2 ? month : `0${month}`}-${
89
- day.length === 2 ? day : `0${day}`
90
- }`
91
- );
92
- }
93
- }
94
- };
95
-
96
- useEffect(() => {
97
- if (typeof window !== 'undefined') {
98
- const element = inputRef?.current;
99
- if (element) {
100
- const computedStyle = window.getComputedStyle(element);
101
- const font = computedStyle.font;
102
-
103
- const displayValue = value || options[part].placeholder;
104
- const measuredWidth = measureTextWidth(displayValue, font);
105
- element.style.width = measuredWidth + 'px';
106
- }
107
- }
108
- }, [inputRef, value, part]);
109
-
110
- return (
111
- <input
112
- ref={inputRef}
113
- value={value || ''}
114
- onChange={e => setValueHandler(e.target.value)}
115
- onClick={e => e.stopPropagation()}
116
- onKeyDown={e => {
117
- if (e.key === 'ArrowLeft') {
118
- e.preventDefault();
119
- e.stopPropagation();
120
- previousInput?.select();
121
- } else if (e.key === 'ArrowRight') {
122
- e.preventDefault();
123
- e.stopPropagation();
124
- nextInput?.select();
125
- } else if (e.key === 'ArrowUp') {
126
- e.preventDefault();
127
- e.stopPropagation();
128
- +value < max && setValueHandler(`${value ? +value + 1 : min}`);
129
- } else if (e.key === 'ArrowDown') {
130
- e.preventDefault();
131
- e.stopPropagation();
132
- +value > min && setValueHandler(`${value ? +value - 1 : min}`);
133
- }
134
- }}
135
- onKeyUp={e => {
136
- if (part !== 'year' && isFinite(+e.key) && value.length === 2) {
137
- nextInput?.select();
138
- }
139
- }}
140
- onFocus={e => e.target.select()}
141
- onBlur={() => {
142
- if (part !== 'year' && value && value.length < 2) {
143
- setValueHandler(value.padStart(2, '0'));
144
- }
145
- }}
146
- required={required}
147
- disabled={disabled}
148
- autoFocus={autoFocus}
149
- min={min}
150
- max={max}
151
- inputMode="numeric"
152
- type="text"
153
- tabIndex={part !== 'day' ? -1 : undefined}
154
- placeholder={options[part].placeholder}
155
- pattern={options[part].regex}
156
- className={clsx({ error: isInvalid })}
157
- />
158
- );
159
- };
@@ -1,95 +0,0 @@
1
- import type { IconDefinition } from '@fortawesome/fontawesome-svg-core';
2
- import type { FC, ReactNode, Ref } from 'react';
3
- import { faCircleXmark } from '@inceptionbg/icons';
4
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
- import clsx from 'clsx';
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
- inputFieldRef?: Ref<HTMLDivElement>;
26
- children: ReactNode;
27
- }
28
- export const InputWrapper: FC<Props> = ({
29
- label,
30
- required,
31
- disabled,
32
- className,
33
- minWidth,
34
- endText,
35
- endButton,
36
- onClearInput,
37
- helperText,
38
- errorText,
39
- error,
40
- focus,
41
- heightAuto,
42
- inputFieldRef,
43
- children,
44
- }) => {
45
- const withEndSection = !!(endText || endButton || onClearInput);
46
-
47
- return (
48
- <div
49
- className={clsx('iui-input-container', className, {
50
- focus,
51
- error,
52
- disabled,
53
- })}
54
- style={{ minWidth }}
55
- >
56
- {label && <p className={clsx('input-label', { required })}>{label}</p>}
57
- <div
58
- ref={inputFieldRef}
59
- className={clsx('iui-input-wrapper-field', {
60
- 'with-end-section': withEndSection,
61
- 'height-auto': heightAuto,
62
- })}
63
- >
64
- {children}
65
- {withEndSection && (
66
- <div className="end-section">
67
- {endText && <p>{endText}</p>}
68
- {!!onClearInput && (
69
- <FontAwesomeIcon
70
- icon={faCircleXmark}
71
- className="icon"
72
- onClick={onClearInput}
73
- />
74
- )}
75
- {endButton && (
76
- <FontAwesomeIcon
77
- className={clsx('icon', { disabled: endButton.disabled })}
78
- icon={endButton.icon}
79
- onClick={!endButton.disabled ? endButton.onClick : undefined}
80
- role="button"
81
- type="button"
82
- />
83
- )}
84
- </div>
85
- )}
86
- </div>
87
- {helperText && (
88
- <p className={clsx('helper-text', { 'helper-hidden': errorText })}>
89
- {helperText}
90
- </p>
91
- )}
92
- {errorText && <p className="helper-text error-text">{errorText}</p>}
93
- </div>
94
- );
95
- };
@@ -1,86 +0,0 @@
1
- import type { 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
- onClear?: () => void;
15
- helperText?: string;
16
- errorText?: string;
17
- error?: boolean;
18
- className?: string;
19
- allowNegative?: boolean;
20
- decimalPlaces?: number;
21
- align?: 'left' | 'right';
22
- inputProps?: InputHTMLAttributes<HTMLInputElement>;
23
- ref?: Ref<HTMLInputElement>;
24
- }
25
-
26
- export const NumberInput: FC<INumberInputProps> = ({
27
- value,
28
- setValue,
29
- label,
30
- required,
31
- disabled,
32
- autoFocus,
33
- placeholder,
34
- endText,
35
- isClearable,
36
- onClear,
37
- helperText,
38
- errorText,
39
- error,
40
- className,
41
- allowNegative,
42
- decimalPlaces,
43
- align = 'left',
44
- inputProps,
45
- ref,
46
- }) => {
47
- const setValueHandler = (e: string) => {
48
- if (decimalPlaces) {
49
- (new RegExp(
50
- `^${allowNegative ? '-?' : ''}\\d*(?:[.,])?(\\d{1,${decimalPlaces}})?$`
51
- ).test(e) ||
52
- !e) &&
53
- setValue(e ? e.replaceAll(',', '.') : e);
54
- } else {
55
- (new RegExp(`^${allowNegative ? '-?' : ''}\\d*$`).test(e) || !e) && setValue(e);
56
- }
57
- };
58
-
59
- return (
60
- <TextInput
61
- ref={ref}
62
- value={value ? `${value}`.replaceAll('.', ',') : ''}
63
- setValue={setValueHandler}
64
- label={label}
65
- required={required}
66
- disabled={disabled}
67
- endText={endText}
68
- isClearable={isClearable}
69
- onClear={onClear}
70
- placeholder={
71
- placeholder ? placeholder : decimalPlaces ? `0.${'0'.repeat(decimalPlaces)}` : '0'
72
- }
73
- inputProps={{
74
- className: `text-${align}`,
75
- lang: 'sr-RS',
76
- inputMode: 'numeric',
77
- ...inputProps,
78
- }}
79
- className={className}
80
- autoFocus={autoFocus}
81
- helperText={helperText}
82
- errorText={errorText}
83
- error={error}
84
- />
85
- );
86
- };
@@ -1,39 +0,0 @@
1
- import type { FC, InputHTMLAttributes, Ref } from 'react';
2
- import { useState } from 'react';
3
- import { faEye, faEyeSlash } from '@inceptionbg/icons';
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
- ref?: Ref<HTMLInputElement>;
20
- }
21
-
22
- export const PasswordInput: FC<IPasswordInputProps> = props => {
23
- const [showPassword, setShowPassword] = useState(false);
24
- return (
25
- <TextInput
26
- {...props}
27
- isClearable={props.isClearable ?? false}
28
- inputProps={{
29
- type: showPassword ? 'text' : 'password',
30
- autoComplete: props.newPassword ? 'new-password' : undefined,
31
- ...props.inputProps,
32
- }}
33
- endButton={{
34
- icon: showPassword ? faEyeSlash : faEye,
35
- onClick: () => setShowPassword(!showPassword),
36
- }}
37
- />
38
- );
39
- };