qlu-20-ui-library 1.10.15 → 1.10.17
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/build/index.css +1 -1
- package/dist/build/qlu-20-ui-library.cjs +65 -179
- package/dist/build/qlu-20-ui-library.js +29929 -28719
- package/dist/components/CreditsManagementDropdownButton/CreditsManagementDropdownButton/index.d.ts +1 -1
- package/dist/types/components/Charts/AreaChart/AreaChart.js +1 -1
- package/dist/types/components/Charts/BarLineChart/BarLineChart.js +7 -7
- package/dist/types/components/CreditsManagementDropdownButton/CreditsManagementDatePicker/CustomDayContent.js +5 -5
- package/dist/types/components/CreditsManagementDropdownButton/CreditsManagementDatePicker/index.js +8 -6
- package/dist/types/components/CreditsManagementDropdownButton/CreditsManagementDropdownButton/index.d.ts +1 -1
- package/dist/types/components/DatePicker/CustomDayContent.js +4 -4
- package/dist/types/components/DatePicker/index.js +7 -5
- package/dist/types/components/OTP/index.js +90 -52
- package/dist/types/components/ToggleComponent/index.js +2 -1
- package/dist/types/stories/OTP.stories.d.ts +2 -2
- package/dist/types/stories/OTP.stories.js +14 -3
- package/dist/types/stories/ToggleComponent.stories.d.ts +2 -2
- package/dist/types/stories/ToggleComponent.stories.js +5 -3
- package/package.json +8 -8
package/dist/components/CreditsManagementDropdownButton/CreditsManagementDropdownButton/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ interface DropDownButtonProps {
|
|
|
6
6
|
width?: string;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
dataCy?: string;
|
|
9
|
-
whiteListedRef?: React.RefObject<HTMLDivElement>;
|
|
9
|
+
whiteListedRef?: React.RefObject<HTMLDivElement | null>;
|
|
10
10
|
isOpen?: boolean;
|
|
11
11
|
handleOpen?: (isOpen: boolean) => void;
|
|
12
12
|
customRootElem?: HTMLDivElement;
|
|
@@ -65,7 +65,7 @@ function AreaChart({ values, valuesFormatter = formatterForUSD, xStepSize, yStep
|
|
|
65
65
|
},
|
|
66
66
|
label: function (context) {
|
|
67
67
|
const label = context.parsed.y;
|
|
68
|
-
return formatterForUSD.format(label);
|
|
68
|
+
return label ? formatterForUSD.format(label) : "$0";
|
|
69
69
|
},
|
|
70
70
|
},
|
|
71
71
|
bodyColor: "#FF8D4E",
|
|
@@ -9,7 +9,7 @@ function BarLineChart({ values, view = "both", showLegend = true, valuesFormatte
|
|
|
9
9
|
transformedValues.forEach((value) => {
|
|
10
10
|
transformedLabels.push([value.key.split("\n")]);
|
|
11
11
|
});
|
|
12
|
-
const maxValue = Math.max(...transformedValues.map(v => v.value));
|
|
12
|
+
const maxValue = Math.max(...transformedValues.map((v) => v.value));
|
|
13
13
|
const minVisiblePercentage = 0.07;
|
|
14
14
|
const options = {
|
|
15
15
|
responsive: true,
|
|
@@ -107,12 +107,12 @@ function BarLineChart({ values, view = "both", showLegend = true, valuesFormatte
|
|
|
107
107
|
if (context.dataset.type === "bar") {
|
|
108
108
|
const barDataset = context.dataset;
|
|
109
109
|
const realValue = barDataset.realData?.[context.dataIndex] ?? context.parsed.y;
|
|
110
|
-
return valuesFormatter.format(realValue);
|
|
110
|
+
return realValue ? valuesFormatter.format(realValue) : "$0";
|
|
111
111
|
}
|
|
112
112
|
if (context.dataset.type === "line") {
|
|
113
113
|
const lineDataset = context.dataset;
|
|
114
114
|
const realValue = lineDataset.realData?.[context.dataIndex] ?? context.parsed.y;
|
|
115
|
-
return valuesFormatter.format(realValue);
|
|
115
|
+
return realValue ? valuesFormatter.format(realValue) : "$0";
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
},
|
|
@@ -146,13 +146,13 @@ function BarLineChart({ values, view = "both", showLegend = true, valuesFormatte
|
|
|
146
146
|
};
|
|
147
147
|
const lineData = {
|
|
148
148
|
type: "line",
|
|
149
|
-
data: transformedValues.map(val => {
|
|
149
|
+
data: transformedValues.map((val) => {
|
|
150
150
|
const actualValue = val.value;
|
|
151
151
|
return actualValue < maxValue * minVisiblePercentage && actualValue !== 0
|
|
152
152
|
? maxValue * minVisiblePercentage
|
|
153
153
|
: actualValue;
|
|
154
154
|
}),
|
|
155
|
-
realData: transformedValues.map(val => val.value),
|
|
155
|
+
realData: transformedValues.map((val) => val.value),
|
|
156
156
|
pointBackgroundColor: "#331C10",
|
|
157
157
|
pointRadius: (context) => {
|
|
158
158
|
if (startsFromZeroVariant) {
|
|
@@ -191,14 +191,14 @@ function BarLineChart({ values, view = "both", showLegend = true, valuesFormatte
|
|
|
191
191
|
};
|
|
192
192
|
const barData = {
|
|
193
193
|
type: "bar",
|
|
194
|
-
data: transformedValues.map(val => {
|
|
194
|
+
data: transformedValues.map((val) => {
|
|
195
195
|
const actualValue = val.value;
|
|
196
196
|
// If the value is very small compared to max, boost it to minimum visible height
|
|
197
197
|
return actualValue < maxValue * minVisiblePercentage && actualValue !== 0
|
|
198
198
|
? maxValue * minVisiblePercentage
|
|
199
199
|
: actualValue;
|
|
200
200
|
}),
|
|
201
|
-
realData: transformedValues.map(val => val.value),
|
|
201
|
+
realData: transformedValues.map((val) => val.value),
|
|
202
202
|
label: "",
|
|
203
203
|
borderWidth: 1,
|
|
204
204
|
backgroundColor: (context) => {
|
|
@@ -4,15 +4,15 @@ import clsx from "clsx";
|
|
|
4
4
|
const CustomDayContent = (props) => {
|
|
5
5
|
const event = props.eventsData?.find((entry) => {
|
|
6
6
|
const date = new Date(entry.date);
|
|
7
|
-
return (date.getDate() === props.date.getDate() &&
|
|
8
|
-
date.getMonth() === props.date.getMonth() &&
|
|
9
|
-
date.getFullYear() === props.date.getFullYear());
|
|
7
|
+
return (date.getDate() === props.day.date.getDate() &&
|
|
8
|
+
date.getMonth() === props.day.date.getMonth() &&
|
|
9
|
+
date.getFullYear() === props.day.date.getFullYear());
|
|
10
10
|
});
|
|
11
|
-
const isDisabled = props.date.getTime() > new Date().getTime();
|
|
11
|
+
const isDisabled = props.day.date.getTime() > new Date().getTime();
|
|
12
12
|
const dayCellClasses = clsx({
|
|
13
13
|
"daypicker-day-cell-content": true,
|
|
14
14
|
disabled: isDisabled,
|
|
15
15
|
});
|
|
16
|
-
return (_jsx(Tooltip, { content: event?.name || "", toolTipPosition: "top", isDisabled: !event, children: _jsxs("span", { className: dayCellClasses, children: [props.date.getDate(), !!event && _jsx("span", { className: "event-dot" })] }) }));
|
|
16
|
+
return (_jsx(Tooltip, { content: event?.name || "", toolTipPosition: "top", isDisabled: !event, children: _jsxs("span", { className: dayCellClasses, children: [props.day.date.getDate(), !!event && _jsx("span", { className: "event-dot" })] }) }));
|
|
17
17
|
};
|
|
18
18
|
export default CustomDayContent;
|
package/dist/types/components/CreditsManagementDropdownButton/CreditsManagementDatePicker/index.js
CHANGED
|
@@ -26,14 +26,15 @@ function DatePicker({ onDateSelected, initialValue, eventsData, timezone, custom
|
|
|
26
26
|
newDate.setMonth(selectedMonth.getMonth() + 1);
|
|
27
27
|
setSelectedMonth(newDate);
|
|
28
28
|
};
|
|
29
|
-
const formatCaption = (date) => {
|
|
30
|
-
const months = date.toLocaleString("en-US", { month: "long" });
|
|
31
|
-
return (_jsxs("div", { className: "datePicker-customCaption", children: [_jsx("span", { className: "datePicker-prevMonthArrow", onClick: handlePrevMonthClick, children: _jsx(GetSvgIcon, { iconType: "arrowLeft", iconSize: "32" }) }), months, " ", date.getFullYear(), _jsx("span", { className: "datePicker-nextMonthArrow", onClick: handleNextMonthClick, children: _jsx(GetSvgIcon, { iconType: "arrowRight", iconSize: "32" }) })] }));
|
|
32
|
-
};
|
|
33
29
|
const formatWeekday = (date) => {
|
|
34
30
|
const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
35
31
|
return weekdays[date.getDay()];
|
|
36
32
|
};
|
|
33
|
+
const CustomCaption = ({ calendarMonth, displayIndex, ...props }) => {
|
|
34
|
+
const displayMonth = calendarMonth.date;
|
|
35
|
+
const months = displayMonth.toLocaleString("en-US", { month: "long" });
|
|
36
|
+
return (_jsxs("div", { className: "datePicker-customCaption", ...props, children: [_jsx("span", { className: "datePicker-prevMonthArrow", onClick: handlePrevMonthClick, children: _jsx(GetSvgIcon, { iconType: "arrowLeft", iconSize: "32" }) }), months, " ", displayMonth.getFullYear(), _jsx("span", { className: "datePicker-nextMonthArrow", onClick: handleNextMonthClick, children: _jsx(GetSvgIcon, { iconType: "arrowRight", iconSize: "32" }) })] }));
|
|
37
|
+
};
|
|
37
38
|
const [dropdownPosition, setDropdownPosition] = useState({ x: 0, y: 0, direction: "top" });
|
|
38
39
|
const dropdownRef = useRef(null);
|
|
39
40
|
const mainRef = useRef(null);
|
|
@@ -105,8 +106,9 @@ function DatePicker({ onDateSelected, initialValue, eventsData, timezone, custom
|
|
|
105
106
|
setSelectedDate(props[0]);
|
|
106
107
|
onDateSelected(props[0]);
|
|
107
108
|
}
|
|
108
|
-
}, footer: footer, formatters: {
|
|
109
|
-
|
|
109
|
+
}, footer: footer, formatters: { formatWeekdayName: formatWeekday }, showOutsideDays: true, components: {
|
|
110
|
+
MonthCaption: CustomCaption,
|
|
111
|
+
Day: (props) => (_jsx(CustomDayContent, { day: props.day, modifiers: props.modifiers, eventsData: eventsData })),
|
|
110
112
|
}, classNames: { day: "datepicker-day-cell" } }) }), customRootElem || document.body)] }));
|
|
111
113
|
}
|
|
112
114
|
export default DatePicker;
|
|
@@ -7,7 +7,7 @@ interface DropDownButtonProps {
|
|
|
7
7
|
width?: string;
|
|
8
8
|
disabled?: boolean;
|
|
9
9
|
dataCy?: string;
|
|
10
|
-
whiteListedRef?: React.RefObject<HTMLDivElement>;
|
|
10
|
+
whiteListedRef?: React.RefObject<HTMLDivElement | null>;
|
|
11
11
|
isOpen?: boolean;
|
|
12
12
|
handleOpen?: (isOpen: boolean) => void;
|
|
13
13
|
customRootElem?: HTMLDivElement;
|
|
@@ -3,10 +3,10 @@ import Tooltip from "../Tooltip";
|
|
|
3
3
|
const CustomDayContent = (props) => {
|
|
4
4
|
const event = props.eventsData?.find((entry) => {
|
|
5
5
|
const date = new Date(entry.date);
|
|
6
|
-
return (date.getDate() === props.date.getDate() &&
|
|
7
|
-
date.getMonth() === props.date.getMonth() &&
|
|
8
|
-
date.getFullYear() === props.date.getFullYear());
|
|
6
|
+
return (date.getDate() === props.day.date.getDate() &&
|
|
7
|
+
date.getMonth() === props.day.date.getMonth() &&
|
|
8
|
+
date.getFullYear() === props.day.date.getFullYear());
|
|
9
9
|
});
|
|
10
|
-
return (_jsx(Tooltip, { content: event?.name || "", toolTipPosition: "top", isDisabled: !event, children: _jsxs("span", { className: "daypicker-day-cell-content", children: [props.date.getDate(), !!event && _jsx("span", { className: "event-dot" })] }) }));
|
|
10
|
+
return (_jsx(Tooltip, { content: event?.name || "", toolTipPosition: "top", isDisabled: !event, children: _jsxs("span", { className: "daypicker-day-cell-content", children: [props.day.date.getDate(), !!event && _jsx("span", { className: "event-dot" })] }) }));
|
|
11
11
|
};
|
|
12
12
|
export default CustomDayContent;
|
|
@@ -26,9 +26,10 @@ const DatePicker = ({ disabledUntil, disableWeekends = false, onDateSelected, in
|
|
|
26
26
|
newDate.setMonth(selectedMonth.getMonth() + 1);
|
|
27
27
|
setSelectedMonth(newDate);
|
|
28
28
|
};
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
29
|
+
const CustomCaption = ({ calendarMonth, displayIndex, ...props }) => {
|
|
30
|
+
const displayMonth = calendarMonth.date;
|
|
31
|
+
const months = displayMonth.toLocaleString("en-US", { month: "long" });
|
|
32
|
+
return (_jsxs("div", { className: "datePicker-customCaption", ...props, children: [_jsx("span", { className: "datePicker-prevMonthArrow", onClick: handlePrevMonthClick, children: _jsx(GetSvgIcon, { iconType: "arrowLeft", iconSize: "32" }) }), months, " ", displayMonth.getFullYear(), _jsx("span", { className: "datePicker-nextMonthArrow", onClick: handleNextMonthClick, children: _jsx(GetSvgIcon, { iconType: "arrowRight", iconSize: "32" }) })] }));
|
|
32
33
|
};
|
|
33
34
|
const formatWeekday = (date) => {
|
|
34
35
|
const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
@@ -120,8 +121,9 @@ const DatePicker = ({ disabledUntil, disableWeekends = false, onDateSelected, in
|
|
|
120
121
|
}, selected: selectedDate, onSelect: (...props) => {
|
|
121
122
|
props?.[3]?.stopPropagation?.();
|
|
122
123
|
setSelectedDate(props[0]);
|
|
123
|
-
}, footer: footer, formatters: {
|
|
124
|
-
|
|
124
|
+
}, footer: footer, formatters: { formatWeekdayName: formatWeekday }, showOutsideDays: true, components: {
|
|
125
|
+
MonthCaption: CustomCaption,
|
|
126
|
+
Day: (props) => (_jsx(CustomDayContent, { day: props.day, modifiers: props.modifiers, eventsData: eventsData })),
|
|
125
127
|
}, classNames: { day: "datepicker-day-cell" } }) }), customRootElem || rootElem.current)] }));
|
|
126
128
|
};
|
|
127
129
|
export default DatePicker;
|
|
@@ -15,61 +15,84 @@ const OTPComponent = ({ length = 6, isDisable = false, error = false, onOTPChang
|
|
|
15
15
|
});
|
|
16
16
|
}, [inputValues]);
|
|
17
17
|
//this function is to handle the onPaste event for an input field
|
|
18
|
-
const handlePaste = (event) => {
|
|
18
|
+
const handlePaste = (index, event) => {
|
|
19
|
+
event.preventDefault();
|
|
19
20
|
const pastedText = event.clipboardData?.getData("text") || "";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const characters =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
// Filter to only numeric characters
|
|
22
|
+
const numericOnly = pastedText.replace(/\D/g, "");
|
|
23
|
+
const characters = numericOnly.split("").slice(0, length - index);
|
|
24
|
+
// Update input values and field values starting from the current index
|
|
25
|
+
const updatedInputValues = [...inputValues];
|
|
26
|
+
const updatedFieldValues = [...fieldValues];
|
|
27
|
+
characters.forEach((char, charIndex) => {
|
|
28
|
+
const targetIndex = index + charIndex;
|
|
29
|
+
if (targetIndex < length) {
|
|
30
|
+
updatedInputValues[targetIndex] = char;
|
|
31
|
+
updatedFieldValues[targetIndex] = char;
|
|
32
|
+
if (inputRefs.current[targetIndex]) {
|
|
33
|
+
inputRefs.current[targetIndex].value = char;
|
|
34
|
+
}
|
|
31
35
|
}
|
|
32
36
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
// Clear remaining fields after the pasted content
|
|
38
|
+
const endIndex = Math.min(index + characters.length, length);
|
|
39
|
+
for (let i = endIndex; i < length; i++) {
|
|
40
|
+
updatedInputValues[i] = "";
|
|
41
|
+
updatedFieldValues[i] = "";
|
|
42
|
+
if (inputRefs.current[i]) {
|
|
43
|
+
inputRefs.current[i].value = "";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
setInputValues(updatedInputValues);
|
|
47
|
+
setFieldValues(updatedFieldValues);
|
|
48
|
+
const completeOTP = updatedFieldValues.join("");
|
|
49
|
+
setOtp(completeOTP);
|
|
50
|
+
// Trigger completion callback if all fields are filled
|
|
51
|
+
if (updatedFieldValues.every((val) => val !== "") && onOTPComplete) {
|
|
52
|
+
onOTPComplete(completeOTP);
|
|
43
53
|
}
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
// Focus the last filled field or next empty field
|
|
55
|
+
const nextEmptyIndex = updatedFieldValues.findIndex((val) => val === "");
|
|
56
|
+
const focusIndex = nextEmptyIndex === -1 ? length - 1 : Math.min(nextEmptyIndex, length - 1);
|
|
57
|
+
if (inputRefs.current[focusIndex]) {
|
|
58
|
+
inputRefs.current[focusIndex].focus();
|
|
46
59
|
}
|
|
47
|
-
}
|
|
60
|
+
};
|
|
48
61
|
const handleInput = (index, event) => {
|
|
49
62
|
const value = event.target.value;
|
|
63
|
+
// Extract only the last character if multiple characters are entered
|
|
64
|
+
const lastChar = value.slice(-1);
|
|
50
65
|
if (value.length === 0) {
|
|
66
|
+
// Clear the field
|
|
51
67
|
event.target.value = "";
|
|
52
|
-
|
|
53
|
-
setFieldValues((prev) => {
|
|
68
|
+
setInputValues((prev) => {
|
|
54
69
|
const updatedValues = [...prev];
|
|
55
70
|
updatedValues[index] = "";
|
|
56
71
|
return updatedValues;
|
|
57
72
|
});
|
|
58
|
-
}
|
|
59
|
-
else if (/^\d$/.test(value)) {
|
|
60
|
-
event.target.value = value;
|
|
61
|
-
setOtp((prev) => prev.slice(0, index) + value + prev.slice(index + 1));
|
|
62
73
|
setFieldValues((prev) => {
|
|
63
74
|
const updatedValues = [...prev];
|
|
64
|
-
updatedValues[index] =
|
|
75
|
+
updatedValues[index] = "";
|
|
65
76
|
return updatedValues;
|
|
66
77
|
});
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
setOtp((prev) => prev.slice(0, index) + prev.slice(index + 1));
|
|
79
|
+
}
|
|
80
|
+
else if (/^\d$/.test(lastChar)) {
|
|
81
|
+
// Only allow numeric input
|
|
82
|
+
event.target.value = lastChar;
|
|
83
|
+
const updatedInputValues = [...inputValues];
|
|
84
|
+
const updatedFieldValues = [...fieldValues];
|
|
85
|
+
updatedInputValues[index] = lastChar;
|
|
86
|
+
updatedFieldValues[index] = lastChar;
|
|
87
|
+
setInputValues(updatedInputValues);
|
|
88
|
+
setFieldValues(updatedFieldValues);
|
|
89
|
+
const completeOTP = updatedFieldValues.join("");
|
|
90
|
+
setOtp(completeOTP);
|
|
91
|
+
// Check if OTP is complete and trigger callback
|
|
92
|
+
if (updatedFieldValues.every((val) => val !== "") && onOTPComplete) {
|
|
71
93
|
onOTPComplete(completeOTP);
|
|
72
94
|
}
|
|
95
|
+
// Move to next field if not the last one
|
|
73
96
|
if (index < length - 1) {
|
|
74
97
|
inputRefs.current[index + 1].focus();
|
|
75
98
|
}
|
|
@@ -77,30 +100,45 @@ const OTPComponent = ({ length = 6, isDisable = false, error = false, onOTPChang
|
|
|
77
100
|
event.target.blur();
|
|
78
101
|
}
|
|
79
102
|
}
|
|
103
|
+
else {
|
|
104
|
+
// Invalid input - reset to previous value
|
|
105
|
+
event.target.value = inputValues[index] || "";
|
|
106
|
+
}
|
|
80
107
|
};
|
|
81
108
|
const handleBackspace = (index, event) => {
|
|
82
|
-
if (event.key === "Backspace"
|
|
83
|
-
index > 0
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
109
|
+
if (event.key === "Backspace") {
|
|
110
|
+
if (event.currentTarget.value === "" && index > 0) {
|
|
111
|
+
// If current field is empty, move to previous and clear it
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
const updatedInputValues = [...inputValues];
|
|
114
|
+
const updatedFieldValues = [...fieldValues];
|
|
115
|
+
updatedInputValues[index - 1] = "";
|
|
116
|
+
updatedFieldValues[index - 1] = "";
|
|
117
|
+
setInputValues(updatedInputValues);
|
|
118
|
+
setFieldValues(updatedFieldValues);
|
|
119
|
+
setOtp((prev) => prev.slice(0, index - 1) + prev.slice(index));
|
|
120
|
+
if (inputRefs.current[index - 1]) {
|
|
121
|
+
inputRefs.current[index - 1].value = "";
|
|
122
|
+
inputRefs.current[index - 1].focus();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// If current field has value, let the default behavior clear it
|
|
126
|
+
// The handleInput will handle the state update
|
|
94
127
|
}
|
|
95
128
|
};
|
|
129
|
+
const handleClick = (event) => {
|
|
130
|
+
// Select all text when clicking on an input for easy clearing
|
|
131
|
+
event.currentTarget.select();
|
|
132
|
+
};
|
|
133
|
+
const handleFocus = (event) => {
|
|
134
|
+
// Select all text on focus for easy clearing
|
|
135
|
+
event.currentTarget.select();
|
|
136
|
+
};
|
|
96
137
|
useEffect(() => {
|
|
97
138
|
if (onOTPChange) {
|
|
98
139
|
onOTPChange(otp);
|
|
99
140
|
}
|
|
100
141
|
}, [otp]);
|
|
101
|
-
return (_jsx("div", { className: "otp-container", children: Array.from({ length }).map((_, index) => (_jsx("input", { autoComplete: "off", disabled: isDisable, type: "text", maxLength: 1, className: `otp-box ${error ? "error" : ""}`, ref: (ref) => (inputRefs.current[index] = ref), onChange: (event) =>
|
|
102
|
-
handleInput(index, event);
|
|
103
|
-
handlePasteChange(event, index);
|
|
104
|
-
}, onKeyDown: (event) => handleBackspace(index, event), onPaste: index === 0 ? handlePaste : undefined }, index))) }));
|
|
142
|
+
return (_jsx("div", { className: "otp-container", children: Array.from({ length }).map((_, index) => (_jsx("input", { autoComplete: "off", disabled: isDisable, type: "text", inputMode: "numeric", pattern: "[0-9]*", maxLength: 1, className: `otp-box ${error ? "error" : ""}`, ref: (ref) => (inputRefs.current[index] = ref), onChange: (event) => handleInput(index, event), onKeyDown: (event) => handleBackspace(index, event), onClick: handleClick, onFocus: handleFocus, onPaste: (event) => handlePaste(index, event) }, index))) }));
|
|
105
143
|
};
|
|
106
144
|
export default OTPComponent;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
|
+
import clsx from "clsx";
|
|
3
4
|
import "./style.scss";
|
|
4
5
|
const ToggleComponent = ({ initialState, onClick, sizeVariant = "base", isDisabled = false, dataCy, }) => {
|
|
5
6
|
const [isOn, setIsOn] = useState(initialState);
|
|
@@ -12,6 +13,6 @@ const ToggleComponent = ({ initialState, onClick, sizeVariant = "base", isDisabl
|
|
|
12
13
|
setIsOn(!isOn);
|
|
13
14
|
onClick();
|
|
14
15
|
};
|
|
15
|
-
return (_jsx("div", { className:
|
|
16
|
+
return (_jsx("div", { className: clsx(sizeVariant === "sm" ? "smSizeToggle" : "toggle", isOn ? "on" : "off", isDisabled && "disabled"), onClick: handleToggle, "data-cy": dataCy, children: _jsx("div", { className: sizeVariant === "sm" ? "smSizeToggle-switch" : "toggle-switch" }) }));
|
|
16
17
|
};
|
|
17
18
|
export default ToggleComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from
|
|
2
|
-
import OTPComponent from
|
|
1
|
+
import type { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import OTPComponent from "../components/OTP";
|
|
3
3
|
declare const meta: Meta<typeof OTPComponent>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type OTPComponentProps = StoryObj<typeof OTPComponent>;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import OTPComponent from
|
|
1
|
+
import OTPComponent from "../components/OTP";
|
|
2
|
+
// Mock function to replace @storybook/test fn() for Storybook 9.x compatibility
|
|
3
|
+
const fn = () => {
|
|
4
|
+
const spy = (...args) => {
|
|
5
|
+
spy.calls.push(args);
|
|
6
|
+
spy.callCount++;
|
|
7
|
+
};
|
|
8
|
+
spy.calls = [];
|
|
9
|
+
spy.callCount = 0;
|
|
10
|
+
return spy;
|
|
11
|
+
};
|
|
2
12
|
const meta = {
|
|
3
13
|
title: "Input/OTPInputField",
|
|
4
|
-
component: OTPComponent
|
|
14
|
+
component: OTPComponent,
|
|
5
15
|
};
|
|
6
16
|
export default meta;
|
|
7
17
|
export const NavBar = {
|
|
@@ -9,6 +19,7 @@ export const NavBar = {
|
|
|
9
19
|
length: 6,
|
|
10
20
|
error: false,
|
|
11
21
|
isDisable: false,
|
|
12
|
-
|
|
22
|
+
onOTPChange: fn(),
|
|
23
|
+
onOTPComplete: (value) => alert(value),
|
|
13
24
|
},
|
|
14
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from
|
|
2
|
-
import ToggleComponent from
|
|
1
|
+
import type { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import ToggleComponent from "../components/ToggleComponent";
|
|
3
3
|
declare const meta: Meta<typeof ToggleComponent>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type ToggleComponentProps = StoryObj<typeof ToggleComponent>;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import ToggleComponent from
|
|
1
|
+
import ToggleComponent from "../components/ToggleComponent";
|
|
2
2
|
const meta = {
|
|
3
|
-
title:
|
|
3
|
+
title: "Button/ToggleComponent",
|
|
4
4
|
component: ToggleComponent,
|
|
5
5
|
};
|
|
6
6
|
export default meta;
|
|
7
7
|
export const Primary = {
|
|
8
|
-
args: {
|
|
8
|
+
args: {
|
|
9
|
+
isDisabled: true,
|
|
10
|
+
},
|
|
9
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlu-20-ui-library",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"chart.js": "^4.3.0",
|
|
37
37
|
"react-chartjs-2": "^5.2.0",
|
|
38
38
|
"react-datepicker": "^7.5.0",
|
|
39
|
-
"react-day-picker": "^
|
|
39
|
+
"react-day-picker": "^9.11.3",
|
|
40
40
|
"react-flags-select": "^2.2.3",
|
|
41
|
-
"react-loader-spinner": "^
|
|
41
|
+
"react-loader-spinner": "^8.0.0",
|
|
42
42
|
"react-modal": "^3.16.3",
|
|
43
43
|
"react-table": "^7.8.0",
|
|
44
|
-
"react-toastify": "^
|
|
45
|
-
"react-tooltip": "^5.
|
|
46
|
-
"recharts": "^2.
|
|
44
|
+
"react-toastify": "^11.0.5",
|
|
45
|
+
"react-tooltip": "^5.30.0",
|
|
46
|
+
"recharts": "^2.15.0",
|
|
47
47
|
"sass": "^1.89.2",
|
|
48
48
|
"tiptap-extension-font-size": "^1.2.0",
|
|
49
49
|
"uuid": "^11.0.3",
|
|
50
50
|
"vite-plugin-dts": "^2.3.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"react": "18.2.0",
|
|
54
|
-
"react-dom": "18.2.0"
|
|
53
|
+
"react": "^18.2.0 || ^19.0.0",
|
|
54
|
+
"react-dom": "^18.2.0 || ^19.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@changesets/cli": "^2.29.5",
|