master-components-react-ts 2.0.1 → 2.1.2
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/assets/Icons/IconErrorDash.d.ts +2 -3
- package/dist/assets/Inter_24pt-SemiBold-DIQUEucn.woff2 +0 -0
- package/dist/components/Dropdown/Dropdown.types.d.ts +2 -2
- package/dist/components/InlineLoading/InlineLoading.d.ts +3 -0
- package/dist/components/InlineLoading/InlineLoading.types.d.ts +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3983 -1080
- package/dist/types/css-modules.d.ts +9 -0
- package/package.json +62 -60
- package/dist/_virtual/_commonjsHelpers.js +0 -8
- package/dist/_virtual/customParseFormat.js +0 -4
- package/dist/_virtual/jsx-runtime.js +0 -4
- package/dist/_virtual/react-jsx-runtime.production.js +0 -4
- package/dist/assets/Icons/IconArrowUp.js +0 -13
- package/dist/assets/Icons/IconCalendar.js +0 -32
- package/dist/assets/Icons/IconCheck.js +0 -15
- package/dist/assets/Icons/IconCheckCircle.js +0 -16
- package/dist/assets/Icons/IconCheckmark.js +0 -15
- package/dist/assets/Icons/IconCircularLoading.js +0 -36
- package/dist/assets/Icons/IconClose.js +0 -31
- package/dist/assets/Icons/IconCloseBackground.js +0 -15
- package/dist/assets/Icons/IconCloseCircle.js +0 -15
- package/dist/assets/Icons/IconExclamation.js +0 -15
- package/dist/assets/Icons/IconLeft.js +0 -13
- package/dist/assets/Icons/IconMinus.js +0 -7
- package/dist/assets/Icons/IconRadioChecked.js +0 -19
- package/dist/assets/Icons/IconRadioCheckedDisabled.js +0 -19
- package/dist/assets/Icons/IconRadioUnchecked.js +0 -16
- package/dist/assets/Icons/IconRadioUncheckedDisabled.js +0 -16
- package/dist/assets/Icons/IconRight.js +0 -13
- package/dist/assets/Icons/IconSave.js +0 -16
- package/dist/assets/Icons/IconSearch.js +0 -26
- package/dist/assets/Icons/IconTrash.js +0 -16
- package/dist/components/ActionDropdown/ActionDropdown.js +0 -74
- package/dist/components/ActionDropdown/ActionDropdown.module.scss.js +0 -29
- package/dist/components/Checkbox/Checkbox.js +0 -54
- package/dist/components/Checkbox/Checkbox.module.scss.js +0 -26
- package/dist/components/DatePicker/Calendar.js +0 -437
- package/dist/components/DatePicker/Calendar.module.scss.js +0 -83
- package/dist/components/DatePicker/DatePicker.js +0 -211
- package/dist/components/DatePicker/Datepicker.module.scss.js +0 -17
- package/dist/components/Dropdown/Dropdown.js +0 -336
- package/dist/components/Dropdown/Dropdown.module.scss.js +0 -74
- package/dist/components/FormInput/FormInput.js +0 -144
- package/dist/components/FormInput/FormInput.module.scss.js +0 -62
- package/dist/components/MainButton/MainButton.js +0 -72
- package/dist/components/MainButton/MainButton.module.scss.js +0 -56
- package/dist/components/NotificationToast/NotificationContext.js +0 -57
- package/dist/components/NotificationToast/NotificationToast.js +0 -66
- package/dist/components/NotificationToast/NotificationToast.module.scss.js +0 -59
- package/dist/components/NotificationToast/createNotificationToast.js +0 -10
- package/dist/components/Popup/Popup.js +0 -116
- package/dist/components/Popup/Popup.module.scss.js +0 -41
- package/dist/components/Radio/Radio.js +0 -46
- package/dist/components/Radio/Radio.module.scss.js +0 -8
- package/dist/components/Skeleton/Skeleton.js +0 -8
- package/dist/components/Skeleton/Skeleton.module.scss.js +0 -20
- package/dist/components/Textarea/Textarea.js +0 -149
- package/dist/components/Textarea/Textarea.module.scss.js +0 -41
- package/dist/components/TimePicker/TimePicker.js +0 -172
- package/dist/components/TimePicker/TimePicker.module.scss.js +0 -50
- package/dist/components/Toggle/Toggle.js +0 -20
- package/dist/components/Toggle/Toggle.module.scss.js +0 -29
- package/dist/components/Tooltip/Tooltip.js +0 -153
- package/dist/components/Tooltip/Tooltip.module.scss.js +0 -35
- package/dist/context/NamespaceContext.js +0 -7
- package/dist/node_modules/dayjs/plugin/customParseFormat.js +0 -129
- package/dist/node_modules/react/cjs/react-jsx-runtime.production.js +0 -35
- package/dist/node_modules/react/jsx-runtime.js +0 -10
- package/dist/utils/Helpers.js +0 -15
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import style from "./ActionDropdown.module.scss.js";
|
|
3
|
-
import { IconArrowUp } from "../../assets/Icons/IconArrowUp.js";
|
|
4
|
-
import { useState, useRef, useEffect } from "react";
|
|
5
|
-
const ActionDropdown = ({ title, data, onSelect }) => {
|
|
6
|
-
const [Collapsed, setCollapsed] = useState(false);
|
|
7
|
-
const DropdownRef = useRef(null);
|
|
8
|
-
const ListRef = useRef(null);
|
|
9
|
-
const [Selected, setSelected] = useState(null);
|
|
10
|
-
const HandleSelect = (item) => {
|
|
11
|
-
setSelected(item);
|
|
12
|
-
onSelect?.(item);
|
|
13
|
-
setCollapsed(false);
|
|
14
|
-
};
|
|
15
|
-
const CalculatePos = () => {
|
|
16
|
-
const componentEl = DropdownRef.current;
|
|
17
|
-
const dropdownEl = ListRef.current;
|
|
18
|
-
if (!dropdownEl || !componentEl) return;
|
|
19
|
-
const componentRect = componentEl.getBoundingClientRect();
|
|
20
|
-
const windowHeight = window.innerHeight;
|
|
21
|
-
dropdownEl.style.position = "fixed";
|
|
22
|
-
dropdownEl.style.width = componentRect.width + "px";
|
|
23
|
-
dropdownEl.style.left = `${componentRect.left + window.pageXOffset}px`;
|
|
24
|
-
if (componentRect.bottom + dropdownEl.offsetHeight > windowHeight) {
|
|
25
|
-
dropdownEl.style.top = `${window.scrollY + componentRect.top - dropdownEl.offsetHeight - 4}px`;
|
|
26
|
-
dropdownEl.style.bottom = "unset";
|
|
27
|
-
} else {
|
|
28
|
-
dropdownEl.style.top = `${window.scrollY + componentRect.bottom + 8}px`;
|
|
29
|
-
dropdownEl.style.bottom = "unset";
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
CalculatePos();
|
|
34
|
-
}, [DropdownRef, Collapsed]);
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
const ClickHandler = (event) => {
|
|
37
|
-
if (!DropdownRef.current) return;
|
|
38
|
-
if (event.composedPath().includes(DropdownRef.current)) return;
|
|
39
|
-
setCollapsed(false);
|
|
40
|
-
};
|
|
41
|
-
const ScrollHandler = (event) => {
|
|
42
|
-
if (!DropdownRef.current || !ListRef.current) return;
|
|
43
|
-
if (ListRef.current.contains(event.target)) return;
|
|
44
|
-
setCollapsed(false);
|
|
45
|
-
};
|
|
46
|
-
document.addEventListener("click", ClickHandler);
|
|
47
|
-
document.addEventListener("wheel", ScrollHandler);
|
|
48
|
-
return () => {
|
|
49
|
-
document.removeEventListener("click", ClickHandler);
|
|
50
|
-
document.removeEventListener("wheel", ScrollHandler);
|
|
51
|
-
};
|
|
52
|
-
}, []);
|
|
53
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${style.actionDropdownContainer} ${Collapsed ? style.collapsed : ""}`, children: [
|
|
54
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: DropdownRef, className: style.actionDropdownContent, onClick: () => setCollapsed((state) => !state), children: [
|
|
55
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { title, className: style.actionDropdownTitle, children: Selected?.label || title }),
|
|
56
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.actionDropdownIcon, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconArrowUp, { width: "10", height: "6", color: "#131314" }) })
|
|
57
|
-
] }),
|
|
58
|
-
Collapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: ListRef, onClick: (e) => e.stopPropagation(), className: style.actionDropdownList, children: data.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
59
|
-
"li",
|
|
60
|
-
{
|
|
61
|
-
onClick: (e) => {
|
|
62
|
-
e.stopPropagation();
|
|
63
|
-
HandleSelect(item);
|
|
64
|
-
},
|
|
65
|
-
className: `${style.actionDropdownItem} ${Selected?.id === item.id ? style.selected : ""}`,
|
|
66
|
-
children: item.label
|
|
67
|
-
},
|
|
68
|
-
item.id
|
|
69
|
-
)) }, data.length)
|
|
70
|
-
] });
|
|
71
|
-
};
|
|
72
|
-
export {
|
|
73
|
-
ActionDropdown as default
|
|
74
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const actionDropdownContainer = "ActionDropdown-module__actionDropdownContainer";
|
|
2
|
-
const collapsed = "ActionDropdown-module__collapsed";
|
|
3
|
-
const actionDropdownIcon = "ActionDropdown-module__actionDropdownIcon";
|
|
4
|
-
const actionDropdownContent = "ActionDropdown-module__actionDropdownContent";
|
|
5
|
-
const actionDropdownTitle = "ActionDropdown-module__actionDropdownTitle";
|
|
6
|
-
const actionDropdownList = "ActionDropdown-module__actionDropdownList";
|
|
7
|
-
const actionDropdownItem = "ActionDropdown-module__actionDropdownItem";
|
|
8
|
-
const selected = "ActionDropdown-module__selected";
|
|
9
|
-
const style = {
|
|
10
|
-
actionDropdownContainer,
|
|
11
|
-
collapsed,
|
|
12
|
-
actionDropdownIcon,
|
|
13
|
-
actionDropdownContent,
|
|
14
|
-
actionDropdownTitle,
|
|
15
|
-
actionDropdownList,
|
|
16
|
-
actionDropdownItem,
|
|
17
|
-
selected
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
actionDropdownContainer,
|
|
21
|
-
actionDropdownContent,
|
|
22
|
-
actionDropdownIcon,
|
|
23
|
-
actionDropdownItem,
|
|
24
|
-
actionDropdownList,
|
|
25
|
-
actionDropdownTitle,
|
|
26
|
-
collapsed,
|
|
27
|
-
style as default,
|
|
28
|
-
selected
|
|
29
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { useRef, useState } from "react";
|
|
3
|
-
import style from "./Checkbox.module.scss.js";
|
|
4
|
-
import { useNamespace } from "../../context/NamespaceContext.js";
|
|
5
|
-
import { IconMinus } from "../../assets/Icons/IconMinus.js";
|
|
6
|
-
import { IconCheckmark } from "../../assets/Icons/IconCheckmark.js";
|
|
7
|
-
const Checkbox = ({
|
|
8
|
-
checked,
|
|
9
|
-
change,
|
|
10
|
-
type = "default",
|
|
11
|
-
disabled = false,
|
|
12
|
-
required = false,
|
|
13
|
-
multipleChecked = false,
|
|
14
|
-
activeStyle,
|
|
15
|
-
checkBoxStyle,
|
|
16
|
-
theme = "light"
|
|
17
|
-
}) => {
|
|
18
|
-
const namespace = useNamespace();
|
|
19
|
-
const CheckboxRef = useRef(null);
|
|
20
|
-
const [isActive, setIsActive] = useState(false);
|
|
21
|
-
const onChange = () => {
|
|
22
|
-
if (disabled) return;
|
|
23
|
-
if (change && typeof change === "function") {
|
|
24
|
-
change(!checked);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const getStyle = () => {
|
|
28
|
-
if (isActive) {
|
|
29
|
-
if (disabled) {
|
|
30
|
-
return { boxShadow: "none" };
|
|
31
|
-
}
|
|
32
|
-
return activeStyle ?? {};
|
|
33
|
-
}
|
|
34
|
-
return checkBoxStyle ?? {};
|
|
35
|
-
};
|
|
36
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
37
|
-
"div",
|
|
38
|
-
{
|
|
39
|
-
style: getStyle(),
|
|
40
|
-
className: `${theme === "dark" ? style.dark : ""} ${style[namespace]} ${style.checkboxWrapper} ${type === "error" ? style.error : ""} ${checked ? style.checked : style.unChecked} ${disabled ? style.disabled : ""}`,
|
|
41
|
-
onMouseDown: () => setIsActive(true),
|
|
42
|
-
onMouseUp: () => setIsActive(false),
|
|
43
|
-
onMouseLeave: () => setIsActive(false),
|
|
44
|
-
onClick: onChange,
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("input", { ref: CheckboxRef, type: "checkbox", disabled, checked: checked ?? false, hidden: true, readOnly: true, required: required ?? false }),
|
|
47
|
-
checked ? multipleChecked ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconMinus, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconCheckmark, {}) : ""
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
};
|
|
52
|
-
export {
|
|
53
|
-
Checkbox as default
|
|
54
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const checkboxWrapper = "Checkbox-module__checkboxWrapper";
|
|
2
|
-
const checkMark = "Checkbox-module__checkMark";
|
|
3
|
-
const error = "Checkbox-module__error";
|
|
4
|
-
const checked = "Checkbox-module__checked";
|
|
5
|
-
const disabled = "Checkbox-module__disabled";
|
|
6
|
-
const namespaceHr = "Checkbox-module__Namespace_Hr";
|
|
7
|
-
const dark = "Checkbox-module__dark";
|
|
8
|
-
const style = {
|
|
9
|
-
checkboxWrapper,
|
|
10
|
-
checkMark,
|
|
11
|
-
error,
|
|
12
|
-
checked,
|
|
13
|
-
disabled,
|
|
14
|
-
namespaceHr,
|
|
15
|
-
dark
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
checkMark,
|
|
19
|
-
checkboxWrapper,
|
|
20
|
-
checked,
|
|
21
|
-
dark,
|
|
22
|
-
style as default,
|
|
23
|
-
disabled,
|
|
24
|
-
error,
|
|
25
|
-
namespaceHr
|
|
26
|
-
};
|
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import { j as jsxRuntimeExports } from "../../node_modules/react/jsx-runtime.js";
|
|
2
|
-
import { useState, useRef, useEffect } from "react";
|
|
3
|
-
import dayjs from "dayjs";
|
|
4
|
-
import style from "./Calendar.module.scss.js";
|
|
5
|
-
import { IconLeft } from "../../assets/Icons/IconLeft.js";
|
|
6
|
-
import { IconRight } from "../../assets/Icons/IconRight.js";
|
|
7
|
-
import { _filterUnique } from "../../utils/Helpers.js";
|
|
8
|
-
import customParseFormat from "../../node_modules/dayjs/plugin/customParseFormat.js";
|
|
9
|
-
import MainButton from "../MainButton/MainButton.js";
|
|
10
|
-
dayjs.extend(customParseFormat);
|
|
11
|
-
const Calendar = ({
|
|
12
|
-
valueFormat,
|
|
13
|
-
quickPick,
|
|
14
|
-
onChange,
|
|
15
|
-
CurrentMonth,
|
|
16
|
-
setCurrentMonth,
|
|
17
|
-
SelectedDate,
|
|
18
|
-
namespace,
|
|
19
|
-
customYears,
|
|
20
|
-
setSelectedDate,
|
|
21
|
-
IsFocused,
|
|
22
|
-
setIsFocused,
|
|
23
|
-
mode,
|
|
24
|
-
RangeSelection,
|
|
25
|
-
setRangeSelection,
|
|
26
|
-
pickerType,
|
|
27
|
-
disabledDatesRange,
|
|
28
|
-
disabledDatesTill,
|
|
29
|
-
disabledDatesFrom,
|
|
30
|
-
CalendarRef,
|
|
31
|
-
defaultValue,
|
|
32
|
-
selectedStyle,
|
|
33
|
-
endDateStyle,
|
|
34
|
-
startDateStyle,
|
|
35
|
-
inRangeStyle,
|
|
36
|
-
otherMonthStyle,
|
|
37
|
-
todayStyle,
|
|
38
|
-
weekDayStyle,
|
|
39
|
-
quickPickStyle,
|
|
40
|
-
monthStyle
|
|
41
|
-
}) => {
|
|
42
|
-
const daysOfWeek = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
|
43
|
-
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
44
|
-
dayjs().year();
|
|
45
|
-
const [PickedMonth, setPickedMonth] = useState("");
|
|
46
|
-
const QuickPicker = useRef([]);
|
|
47
|
-
const [ShowMonths, setShowMonths] = useState(false);
|
|
48
|
-
const getMonthMatrix = (month) => {
|
|
49
|
-
if (customYears?.length && !customYears.includes(month.year().toString())) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
const startDay = (month.startOf("month").day() + 6) % 7;
|
|
53
|
-
const endDay = month.endOf("month").date();
|
|
54
|
-
const prevMonthEnd = month.subtract(1, "month").endOf("month").date();
|
|
55
|
-
const matrix = [];
|
|
56
|
-
let week = [];
|
|
57
|
-
let day = 1;
|
|
58
|
-
for (let i = 0; i < startDay; i++) {
|
|
59
|
-
week.push({
|
|
60
|
-
date: month.subtract(1, "month").date(prevMonthEnd - startDay + i + 1),
|
|
61
|
-
currentMonth: false
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
while (day <= endDay) {
|
|
65
|
-
week.push({ date: month.date(day++), currentMonth: true });
|
|
66
|
-
if (week.length === 7) {
|
|
67
|
-
matrix.push(week);
|
|
68
|
-
week = [];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
let nextMonthDay = 1;
|
|
72
|
-
while (matrix.length < 5) {
|
|
73
|
-
if (week.length === 7) {
|
|
74
|
-
matrix.push(week);
|
|
75
|
-
week = [];
|
|
76
|
-
}
|
|
77
|
-
week.push({
|
|
78
|
-
date: month.add(1, "month").date(nextMonthDay++),
|
|
79
|
-
currentMonth: false
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
if (week.length) {
|
|
83
|
-
while (week.length < 7) {
|
|
84
|
-
week.push({
|
|
85
|
-
date: month.add(1, "month").date(nextMonthDay++),
|
|
86
|
-
currentMonth: false
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
matrix.push(week);
|
|
90
|
-
}
|
|
91
|
-
return matrix;
|
|
92
|
-
};
|
|
93
|
-
const currentMonthMatrix = getMonthMatrix(CurrentMonth);
|
|
94
|
-
const nextMonthMatrix = pickerType === "dual" ? getMonthMatrix(CurrentMonth.add(1, "month")) : null;
|
|
95
|
-
const getQuickPickers = () => {
|
|
96
|
-
let array = [];
|
|
97
|
-
if (quickPick && Array.isArray(quickPick) && quickPick.length > 0) {
|
|
98
|
-
quickPick.forEach((item) => {
|
|
99
|
-
switch (item) {
|
|
100
|
-
case "today":
|
|
101
|
-
QuickPicker.current.push({ name: "Today", key: "Today" });
|
|
102
|
-
break;
|
|
103
|
-
case "yesterday":
|
|
104
|
-
QuickPicker.current.push({ name: "Yesterday", key: "Yesterday" });
|
|
105
|
-
break;
|
|
106
|
-
case "thisweek":
|
|
107
|
-
QuickPicker.current.push({ name: "This week", key: "Thisweek" });
|
|
108
|
-
break;
|
|
109
|
-
case "lastweek":
|
|
110
|
-
QuickPicker.current.push({ name: "Last week", key: "Lastweek" });
|
|
111
|
-
break;
|
|
112
|
-
case "thismonth":
|
|
113
|
-
QuickPicker.current.push({ name: "This month", key: "Thismonth" });
|
|
114
|
-
break;
|
|
115
|
-
case "lastmonth":
|
|
116
|
-
QuickPicker.current.push({ name: "Last month", key: "Lastmonth" });
|
|
117
|
-
break;
|
|
118
|
-
case "thisyear":
|
|
119
|
-
QuickPicker.current.push({ name: "This year", key: "Thisyear" });
|
|
120
|
-
break;
|
|
121
|
-
case "lastyear":
|
|
122
|
-
QuickPicker.current.push({ name: "Last year", key: "Lastyear" });
|
|
123
|
-
break;
|
|
124
|
-
case "alltime":
|
|
125
|
-
QuickPicker.current.push({ name: "All time", key: "Alltime" });
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
QuickPicker.current = _filterUnique(QuickPicker.current, "key");
|
|
131
|
-
array = QuickPicker.current;
|
|
132
|
-
return array;
|
|
133
|
-
};
|
|
134
|
-
const handleQuickPick = (item) => {
|
|
135
|
-
let obj = { start: "", end: "" };
|
|
136
|
-
setSelectedDate(null);
|
|
137
|
-
switch (item.key?.toLowerCase()) {
|
|
138
|
-
case "today":
|
|
139
|
-
setRangeSelection({
|
|
140
|
-
start: dayjs(),
|
|
141
|
-
end: dayjs()
|
|
142
|
-
});
|
|
143
|
-
obj.start = dayjs();
|
|
144
|
-
break;
|
|
145
|
-
case "yesterday":
|
|
146
|
-
setSelectedDate(dayjs().subtract(1, "day"));
|
|
147
|
-
setRangeSelection({
|
|
148
|
-
start: dayjs().subtract(1, "day"),
|
|
149
|
-
end: dayjs().subtract(1, "day")
|
|
150
|
-
});
|
|
151
|
-
obj.start = dayjs().subtract(1, "day");
|
|
152
|
-
break;
|
|
153
|
-
case "thisweek":
|
|
154
|
-
setRangeSelection({
|
|
155
|
-
start: dayjs().startOf("week"),
|
|
156
|
-
end: dayjs().endOf("week")
|
|
157
|
-
});
|
|
158
|
-
obj.start = dayjs().startOf("week");
|
|
159
|
-
obj.end = dayjs().endOf("week");
|
|
160
|
-
break;
|
|
161
|
-
case "lastweek":
|
|
162
|
-
setRangeSelection({
|
|
163
|
-
start: dayjs().subtract(1, "week").startOf("week"),
|
|
164
|
-
end: dayjs().subtract(1, "week").endOf("week")
|
|
165
|
-
});
|
|
166
|
-
obj.start = dayjs().subtract(1, "week").startOf("week");
|
|
167
|
-
obj.end = dayjs().subtract(1, "week").endOf("week");
|
|
168
|
-
break;
|
|
169
|
-
case "thismonth":
|
|
170
|
-
setRangeSelection({
|
|
171
|
-
start: dayjs().startOf("month"),
|
|
172
|
-
end: dayjs().endOf("month")
|
|
173
|
-
});
|
|
174
|
-
obj.start = dayjs().startOf("month");
|
|
175
|
-
obj.end = dayjs().endOf("month");
|
|
176
|
-
break;
|
|
177
|
-
case "lastmonth":
|
|
178
|
-
setRangeSelection({
|
|
179
|
-
start: dayjs().subtract(1, "month").startOf("month"),
|
|
180
|
-
end: dayjs().subtract(1, "month").endOf("month")
|
|
181
|
-
});
|
|
182
|
-
obj.start = dayjs().subtract(1, "month").startOf("month");
|
|
183
|
-
obj.end = dayjs().subtract(1, "month").endOf("month");
|
|
184
|
-
break;
|
|
185
|
-
case "thisyear":
|
|
186
|
-
setRangeSelection({
|
|
187
|
-
start: dayjs().startOf("year"),
|
|
188
|
-
end: dayjs().endOf("year")
|
|
189
|
-
});
|
|
190
|
-
obj.start = dayjs().startOf("year");
|
|
191
|
-
obj.end = dayjs().endOf("year");
|
|
192
|
-
break;
|
|
193
|
-
case "lastyear":
|
|
194
|
-
setRangeSelection({
|
|
195
|
-
start: dayjs().subtract(1, "year").startOf("year"),
|
|
196
|
-
end: dayjs().subtract(1, "year").endOf("year")
|
|
197
|
-
});
|
|
198
|
-
obj.start = dayjs().subtract(1, "year").startOf("year");
|
|
199
|
-
obj.end = dayjs().subtract(1, "year").endOf("year");
|
|
200
|
-
break;
|
|
201
|
-
case "alltime":
|
|
202
|
-
setRangeSelection({
|
|
203
|
-
start: "",
|
|
204
|
-
end: ""
|
|
205
|
-
});
|
|
206
|
-
obj.start = "";
|
|
207
|
-
obj.end = "";
|
|
208
|
-
break;
|
|
209
|
-
default:
|
|
210
|
-
console.warn("Unsupported quick pick option:", item);
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
if (onChange && typeof onChange === "function") {
|
|
214
|
-
const range = {
|
|
215
|
-
start: obj.start ? obj.start : "",
|
|
216
|
-
end: obj.end ? obj.end : ""
|
|
217
|
-
};
|
|
218
|
-
setIsFocused(false);
|
|
219
|
-
onChange(range.end === "" ? range.start : range);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
const HandleChooseMonth = () => {
|
|
223
|
-
return;
|
|
224
|
-
};
|
|
225
|
-
const handleDayClick = (day, isCurrentMonth, withDefault = false) => {
|
|
226
|
-
if (!isCurrentMonth) {
|
|
227
|
-
setCurrentMonth(day.startOf("month"));
|
|
228
|
-
}
|
|
229
|
-
if (mode === "range") {
|
|
230
|
-
setRangeSelection((prev) => {
|
|
231
|
-
if (!prev.start || prev.start && prev.end) {
|
|
232
|
-
if (onChange && typeof onChange === "function") {
|
|
233
|
-
onChange({
|
|
234
|
-
start: day ?? "",
|
|
235
|
-
end: ""
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
return { start: day ?? "", end: "" };
|
|
239
|
-
} else if (prev.start && !prev.end) {
|
|
240
|
-
if (day.isBefore(prev.start, "day")) {
|
|
241
|
-
if (onChange && typeof onChange === "function") {
|
|
242
|
-
onChange({
|
|
243
|
-
start: day ?? "",
|
|
244
|
-
end: prev?.start ?? ""
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
return { start: day ?? "", end: prev?.start ?? "" };
|
|
248
|
-
} else {
|
|
249
|
-
onChange({
|
|
250
|
-
...prev,
|
|
251
|
-
end: day ?? ""
|
|
252
|
-
});
|
|
253
|
-
return { ...prev, end: day ?? "" };
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
return prev;
|
|
257
|
-
});
|
|
258
|
-
} else {
|
|
259
|
-
setRangeSelection({ start: null, end: null });
|
|
260
|
-
setSelectedDate(day);
|
|
261
|
-
if (!withDefault) {
|
|
262
|
-
setIsFocused(false);
|
|
263
|
-
if (onChange && typeof onChange === "function") {
|
|
264
|
-
onChange(day.format(valueFormat));
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
const goToNextMonth = () => {
|
|
270
|
-
setCurrentMonth(CurrentMonth.add(1, "month"));
|
|
271
|
-
};
|
|
272
|
-
const goToPreviousMonth = () => {
|
|
273
|
-
setCurrentMonth(CurrentMonth.subtract(1, "month"));
|
|
274
|
-
};
|
|
275
|
-
const goToNextYear = () => {
|
|
276
|
-
setCurrentMonth(CurrentMonth.add(1, "year"));
|
|
277
|
-
};
|
|
278
|
-
const goToPreviousYear = () => {
|
|
279
|
-
setCurrentMonth(CurrentMonth.subtract(1, "year"));
|
|
280
|
-
};
|
|
281
|
-
useEffect(() => {
|
|
282
|
-
if (defaultValue?.state) {
|
|
283
|
-
if (Array.isArray(defaultValue?.value)) {
|
|
284
|
-
setRangeSelection({ start: dayjs(defaultValue?.value[0], valueFormat), end: dayjs(defaultValue?.value[1], valueFormat) });
|
|
285
|
-
} else {
|
|
286
|
-
handleDayClick(dayjs(defaultValue.value), false, true);
|
|
287
|
-
}
|
|
288
|
-
defaultValue.state = false;
|
|
289
|
-
}
|
|
290
|
-
}, []);
|
|
291
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
292
|
-
"div",
|
|
293
|
-
{
|
|
294
|
-
ref: CalendarRef,
|
|
295
|
-
className: `${namespace === "namespaceHr" ? style.namespaceHr : ""} ${style.datePicker} ${IsFocused ? style.focused : ""} ${pickerType === "dual" ? quickPick && Array.isArray(quickPick) && quickPick.length > 0 ? style.dualCalendarWithQuick : style.dualCalendar : ""} `,
|
|
296
|
-
onClick: (e) => e.stopPropagation(),
|
|
297
|
-
style: pickerType === "dual" && quickPick && Array.isArray(quickPick) && quickPick.length > 0 ? { width: "848px" } : {},
|
|
298
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.div, children: [
|
|
299
|
-
pickerType === "dual" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "100%", display: "flex", justifyContent: "space-between" }, children: [
|
|
300
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "50%", display: "flex", alignItems: "center", justifyContent: "flex-start", gap: "80px" }, children: [
|
|
301
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.left, children: [
|
|
302
|
-
(!customYears || customYears.length > 1) && (!customYears || CurrentMonth.year() > Math.min(...customYears.map(Number))) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.doubleIcon, onClick: goToPreviousYear, children: [
|
|
303
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLeft, {}),
|
|
304
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLeft, {})
|
|
305
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } }),
|
|
306
|
-
!customYears || customYears && CurrentMonth.format("MMMM YYYY") !== `January ${Math.min(...customYears.map(Number))}` ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.singleIcon, onClick: goToPreviousMonth, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconLeft, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } })
|
|
307
|
-
] }),
|
|
308
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: monthStyle ?? {}, children: customYears && customYears.length === 1 ? CurrentMonth.format("MMMM") : CurrentMonth.format("MMMM YYYY") })
|
|
309
|
-
] }),
|
|
310
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "50%", display: "flex", alignItems: "center", justifyContent: "flex-end", gap: "80px" }, children: [
|
|
311
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: monthStyle ?? {}, children: customYears && customYears.length === 1 ? CurrentMonth.add(1, "month").format("MMMM") : CurrentMonth.add(1, "month").format("MMMM YYYY") }),
|
|
312
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.right, children: [
|
|
313
|
-
!customYears || customYears && CurrentMonth.format("MMMM YYYY") !== `December ${Math.max(...customYears.map(Number))}` ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.singleIcon, onClick: goToNextMonth, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconRight, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } }),
|
|
314
|
-
(!customYears || customYears.length > 1) && (!customYears || CurrentMonth.year() < Math.max(...customYears.map(Number))) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.doubleIcon, onClick: goToNextYear, children: [
|
|
315
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconRight, {}),
|
|
316
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconRight, {})
|
|
317
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } })
|
|
318
|
-
] })
|
|
319
|
-
] })
|
|
320
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.datePickerHeader, children: [
|
|
321
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
322
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.left, children: [
|
|
323
|
-
(!customYears || customYears.length > 1) && (!customYears || CurrentMonth.year() > Math.min(...customYears.map(Number))) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.doubleIcon, onClick: goToPreviousYear, children: [
|
|
324
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLeft, {}),
|
|
325
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLeft, {})
|
|
326
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } }),
|
|
327
|
-
!customYears || customYears && CurrentMonth.format("MMMM YYYY") !== `January ${Math.min(...customYears.map(Number))}` ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.singleIcon, onClick: goToPreviousMonth, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconLeft, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } })
|
|
328
|
-
] }),
|
|
329
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.currentDateHeader, style: monthStyle ?? {}, onClick: HandleChooseMonth, children: customYears && customYears.length === 1 ? CurrentMonth.format("MMMM") : CurrentMonth.format("MMMM YYYY") }),
|
|
330
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.right, children: [
|
|
331
|
-
!customYears || customYears && CurrentMonth.format("MMMM YYYY") !== `December ${Math.max(...customYears.map(Number))}` ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.singleIcon, onClick: goToNextMonth, children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconRight, {}) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { width: "20px", height: "20px" } }),
|
|
332
|
-
(!customYears || customYears.length > 1) && (!customYears || CurrentMonth.year() < Math.max(...customYears.map(Number))) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.doubleIcon, onClick: goToNextYear, children: [
|
|
333
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconRight, {}),
|
|
334
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(IconRight, {})
|
|
335
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.doubleIcon })
|
|
336
|
-
] })
|
|
337
|
-
] }),
|
|
338
|
-
pickerType === "single" && quickPick && Array.isArray(quickPick) && quickPick.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: style.quickPick, children: getQuickPickers().slice(0, 3).map((item) => {
|
|
339
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { style: quickPickStyle ?? {}, onClick: () => handleQuickPick(item), children: item.name }, item.key);
|
|
340
|
-
}) })
|
|
341
|
-
] }),
|
|
342
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: style.calendarWrapper, children: [
|
|
343
|
-
ShowMonths ? /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: style.monthsWrapper, children: months.map((month) => /* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: `${style.month} ${PickedMonth === month ? style.pickedMonth : ""}`, onClick: () => setPickedMonth(month), children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.monthName, children: month }) })) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { children: [
|
|
344
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: daysOfWeek.map((day) => /* @__PURE__ */ jsxRuntimeExports.jsx("th", { style: weekDayStyle ?? {}, children: day }, day)) }) }),
|
|
345
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("tbody", { children: [
|
|
346
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("tr", { className: style.spacerRow, children: /* @__PURE__ */ jsxRuntimeExports.jsx("td", {}) }),
|
|
347
|
-
currentMonthMatrix.map((week, index) => /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: week.map(({ date, currentMonth }, idx) => {
|
|
348
|
-
const isInRange = RangeSelection.start && RangeSelection.end && date.isAfter(RangeSelection.start, "day") && date.isBefore(RangeSelection.end, "day");
|
|
349
|
-
const isStartDate = RangeSelection.start && date.isSame(RangeSelection.start, "day");
|
|
350
|
-
const isEndDate = RangeSelection.end && date.isSame(RangeSelection.end, "day");
|
|
351
|
-
const selected = mode === "single" && SelectedDate && date.isSame(SelectedDate, "day");
|
|
352
|
-
const isDisabledTill = disabledDatesTill && date.isBefore(dayjs(disabledDatesTill), "day");
|
|
353
|
-
const isDisabledFrom = disabledDatesFrom && date.isAfter(dayjs(disabledDatesFrom), "day");
|
|
354
|
-
let isInDisabledRange = false;
|
|
355
|
-
if (disabledDatesRange?.length === 2) {
|
|
356
|
-
const [start, end] = disabledDatesRange.map((d) => dayjs(d));
|
|
357
|
-
isInDisabledRange = date.isAfter(start.subtract(1, "day")) && date.isBefore(end.add(1, "day"));
|
|
358
|
-
}
|
|
359
|
-
const isDisabled = isDisabledFrom || isDisabledTill || isInDisabledRange;
|
|
360
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
361
|
-
"td",
|
|
362
|
-
{
|
|
363
|
-
style: {
|
|
364
|
-
...currentMonth ? {} : otherMonthStyle,
|
|
365
|
-
...date.isSame(dayjs(), "day") ? todayStyle : {},
|
|
366
|
-
...isInRange ? inRangeStyle : {},
|
|
367
|
-
...isStartDate ? startDateStyle : {},
|
|
368
|
-
...isEndDate ? endDateStyle : {},
|
|
369
|
-
...selected ? selectedStyle : {}
|
|
370
|
-
},
|
|
371
|
-
className: `${style.day}
|
|
372
|
-
${currentMonth ? "" : style.otherMonth}
|
|
373
|
-
${!currentMonth ? "" : date.isSame(dayjs(), "day") ? style.today : ""}
|
|
374
|
-
${!currentMonth ? "" : isInRange ? style.inRange : ""}
|
|
375
|
-
${!currentMonth ? "" : isStartDate ? style.startDate : ""}
|
|
376
|
-
${!currentMonth ? "" : isEndDate ? style.endDate : ""}
|
|
377
|
-
${!currentMonth && !isInRange && !isEndDate ? "" : selected ? style.selected : ""}
|
|
378
|
-
${isDisabled ? style.disabled : ""}`,
|
|
379
|
-
onClick: () => handleDayClick(date, currentMonth),
|
|
380
|
-
children: date.date()
|
|
381
|
-
},
|
|
382
|
-
idx
|
|
383
|
-
);
|
|
384
|
-
}) }, index))
|
|
385
|
-
] })
|
|
386
|
-
] }),
|
|
387
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.buttonWrapper, children: /* @__PURE__ */ jsxRuntimeExports.jsx(MainButton, { label: "Current date", onClick: () => handleDayClick(dayjs(), true) }) }),
|
|
388
|
-
pickerType === "dual" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: style.border }),
|
|
389
|
-
pickerType === "dual" && /* @__PURE__ */ jsxRuntimeExports.jsxs("table", { children: [
|
|
390
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("thead", { children: /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: daysOfWeek.map((day) => /* @__PURE__ */ jsxRuntimeExports.jsx("th", { style: weekDayStyle ?? {}, children: day }, day)) }) }),
|
|
391
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("tbody", { children: nextMonthMatrix?.map((week, index) => /* @__PURE__ */ jsxRuntimeExports.jsx("tr", { children: week.map(({ date, currentMonth }, idx) => {
|
|
392
|
-
const isInRange = RangeSelection.start && RangeSelection.end && date.isAfter(RangeSelection.start, "day") && date.isBefore(RangeSelection.end, "day");
|
|
393
|
-
const isStartDate = RangeSelection.start && date.isSame(RangeSelection.start, "day");
|
|
394
|
-
const isEndDate = RangeSelection.end && date.isSame(RangeSelection.end, "day");
|
|
395
|
-
const selected = mode === "single" && SelectedDate && date.isSame(SelectedDate, "day");
|
|
396
|
-
const isDisabledTill = disabledDatesTill && date.isBefore(dayjs(disabledDatesTill), "day");
|
|
397
|
-
const isDisabledFrom = disabledDatesFrom && date.isAfter(dayjs(disabledDatesFrom), "day");
|
|
398
|
-
let isInDisabledRange = false;
|
|
399
|
-
if (disabledDatesRange?.length === 2) {
|
|
400
|
-
const [start, end] = disabledDatesRange.map((d) => dayjs(d));
|
|
401
|
-
isInDisabledRange = date.isAfter(start.subtract(1, "day")) && date.isBefore(end.add(1, "day"));
|
|
402
|
-
}
|
|
403
|
-
const isDisabled = isDisabledFrom || isDisabledTill || isInDisabledRange;
|
|
404
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
405
|
-
"td",
|
|
406
|
-
{
|
|
407
|
-
style: {
|
|
408
|
-
...currentMonth ? {} : otherMonthStyle,
|
|
409
|
-
...date.isSame(dayjs(), "day") ? todayStyle : {},
|
|
410
|
-
...isInRange ? inRangeStyle : {},
|
|
411
|
-
...isStartDate ? startDateStyle : {},
|
|
412
|
-
...isEndDate ? endDateStyle : {},
|
|
413
|
-
...selected ? selectedStyle : {}
|
|
414
|
-
},
|
|
415
|
-
className: `${style.day}
|
|
416
|
-
${currentMonth ? "" : style.otherMonth}
|
|
417
|
-
${!currentMonth ? "" : date.isSame(dayjs(), "day") ? style.today : ""}
|
|
418
|
-
${!currentMonth ? "" : isInRange ? style.inRange : ""}
|
|
419
|
-
${!currentMonth ? "" : isStartDate ? style.startDate : ""}
|
|
420
|
-
${!currentMonth ? "" : isEndDate ? style.endDate : ""}
|
|
421
|
-
${!currentMonth && !isInRange && !isEndDate ? "" : selected ? style.selected : ""}
|
|
422
|
-
${isDisabled ? style.disabled : ""}`,
|
|
423
|
-
onClick: () => handleDayClick(date, currentMonth),
|
|
424
|
-
children: date.date()
|
|
425
|
-
},
|
|
426
|
-
idx
|
|
427
|
-
);
|
|
428
|
-
}) }, index)) })
|
|
429
|
-
] })
|
|
430
|
-
] })
|
|
431
|
-
] })
|
|
432
|
-
}
|
|
433
|
-
);
|
|
434
|
-
};
|
|
435
|
-
export {
|
|
436
|
-
Calendar as default
|
|
437
|
-
};
|