digitinary-ui 1.0.4 → 1.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/components/Accordion/Accordion.js +28 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/components/Alert/Alert.js +58 -0
- package/dist/components/Alert/index.js +1 -0
- package/dist/components/Button/Button.js +17 -0
- package/dist/components/Button/index.js +1 -0
- package/dist/components/Card/Card.js +6 -0
- package/dist/components/Card/index.js +1 -0
- package/dist/components/Checkbox/Checkbox.js +8 -0
- package/dist/components/Checkbox/index.js +1 -0
- package/dist/components/Chip/Chip.js +18 -0
- package/dist/components/Chip/index.js +1 -0
- package/dist/components/Date/Date.js +460 -0
- package/dist/components/Date/index.js +1 -0
- package/dist/components/DateRange/DateRange.js +206 -0
- package/dist/components/DateRange/index.js +1 -0
- package/dist/components/Dialog/Dialog.js +36 -0
- package/dist/components/Dialog/index.js +1 -0
- package/dist/components/HelperText/HelperText.js +6 -0
- package/dist/components/HelperText/index.js +1 -0
- package/dist/components/Input/Input.js +38 -0
- package/dist/components/Input/index.js +1 -0
- package/dist/components/Label/Label.js +6 -0
- package/dist/components/Label/index.js +1 -0
- package/dist/components/Overlay/Overlay.js +8 -0
- package/dist/components/Overlay/index.js +1 -0
- package/dist/components/Pagination/Pagination.js +26 -0
- package/dist/components/Pagination/index.js +1 -0
- package/dist/components/Radio/Radio.js +8 -0
- package/dist/components/Radio/index.js +1 -0
- package/dist/components/RadioGroup/RadioGroup.js +14 -0
- package/dist/components/RadioGroup/index.js +1 -0
- package/dist/components/SelectGroup/SelectGroup.js +251 -0
- package/dist/components/SelectGroup/index.js +1 -0
- package/dist/components/SideDrawer/SideDrawer.js +54 -0
- package/dist/components/SideDrawer/index.js +1 -0
- package/dist/components/Switch/Switch.js +6 -0
- package/dist/components/Switch/index.js +1 -0
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Table/Table.js +60 -0
- package/dist/components/Table/index.js +1 -0
- package/dist/components/TextArea/TextArea.d.ts +1 -1
- package/dist/components/TextArea/TextArea.js +30 -0
- package/dist/components/TextArea/index.js +1 -0
- package/dist/components/Tooltip/Tooltip.js +8 -0
- package/dist/components/index.js +19 -0
- package/dist/constants/index.js +5 -0
- package/dist/icons/AlertErrorIcon.js +3 -0
- package/dist/icons/AlertInfoIcon.js +3 -0
- package/dist/icons/AlertSuccessIcon.js +3 -0
- package/dist/icons/AlertWarningIcon.js +3 -0
- package/dist/icons/ArrowBottom.js +3 -0
- package/dist/icons/ArrowLeft.js +3 -0
- package/dist/icons/ArrowRight.js +3 -0
- package/dist/icons/ArrowUpIcon.js +3 -0
- package/dist/icons/Calendar.js +3 -0
- package/dist/icons/CheckMark.js +3 -0
- package/dist/icons/ClearField.js +3 -0
- package/dist/icons/CloseIcon.js +3 -0
- package/dist/icons/DoubleLeftArrow.js +3 -0
- package/dist/icons/DoubleRightArrow.js +3 -0
- package/dist/icons/ExcelIcon.js +3 -0
- package/dist/icons/HidePasswordIcon.js +3 -0
- package/dist/icons/InfoIcon.js +3 -0
- package/dist/icons/LeftArrowIcon.js +3 -0
- package/dist/icons/LoaderIcon.js +3 -0
- package/dist/icons/PdfIcon.js +3 -0
- package/dist/icons/RightArrowIcon.js +3 -0
- package/dist/icons/SearchIcon.js +3 -0
- package/dist/icons/SelectFieldDownArrow.js +3 -0
- package/dist/icons/SelectFieldUpArrow.js +3 -0
- package/dist/icons/ShowPasswordIcon.js +3 -0
- package/dist/icons/SortIcon.js +3 -0
- package/dist/index.js +3 -2
- package/dist/types/enums.js +25 -0
- package/dist/types/index.js +3 -0
- package/dist/types/interfaces.d.ts +4 -10
- package/dist/types/interfaces.js +1 -0
- package/dist/types/types.js +1 -0
- package/dist/utils/index.js +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import moment from 'moment';
|
|
4
|
+
import Date from '../Date';
|
|
5
|
+
import Button from '../Button';
|
|
6
|
+
import SelectGroup from '../SelectGroup';
|
|
7
|
+
import Input from '../Input';
|
|
8
|
+
import styles from './dateRange.module.scss';
|
|
9
|
+
import ClearField from '../../icons/ClearField';
|
|
10
|
+
import CalendarIcon from '../../icons/Calendar';
|
|
11
|
+
import CloseIcon from '../../icons/CloseIcon';
|
|
12
|
+
import { Duration, Size } from '../../types';
|
|
13
|
+
import { optionEmptyState } from '../../constants';
|
|
14
|
+
const DateRange = ({ id, label, helperText, errorMsg, success, disabled, value, onChange, size = 'medium', clearable = true, hideMoreDateOptions = false, showTimePicker = true, acceptSameDay = false, maxStartDate, minStartDate, maxEndDate, minEndDate, labels = {
|
|
15
|
+
month: 'This Month',
|
|
16
|
+
day: 'This Day',
|
|
17
|
+
Apply: 'Apply',
|
|
18
|
+
week: 'This Week',
|
|
19
|
+
Select: 'Select',
|
|
20
|
+
Last: 'Last',
|
|
21
|
+
Start_Date: 'Start Date',
|
|
22
|
+
End_Date: 'End Date',
|
|
23
|
+
Selected_Date: 'Selected Date',
|
|
24
|
+
}, className = '', dataId, }) => {
|
|
25
|
+
const defaultDateTimeFormat = acceptSameDay ? 'DD MMM YYYY' : 'DD MMM YYYY HH:mm:ss';
|
|
26
|
+
const [showDateRange, setShowDateRange] = useState(false);
|
|
27
|
+
const [thisSelected, setThisSelected] = useState();
|
|
28
|
+
const [selectedByType, setSelectedByType] = useState({
|
|
29
|
+
numberOf: '',
|
|
30
|
+
duration: null,
|
|
31
|
+
});
|
|
32
|
+
const [selectedByRange, setSelectedByRange] = useState({
|
|
33
|
+
start: '',
|
|
34
|
+
end: '',
|
|
35
|
+
});
|
|
36
|
+
const datepickerRef = useRef(null);
|
|
37
|
+
const getByThis = (selected) => {
|
|
38
|
+
const startCurrentMonth = moment().startOf('month').format(defaultDateTimeFormat);
|
|
39
|
+
const endCurrentMonth = moment().endOf('month').format(defaultDateTimeFormat);
|
|
40
|
+
const currentMonth = `${startCurrentMonth} - ${endCurrentMonth}`;
|
|
41
|
+
const startCurrentWeek = moment().startOf('week').format(defaultDateTimeFormat);
|
|
42
|
+
const endCurrentWeek = moment().endOf('week').format(defaultDateTimeFormat);
|
|
43
|
+
const currentWeek = `${startCurrentWeek} - ${endCurrentWeek}`;
|
|
44
|
+
const startCurrentDay = moment().startOf('day').format(defaultDateTimeFormat);
|
|
45
|
+
const endCurrentDay = moment().endOf('day').format(defaultDateTimeFormat);
|
|
46
|
+
const currentDay = `${startCurrentDay} - ${endCurrentDay}`;
|
|
47
|
+
setSelectedByType({
|
|
48
|
+
numberOf: '',
|
|
49
|
+
duration: {
|
|
50
|
+
label: '',
|
|
51
|
+
value: '',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
setSelectedByRange({ start: '', end: '' });
|
|
55
|
+
setThisSelected(selected);
|
|
56
|
+
switch (selected) {
|
|
57
|
+
case 'month':
|
|
58
|
+
hideRange();
|
|
59
|
+
return onChange(currentMonth);
|
|
60
|
+
case 'week':
|
|
61
|
+
hideRange();
|
|
62
|
+
return onChange(currentWeek);
|
|
63
|
+
case 'day':
|
|
64
|
+
hideRange();
|
|
65
|
+
return onChange(currentDay);
|
|
66
|
+
default:
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const getByType = (selected) => {
|
|
70
|
+
if (selectedByType?.duration?.value) {
|
|
71
|
+
const lastByMonths = `${moment()
|
|
72
|
+
.subtract(Number(selectedByType.numberOf), selectedByType.duration.value)
|
|
73
|
+
.format(defaultDateTimeFormat)} - ${moment().format(defaultDateTimeFormat)}`;
|
|
74
|
+
const lastByWeeks = `${moment()
|
|
75
|
+
.clone()
|
|
76
|
+
.subtract(Number(selectedByType.numberOf), selectedByType.duration.value)
|
|
77
|
+
.format(defaultDateTimeFormat)} - ${moment().format(defaultDateTimeFormat)}`;
|
|
78
|
+
const lastByDays = `${moment()
|
|
79
|
+
.subtract(Number(selectedByType.numberOf), selectedByType.duration.value)
|
|
80
|
+
.format(defaultDateTimeFormat)} - ${moment().format(defaultDateTimeFormat)}`;
|
|
81
|
+
const lastByHours = `${moment()
|
|
82
|
+
.subtract(Number(selectedByType.numberOf), selectedByType.duration.value)
|
|
83
|
+
.format(defaultDateTimeFormat)} - ${moment().format(defaultDateTimeFormat)}`;
|
|
84
|
+
switch (selected?.value) {
|
|
85
|
+
case 'months':
|
|
86
|
+
hideRange();
|
|
87
|
+
return onChange(lastByMonths);
|
|
88
|
+
case 'weeks':
|
|
89
|
+
hideRange();
|
|
90
|
+
return onChange(lastByWeeks);
|
|
91
|
+
case 'days':
|
|
92
|
+
hideRange();
|
|
93
|
+
return onChange(lastByDays);
|
|
94
|
+
case 'hours':
|
|
95
|
+
hideRange();
|
|
96
|
+
return onChange(lastByHours);
|
|
97
|
+
default:
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function handleDisabled(obj) {
|
|
102
|
+
return Object.values(obj).every((value) => value);
|
|
103
|
+
}
|
|
104
|
+
const showHideRange = () => setShowDateRange(!showDateRange);
|
|
105
|
+
const hideRange = () => setShowDateRange(false);
|
|
106
|
+
const handleInputChange = (value) => {
|
|
107
|
+
if (value !== null) {
|
|
108
|
+
const valueStr = value.toString();
|
|
109
|
+
const regex = /^\d+$/;
|
|
110
|
+
if (regex.test(valueStr) || valueStr.length === 0) {
|
|
111
|
+
setSelectedByType((prev) => ({ ...prev, numberOf: value }));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
setSelectedByType({ ...selectedByType, numberOf: '' });
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const handleSelectChange = (duration) => {
|
|
119
|
+
setSelectedByType((prev) => ({ ...prev, duration }));
|
|
120
|
+
};
|
|
121
|
+
const handleRangeStart = (startDate) => setSelectedByRange((prev) => ({ ...prev, start: startDate === null ? '' : startDate }));
|
|
122
|
+
const handleRangeEnd = (endDate) => setSelectedByRange((prev) => ({ ...prev, end: endDate === null ? '' : endDate }));
|
|
123
|
+
const handleFilterByType = () => {
|
|
124
|
+
getByType(selectedByType.duration);
|
|
125
|
+
setSelectedByRange({ start: '', end: '' });
|
|
126
|
+
setThisSelected('');
|
|
127
|
+
};
|
|
128
|
+
const handleFilterByRange = () => {
|
|
129
|
+
onChange(`${moment(selectedByRange.start).format(defaultDateTimeFormat)} - ${moment(selectedByRange.end).format(defaultDateTimeFormat)}`);
|
|
130
|
+
setSelectedByType({ numberOf: '', duration: optionEmptyState });
|
|
131
|
+
setThisSelected('');
|
|
132
|
+
hideRange();
|
|
133
|
+
};
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
function handleClickOutside(event) {
|
|
136
|
+
const target = event.target;
|
|
137
|
+
if (datepickerRef.current &&
|
|
138
|
+
target &&
|
|
139
|
+
!datepickerRef.current.contains(target) &&
|
|
140
|
+
!(target.matches && target.matches(`#${id ?? 'date-id'}`))) {
|
|
141
|
+
hideRange();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
145
|
+
return () => document.removeEventListener('mousedown', handleClickOutside);
|
|
146
|
+
}, [datepickerRef]);
|
|
147
|
+
const closeDateRange = (e) => {
|
|
148
|
+
if (e.key === 'Escape') {
|
|
149
|
+
hideRange();
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
useEffect(() => {
|
|
153
|
+
window.addEventListener('keydown', closeDateRange);
|
|
154
|
+
return () => {
|
|
155
|
+
window.removeEventListener('keydown', closeDateRange);
|
|
156
|
+
};
|
|
157
|
+
}, []);
|
|
158
|
+
useEffect(() => {
|
|
159
|
+
if (value === '') {
|
|
160
|
+
setSelectedByRange({ start: '', end: '' });
|
|
161
|
+
setThisSelected('');
|
|
162
|
+
setSelectedByType({ numberOf: '', duration: optionEmptyState });
|
|
163
|
+
}
|
|
164
|
+
}, [value]);
|
|
165
|
+
return (_jsxs("div", { className: `${styles.dateRangeContainer} ${className}`, children: [label && (_jsx("label", { htmlFor: id, "data-id": `${String(dataId ?? label)
|
|
166
|
+
?.toUpperCase()
|
|
167
|
+
?.replaceAll(' ', '_')}_FIELD_LABEL_ID`, className: styles.dateRangeLabel, children: label })), _jsxs("div", { className: styles.dateRangeInputContainer, ref: datepickerRef, children: [_jsxs("div", { className: `${styles.dateIconsContainer} ${disabled ? styles.disabled : ''} ${styles[size]} ${errorMsg ? styles.error : ''} ${success ? styles.success : ''} ${!value ? styles.placeholder : ''}`, onClick: showHideRange, "data-id": "DATE_RANGE_FIELD", children: [_jsx("input", { id: id ?? 'date-id', value: value, placeholder: "DD MM YYYY 00:00:00 - DD MM YYYY 00:00:00", type: "text", className: styles.dateRangeInput, autoComplete: "off", disabled: disabled, onKeyDown: (e) => {
|
|
168
|
+
if (e.key === 'Enter') {
|
|
169
|
+
setShowDateRange(!showDateRange);
|
|
170
|
+
}
|
|
171
|
+
} }), _jsxs("div", { className: `${styles.iconsContainer} ${disabled ? styles.disabled : ''}`, "data-id": "DATE_ICON", children: [clearable && value && (_jsx(ClearField, { width: '1rem', height: '1rem', className: styles.dateClearIcon, onClick: (e) => {
|
|
172
|
+
e.stopPropagation();
|
|
173
|
+
onChange('');
|
|
174
|
+
setShowDateRange(false);
|
|
175
|
+
}, "data-id": "CLEAR_ICON_DATE_RANGE_FIELD" })), _jsx(CalendarIcon, { width: '1.5rem', height: '1.5rem', className: `${styles.calendarIcon} ${value ? styles.contentActive : ''}` })] }), helperText && _jsx("span", { className: styles.dateRangeHelper, children: helperText }), errorMsg && _jsx("span", { className: styles.dateRangeError, children: errorMsg })] }), _jsxs("div", { className: `${styles.dateRangeModal} ${showDateRange ? styles.appear : styles.disappear}`, children: [_jsxs("div", { className: styles.title, children: [_jsx("span", { "data-id": "SELECTED_DATE_LABEL", children: labels?.Selected_Date }), _jsx("div", { className: styles.dropdownCloseIcon, "data-id": "CLOSE_ICON", onClick: hideRange, children: _jsx(CloseIcon, { width: '1.5rem', height: '1.5rem' }) })] }), !hideMoreDateOptions && (_jsxs(_Fragment, { children: [_jsxs("div", { className: `${styles.section} ${styles.sectionBtn}`, children: [_jsx(Button, { variant: "outlined", color: "primary", id: "month", size: Size.Medium, onClick: () => getByThis('month'), onKeyDown: (e) => {
|
|
176
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
177
|
+
getByThis('month');
|
|
178
|
+
e.preventDefault();
|
|
179
|
+
}
|
|
180
|
+
}, active: thisSelected === 'month', type: "button", "data-id": "THIS_MONTH", children: labels?.month }), _jsx(Button, { variant: "outlined", color: "primary", id: "week", size: Size.Medium, onClick: () => getByThis('week'), onKeyDown: (e) => {
|
|
181
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
182
|
+
getByThis('week');
|
|
183
|
+
e.preventDefault();
|
|
184
|
+
}
|
|
185
|
+
}, active: thisSelected === 'week', type: "button", "data-id": "THIS_WEEK", children: labels?.week }), _jsx(Button, { variant: "outlined", color: "primary", id: "day", size: Size.Medium, onClick: () => getByThis('day'), onKeyDown: (e) => {
|
|
186
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
187
|
+
getByThis('day');
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
}
|
|
190
|
+
}, active: thisSelected === 'day', type: "button", "data-id": "THIS_DAY", children: labels?.day })] }), _jsxs("form", { className: styles.section, children: [_jsx(Input, { size: Size.Medium, "data-id": "LAST_FILED", type: "text", placeholder: labels?.Last, value: selectedByType.numberOf, onChange: (value) => handleInputChange(value), clearable: true }), _jsx(SelectGroup, { size: Size.Medium, dataId: "SELECT_DROP_DOWN_LIST", placeholder: labels?.Select, options: [
|
|
191
|
+
{
|
|
192
|
+
list: [
|
|
193
|
+
{ label: 'Hours', value: Duration.Hours },
|
|
194
|
+
{ label: 'Days', value: Duration.Days },
|
|
195
|
+
{ label: 'Weeks', value: Duration.Weeks },
|
|
196
|
+
{ label: 'Months', value: Duration.Months },
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
], value: selectedByType.duration, onChange: (value) => handleSelectChange(value), isMultiple: false, withSearch: false }), _jsx(Button, { variant: "outlined", color: "primary", size: Size.Large, "data-id": "APPLY_BUTTON", onClick: handleFilterByType, disabled: !handleDisabled({
|
|
200
|
+
...selectedByType,
|
|
201
|
+
duration: selectedByType.duration?.value,
|
|
202
|
+
}), fullWidth: true, type: "button", children: labels?.Apply })] })] })), _jsxs("div", { className: `${!hideMoreDateOptions ? styles.section : styles.sectionWithoutGrid}`, children: [_jsx(Date, { size: "medium", placeholder: "DD MM YYYY 00:00:00", id: "start", label: labels?.Start_Date, timePicker: showTimePicker, isEndDay: false, selectedEndDate: selectedByRange.end, disabledDay: selectedByRange.start, value: selectedByRange.start, onChange: handleRangeStart, minDate: minStartDate, maxDate: maxStartDate }), _jsx(Date, { size: "medium", placeholder: "DD MM YYYY 23:59:59", id: "end", disabledDay: selectedByRange.start, label: labels?.End_Date, timePicker: showTimePicker, isEndDay: true, acceptSameDay: acceptSameDay, value: selectedByRange.end, onChange: handleRangeEnd, minDate: minEndDate, maxDate: maxEndDate }), _jsx(Button, { variant: "outlined", color: "primary", "data-id": "APPLY_DATE_BUTTON", size: Size.Large, onClick: handleFilterByRange, disabled: !handleDisabled(selectedByRange) ||
|
|
203
|
+
(!acceptSameDay &&
|
|
204
|
+
moment(selectedByRange.start).isSameOrAfter(moment(selectedByRange.end))), fullWidth: true, type: "button", children: labels?.Apply })] })] })] })] }));
|
|
205
|
+
};
|
|
206
|
+
export default DateRange;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './DateRange';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import styles from './dialog.module.scss';
|
|
4
|
+
const Dialog = ({ open, onClose, header, content, footer, position, size, disableOverlay = false, disableBackdropClick = false, fullWidth = true, dataId, scroll = 'root', className = '', }) => {
|
|
5
|
+
const dialogRef = useRef(null);
|
|
6
|
+
const container = useRef(null);
|
|
7
|
+
const overlayClickHandler = () => {
|
|
8
|
+
if (!disableBackdropClick) {
|
|
9
|
+
if (dialogRef.current) {
|
|
10
|
+
dialogRef.current.remove();
|
|
11
|
+
}
|
|
12
|
+
if (onClose) {
|
|
13
|
+
onClose();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const onContentWrapperClickHandler = (e) => {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
if (!disableOverlay) {
|
|
20
|
+
overlayClickHandler();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const onDialogContentClickHandler = (e) => {
|
|
24
|
+
e.stopPropagation();
|
|
25
|
+
};
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (container.current && open) {
|
|
28
|
+
container.current.focus();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
document.getElementById('main-container')?.focus();
|
|
32
|
+
}
|
|
33
|
+
}, [open]);
|
|
34
|
+
return (_jsx(_Fragment, { children: open && (_jsxs("div", { id: styles.dialogContainer, className: className, children: [!disableOverlay && (_jsx("div", { className: `${styles.overlay} ${open ? styles.open : ''}`, role: "button", tabIndex: 0, onClick: overlayClickHandler, ref: dialogRef })), _jsx("div", { className: `${styles.rootContentWrapper} ${styles[position] || styles.center}`, role: "button", tabIndex: 0, onClick: onContentWrapperClickHandler, children: _jsx("div", { className: `${styles.dialogContentWrapper} ${!fullWidth && size ? styles[size] : styles.xs} ${fullWidth ? styles.fullwidth : ''} ${scroll ? `${styles.scroll}-${scroll}` : styles.scrollRoot} ${position || 'center'}`, role: "button", tabIndex: 0, onClick: onDialogContentClickHandler, ref: container, children: _jsxs("div", { "data-id": "DIALOG_CONTAINER_ID", "aria-label": 'custom-dialog', className: `${styles.dialogContentRoot} ${fullWidth ? styles.fullwidth : ''}`, children: [header && _jsx("div", { className: styles.dialogHeader, children: header }), content ? (_jsx("div", { className: styles.dialogContent, children: content })) : (_jsx("div", { className: styles.dialogContent })), footer && _jsx("div", { className: styles.dialogFooter, children: footer })] }) }) })] })) }));
|
|
35
|
+
};
|
|
36
|
+
export default Dialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Dialog';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styles from './helperText.module.scss';
|
|
3
|
+
const HelperText = ({ className = '', type = 'default', text }) => {
|
|
4
|
+
return _jsxs("span", { className: `${styles.helperText} ${className} ${styles[type]}`, children: [" ", text, " "] });
|
|
5
|
+
};
|
|
6
|
+
export default HelperText;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './HelperText';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Label from '../Label';
|
|
4
|
+
import HelperText from '../HelperText';
|
|
5
|
+
import style from './input.module.scss';
|
|
6
|
+
import ClearField from '../../icons/ClearField';
|
|
7
|
+
import ShowPasswordIcon from '../../icons/ShowPasswordIcon';
|
|
8
|
+
import HidePasswordIcon from '../../icons/HidePasswordIcon';
|
|
9
|
+
import { Size } from '../../types';
|
|
10
|
+
const Input = ({ type = 'text', value = '', onChange, placeholder, label, disabled = false, errorMsg = '', helperText, fullWidth = false, size = Size.Medium, startAdornment, endAdornment, blurText = false, required = false, clearable = true, className, autoComplete = 'off', direction = 'ltr', onKeyDown, onPaste, ...props }) => {
|
|
11
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
12
|
+
const toggleShowPassword = (event) => {
|
|
13
|
+
event && event.stopPropagation();
|
|
14
|
+
setShowPassword(!showPassword);
|
|
15
|
+
};
|
|
16
|
+
const handleChange = (event) => {
|
|
17
|
+
const value = event.target.value;
|
|
18
|
+
onChange(value);
|
|
19
|
+
};
|
|
20
|
+
const handleClear = () => {
|
|
21
|
+
if (clearable) {
|
|
22
|
+
onChange('');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const handleIconKeyDown = (event, action) => {
|
|
26
|
+
if (event.key === 'Enter') {
|
|
27
|
+
action();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const getInputType = () => {
|
|
31
|
+
if (type === 'password') {
|
|
32
|
+
return showPassword ? 'text' : 'password';
|
|
33
|
+
}
|
|
34
|
+
return type;
|
|
35
|
+
};
|
|
36
|
+
return (_jsxs("div", { className: `${style.inputContainer} ${fullWidth ? style.fullWidth : ''} ${style[size]} ${className}`, children: [label && _jsx(Label, { required: required, label: label }), _jsxs("div", { className: `${style.inputWrapper} ${errorMsg ? style.error : ''} ${disabled ? style.inputWrapperDisabled : ''}`, dir: direction, children: [_jsxs("div", { className: `${style.innerInputContainer} ${disabled ? style.disabledInnerInput : ''}`, children: [startAdornment && _jsx("div", { className: style.adornment, children: startAdornment }), _jsx("input", { type: getInputType(), "data-id": `${String(label)?.toUpperCase()?.replaceAll(' ', '_')}_INPUT_ID`, value: value ?? '', onChange: handleChange, placeholder: placeholder, disabled: disabled, className: `${style.input} ${errorMsg ? style.inputError : ''} ${blurText && value ? style.blurredInput : ''} ${disabled ? style.disabled : ''}`, "aria-invalid": !!errorMsg, onKeyDown: onKeyDown, onPaste: onPaste, autoComplete: autoComplete, ...props })] }), _jsxs("div", { className: style.endIconsContainer, children: [clearable && value && !disabled && (_jsx("div", { className: style.clearIconContainer, onClick: handleClear, tabIndex: 0, onKeyDown: (event) => handleIconKeyDown(event, handleClear), "aria-label": "Clear text", children: _jsx(ClearField, { width: '1rem', height: '1rem', className: style.clearIcon, "data-id": "CLEAR_ICON_INPUT_FIELD" }) })), endAdornment && _jsx("div", { className: style.adornment, children: endAdornment }), type === 'password' && (_jsx("div", { className: style.adornment, onClick: toggleShowPassword, tabIndex: 0, onKeyDown: (event) => handleIconKeyDown(event, toggleShowPassword), "aria-label": showPassword ? 'Hide password' : 'Show password', children: showPassword ? (_jsx(ShowPasswordIcon, { className: `${style.icon} ${disabled ? style.disabled : style.enabled}`, width: '1.125rem', height: '1.125rem', "data-id": "EYE_ICON_ID" })) : (_jsx(HidePasswordIcon, { className: `${style.icon} ${disabled ? style.disabled : style.enabled}`, width: '1.125rem', height: '1.125rem', "data-id": "EYE_ICON_ID" })) }))] })] }), (helperText || errorMsg) && (_jsx(HelperText, { type: errorMsg ? 'error' : 'default', text: errorMsg ? errorMsg : helperText || '' }))] }));
|
|
37
|
+
};
|
|
38
|
+
export default Input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Input';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styles from './label.module.scss';
|
|
3
|
+
const Label = ({ className = '', required, label }) => {
|
|
4
|
+
return (_jsx("div", { className: `${styles.labelContainer} ${className}`, children: label && (_jsxs("span", { className: styles.label, "data-id": `${String(label)?.replaceAll(' ', '_')}_LABEL_ID`, children: [label, required ? _jsx("span", { className: styles.starRequire, children: "*" }) : ''] })) }));
|
|
5
|
+
};
|
|
6
|
+
export default Label;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Label';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import styles from './overlay.module.scss';
|
|
3
|
+
const Overlay = ({ children, className, open = true }) => {
|
|
4
|
+
if (!open)
|
|
5
|
+
return null;
|
|
6
|
+
return _jsx("div", { className: `${styles.overlayContainer} ${className}`, children: children });
|
|
7
|
+
};
|
|
8
|
+
export default Overlay;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Overlay';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styles from './pagination.module.scss';
|
|
3
|
+
import Button from '../Button/Button';
|
|
4
|
+
import DoubleRightArrow from '../../icons/DoubleRightArrow';
|
|
5
|
+
import DoubleLeftArrow from '../../icons/DoubleLeftArrow';
|
|
6
|
+
import ArrowRight from '../../icons/ArrowRight';
|
|
7
|
+
import ExcelIcon from '../../icons/ExcelIcon';
|
|
8
|
+
import PdfIcon from '../../icons/PdfIcon';
|
|
9
|
+
import ArrowLeft from '../../icons/ArrowLeft';
|
|
10
|
+
const Pagination = ({ page, setPage, count, totalElement, disabledExportExcelBtn, disabledExportPdfBtn, excelExport, showPageCount = true, showExportButtons = true, disabledNextButton = false, removeFirstLastButtons = false, pageSize = 10, labels = {
|
|
11
|
+
currentPage: 'Showing on page',
|
|
12
|
+
to: 'to',
|
|
13
|
+
}, className = '', }) => {
|
|
14
|
+
const pageNumbers = Array.from({ length: count }, (_, i) => i + 1);
|
|
15
|
+
const maxPagesToShow = 5;
|
|
16
|
+
const firstPageToShow = Math.max(1, page - Math.floor(maxPagesToShow / 2));
|
|
17
|
+
const lastPageToShow = Math.min(count, firstPageToShow + maxPagesToShow - 1);
|
|
18
|
+
const visiblePageNumbers = pageNumbers.slice(firstPageToShow - 1, lastPageToShow);
|
|
19
|
+
return (_jsxs("div", { className: `${styles.paginationContainer} ${className}`, "data-id": "PAGINATION_BAR", children: [showExportButtons && (_jsxs("div", { className: styles.exportSection, children: [_jsx("div", { className: styles.exportContainer, children: _jsx(Button, { variant: "outlined", "data-id": "EXPORT_TO_EXCEL", startIcon: _jsx(ExcelIcon, { width: '1rem', height: '1rem' }), disabled: disabledExportExcelBtn, onClick: excelExport, className: styles.exportButton, children: "Export Excel" }) }), _jsx("div", { className: styles.exportContainer, children: _jsx(Button, { variant: "outlined", "data-id": "EXPORT_TO_PDF", startIcon: _jsx(PdfIcon, { width: '1rem', height: '1rem' }), disabled: disabledExportPdfBtn, className: styles.exportButton, children: "Export PDF" }) })] })), !disabledExportExcelBtn && !disabledExportPdfBtn && (_jsxs("span", { className: styles.descriptionPages, "data-id": "DESCRIPTION_PAGES", children: [_jsxs("span", { children: [labels['currentPage'], " ", page, " - ", page * pageSize - (pageSize - 1), " ", labels.to] }), _jsx("span", { className: styles.numberEdit, children: page === count ? totalElement : page * pageSize })] })), _jsxs("div", { className: styles.pagesNavigationContainer, children: [!removeFirstLastButtons && (_jsx("div", { className: `${styles.buttonContainer} ${Boolean(page === 1) ? styles.disabled : styles.active}`, children: _jsx(Button, { disabled: Boolean(page === 1), className: Boolean(page === 1) ? styles.disabled : '', variant: "outlined", onClick: () => setPage(0), "data-id": "FIRST_RECORD_BUTTON", children: _jsx(DoubleLeftArrow, { height: '1.125rem', width: '1.125rem' }) }) })), _jsx("div", { className: `${styles.buttonContainer} ${Boolean(page === 1) ? styles.disabled : styles.active}`, children: _jsx(Button, { disabled: Boolean(page === 1), variant: "outlined", "data-id": "PREVIOUS_BUTTON", onClick: () => {
|
|
20
|
+
setPage((prev) => prev - 1);
|
|
21
|
+
}, className: Boolean(page === 1) ? styles.disabled : '', children: _jsx(ArrowLeft, { height: '0.75rem', width: '0.75rem' }) }) }), showPageCount &&
|
|
22
|
+
visiblePageNumbers?.map((pageNumber, index) => (_jsx("div", { className: styles.buttonContainer, children: _jsx("span", { className: pageNumber === page ? styles.selected : '', children: _jsx("div", { className: `${styles.buttonContainer} ${styles.paginationNums}`, children: _jsx(Button, { disabled: pageNumber === page, variant: "outlined", "data-id": `PAGE_${pageNumber}`, onClick: () => setPage(pageNumber - 1), children: pageNumber }, pageNumber) }) }) }, index))), _jsx("div", { className: `${styles.buttonContainer} ${page === count || count === 0 || disabledNextButton ? styles.disabled : styles.active}`, children: _jsx(Button, { disabled: page === count || count === 0 || disabledNextButton, className: page === count || count === 0 || disabledNextButton ? styles.disabled : '', variant: "outlined", "data-id": "NEXT_BUTTON", onClick: () => {
|
|
23
|
+
totalElement !== 0 && setPage((prev) => prev + 1);
|
|
24
|
+
}, children: _jsx(ArrowRight, { height: '0.75rem', width: '0.75rem' }) }) }), !removeFirstLastButtons && (_jsx("div", { className: `${styles.buttonContainer} ${page === count || count === 0 ? styles.disabled : styles.active}`, children: _jsx(Button, { disabled: page === count || count === 0, className: page === count || count === 0 ? styles.disabled : '', variant: "outlined", "data-id": "LAST_RECORD_BUTTON", onClick: () => setPage(count - 1), children: _jsx(DoubleRightArrow, { height: '1.125rem', width: '1.125rem' }) }) }))] })] }));
|
|
25
|
+
};
|
|
26
|
+
export default Pagination;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Pagination';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
import styles from './radio.module.scss';
|
|
4
|
+
import { Position, Size } from '../../types';
|
|
5
|
+
const Radio = forwardRef(({ name, size = Size.Medium, checked = false, onChange, disabled, label, labelPosition = Position.End, color = 'default', className, }, ref) => {
|
|
6
|
+
return (_jsxs("div", { className: `${styles.radioContainer} ${styles[labelPosition]} ${styles[size]} ${className}`, children: [_jsx("input", { className: `${styles.radioInput} ${styles[color]}`, type: "radio", "data-id": `${label?.toUpperCase().replaceAll(' ', '_')}_BUTTON`, name: name, disabled: disabled, checked: checked, "aria-checked": checked, onClick: onChange, ref: ref }), _jsx("div", { className: `${styles.label} ${disabled ? styles.disabledLabel : ''}`, onClick: onChange, children: label })] }));
|
|
7
|
+
});
|
|
8
|
+
export default Radio;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Radio';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Radio from '../Radio';
|
|
4
|
+
import styles from './radioGroup.module.scss';
|
|
5
|
+
import { Position, Size } from '../../types';
|
|
6
|
+
const RadioGroup = ({ name, options, onChange, size = Size.Medium, labelPosition = Position.End, color = 'default', label, defaultValue, direction = 'horizontal', gap = '10px', className = '', }) => {
|
|
7
|
+
const [selectedValue, setSelectedValue] = useState(defaultValue);
|
|
8
|
+
const handleChange = (value) => {
|
|
9
|
+
onChange(value);
|
|
10
|
+
setSelectedValue(value);
|
|
11
|
+
};
|
|
12
|
+
return (_jsxs("div", { className: styles.radioGroupContainer, children: [_jsxs("div", { className: styles.radioGroupLabel, children: [_jsxs("span", { children: [" ", label] }), _jsx("span", { className: styles.requiredStar, children: "*" })] }), _jsx("div", { className: `${styles.radioGroupList} ${styles[direction]} ${className}`, style: { gap: gap }, children: options.map((option) => (_jsx(Radio, { name: name, checked: option.value === selectedValue, onChange: () => handleChange(option.value), disabled: option.disabled, label: option.label, size: size, labelPosition: labelPosition, color: color }, option.value))) })] }));
|
|
13
|
+
};
|
|
14
|
+
export default RadioGroup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './RadioGroup';
|