@jenesei-software/jenesei-kit-react 1.3.23 → 1.3.25
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/build/area-preview.cjs.js +1 -1
- package/build/area-preview.es.js +1 -1
- package/build/area-skeleton.cjs.js +1 -1
- package/build/area-skeleton.es.js +1 -1
- package/build/build-info.txt +3 -3
- package/build/{component-JIJwPwrc.cjs → component-7NBd7NIb.cjs} +2 -2
- package/build/{component-JIJwPwrc.cjs.map → component-7NBd7NIb.cjs.map} +1 -1
- package/build/{component-JQMDepCj.js → component-BCV2luzE.js} +2 -2
- package/build/{component-JQMDepCj.js.map → component-BCV2luzE.js.map} +1 -1
- package/build/{component-DLEbIbn9.js → component-BI5rC-2m.js} +3 -3
- package/build/{component-DLEbIbn9.js.map → component-BI5rC-2m.js.map} +1 -1
- package/build/component-BbZXNg5P.cjs +2 -0
- package/build/component-BbZXNg5P.cjs.map +1 -0
- package/build/{component-BF_RC9Ej.cjs → component-BzxsZZwo.cjs} +2 -2
- package/build/{component-BF_RC9Ej.cjs.map → component-BzxsZZwo.cjs.map} +1 -1
- package/build/{component-BnJWTOR7.js → component-C0wHqqsE.js} +4 -4
- package/build/{component-BnJWTOR7.js.map → component-C0wHqqsE.js.map} +1 -1
- package/build/{component-BXCFqCtK.cjs → component-CC8gkK9W.cjs} +2 -2
- package/build/{component-BXCFqCtK.cjs.map → component-CC8gkK9W.cjs.map} +1 -1
- package/build/{component-C7Nffvkz.js → component-CGXjLqiU.js} +2 -2
- package/build/{component-C7Nffvkz.js.map → component-CGXjLqiU.js.map} +1 -1
- package/build/{component-D4hkx75Z.js → component-CL9kCwRv.js} +2 -2
- package/build/{component-D4hkx75Z.js.map → component-CL9kCwRv.js.map} +1 -1
- package/build/{component-DHj3MVyO.js → component-CUg8vGc0.js} +6 -7
- package/build/component-CUg8vGc0.js.map +1 -0
- package/build/{component-CaJK3Oq8.js → component-ChwxoVt7.js} +2 -2
- package/build/{component-CaJK3Oq8.js.map → component-ChwxoVt7.js.map} +1 -1
- package/build/{component-C0Cy_U1j.js → component-CsuyjLrN.js} +3 -3
- package/build/{component-C0Cy_U1j.js.map → component-CsuyjLrN.js.map} +1 -1
- package/build/{component-BXhibaBj.cjs → component-DC3s_be7.cjs} +2 -2
- package/build/{component-BXhibaBj.cjs.map → component-DC3s_be7.cjs.map} +1 -1
- package/build/component-DTotEm4D.cjs +2 -0
- package/build/component-DTotEm4D.cjs.map +1 -0
- package/build/{component-CDa4aHfO.cjs → component-DXRFP4Ym.cjs} +2 -2
- package/build/{component-CDa4aHfO.cjs.map → component-DXRFP4Ym.cjs.map} +1 -1
- package/build/{component-GiB9SJbH.cjs → component-DYsviH75.cjs} +2 -2
- package/build/{component-GiB9SJbH.cjs.map → component-DYsviH75.cjs.map} +1 -1
- package/build/component-DgZATMAS.cjs +2 -0
- package/build/component-DgZATMAS.cjs.map +1 -0
- package/build/{component-ySx7l0Xg.cjs → component-Ds4G9JaH.cjs} +2 -2
- package/build/{component-ySx7l0Xg.cjs.map → component-Ds4G9JaH.cjs.map} +1 -1
- package/build/{component-31qgF6V7.js → component-DvkJKhCA.js} +13 -15
- package/build/component-DvkJKhCA.js.map +1 -0
- package/build/{component-Bv6UuRlj.cjs → component-Ei1bxdq2.cjs} +2 -2
- package/build/{component-Bv6UuRlj.cjs.map → component-Ei1bxdq2.cjs.map} +1 -1
- package/build/{component-DwFwB6Zz.js → component-P6uOD564.js} +2 -2
- package/build/{component-DwFwB6Zz.js.map → component-P6uOD564.js.map} +1 -1
- package/build/component-accordion.cjs.js +1 -1
- package/build/component-accordion.es.js +2 -2
- package/build/component-button-group.cjs.js +1 -1
- package/build/component-button-group.es.js +2 -2
- package/build/component-button.cjs.js +1 -1
- package/build/component-button.es.js +1 -1
- package/build/component-checkbox-group.cjs.js +1 -1
- package/build/component-checkbox-group.es.js +2 -2
- package/build/component-checkbox.cjs.js +1 -1
- package/build/component-checkbox.es.js +2 -2
- package/build/component-date-picker.cjs.js +1 -1
- package/build/component-date-picker.es.js +2 -2
- package/build/component-icon.cjs.js +1 -1
- package/build/component-icon.es.js +1 -1
- package/build/component-image-button.cjs.js +1 -1
- package/build/component-image-button.es.js +1 -1
- package/build/component-image-select.cjs.js +1 -1
- package/build/component-image-select.es.js +2 -2
- package/build/component-image-slider.cjs.js +1 -1
- package/build/component-image-slider.es.js +2 -2
- package/build/component-image.cjs.js +1 -1
- package/build/component-image.es.js +2 -2
- package/build/component-input-otp.cjs.js +1 -1
- package/build/component-input-otp.es.js +2 -2
- package/build/component-input.cjs.js +1 -1
- package/build/component-input.es.js +2 -2
- package/build/component-map.cjs.js +1 -1
- package/build/component-map.es.js +2 -2
- package/build/component-pagination.cjs.js +1 -1
- package/build/component-pagination.es.js +1 -1
- package/build/component-range.cjs.js +1 -1
- package/build/component-range.es.js +2 -2
- package/build/component-select.cjs.js +1 -1
- package/build/component-select.es.js +1 -1
- package/build/component-textarea.cjs.js +1 -1
- package/build/component-textarea.es.js +1 -1
- package/build/component-toggle.cjs.js +1 -1
- package/build/component-toggle.es.js +2 -2
- package/build/component-tooltip.cjs.js +1 -1
- package/build/component-tooltip.es.js +1 -1
- package/build/component-typography.cjs.js +1 -1
- package/build/component-typography.es.js +1 -1
- package/build/{component-RXfJR8yQ.js → component-zim9WtKE.js} +9 -10
- package/build/component-zim9WtKE.js.map +1 -0
- package/build/{component.components-DzoKT5j9.cjs → component.components-DUGaqWm1.cjs} +2 -2
- package/build/{component.components-DzoKT5j9.cjs.map → component.components-DUGaqWm1.cjs.map} +1 -1
- package/build/{component.components-DKDMKKNb.js → component.components-DgG3v6IP.js} +2 -2
- package/build/{component.components-DKDMKKNb.js.map → component.components-DgG3v6IP.js.map} +1 -1
- package/build/{component.constants-BMz7bhlw.js → component.constants-Bg4nPldh.js} +2 -2
- package/build/{component.constants-BMz7bhlw.js.map → component.constants-Bg4nPldh.js.map} +1 -1
- package/build/{component.constants-Bgm_xB87.js → component.constants-C_datTCs.js} +3 -3
- package/build/{component.constants-Bgm_xB87.js.map → component.constants-C_datTCs.js.map} +1 -1
- package/build/{component.constants-C0oGZ1iR.cjs → component.constants-DuIk1IUA.cjs} +2 -2
- package/build/{component.constants-C0oGZ1iR.cjs.map → component.constants-DuIk1IUA.cjs.map} +1 -1
- package/build/{component.constants-DZyqQi6L.cjs → component.constants-VFLYS55V.cjs} +2 -2
- package/build/{component.constants-DZyqQi6L.cjs.map → component.constants-VFLYS55V.cjs.map} +1 -1
- package/build/{component.types-D_tW7ArD.js → component.types-BfuKs1g9.js} +241 -274
- package/build/component.types-BfuKs1g9.js.map +1 -0
- package/build/component.types-D55dIYXx.cjs +2 -0
- package/build/component.types-D55dIYXx.cjs.map +1 -0
- package/build/consts.cjs.js +1 -1
- package/build/consts.es.js +1 -1
- package/build/context-app.cjs.js +1 -1
- package/build/context-app.es.js +2 -2
- package/build/context-sonner.cjs.js +1 -1
- package/build/context-sonner.es.js +2 -2
- package/build/{context.constants-wfD246Ww.cjs → context.constants-B9vCuOqK.cjs} +4 -4
- package/build/{context.constants-wfD246Ww.cjs.map → context.constants-B9vCuOqK.cjs.map} +1 -1
- package/build/{context.constants-AVloP24q.js → context.constants-rTgzRM3c.js} +12 -15
- package/build/{context.constants-AVloP24q.js.map → context.constants-rTgzRM3c.js.map} +1 -1
- package/build/{context.hooks-CXSsHfiI.cjs → context.hooks-6lCyn9Dp.cjs} +2 -2
- package/build/{context.hooks-CXSsHfiI.cjs.map → context.hooks-6lCyn9Dp.cjs.map} +1 -1
- package/build/{context.hooks-BsMIDkb3.js → context.hooks-BHFgUgBF.js} +2 -2
- package/build/{context.hooks-BsMIDkb3.js.map → context.hooks-BHFgUgBF.js.map} +1 -1
- package/build/{context.hooks-L-OO9FIg.cjs → context.hooks-C8qSZOb4.cjs} +2 -2
- package/build/{context.hooks-L-OO9FIg.cjs.map → context.hooks-C8qSZOb4.cjs.map} +1 -1
- package/build/{context.hooks-CQXyg8Md.js → context.hooks-D4-JZ2rN.js} +2 -2
- package/build/{context.hooks-CQXyg8Md.js.map → context.hooks-D4-JZ2rN.js.map} +1 -1
- package/build/index.cjs.js +1 -1
- package/build/index.es.js +18 -18
- package/build/style-error.cjs.js +1 -1
- package/build/style-error.es.js +1 -1
- package/build/style-theme.cjs.js +1 -1
- package/build/style-theme.es.js +1 -1
- package/build/{use-fcNoM5UL.cjs → use-C3yxmiPP.cjs} +2 -2
- package/build/{use-fcNoM5UL.cjs.map → use-C3yxmiPP.cjs.map} +1 -1
- package/build/{use-B4ELG6B3.js → use-DP84XchN.js} +3 -3
- package/build/{use-B4ELG6B3.js.map → use-DP84XchN.js.map} +1 -1
- package/package.json +1 -1
- package/build/component-1kuvOkUa.cjs +0 -2
- package/build/component-1kuvOkUa.cjs.map +0 -1
- package/build/component-31qgF6V7.js.map +0 -1
- package/build/component-CYmkHAmE.cjs +0 -2
- package/build/component-CYmkHAmE.cjs.map +0 -1
- package/build/component-DHj3MVyO.js.map +0 -1
- package/build/component-RXfJR8yQ.js.map +0 -1
- package/build/component-jH7YXK4X.cjs +0 -2
- package/build/component-jH7YXK4X.cjs.map +0 -1
- package/build/component.types-D_tW7ArD.js.map +0 -1
- package/build/component.types-ZmH2V3qe.cjs +0 -2
- package/build/component.types-ZmH2V3qe.cjs.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { j as jsxRuntimeExports } from "./jsx-runtime-BrDlu8eK.js";
|
|
2
|
-
import { bt as KEY_SIZE_DATA, bC as usePopover, D as DateWrapper, z as DateInputWrapper, aR as Typography, x as DateInput, F as DateInputButton, bD as Popover, s as DateDropdownList, B as Button, ao as SelectMonth, aq as SelectYear, t as DateDropdownDays, w as DateDropdownDayOfWeek, v as DateDropdownDay, bp as ErrorMessage } from "./context.constants-
|
|
2
|
+
import { bt as KEY_SIZE_DATA, bC as usePopover, D as DateWrapper, z as DateInputWrapper, aR as Typography, x as DateInput, F as DateInputButton, bD as Popover, s as DateDropdownList, B as Button, ao as SelectMonth, aq as SelectYear, t as DateDropdownDays, w as DateDropdownDayOfWeek, v as DateDropdownDay, bp as ErrorMessage } from "./context.constants-rTgzRM3c.js";
|
|
3
3
|
import "./component.styles-B0L4jbOO.js";
|
|
4
4
|
import { R as Ripple } from "./component-DHM9pbab.js";
|
|
5
5
|
import { b as Stack } from "./component-DEZX8aBs.js";
|
|
6
6
|
import moment from "moment";
|
|
7
|
-
import { useState,
|
|
7
|
+
import { useState, useRef, useEffect, useMemo, useCallback, Fragment } from "react";
|
|
8
8
|
import { useTheme } from "styled-components";
|
|
9
9
|
function countSevens(number) {
|
|
10
10
|
const divisor = 7;
|
|
@@ -19,18 +19,22 @@ const DatePicker = (props) => {
|
|
|
19
19
|
const [valueMoment, setValueMoment] = useState(null);
|
|
20
20
|
const [dateDefaultMoment, setDateDefaultMoment] = useState(moment(props.dateDefault).utc());
|
|
21
21
|
const [input, setInput] = useState({
|
|
22
|
-
[DatePickerVariant.DD]:
|
|
23
|
-
[DatePickerVariant.MM]:
|
|
24
|
-
[DatePickerVariant.YYYY]:
|
|
22
|
+
[DatePickerVariant.DD]: "",
|
|
23
|
+
[DatePickerVariant.MM]: "",
|
|
24
|
+
[DatePickerVariant.YYYY]: ""
|
|
25
25
|
});
|
|
26
|
+
const refInputValue = useRef(input);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
refInputValue.current = input;
|
|
29
|
+
}, [input]);
|
|
26
30
|
const isHasInput = useMemo(() => {
|
|
27
|
-
return input[DatePickerVariant.DD] !==
|
|
31
|
+
return input[DatePickerVariant.DD] !== "" || input[DatePickerVariant.MM] !== "" || input[DatePickerVariant.YYYY] !== "";
|
|
28
32
|
}, [input]);
|
|
29
33
|
const onClearInput = useCallback(() => {
|
|
30
34
|
setInput({
|
|
31
|
-
[DatePickerVariant.DD]:
|
|
32
|
-
[DatePickerVariant.MM]:
|
|
33
|
-
[DatePickerVariant.YYYY]:
|
|
35
|
+
[DatePickerVariant.DD]: "",
|
|
36
|
+
[DatePickerVariant.MM]: "",
|
|
37
|
+
[DatePickerVariant.YYYY]: ""
|
|
34
38
|
});
|
|
35
39
|
}, []);
|
|
36
40
|
const [activeSegment, setActiveSegment] = useState(null);
|
|
@@ -59,66 +63,51 @@ const DatePicker = (props) => {
|
|
|
59
63
|
},
|
|
60
64
|
[mode]
|
|
61
65
|
);
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
isLast: mode[mode.length - 1] === DatePickerVariant.DD,
|
|
81
|
-
isFirst: mode[0] === DatePickerVariant.DD,
|
|
82
|
-
onNext: () => setActiveSegment(getNextSegment(DatePickerVariant.DD)),
|
|
83
|
-
onPrev: () => setActiveSegment(getPrevSegment(DatePickerVariant.DD)),
|
|
84
|
-
type: DatePickerVariant.DD,
|
|
85
|
-
value: input.DD,
|
|
86
|
-
setValue: (value) => setInput((prevValue) => ({ ...prevValue, [DatePickerVariant.DD]: value })),
|
|
87
|
-
setActive: () => setActiveSegment(DatePickerVariant.DD),
|
|
88
|
-
placeholder: props.locale.inputs.day
|
|
89
|
-
},
|
|
90
|
-
YYYY: {
|
|
91
|
-
nextSegment: getNextSegment(DatePickerVariant.YYYY),
|
|
92
|
-
preSegment: getPrevSegment(DatePickerVariant.YYYY),
|
|
93
|
-
isLast: mode[mode.length - 1] === DatePickerVariant.YYYY,
|
|
94
|
-
isFirst: mode[0] === DatePickerVariant.YYYY,
|
|
95
|
-
onNext: () => setActiveSegment(getNextSegment(DatePickerVariant.YYYY)),
|
|
96
|
-
onPrev: () => setActiveSegment(getPrevSegment(DatePickerVariant.YYYY)),
|
|
97
|
-
type: DatePickerVariant.YYYY,
|
|
98
|
-
value: input.YYYY,
|
|
99
|
-
setValue: (value) => setInput((prevValue) => ({ ...prevValue, [DatePickerVariant.YYYY]: value })),
|
|
100
|
-
setActive: () => setActiveSegment(DatePickerVariant.YYYY),
|
|
101
|
-
placeholder: props.locale.inputs.year
|
|
66
|
+
const getValidateInput = useCallback(
|
|
67
|
+
(input2, onSuccess, onFailure, onNan) => {
|
|
68
|
+
const dayStr = input2.DD;
|
|
69
|
+
const monthStr = input2.MM;
|
|
70
|
+
const yearStr = input2.YYYY;
|
|
71
|
+
const day = dayStr === "" ? NaN : Number(dayStr);
|
|
72
|
+
const month = monthStr === "" ? NaN : Number(monthStr);
|
|
73
|
+
const year = yearStr === "" ? NaN : Number(yearStr);
|
|
74
|
+
const isHasInput2 = dayStr !== "" || monthStr !== "" || yearStr !== "";
|
|
75
|
+
if (!Number.isNaN(day) && !Number.isNaN(month) && !Number.isNaN(year)) {
|
|
76
|
+
const m = moment.utc(`${day}.${month}.${year}`, "D.M.YYYY", true).startOf("day");
|
|
77
|
+
if (m.isValid()) {
|
|
78
|
+
onSuccess == null ? void 0 : onSuccess(m.valueOf());
|
|
79
|
+
} else {
|
|
80
|
+
onFailure == null ? void 0 : onFailure();
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
onNan == null ? void 0 : onNan(isHasInput2);
|
|
102
84
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
85
|
+
},
|
|
86
|
+
[]
|
|
87
|
+
);
|
|
88
|
+
const dataDate = useMemo(() => {
|
|
89
|
+
const segments = [DatePickerVariant.DD, DatePickerVariant.MM, DatePickerVariant.YYYY];
|
|
90
|
+
const result = Object.fromEntries(
|
|
91
|
+
segments.map((segment) => [
|
|
92
|
+
segment,
|
|
93
|
+
{
|
|
94
|
+
type: segment,
|
|
95
|
+
value: input[segment],
|
|
96
|
+
placeholder: props.locale.inputs[segment === DatePickerVariant.DD ? "day" : segment === DatePickerVariant.MM ? "month" : "year"],
|
|
97
|
+
isFirst: mode[0] === segment,
|
|
98
|
+
isLast: mode[mode.length - 1] === segment,
|
|
99
|
+
segmentNext: getNextSegment(segment),
|
|
100
|
+
segmentPrev: getPrevSegment(segment),
|
|
101
|
+
onNextSegment: () => setActiveSegment(getNextSegment(segment)),
|
|
102
|
+
onPrevSegment: () => setActiveSegment(getPrevSegment(segment)),
|
|
103
|
+
setValue: (value) => setInput((prev) => ({ ...prev, [segment]: value })),
|
|
104
|
+
setActive: () => setActiveSegment(segment)
|
|
105
|
+
}
|
|
106
|
+
])
|
|
107
|
+
);
|
|
108
|
+
const resultSort = mode.map((segment) => result[segment]).filter(Boolean);
|
|
110
109
|
return { sort: resultSort, default: result };
|
|
111
|
-
}, [
|
|
112
|
-
props.locale.inputs.day,
|
|
113
|
-
props.locale.inputs.month,
|
|
114
|
-
props.locale.inputs.year,
|
|
115
|
-
getNextSegment,
|
|
116
|
-
getPrevSegment,
|
|
117
|
-
mode,
|
|
118
|
-
input.DD,
|
|
119
|
-
input.MM,
|
|
120
|
-
input.YYYY
|
|
121
|
-
]);
|
|
110
|
+
}, [props, getNextSegment, getPrevSegment, mode, input]);
|
|
122
111
|
const daysInWeek = useMemo(() => {
|
|
123
112
|
const weekOrder = ["mo", "tu", "we", "th", "fr", "sa", "su"];
|
|
124
113
|
return weekOrder.map((key, index) => {
|
|
@@ -131,61 +120,30 @@ const DatePicker = (props) => {
|
|
|
131
120
|
}, [props.locale.weeks]);
|
|
132
121
|
const daysInMonth = useMemo(() => {
|
|
133
122
|
const today = moment.utc();
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
const
|
|
123
|
+
const baseMoment = valueMoment ?? dateDefaultMoment;
|
|
124
|
+
const startOfMonth = baseMoment.clone().startOf("month");
|
|
125
|
+
const endOfMonth = baseMoment.clone().endOf("month");
|
|
137
126
|
const dateMin = props.dateMin ? moment.utc(props.dateMin) : null;
|
|
138
127
|
const dateMax = props.dateMax ? moment.utc(props.dateMax) : null;
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
labelString: day.format("dd"),
|
|
146
|
-
labelNumber: day.date(),
|
|
147
|
-
dayOfWeek: day.isoWeekday(),
|
|
148
|
-
isWeekend: day.isoWeekday() === 6 || day.isoWeekday() === 7,
|
|
149
|
-
weekOfMonth: Math.ceil((days.length + 1) / 7),
|
|
150
|
-
isToday: day.isSame(today, "day"),
|
|
151
|
-
isCurrentMonth: false,
|
|
152
|
-
isDisabled: day.isBefore(dateMin, "day") || day.isAfter(dateMax, "day")
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
const currentDate = startOfMonth.clone();
|
|
157
|
-
while (currentDate <= endOfMonth) {
|
|
128
|
+
const firstVisibleDay = startOfMonth.clone().subtract(startOfMonth.isoWeekday() - 1, "days");
|
|
129
|
+
const lastVisibleDay = endOfMonth.clone().add(7 - endOfMonth.isoWeekday(), "days");
|
|
130
|
+
const days = [];
|
|
131
|
+
const currentDate = firstVisibleDay.clone();
|
|
132
|
+
while (currentDate <= lastVisibleDay) {
|
|
133
|
+
const isCurrentMonth = currentDate.isBetween(startOfMonth, endOfMonth, "day", "[]");
|
|
158
134
|
days.push({
|
|
159
135
|
value: currentDate.valueOf(),
|
|
160
136
|
labelString: currentDate.format("dd"),
|
|
161
137
|
labelNumber: currentDate.date(),
|
|
162
138
|
dayOfWeek: currentDate.isoWeekday(),
|
|
163
|
-
isWeekend:
|
|
139
|
+
isWeekend: [6, 7].includes(currentDate.isoWeekday()),
|
|
164
140
|
weekOfMonth: Math.ceil((days.length + 1) / 7),
|
|
165
141
|
isToday: currentDate.isSame(today, "day"),
|
|
166
|
-
isCurrentMonth
|
|
167
|
-
isDisabled: currentDate.isBefore(dateMin, "day") || currentDate.isAfter(dateMax, "day")
|
|
142
|
+
isCurrentMonth,
|
|
143
|
+
isDisabled: !!(dateMin && currentDate.isBefore(dateMin, "day") || dateMax && currentDate.isAfter(dateMax, "day"))
|
|
168
144
|
});
|
|
169
145
|
currentDate.add(1, "day");
|
|
170
146
|
}
|
|
171
|
-
const daysToAddAfter = 7 - endOfMonth.isoWeekday();
|
|
172
|
-
if (daysToAddAfter > 0) {
|
|
173
|
-
for (let i = 1; i <= daysToAddAfter; i++) {
|
|
174
|
-
const day = endOfMonth.clone().add(i, "days").startOf("day");
|
|
175
|
-
days.push({
|
|
176
|
-
value: day.valueOf(),
|
|
177
|
-
labelString: day.format("dd"),
|
|
178
|
-
labelNumber: day.date(),
|
|
179
|
-
dayOfWeek: day.isoWeekday(),
|
|
180
|
-
isWeekend: day.isoWeekday() === 6 || day.isoWeekday() === 7,
|
|
181
|
-
weekOfMonth: Math.ceil((days.length + 1) / 7),
|
|
182
|
-
isToday: day.isSame(today, "day"),
|
|
183
|
-
isCurrentMonth: false,
|
|
184
|
-
isDisabled: day.isBefore(dateMin, "day") || day.isAfter(dateMax, "day")
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
days.sort((a, b) => a.value - b.value);
|
|
189
147
|
return days;
|
|
190
148
|
}, [valueMoment, dateDefaultMoment, props.dateMax, props.dateMin]);
|
|
191
149
|
const rows = useMemo(() => countSevens(daysInMonth.length) + 1, [daysInMonth]);
|
|
@@ -239,20 +197,33 @@ const DatePicker = (props) => {
|
|
|
239
197
|
return !!(!isInputFocused && !isHasValue && props.labelPlaceholder && !isOpen && !isHasInput && !activeSegment);
|
|
240
198
|
}, [isInputFocused, isHasValue, isOpen, props.labelPlaceholder, isHasInput, activeSegment]);
|
|
241
199
|
const onChangeDate = useCallback(
|
|
242
|
-
(timestamp) => {
|
|
200
|
+
(timestamp, isAddLeadingZeros, input2) => {
|
|
243
201
|
const momentNewDate = moment(timestamp).utc();
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
202
|
+
const dd = momentNewDate.clone().date().toString();
|
|
203
|
+
const mm = (momentNewDate.clone().month() + 1).toString();
|
|
204
|
+
const ddWithZero = dd.padStart(2, "0");
|
|
205
|
+
const mmWithZero = mm.padStart(2, "0");
|
|
206
|
+
const yyyy = momentNewDate.clone().year().toString();
|
|
207
|
+
const ddInput = input2 == null ? void 0 : input2[DatePickerVariant.DD];
|
|
208
|
+
const mmInput = input2 == null ? void 0 : input2[DatePickerVariant.MM];
|
|
209
|
+
const yyyyInput = input2 == null ? void 0 : input2[DatePickerVariant.YYYY];
|
|
210
|
+
const isSameInput = ddWithZero === ddInput && mmWithZero === mmInput && yyyyInput === yyyy;
|
|
211
|
+
const isSameMoment = valueMoment == null ? void 0 : valueMoment.isSame(momentNewDate, "day");
|
|
212
|
+
if (!isSameMoment) {
|
|
213
|
+
setValueMoment(momentNewDate);
|
|
214
|
+
onChange(momentNewDate.valueOf());
|
|
215
|
+
}
|
|
216
|
+
if (!isSameMoment || input2 ? !isSameInput : false) {
|
|
217
|
+
setInput({
|
|
218
|
+
[DatePickerVariant.DD]: isAddLeadingZeros ? ddWithZero : dd,
|
|
219
|
+
[DatePickerVariant.MM]: isAddLeadingZeros ? mmWithZero : mm,
|
|
220
|
+
[DatePickerVariant.YYYY]: yyyy
|
|
221
|
+
});
|
|
222
|
+
}
|
|
252
223
|
},
|
|
253
224
|
[valueMoment, onChange]
|
|
254
225
|
);
|
|
255
|
-
const
|
|
226
|
+
const onKeyDown = useCallback(
|
|
256
227
|
(e) => {
|
|
257
228
|
var _a2;
|
|
258
229
|
const key = e.key;
|
|
@@ -273,7 +244,7 @@ const DatePicker = (props) => {
|
|
|
273
244
|
if (key === "Tab") {
|
|
274
245
|
if (!dataDate.default[activeSegment].isLast) {
|
|
275
246
|
e.preventDefault();
|
|
276
|
-
dataDate.default[activeSegment].
|
|
247
|
+
dataDate.default[activeSegment].onNextSegment();
|
|
277
248
|
} else {
|
|
278
249
|
(_a2 = refHiddenInput == null ? void 0 : refHiddenInput.current) == null ? void 0 : _a2.blur();
|
|
279
250
|
}
|
|
@@ -284,40 +255,40 @@ const DatePicker = (props) => {
|
|
|
284
255
|
}
|
|
285
256
|
if (key === "Backspace" || key === "Delete") {
|
|
286
257
|
if (activeSegment === DatePickerVariant.DD) {
|
|
287
|
-
if (input.DD !==
|
|
288
|
-
const current = input.DD
|
|
258
|
+
if (input.DD !== "") {
|
|
259
|
+
const current = input.DD;
|
|
289
260
|
if (current.length === 1) {
|
|
290
|
-
dataDate.default[activeSegment].setValue(
|
|
261
|
+
dataDate.default[activeSegment].setValue("");
|
|
291
262
|
} else {
|
|
292
263
|
const newValue = current.slice(0, -1);
|
|
293
|
-
dataDate.default[activeSegment].setValue(
|
|
264
|
+
dataDate.default[activeSegment].setValue(newValue);
|
|
294
265
|
}
|
|
295
266
|
} else {
|
|
296
|
-
dataDate.default[activeSegment].
|
|
267
|
+
dataDate.default[activeSegment].onPrevSegment();
|
|
297
268
|
}
|
|
298
269
|
} else if (activeSegment === DatePickerVariant.MM) {
|
|
299
|
-
if (input.MM !==
|
|
300
|
-
const current = input.MM
|
|
270
|
+
if (input.MM !== "") {
|
|
271
|
+
const current = input.MM;
|
|
301
272
|
if (current.length === 1) {
|
|
302
|
-
dataDate.default[activeSegment].setValue(
|
|
273
|
+
dataDate.default[activeSegment].setValue("");
|
|
303
274
|
} else {
|
|
304
275
|
const newValue = current.slice(0, -1);
|
|
305
|
-
dataDate.default[activeSegment].setValue(
|
|
276
|
+
dataDate.default[activeSegment].setValue(newValue);
|
|
306
277
|
}
|
|
307
278
|
} else {
|
|
308
|
-
dataDate.default[activeSegment].
|
|
279
|
+
dataDate.default[activeSegment].onPrevSegment();
|
|
309
280
|
}
|
|
310
281
|
} else if (activeSegment === DatePickerVariant.YYYY) {
|
|
311
|
-
if (input.YYYY !==
|
|
312
|
-
const current = input.YYYY
|
|
282
|
+
if (input.YYYY !== "") {
|
|
283
|
+
const current = input.YYYY;
|
|
313
284
|
if (current.length === 1) {
|
|
314
|
-
dataDate.default[activeSegment].setValue(
|
|
285
|
+
dataDate.default[activeSegment].setValue("");
|
|
315
286
|
} else {
|
|
316
287
|
const newValue = current.slice(0, -1);
|
|
317
|
-
dataDate.default[activeSegment].setValue(
|
|
288
|
+
dataDate.default[activeSegment].setValue(newValue);
|
|
318
289
|
}
|
|
319
290
|
} else {
|
|
320
|
-
dataDate.default[activeSegment].
|
|
291
|
+
dataDate.default[activeSegment].onPrevSegment();
|
|
321
292
|
}
|
|
322
293
|
}
|
|
323
294
|
e.preventDefault();
|
|
@@ -325,11 +296,11 @@ const DatePicker = (props) => {
|
|
|
325
296
|
}
|
|
326
297
|
if (key === "ArrowLeft" || key === "ArrowDown") {
|
|
327
298
|
e.preventDefault();
|
|
328
|
-
dataDate.default[activeSegment].
|
|
299
|
+
dataDate.default[activeSegment].onPrevSegment();
|
|
329
300
|
}
|
|
330
301
|
if (key === "ArrowRight" || key === "ArrowUp") {
|
|
331
302
|
e.preventDefault();
|
|
332
|
-
dataDate.default[activeSegment].
|
|
303
|
+
dataDate.default[activeSegment].onNextSegment();
|
|
333
304
|
}
|
|
334
305
|
}
|
|
335
306
|
},
|
|
@@ -337,11 +308,11 @@ const DatePicker = (props) => {
|
|
|
337
308
|
);
|
|
338
309
|
const onNextMonth = useCallback(() => {
|
|
339
310
|
const newDate = (valueMoment ?? dateDefaultMoment).clone().add(1, "month");
|
|
340
|
-
onChangeDate(newDate.valueOf());
|
|
311
|
+
onChangeDate(newDate.valueOf(), true);
|
|
341
312
|
}, [valueMoment, onChangeDate, dateDefaultMoment]);
|
|
342
313
|
const onPrevMonth = useCallback(() => {
|
|
343
314
|
const newDate = (valueMoment ?? dateDefaultMoment).clone().subtract(1, "month");
|
|
344
|
-
onChangeDate(newDate.valueOf());
|
|
315
|
+
onChangeDate(newDate.valueOf(), true);
|
|
345
316
|
}, [valueMoment, onChangeDate, dateDefaultMoment]);
|
|
346
317
|
useEffect(() => {
|
|
347
318
|
setDateDefaultMoment(moment(props.dateDefault).utc());
|
|
@@ -349,50 +320,33 @@ const DatePicker = (props) => {
|
|
|
349
320
|
useEffect(() => {
|
|
350
321
|
setValueMoment(props.value || props.defaultValue ? moment(props.value ?? props.defaultValue).utc() : null);
|
|
351
322
|
if (props.value) {
|
|
323
|
+
const m = moment(props.value).utc();
|
|
352
324
|
setInput({
|
|
353
|
-
[DatePickerVariant.DD]:
|
|
354
|
-
[DatePickerVariant.MM]:
|
|
355
|
-
[DatePickerVariant.YYYY]:
|
|
325
|
+
[DatePickerVariant.DD]: m.date().toString().padStart(2, "0"),
|
|
326
|
+
[DatePickerVariant.MM]: (m.month() + 1).toString().padStart(2, "0"),
|
|
327
|
+
[DatePickerVariant.YYYY]: m.year().toString()
|
|
356
328
|
});
|
|
357
329
|
}
|
|
358
330
|
}, [props.value, props.defaultValue]);
|
|
359
|
-
const getValidateInput = useCallback(
|
|
360
|
-
(input2, onSuccess, onFailure, onNan) => {
|
|
361
|
-
const day = input2.DD ?? NaN;
|
|
362
|
-
const month = input2.MM ?? NaN;
|
|
363
|
-
const year = input2.YYYY ?? NaN;
|
|
364
|
-
const isHasInput2 = input2[DatePickerVariant.DD] !== null || input2[DatePickerVariant.MM] !== null || input2[DatePickerVariant.YYYY] !== null;
|
|
365
|
-
if (!Number.isNaN(day) && !Number.isNaN(month) && !Number.isNaN(year)) {
|
|
366
|
-
const m = moment.utc(`${day}.${month}.${year}`, "D.M.YYYY", true).startOf("day");
|
|
367
|
-
if (m.isValid()) {
|
|
368
|
-
onSuccess == null ? void 0 : onSuccess(m.valueOf());
|
|
369
|
-
} else {
|
|
370
|
-
onFailure == null ? void 0 : onFailure();
|
|
371
|
-
}
|
|
372
|
-
} else {
|
|
373
|
-
onNan == null ? void 0 : onNan(isHasInput2);
|
|
374
|
-
}
|
|
375
|
-
},
|
|
376
|
-
[]
|
|
377
|
-
);
|
|
378
331
|
useEffect(() => {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
},
|
|
385
|
-
() => {
|
|
386
|
-
onChange(null);
|
|
387
|
-
setIsError(true);
|
|
388
|
-
},
|
|
389
|
-
(isHasInput2) => {
|
|
390
|
-
if (!isHasInput2) {
|
|
332
|
+
if (!activeSegment)
|
|
333
|
+
getValidateInput(
|
|
334
|
+
input,
|
|
335
|
+
(value) => {
|
|
336
|
+
onChangeDate(value, true, input);
|
|
391
337
|
setIsError(false);
|
|
338
|
+
},
|
|
339
|
+
() => {
|
|
340
|
+
onChange(null);
|
|
341
|
+
setIsError(true);
|
|
342
|
+
},
|
|
343
|
+
(isHasInput2) => {
|
|
344
|
+
if (!isHasInput2) {
|
|
345
|
+
setIsError(false);
|
|
346
|
+
}
|
|
392
347
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
}, [getValidateInput, onChangeDate, onChange, input]);
|
|
348
|
+
);
|
|
349
|
+
}, [getValidateInput, onChangeDate, onChange, input, activeSegment]);
|
|
396
350
|
useEffect(() => {
|
|
397
351
|
if (!isOpen && !isInputFocused && isHasInput && !activeSegment)
|
|
398
352
|
getValidateInput(
|
|
@@ -411,6 +365,24 @@ const DatePicker = (props) => {
|
|
|
411
365
|
}
|
|
412
366
|
);
|
|
413
367
|
}, [getValidateInput, onClearInput, input, isOpen, isInputFocused, onChange, isHasInput, activeSegment]);
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
if (!activeSegment) return;
|
|
370
|
+
getValidateInput(
|
|
371
|
+
refInputValue.current,
|
|
372
|
+
(value) => {
|
|
373
|
+
onChangeDate(value, true, refInputValue.current);
|
|
374
|
+
setIsError(false);
|
|
375
|
+
},
|
|
376
|
+
() => {
|
|
377
|
+
setIsError(true);
|
|
378
|
+
},
|
|
379
|
+
(isHasInput2) => {
|
|
380
|
+
if (!isHasInput2) {
|
|
381
|
+
setIsError(false);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
}, [onChangeDate, getValidateInput, activeSegment]);
|
|
414
386
|
useEffect(() => {
|
|
415
387
|
var _a2;
|
|
416
388
|
if (activeSegment) {
|
|
@@ -465,21 +437,20 @@ const DatePicker = (props) => {
|
|
|
465
437
|
position: "absolute",
|
|
466
438
|
left: "-100dvw",
|
|
467
439
|
top: 0,
|
|
468
|
-
// left: 0,
|
|
469
440
|
width: "100%",
|
|
470
441
|
height: "100%",
|
|
471
442
|
opacity: 0,
|
|
472
443
|
border: "none",
|
|
473
444
|
background: "transparent"
|
|
474
445
|
},
|
|
475
|
-
onKeyDown
|
|
446
|
+
onKeyDown,
|
|
476
447
|
onChange: (e) => {
|
|
477
448
|
const value = e.target.value;
|
|
478
449
|
const prevValue = refPrevValue.current;
|
|
479
450
|
const newChar = value.length > prevValue.length ? value.slice(-1) : null;
|
|
480
451
|
refPrevValue.current = value;
|
|
481
452
|
if (newChar && /^\d$/.test(newChar)) {
|
|
482
|
-
|
|
453
|
+
onKeyDown({
|
|
483
454
|
key: newChar,
|
|
484
455
|
preventDefault: () => {
|
|
485
456
|
},
|
|
@@ -488,7 +459,7 @@ const DatePicker = (props) => {
|
|
|
488
459
|
});
|
|
489
460
|
}
|
|
490
461
|
if (value.length < prevValue.length) {
|
|
491
|
-
|
|
462
|
+
onKeyDown({
|
|
492
463
|
key: "Backspace",
|
|
493
464
|
preventDefault: () => {
|
|
494
465
|
},
|
|
@@ -522,7 +493,7 @@ const DatePicker = (props) => {
|
|
|
522
493
|
children: props.labelPlaceholder
|
|
523
494
|
}
|
|
524
495
|
) : dataDate.sort.map((date, index) => {
|
|
525
|
-
var _a2, _b2
|
|
496
|
+
var _a2, _b2;
|
|
526
497
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Fragment, { children: [
|
|
527
498
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
528
499
|
DateInput,
|
|
@@ -532,10 +503,9 @@ const DatePicker = (props) => {
|
|
|
532
503
|
$genre: props.genre,
|
|
533
504
|
$size: props.size,
|
|
534
505
|
$font: {
|
|
506
|
+
...props.font,
|
|
535
507
|
size: ((_a2 = props.font) == null ? void 0 : _a2.size) ?? 16,
|
|
536
|
-
weight: ((_b2 = props.font) == null ? void 0 : _b2.weight) ?? (props.isBold ? 500 : 400)
|
|
537
|
-
family: ((_c2 = props.font) == null ? void 0 : _c2.family) ?? theme.font.family,
|
|
538
|
-
height: ((_d2 = props.font) == null ? void 0 : _d2.height) ?? theme.font.lineHeight
|
|
508
|
+
weight: ((_b2 = props.font) == null ? void 0 : _b2.weight) ?? (props.isBold ? 500 : 400)
|
|
539
509
|
},
|
|
540
510
|
onClick: (e) => {
|
|
541
511
|
e.preventDefault();
|
|
@@ -543,7 +513,7 @@ const DatePicker = (props) => {
|
|
|
543
513
|
if ((props == null ? void 0 : props.isDisabled) || (props == null ? void 0 : props.isReadOnly)) return;
|
|
544
514
|
date.setActive();
|
|
545
515
|
},
|
|
546
|
-
children: date.value
|
|
516
|
+
children: date.value || date.placeholder || ""
|
|
547
517
|
}
|
|
548
518
|
),
|
|
549
519
|
index !== dataDate.sort.length - 1 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { style: { width: "4px", pointerEvents: "none", textAlign: "center" }, children: "." })
|
|
@@ -557,7 +527,9 @@ const DatePicker = (props) => {
|
|
|
557
527
|
isWidthAsHeight: true,
|
|
558
528
|
isFullSize: true,
|
|
559
529
|
isRadius: true,
|
|
530
|
+
isWhileTapEffect: true,
|
|
560
531
|
isOnlyIcon: true,
|
|
532
|
+
isDisabledRipple: true,
|
|
561
533
|
icons: [{ name: "Calendar", type: "id" }],
|
|
562
534
|
isDisabled: (props == null ? void 0 : props.isDisabled) || (props == null ? void 0 : props.isReadOnly),
|
|
563
535
|
onFocus: (e) => {
|
|
@@ -608,6 +580,7 @@ const DatePicker = (props) => {
|
|
|
608
580
|
{
|
|
609
581
|
type: "button",
|
|
610
582
|
isRadius: true,
|
|
583
|
+
isWhileTapEffect: true,
|
|
611
584
|
icons: [
|
|
612
585
|
{
|
|
613
586
|
name: "Arrow2",
|
|
@@ -619,7 +592,9 @@ const DatePicker = (props) => {
|
|
|
619
592
|
genre: props.genre,
|
|
620
593
|
size: "small",
|
|
621
594
|
onClick: () => !isBlockPrevMonth && onPrevMonth(),
|
|
622
|
-
|
|
595
|
+
isDisabledRipple: true,
|
|
596
|
+
isHidden: isBlockPrevMonth,
|
|
597
|
+
isDisabled: isBlockPrevMonth
|
|
623
598
|
}
|
|
624
599
|
),
|
|
625
600
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(Stack, { sx: { default: { gap: "8px" } }, children: [
|
|
@@ -637,7 +612,7 @@ const DatePicker = (props) => {
|
|
|
637
612
|
isShortLabel: true,
|
|
638
613
|
refFloating: refSelectMonth,
|
|
639
614
|
onChange: (timestamp) => {
|
|
640
|
-
if (timestamp) onChangeDate(timestamp);
|
|
615
|
+
if (timestamp) onChangeDate(timestamp, true);
|
|
641
616
|
},
|
|
642
617
|
dateMin: props.dateMin,
|
|
643
618
|
dateMax: props.dateMax,
|
|
@@ -652,7 +627,7 @@ const DatePicker = (props) => {
|
|
|
652
627
|
refFloating: refSelectYear,
|
|
653
628
|
value: (valueMoment ?? dateDefaultMoment).clone().startOf("year").utc().valueOf(),
|
|
654
629
|
onChange: (timestamp) => {
|
|
655
|
-
if (timestamp) onChangeDate(timestamp);
|
|
630
|
+
if (timestamp) onChangeDate(timestamp, true);
|
|
656
631
|
},
|
|
657
632
|
isOnClickOptionClose: true,
|
|
658
633
|
isStayValueAfterSelect: true,
|
|
@@ -668,6 +643,7 @@ const DatePicker = (props) => {
|
|
|
668
643
|
Button,
|
|
669
644
|
{
|
|
670
645
|
type: "button",
|
|
646
|
+
isWhileTapEffect: true,
|
|
671
647
|
onClick: () => !isBlockNextMonth && onNextMonth(),
|
|
672
648
|
isWidthAsHeight: true,
|
|
673
649
|
isRadius: true,
|
|
@@ -680,6 +656,8 @@ const DatePicker = (props) => {
|
|
|
680
656
|
],
|
|
681
657
|
genre: props.genre,
|
|
682
658
|
size: "small",
|
|
659
|
+
isDisabledRipple: true,
|
|
660
|
+
isDisabled: isBlockNextMonth,
|
|
683
661
|
isHidden: isBlockNextMonth
|
|
684
662
|
}
|
|
685
663
|
)
|
|
@@ -688,14 +666,14 @@ const DatePicker = (props) => {
|
|
|
688
666
|
),
|
|
689
667
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(DateDropdownDays, { $rows: rows, children: [
|
|
690
668
|
daysInWeek.map((e, index) => {
|
|
691
|
-
var _a2
|
|
669
|
+
var _a2;
|
|
692
670
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
693
671
|
DateDropdownDayOfWeek,
|
|
694
672
|
{
|
|
695
673
|
$font: {
|
|
674
|
+
...props.font,
|
|
696
675
|
size: 12,
|
|
697
|
-
weight: 700
|
|
698
|
-
family: ((_a2 = props.font) == null ? void 0 : _a2.family) ?? theme.font.family
|
|
676
|
+
weight: 700
|
|
699
677
|
},
|
|
700
678
|
tabIndex: -1,
|
|
701
679
|
type: "button",
|
|
@@ -703,53 +681,50 @@ const DatePicker = (props) => {
|
|
|
703
681
|
$isWeekend: false,
|
|
704
682
|
$genre: props.genre,
|
|
705
683
|
$size: props.size,
|
|
706
|
-
$row: ((
|
|
684
|
+
$row: ((_a2 = daysInMonth[0]) == null ? void 0 : _a2.weekOfMonth) - 1,
|
|
707
685
|
$column: index + 1,
|
|
708
686
|
children: e.label
|
|
709
687
|
},
|
|
710
688
|
`${e.label}-${index}`
|
|
711
689
|
);
|
|
712
690
|
}),
|
|
713
|
-
daysInMonth.map((day) =>
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
if (
|
|
734
|
-
|
|
735
|
-
if (props.isOnClickClose) {
|
|
736
|
-
close();
|
|
737
|
-
}
|
|
691
|
+
daysInMonth.map((day) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
692
|
+
DateDropdownDay,
|
|
693
|
+
{
|
|
694
|
+
$font: {
|
|
695
|
+
...props.font,
|
|
696
|
+
size: 12,
|
|
697
|
+
weight: 700
|
|
698
|
+
},
|
|
699
|
+
type: "button",
|
|
700
|
+
$isDisabled: day.isDisabled,
|
|
701
|
+
$isDisabledOutline: day.isDisabled ?? props.isDisabledOutline,
|
|
702
|
+
$isOutlineBoxShadow: props.isOutlineBoxShadow,
|
|
703
|
+
$isReadOnly: props.isReadOnly,
|
|
704
|
+
$genre: props.genre,
|
|
705
|
+
$size: props.size,
|
|
706
|
+
$row: (day == null ? void 0 : day.weekOfMonth) + 1,
|
|
707
|
+
$column: day.dayOfWeek,
|
|
708
|
+
onClick: () => {
|
|
709
|
+
if (!day.isDisabled) {
|
|
710
|
+
onChangeDate(day.value, true);
|
|
711
|
+
if (props.isOnClickClose) {
|
|
712
|
+
close();
|
|
738
713
|
}
|
|
739
|
-
}
|
|
740
|
-
tabIndex: day.isDisabled ? -1 : 0,
|
|
741
|
-
$isToday: day.isToday,
|
|
742
|
-
$isWeekend: day.isWeekend,
|
|
743
|
-
$isChoice: day.value === (valueMoment == null ? void 0 : valueMoment.valueOf()),
|
|
744
|
-
$isCurrentMonth: day.isCurrentMonth,
|
|
745
|
-
children: [
|
|
746
|
-
!day.isDisabled && /* @__PURE__ */ jsxRuntimeExports.jsx(Ripple, { color: theme.colors.date[props.genre].color.rest }),
|
|
747
|
-
day.labelNumber
|
|
748
|
-
]
|
|
714
|
+
}
|
|
749
715
|
},
|
|
750
|
-
day.
|
|
751
|
-
|
|
752
|
-
|
|
716
|
+
tabIndex: day.isDisabled ? -1 : 0,
|
|
717
|
+
$isToday: day.isToday,
|
|
718
|
+
$isWeekend: day.isWeekend,
|
|
719
|
+
$isChoice: day.value === (valueMoment == null ? void 0 : valueMoment.valueOf()),
|
|
720
|
+
$isCurrentMonth: day.isCurrentMonth,
|
|
721
|
+
children: [
|
|
722
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Ripple, { color: theme.colors.date[props.genre].color.rest, isDisabled: day.isDisabled }),
|
|
723
|
+
day.labelNumber
|
|
724
|
+
]
|
|
725
|
+
},
|
|
726
|
+
day.value
|
|
727
|
+
))
|
|
753
728
|
] })
|
|
754
729
|
] })
|
|
755
730
|
}
|
|
@@ -773,71 +748,63 @@ const DatePicker = (props) => {
|
|
|
773
748
|
] });
|
|
774
749
|
};
|
|
775
750
|
function handleDigitKey(key, activeSegment, input, dataDate) {
|
|
776
|
-
var _a;
|
|
777
751
|
const digit = key;
|
|
778
752
|
const seg = activeSegment;
|
|
779
|
-
const current =
|
|
780
|
-
const isZero = (s) => s === "0";
|
|
781
|
-
const toNum = (s) => Number(s);
|
|
753
|
+
const current = input[seg] ?? "";
|
|
782
754
|
if (seg === DatePickerVariant.DD) {
|
|
783
755
|
if (current.length >= 2) {
|
|
784
|
-
|
|
785
|
-
if (parsed2 === 0 || parsed2 > 31) return;
|
|
786
|
-
dataDate.default[seg].setValue(parsed2);
|
|
756
|
+
dataDate.default[seg].setValue(digit);
|
|
787
757
|
return;
|
|
788
758
|
}
|
|
789
|
-
if (current
|
|
790
|
-
|
|
791
|
-
if (parsed2 === 0 || parsed2 > 31) return;
|
|
792
|
-
dataDate.default[seg].setValue(parsed2);
|
|
793
|
-
dataDate.default[seg].onNext();
|
|
759
|
+
if (current === "") {
|
|
760
|
+
dataDate.default[seg].setValue(digit);
|
|
794
761
|
return;
|
|
795
762
|
}
|
|
796
763
|
const potential = current + digit;
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
799
|
-
|
|
800
|
-
if (parsed2 === 0 || parsed2 > 31) return;
|
|
801
|
-
dataDate.default[seg].setValue(parsed2);
|
|
802
|
-
dataDate.default[seg].onNext();
|
|
764
|
+
const potentialNum = Number(potential);
|
|
765
|
+
if (potentialNum > 31) {
|
|
766
|
+
dataDate.default[seg].setValue(digit);
|
|
803
767
|
return;
|
|
804
768
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
769
|
+
if (potentialNum === 0) {
|
|
770
|
+
dataDate.default[seg].setValue(digit);
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
dataDate.default[seg].setValue(potential);
|
|
774
|
+
dataDate.default[seg].onNextSegment();
|
|
810
775
|
} else if (seg === DatePickerVariant.MM) {
|
|
811
776
|
if (current.length >= 2) {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
dataDate.default[seg].setValue(parsed2);
|
|
777
|
+
if (digit === "0") return;
|
|
778
|
+
dataDate.default[seg].setValue(digit);
|
|
815
779
|
return;
|
|
816
780
|
}
|
|
817
|
-
if (current
|
|
818
|
-
|
|
819
|
-
if (parsed2 === 0 || parsed2 > 12) return;
|
|
820
|
-
dataDate.default[seg].setValue(parsed2);
|
|
821
|
-
dataDate.default[seg].onNext();
|
|
781
|
+
if (current === "") {
|
|
782
|
+
dataDate.default[seg].setValue(digit);
|
|
822
783
|
return;
|
|
823
784
|
}
|
|
824
785
|
const potential = current + digit;
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
786
|
+
const potentialNum = Number(potential);
|
|
787
|
+
if (potentialNum > 12) {
|
|
788
|
+
if (digit === "0") return;
|
|
789
|
+
dataDate.default[seg].setValue(digit);
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
if (potentialNum === 0) {
|
|
793
|
+
if (digit === "0") return;
|
|
794
|
+
dataDate.default[seg].setValue(digit);
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
dataDate.default[seg].setValue(potential);
|
|
798
|
+
if (potential.length === 2 || potential.length === 1 && Number(potential) > 1) {
|
|
799
|
+
dataDate.default[seg].onNextSegment();
|
|
832
800
|
}
|
|
833
801
|
} else if (seg === DatePickerVariant.YYYY) {
|
|
834
802
|
if (current.length >= 4) {
|
|
835
|
-
|
|
836
|
-
dataDate.default[seg].setValue(toNum(digit));
|
|
803
|
+
dataDate.default[seg].setValue(digit);
|
|
837
804
|
return;
|
|
838
805
|
}
|
|
839
|
-
const nextValue =
|
|
840
|
-
dataDate.default[seg].setValue(
|
|
806
|
+
const nextValue = current + digit;
|
|
807
|
+
dataDate.default[seg].setValue(nextValue);
|
|
841
808
|
}
|
|
842
809
|
}
|
|
843
810
|
var DatePickerVariant = /* @__PURE__ */ ((DatePickerVariant2) => {
|
|
@@ -850,4 +817,4 @@ export {
|
|
|
850
817
|
DatePicker as D,
|
|
851
818
|
DatePickerVariant as a
|
|
852
819
|
};
|
|
853
|
-
//# sourceMappingURL=component.types-
|
|
820
|
+
//# sourceMappingURL=component.types-BfuKs1g9.js.map
|