@inceptionbg/iui 1.0.0
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/package.json +40 -0
- package/src/Elements/Accordions/Accordions.tsx +64 -0
- package/src/Elements/Alert/Alert.tsx +31 -0
- package/src/Elements/Alert/alert.scss +36 -0
- package/src/Elements/Button/Button.tsx +55 -0
- package/src/Elements/Button/IconButton.tsx +42 -0
- package/src/Elements/Button/button.scss +97 -0
- package/src/Elements/Dialog/Dialog.tsx +175 -0
- package/src/Elements/Helper/Collapse.tsx +39 -0
- package/src/Elements/Helper/NoAccessInfo.tsx +195 -0
- package/src/Elements/Tooltip/Tooltip.tsx +116 -0
- package/src/Elements/Tooltip/tooltip.scss +46 -0
- package/src/Elements/Wrappers/ConditionalWrapper.tsx +10 -0
- package/src/Elements/Wrappers/FormWrapper.tsx +67 -0
- package/src/Elements/Wrappers/FullPageWrapper.tsx +87 -0
- package/src/Elements/Wrappers/PageWrapper.tsx +148 -0
- package/src/icons/duotone/faArrowLeftFromLine.ts +17 -0
- package/src/icons/duotone/faArrowRightToLine.ts +17 -0
- package/src/icons/duotone/faBell.ts +17 -0
- package/src/icons/duotone/faEye.ts +17 -0
- package/src/icons/duotone/faEyeSlash.ts +17 -0
- package/src/icons/duotone/faHouseHeart.ts +17 -0
- package/src/icons/duotone/faPlusCircle.ts +18 -0
- package/src/icons/duotone/faUser.ts +18 -0
- package/src/icons/duotone/index.ts +19 -0
- package/src/icons/light/faAngleDown.ts +15 -0
- package/src/icons/light/faArrowDownShortWide.ts +15 -0
- package/src/icons/light/faArrowDownWideShort.ts +15 -0
- package/src/icons/light/faArrowsToLine.ts +15 -0
- package/src/icons/light/faArrowsUpDown.ts +15 -0
- package/src/icons/light/faBell.ts +15 -0
- package/src/icons/light/faCheck.ts +15 -0
- package/src/icons/light/faClockRotateLeft.ts +15 -0
- package/src/icons/light/faEllipsisVertical.ts +15 -0
- package/src/icons/light/faXmark.ts +15 -0
- package/src/icons/light/index.ts +23 -0
- package/src/icons/regular/faArrowRightArrowLeft.ts +15 -0
- package/src/icons/regular/faCalendar.ts +15 -0
- package/src/icons/regular/faCircleCheck.ts +15 -0
- package/src/icons/regular/faCircleExclamation.ts +15 -0
- package/src/icons/regular/faCircleInfo.ts +15 -0
- package/src/icons/regular/faFileArrowDown.ts +15 -0
- package/src/icons/regular/faFilterCircleXmark.ts +15 -0
- package/src/icons/regular/faTriangleExclamation.ts +15 -0
- package/src/icons/solid/faAngleLeft.ts +15 -0
- package/src/icons/solid/faAngleRight.ts +15 -0
- package/src/icons/solid/faArrowDownWideShort.ts +15 -0
- package/src/icons/solid/faArrowLeft.ts +15 -0
- package/src/icons/solid/faEllipsisVertical.ts +15 -0
- package/src/icons/solid/faFilter.ts +15 -0
- package/src/icons/solid/faGripDotsVertical.ts +15 -0
- package/src/icons/solid/faListUl.ts +15 -0
- package/src/icons/solid/faMagnifyingGlass.ts +15 -0
- package/src/icons/solid/faPrint.ts +15 -0
- package/src/icons/solid/faRotateRight.ts +15 -0
- package/src/icons/solid/faXmark.ts +15 -0
- package/src/index.ts +186 -0
- package/src/styles/App.scss +25 -0
- package/src/styles/iui/common/_animations.scss +56 -0
- package/src/styles/iui/common/_typography.scss +76 -0
- package/src/styles/iui/common/_variables.scss +56 -0
- package/src/styles/iui/common/helpers/_base.scss +32 -0
- package/src/styles/iui/common/helpers/_color.scss +7 -0
- package/src/styles/iui/common/helpers/_display.scss +54 -0
- package/src/styles/iui/common/helpers/_size.scss +17 -0
- package/src/styles/iui/common/maps/_align.scss +24 -0
- package/src/styles/iui/common/maps/_spacing.scss +78 -0
- package/src/styles/iui/components/_accordions.scss +47 -0
- package/src/styles/iui/components/_badge.scss +52 -0
- package/src/styles/iui/components/_card.scss +24 -0
- package/src/styles/iui/components/_dialog.scss +75 -0
- package/src/styles/iui/components/_header.scss +22 -0
- package/src/styles/iui/components/_input.scss +225 -0
- package/src/styles/iui/components/_loader.scss +93 -0
- package/src/styles/iui/components/_menu.scss +44 -0
- package/src/styles/iui/components/_notifications.scss +86 -0
- package/src/styles/iui/components/_page.scss +50 -0
- package/src/styles/iui/components/_pagePrelogin.scss +66 -0
- package/src/styles/iui/components/_portal.scss +8 -0
- package/src/styles/iui/components/_print.scss +92 -0
- package/src/styles/iui/components/_scrollbar.scss +18 -0
- package/src/styles/iui/components/_selectInput.scss +15 -0
- package/src/styles/iui/components/_sidebar.scss +171 -0
- package/src/styles/iui/components/_smallComponents.scss +24 -0
- package/src/styles/iui/components/_table.scss +207 -0
- package/src/styles/iui/components/_tabs.scss +94 -0
- package/src/styles/iui.scss +28 -0
- package/src/styles/red-variables.scss +9 -0
- package/src/types/IBasic.ts +31 -0
- package/src/types/IError.ts +4 -0
- package/src/types/IHeaderAction.ts +12 -0
- package/src/types/ISelect.ts +6 -0
- package/src/types/ISidebar.ts +29 -0
- package/src/types/ITab.ts +10 -0
- package/src/types/ITable.ts +210 -0
- package/src/types/custom.d.ts +9 -0
- package/src/utils/DateUtils.ts +30 -0
- package/src/utils/NumberUtils.ts +21 -0
- package/src/utils/ObjectUtils.ts +49 -0
- package/src/utils/StringUtils.ts +2 -0
- package/src/utils/Toasts.ts +6 -0
- package/src/utils/icons.ts +11 -0
- package/src/utils/index.ts +41 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@import "./iui/common/variables";
|
|
2
|
+
@import "./iui/common/typography";
|
|
3
|
+
@import "./iui/common/animations";
|
|
4
|
+
@import "./iui/common/maps/align";
|
|
5
|
+
@import "./iui/common/maps/spacing";
|
|
6
|
+
@import "./iui/common/helpers/base";
|
|
7
|
+
@import "./iui/common/helpers/color";
|
|
8
|
+
@import "./iui/common/helpers/display";
|
|
9
|
+
@import "./iui/common/helpers/size";
|
|
10
|
+
|
|
11
|
+
@import "./iui/components/accordions";
|
|
12
|
+
@import "./iui/components/badge";
|
|
13
|
+
@import "./iui/components/card";
|
|
14
|
+
@import "./iui/components/dialog";
|
|
15
|
+
@import "./iui/components/header";
|
|
16
|
+
@import "./iui/components/input";
|
|
17
|
+
@import "./iui/components/loader";
|
|
18
|
+
@import "./iui/components/menu";
|
|
19
|
+
@import "./iui/components/notifications";
|
|
20
|
+
@import "./iui/components/page";
|
|
21
|
+
@import "./iui/components/portal";
|
|
22
|
+
@import "./iui/components/print";
|
|
23
|
+
@import "./iui/components/scrollbar";
|
|
24
|
+
@import "./iui/components/selectInput";
|
|
25
|
+
@import "./iui/components/sidebar";
|
|
26
|
+
@import "./iui/components/smallComponents";
|
|
27
|
+
@import "./iui/components/table";
|
|
28
|
+
@import "./iui/components/tabs";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface IAnyObject {
|
|
2
|
+
[id: string]: any;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export interface IStringObject {
|
|
6
|
+
[id: string]: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface IBooleanObject {
|
|
10
|
+
[id: string]: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ISimpleObject {
|
|
14
|
+
uuid: string;
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ISimpleObjectWithCode extends ISimpleObject {
|
|
19
|
+
code: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ISimpleObjectWithCodeNew {
|
|
23
|
+
uuid?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
code?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IValueLabel {
|
|
29
|
+
value: any;
|
|
30
|
+
label: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IconDefinition, RotateProp } from "@fortawesome/fontawesome-svg-core";
|
|
2
|
+
|
|
3
|
+
export interface IHeaderAction {
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: IconDefinition;
|
|
6
|
+
iconRotation?: RotateProp;
|
|
7
|
+
to?: string;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
primary?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
hidden?: boolean;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
|
2
|
+
|
|
3
|
+
export interface ISidebarItem {
|
|
4
|
+
label: string;
|
|
5
|
+
icon: IconDefinition;
|
|
6
|
+
to?: string;
|
|
7
|
+
content?: ISidebarSubItem[];
|
|
8
|
+
menu?: {
|
|
9
|
+
content: ISidebarSubItem[];
|
|
10
|
+
openedMenu: string;
|
|
11
|
+
setOpenedMenu: (label: string) => void;
|
|
12
|
+
};
|
|
13
|
+
hidden?: boolean;
|
|
14
|
+
badge?: number;
|
|
15
|
+
addUrl?: string;
|
|
16
|
+
collapsed?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ISidebarSubItem {
|
|
20
|
+
label: string;
|
|
21
|
+
to?: string;
|
|
22
|
+
content?: ISidebarItem[];
|
|
23
|
+
hidden?: boolean;
|
|
24
|
+
tooltip?: string;
|
|
25
|
+
badge?: number;
|
|
26
|
+
addUrl?: string;
|
|
27
|
+
primary?: boolean;
|
|
28
|
+
collapsed?: boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dispatch,
|
|
3
|
+
FunctionComponent,
|
|
4
|
+
MouseEventHandler,
|
|
5
|
+
ReactElement,
|
|
6
|
+
ReactNode,
|
|
7
|
+
RefObject,
|
|
8
|
+
SetStateAction,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
11
|
+
import { IAnyObject } from './IBasic';
|
|
12
|
+
|
|
13
|
+
export interface ITable {
|
|
14
|
+
columns: ITableColumn[];
|
|
15
|
+
setColumns?: (data: ITableColumn[]) => void;
|
|
16
|
+
firstHeaderRow?: ITableColumn[];
|
|
17
|
+
secondHeaderRow?: ITableColumn[];
|
|
18
|
+
data: ITableDataItem[];
|
|
19
|
+
totals?: ITableDataItem;
|
|
20
|
+
isLoading?: boolean;
|
|
21
|
+
loaderLogo?: string;
|
|
22
|
+
serverSidePagination?: IServerSidePagination;
|
|
23
|
+
customPagination?: {
|
|
24
|
+
defaultLimit?: number;
|
|
25
|
+
customLimit?: number[];
|
|
26
|
+
};
|
|
27
|
+
selectedRowUuid?: string;
|
|
28
|
+
footerAction?: {
|
|
29
|
+
icon?: IconDefinition;
|
|
30
|
+
onClick: () => void;
|
|
31
|
+
};
|
|
32
|
+
headerWrap?: boolean;
|
|
33
|
+
hideFooter?: boolean;
|
|
34
|
+
showLastBorder?: boolean;
|
|
35
|
+
filterData?: ITableFilterData;
|
|
36
|
+
sortData?: ITableSortData;
|
|
37
|
+
printData?: IPrintData;
|
|
38
|
+
additionsalOptions?: ReactNode;
|
|
39
|
+
selectedOptions?: ReactNode;
|
|
40
|
+
translations?: ITableTranslations;
|
|
41
|
+
className?: string;
|
|
42
|
+
editable?: {
|
|
43
|
+
selectedItem: any;
|
|
44
|
+
setSelectedItem: (item: any) => void;
|
|
45
|
+
defaultDataValue?: any;
|
|
46
|
+
EditableRow?: FunctionComponent<ITableEditRow>;
|
|
47
|
+
onSubmit: (data: any, onSubmitCallback?: () => void) => void;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
inputFocusRef?: RefObject<any>;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ITableColumn {
|
|
54
|
+
id: string;
|
|
55
|
+
label?: string;
|
|
56
|
+
align?: 'center' | 'left' | 'right' | 'justify' | undefined;
|
|
57
|
+
hidden?: boolean;
|
|
58
|
+
unavailable?: boolean;
|
|
59
|
+
width?: string;
|
|
60
|
+
minWidth?: string;
|
|
61
|
+
colSpan?: number;
|
|
62
|
+
rowSpan?: number;
|
|
63
|
+
break?: boolean;
|
|
64
|
+
sortOptions?: {
|
|
65
|
+
asc: string;
|
|
66
|
+
desc: string;
|
|
67
|
+
label: string;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ITableDataItem {
|
|
72
|
+
uuid: string;
|
|
73
|
+
onRowClick?: MouseEventHandler<HTMLTableRowElement>;
|
|
74
|
+
className?: string;
|
|
75
|
+
cells: {
|
|
76
|
+
[id: string]: {
|
|
77
|
+
value: any;
|
|
78
|
+
align?: ITableColumn['align'];
|
|
79
|
+
className?: string;
|
|
80
|
+
onClick?: MouseEventHandler<HTMLTableCellElement>;
|
|
81
|
+
link?: boolean;
|
|
82
|
+
tooltip?: string;
|
|
83
|
+
span?: number;
|
|
84
|
+
unclickable?: boolean;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
extendable?: {
|
|
88
|
+
element: ReactElement;
|
|
89
|
+
isLoading?: boolean;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ITableFilterData {
|
|
94
|
+
columns: string[];
|
|
95
|
+
filters: ITableFilter;
|
|
96
|
+
activeFilterNo?: number;
|
|
97
|
+
additionalFilters?: ReactElement;
|
|
98
|
+
search: IAnyObject;
|
|
99
|
+
searchData: IAnyObject;
|
|
100
|
+
setSearchData: (search: IAnyObject) => void;
|
|
101
|
+
onSubmit: (search: IAnyObject) => void;
|
|
102
|
+
resetData?: IAnyObject;
|
|
103
|
+
excludeFromSearch?: string[];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface ITableFilterItem {
|
|
107
|
+
label: string;
|
|
108
|
+
field: ReactElement;
|
|
109
|
+
resetField: () => void;
|
|
110
|
+
}
|
|
111
|
+
export interface ITableFilter {
|
|
112
|
+
[id: string]: ITableFilterItem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface ITableSortData {
|
|
116
|
+
sort: string;
|
|
117
|
+
setSort: (sort: string) => void;
|
|
118
|
+
sortOptions: ITableSort;
|
|
119
|
+
menuSize?: 's' | 'm' | 'l';
|
|
120
|
+
}
|
|
121
|
+
export interface ITableSort {
|
|
122
|
+
[id: string]: {
|
|
123
|
+
label: string;
|
|
124
|
+
asc: string;
|
|
125
|
+
desc: string;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface ITableColumnsData {
|
|
130
|
+
columns: ITableColumn[];
|
|
131
|
+
setColumns: (data: any) => void;
|
|
132
|
+
}
|
|
133
|
+
export interface IPrintData {
|
|
134
|
+
label: string;
|
|
135
|
+
organization?: {
|
|
136
|
+
name?: string;
|
|
137
|
+
taxId?: string;
|
|
138
|
+
registrationNumber?: string;
|
|
139
|
+
jbkjs?: string;
|
|
140
|
+
email?: string;
|
|
141
|
+
};
|
|
142
|
+
filters?: {
|
|
143
|
+
basic?: { label: string; value?: string }[];
|
|
144
|
+
date?: { label: string; from?: string; to?: string }[];
|
|
145
|
+
};
|
|
146
|
+
getPrintData: (pagination: IPagination) => Promise<IAnyObject>;
|
|
147
|
+
formatPrintData: (data: any) => ITableDataItem[];
|
|
148
|
+
saveXlsx?: () => void;
|
|
149
|
+
totals?: ITableDataItem;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface IPagination {
|
|
153
|
+
limit: number;
|
|
154
|
+
offset: number;
|
|
155
|
+
}
|
|
156
|
+
export interface IServerSidePagination {
|
|
157
|
+
limit: number;
|
|
158
|
+
offset: number;
|
|
159
|
+
setLimit: Dispatch<SetStateAction<number>>;
|
|
160
|
+
setOffset: Dispatch<SetStateAction<number>>;
|
|
161
|
+
totalRows: number;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface ITableEditRow {
|
|
165
|
+
columns: ITableColumn[];
|
|
166
|
+
data: any;
|
|
167
|
+
setData: (data: any) => void;
|
|
168
|
+
item?: any;
|
|
169
|
+
clearItem: () => void;
|
|
170
|
+
defaultDataValue?: any;
|
|
171
|
+
inputFocusRef?: RefObject<any>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface ITableTranslations {
|
|
175
|
+
noDataText?: string;
|
|
176
|
+
pagination?: {
|
|
177
|
+
rowsPerPage: string;
|
|
178
|
+
of: string;
|
|
179
|
+
allResults: string;
|
|
180
|
+
page: string;
|
|
181
|
+
};
|
|
182
|
+
Sort?: string;
|
|
183
|
+
filter?: {
|
|
184
|
+
Filter?: string;
|
|
185
|
+
ResetFilter?: string;
|
|
186
|
+
Search?: string;
|
|
187
|
+
Delete?: string;
|
|
188
|
+
};
|
|
189
|
+
print?: {
|
|
190
|
+
Print?: string;
|
|
191
|
+
PrintExport?: string;
|
|
192
|
+
TaxId?: string;
|
|
193
|
+
RegistrationNumber?: string;
|
|
194
|
+
PrintDate?: string;
|
|
195
|
+
from?: string;
|
|
196
|
+
to?: string;
|
|
197
|
+
SaveXlsx?: string;
|
|
198
|
+
};
|
|
199
|
+
Cancel?: string;
|
|
200
|
+
Confirm?: string;
|
|
201
|
+
columns?: {
|
|
202
|
+
Columns?: string;
|
|
203
|
+
DragDropListsInfo?: string;
|
|
204
|
+
HiddenColumns?: string;
|
|
205
|
+
SelectedColumns?: string;
|
|
206
|
+
};
|
|
207
|
+
editable?: {
|
|
208
|
+
Actions?: string;
|
|
209
|
+
};
|
|
210
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import moment from 'moment/moment';
|
|
2
|
+
|
|
3
|
+
export const formatDate = (date?: string) =>
|
|
4
|
+
date ? moment(date).format(`DD.MM.YYYY.`) : '/';
|
|
5
|
+
export const formatDateYMD = (date: string | Date) => moment(date).format(`yyyy-MM-DD`);
|
|
6
|
+
|
|
7
|
+
export const formatDateAndTime = (date?: string, withSeconds?: boolean) =>
|
|
8
|
+
date ? moment(date).format(`DD.MM.YYYY. HH:mm${withSeconds ? ':ss' : ''}`) : '/';
|
|
9
|
+
|
|
10
|
+
export const formatTime = (date?: string, withSeconds?: boolean) =>
|
|
11
|
+
date ? moment(date).format(`HH:mm${withSeconds ? ':ss' : ''}`) : '/';
|
|
12
|
+
|
|
13
|
+
export const dateAddDays = (date: string, addDays: number) =>
|
|
14
|
+
moment(date).add(addDays, 'days').toISOString();
|
|
15
|
+
|
|
16
|
+
export const checkIfExpired = (date?: string) =>
|
|
17
|
+
date ? moment(new Date()) > moment(date) : true;
|
|
18
|
+
|
|
19
|
+
export const getCurrentDateFormatted = () => moment().format('DD.MM.YYYY.').toString();
|
|
20
|
+
export const getCurrentDateFormattedYMD = () => moment().format('yyyy-MM-DD').toString();
|
|
21
|
+
|
|
22
|
+
export const getDaysLeft = (date?: string) => moment(date).diff(new Date(), 'days');
|
|
23
|
+
|
|
24
|
+
export const formatYearMonth = (year: number, month: number) =>
|
|
25
|
+
`${year}-${month < 10 ? `0${month}` : month}`;
|
|
26
|
+
|
|
27
|
+
// export const getDayInputRegex = (max: number) =>
|
|
28
|
+
// `(0[1-9]|1[0-9]|2[0-${max === 28 ? "8" : "9"}]${
|
|
29
|
+
// max > 29 && `|3[0${max > 30 && "-1"}]`
|
|
30
|
+
// })`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// export const toNumberOrZero = (value?: string | number) => (!!value ? +value : 0);
|
|
2
|
+
|
|
3
|
+
export const formatCurrency = (
|
|
4
|
+
number?: string | number,
|
|
5
|
+
minimumFractionDigits?: number,
|
|
6
|
+
maximumFractionDigits?: number
|
|
7
|
+
) =>
|
|
8
|
+
Number(number || 0).toLocaleString('sr-RS', {
|
|
9
|
+
minimumFractionDigits: minimumFractionDigits || 2,
|
|
10
|
+
maximumFractionDigits: maximumFractionDigits || 2,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const formatCurrencyNoDecimals = (number?: string | number) =>
|
|
14
|
+
// number?.toString().replace(',', '.') || 0;
|
|
15
|
+
Number(number || 0).toLocaleString('sr-RS');
|
|
16
|
+
|
|
17
|
+
// export const formatDecimalNumber = (number?: string | number) =>
|
|
18
|
+
// number?.toString().replace('.', ',') || 0;
|
|
19
|
+
|
|
20
|
+
// export const roundTwoDecimals = (value?: string | number) =>
|
|
21
|
+
// !!value ? Math.round(+value * 100) / 100 : 0;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { IAnyObject } from "../types/IBasic";
|
|
2
|
+
import { ITableColumn } from "../types/ITable";
|
|
3
|
+
|
|
4
|
+
export const deleteProps = (obj: any, props: string[]) => {
|
|
5
|
+
let newObj = { ...obj };
|
|
6
|
+
props.forEach((e) => delete newObj[e]);
|
|
7
|
+
return newObj;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const deleteEmptyProps = (obj: IAnyObject) =>
|
|
11
|
+
Object.entries(obj).reduce(
|
|
12
|
+
(a: any, [k, v]) =>
|
|
13
|
+
[null, undefined, ""].includes(v) ? a : ((a[k] = v), a),
|
|
14
|
+
{}
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const deleteEmptyPropsIncludingArray = (obj: IAnyObject) =>
|
|
18
|
+
Object.entries(obj).reduce(
|
|
19
|
+
(a: any, [k, v]) =>
|
|
20
|
+
[null, undefined, ""].includes(v) || (Array.isArray(v) && !v.length)
|
|
21
|
+
? a
|
|
22
|
+
: ((a[k] = v), a),
|
|
23
|
+
{}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export const getActiveFilterNumber = (obj: any) => Object.keys(obj).length;
|
|
27
|
+
|
|
28
|
+
export const getPrintColumns = (tableCols: ITableColumn[]) =>
|
|
29
|
+
tableCols.reduce(
|
|
30
|
+
(arr: string[], col) =>
|
|
31
|
+
col.hidden || col.unavailable ? arr : arr.concat(col.id),
|
|
32
|
+
[]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
export const getVisibleColumnsIds = (
|
|
36
|
+
tableCols: ITableColumn[],
|
|
37
|
+
isPrint?: boolean
|
|
38
|
+
) =>
|
|
39
|
+
tableCols.reduce(
|
|
40
|
+
(arr: string[], col) =>
|
|
41
|
+
col.hidden ||
|
|
42
|
+
col.unavailable ||
|
|
43
|
+
(isPrint && ["select", "icons", "actions"].includes(col.id))
|
|
44
|
+
? arr
|
|
45
|
+
: arr.concat(col.id),
|
|
46
|
+
[]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export const deepCopy = (el: any[] | object) => JSON.parse(JSON.stringify(el));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { toast } from "react-toastify";
|
|
2
|
+
|
|
3
|
+
export const toastSuccess = (message: string) => toast.success(message);
|
|
4
|
+
export const toastError = (message: string) => toast.error(message, { autoClose: false });
|
|
5
|
+
// export const toastInfo = (message: string) => toast.info(message);
|
|
6
|
+
// export const toastWarn = (message: string) => toast.warn(message);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { faCircleCheck } from "../icons/regular/faCircleCheck";
|
|
2
|
+
import { faCircleExclamation } from "../icons/regular/faCircleExclamation";
|
|
3
|
+
import { faCircleInfo } from "../icons/regular/faCircleInfo";
|
|
4
|
+
import { faTriangleExclamation } from "../icons/regular/faTriangleExclamation";
|
|
5
|
+
|
|
6
|
+
export const infoIcons = {
|
|
7
|
+
error: faCircleExclamation,
|
|
8
|
+
success: faCircleCheck,
|
|
9
|
+
info: faCircleInfo,
|
|
10
|
+
warning: faTriangleExclamation,
|
|
11
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkIfExpired,
|
|
3
|
+
dateAddDays,
|
|
4
|
+
formatDate,
|
|
5
|
+
formatDateAndTime,
|
|
6
|
+
formatTime,
|
|
7
|
+
formatYearMonth,
|
|
8
|
+
getCurrentDateFormattedYMD,
|
|
9
|
+
getDaysLeft,
|
|
10
|
+
} from "./DateUtils";
|
|
11
|
+
import { formatCurrency, formatCurrencyNoDecimals } from "./NumberUtils";
|
|
12
|
+
import {
|
|
13
|
+
deleteEmptyProps,
|
|
14
|
+
deleteEmptyPropsIncludingArray,
|
|
15
|
+
deleteProps,
|
|
16
|
+
getActiveFilterNumber,
|
|
17
|
+
getVisibleColumnsIds,
|
|
18
|
+
} from "./ObjectUtils";
|
|
19
|
+
import { maxChar } from "./StringUtils";
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
checkIfExpired,
|
|
23
|
+
dateAddDays,
|
|
24
|
+
formatDate,
|
|
25
|
+
formatDateAndTime,
|
|
26
|
+
formatTime,
|
|
27
|
+
formatYearMonth,
|
|
28
|
+
getCurrentDateFormattedYMD,
|
|
29
|
+
getDaysLeft,
|
|
30
|
+
formatCurrency,
|
|
31
|
+
formatCurrencyNoDecimals,
|
|
32
|
+
deleteEmptyProps,
|
|
33
|
+
deleteEmptyPropsIncludingArray,
|
|
34
|
+
deleteProps,
|
|
35
|
+
getActiveFilterNumber,
|
|
36
|
+
getVisibleColumnsIds,
|
|
37
|
+
// apiResponseHandler,
|
|
38
|
+
// toastError,
|
|
39
|
+
// toastSuccess,
|
|
40
|
+
maxChar,
|
|
41
|
+
};
|