triafly-ui-kit 1.0.30 → 1.0.31
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/_virtual/dayjs.min.js +7 -0
- package/dist/_virtual/dayjs.min2.js +4 -0
- package/dist/_virtual/ru.js +2 -0
- package/dist/_virtual/ru2.js +4 -0
- package/dist/assets/src/components/Ui/DateRangePicker/DateRangePicker.css +1 -0
- package/dist/components/Ui/DatePicker/DatePicker.js +6 -13
- package/dist/components/Ui/DatePicker/DatePicker.stories.js +33 -39
- package/dist/components/Ui/DatePicker/index.js +4 -0
- package/dist/components/Ui/DateRangePicker/DateRangePicker.js +195 -0
- package/dist/components/Ui/DateRangePicker/DateRangePicker.stories.js +84 -0
- package/dist/components/Ui/DateRangePicker/const.js +37 -0
- package/dist/components/Ui/DateRangePicker/hooks/useCalendarRenderer.js +48 -0
- package/dist/components/Ui/DateRangePicker/hooks/useChangeDate.js +28 -0
- package/dist/components/Ui/DateRangePicker/hooks/useDateNavigation.js +22 -0
- package/dist/components/Ui/DateRangePicker/hooks/useDateRangeState.js +24 -0
- package/dist/components/Ui/DateRangePicker/hooks/useQuickRange.js +77 -0
- package/dist/components/Ui/DateRangePicker/index.js +4 -0
- package/dist/main.d.ts +33 -0
- package/dist/main.js +157 -153
- package/dist/node_modules/dayjs/dayjs.min.js +282 -0
- package/dist/node_modules/dayjs/locale/ru.js +36 -0
- package/dist/styles/variables.scss +17 -15
- package/package.json +1 -1
- package/src/styles/variables.scss +4 -2
@@ -0,0 +1 @@
|
|
1
|
+
.date-range-picker{position:relative;width:260px;font-family:Arial,sans-serif}.date-range-picker-input{display:flex;align-items:center;gap:8px;height:44px;padding:8px;border:1px solid var(--color-border-primary-default);border-radius:8px;background-color:var(--color-bg-neutral-basic-default);cursor:pointer;transition:border-color .2s}.date-range-picker-input:hover{border-color:#9ca3af}.date-range-picker-input .calendar-icon{color:#6b7280}.date-range-picker-input .placeholder{color:#6b7280;margin:0 auto 0 0}.date-range-picker-input .placeholder:not(:empty){color:#111827}.date-range-picker-input .caret *{fill:var(--color-icon-secondary-default)}.date-range-picker-calendar{position:absolute;top:100%;left:0;z-index:100;width:950px;padding:12px 16px;background-color:var(--color-bg-neutral-basic-default);border-radius:8px;border:1px solid var(--color-border-primary-default)}.date-range-picker-selection{display:flex;gap:32px}.date-range-picker-selection .line{width:1px;height:inherit;background-color:var(--color-border-primary-default)}.date-range-picker-quick-selection-options{display:flex;flex-direction:column;justify-content:space-evenly}.date-range-picker-quick-selection-options button{padding:8px 16px;border-radius:8px;background:none;text-align:left}.date-range-picker-quick-selection-options button[disabled]{opacity:.5;cursor:not-allowed;pointer-events:none}.date-range-picker-quick-selection-options button.active{background-color:#f1f2f4}.date-range-picker-section-period{display:flex;gap:32px}.date-range-picker-section-period-month-year-block{display:flex;padding:12px 16px;justify-content:space-between}.date-range-picker-section-period-month-year-block .month-control{display:flex;align-items:center;gap:30px}.date-range-picker-section-period-month-year-block .month-control button{background:none}.date-range-picker-section-period-month-year-block .year-control{display:flex;align-items:center}.date-range-picker-section-period-month-year-block .year-control button{background:none}.date-range-picker-section-period-month-year-block .current-year{padding:0 12px}.calendar-month{padding:12px 16px}.calendar-month table{width:100%;border-collapse:collapse}.calendar-month th{text-align:center;padding:11.5px;font-weight:500;font-size:14px;line-height:20px}.calendar-month td{text-align:center;padding:11.5px;cursor:pointer;position:relative;font-weight:400;font-size:14px}.calendar-month td:hover{background-color:#f5f5f5}.calendar-month table td.empty{pointer-events:none;background:none;cursor:default}.calendar-month table td.empty:hover{background:none}.calendar-month td.disabled{color:#ccc;cursor:not-allowed}.calendar-month td.other-month.empty{color:#ed0000}.today-dot{position:absolute;bottom:2px;left:50%;transform:translate(-50%);width:4px;height:4px;background-color:#1976d2;border-radius:50%}.calendar-month td.selected-start{border-top-left-radius:4px;border-bottom-left-radius:4px}.calendar-month td.selected-end{border-top-right-radius:4px;border-bottom-right-radius:4px}.calendar-month td.selected-start,.calendar-month td.selected-end{background-color:#2454ff;color:#fff}.calendar-month td.in-range{background-color:#f1f2f4}
|
@@ -116,18 +116,11 @@ const H = [
|
|
116
116
|
"aria-hidden": "true"
|
117
117
|
}
|
118
118
|
),
|
119
|
-
/* @__PURE__ */ i(
|
120
|
-
|
121
|
-
{
|
122
|
-
|
123
|
-
|
124
|
-
children: [
|
125
|
-
/* @__PURE__ */ n(A, {}),
|
126
|
-
/* @__PURE__ */ n("span", { className: "placeholder", children: c ? j(c) : L }),
|
127
|
-
/* @__PURE__ */ n(G, { className: "caret" })
|
128
|
-
]
|
129
|
-
}
|
130
|
-
),
|
119
|
+
/* @__PURE__ */ i("div", { className: `datepicker-input ${T}`, onClick: () => g(!F), children: [
|
120
|
+
/* @__PURE__ */ n(A, {}),
|
121
|
+
/* @__PURE__ */ n("span", { className: "placeholder", children: c ? j(c) : L }),
|
122
|
+
/* @__PURE__ */ n(G, { className: "caret" })
|
123
|
+
] }),
|
131
124
|
F && /* @__PURE__ */ i("div", { className: `datepicker-calendar ${E}`, children: [
|
132
125
|
/* @__PURE__ */ i("div", { className: "calendar-controls", children: [
|
133
126
|
/* @__PURE__ */ i("div", { className: "month-control", children: [
|
@@ -179,5 +172,5 @@ const H = [
|
|
179
172
|
] });
|
180
173
|
};
|
181
174
|
export {
|
182
|
-
Z as
|
175
|
+
Z as DatePicker
|
183
176
|
};
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { jsxs as a, jsx as e } from "react/jsx-runtime";
|
2
2
|
import l from "react";
|
3
|
-
import
|
4
|
-
const
|
3
|
+
import { DatePicker as r } from "./DatePicker.js";
|
4
|
+
const m = {
|
5
5
|
title: "UIKit/DatePicker",
|
6
|
-
component:
|
6
|
+
component: r,
|
7
7
|
tags: ["autodocs"],
|
8
8
|
argTypes: {
|
9
9
|
value: {
|
@@ -39,27 +39,27 @@ const d = {
|
|
39
39
|
description: "Максимальная доступная дата"
|
40
40
|
}
|
41
41
|
}
|
42
|
-
},
|
42
|
+
}, u = {
|
43
43
|
args: {
|
44
44
|
placeholder: "Любая дата"
|
45
45
|
}
|
46
|
-
},
|
46
|
+
}, x = {
|
47
47
|
args: {
|
48
48
|
value: new Date(2023, 5, 15),
|
49
49
|
placeholder: "Выберите дату"
|
50
50
|
}
|
51
|
-
},
|
51
|
+
}, h = {
|
52
52
|
args: {
|
53
53
|
minDate: new Date(2023, 0, 1),
|
54
54
|
maxDate: new Date(2023, 11, 31)
|
55
55
|
}
|
56
|
-
},
|
56
|
+
}, g = {
|
57
57
|
args: {
|
58
58
|
inputClassName: "custom-input",
|
59
59
|
calendarClassName: "custom-calendar"
|
60
60
|
},
|
61
61
|
decorators: [
|
62
|
-
(
|
62
|
+
(o) => /* @__PURE__ */ a("div", { children: [
|
63
63
|
/* @__PURE__ */ e("style", { children: `
|
64
64
|
.custom-input {
|
65
65
|
border: 2px solid #6366f1;
|
@@ -75,46 +75,40 @@ const d = {
|
|
75
75
|
background-color: #6366f1;
|
76
76
|
}
|
77
77
|
` }),
|
78
|
-
/* @__PURE__ */ e(
|
78
|
+
/* @__PURE__ */ e(o, {})
|
79
79
|
] })
|
80
80
|
]
|
81
|
-
},
|
82
|
-
render: ()
|
83
|
-
const [t,
|
81
|
+
}, D = {
|
82
|
+
render: function() {
|
83
|
+
const [t, n] = l.useState(null);
|
84
84
|
return /* @__PURE__ */ a("div", { style: { maxWidth: "300px" }, children: [
|
85
|
-
/* @__PURE__ */ e(
|
86
|
-
n,
|
87
|
-
{
|
88
|
-
value: t,
|
89
|
-
onChange: o,
|
90
|
-
placeholder: "Контролируемый выбор"
|
91
|
-
}
|
92
|
-
),
|
85
|
+
/* @__PURE__ */ e(r, { value: t, onChange: n, placeholder: "Контролируемый выбор" }),
|
93
86
|
/* @__PURE__ */ a("div", { style: { marginTop: "16px", fontSize: "14px" }, children: [
|
94
87
|
"Выбрано: ",
|
95
88
|
t ? t.toLocaleDateString("ru-RU") : "дата не выбрана"
|
96
89
|
] })
|
97
90
|
] });
|
98
91
|
}
|
99
|
-
},
|
100
|
-
render: ()
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
92
|
+
}, f = {
|
93
|
+
render: function() {
|
94
|
+
const [t, n] = l.useState(null);
|
95
|
+
return /* @__PURE__ */ a("form", { onSubmit: (i) => {
|
96
|
+
i.preventDefault(), alert(`Выбрана дата: ${t == null ? void 0 : t.toLocaleDateString("ru-RU")}`);
|
97
|
+
}, style: { maxWidth: "300px" }, children: [
|
98
|
+
/* @__PURE__ */ a("div", { style: { marginBottom: "16px" }, children: [
|
99
|
+
/* @__PURE__ */ e("label", { style: { display: "block", marginBottom: "4px" }, children: "Дата события:" }),
|
100
|
+
/* @__PURE__ */ e(r, { name: "eventDate", value: t, onChange: n })
|
101
|
+
] }),
|
102
|
+
/* @__PURE__ */ e("button", { type: "submit", children: "Отправить" })
|
103
|
+
] });
|
104
|
+
}
|
111
105
|
};
|
112
106
|
export {
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
107
|
+
D as Controlled,
|
108
|
+
g as CustomStyled,
|
109
|
+
u as Default,
|
110
|
+
f as InForm,
|
111
|
+
h as WithDateRange,
|
112
|
+
x as WithInitialDate,
|
113
|
+
m as default
|
120
114
|
};
|
@@ -0,0 +1,195 @@
|
|
1
|
+
import { jsx as e, Fragment as E, jsxs as n } from "react/jsx-runtime";
|
2
|
+
import { useRef as $, useState as A, useEffect as P } from "react";
|
3
|
+
import D from "../../../_virtual/dayjs.min.js";
|
4
|
+
import "../../../_virtual/ru.js";
|
5
|
+
import '../../../assets/src/components/Ui/DateRangePicker/DateRangePicker.css';/* empty css */
|
6
|
+
import { selectAutoCompliteDate as q } from "./const.js";
|
7
|
+
import { useDateRangeState as F } from "./hooks/useDateRangeState.js";
|
8
|
+
import { useDateNavigation as U } from "./hooks/useDateNavigation.js";
|
9
|
+
import { useQuickRange as z } from "./hooks/useQuickRange.js";
|
10
|
+
import { useCalendarRenderer as G } from "./hooks/useCalendarRenderer.js";
|
11
|
+
import { IconCalendarBlank as H, IconCaretUpDown as J, IconCaretLeft as v, IconCaretRight as k } from "../Icons/Icons.js";
|
12
|
+
D.locale("ru");
|
13
|
+
const re = ({
|
14
|
+
disabledBefore: m,
|
15
|
+
disabledAfter: h,
|
16
|
+
onChange: l,
|
17
|
+
initialRange: R,
|
18
|
+
className: x,
|
19
|
+
placeholder: O = "Любая дата",
|
20
|
+
autoCompleteWithToday: w = !0
|
21
|
+
}) => {
|
22
|
+
const N = $(null), [b, g] = A(!1), { leftMonth: s, rightMonth: c, setLeftMonth: u, setRightMonth: o, selectedRange: t, setSelectedRange: d } = F(R), { navigateLeftMonth: M, navigateRightMonth: y, navigateYear: f } = U(
|
23
|
+
s,
|
24
|
+
c,
|
25
|
+
u,
|
26
|
+
o
|
27
|
+
), { activeQuickRange: I, setQuickRange: L, isQuickRangeDisabled: Q, setActiveQuickRange: S } = z(
|
28
|
+
d,
|
29
|
+
u,
|
30
|
+
o,
|
31
|
+
m,
|
32
|
+
h,
|
33
|
+
l
|
34
|
+
), j = (a, r) => {
|
35
|
+
if (!(m && a.isBefore(m, "day") || h && a.isAfter(h, "day")))
|
36
|
+
if (S(null), !t.start || t.start && t.end) {
|
37
|
+
if (d({ start: a, end: null }), r === "left") {
|
38
|
+
const i = a.add(1, "month").startOf("month");
|
39
|
+
i.isSame(s) ? o(i.add(1, "month")) : o(i);
|
40
|
+
}
|
41
|
+
} else
|
42
|
+
a.isBefore(t.start, "day") ? d({ start: a, end: t.start }) : d({ ...t, end: a }), l && l({
|
43
|
+
start: a.isBefore(t.start, "day") ? a : t.start,
|
44
|
+
end: a.isBefore(t.start, "day") ? t.start : a
|
45
|
+
});
|
46
|
+
}, { renderCalendar: Y } = G(
|
47
|
+
t,
|
48
|
+
j,
|
49
|
+
m,
|
50
|
+
h
|
51
|
+
), B = () => {
|
52
|
+
if (w && t.start && !t.end) {
|
53
|
+
const a = D(), r = a.isAfter(t.start) ? a : t.start, i = {
|
54
|
+
start: t.start,
|
55
|
+
end: r
|
56
|
+
};
|
57
|
+
d(i), l && l(i);
|
58
|
+
const p = i.start.startOf("month"), C = r.startOf("month");
|
59
|
+
p.isSame(C) ? (u(p), o(p.add(1, "month"))) : (u(p), o(C));
|
60
|
+
}
|
61
|
+
g(!1);
|
62
|
+
};
|
63
|
+
return P(() => {
|
64
|
+
const a = (r) => {
|
65
|
+
N.current && !N.current.contains(r.target) && B();
|
66
|
+
};
|
67
|
+
return document.addEventListener("mousedown", a), () => {
|
68
|
+
document.removeEventListener("mousedown", a);
|
69
|
+
};
|
70
|
+
}, [t]), /* @__PURE__ */ e(E, { children: /* @__PURE__ */ n("div", { className: `date-range-picker ${x}`, ref: N, children: [
|
71
|
+
/* @__PURE__ */ n("div", { className: "date-range-picker-input", onClick: () => g(!b), children: [
|
72
|
+
/* @__PURE__ */ e(H, {}),
|
73
|
+
/* @__PURE__ */ e("span", { className: "placeholder", children: t != null && t.start && (t != null && t.end) ? `${t.start.format("DD-MM-YYYY")} – ${t.end.format("DD-MM-YYYY")}` : O }),
|
74
|
+
/* @__PURE__ */ e(J, { className: "caret" })
|
75
|
+
] }),
|
76
|
+
b && /* @__PURE__ */ e("div", { className: "date-range-picker-calendar", children: /* @__PURE__ */ n("div", { className: "date-range-picker-selection", children: [
|
77
|
+
/* @__PURE__ */ e("div", { className: "date-range-picker-quick-selection-options", children: q.map((a) => {
|
78
|
+
const r = Q(a.key);
|
79
|
+
return /* @__PURE__ */ e(
|
80
|
+
"button",
|
81
|
+
{
|
82
|
+
className: I === a.key ? "active" : "",
|
83
|
+
onClick: () => !r && L(a.key),
|
84
|
+
disabled: r,
|
85
|
+
children: a.label
|
86
|
+
},
|
87
|
+
a.key
|
88
|
+
);
|
89
|
+
}) }),
|
90
|
+
/* @__PURE__ */ e("div", { className: "line" }),
|
91
|
+
/* @__PURE__ */ n("div", { className: "date-range-picker-section-period", children: [
|
92
|
+
/* @__PURE__ */ n("div", { children: [
|
93
|
+
/* @__PURE__ */ n("div", { className: "date-range-picker-section-period-month-year-block", children: [
|
94
|
+
/* @__PURE__ */ n("div", { className: "month-control", children: [
|
95
|
+
/* @__PURE__ */ e(
|
96
|
+
"button",
|
97
|
+
{
|
98
|
+
className: "nav-button",
|
99
|
+
onClick: () => M("prev"),
|
100
|
+
"aria-label": "Предыдущий месяц",
|
101
|
+
children: /* @__PURE__ */ e(v, {})
|
102
|
+
}
|
103
|
+
),
|
104
|
+
/* @__PURE__ */ e("span", { className: "current-month", children: s.format("MMMM") }),
|
105
|
+
/* @__PURE__ */ e(
|
106
|
+
"button",
|
107
|
+
{
|
108
|
+
className: "nav-button",
|
109
|
+
onClick: () => M("next"),
|
110
|
+
"aria-label": "Следующий месяц",
|
111
|
+
disabled: s.add(1, "month").isAfter(c),
|
112
|
+
children: /* @__PURE__ */ e(k, {})
|
113
|
+
}
|
114
|
+
)
|
115
|
+
] }),
|
116
|
+
/* @__PURE__ */ n("div", { className: "year-control", children: [
|
117
|
+
/* @__PURE__ */ e(
|
118
|
+
"button",
|
119
|
+
{
|
120
|
+
className: "nav-button",
|
121
|
+
onClick: () => f("prev", "left"),
|
122
|
+
"aria-label": "Предыдущий год",
|
123
|
+
children: /* @__PURE__ */ e(v, {})
|
124
|
+
}
|
125
|
+
),
|
126
|
+
/* @__PURE__ */ e("span", { className: "current-year", children: s.format("YYYY") }),
|
127
|
+
/* @__PURE__ */ e(
|
128
|
+
"button",
|
129
|
+
{
|
130
|
+
className: "nav-button",
|
131
|
+
onClick: () => f("next", "left"),
|
132
|
+
"aria-label": "Следующий год",
|
133
|
+
children: /* @__PURE__ */ e(k, {})
|
134
|
+
}
|
135
|
+
)
|
136
|
+
] })
|
137
|
+
] }),
|
138
|
+
Y(s, "left")
|
139
|
+
] }),
|
140
|
+
/* @__PURE__ */ e("div", { className: "line" }),
|
141
|
+
/* @__PURE__ */ n("div", { children: [
|
142
|
+
/* @__PURE__ */ n("div", { className: "date-range-picker-section-period-month-year-block", children: [
|
143
|
+
/* @__PURE__ */ n("div", { className: "month-control", children: [
|
144
|
+
/* @__PURE__ */ e(
|
145
|
+
"button",
|
146
|
+
{
|
147
|
+
className: "nav-button",
|
148
|
+
onClick: () => y("prev"),
|
149
|
+
"aria-label": "Предыдущий месяц",
|
150
|
+
disabled: c.subtract(1, "month").isBefore(s),
|
151
|
+
children: /* @__PURE__ */ e(v, {})
|
152
|
+
}
|
153
|
+
),
|
154
|
+
/* @__PURE__ */ e("span", { className: "current-month", children: c.format("MMMM") }),
|
155
|
+
/* @__PURE__ */ e(
|
156
|
+
"button",
|
157
|
+
{
|
158
|
+
className: "nav-button",
|
159
|
+
onClick: () => y("next"),
|
160
|
+
"aria-label": "Следующий месяц",
|
161
|
+
children: /* @__PURE__ */ e(k, {})
|
162
|
+
}
|
163
|
+
)
|
164
|
+
] }),
|
165
|
+
/* @__PURE__ */ n("div", { className: "year-control", children: [
|
166
|
+
/* @__PURE__ */ e(
|
167
|
+
"button",
|
168
|
+
{
|
169
|
+
className: "nav-button",
|
170
|
+
onClick: () => f("prev", "right"),
|
171
|
+
"aria-label": "Предыдущий год",
|
172
|
+
children: /* @__PURE__ */ e(v, {})
|
173
|
+
}
|
174
|
+
),
|
175
|
+
/* @__PURE__ */ e("span", { className: "current-year", children: c.format("YYYY") }),
|
176
|
+
/* @__PURE__ */ e(
|
177
|
+
"button",
|
178
|
+
{
|
179
|
+
className: "nav-button",
|
180
|
+
onClick: () => f("next", "right"),
|
181
|
+
"aria-label": "Следующий год",
|
182
|
+
children: /* @__PURE__ */ e(k, {})
|
183
|
+
}
|
184
|
+
)
|
185
|
+
] })
|
186
|
+
] }),
|
187
|
+
Y(c, "right")
|
188
|
+
] })
|
189
|
+
] })
|
190
|
+
] }) })
|
191
|
+
] }) });
|
192
|
+
};
|
193
|
+
export {
|
194
|
+
re as DateRangePicker
|
195
|
+
};
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
2
|
+
import { DateRangePicker as a } from "./DateRangePicker.js";
|
3
|
+
import e from "../../../_virtual/dayjs.min.js";
|
4
|
+
const s = {
|
5
|
+
title: "UIKit/DateRangePicker",
|
6
|
+
component: a,
|
7
|
+
tags: ["autodocs"],
|
8
|
+
argTypes: {
|
9
|
+
disabledBefore: {
|
10
|
+
control: "text",
|
11
|
+
description: "Дизейбл до"
|
12
|
+
},
|
13
|
+
disabledAfter: {
|
14
|
+
control: "text",
|
15
|
+
description: "Дизейбл после"
|
16
|
+
},
|
17
|
+
className: {
|
18
|
+
control: "text",
|
19
|
+
description: "Класс для основного контейнера"
|
20
|
+
},
|
21
|
+
onChange: {
|
22
|
+
action: "dateChanged",
|
23
|
+
description: "Обработчик изменения даты"
|
24
|
+
},
|
25
|
+
placeholder: {
|
26
|
+
control: "text",
|
27
|
+
description: "Текст плейсхолдера"
|
28
|
+
},
|
29
|
+
autoCompleteWithToday: {
|
30
|
+
control: "boolean",
|
31
|
+
description: "Автозаполнение датой, если указали один не полностью"
|
32
|
+
},
|
33
|
+
initialRange: {
|
34
|
+
control: "object",
|
35
|
+
description: "Начальное состояние"
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}, d = {
|
39
|
+
args: {
|
40
|
+
placeholder: "Любая дата"
|
41
|
+
}
|
42
|
+
}, c = {
|
43
|
+
args: {
|
44
|
+
initialRange: {
|
45
|
+
start: e("2023-01-01"),
|
46
|
+
end: e()
|
47
|
+
},
|
48
|
+
placeholder: "Выберите дату"
|
49
|
+
}
|
50
|
+
}, p = {
|
51
|
+
args: {
|
52
|
+
disabledBefore: e(new Date(2023, 0, 1)),
|
53
|
+
disabledAfter: e(new Date(2023, 11, 31)),
|
54
|
+
placeholder: "Выберите дату в 2023 году"
|
55
|
+
}
|
56
|
+
}, g = {
|
57
|
+
args: {
|
58
|
+
disabledAfter: e(),
|
59
|
+
placeholder: "Выберите дату"
|
60
|
+
}
|
61
|
+
}, h = {
|
62
|
+
args: {
|
63
|
+
initialRange: {
|
64
|
+
start: e("2025-06-01"),
|
65
|
+
end: e("2025-06-15")
|
66
|
+
},
|
67
|
+
placeholder: "Выберите дату"
|
68
|
+
},
|
69
|
+
render: (t) => {
|
70
|
+
const o = {
|
71
|
+
...t,
|
72
|
+
initialRange: t.initialRange
|
73
|
+
};
|
74
|
+
return /* @__PURE__ */ i(a, { ...o });
|
75
|
+
}
|
76
|
+
};
|
77
|
+
export {
|
78
|
+
d as Default,
|
79
|
+
h as InitialDate,
|
80
|
+
p as WithDateRange,
|
81
|
+
g as WithDateRangeDisabledMonth,
|
82
|
+
c as WithInitialDate,
|
83
|
+
s as default
|
84
|
+
};
|
@@ -0,0 +1,37 @@
|
|
1
|
+
const e = [
|
2
|
+
{
|
3
|
+
label: "Сегодня",
|
4
|
+
key: "today"
|
5
|
+
},
|
6
|
+
{
|
7
|
+
label: "Вчера",
|
8
|
+
key: "yesterday"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
label: "Эта неделя",
|
12
|
+
key: "thisWeek"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
label: "Прошлая неделя",
|
16
|
+
key: "lastWeek"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
label: "Этот месяц",
|
20
|
+
key: "thisMonth"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
label: "Прошлый месяц",
|
24
|
+
key: "lastMonth"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
label: "Этот год",
|
28
|
+
key: "thisYear"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
label: "Прошлый год",
|
32
|
+
key: "lastYear"
|
33
|
+
}
|
34
|
+
];
|
35
|
+
export {
|
36
|
+
e as selectAutoCompliteDate
|
37
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
import { jsx as n, jsxs as u } from "react/jsx-runtime";
|
2
|
+
import D from "../../../../_virtual/dayjs.min.js";
|
3
|
+
const B = (o, S, d, i) => {
|
4
|
+
const $ = D();
|
5
|
+
return { renderCalendar: (a, C) => {
|
6
|
+
const e = a.startOf("month"), c = a.endOf("month"), O = c.date(), M = (e.day() + 6) % 7, r = [];
|
7
|
+
for (let t = M; t > 0; t--)
|
8
|
+
r.push(e.subtract(t, "day"));
|
9
|
+
for (let t = 0; t < O; t++)
|
10
|
+
r.push(e.add(t, "day"));
|
11
|
+
const N = Math.ceil(r.length / 7) * 7 - r.length;
|
12
|
+
for (let t = 1; t <= N; t++)
|
13
|
+
r.push(c.add(t, "day"));
|
14
|
+
const l = [];
|
15
|
+
for (let t = 0; t < r.length; t += 7)
|
16
|
+
l.push(r.slice(t, t + 7));
|
17
|
+
return /* @__PURE__ */ n("div", { className: "calendar-month", children: /* @__PURE__ */ u("table", { children: [
|
18
|
+
/* @__PURE__ */ n("thead", { children: /* @__PURE__ */ n("tr", { children: ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"].map((t) => /* @__PURE__ */ n("th", { children: t }, t)) }) }),
|
19
|
+
/* @__PURE__ */ n("tbody", { children: l.map((t, h) => /* @__PURE__ */ n("tr", { children: t.map((s, b) => {
|
20
|
+
var f, p;
|
21
|
+
if (!s || s.month() !== a.month())
|
22
|
+
return /* @__PURE__ */ n("td", { className: "other-month empty" }, `empty-${h}-${b}`);
|
23
|
+
const y = d && s.isBefore(d, "day") || i && s.isAfter(i, "day"), m = s.isSame($, "day"), j = (f = o.start) == null ? void 0 : f.isSame(s, "day"), k = (p = o.end) == null ? void 0 : p.isSame(s, "day"), v = o.start && o.end && s.isAfter(o.start, "day") && s.isBefore(o.end, "day");
|
24
|
+
return /* @__PURE__ */ u(
|
25
|
+
"td",
|
26
|
+
{
|
27
|
+
className: `
|
28
|
+
${y ? "disabled" : ""}
|
29
|
+
${m ? "today" : ""}
|
30
|
+
${j ? "selected-start" : ""}
|
31
|
+
${k ? "selected-end" : ""}
|
32
|
+
${v ? "in-range" : ""}
|
33
|
+
`,
|
34
|
+
onClick: () => !y && S(s, C),
|
35
|
+
children: [
|
36
|
+
s.date(),
|
37
|
+
m && /* @__PURE__ */ n("div", { className: "today-dot" })
|
38
|
+
]
|
39
|
+
},
|
40
|
+
s.toString()
|
41
|
+
);
|
42
|
+
}) }, h)) })
|
43
|
+
] }) });
|
44
|
+
} };
|
45
|
+
};
|
46
|
+
export {
|
47
|
+
B as useCalendarRenderer
|
48
|
+
};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import p from "../../../../_virtual/dayjs.min.js";
|
2
|
+
const j = (r, o, m, f, k, D, B, O, y, h, i) => ({ handleDateClick: (t, a) => {
|
3
|
+
if (!(y && t.isBefore(y, "day") || h && t.isAfter(h, "day")))
|
4
|
+
if (B(null), !r.start || r.start && r.end) {
|
5
|
+
if (o({ start: t, end: null }), a === "left") {
|
6
|
+
const s = t.add(1, "month").startOf("month");
|
7
|
+
s.isSame(k) ? f(s.add(1, "month")) : f(s);
|
8
|
+
}
|
9
|
+
} else
|
10
|
+
t.isBefore(r.start, "day") ? o({ start: t, end: r.start }) : o({ ...r, end: t }), i && i({
|
11
|
+
start: t.isBefore(r.start, "day") ? t : r.start,
|
12
|
+
end: t.isBefore(r.start, "day") ? r.start : t
|
13
|
+
});
|
14
|
+
}, handleClosePicker: () => {
|
15
|
+
if (D && r.start && !r.end) {
|
16
|
+
const t = p(), a = t.isAfter(r.start) ? t : r.start, s = {
|
17
|
+
start: r.start,
|
18
|
+
end: a
|
19
|
+
};
|
20
|
+
o(s), i && i(s);
|
21
|
+
const n = s.start.startOf("month"), u = a.startOf("month");
|
22
|
+
n.isSame(u) ? (m(n), f(n.add(1, "month"))) : (m(n), f(u));
|
23
|
+
}
|
24
|
+
O(!1);
|
25
|
+
} });
|
26
|
+
export {
|
27
|
+
j as useChangeDate
|
28
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
const m = (e, n, t, c) => ({
|
2
|
+
navigateLeftMonth: (s) => {
|
3
|
+
const a = s === "prev" ? e.subtract(1, "month") : e.add(1, "month");
|
4
|
+
(a.isSame(n) || a.isAfter(n)) && c(a.add(1, "month")), t(a);
|
5
|
+
},
|
6
|
+
navigateRightMonth: (s) => {
|
7
|
+
const a = s === "prev" ? n.subtract(1, "month") : n.add(1, "month");
|
8
|
+
(a.isSame(e) || a.isBefore(e)) && t(a.subtract(1, "month")), c(a);
|
9
|
+
},
|
10
|
+
navigateYear: (s, a) => {
|
11
|
+
if (a === "left") {
|
12
|
+
const r = s === "prev" ? e.subtract(1, "year") : e.add(1, "year");
|
13
|
+
t(r), r.isAfter(n) && c(r.add(1, "month"));
|
14
|
+
} else {
|
15
|
+
const r = s === "prev" ? n.subtract(1, "year") : n.add(1, "year");
|
16
|
+
c(r), r.isBefore(e) && t(r.subtract(1, "month"));
|
17
|
+
}
|
18
|
+
}
|
19
|
+
});
|
20
|
+
export {
|
21
|
+
m as useDateNavigation
|
22
|
+
};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { useState as d, useEffect as u } from "react";
|
2
|
+
import M from "../../../../_virtual/dayjs.min.js";
|
3
|
+
const a = (t) => {
|
4
|
+
const f = M(), [m, r] = d(f), [n, h] = d(f.add(1, "month")), [s, c] = d({
|
5
|
+
start: (t == null ? void 0 : t.start) || null,
|
6
|
+
end: (t == null ? void 0 : t.end) || null
|
7
|
+
});
|
8
|
+
return u(() => {
|
9
|
+
if (s.start && s.end) {
|
10
|
+
const e = s.start.startOf("month"), o = s.end.startOf("month");
|
11
|
+
e.isSame(o) ? (r(e), h(e.add(1, "month"))) : (e.isSame(m, "month") || r(e), !o.isSame(n, "month") && o.isAfter(e) && h(o));
|
12
|
+
}
|
13
|
+
}, [s]), {
|
14
|
+
leftMonth: m,
|
15
|
+
rightMonth: n,
|
16
|
+
setLeftMonth: r,
|
17
|
+
setRightMonth: h,
|
18
|
+
selectedRange: s,
|
19
|
+
setSelectedRange: c
|
20
|
+
};
|
21
|
+
};
|
22
|
+
export {
|
23
|
+
a as useDateRangeState
|
24
|
+
};
|