@stenajs-webui/calendar 17.13.0 → 17.13.3

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/index.es.js CHANGED
@@ -1,20 +1,21 @@
1
- (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("._calendar_1w0de_1{--swui-calendar-day-width: 40px;--swui-calendar-day-height: 38px;--swui-calendar-day-border-radius: 4px;--swui-calendar-week-number-bg-color: transparent;--swui-calendar-week-number-text-color: var(--lhds-color-ui-500);--swui-calendar-week-number-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-wrapper-selected-border: var(--swui-primary-action-color);--swui-calendar-wrapper-selected-background: var(--swui-primary-action-color);--swui-calendar-wrapper-range-border: var(--lhds-color-blue-100);--swui-calendar-wrapper-range-background: var(--lhds-color-blue-100);--swui-calendar-wrapper-today-border: var(--lhds-color-ui-200);--swui-calendar-wrapper-today-background: var(--lhds-color-ui-200);--swui-calendar-text-selected-color: #fff;--swui-calendar-text-disabled-color: var(--swui-text-disabled-color);--swui-calendar-text-in-other-month-color: var(--swui-text-disabled-color)}._calendar_1w0de_1 table{border-spacing:0 4px}._calendar_1w0de_1 span{line-height:100%}._calendar_1w0de_1 tr td:last-child{border-top-right-radius:var(--swui-calendar-day-border-radius);border-bottom-right-radius:var(--swui-calendar-day-border-radius)}._calendar_1w0de_1 tr td:nth-child(2){border-top-left-radius:var(--swui-calendar-day-border-radius);border-bottom-left-radius:var(--swui-calendar-day-border-radius)}._calendar_1w0de_1 td{padding:0;width:var(--swui-calendar-day-width);height:var(--swui-calendar-day-height)}._timePicker_1w05d_1{overflow:hidden;width:180px}._timePickerColumn_1w05d_6{overflow-y:hidden;flex:1}._timePickerColumn_1w05d_6:hover{overflow-y:scroll}")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();import { FlatButton, stenaAngleLeft, stenaAngleRight, PrimaryButton, stenaCalendar, Icon, stenaClock, stenaAngleDown, stenaArrowRight } from "@stenajs-webui/elements";
2
- import { Box, Text, Clickable, Row, Space, Spacing, Indent, Column, SeparatorLine, parseIntElseUndefined, useBoolean, useDelayedFalse } from "@stenajs-webui/core";
3
- import { isAfter, eachDayOfInterval, isSameDay, endOfMonth, startOfMonth, min, addDays, max, subDays, format, getISOWeek, getDate, startOfISOWeek, addWeeks, getMonth, getYear, getISODay, addHours, isBefore, parse, addMonths, addYears, subMonths, subYears, isValid } from "date-fns";
4
- import { last, chunk, range, debounce } from "lodash";
5
- import * as React from "react";
6
- import { useMemo, useCallback, useState, useEffect, useRef } from "react";
7
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
8
- import styled from "@emotion/styled";
9
- import { faAngleDoubleLeft } from "@fortawesome/free-solid-svg-icons/faAngleDoubleLeft";
10
- import { faAngleDoubleRight } from "@fortawesome/free-solid-svg-icons/faAngleDoubleRight";
11
- import { faCaretLeft } from "@fortawesome/free-solid-svg-icons/faCaretLeft";
12
- import { faCaretRight } from "@fortawesome/free-solid-svg-icons/faCaretRight";
13
- import { TextInput, TextInputBox } from "@stenajs-webui/forms";
14
- import { useTippyInstance, Popover } from "@stenajs-webui/tooltip";
15
- import { cssColor } from "@stenajs-webui/theme";
16
- import { faLongArrowAltRight } from "@fortawesome/free-solid-svg-icons/faLongArrowAltRight";
17
- const DateFormats = {
1
+ (function(){"use strict";try{var r=document.createElement("style");r.appendChild(document.createTextNode("._calendar_1w0de_1{--swui-calendar-day-width: 40px;--swui-calendar-day-height: 38px;--swui-calendar-day-border-radius: 4px;--swui-calendar-week-number-bg-color: transparent;--swui-calendar-week-number-text-color: var(--lhds-color-ui-500);--swui-calendar-week-number-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-text-color: var(--lhds-color-ui-500);--swui-calendar-week-day-clickable-text-color: var(--lhds-color-ui-500);--swui-calendar-wrapper-selected-border: var(--swui-primary-action-color);--swui-calendar-wrapper-selected-background: var(--swui-primary-action-color);--swui-calendar-wrapper-range-border: var(--lhds-color-blue-100);--swui-calendar-wrapper-range-background: var(--lhds-color-blue-100);--swui-calendar-wrapper-today-border: var(--lhds-color-ui-200);--swui-calendar-wrapper-today-background: var(--lhds-color-ui-200);--swui-calendar-text-selected-color: #fff;--swui-calendar-text-disabled-color: var(--swui-text-disabled-color);--swui-calendar-text-in-other-month-color: var(--swui-text-disabled-color)}._calendar_1w0de_1 table{border-spacing:0 4px}._calendar_1w0de_1 span{line-height:100%}._calendar_1w0de_1 tr td:last-child{border-top-right-radius:var(--swui-calendar-day-border-radius);border-bottom-right-radius:var(--swui-calendar-day-border-radius)}._calendar_1w0de_1 tr td:nth-child(2){border-top-left-radius:var(--swui-calendar-day-border-radius);border-bottom-left-radius:var(--swui-calendar-day-border-radius)}._calendar_1w0de_1 td{padding:0;width:var(--swui-calendar-day-width);height:var(--swui-calendar-day-height)}._timePicker_1w05d_1{overflow:hidden;width:180px}._timePickerColumn_1w05d_6{overflow-y:hidden;flex:1}._timePickerColumn_1w05d_6:hover{overflow-y:scroll}")),document.head.appendChild(r)}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import { FlatButton as T, stenaAngleLeft as Ot, stenaAngleRight as $t, PrimaryButton as lt, stenaCalendar as ht, Icon as qt, stenaClock as Qt, stenaAngleDown as De, stenaArrowRight as he } from "@stenajs-webui/elements";
3
+ import { Box as I, Text as et, Clickable as Pt, Row as R, Space as $, Spacing as ge, Indent as gt, Column as B, SeparatorLine as ye, parseIntElseUndefined as _t, useBoolean as Yt, useDelayedFalse as Lt } from "@stenajs-webui/core";
4
+ import { isAfter as nt, eachDayOfInterval as Bt, isSameDay as z, endOfMonth as Xt, startOfMonth as Zt, min as me, addDays as q, max as we, subDays as Dt, format as W, getISOWeek as pt, getDate as It, startOfISOWeek as pe, addWeeks as be, getMonth as tt, getYear as yt, getISODay as ke, addHours as Se, isBefore as Me, parse as ot, addMonths as Ee, addYears as Re, subMonths as Ae, subYears as Te, isValid as xe } from "date-fns";
5
+ import { last as Ce, chunk as Ft, range as zt, debounce as Ie } from "lodash";
6
+ import * as vt from "react";
7
+ import { useMemo as C, useCallback as g, useState as S, useEffect as Q, useRef as J } from "react";
8
+ import { jsx as i, jsxs as E, Fragment as mt } from "react/jsx-runtime";
9
+ import Nt from "@emotion/styled";
10
+ import { faAngleDoubleLeft as Vt } from "@fortawesome/free-solid-svg-icons/faAngleDoubleLeft";
11
+ import { faAngleDoubleRight as te } from "@fortawesome/free-solid-svg-icons/faAngleDoubleRight";
12
+ import { faCaretLeft as Ne } from "@fortawesome/free-solid-svg-icons/faCaretLeft";
13
+ import { faCaretRight as He } from "@fortawesome/free-solid-svg-icons/faCaretRight";
14
+ import { TextInput as rt, TextInputBox as Ye } from "@stenajs-webui/forms";
15
+ import { useTippyInstance as Le, Popover as bt } from "@stenajs-webui/tooltip";
16
+ import { cssColor as ee } from "@stenajs-webui/theme";
17
+ import { faLongArrowAltRight as Ue } from "@fortawesome/free-solid-svg-icons/faLongArrowAltRight";
18
+ const Z = {
18
19
  yearAndMonth: "yyyy-MM",
19
20
  fullDate: "yyyy-MM-dd",
20
21
  fullMonthName: "LLLL",
@@ -24,322 +25,222 @@ const DateFormats = {
24
25
  weekDayNameShort: "EEE",
25
26
  dateAndMonth: "d MMM",
26
27
  monthAndDate: "MMM do"
27
- };
28
- const buildDayStateForDateRange = (statePerMonth = {}, start, end) => {
29
- if (start && end && isAfter(end, start)) {
30
- return eachDayOfInterval({ start, end }).reduce((result, date) => {
31
- const isFirstInRange = isSameDay(date, start);
32
- const isLastInRange = isSameDay(date, end);
33
- const highlights = isFirstInRange ? ["selected", "selectedStart", "range"] : isLastInRange ? ["selected", "selectedEnd", "range"] : ["range"];
34
- return addDayStateHighlights(result, date, highlights);
35
- }, statePerMonth);
36
- }
37
- let state = statePerMonth;
38
- if (start) {
39
- state = addDayStateHighlights(state, start, ["selected", "singleSelected"]);
40
- }
41
- if (end) {
42
- state = addDayStateHighlights(state, end, ["selected", "singleSelected"]);
43
- }
44
- return state;
45
- };
46
- const buildDayStateForSingleMonth = (statePerMonth = {}, start, end, dateInFocus) => buildDayStateForRange(statePerMonth, start, end, startOfMonth(dateInFocus), endOfMonth(dateInFocus));
47
- const buildDayStateForRange = (statePerMonth = {}, start, end, startLimit, endLimit) => {
48
- if (start && end) {
49
- return buildDayStateForDateRange(statePerMonth, max([start, subDays(startLimit, 1)]), min([end, addDays(endLimit, 1)]));
50
- } else {
51
- return buildDayStateForDateRange(statePerMonth, start, end);
52
- }
53
- };
54
- const setDayStateValue = (state, date, values) => {
55
- const monthString = format(date, DateFormats.yearAndMonth);
56
- const weekNumber = getISOWeek(date);
57
- const dayInMonth = getDate(date);
28
+ }, wt = (t = {}, e, n) => {
29
+ if (e && n && nt(n, e))
30
+ return Bt({ start: e, end: n }).reduce(
31
+ (c, s) => {
32
+ const l = z(s, e), o = z(s, n);
33
+ return X(c, s, l ? ["selected", "selectedStart", "range"] : o ? ["selected", "selectedEnd", "range"] : ["range"]);
34
+ },
35
+ t
36
+ );
37
+ let r = t;
38
+ return e && (r = X(r, e, ["selected", "singleSelected"])), n && (r = X(r, n, ["selected", "singleSelected"])), r;
39
+ }, We = (t = {}, e, n, r) => Oe(
40
+ t,
41
+ e,
42
+ n,
43
+ Zt(r),
44
+ Xt(r)
45
+ ), Oe = (t = {}, e, n, r, c) => e && n ? wt(
46
+ t,
47
+ we([e, Dt(r, 1)]),
48
+ me([n, q(c, 1)])
49
+ ) : wt(t, e, n), ur = (t, e, n) => {
50
+ const r = W(e, Z.yearAndMonth), c = pt(e), s = It(e);
58
51
  return {
59
- ...state,
60
- [monthString]: {
61
- ...state && state[monthString],
62
- [weekNumber]: {
63
- ...state && state[monthString] && state[monthString][weekNumber],
64
- [dayInMonth]: {
65
- ...state && state[monthString] && state[monthString][weekNumber] && state[monthString][weekNumber][dayInMonth],
66
- ...values
52
+ ...t,
53
+ [r]: {
54
+ ...t && t[r],
55
+ [c]: {
56
+ ...t && t[r] && t[r][c],
57
+ [s]: {
58
+ ...t && t[r] && t[r][c] && t[r][c][s],
59
+ ...n
67
60
  }
68
61
  }
69
62
  }
70
63
  };
71
- };
72
- const setDayStateValueFunction = (state, date, setter) => {
73
- const monthString = format(date, DateFormats.yearAndMonth);
74
- const weekNumber = getISOWeek(date);
75
- const dayInMonth = getDate(date);
64
+ }, Dr = (t, e, n) => {
65
+ const r = W(e, Z.yearAndMonth), c = pt(e), s = It(e);
76
66
  return {
77
- ...state,
78
- [monthString]: {
79
- ...state && state[monthString],
80
- [weekNumber]: {
81
- ...state && state[monthString] && state[monthString][weekNumber],
82
- [dayInMonth]: {
83
- ...state && state[monthString] && state[monthString][weekNumber] && state[monthString][weekNumber][dayInMonth],
84
- ...setter(state && state[monthString] && state[monthString][weekNumber] && state[monthString][weekNumber][dayInMonth])
67
+ ...t,
68
+ [r]: {
69
+ ...t && t[r],
70
+ [c]: {
71
+ ...t && t[r] && t[r][c],
72
+ [s]: {
73
+ ...t && t[r] && t[r][c] && t[r][c][s],
74
+ ...n(
75
+ t && t[r] && t[r][c] && t[r][c][s]
76
+ )
85
77
  }
86
78
  }
87
79
  }
88
80
  };
89
- };
90
- const addDayStateHighlights = (calendarState, date, highlights) => {
91
- const month = date.getMonth() + 1;
92
- const monthString = `${date.getFullYear()}-${month < 10 ? "0" : ""}${month}`;
93
- const weekNumber = getISOWeek(date);
94
- const dayInMonth = getDate(date);
95
- const dayState = calendarState && calendarState[monthString] && calendarState[monthString][weekNumber] && calendarState[monthString][weekNumber][dayInMonth];
81
+ }, X = (t, e, n) => {
82
+ const r = e.getMonth() + 1, c = `${e.getFullYear()}-${r < 10 ? "0" : ""}${r}`, s = pt(e), l = It(e), o = t && t[c] && t[c][s] && t[c][s][l];
96
83
  return {
97
- ...calendarState,
98
- [monthString]: {
99
- ...calendarState && calendarState[monthString],
100
- [weekNumber]: {
101
- ...calendarState && calendarState[monthString] && calendarState[monthString][weekNumber],
102
- [dayInMonth]: addDayStateHighlightsOnSingleDay(dayState, highlights)
84
+ ...t,
85
+ [c]: {
86
+ ...t && t[c],
87
+ [s]: {
88
+ ...t && t[c] && t[c][s],
89
+ [l]: ne(o, n)
103
90
  }
104
91
  }
105
92
  };
106
- };
107
- const addDayStateHighlightsOnSingleDay = (dayState, highlights) => {
108
- var _a;
93
+ }, ne = (t, e) => {
94
+ var n;
109
95
  return {
110
- ...dayState,
111
- highlights: [...(_a = dayState == null ? void 0 : dayState.highlights) != null ? _a : [], ...highlights]
96
+ ...t,
97
+ highlights: [...(n = t == null ? void 0 : t.highlights) != null ? n : [], ...e]
112
98
  };
113
- };
114
- const addWeekStateHighlights = (calendarState, week, highlights) => {
115
- const date = week.days[0].date;
116
- const month = date.getMonth() + 1;
117
- const monthString = `${date.getFullYear()}-${month < 10 ? "0" : ""}${month}`;
118
- const weekNumber = week.weekNumber;
119
- let state = calendarState;
120
- week.days.forEach((day) => {
121
- state = addDayStateHighlights(state, day.date, highlights);
99
+ }, hr = (t, e, n) => {
100
+ const r = e.days[0].date, c = r.getMonth() + 1, s = `${r.getFullYear()}-${c < 10 ? "0" : ""}${c}`, l = e.weekNumber;
101
+ let o = t;
102
+ e.days.forEach((h) => {
103
+ o = X(o, h.date, n);
122
104
  });
123
- const weekState = state && state[monthString] ? state[monthString][weekNumber] : void 0;
124
- const newHighlights = weekState && weekState.highlights ? [...weekState.highlights, ...highlights] : highlights;
125
- const newWeekState = {
126
- ...weekState,
127
- highlights: newHighlights
105
+ const d = o && o[s] ? o[s][l] : void 0, a = d && d.highlights ? [...d.highlights, ...n] : n, f = {
106
+ ...d,
107
+ highlights: a
128
108
  };
129
109
  return {
130
- ...state,
131
- [monthString]: {
132
- ...calendarState && calendarState[monthString],
133
- [weekNumber]: newWeekState
110
+ ...o,
111
+ [s]: {
112
+ ...t && t[s],
113
+ [l]: f
134
114
  }
135
115
  };
136
- };
137
- const addWeekRangeHighlights = (calendarState, week) => {
138
- var _a;
139
- if (!week.days.length) {
140
- return { ...calendarState };
141
- }
142
- const startDate = week.days[0].date;
143
- const endDate = (_a = last(week.days)) == null ? void 0 : _a.date;
116
+ }, $e = (t, e) => {
117
+ var c;
118
+ if (!e.days.length)
119
+ return { ...t };
120
+ const n = e.days[0].date, r = (c = Ce(e.days)) == null ? void 0 : c.date;
144
121
  return {
145
- ...buildDayStateForDateRange(calendarState, startDate, endDate)
122
+ ...wt(t, n, r)
146
123
  };
147
- };
148
- const useHighlightToday = (enabled, statePerMonth) => {
149
- return useMemo(() => {
150
- return enabled ? addDayStateHighlights(statePerMonth, new Date(), ["today"]) : statePerMonth;
151
- }, [enabled, statePerMonth]);
152
- };
153
- var Month = /* @__PURE__ */ ((Month2) => {
154
- Month2[Month2["JANUARY"] = 0] = "JANUARY";
155
- Month2[Month2["FEBRUARY"] = 1] = "FEBRUARY";
156
- Month2[Month2["MARCH"] = 2] = "MARCH";
157
- Month2[Month2["APRIL"] = 3] = "APRIL";
158
- Month2[Month2["MAY"] = 4] = "MAY";
159
- Month2[Month2["JUNE"] = 5] = "JUNE";
160
- Month2[Month2["JULY"] = 6] = "JULY";
161
- Month2[Month2["AUGUST"] = 7] = "AUGUST";
162
- Month2[Month2["SEPTEMBER"] = 8] = "SEPTEMBER";
163
- Month2[Month2["OCTOBER"] = 9] = "OCTOBER";
164
- Month2[Month2["NOVEMBER"] = 10] = "NOVEMBER";
165
- Month2[Month2["DECEMBER"] = 11] = "DECEMBER";
166
- return Month2;
167
- })(Month || {});
168
- var WeekDay = /* @__PURE__ */ ((WeekDay2) => {
169
- WeekDay2[WeekDay2["SUNDAY"] = 0] = "SUNDAY";
170
- WeekDay2[WeekDay2["MONDAY"] = 1] = "MONDAY";
171
- WeekDay2[WeekDay2["TUESDAY"] = 2] = "TUESDAY";
172
- WeekDay2[WeekDay2["WEDNESDAY"] = 3] = "WEDNESDAY";
173
- WeekDay2[WeekDay2["THURSDAY"] = 4] = "THURSDAY";
174
- WeekDay2[WeekDay2["FRIDAY"] = 5] = "FRIDAY";
175
- WeekDay2[WeekDay2["SATURDAY"] = 6] = "SATURDAY";
176
- return WeekDay2;
177
- })(WeekDay || {});
178
- const getMonthsInYear = (year, startMonth, numMonths) => {
179
- const months = [];
180
- for (let i = 0; i < numMonths; i++) {
181
- months.push(getMonthInYear(year, startMonth + i));
182
- }
183
- return months;
184
- };
185
- const getMonthInYear = (year, month) => {
186
- const yearToUse = year + Math.floor(month / 12);
187
- const monthToUse = month % 12;
188
- const firstDayOfMonth = new Date(yearToUse, monthToUse, 1);
124
+ }, Pe = (t, e) => C(() => t ? X(e, new Date(), ["today"]) : e, [t, e]);
125
+ var U = /* @__PURE__ */ ((t) => (t[t.JANUARY = 0] = "JANUARY", t[t.FEBRUARY = 1] = "FEBRUARY", t[t.MARCH = 2] = "MARCH", t[t.APRIL = 3] = "APRIL", t[t.MAY = 4] = "MAY", t[t.JUNE = 5] = "JUNE", t[t.JULY = 6] = "JULY", t[t.AUGUST = 7] = "AUGUST", t[t.SEPTEMBER = 8] = "SEPTEMBER", t[t.OCTOBER = 9] = "OCTOBER", t[t.NOVEMBER = 10] = "NOVEMBER", t[t.DECEMBER = 11] = "DECEMBER", t))(U || {}), Be = /* @__PURE__ */ ((t) => (t[t.SUNDAY = 0] = "SUNDAY", t[t.MONDAY = 1] = "MONDAY", t[t.TUESDAY = 2] = "TUESDAY", t[t.WEDNESDAY = 3] = "WEDNESDAY", t[t.THURSDAY = 4] = "THURSDAY", t[t.FRIDAY = 5] = "FRIDAY", t[t.SATURDAY = 6] = "SATURDAY", t))(Be || {});
126
+ const Jt = (t, e, n) => {
127
+ const r = [];
128
+ for (let c = 0; c < n; c++)
129
+ r.push(re(t, e + c));
130
+ return r;
131
+ }, re = (t, e) => {
132
+ const n = t + Math.floor(e / 12), r = e % 12, c = new Date(n, r, 1);
189
133
  return {
190
- monthString: format(firstDayOfMonth, DateFormats.yearAndMonth),
191
- name: format(firstDayOfMonth, DateFormats.fullMonthName),
192
- year: yearToUse,
193
- monthInYear: monthToUse,
194
- weeks: getWeeksForMonth(yearToUse, monthToUse)
134
+ monthString: W(c, Z.yearAndMonth),
135
+ name: W(c, Z.fullMonthName),
136
+ year: n,
137
+ monthInYear: r,
138
+ weeks: ze(n, r)
195
139
  };
196
- };
197
- const getWeeksForMonth = (year, month, forceSixWeeks = true) => {
198
- const firstDayOfMonth = new Date(year, month, 1);
199
- const firstDayOfFirstWeek = startOfISOWeek(firstDayOfMonth);
200
- const weeks = [];
201
- for (let i = 0; i < 6; i++) {
202
- const week = getWeekForDate(addWeeks(firstDayOfFirstWeek, i));
203
- if (i > 0 && week.startMonth !== month && !forceSixWeeks) {
204
- return weeks;
205
- }
206
- weeks.push(week);
140
+ }, ze = (t, e, n = !0) => {
141
+ const r = new Date(t, e, 1), c = pe(r), s = [];
142
+ for (let l = 0; l < 6; l++) {
143
+ const o = jt(be(c, l));
144
+ if (l > 0 && o.startMonth !== e && !n)
145
+ return s;
146
+ s.push(o);
207
147
  }
208
- return weeks;
209
- };
210
- const getWeekForDate = (firstDayOfWeek) => {
211
- const isLastWeekOfMonth = getMonth(addDays(firstDayOfWeek, 7)) !== getMonth(firstDayOfWeek);
148
+ return s;
149
+ }, jt = (t) => {
150
+ const e = tt(q(t, 7)) !== tt(t);
212
151
  return {
213
- weekNumber: getISOWeek(firstDayOfWeek),
214
- startMonth: getMonth(firstDayOfWeek),
215
- startYear: getYear(firstDayOfWeek),
216
- endMonth: getMonth(addDays(firstDayOfWeek, 6)),
217
- endYear: getYear(addDays(firstDayOfWeek, 6)),
218
- days: getDaysForWeekForDate(firstDayOfWeek),
219
- isLastWeekOfMonth
152
+ weekNumber: pt(t),
153
+ startMonth: tt(t),
154
+ startYear: yt(t),
155
+ endMonth: tt(q(t, 6)),
156
+ endYear: yt(q(t, 6)),
157
+ days: _e(t),
158
+ isLastWeekOfMonth: e
220
159
  };
221
- };
222
- const createDay = (date) => {
223
- const dayOfWeek = getISODay(date);
160
+ }, je = (t) => {
161
+ const e = ke(t);
224
162
  return {
225
- date,
226
- name: format(date, "EEE"),
227
- dateString: format(addHours(date, 12), DateFormats.fullDate),
228
- weekNumber: getISOWeek(date),
229
- year: getYear(date),
230
- month: getMonth(date),
231
- dayOfMonth: getDate(date),
232
- dayOfWeek,
233
- isFirstDayOfWeek: dayOfWeek === 1,
234
- isLastDayOfWeek: dayOfWeek === 7,
235
- isFirstDayOfMonth: isSameDay(startOfMonth(date), date),
236
- isLastDayOfMonth: isSameDay(endOfMonth(date), date)
163
+ date: t,
164
+ name: W(t, "EEE"),
165
+ dateString: W(Se(t, 12), Z.fullDate),
166
+ weekNumber: pt(t),
167
+ year: yt(t),
168
+ month: tt(t),
169
+ dayOfMonth: It(t),
170
+ dayOfWeek: e,
171
+ isFirstDayOfWeek: e === 1,
172
+ isLastDayOfWeek: e === 7,
173
+ isFirstDayOfMonth: z(Zt(t), t),
174
+ isLastDayOfMonth: z(Xt(t), t)
237
175
  };
238
- };
239
- const getDaysForWeekForDate = (firstDayOfWeek) => {
240
- return eachDayOfInterval({
241
- start: firstDayOfWeek,
242
- end: addDays(firstDayOfWeek, 6)
243
- }).map(createDay);
244
- };
245
- const getStartDateOfISOWeek = (weekNumber, year) => {
246
- const simple = new Date(year, 0, 1 + (weekNumber - 1) * 7);
247
- const dayOfWeek = simple.getDay();
248
- const isoWeekStart = simple;
249
- if (dayOfWeek <= 4) {
250
- isoWeekStart.setDate(simple.getDate() - simple.getDay() + 1);
251
- } else {
252
- isoWeekStart.setDate(simple.getDate() + 8 - simple.getDay());
253
- }
254
- return isoWeekStart;
255
- };
256
- const calculateOverflowingMonth = (year, month) => {
257
- if (month > 11) {
258
- return { year: year + Math.floor(month / 12), month: month % 12 };
259
- }
260
- if (month < 0) {
261
- return { year: year + Math.floor(month / 12), month: 12 + month % 12 };
262
- }
263
- return { year, month };
264
- };
265
- const dayHasHighlight = (dayState, defaultHighlights, highlight) => {
266
- if (defaultHighlights && defaultHighlights.indexOf(highlight) >= 0) {
267
- return true;
268
- }
269
- if (dayState && dayState.highlights && dayState.highlights.indexOf(highlight) >= 0) {
270
- return true;
271
- }
272
- return false;
273
- };
274
- const dayHighlightSelect = (dayState, defaultHighlights, highlightsOrBoolean, returnValues, fallbackValue) => {
275
- if (highlightsOrBoolean.length !== returnValues.length) {
276
- throw new Error("Select highlight failed, number of values do not equal number of highlights.");
277
- }
278
- if (highlightsOrBoolean.length === 0) {
279
- return fallbackValue;
280
- }
281
- for (let i = 0; i < highlightsOrBoolean.length; i++) {
282
- if (typeof highlightsOrBoolean[i] === "boolean" && highlightsOrBoolean[i]) {
283
- return returnValues[i];
284
- }
285
- if (typeof highlightsOrBoolean[i] === "string" && dayHasHighlight(dayState, defaultHighlights, highlightsOrBoolean[i])) {
286
- return returnValues[i];
287
- }
288
- }
289
- return fallbackValue;
290
- };
291
- const defaultWrapperStyleProvider = ({
292
- selectedBackground,
293
- todayBackground,
294
- rangeBackground,
295
- borderColor = "transparent"
296
- }) => (defaultHighlights, dayState, day, _, month) => {
297
- let style = {};
298
- const backgroundColor = dayHighlightSelect(dayState, defaultHighlights, ["selected", "range", "today", day.month === month.monthInYear], [selectedBackground, rangeBackground, todayBackground, "#fff"], "transparent");
176
+ }, _e = (t) => Bt({
177
+ start: t,
178
+ end: q(t, 6)
179
+ }).map(je), Je = (t, e) => {
180
+ const n = new Date(e, 0, 1 + (t - 1) * 7), r = n.getDay(), c = n;
181
+ return r <= 4 ? c.setDate(n.getDate() - n.getDay() + 1) : c.setDate(n.getDate() + 8 - n.getDay()), c;
182
+ }, Ke = (t, e) => e > 11 ? { year: t + Math.floor(e / 12), month: e % 12 } : e < 0 ? { year: t + Math.floor(e / 12), month: 12 + e % 12 } : { year: t, month: e }, Ge = (t, e, n) => !!(e && e.indexOf(n) >= 0 || t && t.highlights && t.highlights.indexOf(n) >= 0), V = (t, e, n, r, c) => {
183
+ if (n.length !== r.length)
184
+ throw new Error(
185
+ "Select highlight failed, number of values do not equal number of highlights."
186
+ );
187
+ if (n.length === 0)
188
+ return c;
189
+ for (let s = 0; s < n.length; s++)
190
+ if (typeof n[s] == "boolean" && n[s] || typeof n[s] == "string" && Ge(
191
+ t,
192
+ e,
193
+ n[s]
194
+ ))
195
+ return r[s];
196
+ return c;
197
+ }, qe = ({
198
+ selectedBackground: t,
199
+ todayBackground: e,
200
+ rangeBackground: n,
201
+ borderColor: r = "transparent"
202
+ }) => (c, s, l, o, d) => {
203
+ let a = {};
204
+ const f = V(s, c, ["selected", "range", "today", l.month === d.monthInYear], [t, n, e, "#fff"], "transparent");
299
205
  return {
300
- ...style,
301
- backgroundColor,
302
- borderTopLeftRadius: dayHighlightSelect(dayState, defaultHighlights, ["selectedStart", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], borderColor),
303
- borderBottomLeftRadius: dayHighlightSelect(dayState, defaultHighlights, ["selectedStart", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], borderColor),
304
- borderTopRightRadius: dayHighlightSelect(dayState, defaultHighlights, ["selectedEnd", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], borderColor),
305
- borderBottomRightRadius: dayHighlightSelect(dayState, defaultHighlights, ["selectedEnd", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], borderColor),
206
+ ...a,
207
+ backgroundColor: f,
208
+ borderTopLeftRadius: V(s, c, ["selectedStart", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], r),
209
+ borderBottomLeftRadius: V(s, c, ["selectedStart", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], r),
210
+ borderTopRightRadius: V(s, c, ["selectedEnd", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], r),
211
+ borderBottomRightRadius: V(s, c, ["selectedEnd", "singleSelected"], ["var(--swui-calendar-day-border-radius)", "var(--swui-calendar-day-border-radius)"], r),
306
212
  boxSizing: "border-box"
307
213
  };
308
- };
309
- const defaultTextPropsProvider = ({
310
- selectedColor,
311
- disabledColor,
312
- inOtherMonthColor,
313
- rangeTextColor
314
- }) => {
315
- return (defaultHighlights, dayState, day, _, month) => {
316
- const isOtherMonth = day.month !== month.monthInYear;
317
- const color = dayHighlightSelect(dayState, defaultHighlights, [isOtherMonth, "selected", "range", "enabled", "disabled"], [inOtherMonthColor, selectedColor, rangeTextColor, void 0, disabledColor]);
318
- return {
319
- color
320
- };
214
+ }, Qe = ({
215
+ selectedColor: t,
216
+ disabledColor: e,
217
+ inOtherMonthColor: n,
218
+ rangeTextColor: r
219
+ }) => (c, s, l, o, d) => {
220
+ const a = l.month !== d.monthInYear;
221
+ return {
222
+ color: V(s, c, [a, "selected", "range", "enabled", "disabled"], [n, t, r, void 0, e])
321
223
  };
322
- };
323
- const defaultCalendarTheme = {
224
+ }, ct = {
324
225
  width: "var(--swui-calendar-day-width)",
325
226
  height: "var(--swui-calendar-day-height)",
326
227
  WeekNumber: {
327
228
  backgroundColor: "var(--swui-calendar-week-number-bg-color)",
328
229
  textColor: "var(--swui-calendar-week-number-text-color)",
329
230
  clickableTextColor: "var(--swui-calendar-week-number-clickable-text-color)",
330
- show: true
231
+ show: !0
331
232
  },
332
233
  WeekDay: {
333
234
  textColor: "var(--swui-calendar-week-day-text-color)",
334
235
  clickableTextColor: "var(--swui-calendar-week-day-clickable-text-color)"
335
236
  },
336
237
  CalendarDay: {
337
- tdStyle: defaultWrapperStyleProvider({
238
+ tdStyle: qe({
338
239
  selectedBackground: "var(--swui-calendar-wrapper-selected-background)",
339
240
  rangeBackground: "var(--swui-calendar-wrapper-range-background)",
340
241
  todayBackground: "var(--swui-calendar-wrapper-today-background)"
341
242
  }),
342
- textProps: defaultTextPropsProvider({
243
+ textProps: Qe({
343
244
  selectedColor: "var(--swui-calendar-text-selected-color)",
344
245
  disabledColor: "var(--swui-calendar-text-disabled-color)",
345
246
  inOtherMonthColor: "var(--swui-calendar-text-in-other-month-color)"
@@ -348,2533 +249,2145 @@ const defaultCalendarTheme = {
348
249
  CalendarMonth: {
349
250
  headerTextColor: "var(--swui-calendar-week-day-text-color)"
350
251
  }
351
- };
352
- const extranetCalendarTheme = {
353
- ...defaultCalendarTheme,
252
+ }, gr = {
253
+ ...ct,
354
254
  width: "37px",
355
255
  height: "37px"
356
- };
357
- const isDateInMinMaxRange = (date, min2, max2) => {
358
- if (min2 && isBefore(date, min2)) {
359
- return isSameDay(date, min2);
360
- }
361
- if (max2 && isAfter(date, max2)) {
362
- return isSameDay(date, max2);
363
- }
364
- return true;
365
- };
366
- const DisabledDayWrapper = function DisabledDayWrapper2({
367
- dayComponent: DayComponent,
368
- minDate,
369
- maxDate,
370
- dayState,
371
- day,
372
- ...props
256
+ }, Xe = (t, e, n) => e && Me(t, e) ? z(t, e) : n && nt(t, n) ? z(t, n) : !0, Ze = function({
257
+ dayComponent: e,
258
+ minDate: n,
259
+ maxDate: r,
260
+ dayState: c,
261
+ day: s,
262
+ ...l
373
263
  }) {
374
- const activeDayState = useMemo(() => !isDateInMinMaxRange(day.date, minDate, maxDate) ? addDayStateHighlightsOnSingleDay(dayState, ["disabled"]) : dayState, [day.date, dayState, maxDate, minDate]);
375
- return /* @__PURE__ */ jsx(DayComponent, {
376
- day,
377
- ...props,
378
- dayState: activeDayState
264
+ const o = C(() => Xe(s.date, n, r) ? c : ne(c, ["disabled"]), [s.date, c, r, n]);
265
+ return /* @__PURE__ */ i(e, {
266
+ day: s,
267
+ ...l,
268
+ dayState: o
379
269
  });
380
- };
381
- const WeekNumberCell = ({
382
- onClickWeek,
383
- theme,
384
- week,
385
- background,
386
- backgroundColor,
387
- prefix
270
+ }, Fe = ({
271
+ onClickWeek: t,
272
+ theme: e,
273
+ week: n,
274
+ background: r,
275
+ backgroundColor: c,
276
+ prefix: s
388
277
  }) => {
389
- const content = /* @__PURE__ */ jsxs(Box, {
390
- width: theme.width,
391
- height: theme.height,
278
+ const l = /* @__PURE__ */ E(I, {
279
+ width: e.width,
280
+ height: e.height,
392
281
  justifyContent: "center",
393
282
  alignItems: "center",
394
- children: [background && /* @__PURE__ */ jsx(Box, {
283
+ children: [r && /* @__PURE__ */ i(I, {
395
284
  position: "absolute",
396
- children: background
397
- }), /* @__PURE__ */ jsx(Box, {
285
+ children: r
286
+ }), /* @__PURE__ */ i(I, {
398
287
  position: "absolute",
399
- children: /* @__PURE__ */ jsxs(Text, {
400
- color: onClickWeek ? theme.WeekNumber.clickableTextColor : theme.WeekNumber.textColor,
401
- children: [prefix, week.weekNumber]
288
+ children: /* @__PURE__ */ E(et, {
289
+ color: t ? e.WeekNumber.clickableTextColor : e.WeekNumber.textColor,
290
+ children: [s, n.weekNumber]
402
291
  })
403
292
  })]
404
293
  });
405
- return /* @__PURE__ */ jsx(Box, {
406
- background: backgroundColor || theme.WeekNumber.backgroundColor,
294
+ return /* @__PURE__ */ i(I, {
295
+ background: c || e.WeekNumber.backgroundColor,
407
296
  position: "relative",
408
- children: onClickWeek ? /* @__PURE__ */ jsx(Clickable, {
297
+ children: t ? /* @__PURE__ */ i(Pt, {
409
298
  borderRadius: "var(--swui-calendar-day-border-radius)",
410
- onClick: (ev) => onClickWeek(week, ev),
411
- disableFocusHighlight: !onClickWeek,
412
- children: content
413
- }) : content
299
+ onClick: (o) => t(n, o),
300
+ disableFocusHighlight: !t,
301
+ children: l
302
+ }) : l
414
303
  });
415
304
  };
416
- function CalendarWeek({
417
- week,
418
- month,
419
- dayComponent,
420
- statePerWeekDay,
421
- userDataPerWeekDay,
422
- minDate,
423
- maxDate,
424
- onClickWeek,
425
- onClickDay,
426
- theme,
427
- renderWeekNumber,
428
- extraDayContent,
429
- defaultHighlights
305
+ function ve({
306
+ week: t,
307
+ month: e,
308
+ dayComponent: n,
309
+ statePerWeekDay: r,
310
+ userDataPerWeekDay: c,
311
+ minDate: s,
312
+ maxDate: l,
313
+ onClickWeek: o,
314
+ onClickDay: d,
315
+ theme: a,
316
+ renderWeekNumber: f,
317
+ extraDayContent: h,
318
+ defaultHighlights: u
430
319
  }) {
431
- return /* @__PURE__ */ jsxs("tr", {
432
- children: [theme.WeekNumber.show && /* @__PURE__ */ jsx("td", {
433
- children: renderWeekNumber ? renderWeekNumber(week, theme, onClickWeek) : /* @__PURE__ */ jsx(WeekNumberCell, {
434
- week,
435
- onClickWeek,
436
- theme
320
+ return /* @__PURE__ */ E("tr", {
321
+ children: [a.WeekNumber.show && /* @__PURE__ */ i("td", {
322
+ children: f ? f(t, a, o) : /* @__PURE__ */ i(Fe, {
323
+ week: t,
324
+ onClickWeek: o,
325
+ theme: a
437
326
  })
438
- }), week.days.map((day) => /* @__PURE__ */ jsx(DisabledDayWrapper, {
439
- dayComponent,
440
- day,
441
- week,
442
- month,
443
- dayState: statePerWeekDay && statePerWeekDay[day.dayOfMonth],
444
- userData: userDataPerWeekDay && userDataPerWeekDay[day.dayOfMonth],
445
- onClickDay,
446
- theme,
447
- extraDayContent,
448
- defaultHighlights,
449
- minDate,
450
- maxDate
451
- }, day.dateString))]
452
- }, week.weekNumber);
327
+ }), t.days.map((D) => /* @__PURE__ */ i(Ze, {
328
+ dayComponent: n,
329
+ day: D,
330
+ week: t,
331
+ month: e,
332
+ dayState: r && r[D.dayOfMonth],
333
+ userData: c && c[D.dayOfMonth],
334
+ onClickDay: d,
335
+ theme: a,
336
+ extraDayContent: h,
337
+ defaultHighlights: u,
338
+ minDate: s,
339
+ maxDate: l
340
+ }, D.dateString))]
341
+ }, t.weekNumber);
453
342
  }
454
- const WeekDayCell = ({
455
- onClickWeekDay,
456
- day,
457
- theme
343
+ const Ve = ({
344
+ onClickWeekDay: t,
345
+ day: e,
346
+ theme: n
458
347
  }) => {
459
- const content = /* @__PURE__ */ jsx(Box, {
460
- width: theme.width,
461
- height: theme.height,
348
+ const r = /* @__PURE__ */ i(I, {
349
+ width: n.width,
350
+ height: n.height,
462
351
  justifyContent: "center",
463
352
  alignItems: "center",
464
- children: /* @__PURE__ */ jsx(Text, {
353
+ children: /* @__PURE__ */ i(et, {
465
354
  size: "small",
466
- color: onClickWeekDay ? theme.WeekDay.clickableTextColor : theme.WeekDay.textColor,
467
- children: day.name
355
+ color: t ? n.WeekDay.clickableTextColor : n.WeekDay.textColor,
356
+ children: e.name
468
357
  })
469
358
  });
470
- if (onClickWeekDay) {
471
- return /* @__PURE__ */ jsx(Clickable, {
472
- borderRadius: "var(--swui-calendar-day-border-radius)",
473
- onClick: (ev) => onClickWeekDay(day.dayOfWeek, ev),
474
- disableFocusHighlight: !onClickWeekDay,
475
- children: content
476
- });
477
- }
478
- return content;
479
- };
480
- const CalendarDay = function CalendarDay2({
481
- day,
482
- week,
483
- month,
484
- dayState,
485
- userData,
486
- onClickDay,
487
- theme,
488
- extraDayContent: ExtraDayContent,
489
- defaultHighlights
359
+ return t ? /* @__PURE__ */ i(Pt, {
360
+ borderRadius: "var(--swui-calendar-day-border-radius)",
361
+ onClick: (c) => t(e.dayOfWeek, c),
362
+ disableFocusHighlight: !t,
363
+ children: r
364
+ }) : r;
365
+ }, ce = function({
366
+ day: e,
367
+ week: n,
368
+ month: r,
369
+ dayState: c,
370
+ userData: s,
371
+ onClickDay: l,
372
+ theme: o,
373
+ extraDayContent: d,
374
+ defaultHighlights: a
490
375
  }) {
491
- const content = /* @__PURE__ */ jsx(Box, {
376
+ const f = /* @__PURE__ */ i(I, {
492
377
  width: "100%",
493
378
  height: "100%",
494
379
  justifyContent: "center",
495
380
  alignItems: "center",
496
- children: /* @__PURE__ */ jsx(Text, {
497
- ...theme.CalendarDay.textProps && theme.CalendarDay.textProps(defaultHighlights, dayState, day, week, month, userData),
498
- children: day.dayOfMonth
381
+ children: /* @__PURE__ */ i(et, {
382
+ ...o.CalendarDay.textProps && o.CalendarDay.textProps(a, c, e, n, r, s),
383
+ children: e.dayOfMonth
499
384
  })
500
- });
501
- const WrapperTd = styled.td({
502
- ...theme.CalendarDay.tdStyle && theme.CalendarDay.tdStyle(defaultHighlights, dayState, day, week, month, userData)
503
- });
504
- const InnerWrapperDiv = styled.div({
505
- ...theme.CalendarDay.innerWrapperStyle && theme.CalendarDay.innerWrapperStyle(defaultHighlights, dayState, day, week, month, userData),
385
+ }), h = Nt.td({
386
+ ...o.CalendarDay.tdStyle && o.CalendarDay.tdStyle(a, c, e, n, r, s)
387
+ }), u = Nt.div({
388
+ ...o.CalendarDay.innerWrapperStyle && o.CalendarDay.innerWrapperStyle(a, c, e, n, r, s),
506
389
  width: "100%",
507
390
  height: "100%"
508
- });
509
- const CellWrapperDiv = styled.div({
510
- ...theme.CalendarDay.cellWrapperStyle && theme.CalendarDay.cellWrapperStyle(defaultHighlights, dayState, day, week, month, userData),
391
+ }), D = Nt.div({
392
+ ...o.CalendarDay.cellWrapperStyle && o.CalendarDay.cellWrapperStyle(a, c, e, n, r, s),
511
393
  width: "100%",
512
394
  height: "100%",
513
395
  position: "relative"
514
396
  });
515
- return /* @__PURE__ */ jsx(WrapperTd, {
516
- children: /* @__PURE__ */ jsx(InnerWrapperDiv, {
517
- children: /* @__PURE__ */ jsx(CellWrapperDiv, {
518
- children: day.month === month.monthInYear && /* @__PURE__ */ jsxs(Fragment, {
519
- children: [ExtraDayContent && /* @__PURE__ */ jsx(ExtraDayContent, {
520
- week,
521
- month,
522
- day,
523
- dayState,
524
- theme,
525
- userData
526
- }), onClickDay && isClickable(defaultHighlights, dayState) ? /* @__PURE__ */ jsx(Clickable, {
527
- onClick: (ev) => onClickDay(day, userData, ev),
397
+ return /* @__PURE__ */ i(h, {
398
+ children: /* @__PURE__ */ i(u, {
399
+ children: /* @__PURE__ */ i(D, {
400
+ children: e.month === r.monthInYear && /* @__PURE__ */ E(mt, {
401
+ children: [d && /* @__PURE__ */ i(d, {
402
+ week: n,
403
+ month: r,
404
+ day: e,
405
+ dayState: c,
406
+ theme: o,
407
+ userData: s
408
+ }), l && tn(a, c) ? /* @__PURE__ */ i(Pt, {
409
+ onClick: (m) => l(e, s, m),
528
410
  style: {
529
411
  width: "100%",
530
412
  height: "100%"
531
413
  },
532
414
  borderRadius: "var(--swui-calendar-day-border-radius)",
533
- children: content
534
- }) : /* @__PURE__ */ jsx(Fragment, {
535
- children: content
415
+ children: f
416
+ }) : /* @__PURE__ */ i(mt, {
417
+ children: f
536
418
  })]
537
419
  })
538
420
  })
539
421
  })
540
422
  });
541
- };
542
- const isClickable = (defaultHighlights, dayState) => !!dayHighlightSelect(dayState, defaultHighlights, ["enabled", "disabled"], [true, false], true);
543
- function CalendarMonth({
544
- month,
545
- dayComponent = CalendarDay,
546
- statePerWeek,
547
- userDataPerWeek,
548
- minDate,
549
- maxDate,
550
- onClickDay,
551
- onClickWeek,
552
- onClickWeekDay,
553
- onClickMonth,
554
- onClickYear,
555
- renderWeekNumber,
556
- renderWeekDay,
557
- headerLeftContent,
558
- headerRightContent,
559
- theme = defaultCalendarTheme,
560
- extraDayContent,
561
- defaultHighlights
423
+ }, tn = (t, e) => !!V(e, t, ["enabled", "disabled"], [!0, !1], !0);
424
+ function en({
425
+ month: t,
426
+ dayComponent: e = ce,
427
+ statePerWeek: n,
428
+ userDataPerWeek: r,
429
+ minDate: c,
430
+ maxDate: s,
431
+ onClickDay: l,
432
+ onClickWeek: o,
433
+ onClickWeekDay: d,
434
+ onClickMonth: a,
435
+ onClickYear: f,
436
+ renderWeekNumber: h,
437
+ renderWeekDay: u,
438
+ headerLeftContent: D,
439
+ headerRightContent: m,
440
+ theme: k = ct,
441
+ extraDayContent: p,
442
+ defaultHighlights: b
562
443
  }) {
563
- const showWeekNumber = theme.WeekNumber.show;
564
- return /* @__PURE__ */ jsx(Fragment, {
565
- children: /* @__PURE__ */ jsxs(Box, {
444
+ const w = k.WeekNumber.show;
445
+ return /* @__PURE__ */ i(mt, {
446
+ children: /* @__PURE__ */ E(I, {
566
447
  alignItems: "stretch",
567
- children: [/* @__PURE__ */ jsxs(Row, {
448
+ children: [/* @__PURE__ */ E(R, {
568
449
  justifyContent: "space-between",
569
450
  alignItems: "center",
570
451
  height: "32px",
571
- children: [/* @__PURE__ */ jsx(Box, {
452
+ children: [/* @__PURE__ */ i(I, {
572
453
  alignItems: "center",
573
- children: headerLeftContent
574
- }), /* @__PURE__ */ jsxs(Row, {
454
+ children: D
455
+ }), /* @__PURE__ */ E(R, {
575
456
  alignItems: "center",
576
- children: [/* @__PURE__ */ jsx(Row, {
457
+ children: [/* @__PURE__ */ i(R, {
577
458
  width: "104px",
578
459
  justifyContent: "center",
579
- children: onClickMonth ? /* @__PURE__ */ jsx(FlatButton, {
580
- onClick: () => onClickMonth(month),
581
- label: month.name
582
- }) : /* @__PURE__ */ jsx(Text, {
583
- children: month.name
460
+ children: a ? /* @__PURE__ */ i(T, {
461
+ onClick: () => a(t),
462
+ label: t.name
463
+ }) : /* @__PURE__ */ i(et, {
464
+ children: t.name
584
465
  })
585
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(Row, {
466
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(R, {
586
467
  width: "64px",
587
468
  justifyContent: "center",
588
- children: onClickYear ? /* @__PURE__ */ jsx(FlatButton, {
589
- onClick: () => onClickYear(month.year),
590
- label: String(month.year)
591
- }) : /* @__PURE__ */ jsx(Text, {
592
- children: month.year
469
+ children: f ? /* @__PURE__ */ i(T, {
470
+ onClick: () => f(t.year),
471
+ label: String(t.year)
472
+ }) : /* @__PURE__ */ i(et, {
473
+ children: t.year
593
474
  })
594
475
  })]
595
- }), /* @__PURE__ */ jsx(Box, {
476
+ }), /* @__PURE__ */ i(I, {
596
477
  alignItems: "center",
597
- children: headerRightContent
478
+ children: m
598
479
  })]
599
- }), /* @__PURE__ */ jsx("table", {
600
- children: /* @__PURE__ */ jsxs("tbody", {
601
- children: [/* @__PURE__ */ jsxs("tr", {
602
- children: [showWeekNumber && /* @__PURE__ */ jsx("td", {
603
- children: /* @__PURE__ */ jsx(Box, {
604
- width: theme.width,
605
- height: theme.height,
480
+ }), /* @__PURE__ */ i("table", {
481
+ children: /* @__PURE__ */ E("tbody", {
482
+ children: [/* @__PURE__ */ E("tr", {
483
+ children: [w && /* @__PURE__ */ i("td", {
484
+ children: /* @__PURE__ */ i(I, {
485
+ width: k.width,
486
+ height: k.height,
606
487
  justifyContent: "center",
607
488
  alignItems: "center",
608
- children: /* @__PURE__ */ jsx(Text, {
489
+ children: /* @__PURE__ */ i(et, {
609
490
  size: "small",
610
- color: theme.CalendarMonth.headerTextColor,
491
+ color: k.CalendarMonth.headerTextColor,
611
492
  children: "W"
612
493
  })
613
494
  })
614
- }), month.weeks[0].days.map((day) => /* @__PURE__ */ jsx("td", {
615
- children: renderWeekDay ? renderWeekDay(day.name, theme, onClickWeekDay) : /* @__PURE__ */ jsx(WeekDayCell, {
616
- day,
617
- onClickWeekDay,
618
- theme
495
+ }), t.weeks[0].days.map((y) => /* @__PURE__ */ i("td", {
496
+ children: u ? u(y.name, k, d) : /* @__PURE__ */ i(Ve, {
497
+ day: y,
498
+ onClickWeekDay: d,
499
+ theme: k
619
500
  })
620
- }, day.name))]
621
- }), month.weeks.map((week) => /* @__PURE__ */ jsx(CalendarWeek, {
622
- month,
623
- week,
624
- dayComponent,
625
- statePerWeekDay: statePerWeek && statePerWeek[week.weekNumber],
626
- userDataPerWeekDay: userDataPerWeek && userDataPerWeek[week.weekNumber],
627
- onClickDay,
628
- onClickWeek,
629
- theme,
630
- renderWeekNumber,
631
- extraDayContent,
632
- defaultHighlights,
633
- minDate,
634
- maxDate
635
- }, week.weekNumber))]
501
+ }, y.name))]
502
+ }), t.weeks.map((y) => /* @__PURE__ */ i(ve, {
503
+ month: t,
504
+ week: y,
505
+ dayComponent: e,
506
+ statePerWeekDay: n && n[y.weekNumber],
507
+ userDataPerWeekDay: r && r[y.weekNumber],
508
+ onClickDay: l,
509
+ onClickWeek: o,
510
+ theme: k,
511
+ renderWeekNumber: h,
512
+ extraDayContent: p,
513
+ defaultHighlights: b,
514
+ minDate: c,
515
+ maxDate: s
516
+ }, y.weekNumber))]
636
517
  })
637
518
  })]
638
519
  })
639
520
  });
640
521
  }
641
- const calendar = "_calendar_1w0de_1";
642
- var styles$1 = {
643
- calendar
644
- };
645
- function CalendarPanel({
646
- monthRows,
647
- dayComponent = CalendarDay,
648
- userDataPerMonth,
649
- statePerMonth,
650
- minDate,
651
- maxDate,
652
- onClickDay,
653
- onClickWeekDay,
654
- onClickWeek,
655
- onClickMonth,
656
- onClickYear,
657
- renderWeekDay,
658
- renderWeekNumber,
659
- headerLeftContent,
660
- headerRightContent,
661
- extraDayContent,
662
- defaultHighlights,
663
- theme = defaultCalendarTheme
522
+ const nn = "_calendar_1w0de_1", rn = {
523
+ calendar: nn
524
+ };
525
+ function cn({
526
+ monthRows: t,
527
+ dayComponent: e = ce,
528
+ userDataPerMonth: n,
529
+ statePerMonth: r,
530
+ minDate: c,
531
+ maxDate: s,
532
+ onClickDay: l,
533
+ onClickWeekDay: o,
534
+ onClickWeek: d,
535
+ onClickMonth: a,
536
+ onClickYear: f,
537
+ renderWeekDay: h,
538
+ renderWeekNumber: u,
539
+ headerLeftContent: D,
540
+ headerRightContent: m,
541
+ extraDayContent: k,
542
+ defaultHighlights: p,
543
+ theme: b = ct
664
544
  }) {
665
- const minDateObj = useMemo(() => minDate ? parse(minDate, "yyyy-MM-dd", new Date()) : void 0, [minDate]);
666
- const maxDateObj = useMemo(() => maxDate ? parse(maxDate, "yyyy-MM-dd", new Date()) : void 0, [maxDate]);
667
- return /* @__PURE__ */ jsx("div", {
668
- className: styles$1.calendar,
669
- children: monthRows.map((monthRow, rowIndex) => /* @__PURE__ */ jsx(Spacing, {
670
- children: /* @__PURE__ */ jsx(Row, {
671
- children: monthRow.map((month, index) => /* @__PURE__ */ jsxs(React.Fragment, {
672
- children: [index > 0 && /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(CalendarMonth, {
673
- month,
674
- dayComponent,
675
- userDataPerWeek: userDataPerMonth && userDataPerMonth[month.monthString],
676
- statePerWeek: statePerMonth && statePerMonth[month.monthString],
677
- onClickDay,
678
- onClickWeekDay,
679
- onClickWeek,
680
- onClickMonth,
681
- onClickYear,
682
- theme,
683
- renderWeekNumber,
684
- renderWeekDay,
685
- headerLeftContent,
686
- headerRightContent,
687
- extraDayContent,
688
- defaultHighlights,
689
- minDate: minDateObj,
690
- maxDate: maxDateObj
545
+ const w = C(() => c ? ot(c, "yyyy-MM-dd", new Date()) : void 0, [c]), y = C(() => s ? ot(s, "yyyy-MM-dd", new Date()) : void 0, [s]);
546
+ return /* @__PURE__ */ i("div", {
547
+ className: rn.calendar,
548
+ children: t.map((M, A) => /* @__PURE__ */ i(ge, {
549
+ children: /* @__PURE__ */ i(R, {
550
+ children: M.map((x, N) => /* @__PURE__ */ E(vt.Fragment, {
551
+ children: [N > 0 && /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(en, {
552
+ month: x,
553
+ dayComponent: e,
554
+ userDataPerWeek: n && n[x.monthString],
555
+ statePerWeek: r && r[x.monthString],
556
+ onClickDay: l,
557
+ onClickWeekDay: o,
558
+ onClickWeek: d,
559
+ onClickMonth: a,
560
+ onClickYear: f,
561
+ theme: b,
562
+ renderWeekNumber: u,
563
+ renderWeekDay: h,
564
+ headerLeftContent: D,
565
+ headerRightContent: m,
566
+ extraDayContent: k,
567
+ defaultHighlights: p,
568
+ minDate: w,
569
+ maxDate: y
691
570
  })]
692
- }, month.name))
571
+ }, x.name))
693
572
  })
694
- }, rowIndex))
573
+ }, A))
695
574
  });
696
575
  }
697
- function Calendar(props) {
698
- const initialDate = getInitialDate(props.year, props.month, props.date);
699
- const {
700
- year,
701
- month
702
- } = calculateOverflowingMonth(initialDate.year, initialDate.month);
703
- const monthRows = getMonthRows(year, month, props.numMonths, props.monthsPerRow);
704
- const statePerMonth = useHighlightToday(props.highlightToday, props.statePerMonth);
705
- return /* @__PURE__ */ jsx(CalendarPanel, {
706
- year,
707
- month,
708
- monthRows,
709
- ...props,
710
- statePerMonth
576
+ function Ut(t) {
577
+ const e = sn(t.year, t.month, t.date), {
578
+ year: n,
579
+ month: r
580
+ } = Ke(e.year, e.month), c = on(n, r, t.numMonths, t.monthsPerRow), s = Pe(t.highlightToday, t.statePerMonth);
581
+ return /* @__PURE__ */ i(cn, {
582
+ year: n,
583
+ month: r,
584
+ monthRows: c,
585
+ ...t,
586
+ statePerMonth: s
711
587
  });
712
588
  }
713
- const getInitialDate = (year, month, date) => {
714
- if (month && year) {
589
+ const sn = (t, e, n) => {
590
+ if (e && t)
715
591
  return {
716
- month,
717
- year
592
+ month: e,
593
+ year: t
718
594
  };
719
- }
720
- if (date) {
595
+ if (n)
721
596
  return {
722
- month: getMonth(date),
723
- year: getYear(date)
597
+ month: tt(n),
598
+ year: yt(n)
724
599
  };
725
- }
726
- const now = new Date();
600
+ const r = new Date();
727
601
  return {
728
- month: getMonth(now),
729
- year: getYear(now)
602
+ month: tt(r),
603
+ year: yt(r)
730
604
  };
731
- };
732
- const getMonthRows = (year, month, numMonths, monthsPerRow) => {
733
- if (numMonths == null) {
734
- return [[getMonthInYear(year, month)]];
735
- }
736
- if (monthsPerRow == null) {
737
- return [getMonthsInYear(year, month, numMonths)];
738
- }
739
- return chunk(getMonthsInYear(year, month, numMonths), monthsPerRow);
740
- };
741
- const useSelectedMonthStepperLogic = (dateInFocus, setDateInFocus, monthsPerRow, numMonths) => {
742
- const nextMonth = useCallback(() => {
743
- var _a;
744
- const d = addMonths(dateInFocus, (_a = monthsPerRow != null ? monthsPerRow : numMonths) != null ? _a : 1);
745
- setDateInFocus == null ? void 0 : setDateInFocus(d);
746
- }, [setDateInFocus, dateInFocus, monthsPerRow, numMonths]);
747
- const nextYear = useCallback(() => {
748
- const d = addYears(dateInFocus, 1);
749
- setDateInFocus == null ? void 0 : setDateInFocus(d);
750
- }, [setDateInFocus, dateInFocus]);
751
- const prevMonth = useCallback(() => {
752
- var _a;
753
- const d = subMonths(dateInFocus, (_a = monthsPerRow != null ? monthsPerRow : numMonths) != null ? _a : 1);
754
- setDateInFocus == null ? void 0 : setDateInFocus(d);
755
- }, [setDateInFocus, dateInFocus, monthsPerRow, numMonths]);
756
- const prevYear = useCallback(() => {
757
- const d = subYears(dateInFocus, 1);
758
- setDateInFocus == null ? void 0 : setDateInFocus(d);
759
- }, [setDateInFocus, dateInFocus]);
605
+ }, on = (t, e, n, r) => n == null ? [[re(t, e)]] : r == null ? [Jt(t, e, n)] : Ft(Jt(t, e, n), r), ln = (t, e, n, r) => {
606
+ const c = g(() => {
607
+ var a;
608
+ const d = Ee(t, (a = n != null ? n : r) != null ? a : 1);
609
+ e == null || e(d);
610
+ }, [e, t, n, r]), s = g(() => {
611
+ const d = Re(t, 1);
612
+ e == null || e(d);
613
+ }, [e, t]), l = g(() => {
614
+ var a;
615
+ const d = Ae(t, (a = n != null ? n : r) != null ? a : 1);
616
+ e == null || e(d);
617
+ }, [e, t, n, r]), o = g(() => {
618
+ const d = Te(t, 1);
619
+ e == null || e(d);
620
+ }, [e, t]);
760
621
  return {
761
- nextMonth,
762
- prevMonth,
763
- nextYear,
764
- prevYear
622
+ nextMonth: c,
623
+ prevMonth: l,
624
+ nextYear: s,
625
+ prevYear: o
765
626
  };
766
- };
767
- const WithMonthSwitcherBelow = ({
768
- children,
769
- prevMonth,
770
- nextMonth,
771
- prevYear,
772
- nextYear
773
- }) => /* @__PURE__ */ jsxs("div", {
774
- children: [children, /* @__PURE__ */ jsx(Indent, {
775
- children: /* @__PURE__ */ jsxs(Row, {
776
- children: [/* @__PURE__ */ jsx(FlatButton, {
777
- onClick: prevYear,
778
- leftIcon: faAngleDoubleLeft
779
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(FlatButton, {
780
- onClick: prevMonth,
781
- leftIcon: stenaAngleLeft
782
- }), /* @__PURE__ */ jsx(Indent, {
627
+ }, dn = ({
628
+ children: t,
629
+ prevMonth: e,
630
+ nextMonth: n,
631
+ prevYear: r,
632
+ nextYear: c
633
+ }) => /* @__PURE__ */ E("div", {
634
+ children: [t, /* @__PURE__ */ i(gt, {
635
+ children: /* @__PURE__ */ E(R, {
636
+ children: [/* @__PURE__ */ i(T, {
637
+ onClick: r,
638
+ leftIcon: Vt
639
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(T, {
640
+ onClick: e,
641
+ leftIcon: Ot
642
+ }), /* @__PURE__ */ i(gt, {
783
643
  num: 2
784
- }), /* @__PURE__ */ jsx(FlatButton, {
785
- onClick: nextMonth,
786
- leftIcon: stenaAngleRight
787
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(FlatButton, {
788
- onClick: nextYear,
789
- leftIcon: faAngleDoubleRight
644
+ }), /* @__PURE__ */ i(T, {
645
+ onClick: n,
646
+ leftIcon: $t
647
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(T, {
648
+ onClick: c,
649
+ leftIcon: te
790
650
  })]
791
651
  })
792
- }), /* @__PURE__ */ jsx(Space, {})]
793
- });
794
- const MonthPickerCell = ({
795
- value,
796
- onValueChange,
797
- month
652
+ }), /* @__PURE__ */ i($, {})]
653
+ }), an = ({
654
+ value: t,
655
+ onValueChange: e,
656
+ month: n
798
657
  }) => {
799
- const label = useMemo(() => {
800
- const now = new Date(2e3, month, 1);
801
- return format(now, "MMM");
802
- }, [month]);
803
- return /* @__PURE__ */ jsx(Row, {
658
+ const r = C(() => {
659
+ const c = new Date(2e3, n, 1);
660
+ return W(c, "MMM");
661
+ }, [n]);
662
+ return /* @__PURE__ */ i(R, {
804
663
  width: "64px",
805
664
  justifyContent: "center",
806
665
  spacing: 0.5,
807
666
  indent: 0.5,
808
- children: value === month ? /* @__PURE__ */ jsx(PrimaryButton, {
809
- label,
810
- onClick: () => onValueChange && onValueChange(month)
811
- }) : /* @__PURE__ */ jsx(FlatButton, {
812
- label,
813
- onClick: () => onValueChange && onValueChange(month)
667
+ children: t === n ? /* @__PURE__ */ i(lt, {
668
+ label: r,
669
+ onClick: () => e && e(n)
670
+ }) : /* @__PURE__ */ i(T, {
671
+ label: r,
672
+ onClick: () => e && e(n)
814
673
  })
815
674
  });
816
- };
817
- const monthMatrix = [[Month.JANUARY, Month.FEBRUARY, Month.MARCH], [Month.APRIL, Month.MAY, Month.JUNE], [Month.JULY, Month.AUGUST, Month.SEPTEMBER], [Month.OCTOBER, Month.NOVEMBER, Month.DECEMBER]];
818
- const MonthPicker = ({
819
- value,
820
- onValueChange
821
- }) => {
822
- return /* @__PURE__ */ jsx(Column, {
823
- children: monthMatrix.map((monthRow) => /* @__PURE__ */ jsx(Row, {
824
- children: monthRow.map((month) => /* @__PURE__ */ jsx(MonthPickerCell, {
825
- month,
826
- onValueChange,
827
- value
828
- }, month))
829
- }, monthRow[0]))
830
- });
831
- };
832
- const createStandardDateRangePresets = (now) => [
675
+ }, fn = [[U.JANUARY, U.FEBRUARY, U.MARCH], [U.APRIL, U.MAY, U.JUNE], [U.JULY, U.AUGUST, U.SEPTEMBER], [U.OCTOBER, U.NOVEMBER, U.DECEMBER]], un = ({
676
+ value: t,
677
+ onValueChange: e
678
+ }) => /* @__PURE__ */ i(B, {
679
+ children: fn.map((n) => /* @__PURE__ */ i(R, {
680
+ children: n.map((r) => /* @__PURE__ */ i(an, {
681
+ month: r,
682
+ onValueChange: e,
683
+ value: t
684
+ }, r))
685
+ }, n[0]))
686
+ }), Dn = (t) => [
833
687
  {
834
688
  label: "Past",
835
689
  presets: [
836
- { label: "Last 3 days", startDate: now, endDate: subDays(now, 2) },
837
- { label: "Last 7 days", startDate: now, endDate: subDays(now, 6) },
838
- { label: "Last 30 days", startDate: now, endDate: subDays(now, 29) },
839
- { label: "Last 45 days", startDate: now, endDate: subDays(now, 44) }
690
+ { label: "Last 3 days", startDate: t, endDate: Dt(t, 2) },
691
+ { label: "Last 7 days", startDate: t, endDate: Dt(t, 6) },
692
+ { label: "Last 30 days", startDate: t, endDate: Dt(t, 29) },
693
+ { label: "Last 45 days", startDate: t, endDate: Dt(t, 44) }
840
694
  ]
841
695
  },
842
696
  {
843
697
  label: "Future",
844
698
  presets: [
845
- { label: "Next 3 days", startDate: now, endDate: addDays(now, 2) },
846
- { label: "Next 7 days", startDate: now, endDate: addDays(now, 6) },
847
- { label: "Next 30 days", startDate: now, endDate: addDays(now, 29) },
848
- { label: "Next 45 days", startDate: now, endDate: addDays(now, 44) }
699
+ { label: "Next 3 days", startDate: t, endDate: q(t, 2) },
700
+ { label: "Next 7 days", startDate: t, endDate: q(t, 6) },
701
+ { label: "Next 30 days", startDate: t, endDate: q(t, 29) },
702
+ { label: "Next 45 days", startDate: t, endDate: q(t, 44) }
849
703
  ]
850
704
  }
851
- ];
852
- const PresetPicker = ({
853
- onClickPreset
705
+ ], hn = ({
706
+ onClickPreset: t
854
707
  }) => {
855
- var _a;
856
- const [pageIndex, setPageIndex] = useState(0);
857
- const pages = useMemo(() => createStandardDateRangePresets(new Date()), []);
858
- const currentPage = (_a = pages[pageIndex]) != null ? _a : pages[0];
859
- return /* @__PURE__ */ jsxs(Column, {
860
- children: [/* @__PURE__ */ jsxs(Row, {
708
+ var s;
709
+ const [e, n] = S(0), r = C(() => Dn(new Date()), []), c = (s = r[e]) != null ? s : r[0];
710
+ return /* @__PURE__ */ E(B, {
711
+ children: [/* @__PURE__ */ E(R, {
861
712
  justifyContent: "space-between",
862
713
  alignItems: "center",
863
714
  width: "200px",
864
- children: [/* @__PURE__ */ jsx(FlatButton, {
715
+ children: [/* @__PURE__ */ i(T, {
865
716
  size: "small",
866
- leftIcon: stenaAngleLeft,
867
- disabled: pageIndex === 0,
868
- onClick: () => setPageIndex(pageIndex - 1)
869
- }), /* @__PURE__ */ jsx(Text, {
870
- children: currentPage.label
871
- }), /* @__PURE__ */ jsx(FlatButton, {
717
+ leftIcon: Ot,
718
+ disabled: e === 0,
719
+ onClick: () => n(e - 1)
720
+ }), /* @__PURE__ */ i(et, {
721
+ children: c.label
722
+ }), /* @__PURE__ */ i(T, {
872
723
  size: "small",
873
- leftIcon: stenaAngleRight,
874
- disabled: pageIndex === pages.length - 1,
875
- onClick: () => setPageIndex(pageIndex + 1)
724
+ leftIcon: $t,
725
+ disabled: e === r.length - 1,
726
+ onClick: () => n(e + 1)
876
727
  })]
877
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(Column, {
728
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(B, {
878
729
  alignItems: "center",
879
- children: currentPage.presets.map((preset) => /* @__PURE__ */ jsxs(React.Fragment, {
880
- children: [/* @__PURE__ */ jsx(PrimaryButton, {
881
- label: preset.label,
882
- onClick: () => onClickPreset(preset)
883
- }), /* @__PURE__ */ jsx(Space, {})]
884
- }, preset.label))
730
+ children: c.presets.map((l) => /* @__PURE__ */ E(vt.Fragment, {
731
+ children: [/* @__PURE__ */ i(lt, {
732
+ label: l.label,
733
+ onClick: () => t(l)
734
+ }), /* @__PURE__ */ i($, {})]
735
+ }, l.label))
885
736
  })]
886
737
  });
887
- };
888
- const YearPickerCell = ({
889
- value,
890
- onValueChange,
891
- year
738
+ }, gn = ({
739
+ value: t,
740
+ onValueChange: e,
741
+ year: n
892
742
  }) => {
893
- const label = String(year);
894
- return /* @__PURE__ */ jsx(Row, {
743
+ const r = String(n);
744
+ return /* @__PURE__ */ i(R, {
895
745
  width: "64px",
896
746
  justifyContent: "center",
897
747
  spacing: 0.5,
898
748
  indent: 0.5,
899
- children: value === year ? /* @__PURE__ */ jsx(PrimaryButton, {
900
- label,
901
- onClick: () => onValueChange == null ? void 0 : onValueChange(year)
902
- }) : /* @__PURE__ */ jsx(FlatButton, {
903
- label,
904
- onClick: () => onValueChange == null ? void 0 : onValueChange(year)
749
+ children: t === n ? /* @__PURE__ */ i(lt, {
750
+ label: r,
751
+ onClick: () => e == null ? void 0 : e(n)
752
+ }) : /* @__PURE__ */ i(T, {
753
+ label: r,
754
+ onClick: () => e == null ? void 0 : e(n)
905
755
  })
906
756
  });
907
- };
908
- const YearPicker = ({
909
- value,
910
- onValueChange,
911
- initialLastYear
757
+ }, yn = ({
758
+ value: t,
759
+ onValueChange: e,
760
+ initialLastYear: n
912
761
  }) => {
913
- const [lastYear, setLastYear] = useState(() => {
914
- if (value) {
915
- return value + 4;
916
- }
917
- return initialLastYear != null ? initialLastYear : new Date().getFullYear() + 4;
918
- });
919
- const yearRows = useMemo(() => {
920
- const startYear = lastYear - 11;
921
- return chunk(range(startYear, lastYear + 1), 3);
922
- }, [lastYear]);
923
- useEffect(() => {
924
- setLastYear((prev) => calculateLastYearInFocus(value, prev));
925
- }, [value]);
926
- return /* @__PURE__ */ jsxs(Row, {
927
- children: [/* @__PURE__ */ jsx(Column, {
762
+ const [r, c] = S(() => t ? t + 4 : n != null ? n : new Date().getFullYear() + 4), s = C(() => {
763
+ const l = r - 11;
764
+ return Ft(zt(l, r + 1), 3);
765
+ }, [r]);
766
+ return Q(() => {
767
+ c((l) => mn(t, l));
768
+ }, [t]), /* @__PURE__ */ E(R, {
769
+ children: [/* @__PURE__ */ i(B, {
928
770
  justifyContent: "center",
929
- children: /* @__PURE__ */ jsx(FlatButton, {
930
- leftIcon: faCaretLeft,
931
- onClick: () => setLastYear(lastYear - 3)
771
+ children: /* @__PURE__ */ i(T, {
772
+ leftIcon: Ne,
773
+ onClick: () => c(r - 3)
932
774
  })
933
- }), /* @__PURE__ */ jsx(Column, {
934
- children: yearRows.map((yearRow) => /* @__PURE__ */ jsx(Row, {
935
- children: yearRow.map((year) => /* @__PURE__ */ jsx(YearPickerCell, {
936
- year,
937
- onValueChange,
938
- value
939
- }, year))
940
- }, yearRow[0]))
941
- }), /* @__PURE__ */ jsx(Column, {
775
+ }), /* @__PURE__ */ i(B, {
776
+ children: s.map((l) => /* @__PURE__ */ i(R, {
777
+ children: l.map((o) => /* @__PURE__ */ i(gn, {
778
+ year: o,
779
+ onValueChange: e,
780
+ value: t
781
+ }, o))
782
+ }, l[0]))
783
+ }), /* @__PURE__ */ i(B, {
942
784
  justifyContent: "center",
943
- children: /* @__PURE__ */ jsx(FlatButton, {
944
- leftIcon: faCaretRight,
945
- onClick: () => setLastYear(lastYear + 3)
785
+ children: /* @__PURE__ */ i(T, {
786
+ leftIcon: He,
787
+ onClick: () => c(r + 3)
946
788
  })
947
789
  })]
948
790
  });
949
- };
950
- const calculateLastYearInFocus = (value, lastYear) => {
951
- if (value == null) {
952
- return lastYear;
953
- }
954
- if (value > lastYear) {
955
- const yearDiff = value - lastYear;
956
- const remaining = yearDiff % 3;
957
- const yearsToAdd = yearDiff - remaining + 3;
958
- return lastYear + yearsToAdd;
791
+ }, mn = (t, e) => {
792
+ if (t == null)
793
+ return e;
794
+ if (t > e) {
795
+ const r = t - e, c = r % 3, s = r - c + 3;
796
+ return e + s;
959
797
  }
960
- const startYear = lastYear - 11;
961
- if (value < startYear) {
962
- const yearDiff = startYear - value;
963
- const remaining = yearDiff % 3;
964
- const yearsToSubtract = yearDiff - remaining + 3;
965
- return lastYear - yearsToSubtract;
798
+ const n = e - 11;
799
+ if (t < n) {
800
+ const r = n - t, c = r % 3, s = r - c + 3;
801
+ return e - s;
966
802
  }
967
- return lastYear;
968
- };
969
- const CalendarWithMonthYearPickers = function CalendarWithMonthYearPickers2({
970
- dateInFocus,
971
- setDateInFocus,
972
- currentPanel,
973
- setCurrentPanel,
974
- ...props
803
+ return e;
804
+ }, wn = function({
805
+ dateInFocus: e,
806
+ setDateInFocus: n,
807
+ currentPanel: r,
808
+ setCurrentPanel: c,
809
+ ...s
975
810
  }) {
976
- const onChangeSelectedMonth = useCallback((selectedMonth) => {
977
- const newDate = dateInFocus ? new Date(dateInFocus) : new Date();
978
- newDate.setMonth(selectedMonth);
979
- if (setDateInFocus) {
980
- setDateInFocus(newDate);
981
- }
982
- setCurrentPanel("calendar");
983
- }, [dateInFocus, setDateInFocus, setCurrentPanel]);
984
- const onChangeSelectedYear = useCallback((selectedYear) => {
985
- const newDate = dateInFocus ? new Date(dateInFocus) : new Date();
986
- newDate.setFullYear(selectedYear);
987
- if (setDateInFocus) {
988
- setDateInFocus(newDate);
989
- }
990
- setCurrentPanel("calendar");
991
- }, [dateInFocus, setDateInFocus, setCurrentPanel]);
992
- const onClickYear = useCallback(() => {
993
- setCurrentPanel("year");
994
- }, [setCurrentPanel]);
995
- const onClickMonth = useCallback(() => {
996
- setCurrentPanel("month");
997
- }, [setCurrentPanel]);
998
- switch (currentPanel) {
811
+ const l = g((f) => {
812
+ const h = e ? new Date(e) : new Date();
813
+ h.setMonth(f), n && n(h), c("calendar");
814
+ }, [e, n, c]), o = g((f) => {
815
+ const h = e ? new Date(e) : new Date();
816
+ h.setFullYear(f), n && n(h), c("calendar");
817
+ }, [e, n, c]), d = g(() => {
818
+ c("year");
819
+ }, [c]), a = g(() => {
820
+ c("month");
821
+ }, [c]);
822
+ switch (r) {
999
823
  case "calendar":
1000
- return /* @__PURE__ */ jsx(Fragment, {
1001
- children: /* @__PURE__ */ jsx(Calendar, {
1002
- ...props,
1003
- date: dateInFocus,
1004
- onClickYear,
1005
- onClickMonth
824
+ return /* @__PURE__ */ i(mt, {
825
+ children: /* @__PURE__ */ i(Ut, {
826
+ ...s,
827
+ date: e,
828
+ onClickYear: d,
829
+ onClickMonth: a
1006
830
  })
1007
831
  });
1008
832
  case "month":
1009
- return /* @__PURE__ */ jsx(MonthPicker, {
1010
- value: dateInFocus.getMonth(),
1011
- onValueChange: onChangeSelectedMonth
833
+ return /* @__PURE__ */ i(un, {
834
+ value: e.getMonth(),
835
+ onValueChange: l
1012
836
  });
1013
837
  case "year":
1014
- return /* @__PURE__ */ jsx(YearPicker, {
1015
- value: dateInFocus.getFullYear(),
1016
- onValueChange: onChangeSelectedYear
838
+ return /* @__PURE__ */ i(yn, {
839
+ value: e.getFullYear(),
840
+ onValueChange: o
1017
841
  });
1018
842
  case "presets":
1019
- return /* @__PURE__ */ jsx(PresetPicker, {
843
+ return /* @__PURE__ */ i(hn, {
1020
844
  onClickPreset: () => {
1021
845
  }
1022
846
  });
1023
847
  default:
1024
- return /* @__PURE__ */ jsx(Box, {
1025
- children: /* @__PURE__ */ jsx(PrimaryButton, {
848
+ return /* @__PURE__ */ i(I, {
849
+ children: /* @__PURE__ */ i(lt, {
1026
850
  label: "Show calendar",
1027
- onClick: () => setCurrentPanel("calendar")
851
+ onClick: () => c("calendar")
1028
852
  })
1029
853
  });
1030
854
  }
1031
- };
1032
- const noop = () => {
1033
- };
1034
- function CalendarWithMonthSwitcher({
1035
- monthSwitcherPlacement,
1036
- theme = defaultCalendarTheme,
1037
- dateInFocus,
1038
- setDateInFocus,
1039
- currentPanel,
1040
- setCurrentPanel,
1041
- onSelectPreset = noop,
1042
- hideYearPagination = false,
1043
- ...calendarProps
855
+ }, pn = () => {
856
+ };
857
+ function F({
858
+ monthSwitcherPlacement: t,
859
+ theme: e = ct,
860
+ dateInFocus: n,
861
+ setDateInFocus: r,
862
+ currentPanel: c,
863
+ setCurrentPanel: s,
864
+ onSelectPreset: l = pn,
865
+ hideYearPagination: o = !1,
866
+ ...d
1044
867
  }) {
1045
868
  const {
1046
- nextMonth,
1047
- prevMonth,
1048
- nextYear,
1049
- prevYear
1050
- } = useSelectedMonthStepperLogic(dateInFocus, setDateInFocus, calendarProps.monthsPerRow, calendarProps.numMonths);
1051
- const placement = fallbackIfNoPlacement(monthSwitcherPlacement, calendarProps.numMonths);
1052
- switch (placement) {
1053
- case "below": {
1054
- return /* @__PURE__ */ jsx(WithMonthSwitcherBelow, {
1055
- theme,
1056
- nextMonth,
1057
- prevMonth,
1058
- nextYear,
1059
- prevYear,
1060
- children: /* @__PURE__ */ jsx(Calendar, {
1061
- ...calendarProps,
1062
- theme,
1063
- date: dateInFocus
869
+ nextMonth: a,
870
+ prevMonth: f,
871
+ nextYear: h,
872
+ prevYear: u
873
+ } = ln(n, r, d.monthsPerRow, d.numMonths);
874
+ switch (bn(t, d.numMonths)) {
875
+ case "below":
876
+ return /* @__PURE__ */ i(dn, {
877
+ theme: e,
878
+ nextMonth: a,
879
+ prevMonth: f,
880
+ nextYear: h,
881
+ prevYear: u,
882
+ children: /* @__PURE__ */ i(Ut, {
883
+ ...d,
884
+ theme: e,
885
+ date: n
1064
886
  })
1065
887
  });
1066
- }
1067
- case "header": {
1068
- return /* @__PURE__ */ jsx(Column, {
1069
- children: /* @__PURE__ */ jsx(CalendarWithMonthYearPickers, {
1070
- ...calendarProps,
1071
- theme,
1072
- dateInFocus,
1073
- setDateInFocus,
1074
- currentPanel,
1075
- setCurrentPanel,
1076
- onSelectPreset,
1077
- headerLeftContent: /* @__PURE__ */ jsxs(Row, {
888
+ case "header":
889
+ return /* @__PURE__ */ i(B, {
890
+ children: /* @__PURE__ */ i(wn, {
891
+ ...d,
892
+ theme: e,
893
+ dateInFocus: n,
894
+ setDateInFocus: r,
895
+ currentPanel: c,
896
+ setCurrentPanel: s,
897
+ onSelectPreset: l,
898
+ headerLeftContent: /* @__PURE__ */ E(R, {
1078
899
  alignItems: "center",
1079
- children: [!hideYearPagination && /* @__PURE__ */ jsx(FlatButton, {
900
+ children: [!o && /* @__PURE__ */ i(T, {
1080
901
  size: "small",
1081
- onClick: prevYear,
1082
- leftIcon: faAngleDoubleLeft
1083
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(FlatButton, {
902
+ onClick: u,
903
+ leftIcon: Vt
904
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(T, {
1084
905
  size: "small",
1085
- onClick: prevMonth,
1086
- leftIcon: stenaAngleLeft
906
+ onClick: f,
907
+ leftIcon: Ot
1087
908
  })]
1088
909
  }),
1089
- headerRightContent: /* @__PURE__ */ jsxs(Row, {
910
+ headerRightContent: /* @__PURE__ */ E(R, {
1090
911
  alignItems: "center",
1091
- children: [/* @__PURE__ */ jsx(FlatButton, {
912
+ children: [/* @__PURE__ */ i(T, {
1092
913
  size: "small",
1093
- onClick: nextMonth,
1094
- leftIcon: stenaAngleRight
1095
- }), /* @__PURE__ */ jsx(Space, {}), !hideYearPagination && /* @__PURE__ */ jsx(FlatButton, {
914
+ onClick: a,
915
+ leftIcon: $t
916
+ }), /* @__PURE__ */ i($, {}), !o && /* @__PURE__ */ i(T, {
1096
917
  size: "small",
1097
- onClick: nextYear,
1098
- leftIcon: faAngleDoubleRight
918
+ onClick: h,
919
+ leftIcon: te
1099
920
  })]
1100
921
  })
1101
922
  })
1102
923
  });
1103
- }
1104
- default: {
1105
- return /* @__PURE__ */ jsx(Calendar, {
1106
- ...calendarProps,
1107
- theme,
1108
- date: dateInFocus
924
+ default:
925
+ return /* @__PURE__ */ i(Ut, {
926
+ ...d,
927
+ theme: e,
928
+ date: n
1109
929
  });
1110
- }
1111
930
  }
1112
931
  }
1113
- const fallbackIfNoPlacement = (monthSwitcherPlacement, numMonths) => {
1114
- return monthSwitcherPlacement || (numMonths || 1) > 1 ? "below" : "header";
1115
- };
1116
- const dateRangeToStrings = (dateRange) => ({
1117
- startDate: dateRange.startDate ? format(dateRange.startDate, "yyyy-MM-dd") : void 0,
1118
- endDate: dateRange.endDate ? format(dateRange.endDate, "yyyy-MM-dd") : void 0
1119
- });
1120
- const stringsToDateRange = ({
1121
- startDate,
1122
- endDate
932
+ const bn = (t, e) => t || (e || 1) > 1 ? "below" : "header", kn = (t) => ({
933
+ startDate: t.startDate ? W(t.startDate, "yyyy-MM-dd") : void 0,
934
+ endDate: t.endDate ? W(t.endDate, "yyyy-MM-dd") : void 0
935
+ }), Sn = ({
936
+ startDate: t,
937
+ endDate: e
1123
938
  }) => {
1124
- const now = new Date();
939
+ const n = new Date();
1125
940
  return {
1126
- startDate: startDate ? parse(startDate, "yyyy-MM-dd", now) : void 0,
1127
- endDate: endDate ? parse(endDate, "yyyy-MM-dd", now) : void 0
941
+ startDate: t ? ot(t, "yyyy-MM-dd", n) : void 0,
942
+ endDate: e ? ot(e, "yyyy-MM-dd", n) : void 0
1128
943
  };
1129
- };
1130
- const isDateRangeInvalid = ({
1131
- startDate,
1132
- endDate
1133
- }) => Boolean(startDate && endDate && !isSameDay(startDate, endDate) && isAfter(startDate, endDate));
1134
- const toggleDatesIfEndIsEarlierThanStart = (dateRange) => {
1135
- if (isDateRangeInvalid(dateRange)) {
1136
- return {
1137
- startDate: dateRange.endDate,
1138
- endDate: dateRange.startDate
1139
- };
1140
- }
1141
- return dateRange;
1142
- };
1143
- const toggleDateStringsIfEndIsEarlierThanStart = (dateRange) => {
1144
- if (dateRange.startDate && dateRange.endDate) {
1145
- return dateRangeToStrings(toggleDatesIfEndIsEarlierThanStart(stringsToDateRange(dateRange)));
1146
- }
1147
- return dateRange;
1148
- };
1149
- const useDateRangeOnClickDayHandler = (value, onValueChange, focusedInput, setFocusedInput) => {
1150
- return useCallback((day) => {
1151
- const dateRange = {
1152
- startDate: focusedInput === "startDate" ? day.date : value == null ? void 0 : value.startDate,
1153
- endDate: focusedInput === "endDate" ? day.date : value == null ? void 0 : value.endDate
944
+ }, se = ({
945
+ startDate: t,
946
+ endDate: e
947
+ }) => Boolean(
948
+ t && e && !z(t, e) && nt(t, e)
949
+ ), ie = (t) => se(t) ? {
950
+ startDate: t.endDate,
951
+ endDate: t.startDate
952
+ } : t, yr = (t) => t.startDate && t.endDate ? kn(
953
+ ie(Sn(t))
954
+ ) : t, oe = (t, e, n, r) => g(
955
+ (c) => {
956
+ const s = {
957
+ startDate: n === "startDate" ? c.date : t == null ? void 0 : t.startDate,
958
+ endDate: n === "endDate" ? c.date : t == null ? void 0 : t.endDate
1154
959
  };
1155
- if (!isDateRangeInvalid(dateRange)) {
1156
- setFocusedInput(focusedInput === "startDate" ? "endDate" : "startDate");
1157
- }
1158
- onValueChange == null ? void 0 : onValueChange(toggleDatesIfEndIsEarlierThanStart(dateRange));
1159
- }, [
1160
- focusedInput,
1161
- onValueChange,
1162
- setFocusedInput,
1163
- value == null ? void 0 : value.endDate,
1164
- value == null ? void 0 : value.startDate
1165
- ]);
1166
- };
1167
- const useInternalPanelState = (onChangePanel) => {
1168
- const [currentPanel, _setCurrentPanel] = useState("calendar");
1169
- const setCurrentPanel = useCallback((currentPanel2) => {
1170
- _setCurrentPanel(currentPanel2);
1171
- onChangePanel == null ? void 0 : onChangePanel(currentPanel2);
1172
- }, [onChangePanel]);
960
+ se(s) || r(n === "startDate" ? "endDate" : "startDate"), e == null || e(ie(s));
961
+ },
962
+ [
963
+ n,
964
+ e,
965
+ r,
966
+ t == null ? void 0 : t.endDate,
967
+ t == null ? void 0 : t.startDate
968
+ ]
969
+ ), kt = (t) => {
970
+ const [e, n] = S("calendar"), r = g((c) => {
971
+ n(c), t == null || t(c);
972
+ }, [t]);
1173
973
  return {
1174
- currentPanel,
1175
- setCurrentPanel
974
+ currentPanel: e,
975
+ setCurrentPanel: r
1176
976
  };
1177
- };
1178
- const useDateRangeSelection = ({
1179
- focusedInput,
1180
- value,
1181
- onValueChange,
1182
- setFocusedInput,
1183
- statePerMonth,
1184
- onChangePanel
977
+ }, Mn = ({
978
+ focusedInput: t,
979
+ value: e,
980
+ onValueChange: n,
981
+ setFocusedInput: r,
982
+ statePerMonth: c,
983
+ onChangePanel: s
1185
984
  }) => {
1186
- const { currentPanel, setCurrentPanel } = useInternalPanelState(onChangePanel);
1187
- const [dateInFocus, setDateInFocus] = useState(() => new Date());
1188
- const onClickDay = useDateRangeOnClickDayHandler(value, onValueChange, focusedInput, setFocusedInput);
1189
- const statePerMonthWithSelection = useMemo(() => buildDayStateForDateRange(statePerMonth, value == null ? void 0 : value.startDate, value == null ? void 0 : value.endDate), [statePerMonth, value == null ? void 0 : value.endDate, value == null ? void 0 : value.startDate]);
985
+ const { currentPanel: l, setCurrentPanel: o } = kt(s), [d, a] = S(() => new Date()), f = oe(
986
+ e,
987
+ n,
988
+ t,
989
+ r
990
+ ), h = C(
991
+ () => wt(
992
+ c,
993
+ e == null ? void 0 : e.startDate,
994
+ e == null ? void 0 : e.endDate
995
+ ),
996
+ [c, e == null ? void 0 : e.endDate, e == null ? void 0 : e.startDate]
997
+ );
1190
998
  return {
1191
- onClickDay,
1192
- statePerMonth: statePerMonthWithSelection,
1193
- currentPanel,
1194
- setCurrentPanel,
1195
- setDateInFocus,
1196
- dateInFocus
999
+ onClickDay: f,
1000
+ statePerMonth: h,
1001
+ currentPanel: l,
1002
+ setCurrentPanel: o,
1003
+ setDateInFocus: a,
1004
+ dateInFocus: d
1197
1005
  };
1198
1006
  };
1199
- function DateRangeCalendar(props) {
1200
- const dateRangeSelectionProps = useDateRangeSelection(props);
1201
- return /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
1202
- ...props,
1203
- ...dateRangeSelectionProps
1007
+ function mr(t) {
1008
+ const e = Mn(t);
1009
+ return /* @__PURE__ */ i(F, {
1010
+ ...t,
1011
+ ...e
1204
1012
  });
1205
1013
  }
1206
- const useDateRangeCalendarState = () => {
1207
- const [startDate, setStartDate] = useState();
1208
- const [endDate, setEndDate] = useState();
1209
- const [focusedInput, setFocusedInput] = useState("startDate");
1014
+ const wr = () => {
1015
+ const [t, e] = S(), [n, r] = S(), [c, s] = S("startDate");
1210
1016
  return {
1211
- startDate,
1212
- setStartDate,
1213
- endDate,
1214
- setEndDate,
1215
- focusedInput,
1216
- setFocusedInput
1017
+ startDate: t,
1018
+ setStartDate: e,
1019
+ endDate: n,
1020
+ setEndDate: r,
1021
+ focusedInput: c,
1022
+ setFocusedInput: s
1217
1023
  };
1218
- };
1219
- const useSingleDateSelection = ({
1220
- onChange,
1221
- value,
1222
- statePerMonth,
1223
- onChangePanel
1024
+ }, En = ({
1025
+ onChange: t,
1026
+ value: e,
1027
+ statePerMonth: n,
1028
+ onChangePanel: r
1224
1029
  }) => {
1225
- const { currentPanel, setCurrentPanel } = useInternalPanelState(onChangePanel);
1226
- const [dateInFocus, setDateInFocus] = useState(() => value != null ? value : new Date());
1227
- const onClickDay = useCallback((day) => {
1228
- if (onChange) {
1229
- onChange(day.date);
1230
- }
1231
- }, [onChange]);
1232
- const statePerMonthWithSelectedDate = useMemo(() => value ? addDayStateHighlights(statePerMonth, value, [
1233
- "selected",
1234
- "singleSelected"
1235
- ]) : statePerMonth, [statePerMonth, value]);
1030
+ const { currentPanel: c, setCurrentPanel: s } = kt(r), [l, o] = S(() => e != null ? e : new Date()), d = g(
1031
+ (f) => {
1032
+ t && t(f.date);
1033
+ },
1034
+ [t]
1035
+ ), a = C(
1036
+ () => e ? X(n, e, [
1037
+ "selected",
1038
+ "singleSelected"
1039
+ ]) : n,
1040
+ [n, e]
1041
+ );
1236
1042
  return {
1237
- onClickDay,
1238
- statePerMonth: statePerMonthWithSelectedDate,
1239
- date: value,
1240
- currentPanel,
1241
- setCurrentPanel,
1242
- dateInFocus,
1243
- setDateInFocus
1043
+ onClickDay: d,
1044
+ statePerMonth: a,
1045
+ date: e,
1046
+ currentPanel: c,
1047
+ setCurrentPanel: s,
1048
+ dateInFocus: l,
1049
+ setDateInFocus: o
1244
1050
  };
1245
1051
  };
1246
- function SingleDateCalendar(props) {
1247
- const singleDateSelectionProps = useSingleDateSelection(props);
1248
- return /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
1249
- ...props,
1250
- ...singleDateSelectionProps
1052
+ function le(t) {
1053
+ const e = En(t);
1054
+ return /* @__PURE__ */ i(F, {
1055
+ ...t,
1056
+ ...e
1251
1057
  });
1252
1058
  }
1253
- const useMultiDateSelection = ({
1254
- onChange,
1255
- value,
1256
- statePerMonth,
1257
- onChangePanel
1059
+ const Rn = ({
1060
+ onChange: t,
1061
+ value: e,
1062
+ statePerMonth: n,
1063
+ onChangePanel: r
1258
1064
  }) => {
1259
- const { currentPanel, setCurrentPanel } = useInternalPanelState(onChangePanel);
1260
- const [dateInFocus, setDateInFocus] = useState(() => new Date());
1261
- const onClickDay = useCallback((day) => {
1262
- if (!onChange) {
1263
- return;
1264
- }
1265
- const isSelected = value && value.find((d) => isSameDay(d, day.date));
1266
- if (value && isSelected) {
1267
- onChange(value.filter((v) => !isSameDay(v, day.date)));
1268
- } else {
1269
- onChange([...value || [], day.date]);
1270
- }
1271
- }, [onChange, value]);
1272
- const statePerMonthWithSelectedDate = useMemo(() => {
1273
- if (!value) {
1274
- return statePerMonth;
1275
- }
1276
- return value.reduce((stateSum, date) => addDayStateHighlights(stateSum, date, ["selected"]), statePerMonth);
1277
- }, [statePerMonth, value]);
1065
+ const { currentPanel: c, setCurrentPanel: s } = kt(r), [l, o] = S(() => new Date()), d = g(
1066
+ (f) => {
1067
+ if (!t)
1068
+ return;
1069
+ const h = e && e.find((u) => z(u, f.date));
1070
+ t(e && h ? e.filter((u) => !z(u, f.date)) : [...e || [], f.date]);
1071
+ },
1072
+ [t, e]
1073
+ ), a = C(() => e ? e.reduce(
1074
+ (f, h) => X(f, h, ["selected"]),
1075
+ n
1076
+ ) : n, [n, e]);
1278
1077
  return {
1279
- onClickDay,
1280
- statePerMonth: statePerMonthWithSelectedDate,
1281
- currentPanel,
1282
- setCurrentPanel,
1283
- dateInFocus,
1284
- setDateInFocus
1078
+ onClickDay: d,
1079
+ statePerMonth: a,
1080
+ currentPanel: c,
1081
+ setCurrentPanel: s,
1082
+ dateInFocus: l,
1083
+ setDateInFocus: o
1285
1084
  };
1286
1085
  };
1287
- function MultiDateCalendar(props) {
1288
- const selectionProps = useMultiDateSelection(props);
1289
- return /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
1290
- ...props,
1291
- ...selectionProps
1086
+ function pr(t) {
1087
+ const e = Rn(t);
1088
+ return /* @__PURE__ */ i(F, {
1089
+ ...t,
1090
+ ...e
1292
1091
  });
1293
1092
  }
1294
- const useSingleWeekSelection = ({
1295
- onChange,
1296
- value,
1297
- statePerMonth,
1298
- onChangePanel
1093
+ const An = ({
1094
+ onChange: t,
1095
+ value: e,
1096
+ statePerMonth: n,
1097
+ onChangePanel: r
1299
1098
  }) => {
1300
- const [dateInFocus, setDateInFocus] = useState(() => {
1301
- const week = getWeekDataFromWeekString(value);
1302
- if (!week) {
1303
- return new Date();
1304
- }
1305
- return week.days[0].date;
1306
- });
1307
- const { currentPanel, setCurrentPanel } = useInternalPanelState(onChangePanel);
1308
- const onClickDay = useCallback((day) => {
1309
- if (onChange) {
1310
- onChange(getWeekStringFromWeekData(getWeekForDate(day.date)));
1311
- }
1312
- }, [onChange]);
1313
- const onClickWeek = useCallback((week) => {
1314
- if (onChange) {
1315
- onChange(getWeekStringFromWeekData(week));
1316
- }
1317
- }, [onChange]);
1318
- const statePerMonthWithSelection = useMemo(() => {
1319
- const weekData = getWeekDataFromWeekString(value);
1320
- return weekData ? addWeekRangeHighlights(statePerMonth, weekData) : statePerMonth;
1321
- }, [value, statePerMonth]);
1322
- const date = useMemo(() => {
1323
- const week = getWeekDataFromWeekString(value);
1324
- if (!week) {
1325
- return new Date();
1326
- }
1327
- return week.days[0].date;
1328
- }, [value]);
1099
+ const [c, s] = S(() => {
1100
+ const u = Ht(e);
1101
+ return u ? u.days[0].date : new Date();
1102
+ }), { currentPanel: l, setCurrentPanel: o } = kt(r), d = g(
1103
+ (u) => {
1104
+ t && t(Kt(jt(u.date)));
1105
+ },
1106
+ [t]
1107
+ ), a = g(
1108
+ (u) => {
1109
+ t && t(Kt(u));
1110
+ },
1111
+ [t]
1112
+ ), f = C(() => {
1113
+ const u = Ht(e);
1114
+ return u ? $e(n, u) : n;
1115
+ }, [e, n]), h = C(() => {
1116
+ const u = Ht(e);
1117
+ return u ? u.days[0].date : new Date();
1118
+ }, [e]);
1329
1119
  return {
1330
- statePerMonth: statePerMonthWithSelection,
1331
- date,
1332
- dateInFocus,
1333
- setDateInFocus,
1334
- onClickDay,
1335
- onClickWeek,
1336
- currentPanel,
1337
- setCurrentPanel
1120
+ statePerMonth: f,
1121
+ date: h,
1122
+ dateInFocus: c,
1123
+ setDateInFocus: s,
1124
+ onClickDay: d,
1125
+ onClickWeek: a,
1126
+ currentPanel: l,
1127
+ setCurrentPanel: o
1338
1128
  };
1339
- };
1340
- const getWeekStringFromWeekData = (week) => {
1341
- if (!week) {
1342
- return void 0;
1343
- }
1344
- return `${week.endYear}-${week.weekNumber}`;
1345
- };
1346
- const getWeekDataFromWeekString = (week) => {
1347
- if (!week) {
1348
- return void 0;
1349
- }
1350
- const parts = week.split("-");
1351
- const weekNumber = parseInt(parts[1], 10);
1352
- const year = parseInt(parts[0], 10);
1353
- return getWeekForDate(getStartDateOfISOWeek(weekNumber, year));
1354
- };
1355
- function SingleWeekCalendar(props) {
1356
- const singleWeekSelectionProps = useSingleWeekSelection(props);
1357
- return /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
1358
- ...props,
1359
- ...singleWeekSelectionProps
1129
+ }, Kt = (t) => {
1130
+ if (!!t)
1131
+ return `${t.endYear}-${t.weekNumber}`;
1132
+ }, Ht = (t) => {
1133
+ if (!t)
1134
+ return;
1135
+ const e = t.split("-"), n = parseInt(e[1], 10), r = parseInt(e[0], 10);
1136
+ return jt(Je(n, r));
1137
+ };
1138
+ function br(t) {
1139
+ const e = An(t);
1140
+ return /* @__PURE__ */ i(F, {
1141
+ ...t,
1142
+ ...e
1360
1143
  });
1361
1144
  }
1362
- const removeDateIfExist = (list, date) => list.filter((item) => !isSameDay(item, date));
1363
- const listContainsDate = (list, date) => !!list.find((item) => isSameDay(item, date));
1364
- const useDateRangeExclusionSelection = ({
1365
- value,
1366
- onValueChange,
1367
- statePerMonth,
1368
- onChangePanel
1145
+ const Tn = (t, e) => t.filter((n) => !z(n, e)), xn = (t, e) => !!t.find((n) => z(n, e)), Cn = ({
1146
+ value: t,
1147
+ onValueChange: e,
1148
+ statePerMonth: n,
1149
+ onChangePanel: r
1369
1150
  }) => {
1370
- const [dateRange, setDateRange] = useState();
1371
- const [focusedInput, setFocusedInput] = useState("startDate");
1372
- const { currentPanel, setCurrentPanel } = useInternalPanelState(onChangePanel);
1373
- const [dateInFocus, setDateInFocus] = useState(() => {
1374
- var _a;
1375
- return (_a = focusedInput && (value == null ? void 0 : value[focusedInput])) != null ? _a : new Date();
1376
- });
1377
- const onChangeHandler = useCallback((value2) => {
1378
- setDateRange(value2);
1379
- const { startDate, endDate } = value2;
1380
- if (onValueChange) {
1381
- if (startDate && endDate) {
1382
- const dates = eachDayOfInterval({ start: startDate, end: endDate });
1383
- onValueChange(dates);
1384
- } else if (startDate) {
1385
- onValueChange([startDate]);
1386
- } else if (endDate) {
1387
- onValueChange([endDate]);
1388
- }
1389
- }
1390
- }, [onValueChange]);
1391
- const onClickDayRange = useDateRangeOnClickDayHandler(dateRange, onChangeHandler, focusedInput, setFocusedInput);
1392
- const onClickDay = useCallback((day, userData, ev) => {
1393
- if (onValueChange) {
1394
- if (ev.ctrlKey || ev.metaKey) {
1395
- if (!value) {
1396
- onValueChange([day.date]);
1397
- } else if (listContainsDate(value, day.date)) {
1398
- onValueChange(removeDateIfExist(value, day.date));
1399
- } else {
1400
- onValueChange([...value, day.date]);
1401
- }
1402
- } else {
1403
- onClickDayRange(day, userData, ev);
1404
- }
1405
- }
1406
- }, [onValueChange, onClickDayRange, value]);
1407
- const statePerMonthWithSelectedDate = useMemo(() => {
1408
- return addHighlighting(statePerMonth, value);
1409
- }, [statePerMonth, value]);
1151
+ const [c, s] = S(), [l, o] = S("startDate"), { currentPanel: d, setCurrentPanel: a } = kt(r), [f, h] = S(
1152
+ () => {
1153
+ var p;
1154
+ return (p = l && (t == null ? void 0 : t[l])) != null ? p : new Date();
1155
+ }
1156
+ ), u = g(
1157
+ (p) => {
1158
+ s(p);
1159
+ const { startDate: b, endDate: w } = p;
1160
+ if (e)
1161
+ if (b && w) {
1162
+ const y = Bt({ start: b, end: w });
1163
+ e(y);
1164
+ } else
1165
+ b ? e([b]) : w && e([w]);
1166
+ },
1167
+ [e]
1168
+ ), D = oe(
1169
+ c,
1170
+ u,
1171
+ l,
1172
+ o
1173
+ ), m = g(
1174
+ (p, b, w) => {
1175
+ e && (w.ctrlKey || w.metaKey ? t ? xn(t, p.date) ? e(Tn(t, p.date)) : e([...t, p.date]) : e([p.date]) : D(p, b, w));
1176
+ },
1177
+ [e, D, t]
1178
+ ), k = C(() => In(n, t), [n, t]);
1410
1179
  return {
1411
- onClickDay,
1412
- statePerMonth: statePerMonthWithSelectedDate,
1413
- currentPanel,
1414
- setCurrentPanel,
1415
- dateInFocus,
1416
- setDateInFocus
1180
+ onClickDay: m,
1181
+ statePerMonth: k,
1182
+ currentPanel: d,
1183
+ setCurrentPanel: a,
1184
+ dateInFocus: f,
1185
+ setDateInFocus: h
1417
1186
  };
1418
- };
1419
- const addHighlighting = (statePerMonth, dateList) => {
1420
- if (!dateList) {
1421
- return statePerMonth;
1422
- }
1423
- return dateList.reduce((statePerMonth2, date) => {
1424
- return addDayStateHighlights(statePerMonth2, date, ["selected"]);
1425
- }, statePerMonth);
1426
- };
1427
- function DateRangeExclusionCalendar(props) {
1428
- const selectionProps = useDateRangeExclusionSelection(props);
1429
- return /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
1430
- ...props,
1431
- ...selectionProps
1187
+ }, In = (t, e) => e ? e.reduce((n, r) => X(n, r, ["selected"]), t) : t;
1188
+ function kr(t) {
1189
+ const e = Cn(t);
1190
+ return /* @__PURE__ */ i(F, {
1191
+ ...t,
1192
+ ...e
1432
1193
  });
1433
1194
  }
1434
- const defaultPopoverPlacement = "bottom";
1435
- const useCalendarPopoverUpdater = () => {
1436
- const [tippyRef, tippyInstanceRef] = useTippyInstance();
1437
- const onChangePanel = useCallback(() => {
1438
- var _a, _b;
1439
- (_b = (_a = tippyInstanceRef.current) == null ? void 0 : _a.popperInstance) == null ? void 0 : _b.update();
1440
- }, [tippyInstanceRef]);
1195
+ const St = "bottom", de = () => {
1196
+ const [t, e] = Le();
1441
1197
  return {
1442
- onChangePanel,
1443
- tippyRef
1198
+ onChangePanel: g(() => {
1199
+ var r, c;
1200
+ (c = (r = e.current) == null ? void 0 : r.popperInstance) == null || c.update();
1201
+ }, [e]),
1202
+ tippyRef: t
1444
1203
  };
1445
- };
1446
- const useDateInput = (onChange, onClose, openOnMount) => {
1447
- const [showingCalendar, setShowingCalendar] = useState(openOnMount || false);
1448
- const showCalendar = useCallback(() => {
1449
- setShowingCalendar(true);
1450
- return true;
1451
- }, [setShowingCalendar]);
1452
- const hideCalendar = useCallback(() => {
1453
- setShowingCalendar(false);
1454
- if (onClose) {
1455
- onClose();
1456
- }
1457
- }, [setShowingCalendar, onClose]);
1458
- const onSelectDate = useCallback((date) => {
1459
- if (onChange) {
1460
- onChange(date);
1461
- }
1462
- setTimeout(hideCalendar, 150);
1463
- }, [onChange, hideCalendar]);
1204
+ }, Nn = (t, e, n) => {
1205
+ const [r, c] = S(n || !1), s = g(() => (c(!0), !0), [c]), l = g(() => {
1206
+ c(!1), e && e();
1207
+ }, [c, e]), o = g((d) => {
1208
+ t && t(d), setTimeout(l, 150);
1209
+ }, [t, l]);
1464
1210
  return {
1465
- showCalendar,
1466
- hideCalendar,
1467
- showingCalendar,
1468
- onSelectDate
1211
+ showCalendar: s,
1212
+ hideCalendar: l,
1213
+ showingCalendar: r,
1214
+ onSelectDate: o
1469
1215
  };
1470
- };
1471
- const defaultMaxDate = "2999-12-31";
1472
- const DateInput = ({
1473
- displayFormat = DateFormats.fullDate,
1474
- placeholder = "Enter date",
1475
- value,
1476
- zIndex = 100,
1477
- calendarTheme = defaultCalendarTheme,
1478
- calendarProps,
1479
- openOnMount,
1480
- onClose,
1481
- onChange,
1482
- portalTarget,
1483
- variant,
1484
- width,
1485
- minDate,
1486
- maxDate = defaultMaxDate,
1487
- disabled
1216
+ }, Mt = "2999-12-31", Sr = ({
1217
+ displayFormat: t = Z.fullDate,
1218
+ placeholder: e = "Enter date",
1219
+ value: n,
1220
+ zIndex: r = 100,
1221
+ calendarTheme: c = ct,
1222
+ calendarProps: s,
1223
+ openOnMount: l,
1224
+ onClose: o,
1225
+ onChange: d,
1226
+ portalTarget: a,
1227
+ variant: f,
1228
+ width: h,
1229
+ minDate: u,
1230
+ maxDate: D = Mt,
1231
+ disabled: m
1488
1232
  }) => {
1489
1233
  const {
1490
- hideCalendar,
1491
- showingCalendar,
1492
- onSelectDate,
1493
- showCalendar
1494
- } = useDateInput(onChange, onClose, openOnMount);
1495
- const {
1496
- tippyRef,
1497
- onChangePanel
1498
- } = useCalendarPopoverUpdater();
1499
- return /* @__PURE__ */ jsx(Box, {
1500
- width,
1501
- children: /* @__PURE__ */ jsx(Popover, {
1502
- arrow: false,
1503
- lazy: true,
1504
- visible: showingCalendar,
1505
- onClickOutside: hideCalendar,
1506
- placement: defaultPopoverPlacement,
1507
- zIndex,
1508
- appendTo: portalTarget != null ? portalTarget : "parent",
1509
- tippyRef,
1510
- disabled,
1511
- content: /* @__PURE__ */ jsx(SingleDateCalendar, {
1512
- ...calendarProps,
1513
- onChange: onSelectDate,
1514
- value,
1515
- theme: calendarTheme,
1516
- onChangePanel,
1517
- minDate,
1518
- maxDate
1234
+ hideCalendar: k,
1235
+ showingCalendar: p,
1236
+ onSelectDate: b,
1237
+ showCalendar: w
1238
+ } = Nn(d, o, l), {
1239
+ tippyRef: y,
1240
+ onChangePanel: M
1241
+ } = de();
1242
+ return /* @__PURE__ */ i(I, {
1243
+ width: h,
1244
+ children: /* @__PURE__ */ i(bt, {
1245
+ arrow: !1,
1246
+ lazy: !0,
1247
+ visible: p,
1248
+ onClickOutside: k,
1249
+ placement: St,
1250
+ zIndex: r,
1251
+ appendTo: a != null ? a : "parent",
1252
+ tippyRef: y,
1253
+ disabled: m,
1254
+ content: /* @__PURE__ */ i(le, {
1255
+ ...s,
1256
+ onChange: b,
1257
+ value: n,
1258
+ theme: c,
1259
+ onChangePanel: M,
1260
+ minDate: u,
1261
+ maxDate: D
1519
1262
  }),
1520
- children: /* @__PURE__ */ jsx(TextInput, {
1263
+ children: /* @__PURE__ */ i(rt, {
1521
1264
  type: "date",
1522
- contentRight: /* @__PURE__ */ jsx(Row, {
1265
+ contentRight: /* @__PURE__ */ i(R, {
1523
1266
  alignItems: "center",
1524
- children: /* @__PURE__ */ jsx(FlatButton, {
1267
+ children: /* @__PURE__ */ i(T, {
1525
1268
  size: "small",
1526
- disabled,
1527
- leftIcon: stenaCalendar,
1528
- onClick: showCalendar
1269
+ disabled: m,
1270
+ leftIcon: ht,
1271
+ onClick: w
1529
1272
  })
1530
1273
  }),
1531
- onFocus: showCalendar,
1532
- onClickRight: showCalendar,
1533
- value: value ? format(value, displayFormat) : "",
1534
- placeholder,
1274
+ onFocus: w,
1275
+ onClickRight: w,
1276
+ value: n ? W(n, t) : "",
1277
+ placeholder: e,
1535
1278
  size: 9,
1536
- disabled,
1537
- autoFocus: openOnMount,
1538
- variant,
1539
- min: minDate,
1540
- max: maxDate
1279
+ disabled: m,
1280
+ autoFocus: l,
1281
+ variant: f,
1282
+ min: u,
1283
+ max: D
1541
1284
  })
1542
1285
  })
1543
1286
  });
1544
- };
1545
- const useDateRangeInput = (value, onValueChange) => {
1546
- const startDateInputRef = useRef(null);
1547
- const endDateInputRef = useRef(null);
1548
- const [showingCalendar, setShowingCalendar] = useState(false);
1549
- const [focusedInput, setFocusedInput] = useState(void 0);
1550
- const showCalendarStartDate = useCallback(() => {
1551
- setFocusedInput("startDate");
1552
- setShowingCalendar(true);
1553
- return true;
1554
- }, [setFocusedInput, setShowingCalendar]);
1555
- const showCalendarEndDate = useCallback(() => {
1556
- setFocusedInput("endDate");
1557
- setShowingCalendar(true);
1558
- return true;
1559
- }, [setFocusedInput, setShowingCalendar]);
1560
- const hideCalendar = useCallback(() => {
1561
- setShowingCalendar(false);
1562
- }, [setShowingCalendar]);
1563
- const onClickDay = useCallback((day) => {
1564
- if (focusedInput === "startDate") {
1565
- onValueChange == null ? void 0 : onValueChange({
1566
- startDate: day.date,
1567
- endDate: value == null ? void 0 : value.endDate
1568
- });
1569
- if (!(value == null ? void 0 : value.endDate)) {
1570
- setFocusedInput("endDate");
1571
- endDateInputRef.current && endDateInputRef.current.focus();
1572
- } else {
1573
- setTimeout(hideCalendar, 150);
1574
- }
1575
- } else if (focusedInput === "endDate") {
1576
- onValueChange == null ? void 0 : onValueChange({
1577
- startDate: value == null ? void 0 : value.startDate,
1578
- endDate: day.date
1579
- });
1580
- if (!(value == null ? void 0 : value.startDate)) {
1581
- setFocusedInput("startDate");
1582
- startDateInputRef.current && startDateInputRef.current.focus();
1583
- } else {
1584
- setTimeout(hideCalendar, 150);
1585
- }
1586
- }
1587
- }, [focusedInput, onValueChange, setFocusedInput, hideCalendar, value]);
1588
- const startDateIsAfterEnd = useMemo(() => (value == null ? void 0 : value.startDate) && (value == null ? void 0 : value.endDate) && isAfter(value.startDate, value.endDate), [value == null ? void 0 : value.startDate, value == null ? void 0 : value.endDate]);
1287
+ }, Hn = (t, e) => {
1288
+ const n = J(null), r = J(null), [c, s] = S(!1), [l, o] = S(void 0), d = g(() => (o("startDate"), s(!0), !0), [o, s]), a = g(() => (o("endDate"), s(!0), !0), [o, s]), f = g(() => {
1289
+ s(!1);
1290
+ }, [s]), h = g((D) => {
1291
+ l === "startDate" ? (e == null || e({
1292
+ startDate: D.date,
1293
+ endDate: t == null ? void 0 : t.endDate
1294
+ }), t != null && t.endDate ? setTimeout(f, 150) : (o("endDate"), r.current && r.current.focus())) : l === "endDate" && (e == null || e({
1295
+ startDate: t == null ? void 0 : t.startDate,
1296
+ endDate: D.date
1297
+ }), t != null && t.startDate ? setTimeout(f, 150) : (o("startDate"), n.current && n.current.focus()));
1298
+ }, [l, e, o, f, t]), u = C(() => (t == null ? void 0 : t.startDate) && (t == null ? void 0 : t.endDate) && nt(t.startDate, t.endDate), [t == null ? void 0 : t.startDate, t == null ? void 0 : t.endDate]);
1589
1299
  return {
1590
- showingCalendar,
1591
- hideCalendar,
1592
- showCalendarEndDate,
1593
- showCalendarStartDate,
1594
- focusedInput,
1595
- setFocusedInput,
1596
- startDateInputRef,
1597
- endDateInputRef,
1598
- onClickDay,
1599
- startDateIsAfterEnd
1300
+ showingCalendar: c,
1301
+ hideCalendar: f,
1302
+ showCalendarEndDate: a,
1303
+ showCalendarStartDate: d,
1304
+ focusedInput: l,
1305
+ setFocusedInput: o,
1306
+ startDateInputRef: n,
1307
+ endDateInputRef: r,
1308
+ onClickDay: h,
1309
+ startDateIsAfterEnd: u
1600
1310
  };
1601
1311
  };
1602
- const DateRangeInput = ({
1603
- displayFormat = DateFormats.fullDate,
1604
- placeholderStartDate = "Start date",
1605
- placeholderEndDate = "End date",
1606
- portalTarget,
1607
- value,
1608
- onValueChange,
1609
- zIndex = 100,
1610
- width,
1611
- calendarTheme = defaultCalendarTheme,
1612
- calendarProps,
1613
- minDate,
1614
- maxDate = defaultMaxDate,
1615
- disabled
1616
- }) => {
1617
- const [dateInFocus, setDateInFocus] = useState(() => {
1618
- var _a;
1619
- return (_a = focusedInput && (value == null ? void 0 : value[focusedInput])) != null ? _a : new Date();
1620
- });
1621
- const [currentPanel, setCurrentPanel] = useState("calendar");
1622
- const {
1623
- hideCalendar,
1624
- showCalendarEndDate,
1625
- showCalendarStartDate,
1626
- showingCalendar,
1627
- focusedInput,
1628
- startDateInputRef,
1629
- endDateInputRef,
1630
- onClickDay,
1631
- startDateIsAfterEnd
1632
- } = useDateRangeInput(value, onValueChange);
1633
- const statePerMonth = useMemo(() => buildDayStateForDateRange(void 0, value == null ? void 0 : value.startDate, value == null ? void 0 : value.endDate), [value]);
1634
- return /* @__PURE__ */ jsx(Popover, {
1635
- arrow: false,
1636
- lazy: true,
1637
- disabled,
1638
- visible: showingCalendar,
1639
- zIndex,
1640
- placement: defaultPopoverPlacement,
1641
- appendTo: portalTarget != null ? portalTarget : "parent",
1642
- onClickOutside: hideCalendar,
1643
- content: /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
1644
- ...calendarProps,
1645
- dateInFocus,
1646
- setDateInFocus,
1647
- statePerMonth,
1648
- theme: calendarTheme,
1649
- onClickDay,
1650
- currentPanel,
1651
- setCurrentPanel,
1652
- minDate,
1653
- maxDate
1312
+ function Mr({
1313
+ displayFormat: t = Z.fullDate,
1314
+ placeholderStartDate: e = "Start date",
1315
+ placeholderEndDate: n = "End date",
1316
+ portalTarget: r,
1317
+ value: c,
1318
+ onValueChange: s,
1319
+ zIndex: l = 100,
1320
+ width: o,
1321
+ calendarTheme: d = ct,
1322
+ calendarProps: a,
1323
+ minDate: f,
1324
+ maxDate: h = Mt,
1325
+ disabled: u
1326
+ }) {
1327
+ const [D, m] = S(() => {
1328
+ var _;
1329
+ return (_ = A && (c == null ? void 0 : c[A])) != null ? _ : new Date();
1330
+ }), [k, p] = S("calendar"), {
1331
+ hideCalendar: b,
1332
+ showCalendarEndDate: w,
1333
+ showCalendarStartDate: y,
1334
+ showingCalendar: M,
1335
+ focusedInput: A,
1336
+ startDateInputRef: x,
1337
+ endDateInputRef: N,
1338
+ onClickDay: O,
1339
+ startDateIsAfterEnd: H
1340
+ } = Hn(c, s), j = C(() => wt(void 0, c == null ? void 0 : c.startDate, c == null ? void 0 : c.endDate), [c]);
1341
+ return /* @__PURE__ */ i(bt, {
1342
+ arrow: !1,
1343
+ lazy: !0,
1344
+ disabled: u,
1345
+ visible: M,
1346
+ zIndex: l,
1347
+ placement: St,
1348
+ appendTo: r != null ? r : "parent",
1349
+ onClickOutside: b,
1350
+ content: /* @__PURE__ */ i(F, {
1351
+ ...a,
1352
+ dateInFocus: D,
1353
+ setDateInFocus: m,
1354
+ statePerMonth: j,
1355
+ theme: d,
1356
+ onClickDay: O,
1357
+ currentPanel: k,
1358
+ setCurrentPanel: p,
1359
+ minDate: f,
1360
+ maxDate: h
1654
1361
  }),
1655
- children: /* @__PURE__ */ jsxs(Row, {
1362
+ children: /* @__PURE__ */ E(R, {
1656
1363
  alignItems: "center",
1657
- children: [/* @__PURE__ */ jsx(TextInput, {
1658
- iconLeft: stenaCalendar,
1659
- onFocus: showCalendarStartDate,
1660
- value: (value == null ? void 0 : value.startDate) ? format(value.startDate, displayFormat) : "",
1661
- placeholder: placeholderStartDate,
1662
- width,
1663
- disabled,
1664
- inputRef: startDateInputRef,
1364
+ children: [/* @__PURE__ */ i(rt, {
1365
+ iconLeft: ht,
1366
+ onFocus: y,
1367
+ value: c != null && c.startDate ? W(c.startDate, t) : "",
1368
+ placeholder: e,
1369
+ width: o,
1370
+ disabled: u,
1371
+ inputRef: x,
1665
1372
  size: 9,
1666
- variant: startDateIsAfterEnd ? "error" : void 0
1667
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(Icon, {
1668
- icon: faLongArrowAltRight,
1669
- color: cssColor("--lhds-color-ui-500"),
1373
+ variant: H ? "error" : void 0
1374
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(qt, {
1375
+ icon: Ue,
1376
+ color: ee("--lhds-color-ui-500"),
1670
1377
  size: 14
1671
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(TextInput, {
1672
- iconLeft: stenaCalendar,
1673
- onFocus: showCalendarEndDate,
1674
- value: (value == null ? void 0 : value.endDate) ? format(value.endDate, displayFormat) : "",
1675
- placeholder: placeholderEndDate,
1676
- width,
1677
- disabled,
1678
- inputRef: endDateInputRef,
1378
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(rt, {
1379
+ iconLeft: ht,
1380
+ onFocus: w,
1381
+ value: c != null && c.endDate ? W(c.endDate, t) : "",
1382
+ placeholder: n,
1383
+ width: o,
1384
+ disabled: u,
1385
+ inputRef: N,
1679
1386
  size: 9,
1680
- variant: startDateIsAfterEnd ? "error" : void 0
1387
+ variant: H ? "error" : void 0
1681
1388
  })]
1682
1389
  })
1683
1390
  });
1684
- };
1685
- const DateTextInput = ({
1686
- calendarProps,
1687
- closeOnCalendarSelectDate = true,
1688
- dateFormat = DateFormats.fullDate,
1689
- disableCalender = false,
1690
- onValueChange,
1691
- placeholder = "yyyy-mm-dd",
1692
- portalTarget,
1693
- value,
1694
- width = "130px",
1695
- zIndex = 100,
1696
- calendarTheme = defaultCalendarTheme,
1697
- hideCalenderIcon = false,
1698
- minDate,
1699
- maxDate = defaultMaxDate,
1700
- variant,
1701
- ...props
1391
+ }
1392
+ const Er = ({
1393
+ calendarProps: t,
1394
+ closeOnCalendarSelectDate: e = !0,
1395
+ dateFormat: n = Z.fullDate,
1396
+ disableCalender: r = !1,
1397
+ onValueChange: c,
1398
+ placeholder: s = "yyyy-mm-dd",
1399
+ portalTarget: l,
1400
+ value: o,
1401
+ width: d = "130px",
1402
+ zIndex: a = 100,
1403
+ calendarTheme: f = ct,
1404
+ hideCalenderIcon: h = !1,
1405
+ minDate: u,
1406
+ maxDate: D = Mt,
1407
+ variant: m,
1408
+ ...k
1702
1409
  }) => {
1703
- const [open, setOpen] = useState(false);
1704
- const {
1705
- tippyRef,
1706
- onChangePanel
1707
- } = useCalendarPopoverUpdater();
1708
- const toggleCalendar = useCallback(() => {
1709
- setOpen(!open);
1710
- }, [setOpen, open]);
1711
- const hideCalendar = useCallback(() => {
1712
- setOpen(false);
1713
- }, [setOpen]);
1714
- const onValueChangeHandler = useCallback((value2) => {
1715
- if (onValueChange) {
1716
- onValueChange(value2);
1717
- }
1718
- }, [onValueChange]);
1719
- const onCalendarSelectDate = useCallback((date) => {
1720
- if (date) {
1721
- onValueChangeHandler(format(date, dateFormat));
1722
- if (closeOnCalendarSelectDate) {
1723
- setTimeout(() => setOpen(!open), 200);
1724
- }
1725
- }
1726
- }, [onValueChangeHandler, dateFormat, closeOnCalendarSelectDate, setOpen, open]);
1727
- const inValidInput = !!value && !/^[-/\\.0-9]+$/.test(value);
1728
- const dateIsValid = !!value && isValid(parse(value, dateFormat, new Date()));
1729
- const userInputCorrectLength = !!value && value.length >= dateFormat.length;
1730
- const invalid = userInputCorrectLength && !dateIsValid || inValidInput;
1731
- return /* @__PURE__ */ jsx(Box, {
1732
- width,
1733
- children: /* @__PURE__ */ jsx(Popover, {
1734
- arrow: false,
1735
- lazy: true,
1736
- visible: open,
1737
- zIndex,
1738
- appendTo: portalTarget != null ? portalTarget : "parent",
1739
- placement: defaultPopoverPlacement,
1740
- onClickOutside: hideCalendar,
1741
- tippyRef,
1742
- content: /* @__PURE__ */ jsx(SingleDateCalendar, {
1743
- ...calendarProps,
1744
- onChange: onCalendarSelectDate,
1745
- onChangePanel,
1746
- value: value && dateIsValid ? parse(value, dateFormat, new Date()) : void 0,
1747
- minDate,
1748
- maxDate,
1749
- theme: calendarTheme
1410
+ const [p, b] = S(!1), {
1411
+ tippyRef: w,
1412
+ onChangePanel: y
1413
+ } = de(), M = g(() => {
1414
+ b(!p);
1415
+ }, [b, p]), A = g(() => {
1416
+ b(!1);
1417
+ }, [b]), x = g((P) => {
1418
+ c && c(P);
1419
+ }, [c]), N = g((P) => {
1420
+ P && (x(W(P, n)), e && setTimeout(() => b(!p), 200));
1421
+ }, [x, n, e, b, p]), O = !!o && !/^[-/\\.0-9]+$/.test(o), H = !!o && xe(ot(o, n, new Date())), _ = !!o && o.length >= n.length && !H || O;
1422
+ return /* @__PURE__ */ i(I, {
1423
+ width: d,
1424
+ children: /* @__PURE__ */ i(bt, {
1425
+ arrow: !1,
1426
+ lazy: !0,
1427
+ visible: p,
1428
+ zIndex: a,
1429
+ appendTo: l != null ? l : "parent",
1430
+ placement: St,
1431
+ onClickOutside: A,
1432
+ tippyRef: w,
1433
+ content: /* @__PURE__ */ i(le, {
1434
+ ...t,
1435
+ onChange: N,
1436
+ onChangePanel: y,
1437
+ value: o && H ? ot(o, n, new Date()) : void 0,
1438
+ minDate: u,
1439
+ maxDate: D,
1440
+ theme: f
1750
1441
  }),
1751
- children: /* @__PURE__ */ jsx(TextInput, {
1752
- ...props,
1753
- variant: invalid ? "error" : variant,
1754
- disableContentPaddingRight: true,
1755
- contentRight: !hideCalenderIcon ? /* @__PURE__ */ jsx(Row, {
1442
+ children: /* @__PURE__ */ i(rt, {
1443
+ ...k,
1444
+ variant: _ ? "error" : m,
1445
+ disableContentPaddingRight: !0,
1446
+ contentRight: h ? void 0 : /* @__PURE__ */ i(R, {
1756
1447
  alignItems: "center",
1757
1448
  indent: 0.5,
1758
- children: /* @__PURE__ */ jsx(FlatButton, {
1449
+ children: /* @__PURE__ */ i(T, {
1759
1450
  size: "small",
1760
- disabled: props.disabled,
1761
- leftIcon: stenaCalendar,
1762
- onClick: toggleCalendar
1451
+ disabled: k.disabled,
1452
+ leftIcon: ht,
1453
+ onClick: M
1763
1454
  })
1764
- }) : void 0,
1765
- onValueChange: onValueChangeHandler,
1766
- placeholder,
1767
- value: value || "",
1768
- min: minDate,
1769
- max: maxDate,
1455
+ }),
1456
+ onValueChange: x,
1457
+ placeholder: s,
1458
+ value: o || "",
1459
+ min: u,
1460
+ max: D,
1770
1461
  size: 10
1771
1462
  })
1772
1463
  })
1773
1464
  });
1774
- };
1775
- const formatHours = (hours2) => {
1776
- if (hours2 === "") {
1465
+ }, xt = (t) => {
1466
+ if (t === "")
1777
1467
  return "00";
1778
- }
1779
- const h = parseInt(hours2, 10);
1780
- if (isNaN(h)) {
1468
+ const e = parseInt(t, 10);
1469
+ if (isNaN(e))
1781
1470
  throw new Error("Hours is not a number");
1782
- }
1783
- if (h < 0 || h > 23) {
1471
+ if (e < 0 || e > 23)
1784
1472
  throw new Error("Hours is an invalid number");
1785
- }
1786
- switch (hours2.length) {
1473
+ switch (t.length) {
1787
1474
  case 1:
1788
- return `0${h}`;
1475
+ return `0${e}`;
1789
1476
  case 2:
1790
- return hours2;
1477
+ return t;
1791
1478
  default:
1792
1479
  throw new Error("Invalid hour string");
1793
1480
  }
1794
- };
1795
- const formatMinutes = (minutes2) => {
1796
- if (minutes2 === "") {
1481
+ }, Ct = (t) => {
1482
+ if (t === "")
1797
1483
  return "00";
1798
- }
1799
- const m = parseInt(minutes2, 10);
1800
- if (isNaN(m)) {
1484
+ const e = parseInt(t, 10);
1485
+ if (isNaN(e))
1801
1486
  throw new Error("Minutes is not a number");
1802
- }
1803
- if (m < 0 || m > 59) {
1487
+ if (e < 0 || e > 59)
1804
1488
  throw new Error("Minutes is an invalid number");
1805
- }
1806
- switch (minutes2.length) {
1489
+ switch (t.length) {
1807
1490
  case 1:
1808
- return `0${m}`;
1491
+ return `0${e}`;
1809
1492
  case 2:
1810
- return minutes2;
1493
+ return t;
1811
1494
  default:
1812
1495
  throw new Error("Invalid minute string");
1813
1496
  }
1814
- };
1815
- const formatTimeString = (time) => {
1816
- if (!validUserInput(time)) {
1817
- return { time, success: false };
1818
- }
1819
- const arr = time && time.split(/-|:|,|;|[/]|[.]| /);
1820
- if (arr && arr.length === 2) {
1497
+ }, Yn = (t) => {
1498
+ if (!Wt(t))
1499
+ return { time: t, success: !1 };
1500
+ const e = t && t.split(/-|:|,|;|[/]|[.]| /);
1501
+ if (e && e.length === 2)
1821
1502
  try {
1822
- const hours2 = formatHours(arr[0]);
1823
- const minutes2 = formatMinutes(arr[1]);
1824
- return { time: `${hours2}:${minutes2}`, success: true };
1503
+ const n = xt(e[0]), r = Ct(e[1]);
1504
+ return { time: `${n}:${r}`, success: !0 };
1825
1505
  } catch {
1826
- return { time, success: false };
1506
+ return { time: t, success: !1 };
1827
1507
  }
1828
- } else if (arr && arr.length === 1) {
1829
- let hours2 = 0;
1830
- let minutes2 = 0;
1831
- switch (time.length) {
1508
+ else if (e && e.length === 1) {
1509
+ let n = 0, r = 0;
1510
+ switch (t.length) {
1832
1511
  case 1:
1833
- return { time: `0${time}:00`, success: true };
1512
+ return { time: `0${t}:00`, success: !0 };
1834
1513
  case 2:
1835
- const timeNumber = parseInt(arr[0], 10);
1836
- if (timeNumber >= 0 && timeNumber < 24) {
1837
- return { time: `${time}:00`, success: true };
1838
- } else if (timeNumber >= 24 && timeNumber < 59) {
1839
- return { time: `00:${time}`, success: true };
1840
- }
1841
- return { time, success: false };
1514
+ const c = parseInt(e[0], 10);
1515
+ return c >= 0 && c < 24 ? { time: `${t}:00`, success: !0 } : c >= 24 && c < 59 ? { time: `00:${t}`, success: !0 } : { time: t, success: !1 };
1842
1516
  case 3:
1843
- minutes2 = parseInt(time.substr(1, 2), 10);
1844
- if (minutes2 >= 0 && minutes2 <= 59) {
1845
- return {
1846
- time: `0${time.substr(0, 1)}:${time.substr(1, 2)}`,
1847
- success: true
1848
- };
1849
- }
1850
- return { time, success: false };
1517
+ return r = parseInt(t.substr(1, 2), 10), r >= 0 && r <= 59 ? {
1518
+ time: `0${t.substr(0, 1)}:${t.substr(1, 2)}`,
1519
+ success: !0
1520
+ } : { time: t, success: !1 };
1851
1521
  case 4:
1852
- hours2 = parseInt(time.substr(0, 2), 10);
1853
- minutes2 = parseInt(time.substr(2, 2), 10);
1854
- if (hours2 < 0 || hours2 > 23) {
1855
- return { time, success: false };
1856
- }
1857
- if (minutes2 < 0 || minutes2 > 59) {
1858
- return { time, success: false };
1859
- }
1860
- return {
1861
- time: `${time.substr(0, 2)}:${time.substr(2, 2)}`,
1862
- success: true
1522
+ return n = parseInt(t.substr(0, 2), 10), r = parseInt(t.substr(2, 2), 10), n < 0 || n > 23 ? { time: t, success: !1 } : r < 0 || r > 59 ? { time: t, success: !1 } : {
1523
+ time: `${t.substr(0, 2)}:${t.substr(2, 2)}`,
1524
+ success: !0
1863
1525
  };
1864
1526
  default:
1865
- return { time, success: false };
1527
+ return { time: t, success: !1 };
1866
1528
  }
1867
1529
  }
1868
- return { time, success: false };
1869
- };
1870
- const validUserInput = (input) => {
1871
- if (input) {
1872
- return /^[-:.,/; 0-9]+$/.test(input);
1873
- }
1874
- return true;
1875
- };
1876
- const TimeTextInput = ({
1877
- onValueChange,
1878
- showPlaceholder = true,
1879
- useIcon = true,
1880
- value,
1881
- width = "85px",
1882
- variant,
1883
- ...props
1530
+ return { time: t, success: !1 };
1531
+ }, Wt = (t) => t ? /^[-:.,/; 0-9]+$/.test(t) : !0, Rr = ({
1532
+ onValueChange: t,
1533
+ showPlaceholder: e = !0,
1534
+ useIcon: n = !0,
1535
+ value: r,
1536
+ width: c = "85px",
1537
+ variant: s,
1538
+ ...l
1884
1539
  }) => {
1885
- const [valid, setValid] = useState(() => validUserInput(value));
1886
- const timeFormat = "hh:mm";
1887
- const onBlur = useCallback(() => {
1888
- if (value) {
1889
- const formattedResult = formatTimeString(value);
1890
- setValid(formattedResult.success);
1891
- if (formattedResult.success) {
1892
- if (onValueChange) {
1893
- onValueChange(formattedResult.time);
1894
- }
1895
- }
1896
- }
1897
- }, [value, onValueChange, setValid]);
1898
- const onChangeHandler = useCallback((ev) => {
1899
- const time = ev.target.value;
1900
- const validInput = validUserInput(time);
1901
- setValid(validInput && time.length <= timeFormat.length);
1902
- if (onValueChange) {
1903
- onValueChange(time);
1904
- }
1905
- }, [onValueChange, setValid]);
1906
- return /* @__PURE__ */ jsx(TextInput, {
1907
- ...props,
1540
+ const [o, d] = S(() => Wt(r)), a = "hh:mm", f = g(() => {
1541
+ if (r) {
1542
+ const u = Yn(r);
1543
+ d(u.success), u.success && t && t(u.time);
1544
+ }
1545
+ }, [r, t, d]), h = g((u) => {
1546
+ const D = u.target.value, m = Wt(D);
1547
+ d(m && D.length <= a.length), t && t(D);
1548
+ }, [t, d]);
1549
+ return /* @__PURE__ */ i(rt, {
1550
+ ...l,
1908
1551
  type: "time",
1909
- variant: !valid ? "error" : variant,
1910
- iconLeft: useIcon ? stenaClock : void 0,
1911
- value,
1912
- placeholder: showPlaceholder ? timeFormat : void 0,
1913
- onChange: onChangeHandler,
1914
- onBlur,
1915
- width
1552
+ variant: o ? s : "error",
1553
+ iconLeft: n ? Qt : void 0,
1554
+ value: r,
1555
+ placeholder: e ? a : void 0,
1556
+ onChange: h,
1557
+ onBlur: f,
1558
+ width: c
1916
1559
  });
1917
- };
1918
- const DualTextInput = ({
1919
- autoFocusLeft,
1920
- autoFocusRight,
1921
- onEsc,
1922
- onEnter,
1923
- onValueChangeLeft,
1924
- onValueChangeRight,
1925
- separatorIcon,
1926
- placeholderLeft,
1927
- placeholderRight,
1928
- typeLeft,
1929
- typeRight,
1930
- onChangeLeft,
1931
- onChangeRight,
1932
- valueLeft,
1933
- valueRight,
1934
- minLeft,
1935
- maxLeft,
1936
- minRight,
1937
- maxRight,
1938
- onClickLeft,
1939
- onClickRight,
1940
- onClickCalendar,
1941
- onClickArrowDown,
1942
- onBlurLeft,
1943
- onBlurRight,
1944
- onFocusLeft,
1945
- onFocusRight,
1946
- inputRefLeft,
1947
- inputRefRight,
1948
- variant,
1949
- variantLeft,
1950
- variantRight,
1951
- onBlur,
1952
- showPresets,
1953
- widthLeft,
1954
- widthRight,
1955
- disabled
1560
+ }, ae = ({
1561
+ autoFocusLeft: t,
1562
+ autoFocusRight: e,
1563
+ onEsc: n,
1564
+ onEnter: r,
1565
+ onValueChangeLeft: c,
1566
+ onValueChangeRight: s,
1567
+ separatorIcon: l,
1568
+ placeholderLeft: o,
1569
+ placeholderRight: d,
1570
+ typeLeft: a,
1571
+ typeRight: f,
1572
+ onChangeLeft: h,
1573
+ onChangeRight: u,
1574
+ valueLeft: D,
1575
+ valueRight: m,
1576
+ minLeft: k,
1577
+ maxLeft: p,
1578
+ minRight: b,
1579
+ maxRight: w,
1580
+ onClickLeft: y,
1581
+ onClickRight: M,
1582
+ onClickCalendar: A,
1583
+ onClickArrowDown: x,
1584
+ onBlurLeft: N,
1585
+ onBlurRight: O,
1586
+ onFocusLeft: H,
1587
+ onFocusRight: j,
1588
+ inputRefLeft: _,
1589
+ inputRefRight: P,
1590
+ variant: st,
1591
+ variantLeft: dt,
1592
+ variantRight: it,
1593
+ onBlur: K,
1594
+ showPresets: at,
1595
+ widthLeft: ft,
1596
+ widthRight: ut,
1597
+ disabled: v
1956
1598
  }) => {
1957
- const focusCounter = useRef(0);
1958
- const tryTriggerOnBlur = useMemo(() => debounce((focusCounter2) => {
1959
- if (focusCounter2 === 0) {
1960
- onBlur == null ? void 0 : onBlur();
1961
- }
1962
- }, 10), [onBlur]);
1963
- const focusLeftHandler = useCallback((ev) => {
1964
- focusCounter.current++;
1965
- tryTriggerOnBlur(focusCounter.current);
1966
- if (onFocusLeft) {
1967
- onFocusLeft(ev);
1968
- }
1969
- }, [onFocusLeft, focusCounter, tryTriggerOnBlur]);
1970
- const focusRightHandler = useCallback((ev) => {
1971
- focusCounter.current++;
1972
- tryTriggerOnBlur(focusCounter.current);
1973
- if (onFocusRight) {
1974
- onFocusRight(ev);
1975
- }
1976
- }, [onFocusRight, focusCounter, tryTriggerOnBlur]);
1977
- const blurLeftHandler = useCallback((ev) => {
1978
- focusCounter.current--;
1979
- tryTriggerOnBlur(focusCounter.current);
1980
- if (onBlurLeft) {
1981
- onBlurLeft(ev);
1982
- }
1983
- }, [onBlurLeft, focusCounter, tryTriggerOnBlur]);
1984
- const blurRightHandler = useCallback((ev) => {
1985
- focusCounter.current--;
1986
- tryTriggerOnBlur(focusCounter.current);
1987
- if (onBlurRight) {
1988
- onBlurRight(ev);
1989
- }
1990
- }, [onBlurRight, focusCounter, tryTriggerOnBlur]);
1991
- return /* @__PURE__ */ jsx(Box, {
1992
- children: /* @__PURE__ */ jsxs(TextInputBox, {
1993
- disableContentPaddingRight: true,
1994
- disabled,
1995
- variant,
1996
- contentRight: /* @__PURE__ */ jsxs(Row, {
1599
+ const L = J(0), Y = C(() => Ie((G) => {
1600
+ G === 0 && (K == null || K());
1601
+ }, 10), [K]), Et = g((G) => {
1602
+ L.current++, Y(L.current), H && H(G);
1603
+ }, [H, L, Y]), Rt = g((G) => {
1604
+ L.current++, Y(L.current), j && j(G);
1605
+ }, [j, L, Y]), At = g((G) => {
1606
+ L.current--, Y(L.current), N && N(G);
1607
+ }, [N, L, Y]), ue = g((G) => {
1608
+ L.current--, Y(L.current), O && O(G);
1609
+ }, [O, L, Y]);
1610
+ return /* @__PURE__ */ i(I, {
1611
+ children: /* @__PURE__ */ E(Ye, {
1612
+ disableContentPaddingRight: !0,
1613
+ disabled: v,
1614
+ variant: st,
1615
+ contentRight: /* @__PURE__ */ E(R, {
1997
1616
  alignItems: "center",
1998
- children: [/* @__PURE__ */ jsx(Indent, {
1617
+ children: [/* @__PURE__ */ i(gt, {
1999
1618
  num: 0.5,
2000
- children: /* @__PURE__ */ jsx(FlatButton, {
2001
- leftIcon: stenaCalendar,
2002
- onClick: onClickCalendar,
2003
- disabled,
1619
+ children: /* @__PURE__ */ i(T, {
1620
+ leftIcon: ht,
1621
+ onClick: A,
1622
+ disabled: v,
2004
1623
  size: "small"
2005
1624
  })
2006
- }), showPresets ? /* @__PURE__ */ jsxs(Fragment, {
2007
- children: [/* @__PURE__ */ jsx(Row, {
1625
+ }), at ? /* @__PURE__ */ E(mt, {
1626
+ children: [/* @__PURE__ */ i(R, {
2008
1627
  height: "22px",
2009
- children: /* @__PURE__ */ jsx(SeparatorLine, {
2010
- vertical: true
1628
+ children: /* @__PURE__ */ i(ye, {
1629
+ vertical: !0
2011
1630
  })
2012
- }), /* @__PURE__ */ jsx(Indent, {
1631
+ }), /* @__PURE__ */ i(gt, {
2013
1632
  num: 0.5,
2014
- children: /* @__PURE__ */ jsx(FlatButton, {
2015
- leftIcon: stenaAngleDown,
2016
- onClick: onClickArrowDown,
2017
- disabled,
1633
+ children: /* @__PURE__ */ i(T, {
1634
+ leftIcon: De,
1635
+ onClick: x,
1636
+ disabled: v,
2018
1637
  size: "small"
2019
1638
  })
2020
1639
  })]
2021
1640
  }) : null]
2022
1641
  }),
2023
- children: [/* @__PURE__ */ jsx(Box, {
2024
- width: widthLeft,
2025
- children: /* @__PURE__ */ jsx(TextInput, {
2026
- onEsc,
2027
- onEnter,
2028
- onClick: onClickLeft,
2029
- disabled,
2030
- hideBorder: true,
2031
- placeholder: placeholderLeft,
2032
- value: valueLeft,
2033
- onValueChange: onValueChangeLeft,
2034
- onChange: onChangeLeft,
2035
- onBlur: blurLeftHandler,
2036
- onFocus: focusLeftHandler,
2037
- inputRef: inputRefLeft,
2038
- variant: variantLeft,
2039
- type: typeLeft,
2040
- autoFocus: autoFocusLeft,
2041
- min: minLeft,
2042
- max: maxLeft
1642
+ children: [/* @__PURE__ */ i(I, {
1643
+ width: ft,
1644
+ children: /* @__PURE__ */ i(rt, {
1645
+ onEsc: n,
1646
+ onEnter: r,
1647
+ onClick: y,
1648
+ disabled: v,
1649
+ hideBorder: !0,
1650
+ placeholder: o,
1651
+ value: D,
1652
+ onValueChange: c,
1653
+ onChange: h,
1654
+ onBlur: At,
1655
+ onFocus: Et,
1656
+ inputRef: _,
1657
+ variant: dt,
1658
+ type: a,
1659
+ autoFocus: t,
1660
+ min: k,
1661
+ max: p
2043
1662
  })
2044
- }), /* @__PURE__ */ jsx(Row, {
1663
+ }), /* @__PURE__ */ i(R, {
2045
1664
  indent: 0.5,
2046
1665
  alignItems: "center",
2047
1666
  justifyContent: "center",
2048
- children: /* @__PURE__ */ jsx(Icon, {
2049
- icon: separatorIcon,
1667
+ children: /* @__PURE__ */ i(qt, {
1668
+ icon: l,
2050
1669
  size: 12,
2051
- color: cssColor("--lhds-color-ui-500")
1670
+ color: ee("--lhds-color-ui-500")
2052
1671
  })
2053
- }), /* @__PURE__ */ jsx(Box, {
2054
- width: widthRight,
2055
- children: /* @__PURE__ */ jsx(TextInput, {
2056
- onEsc,
2057
- onEnter,
2058
- onClick: onClickRight,
2059
- disabled,
2060
- hideBorder: true,
2061
- placeholder: placeholderRight,
2062
- value: valueRight,
2063
- onValueChange: onValueChangeRight,
2064
- onChange: onChangeRight,
2065
- onBlur: blurRightHandler,
2066
- onFocus: focusRightHandler,
2067
- inputRef: inputRefRight,
2068
- variant: variantRight,
2069
- type: typeRight,
2070
- autoFocus: autoFocusRight,
2071
- min: minRight,
2072
- max: maxRight
1672
+ }), /* @__PURE__ */ i(I, {
1673
+ width: ut,
1674
+ children: /* @__PURE__ */ i(rt, {
1675
+ onEsc: n,
1676
+ onEnter: r,
1677
+ onClick: M,
1678
+ disabled: v,
1679
+ hideBorder: !0,
1680
+ placeholder: d,
1681
+ value: m,
1682
+ onValueChange: s,
1683
+ onChange: u,
1684
+ onBlur: ue,
1685
+ onFocus: Rt,
1686
+ inputRef: P,
1687
+ variant: it,
1688
+ type: f,
1689
+ autoFocus: e,
1690
+ min: b,
1691
+ max: w
2073
1692
  })
2074
1693
  })]
2075
1694
  })
2076
1695
  });
2077
- };
2078
- const transformTimeStringToNumber = (time) => {
2079
- if (time == null) {
1696
+ }, Ln = (t) => {
1697
+ if (t == null)
2080
1698
  throw new Error("Time is not set.");
2081
- }
2082
- if (time === "") {
1699
+ if (t === "")
2083
1700
  throw new Error("Time is empty.");
2084
- }
2085
- const parts = time.split(":");
2086
- if (parts.length !== 2) {
1701
+ const e = t.split(":");
1702
+ if (e.length !== 2)
2087
1703
  throw new Error("Invalid time.");
2088
- }
2089
- if (parts[1].length !== 2) {
1704
+ if (e[1].length !== 2)
2090
1705
  throw new Error("Invalid time.");
2091
- }
2092
- if (parts[0].length < 1 || parts[0].length > 2) {
1706
+ if (e[0].length < 1 || e[0].length > 2)
2093
1707
  throw new Error("Invalid time.");
2094
- }
2095
- const hours2 = parseInt(parts[0], 10);
2096
- const minutes2 = parseInt(parts[1], 10);
2097
- if (isNaN(hours2)) {
1708
+ const n = parseInt(e[0], 10), r = parseInt(e[1], 10);
1709
+ if (isNaN(n))
2098
1710
  throw new Error("Invalid time.");
2099
- }
2100
- if (isNaN(minutes2)) {
1711
+ if (isNaN(r))
2101
1712
  throw new Error("Invalid time.");
2102
- }
2103
- if (hours2 < 0 || hours2 > 23) {
1713
+ if (n < 0 || n > 23)
2104
1714
  throw new Error("Invalid time.");
2105
- }
2106
- if (minutes2 < 0 || minutes2 > 59) {
1715
+ if (r < 0 || r > 59)
2107
1716
  throw new Error("Invalid time.");
2108
- }
2109
- return hours2 * 100 + minutes2;
2110
- };
2111
- const isValidTimeString = (time) => {
1717
+ return n * 100 + r;
1718
+ }, Un = (t) => {
2112
1719
  try {
2113
- transformTimeStringToNumber(time);
2114
- return true;
2115
- } catch (e) {
2116
- return false;
1720
+ return Ln(t), !0;
1721
+ } catch {
1722
+ return !1;
2117
1723
  }
2118
- };
2119
- const getHoursAndMinutesFromTimeString = (value) => {
2120
- if (value && isValidTimeString(value)) {
2121
- const p = value.split(":");
1724
+ }, Tt = (t) => {
1725
+ if (t && Un(t)) {
1726
+ const e = t.split(":");
2122
1727
  return {
2123
- hour: parseIntElseUndefined(p[0]),
2124
- minute: parseIntElseUndefined(p[1])
1728
+ hour: _t(e[0]),
1729
+ minute: _t(e[1])
2125
1730
  };
2126
1731
  }
2127
1732
  return {
2128
1733
  hour: void 0,
2129
1734
  minute: void 0
2130
1735
  };
2131
- };
2132
- const transformTimeInDateToTimeString = (date) => `${formatHours(String(date.getHours()))}:${formatMinutes(String(date.getMinutes()))}`;
2133
- const timePicker = "_timePicker_1w05d_1";
2134
- const timePickerColumn = "_timePickerColumn_1w05d_6";
2135
- var styles = {
2136
- timePicker,
2137
- timePickerColumn
2138
- };
2139
- const TimePickerCell = ({
2140
- onClick,
2141
- item,
2142
- selected,
2143
- columnRef,
2144
- canScrollRef
1736
+ }, Wn = (t) => `${xt(String(t.getHours()))}:${Ct(
1737
+ String(t.getMinutes())
1738
+ )}`, On = "_timePicker_1w05d_1", $n = "_timePickerColumn_1w05d_6", fe = {
1739
+ timePicker: On,
1740
+ timePickerColumn: $n
1741
+ }, Pn = ({
1742
+ onClick: t,
1743
+ item: e,
1744
+ selected: n,
1745
+ columnRef: r,
1746
+ canScrollRef: c
2145
1747
  }) => {
2146
- const ref = useRef(null);
2147
- useEffect(function scrollToSelectedItem() {
2148
- if (selected && columnRef.current && ref.current && canScrollRef.current) {
2149
- const targetScroll = ref.current.scrollHeight * Math.max(item - 2, 0);
2150
- columnRef.current.scrollTo(0, targetScroll);
2151
- canScrollRef.current = false;
1748
+ const s = J(null);
1749
+ return Q(function() {
1750
+ if (n && r.current && s.current && c.current) {
1751
+ const o = s.current.scrollHeight * Math.max(e - 2, 0);
1752
+ r.current.scrollTo(0, o), c.current = !1;
2152
1753
  }
2153
- }, [columnRef, item, selected, canScrollRef]);
2154
- return /* @__PURE__ */ jsx(Row, {
1754
+ }, [r, e, n, c]), /* @__PURE__ */ i(R, {
2155
1755
  width: "64px",
2156
1756
  justifyContent: "center",
2157
1757
  spacing: 0.5,
2158
1758
  indent: 0.5,
2159
- ref,
2160
- children: selected ? /* @__PURE__ */ jsx(PrimaryButton, {
2161
- label: String(item),
2162
- onClick: () => onClick && onClick(item)
2163
- }) : /* @__PURE__ */ jsx(FlatButton, {
2164
- label: String(item),
2165
- onClick: () => onClick && onClick(item)
1759
+ ref: s,
1760
+ children: n ? /* @__PURE__ */ i(lt, {
1761
+ label: String(e),
1762
+ onClick: () => t && t(e)
1763
+ }) : /* @__PURE__ */ i(T, {
1764
+ label: String(e),
1765
+ onClick: () => t && t(e)
2166
1766
  })
2167
1767
  });
2168
- };
2169
- const TimePickerColumn = ({
2170
- onClick,
2171
- items,
2172
- selectedItem,
2173
- canScrollRef
1768
+ }, Gt = ({
1769
+ onClick: t,
1770
+ items: e,
1771
+ selectedItem: n,
1772
+ canScrollRef: r
2174
1773
  }) => {
2175
- const columnRef = useRef(null);
2176
- return /* @__PURE__ */ jsx(Column, {
2177
- className: styles.timePickerColumn,
2178
- ref: columnRef,
2179
- children: items.map((item) => /* @__PURE__ */ jsx(TimePickerCell, {
2180
- item,
2181
- onClick,
2182
- selected: item === selectedItem,
2183
- columnRef,
2184
- canScrollRef
2185
- }, item))
1774
+ const c = J(null);
1775
+ return /* @__PURE__ */ i(B, {
1776
+ className: fe.timePickerColumn,
1777
+ ref: c,
1778
+ children: e.map((s) => /* @__PURE__ */ i(Pn, {
1779
+ item: s,
1780
+ onClick: t,
1781
+ selected: s === n,
1782
+ columnRef: c,
1783
+ canScrollRef: r
1784
+ }, s))
2186
1785
  });
2187
- };
2188
- const hours = range(0, 24);
2189
- const minutes = range(0, 60);
2190
- const TimePicker = ({
2191
- value,
2192
- onValueChange
1786
+ }, Bn = zt(0, 24), zn = zt(0, 60), jn = ({
1787
+ value: t,
1788
+ onValueChange: e
2193
1789
  }) => {
2194
- const canScrollRef = useRef(true);
2195
- const [hour, setHour] = useState(void 0);
2196
- const [minute, setMinute] = useState(void 0);
2197
- useEffect(() => {
2198
- if (value) {
1790
+ const n = J(!0), [r, c] = S(void 0), [s, l] = S(void 0);
1791
+ Q(() => {
1792
+ if (t) {
2199
1793
  const {
2200
- minute: minute2,
2201
- hour: hour2
2202
- } = getHoursAndMinutesFromTimeString(value);
2203
- setHour(hour2);
2204
- setMinute(minute2);
2205
- }
2206
- }, [value]);
2207
- const onClickHour = useCallback((h) => {
2208
- setHour(h);
2209
- onValueChange == null ? void 0 : onValueChange(`${formatHours(String(h != null ? h : 0))}:${formatMinutes(String(minute != null ? minute : 0))}`);
2210
- }, [minute, onValueChange]);
2211
- const onClickMinutes = useCallback((m) => {
2212
- setMinute(m);
2213
- onValueChange == null ? void 0 : onValueChange(`${formatHours(String(hour != null ? hour : 0))}:${formatMinutes(String(m != null ? m : 0))}`);
2214
- }, [hour, onValueChange]);
2215
- return /* @__PURE__ */ jsxs(Row, {
2216
- className: styles.timePicker,
2217
- children: [/* @__PURE__ */ jsx(TimePickerColumn, {
2218
- items: hours,
2219
- onClick: onClickHour,
2220
- selectedItem: hour,
2221
- canScrollRef
2222
- }), /* @__PURE__ */ jsx(Indent, {}), /* @__PURE__ */ jsx(TimePickerColumn, {
2223
- items: minutes,
2224
- onClick: onClickMinutes,
2225
- selectedItem: minute,
2226
- canScrollRef
1794
+ minute: a,
1795
+ hour: f
1796
+ } = Tt(t);
1797
+ c(f), l(a);
1798
+ }
1799
+ }, [t]);
1800
+ const o = g((a) => {
1801
+ c(a), e == null || e(`${xt(String(a != null ? a : 0))}:${Ct(String(s != null ? s : 0))}`);
1802
+ }, [s, e]), d = g((a) => {
1803
+ l(a), e == null || e(`${xt(String(r != null ? r : 0))}:${Ct(String(a != null ? a : 0))}`);
1804
+ }, [r, e]);
1805
+ return /* @__PURE__ */ E(R, {
1806
+ className: fe.timePicker,
1807
+ children: [/* @__PURE__ */ i(Gt, {
1808
+ items: Bn,
1809
+ onClick: o,
1810
+ selectedItem: r,
1811
+ canScrollRef: n
1812
+ }), /* @__PURE__ */ i(gt, {}), /* @__PURE__ */ i(Gt, {
1813
+ items: zn,
1814
+ onClick: d,
1815
+ selectedItem: s,
1816
+ canScrollRef: n
2227
1817
  })]
2228
1818
  });
2229
- };
2230
- const useDateRangeEffects$1 = (date, setDateInFocus, dateInputRef) => {
2231
- useEffect(function moveFocusedDateWhenDateChanges() {
2232
- if (date) {
2233
- setDateInFocus(date);
2234
- }
2235
- }, [date, setDateInFocus]);
2236
- useEffect(function updateDateFieldWhenValueChanges() {
2237
- if (dateInputRef.current) {
2238
- if (date) {
2239
- dateInputRef.current.valueAsDate = new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
2240
- } else {
2241
- dateInputRef.current.valueAsDate = null;
2242
- }
2243
- }
2244
- }, [date, dateInputRef]);
2245
- };
2246
- const useDateRangeHandlers$1 = (date, onValueChange, {
2247
- setDateInFocus,
2248
- showCalendarInternal,
2249
- hideCalendarInternal,
2250
- setFirstFocusedInput,
2251
- setCurrentPanel,
2252
- localTime,
2253
- setLocalTime,
2254
- localDate,
2255
- setLocalDate
2256
- }, dateInputRef) => {
2257
- const onChangeDate = useCallback((incomingDate) => {
2258
- if (!incomingDate) {
2259
- return;
2260
- }
2261
- const newDate = new Date(incomingDate);
2262
- if (date) {
2263
- newDate.setHours(date.getHours());
2264
- newDate.setMinutes(date.getMinutes());
2265
- onValueChange == null ? void 0 : onValueChange(newDate);
2266
- setLocalDate(void 0);
2267
- } else if (localTime) {
2268
- const { minute, hour } = getHoursAndMinutesFromTimeString(localTime);
2269
- newDate.setHours(hour != null ? hour : 0);
2270
- newDate.setMinutes(minute != null ? minute : 0);
2271
- onValueChange == null ? void 0 : onValueChange(newDate);
2272
- setLocalDate(void 0);
2273
- } else {
2274
- setLocalDate(newDate);
2275
- }
2276
- setDateInFocus(newDate);
2277
- if (dateInputRef.current) {
2278
- dateInputRef.current.valueAsDate = newDate;
2279
- }
2280
- }, [date, dateInputRef, localTime, onValueChange, setDateInFocus, setLocalDate]);
2281
- const onChangeTime = useCallback((time) => {
2282
- if (!time) {
2283
- return;
2284
- }
2285
- if (date) {
2286
- const newTime = getHoursAndMinutesFromTimeString(time);
2287
- const newDate = new Date(date);
2288
- newDate.setHours(newTime.hour || 0);
2289
- newDate.setMinutes(newTime.minute || 0);
2290
- onValueChange == null ? void 0 : onValueChange(newDate);
2291
- setLocalTime(void 0);
2292
- } else if (localDate) {
2293
- const newTime = getHoursAndMinutesFromTimeString(time);
2294
- const newDate = new Date(localDate);
2295
- newDate.setHours(newTime.hour || 0);
2296
- newDate.setMinutes(newTime.minute || 0);
2297
- onValueChange == null ? void 0 : onValueChange(newDate);
2298
- setLocalTime(void 0);
2299
- } else {
2300
- setLocalTime(time);
2301
- }
2302
- }, [onValueChange, date, localDate, setLocalTime]);
2303
- const inputLeftChangeHandler = useCallback((ev) => {
2304
- if (ev.target.value[0] !== "0") {
2305
- onChangeDate(ev.target.valueAsDate);
2306
- }
2307
- }, [onChangeDate]);
2308
- const inputRightChangeHandler = useCallback((ev) => onChangeTime(ev.target.value), [onChangeTime]);
2309
- const showCalendar = useCallback(() => {
2310
- if (date) {
2311
- setDateInFocus(date);
2312
- } else {
2313
- setDateInFocus(new Date());
2314
- }
2315
- setCurrentPanel("calendar");
2316
- showCalendarInternal();
2317
- }, [date, setCurrentPanel, showCalendarInternal, setDateInFocus]);
2318
- const hideCalendar = useCallback(() => {
2319
- setFirstFocusedInput(void 0);
2320
- hideCalendarInternal();
2321
- }, [setFirstFocusedInput, hideCalendarInternal]);
1819
+ }, _n = (t, e, n) => {
1820
+ Q(
1821
+ function() {
1822
+ t && e(t);
1823
+ },
1824
+ [t, e]
1825
+ ), Q(
1826
+ function() {
1827
+ n.current && (t ? n.current.valueAsDate = new Date(
1828
+ Date.UTC(t.getFullYear(), t.getMonth(), t.getDate())
1829
+ ) : n.current.valueAsDate = null);
1830
+ },
1831
+ [t, n]
1832
+ );
1833
+ }, Jn = (t, e, {
1834
+ setDateInFocus: n,
1835
+ showCalendarInternal: r,
1836
+ hideCalendarInternal: c,
1837
+ setFirstFocusedInput: s,
1838
+ setCurrentPanel: l,
1839
+ localTime: o,
1840
+ setLocalTime: d,
1841
+ localDate: a,
1842
+ setLocalDate: f
1843
+ }, h) => {
1844
+ const u = g(
1845
+ (w) => {
1846
+ if (!w)
1847
+ return;
1848
+ const y = new Date(w);
1849
+ if (t)
1850
+ y.setHours(t.getHours()), y.setMinutes(t.getMinutes()), e == null || e(y), f(void 0);
1851
+ else if (o) {
1852
+ const { minute: M, hour: A } = Tt(o);
1853
+ y.setHours(A != null ? A : 0), y.setMinutes(M != null ? M : 0), e == null || e(y), f(void 0);
1854
+ } else
1855
+ f(y);
1856
+ n(y), h.current && (h.current.valueAsDate = y);
1857
+ },
1858
+ [t, h, o, e, n, f]
1859
+ ), D = g(
1860
+ (w) => {
1861
+ if (!!w)
1862
+ if (t) {
1863
+ const y = Tt(w), M = new Date(t);
1864
+ M.setHours(y.hour || 0), M.setMinutes(y.minute || 0), e == null || e(M), d(void 0);
1865
+ } else if (a) {
1866
+ const y = Tt(w), M = new Date(a);
1867
+ M.setHours(y.hour || 0), M.setMinutes(y.minute || 0), e == null || e(M), d(void 0);
1868
+ } else
1869
+ d(w);
1870
+ },
1871
+ [e, t, a, d]
1872
+ ), m = g(
1873
+ (w) => {
1874
+ w.target.value[0] !== "0" && u(w.target.valueAsDate);
1875
+ },
1876
+ [u]
1877
+ ), k = g(
1878
+ (w) => D(w.target.value),
1879
+ [D]
1880
+ ), p = g(() => {
1881
+ n(t || new Date()), l("calendar"), r();
1882
+ }, [t, l, r, n]), b = g(() => {
1883
+ s(void 0), c();
1884
+ }, [s, c]);
2322
1885
  return {
2323
- inputLeftChangeHandler,
2324
- inputRightChangeHandler,
2325
- hideCalendar,
2326
- showCalendar,
2327
- onChangeTime,
2328
- onChangeDate
1886
+ inputLeftChangeHandler: m,
1887
+ inputRightChangeHandler: k,
1888
+ hideCalendar: b,
1889
+ showCalendar: p,
1890
+ onChangeTime: D,
1891
+ onChangeDate: u
2329
1892
  };
2330
- };
2331
- const useInputStates$1 = (date) => {
2332
- const [localDate, setLocalDate] = useState(void 0);
2333
- const [localTime, setLocalTime] = useState(void 0);
2334
- const [isCalendarVisible, showCalendarInternal, hideCalendarInternal] = useBoolean(false);
2335
- const [isTimePickerVisible, showTimePicker, hideTimePicker] = useBoolean(false);
2336
- const [firstFocusedInput, setFirstFocusedInput] = useState(void 0);
2337
- const [dateInFocus, setDateInFocus] = useState(() => date != null ? date : new Date());
2338
- const [currentPanel, setCurrentPanel] = useState("calendar");
1893
+ }, Kn = (t) => {
1894
+ const [e, n] = S(void 0), [r, c] = S(void 0), [s, l, o] = Yt(!1), [d, a, f] = Yt(!1), [h, u] = S(void 0), [D, m] = S(
1895
+ () => t != null ? t : new Date()
1896
+ ), [k, p] = S("calendar");
2339
1897
  return {
2340
- isCalendarVisible,
2341
- showCalendarInternal,
2342
- hideCalendarInternal,
2343
- firstFocusedInput,
2344
- setFirstFocusedInput,
2345
- dateInFocus,
2346
- setDateInFocus,
2347
- currentPanel,
2348
- setCurrentPanel,
2349
- isTimePickerVisible,
2350
- showTimePicker,
2351
- hideTimePicker,
2352
- localDate,
2353
- setLocalDate,
2354
- localTime,
2355
- setLocalTime
1898
+ isCalendarVisible: s,
1899
+ showCalendarInternal: l,
1900
+ hideCalendarInternal: o,
1901
+ firstFocusedInput: h,
1902
+ setFirstFocusedInput: u,
1903
+ dateInFocus: D,
1904
+ setDateInFocus: m,
1905
+ currentPanel: k,
1906
+ setCurrentPanel: p,
1907
+ isTimePickerVisible: d,
1908
+ showTimePicker: a,
1909
+ hideTimePicker: f,
1910
+ localDate: e,
1911
+ setLocalDate: n,
1912
+ localTime: r,
1913
+ setLocalTime: c
2356
1914
  };
2357
- };
2358
- const useUserInputHandlers$1 = (onChangeDate, dateInputRef, showCalendar, hideCalendar, {
2359
- isCalendarVisible,
2360
- setCurrentPanel,
2361
- showTimePicker,
2362
- hideTimePicker
1915
+ }, Gn = (t, e, n, r, {
1916
+ isCalendarVisible: c,
1917
+ setCurrentPanel: s,
1918
+ showTimePicker: l,
1919
+ hideTimePicker: o
2363
1920
  }) => {
2364
- const onFocusLeft = useCallback(() => {
2365
- if (!isCalendarVisible) {
2366
- showCalendar();
2367
- }
2368
- setCurrentPanel("calendar");
2369
- hideTimePicker();
2370
- }, [hideTimePicker, isCalendarVisible, setCurrentPanel, showCalendar]);
2371
- const onFocusRight = useCallback(() => {
2372
- hideCalendar();
2373
- showTimePicker();
2374
- }, [hideCalendar, showTimePicker]);
2375
- const onClickDay = useCallback((day) => {
2376
- onChangeDate(day.date);
2377
- hideCalendar();
2378
- showTimePicker();
2379
- }, [onChangeDate, hideCalendar, showTimePicker]);
2380
- const onClickArrowButton = useCallback(() => {
2381
- setCurrentPanel("presets");
2382
- showCalendar();
2383
- }, [setCurrentPanel, showCalendar]);
2384
- const onClickCalendarButton = useCallback(() => {
2385
- var _a;
2386
- if (isCalendarVisible) {
2387
- hideCalendar();
2388
- } else {
2389
- (_a = dateInputRef.current) == null ? void 0 : _a.focus();
2390
- setCurrentPanel("calendar");
2391
- showCalendar();
2392
- }
1921
+ const d = g(() => {
1922
+ c || n(), s("calendar"), o();
1923
+ }, [o, c, s, n]), a = g(() => {
1924
+ r(), l();
1925
+ }, [r, l]), f = g(
1926
+ (m) => {
1927
+ t(m.date), r(), l();
1928
+ },
1929
+ [t, r, l]
1930
+ ), h = g(() => {
1931
+ s("presets"), n();
1932
+ }, [s, n]), u = g(() => {
1933
+ var m;
1934
+ c ? r() : ((m = e.current) == null || m.focus(), s("calendar"), n());
2393
1935
  }, [
2394
- isCalendarVisible,
2395
- hideCalendar,
2396
- dateInputRef,
2397
- setCurrentPanel,
2398
- showCalendar
2399
- ]);
2400
- const onKeyDownHandler = useCallback((ev) => {
2401
- if (ev.key === "Escape") {
2402
- hideCalendar();
2403
- }
2404
- }, [hideCalendar]);
1936
+ c,
1937
+ r,
1938
+ e,
1939
+ s,
1940
+ n
1941
+ ]), D = g(
1942
+ (m) => {
1943
+ m.key === "Escape" && r();
1944
+ },
1945
+ [r]
1946
+ );
2405
1947
  return {
2406
- onFocusLeft,
2407
- onFocusRight,
2408
- onClickDay,
2409
- onClickArrowButton,
2410
- onClickCalendarButton,
2411
- onKeyDownHandler
1948
+ onFocusLeft: d,
1949
+ onFocusRight: a,
1950
+ onClickDay: f,
1951
+ onClickArrowButton: h,
1952
+ onClickCalendarButton: u,
1953
+ onKeyDownHandler: D
2412
1954
  };
2413
- };
2414
- const DateTimeInput = ({
2415
- value,
2416
- onValueChange,
2417
- onEnter,
2418
- onEsc,
2419
- onBlur,
2420
- autoFocus,
2421
- minDate,
2422
- widthLeft = 128,
2423
- widthRight = 80,
2424
- maxDate = defaultMaxDate,
2425
- variant,
2426
- disabled
1955
+ }, Ar = ({
1956
+ value: t,
1957
+ onValueChange: e,
1958
+ onEnter: n,
1959
+ onEsc: r,
1960
+ onBlur: c,
1961
+ autoFocus: s,
1962
+ minDate: l,
1963
+ widthLeft: o = 128,
1964
+ widthRight: d = 80,
1965
+ maxDate: a = Mt,
1966
+ variant: f,
1967
+ disabled: h
2427
1968
  }) => {
2428
- const dateInputRef = useRef(null);
2429
- const timeInputRef = useRef(null);
2430
- const states = useInputStates$1(value);
2431
- const {
2432
- setCurrentPanel,
2433
- currentPanel,
2434
- isCalendarVisible,
2435
- dateInFocus,
2436
- setDateInFocus,
2437
- isTimePickerVisible,
2438
- hideTimePicker,
2439
- localTime,
2440
- localDate
2441
- } = states;
2442
- const {
2443
- showCalendar,
2444
- hideCalendar,
2445
- inputLeftChangeHandler,
2446
- inputRightChangeHandler,
2447
- onChangeTime,
2448
- onChangeDate
2449
- } = useDateRangeHandlers$1(value, onValueChange, states, dateInputRef);
2450
- const {
2451
- onKeyDownHandler,
2452
- onFocusRight,
2453
- onFocusLeft,
2454
- onClickDay,
2455
- onClickCalendarButton,
2456
- onClickArrowButton
2457
- } = useUserInputHandlers$1(onChangeDate, dateInputRef, showCalendar, hideCalendar, states);
2458
- useDateRangeEffects$1(value, setDateInFocus, dateInputRef);
2459
- const statePerMonth = useMemo(() => {
2460
- const dateToHighlight = value || localDate;
2461
- if (!dateToHighlight) {
2462
- return {};
2463
- }
2464
- return addDayStateHighlights(void 0, dateToHighlight, ["singleSelected", "selected"]);
2465
- }, [localDate, value]);
2466
- const hideAll = useCallback(() => {
2467
- hideCalendar();
2468
- hideTimePicker();
2469
- }, [hideCalendar, hideTimePicker]);
2470
- const timeValue = useMemo(() => value ? transformTimeInDateToTimeString(value) : localTime, [value, localTime]);
2471
- const delayedIsCalendarVisible = useDelayedFalse(isCalendarVisible, 300);
2472
- const delayedIsTimePickerVisible = useDelayedFalse(isTimePickerVisible, 300);
2473
- return /* @__PURE__ */ jsx(Box, {
2474
- onKeyDown: onKeyDownHandler,
2475
- children: /* @__PURE__ */ jsx(Popover, {
2476
- arrow: false,
2477
- lazy: true,
2478
- disabled,
2479
- placement: defaultPopoverPlacement,
2480
- visible: isCalendarVisible || isTimePickerVisible,
2481
- onClickOutside: hideAll,
2482
- content: (delayedIsCalendarVisible || delayedIsTimePickerVisible) && /* @__PURE__ */ jsx(Column, {
2483
- children: delayedIsCalendarVisible ? /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
2484
- statePerMonth,
2485
- onClickDay,
2486
- dateInFocus,
2487
- setDateInFocus,
2488
- currentPanel,
2489
- setCurrentPanel,
2490
- minDate,
2491
- maxDate
2492
- }) : delayedIsTimePickerVisible ? /* @__PURE__ */ jsxs(Column, {
2493
- children: [/* @__PURE__ */ jsx(Column, {
1969
+ const u = J(null), D = J(null), m = Kn(t), {
1970
+ setCurrentPanel: k,
1971
+ currentPanel: p,
1972
+ isCalendarVisible: b,
1973
+ dateInFocus: w,
1974
+ setDateInFocus: y,
1975
+ isTimePickerVisible: M,
1976
+ hideTimePicker: A,
1977
+ localTime: x,
1978
+ localDate: N
1979
+ } = m, {
1980
+ showCalendar: O,
1981
+ hideCalendar: H,
1982
+ inputLeftChangeHandler: j,
1983
+ inputRightChangeHandler: _,
1984
+ onChangeTime: P,
1985
+ onChangeDate: st
1986
+ } = Jn(t, e, m, u), {
1987
+ onKeyDownHandler: dt,
1988
+ onFocusRight: it,
1989
+ onFocusLeft: K,
1990
+ onClickDay: at,
1991
+ onClickCalendarButton: ft,
1992
+ onClickArrowButton: ut
1993
+ } = Gn(st, u, O, H, m);
1994
+ _n(t, y, u);
1995
+ const v = C(() => {
1996
+ const At = t || N;
1997
+ return At ? X(void 0, At, ["singleSelected", "selected"]) : {};
1998
+ }, [N, t]), L = g(() => {
1999
+ H(), A();
2000
+ }, [H, A]), Y = C(() => t ? Wn(t) : x, [t, x]), Et = Lt(b, 300), Rt = Lt(M, 300);
2001
+ return /* @__PURE__ */ i(I, {
2002
+ onKeyDown: dt,
2003
+ children: /* @__PURE__ */ i(bt, {
2004
+ arrow: !1,
2005
+ lazy: !0,
2006
+ disabled: h,
2007
+ placement: St,
2008
+ visible: b || M,
2009
+ onClickOutside: L,
2010
+ content: (Et || Rt) && /* @__PURE__ */ i(B, {
2011
+ children: Et ? /* @__PURE__ */ i(F, {
2012
+ statePerMonth: v,
2013
+ onClickDay: at,
2014
+ dateInFocus: w,
2015
+ setDateInFocus: y,
2016
+ currentPanel: p,
2017
+ setCurrentPanel: k,
2018
+ minDate: l,
2019
+ maxDate: a
2020
+ }) : Rt ? /* @__PURE__ */ E(B, {
2021
+ children: [/* @__PURE__ */ i(B, {
2494
2022
  overflow: "hidden",
2495
2023
  height: "250px",
2496
- children: /* @__PURE__ */ jsx(TimePicker, {
2497
- value: timeValue != null ? timeValue : "",
2498
- onValueChange: onChangeTime
2024
+ children: /* @__PURE__ */ i(jn, {
2025
+ value: Y != null ? Y : "",
2026
+ onValueChange: P
2499
2027
  })
2500
- }), /* @__PURE__ */ jsx(Space, {}), /* @__PURE__ */ jsx(Row, {
2028
+ }), /* @__PURE__ */ i($, {}), /* @__PURE__ */ i(R, {
2501
2029
  justifyContent: "flex-end",
2502
- children: /* @__PURE__ */ jsx(PrimaryButton, {
2030
+ children: /* @__PURE__ */ i(lt, {
2503
2031
  label: "Done",
2504
- onClick: hideTimePicker
2032
+ onClick: A
2505
2033
  })
2506
2034
  })]
2507
2035
  }) : null
2508
2036
  }),
2509
- children: /* @__PURE__ */ jsx(DualTextInput, {
2510
- autoFocusLeft: autoFocus,
2511
- onEsc,
2512
- onEnter,
2513
- onBlur,
2514
- disabled,
2515
- separatorIcon: stenaClock,
2037
+ children: /* @__PURE__ */ i(ae, {
2038
+ autoFocusLeft: s,
2039
+ onEsc: r,
2040
+ onEnter: n,
2041
+ onBlur: c,
2042
+ disabled: h,
2043
+ separatorIcon: Qt,
2516
2044
  typeLeft: "date",
2517
2045
  typeRight: "time",
2518
2046
  placeholderLeft: "yyyy-mm-dd",
2519
2047
  placeholderRight: "hh:mm",
2520
- onChangeLeft: inputLeftChangeHandler,
2521
- onChangeRight: inputRightChangeHandler,
2522
- onClickArrowDown: onClickArrowButton,
2523
- onClickCalendar: onClickCalendarButton,
2524
- onFocusLeft,
2525
- onFocusRight,
2526
- onClickLeft: onFocusLeft,
2527
- onClickRight: onFocusRight,
2528
- inputRefLeft: dateInputRef,
2529
- inputRefRight: timeInputRef,
2530
- valueRight: timeValue != null ? timeValue : "",
2531
- widthLeft,
2532
- widthRight,
2533
- minLeft: minDate,
2534
- maxLeft: maxDate,
2535
- variant
2048
+ onChangeLeft: j,
2049
+ onChangeRight: _,
2050
+ onClickArrowDown: ut,
2051
+ onClickCalendar: ft,
2052
+ onFocusLeft: K,
2053
+ onFocusRight: it,
2054
+ onClickLeft: K,
2055
+ onClickRight: it,
2056
+ inputRefLeft: u,
2057
+ inputRefRight: D,
2058
+ valueRight: Y != null ? Y : "",
2059
+ widthLeft: o,
2060
+ widthRight: d,
2061
+ minLeft: l,
2062
+ maxLeft: a,
2063
+ variant: f
2536
2064
  })
2537
2065
  })
2538
2066
  });
2539
- };
2540
- const useDateRangeEffects = (startDate, endDate, setDateInFocus, startDateInputRef, endDateInputRef) => {
2541
- useEffect(function moveFocusedDateWhenStartDateChanges() {
2542
- if (startDate) {
2543
- setDateInFocus(startDate);
2544
- }
2545
- }, [startDate, setDateInFocus]);
2546
- useEffect(function moveFocusedDateWhenEndDateChanges() {
2547
- if (endDate) {
2548
- setDateInFocus(endDate);
2549
- }
2550
- }, [endDate, setDateInFocus]);
2551
- useEffect(function updateStartDateFieldWhenValueChanges() {
2552
- if (startDateInputRef.current) {
2553
- if (startDate) {
2554
- startDateInputRef.current.valueAsDate = new Date(Date.UTC(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()));
2555
- } else {
2556
- startDateInputRef.current.valueAsDate = null;
2557
- }
2558
- }
2559
- }, [startDate, startDateInputRef]);
2560
- useEffect(function updateEndDateFieldWhenValueChanges() {
2561
- if (endDateInputRef.current) {
2562
- if (endDate) {
2563
- endDateInputRef.current.valueAsDate = new Date(Date.UTC(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()));
2564
- } else {
2565
- endDateInputRef.current.valueAsDate = null;
2566
- }
2567
- }
2568
- }, [endDate, endDateInputRef]);
2569
- };
2570
- const useDateRangeHandlers = (startDate, endDate, onValueChange, {
2571
- setDateInFocus,
2572
- showCalendarInternal,
2573
- hideCalendarInternal,
2574
- setFirstFocusedInput,
2575
- setCurrentPanel
2067
+ }, qn = (t, e, n, r, c) => {
2068
+ Q(
2069
+ function() {
2070
+ t && n(t);
2071
+ },
2072
+ [t, n]
2073
+ ), Q(
2074
+ function() {
2075
+ e && n(e);
2076
+ },
2077
+ [e, n]
2078
+ ), Q(
2079
+ function() {
2080
+ r.current && (t ? r.current.valueAsDate = new Date(
2081
+ Date.UTC(
2082
+ t.getFullYear(),
2083
+ t.getMonth(),
2084
+ t.getDate()
2085
+ )
2086
+ ) : r.current.valueAsDate = null);
2087
+ },
2088
+ [t, r]
2089
+ ), Q(
2090
+ function() {
2091
+ c.current && (e ? c.current.valueAsDate = new Date(
2092
+ Date.UTC(
2093
+ e.getFullYear(),
2094
+ e.getMonth(),
2095
+ e.getDate()
2096
+ )
2097
+ ) : c.current.valueAsDate = null);
2098
+ },
2099
+ [e, c]
2100
+ );
2101
+ }, Qn = (t, e, n, {
2102
+ setDateInFocus: r,
2103
+ showCalendarInternal: c,
2104
+ hideCalendarInternal: s,
2105
+ setFirstFocusedInput: l,
2106
+ setCurrentPanel: o
2576
2107
  }) => {
2577
- const inputLeftChangeHandler = useCallback((ev) => {
2578
- var _a;
2579
- if (ev.target.value[0] !== "0") {
2580
- onValueChange == null ? void 0 : onValueChange({
2581
- startDate: (_a = ev.target.valueAsDate) != null ? _a : void 0,
2582
- endDate
2583
- });
2584
- }
2585
- }, [onValueChange, endDate]);
2586
- const inputRightChangeHandler = useCallback((ev) => {
2587
- var _a;
2588
- if (ev.target.value[0] !== "0") {
2589
- onValueChange == null ? void 0 : onValueChange({
2590
- startDate,
2591
- endDate: (_a = ev.target.valueAsDate) != null ? _a : void 0
2592
- });
2593
- }
2594
- }, [onValueChange, startDate]);
2595
- const showCalendar = useCallback(() => {
2596
- if (startDate) {
2597
- setDateInFocus(startDate);
2598
- } else if (endDate) {
2599
- setDateInFocus(endDate);
2600
- } else {
2601
- setDateInFocus(new Date());
2602
- }
2603
- setCurrentPanel("calendar");
2604
- showCalendarInternal();
2108
+ const d = g(
2109
+ (u) => {
2110
+ var D;
2111
+ u.target.value[0] !== "0" && (n == null || n({
2112
+ startDate: (D = u.target.valueAsDate) != null ? D : void 0,
2113
+ endDate: e
2114
+ }));
2115
+ },
2116
+ [n, e]
2117
+ ), a = g(
2118
+ (u) => {
2119
+ var D;
2120
+ u.target.value[0] !== "0" && (n == null || n({
2121
+ startDate: t,
2122
+ endDate: (D = u.target.valueAsDate) != null ? D : void 0
2123
+ }));
2124
+ },
2125
+ [n, t]
2126
+ ), f = g(() => {
2127
+ r(t || e || new Date()), o("calendar"), c();
2605
2128
  }, [
2606
- startDate,
2607
- endDate,
2608
- setCurrentPanel,
2609
- showCalendarInternal,
2610
- setDateInFocus
2611
- ]);
2612
- const hideCalendar = useCallback(() => {
2613
- setFirstFocusedInput(void 0);
2614
- hideCalendarInternal();
2615
- }, [setFirstFocusedInput, hideCalendarInternal]);
2129
+ t,
2130
+ e,
2131
+ o,
2132
+ c,
2133
+ r
2134
+ ]), h = g(() => {
2135
+ l(void 0), s();
2136
+ }, [l, s]);
2616
2137
  return {
2617
- inputLeftChangeHandler,
2618
- inputRightChangeHandler,
2619
- hideCalendar,
2620
- setDateInFocus,
2621
- setCurrentPanel,
2622
- showCalendar
2138
+ inputLeftChangeHandler: d,
2139
+ inputRightChangeHandler: a,
2140
+ hideCalendar: h,
2141
+ setDateInFocus: r,
2142
+ setCurrentPanel: o,
2143
+ showCalendar: f
2623
2144
  };
2624
- };
2625
- const useInputStates = (startDate, endDate) => {
2626
- const [isCalendarVisible, showCalendarInternal, hideCalendarInternal] = useBoolean(false);
2627
- const [firstFocusedInput, setFirstFocusedInput] = useState(void 0);
2628
- const [focusedInput, setFocusedInput] = useState("startDate");
2629
- const [dateInFocus, setDateInFocus] = useState(() => {
2630
- const fromValue = focusedInput === "startDate" ? startDate : focusedInput === "endDate" ? endDate : void 0;
2631
- return fromValue != null ? fromValue : new Date();
2632
- });
2633
- const [currentPanel, setCurrentPanel] = useState("calendar");
2145
+ }, Xn = (t, e) => {
2146
+ const [n, r, c] = Yt(!1), [s, l] = S(void 0), [o, d] = S("startDate"), [a, f] = S(() => {
2147
+ const D = o === "startDate" ? t : o === "endDate" ? e : void 0;
2148
+ return D != null ? D : new Date();
2149
+ }), [h, u] = S("calendar");
2634
2150
  return {
2635
- isCalendarVisible,
2636
- showCalendarInternal,
2637
- hideCalendarInternal,
2638
- firstFocusedInput,
2639
- setFirstFocusedInput,
2640
- focusedInput,
2641
- setFocusedInput,
2642
- dateInFocus,
2643
- setDateInFocus,
2644
- currentPanel,
2645
- setCurrentPanel
2151
+ isCalendarVisible: n,
2152
+ showCalendarInternal: r,
2153
+ hideCalendarInternal: c,
2154
+ firstFocusedInput: s,
2155
+ setFirstFocusedInput: l,
2156
+ focusedInput: o,
2157
+ setFocusedInput: d,
2158
+ dateInFocus: a,
2159
+ setDateInFocus: f,
2160
+ currentPanel: h,
2161
+ setCurrentPanel: u
2646
2162
  };
2647
- };
2648
- const useUserInputHandlers = (startDate, endDate, onValueChange, startDateInputRef, endDateInputRef, showCalendar, hideCalendar, {
2649
- firstFocusedInput,
2650
- setFirstFocusedInput,
2651
- isCalendarVisible,
2652
- setFocusedInput,
2653
- focusedInput,
2654
- setCurrentPanel
2163
+ }, Zn = (t, e, n, r, c, s, l, {
2164
+ firstFocusedInput: o,
2165
+ setFirstFocusedInput: d,
2166
+ isCalendarVisible: a,
2167
+ setFocusedInput: f,
2168
+ focusedInput: h,
2169
+ setCurrentPanel: u
2655
2170
  }) => {
2656
- const onFocusLeft = useCallback(() => {
2657
- if (firstFocusedInput == null) {
2658
- setFirstFocusedInput("startDate");
2659
- }
2660
- setFocusedInput("startDate");
2661
- if (!isCalendarVisible) {
2662
- showCalendar();
2663
- }
2664
- }, [
2665
- isCalendarVisible,
2666
- setFocusedInput,
2667
- showCalendar,
2668
- setFirstFocusedInput,
2669
- firstFocusedInput
2670
- ]);
2671
- const onFocusRight = useCallback(() => {
2672
- if (firstFocusedInput == null) {
2673
- setFirstFocusedInput("endDate");
2674
- }
2675
- setFocusedInput("endDate");
2676
- if (!isCalendarVisible) {
2677
- showCalendar();
2678
- }
2171
+ const D = g(() => {
2172
+ o == null && d("startDate"), f("startDate"), a || s();
2679
2173
  }, [
2680
- isCalendarVisible,
2681
- setFocusedInput,
2682
- showCalendar,
2683
- setFirstFocusedInput,
2684
- firstFocusedInput
2685
- ]);
2686
- const onClickDay = useCallback((day) => {
2687
- var _a, _b, _c, _d;
2688
- if (focusedInput === "startDate") {
2689
- if (endDate != null && isAfter(day.date, endDate)) {
2690
- onValueChange == null ? void 0 : onValueChange({
2691
- startDate: day.date,
2692
- endDate: void 0
2693
- });
2694
- setFocusedInput("endDate");
2695
- (_a = endDateInputRef.current) == null ? void 0 : _a.focus();
2696
- } else {
2697
- onValueChange == null ? void 0 : onValueChange({
2698
- startDate: day.date,
2699
- endDate
2700
- });
2701
- if (firstFocusedInput === "startDate") {
2702
- setFocusedInput("endDate");
2703
- (_b = endDateInputRef.current) == null ? void 0 : _b.focus();
2704
- } else {
2705
- setTimeout(hideCalendar, 50);
2706
- }
2707
- }
2708
- } else if (focusedInput === "endDate") {
2709
- if (!startDate) {
2710
- onValueChange == null ? void 0 : onValueChange({
2711
- startDate,
2712
- endDate: day.date
2713
- });
2714
- setFocusedInput("startDate");
2715
- (_c = startDateInputRef.current) == null ? void 0 : _c.focus();
2716
- } else if (isAfter(startDate, day.date)) {
2717
- onValueChange == null ? void 0 : onValueChange({
2718
- startDate: day.date,
2719
- endDate: void 0
2720
- });
2721
- setFocusedInput("endDate");
2722
- (_d = endDateInputRef.current) == null ? void 0 : _d.focus();
2723
- } else {
2724
- onValueChange == null ? void 0 : onValueChange({
2725
- startDate,
2726
- endDate: day.date
2727
- });
2728
- setTimeout(hideCalendar, 50);
2729
- }
2730
- }
2174
+ a,
2175
+ f,
2176
+ s,
2177
+ d,
2178
+ o
2179
+ ]), m = g(() => {
2180
+ o == null && d("endDate"), f("endDate"), a || s();
2731
2181
  }, [
2732
- focusedInput,
2733
- onValueChange,
2734
- endDate,
2735
- firstFocusedInput,
2736
- setFocusedInput,
2737
- endDateInputRef,
2738
- hideCalendar,
2739
- startDate,
2740
- startDateInputRef
2741
- ]);
2742
- const onClickArrowButton = useCallback(() => {
2743
- setCurrentPanel("presets");
2744
- showCalendar();
2745
- }, [setCurrentPanel, showCalendar]);
2746
- const onClickCalendarButton = useCallback(() => {
2747
- var _a;
2748
- if (isCalendarVisible) {
2749
- hideCalendar();
2750
- } else {
2751
- setFocusedInput("startDate");
2752
- setFirstFocusedInput("startDate");
2753
- (_a = startDateInputRef.current) == null ? void 0 : _a.focus();
2754
- setCurrentPanel("calendar");
2755
- showCalendar();
2756
- }
2182
+ a,
2183
+ f,
2184
+ s,
2185
+ d,
2186
+ o
2187
+ ]), k = g(
2188
+ (y) => {
2189
+ var M, A, x, N;
2190
+ h === "startDate" ? e != null && nt(y.date, e) ? (n == null || n({
2191
+ startDate: y.date,
2192
+ endDate: void 0
2193
+ }), f("endDate"), (M = c.current) == null || M.focus()) : (n == null || n({
2194
+ startDate: y.date,
2195
+ endDate: e
2196
+ }), o === "startDate" ? (f("endDate"), (A = c.current) == null || A.focus()) : setTimeout(l, 50)) : h === "endDate" && (t ? nt(t, y.date) ? (n == null || n({
2197
+ startDate: y.date,
2198
+ endDate: void 0
2199
+ }), f("endDate"), (N = c.current) == null || N.focus()) : (n == null || n({
2200
+ startDate: t,
2201
+ endDate: y.date
2202
+ }), setTimeout(l, 50)) : (n == null || n({
2203
+ startDate: t,
2204
+ endDate: y.date
2205
+ }), f("startDate"), (x = r.current) == null || x.focus()));
2206
+ },
2207
+ [
2208
+ h,
2209
+ n,
2210
+ e,
2211
+ o,
2212
+ f,
2213
+ c,
2214
+ l,
2215
+ t,
2216
+ r
2217
+ ]
2218
+ ), p = g(() => {
2219
+ u("presets"), s();
2220
+ }, [u, s]), b = g(() => {
2221
+ var y;
2222
+ a ? l() : (f("startDate"), d("startDate"), (y = r.current) == null || y.focus(), u("calendar"), s());
2757
2223
  }, [
2758
- isCalendarVisible,
2759
- hideCalendar,
2760
- setFocusedInput,
2761
- setFirstFocusedInput,
2762
- startDateInputRef,
2763
- setCurrentPanel,
2764
- showCalendar
2765
- ]);
2766
- const onKeyDownHandler = useCallback((ev) => {
2767
- if (ev.key === "Escape") {
2768
- hideCalendar();
2769
- }
2770
- }, [hideCalendar]);
2224
+ a,
2225
+ l,
2226
+ f,
2227
+ d,
2228
+ r,
2229
+ u,
2230
+ s
2231
+ ]), w = g(
2232
+ (y) => {
2233
+ y.key === "Escape" && l();
2234
+ },
2235
+ [l]
2236
+ );
2771
2237
  return {
2772
- onFocusLeft,
2773
- onFocusRight,
2774
- onClickDay,
2775
- onClickArrowButton,
2776
- onClickCalendarButton,
2777
- onKeyDownHandler
2238
+ onFocusLeft: D,
2239
+ onFocusRight: m,
2240
+ onClickDay: k,
2241
+ onClickArrowButton: p,
2242
+ onClickCalendarButton: b,
2243
+ onKeyDownHandler: w
2778
2244
  };
2779
2245
  };
2780
- const DateRangeDualTextInput = ({
2781
- value,
2782
- onValueChange,
2783
- autoFocus,
2784
- onBlur,
2785
- onEnter,
2786
- onEsc,
2787
- minDate,
2788
- maxDate = defaultMaxDate,
2789
- calendarProps,
2790
- widthLeft = 128,
2791
- widthRight = 128,
2792
- variant,
2793
- disabled
2794
- }) => {
2795
- const {
2796
- startDate,
2797
- endDate
2798
- } = value || {};
2799
- const startDateInputRef = useRef(null);
2800
- const endDateInputRef = useRef(null);
2801
- const states = useInputStates(startDate, endDate);
2802
- const {
2803
- dateInFocus,
2804
- setDateInFocus,
2805
- isCalendarVisible,
2806
- currentPanel,
2807
- setCurrentPanel
2808
- } = states;
2809
- const {
2810
- showCalendar,
2811
- hideCalendar,
2812
- inputLeftChangeHandler,
2813
- inputRightChangeHandler
2814
- } = useDateRangeHandlers(startDate, endDate, onValueChange, states);
2246
+ function Tr({
2247
+ value: t,
2248
+ onValueChange: e,
2249
+ autoFocus: n,
2250
+ onBlur: r,
2251
+ onEnter: c,
2252
+ onEsc: s,
2253
+ minDate: l,
2254
+ maxDate: o = Mt,
2255
+ calendarProps: d,
2256
+ widthLeft: a = 128,
2257
+ widthRight: f = 128,
2258
+ variant: h,
2259
+ disabled: u
2260
+ }) {
2815
2261
  const {
2816
- onKeyDownHandler,
2817
- onFocusRight,
2818
- onFocusLeft,
2819
- onClickDay,
2820
- onClickCalendarButton,
2821
- onClickArrowButton
2822
- } = useUserInputHandlers(startDate, endDate, onValueChange, startDateInputRef, endDateInputRef, showCalendar, hideCalendar, states);
2823
- useDateRangeEffects(startDate, endDate, setDateInFocus, startDateInputRef, endDateInputRef);
2824
- const startDateIsAfterEnd = useMemo(() => startDate && endDate && isAfter(startDate, endDate), [startDate, endDate]);
2825
- const statePerMonth = useMemo(() => buildDayStateForSingleMonth(calendarProps == null ? void 0 : calendarProps.statePerMonth, startDate, endDate, dateInFocus), [calendarProps == null ? void 0 : calendarProps.statePerMonth, startDate, endDate, dateInFocus]);
2826
- const delayedIsCalendarVisible = useDelayedFalse(isCalendarVisible, 300);
2827
- return /* @__PURE__ */ jsx(Box, {
2828
- onKeyDown: onKeyDownHandler,
2829
- children: /* @__PURE__ */ jsx(Popover, {
2830
- arrow: false,
2831
- lazy: true,
2832
- disabled,
2833
- placement: defaultPopoverPlacement,
2834
- onClickOutside: hideCalendar,
2835
- visible: isCalendarVisible,
2836
- content: delayedIsCalendarVisible && /* @__PURE__ */ jsx(CalendarWithMonthSwitcher, {
2837
- onClickDay,
2838
- dateInFocus,
2839
- setDateInFocus,
2840
- currentPanel,
2841
- setCurrentPanel,
2842
- minDate,
2843
- maxDate,
2844
- ...calendarProps,
2845
- statePerMonth
2262
+ startDate: D,
2263
+ endDate: m
2264
+ } = t || {}, k = J(null), p = J(null), b = Xn(D, m), {
2265
+ dateInFocus: w,
2266
+ setDateInFocus: y,
2267
+ isCalendarVisible: M,
2268
+ currentPanel: A,
2269
+ setCurrentPanel: x
2270
+ } = b, {
2271
+ showCalendar: N,
2272
+ hideCalendar: O,
2273
+ inputLeftChangeHandler: H,
2274
+ inputRightChangeHandler: j
2275
+ } = Qn(D, m, e, b), {
2276
+ onKeyDownHandler: _,
2277
+ onFocusRight: P,
2278
+ onFocusLeft: st,
2279
+ onClickDay: dt,
2280
+ onClickCalendarButton: it,
2281
+ onClickArrowButton: K
2282
+ } = Zn(D, m, e, k, p, N, O, b);
2283
+ qn(D, m, y, k, p);
2284
+ const at = C(() => D && m && nt(D, m), [D, m]), ft = C(() => We(d == null ? void 0 : d.statePerMonth, D, m, w), [d == null ? void 0 : d.statePerMonth, D, m, w]), ut = Lt(M, 300);
2285
+ return /* @__PURE__ */ i(I, {
2286
+ onKeyDown: _,
2287
+ children: /* @__PURE__ */ i(bt, {
2288
+ arrow: !1,
2289
+ lazy: !0,
2290
+ disabled: u,
2291
+ placement: St,
2292
+ onClickOutside: O,
2293
+ visible: M,
2294
+ content: ut && /* @__PURE__ */ i(F, {
2295
+ onClickDay: dt,
2296
+ dateInFocus: w,
2297
+ setDateInFocus: y,
2298
+ currentPanel: A,
2299
+ setCurrentPanel: x,
2300
+ minDate: l,
2301
+ maxDate: o,
2302
+ ...d,
2303
+ statePerMonth: ft
2846
2304
  }),
2847
- children: /* @__PURE__ */ jsx(DualTextInput, {
2848
- autoFocusLeft: autoFocus,
2849
- onEsc,
2850
- onEnter,
2851
- onBlur,
2852
- disabled,
2853
- separatorIcon: stenaArrowRight,
2305
+ children: /* @__PURE__ */ i(ae, {
2306
+ autoFocusLeft: n,
2307
+ onEsc: s,
2308
+ onEnter: c,
2309
+ onBlur: r,
2310
+ disabled: u,
2311
+ separatorIcon: he,
2854
2312
  typeLeft: "date",
2855
2313
  typeRight: "date",
2856
2314
  placeholderLeft: "Start date",
2857
2315
  placeholderRight: "End date",
2858
- onChangeLeft: inputLeftChangeHandler,
2859
- onChangeRight: inputRightChangeHandler,
2860
- onClickArrowDown: onClickArrowButton,
2861
- onClickCalendar: onClickCalendarButton,
2862
- onFocusLeft,
2863
- onFocusRight,
2864
- onClickLeft: onFocusLeft,
2865
- onClickRight: onFocusRight,
2866
- inputRefLeft: startDateInputRef,
2867
- inputRefRight: endDateInputRef,
2868
- variant: startDateIsAfterEnd ? "error" : variant,
2869
- widthLeft,
2870
- widthRight,
2871
- minLeft: minDate,
2872
- maxLeft: maxDate,
2873
- minRight: minDate,
2874
- maxRight: maxDate
2316
+ onChangeLeft: H,
2317
+ onChangeRight: j,
2318
+ onClickArrowDown: K,
2319
+ onClickCalendar: it,
2320
+ onFocusLeft: st,
2321
+ onFocusRight: P,
2322
+ onClickLeft: st,
2323
+ onClickRight: P,
2324
+ inputRefLeft: k,
2325
+ inputRefRight: p,
2326
+ variant: at ? "error" : h,
2327
+ widthLeft: a,
2328
+ widthRight: f,
2329
+ minLeft: l,
2330
+ maxLeft: o,
2331
+ minRight: l,
2332
+ maxRight: o
2875
2333
  })
2876
2334
  })
2877
2335
  });
2336
+ }
2337
+ export {
2338
+ Ut as Calendar,
2339
+ ce as CalendarDay,
2340
+ Sr as DateInput,
2341
+ mr as DateRangeCalendar,
2342
+ Tr as DateRangeDualTextInput,
2343
+ kr as DateRangeExclusionCalendar,
2344
+ Mr as DateRangeInput,
2345
+ Er as DateTextInput,
2346
+ Ar as DateTimeInput,
2347
+ U as Month,
2348
+ un as MonthPicker,
2349
+ pr as MultiDateCalendar,
2350
+ hn as PresetPicker,
2351
+ le as SingleDateCalendar,
2352
+ br as SingleWeekCalendar,
2353
+ Rr as TimeTextInput,
2354
+ Be as WeekDay,
2355
+ Ve as WeekDayCell,
2356
+ Fe as WeekNumberCell,
2357
+ yn as YearPicker,
2358
+ X as addDayStateHighlights,
2359
+ ne as addDayStateHighlightsOnSingleDay,
2360
+ $e as addWeekRangeHighlights,
2361
+ hr as addWeekStateHighlights,
2362
+ wt as buildDayStateForDateRange,
2363
+ Oe as buildDayStateForRange,
2364
+ We as buildDayStateForSingleMonth,
2365
+ Ke as calculateOverflowingMonth,
2366
+ je as createDay,
2367
+ kn as dateRangeToStrings,
2368
+ Ge as dayHasHighlight,
2369
+ V as dayHighlightSelect,
2370
+ ct as defaultCalendarTheme,
2371
+ Qe as defaultTextPropsProvider,
2372
+ qe as defaultWrapperStyleProvider,
2373
+ gr as extranetCalendarTheme,
2374
+ _e as getDaysForWeekForDate,
2375
+ re as getMonthInYear,
2376
+ Jt as getMonthsInYear,
2377
+ Je as getStartDateOfISOWeek,
2378
+ jt as getWeekForDate,
2379
+ ze as getWeeksForMonth,
2380
+ se as isDateRangeInvalid,
2381
+ ur as setDayStateValue,
2382
+ Dr as setDayStateValueFunction,
2383
+ Sn as stringsToDateRange,
2384
+ yr as toggleDateStringsIfEndIsEarlierThanStart,
2385
+ ie as toggleDatesIfEndIsEarlierThanStart,
2386
+ wr as useDateRangeCalendarState,
2387
+ Cn as useDateRangeExclusionSelection,
2388
+ Mn as useDateRangeSelection,
2389
+ Rn as useMultiDateSelection,
2390
+ En as useSingleDateSelection,
2391
+ An as useSingleWeekSelection
2878
2392
  };
2879
- export { Calendar, CalendarDay, DateInput, DateRangeCalendar, DateRangeDualTextInput, DateRangeExclusionCalendar, DateRangeInput, DateTextInput, DateTimeInput, Month, MonthPicker, MultiDateCalendar, PresetPicker, SingleDateCalendar, SingleWeekCalendar, TimeTextInput, WeekDay, WeekDayCell, WeekNumberCell, YearPicker, addDayStateHighlights, addDayStateHighlightsOnSingleDay, addWeekRangeHighlights, addWeekStateHighlights, buildDayStateForDateRange, buildDayStateForRange, buildDayStateForSingleMonth, calculateOverflowingMonth, createDay, dateRangeToStrings, dayHasHighlight, dayHighlightSelect, defaultCalendarTheme, defaultTextPropsProvider, defaultWrapperStyleProvider, extranetCalendarTheme, getDaysForWeekForDate, getMonthInYear, getMonthsInYear, getStartDateOfISOWeek, getWeekForDate, getWeeksForMonth, isDateRangeInvalid, setDayStateValue, setDayStateValueFunction, stringsToDateRange, toggleDateStringsIfEndIsEarlierThanStart, toggleDatesIfEndIsEarlierThanStart, useDateRangeCalendarState, useDateRangeExclusionSelection, useDateRangeSelection, useMultiDateSelection, useSingleDateSelection, useSingleWeekSelection };
2880
2393
  //# sourceMappingURL=index.es.js.map