linear-react-components-ui 2.1.0-beta.5 → 2.2.0-beta.0
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/lib/assets/styles/datepicker2.css +11 -81
- package/lib/form2/useForm/index.js +1 -0
- package/lib/form2/useForm/index.js.map +1 -1
- package/lib/inputs2/date/{hooks/useCalendarPosition.d.ts → base/constants.d.ts} +1 -1
- package/lib/inputs2/date/base/constants.js +69 -0
- package/lib/inputs2/date/base/constants.js.map +1 -0
- package/lib/inputs2/date/datefield/base.js +214 -691
- package/lib/inputs2/date/datefield/base.js.map +1 -1
- package/lib/inputs2/date/datefield/calendarbox.d.ts +6 -0
- package/lib/inputs2/date/datefield/calendarbox.js +228 -0
- package/lib/inputs2/date/datefield/calendarbox.js.map +1 -0
- package/lib/inputs2/date/datefield/triggers.js +4 -4
- package/lib/inputs2/date/datefield/triggers.js.map +1 -1
- package/lib/inputs2/date/datefield/types.d.ts +12 -5
- package/lib/inputs2/date/dateperiodfield/base.js +809 -694
- package/lib/inputs2/date/dateperiodfield/base.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/calendarbox.d.ts +6 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.js +282 -0
- package/lib/inputs2/date/dateperiodfield/calendarbox.js.map +1 -0
- package/lib/inputs2/date/dateperiodfield/triggers.js +9 -21
- package/lib/inputs2/date/dateperiodfield/triggers.js.map +1 -1
- package/lib/inputs2/date/dateperiodfield/types.d.ts +23 -13
- package/lib/inputs2/date/helpers.d.ts +4 -44
- package/lib/inputs2/date/helpers.js +4 -200
- package/lib/inputs2/date/helpers.js.map +1 -1
- package/lib/inputs2/date/types.d.ts +1 -22
- package/lib/inputs2/date/types.js.map +1 -1
- package/lib/node_modules/lodash/lodash.js +2 -2
- package/lib/node_modules/lodash/lodash.js.map +1 -1
- package/package.json +1 -1
- package/lib/inputs2/date/calendarbox.d.ts +0 -23
- package/lib/inputs2/date/calendarbox.js +0 -254
- package/lib/inputs2/date/calendarbox.js.map +0 -1
- package/lib/inputs2/date/hooks/useCalendarPosition.js +0 -93
- package/lib/inputs2/date/hooks/useCalendarPosition.js.map +0 -1
- package/lib/inputs2/date/hooks/useDateCalendarState.d.ts +0 -14
- package/lib/inputs2/date/hooks/useDateCalendarState.js +0 -250
- package/lib/inputs2/date/hooks/useDateCalendarState.js.map +0 -1
- package/lib/inputs2/date/hooks/useDateMask.d.ts +0 -22
- package/lib/inputs2/date/hooks/useDateMask.js +0 -143
- package/lib/inputs2/date/hooks/useDateMask.js.map +0 -1
- package/lib/inputs2/date/timeselector.d.ts +0 -17
- package/lib/inputs2/date/timeselector.js +0 -226
- package/lib/inputs2/date/timeselector.js.map +0 -1
- package/lib/node_modules/moment/dist/locale/pt-br.js +0 -54
- package/lib/node_modules/moment/dist/locale/pt-br.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Moment } from 'moment';
|
|
2
|
-
import { ReactNode, RefObject } from 'react';
|
|
3
|
-
interface CalendarDayState {
|
|
4
|
-
isSelected: boolean;
|
|
5
|
-
isInRange?: boolean;
|
|
6
|
-
isDisabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
interface CalendarBoxProps {
|
|
9
|
-
testIdPrefix: string;
|
|
10
|
-
headerId: string;
|
|
11
|
-
calendarBoxOpen: boolean;
|
|
12
|
-
activeDescendant: string;
|
|
13
|
-
calendarDisplayDate: Moment;
|
|
14
|
-
containerRef: RefObject<HTMLDivElement | null>;
|
|
15
|
-
onNextMonth: () => void;
|
|
16
|
-
onPreviousMonth: () => void;
|
|
17
|
-
getDayState: (day: Moment) => CalendarDayState;
|
|
18
|
-
onSelectDay: (day: Moment) => void;
|
|
19
|
-
children?: ReactNode;
|
|
20
|
-
}
|
|
21
|
-
declare const CalendarBox: import('react').ForwardRefExoticComponent<CalendarBoxProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
22
|
-
export { CalendarBox };
|
|
23
|
-
export type { CalendarBoxProps, CalendarDayState };
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { c as compilerRuntimeExports } from "../../_virtual/compiler-runtime.js";
|
|
3
|
-
import _ from "../../_virtual/lodash.js";
|
|
4
|
-
import hooks from "../../node_modules/moment/dist/moment.js";
|
|
5
|
-
import { forwardRef, useRef } from "react";
|
|
6
|
-
import Button from "../../buttons/Button.js";
|
|
7
|
-
import '../../assets/styles/button.css';/* empty css */
|
|
8
|
-
import { mergeRefs } from "../../form2/helpers.js";
|
|
9
|
-
import TextContent from "../../textContent/index.js";
|
|
10
|
-
import { generateCalendarWeeks, TOKEN_ISO_FORMAT } from "./helpers.js";
|
|
11
|
-
import { useCalendarPosition } from "./hooks/useCalendarPosition.js";
|
|
12
|
-
const CalendarBox = forwardRef((props, ref) => {
|
|
13
|
-
const $ = compilerRuntimeExports.c(69);
|
|
14
|
-
const {
|
|
15
|
-
testIdPrefix,
|
|
16
|
-
headerId,
|
|
17
|
-
calendarBoxOpen,
|
|
18
|
-
activeDescendant,
|
|
19
|
-
calendarDisplayDate,
|
|
20
|
-
containerRef,
|
|
21
|
-
onNextMonth,
|
|
22
|
-
onPreviousMonth,
|
|
23
|
-
getDayState,
|
|
24
|
-
onSelectDay,
|
|
25
|
-
children
|
|
26
|
-
} = props;
|
|
27
|
-
const calendarBoxRef = useRef(null);
|
|
28
|
-
const {
|
|
29
|
-
calendarBoxStyles
|
|
30
|
-
} = useCalendarPosition(calendarBoxOpen, containerRef, calendarBoxRef);
|
|
31
|
-
let t0;
|
|
32
|
-
let t1;
|
|
33
|
-
let t10;
|
|
34
|
-
let t11;
|
|
35
|
-
let t2;
|
|
36
|
-
let t3;
|
|
37
|
-
let t4;
|
|
38
|
-
let t5;
|
|
39
|
-
let t6;
|
|
40
|
-
let t7;
|
|
41
|
-
let t8;
|
|
42
|
-
let t9;
|
|
43
|
-
if ($[0] !== activeDescendant || $[1] !== calendarBoxOpen || $[2] !== calendarBoxStyles || $[3] !== calendarDisplayDate || $[4] !== getDayState || $[5] !== headerId || $[6] !== onNextMonth || $[7] !== onPreviousMonth || $[8] !== onSelectDay || $[9] !== ref || $[10] !== testIdPrefix) {
|
|
44
|
-
const weeks = generateCalendarWeeks(calendarDisplayDate);
|
|
45
|
-
const handleOnMouseDown = _temp;
|
|
46
|
-
if ($[23] !== ref) {
|
|
47
|
-
t5 = mergeRefs(ref, calendarBoxRef);
|
|
48
|
-
$[23] = ref;
|
|
49
|
-
$[24] = t5;
|
|
50
|
-
} else {
|
|
51
|
-
t5 = $[24];
|
|
52
|
-
}
|
|
53
|
-
t6 = calendarBoxStyles;
|
|
54
|
-
t7 = calendarBoxOpen;
|
|
55
|
-
t8 = "date-calendar-box";
|
|
56
|
-
t9 = `${testIdPrefix}-calendar-box`;
|
|
57
|
-
let t122;
|
|
58
|
-
if ($[25] !== onPreviousMonth) {
|
|
59
|
-
t122 = /* @__PURE__ */ jsx(Button, { boxShadow: false, type: "button", iconName: "arrow_left", title: "Mês anterior", className: "previous-month", "aria-label": "Mês anterior", onClick: onPreviousMonth, onMouseDown: handleOnMouseDown });
|
|
60
|
-
$[25] = onPreviousMonth;
|
|
61
|
-
$[26] = t122;
|
|
62
|
-
} else {
|
|
63
|
-
t122 = $[26];
|
|
64
|
-
}
|
|
65
|
-
let t132;
|
|
66
|
-
if ($[27] !== calendarDisplayDate) {
|
|
67
|
-
t132 = calendarDisplayDate.format("MMMM YYYY");
|
|
68
|
-
$[27] = calendarDisplayDate;
|
|
69
|
-
$[28] = t132;
|
|
70
|
-
} else {
|
|
71
|
-
t132 = $[28];
|
|
72
|
-
}
|
|
73
|
-
const t142 = `${testIdPrefix}-calendar-box-month-description`;
|
|
74
|
-
let t152;
|
|
75
|
-
if ($[29] !== calendarDisplayDate) {
|
|
76
|
-
t152 = calendarDisplayDate.format("MMMM YYYY");
|
|
77
|
-
$[29] = calendarDisplayDate;
|
|
78
|
-
$[30] = t152;
|
|
79
|
-
} else {
|
|
80
|
-
t152 = $[30];
|
|
81
|
-
}
|
|
82
|
-
let t16;
|
|
83
|
-
if ($[31] !== t132 || $[32] !== t142 || $[33] !== t152) {
|
|
84
|
-
t16 = /* @__PURE__ */ jsx("div", { "aria-live": "polite", className: "month-year", children: /* @__PURE__ */ jsx(TextContent, { "aria-label": t132, as: "p", "data-testid": t142, children: t152 }) });
|
|
85
|
-
$[31] = t132;
|
|
86
|
-
$[32] = t142;
|
|
87
|
-
$[33] = t152;
|
|
88
|
-
$[34] = t16;
|
|
89
|
-
} else {
|
|
90
|
-
t16 = $[34];
|
|
91
|
-
}
|
|
92
|
-
let t17;
|
|
93
|
-
if ($[35] !== onNextMonth) {
|
|
94
|
-
t17 = /* @__PURE__ */ jsx(Button, { boxShadow: false, type: "button", iconName: "arrow_right", title: "Próximo mês", className: "next-month", "aria-label": "Próximo mês", onClick: onNextMonth, onMouseDown: handleOnMouseDown });
|
|
95
|
-
$[35] = onNextMonth;
|
|
96
|
-
$[36] = t17;
|
|
97
|
-
} else {
|
|
98
|
-
t17 = $[36];
|
|
99
|
-
}
|
|
100
|
-
if ($[37] !== headerId || $[38] !== t122 || $[39] !== t16 || $[40] !== t17) {
|
|
101
|
-
t10 = /* @__PURE__ */ jsxs("div", { id: headerId, className: "date-calendar-box-header", children: [
|
|
102
|
-
t122,
|
|
103
|
-
t16,
|
|
104
|
-
t17
|
|
105
|
-
] });
|
|
106
|
-
$[37] = headerId;
|
|
107
|
-
$[38] = t122;
|
|
108
|
-
$[39] = t16;
|
|
109
|
-
$[40] = t17;
|
|
110
|
-
$[41] = t10;
|
|
111
|
-
} else {
|
|
112
|
-
t10 = $[41];
|
|
113
|
-
}
|
|
114
|
-
if ($[42] === Symbol.for("react.memo_cache_sentinel")) {
|
|
115
|
-
t11 = /* @__PURE__ */ jsx("div", { "aria-label": "Dias da Semana", role: "grid", className: "date-calendar-box-days-of-week", children: hooks.weekdaysShort(true).map(_temp2) });
|
|
116
|
-
$[42] = t11;
|
|
117
|
-
} else {
|
|
118
|
-
t11 = $[42];
|
|
119
|
-
}
|
|
120
|
-
t4 = "date-calendar-box-grid-of-days";
|
|
121
|
-
t2 = "Calendário";
|
|
122
|
-
t3 = "grid";
|
|
123
|
-
t0 = "weeks";
|
|
124
|
-
let t18;
|
|
125
|
-
if ($[43] !== activeDescendant || $[44] !== calendarDisplayDate || $[45] !== getDayState || $[46] !== onSelectDay || $[47] !== testIdPrefix) {
|
|
126
|
-
t18 = (week, weekIndex) => /* @__PURE__ */ jsx("tr", { role: "row", children: week.map((day_0, dateIndex) => {
|
|
127
|
-
const idActiveDescendant = day_0.format(TOKEN_ISO_FORMAT);
|
|
128
|
-
const {
|
|
129
|
-
isSelected,
|
|
130
|
-
isInRange,
|
|
131
|
-
isDisabled
|
|
132
|
-
} = getDayState(day_0);
|
|
133
|
-
const isToday = _.isEqual(hooks().format(TOKEN_ISO_FORMAT), idActiveDescendant);
|
|
134
|
-
const hasFocus = _.isEqual(activeDescendant, idActiveDescendant);
|
|
135
|
-
const isCurrentMonth = day_0.month() === calendarDisplayDate.month();
|
|
136
|
-
const descriptionDate = day_0.format("LL");
|
|
137
|
-
const rangeAttribute = _.isUndefined(isInRange) ? {} : {
|
|
138
|
-
"data-state-is-in-range": isInRange
|
|
139
|
-
};
|
|
140
|
-
const boundsAttribute = _.isUndefined(isDisabled) ? {} : {
|
|
141
|
-
"data-state-out-of-bounds": isDisabled,
|
|
142
|
-
"aria-disabled": isDisabled
|
|
143
|
-
};
|
|
144
|
-
return /* @__PURE__ */ jsx("td", { role: "gridcell", children: /* @__PURE__ */ jsx(Button, { ...rangeAttribute, ...boundsAttribute, id: idActiveDescendant, type: "button", className: "day-button", boxShadow: false, tabIndex: -1, title: descriptionDate, disabled: isDisabled, "aria-label": descriptionDate, "aria-selected": isSelected, "data-testid": `${testIdPrefix}-day-button`, "data-state-is-today": isToday, "data-state-has-focus": hasFocus, "data-state-is-current-month": isCurrentMonth, label: day_0.date().toString(), onMouseDown: handleOnMouseDown, onClick: () => onSelectDay(day_0) }) }, dateIndex);
|
|
145
|
-
}) }, weekIndex + 1);
|
|
146
|
-
$[43] = activeDescendant;
|
|
147
|
-
$[44] = calendarDisplayDate;
|
|
148
|
-
$[45] = getDayState;
|
|
149
|
-
$[46] = onSelectDay;
|
|
150
|
-
$[47] = testIdPrefix;
|
|
151
|
-
$[48] = t18;
|
|
152
|
-
} else {
|
|
153
|
-
t18 = $[48];
|
|
154
|
-
}
|
|
155
|
-
t1 = weeks.map(t18);
|
|
156
|
-
$[0] = activeDescendant;
|
|
157
|
-
$[1] = calendarBoxOpen;
|
|
158
|
-
$[2] = calendarBoxStyles;
|
|
159
|
-
$[3] = calendarDisplayDate;
|
|
160
|
-
$[4] = getDayState;
|
|
161
|
-
$[5] = headerId;
|
|
162
|
-
$[6] = onNextMonth;
|
|
163
|
-
$[7] = onPreviousMonth;
|
|
164
|
-
$[8] = onSelectDay;
|
|
165
|
-
$[9] = ref;
|
|
166
|
-
$[10] = testIdPrefix;
|
|
167
|
-
$[11] = t0;
|
|
168
|
-
$[12] = t1;
|
|
169
|
-
$[13] = t10;
|
|
170
|
-
$[14] = t11;
|
|
171
|
-
$[15] = t2;
|
|
172
|
-
$[16] = t3;
|
|
173
|
-
$[17] = t4;
|
|
174
|
-
$[18] = t5;
|
|
175
|
-
$[19] = t6;
|
|
176
|
-
$[20] = t7;
|
|
177
|
-
$[21] = t8;
|
|
178
|
-
$[22] = t9;
|
|
179
|
-
} else {
|
|
180
|
-
t0 = $[11];
|
|
181
|
-
t1 = $[12];
|
|
182
|
-
t10 = $[13];
|
|
183
|
-
t11 = $[14];
|
|
184
|
-
t2 = $[15];
|
|
185
|
-
t3 = $[16];
|
|
186
|
-
t4 = $[17];
|
|
187
|
-
t5 = $[18];
|
|
188
|
-
t6 = $[19];
|
|
189
|
-
t7 = $[20];
|
|
190
|
-
t8 = $[21];
|
|
191
|
-
t9 = $[22];
|
|
192
|
-
}
|
|
193
|
-
let t12;
|
|
194
|
-
if ($[49] !== t0 || $[50] !== t1) {
|
|
195
|
-
t12 = /* @__PURE__ */ jsx("tbody", { className: t0, children: t1 });
|
|
196
|
-
$[49] = t0;
|
|
197
|
-
$[50] = t1;
|
|
198
|
-
$[51] = t12;
|
|
199
|
-
} else {
|
|
200
|
-
t12 = $[51];
|
|
201
|
-
}
|
|
202
|
-
let t13;
|
|
203
|
-
if ($[52] !== t12 || $[53] !== t2 || $[54] !== t3) {
|
|
204
|
-
t13 = /* @__PURE__ */ jsx("table", { "aria-label": t2, role: t3, children: t12 });
|
|
205
|
-
$[52] = t12;
|
|
206
|
-
$[53] = t2;
|
|
207
|
-
$[54] = t3;
|
|
208
|
-
$[55] = t13;
|
|
209
|
-
} else {
|
|
210
|
-
t13 = $[55];
|
|
211
|
-
}
|
|
212
|
-
let t14;
|
|
213
|
-
if ($[56] !== t13 || $[57] !== t4) {
|
|
214
|
-
t14 = /* @__PURE__ */ jsx("div", { className: t4, children: t13 });
|
|
215
|
-
$[56] = t13;
|
|
216
|
-
$[57] = t4;
|
|
217
|
-
$[58] = t14;
|
|
218
|
-
} else {
|
|
219
|
-
t14 = $[58];
|
|
220
|
-
}
|
|
221
|
-
let t15;
|
|
222
|
-
if ($[59] !== children || $[60] !== t10 || $[61] !== t11 || $[62] !== t14 || $[63] !== t5 || $[64] !== t6 || $[65] !== t7 || $[66] !== t8 || $[67] !== t9) {
|
|
223
|
-
t15 = /* @__PURE__ */ jsxs("div", { ref: t5, style: t6, "aria-expanded": t7, className: t8, "data-testid": t9, children: [
|
|
224
|
-
t10,
|
|
225
|
-
t11,
|
|
226
|
-
t14,
|
|
227
|
-
children
|
|
228
|
-
] });
|
|
229
|
-
$[59] = children;
|
|
230
|
-
$[60] = t10;
|
|
231
|
-
$[61] = t11;
|
|
232
|
-
$[62] = t14;
|
|
233
|
-
$[63] = t5;
|
|
234
|
-
$[64] = t6;
|
|
235
|
-
$[65] = t7;
|
|
236
|
-
$[66] = t8;
|
|
237
|
-
$[67] = t9;
|
|
238
|
-
$[68] = t15;
|
|
239
|
-
} else {
|
|
240
|
-
t15 = $[68];
|
|
241
|
-
}
|
|
242
|
-
return t15;
|
|
243
|
-
});
|
|
244
|
-
CalendarBox.displayName = "DateCalendarBox";
|
|
245
|
-
function _temp(event) {
|
|
246
|
-
event?.preventDefault?.();
|
|
247
|
-
}
|
|
248
|
-
function _temp2(day, idx) {
|
|
249
|
-
return /* @__PURE__ */ jsx("span", { title: day, role: "columnheader", children: day }, `day-of-week-${idx + 1}`);
|
|
250
|
-
}
|
|
251
|
-
export {
|
|
252
|
-
CalendarBox
|
|
253
|
-
};
|
|
254
|
-
//# sourceMappingURL=calendarbox.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calendarbox.js","sources":["../../../src/lib/inputs2/date/calendarbox.tsx"],"sourcesContent":["import _ from 'lodash';\nimport moment, { type Moment } from 'moment';\nimport { forwardRef, MouseEvent, useRef, type ReactNode, type RefObject } from 'react';\nimport Button from '../../buttons';\nimport { mergeRefs } from '../../form2/helpers';\nimport TextContent from '../../textContent';\nimport { generateCalendarWeeks, TOKEN_ISO_FORMAT } from './helpers';\nimport { useCalendarPosition } from './hooks/useCalendarPosition';\n\ninterface CalendarDayState {\n isSelected: boolean;\n isInRange?: boolean;\n isDisabled?: boolean;\n}\n\ninterface CalendarBoxProps {\n testIdPrefix: string;\n headerId: string;\n calendarBoxOpen: boolean;\n activeDescendant: string;\n calendarDisplayDate: Moment;\n containerRef: RefObject<HTMLDivElement | null>;\n onNextMonth: () => void;\n onPreviousMonth: () => void;\n getDayState: (day: Moment) => CalendarDayState;\n onSelectDay: (day: Moment) => void;\n children?: ReactNode;\n}\n\nconst CalendarBox = forwardRef<HTMLDivElement, CalendarBoxProps>((props, ref) => {\n const {\n testIdPrefix, headerId, calendarBoxOpen, activeDescendant, calendarDisplayDate,\n containerRef, onNextMonth, onPreviousMonth, getDayState, onSelectDay, children,\n } = props;\n const calendarBoxRef = useRef<HTMLDivElement | null>(null);\n const { calendarBoxStyles } = useCalendarPosition(calendarBoxOpen, containerRef, calendarBoxRef);\n\n const weeks = generateCalendarWeeks(calendarDisplayDate);\n\n const handleOnMouseDown = (event: MouseEvent<HTMLButtonElement>) => {\n event?.preventDefault?.();\n };\n\n return (\n <div\n ref={mergeRefs(ref, calendarBoxRef)}\n style={calendarBoxStyles}\n aria-expanded={calendarBoxOpen}\n className=\"date-calendar-box\"\n data-testid={`${testIdPrefix}-calendar-box`}>\n <div id={headerId} className=\"date-calendar-box-header\">\n <Button\n boxShadow={false}\n type=\"button\"\n iconName=\"arrow_left\"\n title=\"Mês anterior\"\n className=\"previous-month\"\n aria-label=\"Mês anterior\"\n onClick={onPreviousMonth}\n onMouseDown={handleOnMouseDown} />\n <div aria-live=\"polite\" className=\"month-year\">\n <TextContent\n aria-label={calendarDisplayDate.format('MMMM YYYY')}\n as=\"p\"\n data-testid={`${testIdPrefix}-calendar-box-month-description`}>\n {calendarDisplayDate.format('MMMM YYYY')}\n </TextContent>\n </div>\n <Button\n boxShadow={false}\n type=\"button\"\n iconName=\"arrow_right\"\n title=\"Próximo mês\"\n className=\"next-month\"\n aria-label=\"Próximo mês\"\n onClick={onNextMonth}\n onMouseDown={handleOnMouseDown} />\n </div>\n <div aria-label=\"Dias da Semana\" role=\"grid\" className=\"date-calendar-box-days-of-week\">\n {moment.weekdaysShort(true).map((day, idx) => (\n <span\n title={day}\n role=\"columnheader\"\n key={`day-of-week-${idx + 1}`}>\n {day}\n </span>\n ))}\n </div>\n <div className=\"date-calendar-box-grid-of-days\">\n <table aria-label=\"Calendário\" role=\"grid\">\n <tbody className=\"weeks\">\n {weeks.map((week, weekIndex) => (\n <tr role=\"row\" key={weekIndex + 1}>\n {week.map((day, dateIndex) => {\n const idActiveDescendant = day.format(TOKEN_ISO_FORMAT);\n const { isSelected, isInRange, isDisabled } = getDayState(day);\n const isToday = _.isEqual(moment().format(TOKEN_ISO_FORMAT), idActiveDescendant);\n const hasFocus = _.isEqual(activeDescendant, idActiveDescendant);\n const isCurrentMonth = day.month() === calendarDisplayDate.month();\n const descriptionDate = day.format('LL');\n const rangeAttribute = _.isUndefined(isInRange)\n ? {}\n : { 'data-state-is-in-range': isInRange };\n const boundsAttribute = _.isUndefined(isDisabled)\n ? {}\n : { 'data-state-out-of-bounds': isDisabled, 'aria-disabled': isDisabled };\n return (\n <td role=\"gridcell\" key={dateIndex}>\n <Button\n {...rangeAttribute}\n {...boundsAttribute}\n id={idActiveDescendant}\n type=\"button\"\n className=\"day-button\"\n boxShadow={false}\n tabIndex={-1}\n title={descriptionDate}\n disabled={isDisabled}\n aria-label={descriptionDate}\n aria-selected={isSelected}\n data-testid={`${testIdPrefix}-day-button`}\n data-state-is-today={isToday}\n data-state-has-focus={hasFocus}\n data-state-is-current-month={isCurrentMonth}\n label={day.date().toString()}\n onMouseDown={handleOnMouseDown}\n onClick={() => onSelectDay(day)} />\n </td>\n );\n })}\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n {children}\n </div>\n );\n});\n\nCalendarBox.displayName = 'DateCalendarBox';\n\nexport { CalendarBox };\nexport type { CalendarBoxProps, CalendarDayState };\n"],"names":["CalendarBox","forwardRef","props","ref","$","_c","testIdPrefix","headerId","calendarBoxOpen","activeDescendant","calendarDisplayDate","containerRef","onNextMonth","onPreviousMonth","getDayState","onSelectDay","children","calendarBoxRef","useRef","calendarBoxStyles","useCalendarPosition","t0","t1","t10","t11","t2","t3","t4","t5","t6","t7","t8","t9","weeks","generateCalendarWeeks","handleOnMouseDown","_temp","mergeRefs","t12","t13","format","t14","t15","t16","t17","Symbol","for","moment","weekdaysShort","map","_temp2","t18","week","weekIndex","day_0","dateIndex","idActiveDescendant","day","TOKEN_ISO_FORMAT","isSelected","isInRange","isDisabled","isToday","_","isEqual","hasFocus","isCurrentMonth","month","descriptionDate","rangeAttribute","isUndefined","boundsAttribute","date","toString","displayName","event","preventDefault","idx"],"mappings":";;;;;;;;;;;AA6BA,MAAMA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EAAA,EAAA,MAAAyB,MAAAzB,EAAA,EAAA,MAAA0B,MAAA1B,EAAA,EAAA,MAAA2B,MAAA3B,UAAA4B,IAAA;AA1FRU,wCACO,KAAAd,IACET,OAAAA,IACQX,qBACL,WAAAuB,IACG,eAAAC,IACbT,UAAAA;AAAAA,MAAAA;AAAAA,MA4BAC;AAAAA,MAUAiB;AAAAA,MA+CCzB;AAAAA,IAAAA,GACH;AAAMZ,YAAAY;AAAAZ,YAAAmB;AAAAnB,YAAAoB;AAAApB,YAAAqC;AAAArC,YAAAwB;AAAAxB,YAAAyB;AAAAzB,YAAA0B;AAAA1B,YAAA2B;AAAA3B,YAAA4B;AAAA5B,YAAAsC;AAAAA,EAAA,OAAA;AAAAA,UAAAtC,EAAA,EAAA;AAAA,EAAA;AAAA,SA5FNsC;AA4FM,CAET;AAED1C,YAAY0E,cAAc;AA/GuC,SAAAtC,MAAAuC,OAAA;AAW7DA,SAAKC,iBAAAA;AAAoB;AAXoC,SAAA1B,OAAAO,KAAAoB,KAAA;AAAA,SAmDvD,oBAAA,QAAA,EACSpB,YACF,MAAA,gBAEJA,UAAAA,IAAAA,GADI,eAAeoB,MAAM,CAAC,EAE7B;AAAO;"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { c as compilerRuntimeExports } from "../../../_virtual/compiler-runtime.js";
|
|
2
|
-
import { useState, useRef, useLayoutEffect } from "react";
|
|
3
|
-
const getOuterHeight = (element) => {
|
|
4
|
-
if (!element) return 0;
|
|
5
|
-
const {
|
|
6
|
-
borderTopWidth,
|
|
7
|
-
borderBottomWidth,
|
|
8
|
-
marginTop,
|
|
9
|
-
marginBottom
|
|
10
|
-
} = getComputedStyle(element);
|
|
11
|
-
const toNumber = (value) => parseFloat(value) || 0;
|
|
12
|
-
return element.scrollHeight + toNumber(borderTopWidth) + toNumber(borderBottomWidth) + toNumber(marginTop) + toNumber(marginBottom);
|
|
13
|
-
};
|
|
14
|
-
const useCalendarPosition = (calendarBoxOpen, containerRef, calendarBoxRef) => {
|
|
15
|
-
const $ = compilerRuntimeExports.c(8);
|
|
16
|
-
let t0;
|
|
17
|
-
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
18
|
-
t0 = {
|
|
19
|
-
top: 0,
|
|
20
|
-
left: 0,
|
|
21
|
-
position: "absolute"
|
|
22
|
-
};
|
|
23
|
-
$[0] = t0;
|
|
24
|
-
} else {
|
|
25
|
-
t0 = $[0];
|
|
26
|
-
}
|
|
27
|
-
const [calendarBoxStyles, setCalendarBoxStyles] = useState(t0);
|
|
28
|
-
const shouldAlignRight = useRef(false);
|
|
29
|
-
const shouldFlipAbove = useRef(false);
|
|
30
|
-
let t1;
|
|
31
|
-
let t2;
|
|
32
|
-
if ($[1] !== calendarBoxOpen || $[2] !== calendarBoxRef || $[3] !== containerRef) {
|
|
33
|
-
t1 = () => {
|
|
34
|
-
const updatePosition = (shouldReviewAlignment) => {
|
|
35
|
-
const anchor = containerRef.current?.getBoundingClientRect();
|
|
36
|
-
if (!anchor) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const measuredWidth = calendarBoxRef.current?.getBoundingClientRect().width ?? 0;
|
|
40
|
-
const boxWidth = Math.max(anchor.width, measuredWidth);
|
|
41
|
-
const boxHeight = getOuterHeight(calendarBoxRef.current);
|
|
42
|
-
if (shouldReviewAlignment) {
|
|
43
|
-
shouldAlignRight.current = anchor.left + boxWidth > window.innerWidth;
|
|
44
|
-
shouldFlipAbove.current = anchor.bottom + boxHeight > window.innerHeight && anchor.top - boxHeight >= 0;
|
|
45
|
-
}
|
|
46
|
-
const alignedLeft = shouldAlignRight.current ? Math.max(0, anchor.right - boxWidth) : anchor.left;
|
|
47
|
-
const alignedTop = shouldFlipAbove.current ? anchor.top - boxHeight : anchor.top + anchor.height;
|
|
48
|
-
setCalendarBoxStyles({
|
|
49
|
-
top: alignedTop + window.scrollY,
|
|
50
|
-
left: alignedLeft + window.scrollX,
|
|
51
|
-
width: anchor.width,
|
|
52
|
-
position: "absolute"
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
const handleScroll = () => updatePosition(false);
|
|
56
|
-
const handleResize = () => updatePosition(true);
|
|
57
|
-
if (calendarBoxOpen) {
|
|
58
|
-
updatePosition(true);
|
|
59
|
-
window.addEventListener("resize", handleResize);
|
|
60
|
-
window.addEventListener("scroll", handleScroll, true);
|
|
61
|
-
}
|
|
62
|
-
return () => {
|
|
63
|
-
window.removeEventListener("resize", handleResize);
|
|
64
|
-
window.removeEventListener("scroll", handleScroll, true);
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
t2 = [calendarBoxOpen, containerRef, calendarBoxRef];
|
|
68
|
-
$[1] = calendarBoxOpen;
|
|
69
|
-
$[2] = calendarBoxRef;
|
|
70
|
-
$[3] = containerRef;
|
|
71
|
-
$[4] = t1;
|
|
72
|
-
$[5] = t2;
|
|
73
|
-
} else {
|
|
74
|
-
t1 = $[4];
|
|
75
|
-
t2 = $[5];
|
|
76
|
-
}
|
|
77
|
-
useLayoutEffect(t1, t2);
|
|
78
|
-
let t3;
|
|
79
|
-
if ($[6] !== calendarBoxStyles) {
|
|
80
|
-
t3 = {
|
|
81
|
-
calendarBoxStyles
|
|
82
|
-
};
|
|
83
|
-
$[6] = calendarBoxStyles;
|
|
84
|
-
$[7] = t3;
|
|
85
|
-
} else {
|
|
86
|
-
t3 = $[7];
|
|
87
|
-
}
|
|
88
|
-
return t3;
|
|
89
|
-
};
|
|
90
|
-
export {
|
|
91
|
-
useCalendarPosition
|
|
92
|
-
};
|
|
93
|
-
//# sourceMappingURL=useCalendarPosition.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCalendarPosition.js","sources":["../../../../src/lib/inputs2/date/hooks/useCalendarPosition.ts"],"sourcesContent":["import { CSSProperties, RefObject, useLayoutEffect, useRef, useState } from 'react';\n\nconst getOuterHeight = (element: HTMLDivElement | null) => {\n if (!element) return 0;\n const { borderTopWidth, borderBottomWidth, marginTop, marginBottom } = getComputedStyle(element);\n const toNumber = (value: string) => parseFloat(value) || 0;\n return element.scrollHeight + toNumber(borderTopWidth) + toNumber(borderBottomWidth)\n + toNumber(marginTop) + toNumber(marginBottom);\n};\n\nexport const useCalendarPosition = (\n calendarBoxOpen: boolean,\n containerRef: RefObject<HTMLDivElement | null>,\n calendarBoxRef: RefObject<HTMLDivElement | null>,\n) => {\n const [calendarBoxStyles, setCalendarBoxStyles] = useState<CSSProperties>({\n top: 0,\n left: 0,\n position: 'absolute',\n });\n const shouldAlignRight = useRef(false);\n const shouldFlipAbove = useRef(false);\n\n useLayoutEffect(() => {\n const updatePosition = (shouldReviewAlignment: boolean) => {\n const anchor = containerRef.current?.getBoundingClientRect();\n if (!anchor) return;\n const measuredWidth = calendarBoxRef.current?.getBoundingClientRect().width ?? 0;\n const boxWidth = Math.max(anchor.width, measuredWidth);\n const boxHeight = getOuterHeight(calendarBoxRef.current);\n if (shouldReviewAlignment) {\n shouldAlignRight.current = anchor.left + boxWidth > window.innerWidth;\n shouldFlipAbove.current = anchor.bottom + boxHeight > window.innerHeight\n && anchor.top - boxHeight >= 0;\n }\n const alignedLeft = shouldAlignRight.current\n ? Math.max(0, anchor.right - boxWidth)\n : anchor.left;\n const alignedTop = shouldFlipAbove.current\n ? anchor.top - boxHeight\n : anchor.top + anchor.height;\n setCalendarBoxStyles({\n top: alignedTop + window.scrollY,\n left: alignedLeft + window.scrollX,\n width: anchor.width,\n position: 'absolute',\n });\n };\n\n const handleScroll = () => updatePosition(false);\n const handleResize = () => updatePosition(true);\n\n if (calendarBoxOpen) {\n updatePosition(true);\n window.addEventListener('resize', handleResize);\n window.addEventListener('scroll', handleScroll, true);\n }\n\n return () => {\n window.removeEventListener('resize', handleResize);\n window.removeEventListener('scroll', handleScroll, true);\n };\n }, [calendarBoxOpen, containerRef, calendarBoxRef]);\n\n return { calendarBoxStyles };\n};\n"],"names":["getOuterHeight","element","borderTopWidth","borderBottomWidth","marginTop","marginBottom","getComputedStyle","toNumber","value","parseFloat","scrollHeight","useCalendarPosition","calendarBoxOpen","containerRef","calendarBoxRef","$","_c","t0","Symbol","for","top","left","position","calendarBoxStyles","setCalendarBoxStyles","useState","shouldAlignRight","useRef","shouldFlipAbove","t1","t2","updatePosition","shouldReviewAlignment","anchor","current","getBoundingClientRect","measuredWidth","width","boxWidth","Math","max","boxHeight","window","innerWidth","bottom","innerHeight","alignedLeft","right","alignedTop","height","scrollY","scrollX","handleScroll","handleResize","addEventListener","removeEventListener","useLayoutEffect","t3"],"mappings":";;AAEA,MAAMA,iBAAiBA,CAACC,YAAmC;AACzD,MAAI,CAACA,QAAS,QAAO;AACrB,QAAM;AAAA,IAAEC;AAAAA,IAAgBC;AAAAA,IAAmBC;AAAAA,IAAWC;AAAAA,EAAAA,IAAiBC,iBAAiBL,OAAO;AAC/F,QAAMM,WAAWA,CAACC,UAAkBC,WAAWD,KAAK,KAAK;AACzD,SAAOP,QAAQS,eAAeH,SAASL,cAAc,IAAIK,SAASJ,iBAAiB,IAC/EI,SAASH,SAAS,IAAIG,SAASF,YAAY;AACjD;AAEO,MAAMM,sBAAsBA,CAAAC,iBAAAC,cAAAC,mBAAA;AAAA,QAAAC,IAAAC,uBAAAA,EAAA,CAAA;AAAA,MAAAC;AAAA,MAAAF,EAAA,CAAA,MAAAG,OAAAC,IAAA,2BAAA,GAAA;AAKyCF,SAAA;AAAA,MAAAG,KACnE;AAAA,MAACC,MACA;AAAA,MAACC,UACG;AAAA,IAAA;AACXP,WAAAE;AAAAA,EAAA,OAAA;AAAAA,SAAAF,EAAA,CAAA;AAAA,EAAA;AAJD,QAAA,CAAAQ,mBAAAC,oBAAA,IAAkDC,SAAwBR,EAIzE;AACD,QAAAS,mBAAyBC,OAAO,KAAK;AACrC,QAAAC,kBAAwBD,OAAO,KAAK;AAAE,MAAAE;AAAA,MAAAC;AAAA,MAAAf,EAAA,CAAA,MAAAH,mBAAAG,SAAAD,kBAAAC,EAAA,CAAA,MAAAF,cAA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AH;AAAAG,WAAAD;AAAAC,WAAAF;AAAAE,WAAAc;AAAAd,WAAAe;AAAAA,EAAA,OAAA;AAAAD,SAAAd,EAAA,CAAA;AAAAe,SAAAf,EAAA,CAAA;AAAA,EAAA;AAvClDyC,kBAAgB3B,IAuCbC,EAA+C;AAAC,MAAA2B;AAAA,MAAA1C,SAAAQ,mBAAA;AAE5CkC,SAAA;AAAA,MAAAlC;AAAAA,IAAAA;AAAqBR,WAAAQ;AAAAR,WAAA0C;AAAAA,EAAA,OAAA;AAAAA,SAAA1C,EAAA,CAAA;AAAA,EAAA;AAAA,SAArB0C;AAAqB;"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { Moment } from 'moment';
|
|
3
|
-
import { DateSharedContextProps } from '../types';
|
|
4
|
-
interface UseDateCalendarStateParams {
|
|
5
|
-
inputRef?: React.RefObject<HTMLInputElement | null>;
|
|
6
|
-
min?: Moment;
|
|
7
|
-
max?: Moment;
|
|
8
|
-
onPressEnter?: (activeDescendant: string) => void;
|
|
9
|
-
}
|
|
10
|
-
interface UseDateCalendarStateReturn extends DateSharedContextProps {
|
|
11
|
-
handleKeyDownNavigation: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare const useDateCalendarState: (params?: UseDateCalendarStateParams) => UseDateCalendarStateReturn;
|
|
14
|
-
export {};
|
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { c as compilerRuntimeExports } from "../../../_virtual/compiler-runtime.js";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import hooks from "../../../node_modules/moment/dist/moment.js";
|
|
4
|
-
import { Keys } from "../types.js";
|
|
5
|
-
import { TOKEN_ISO_FORMAT, NAVIGATION_KEYS } from "../helpers.js";
|
|
6
|
-
const useDateCalendarState = (t0) => {
|
|
7
|
-
const $ = compilerRuntimeExports.c(30);
|
|
8
|
-
let t1;
|
|
9
|
-
if ($[0] !== t0) {
|
|
10
|
-
t1 = t0 === void 0 ? {} : t0;
|
|
11
|
-
$[0] = t0;
|
|
12
|
-
$[1] = t1;
|
|
13
|
-
} else {
|
|
14
|
-
t1 = $[1];
|
|
15
|
-
}
|
|
16
|
-
const params = t1;
|
|
17
|
-
const {
|
|
18
|
-
inputRef,
|
|
19
|
-
min,
|
|
20
|
-
max,
|
|
21
|
-
onPressEnter
|
|
22
|
-
} = params;
|
|
23
|
-
const [calendarBoxOpen, setCalendarBoxOpen] = React.useState(false);
|
|
24
|
-
let t2;
|
|
25
|
-
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
26
|
-
t2 = hooks().format(TOKEN_ISO_FORMAT);
|
|
27
|
-
$[2] = t2;
|
|
28
|
-
} else {
|
|
29
|
-
t2 = $[2];
|
|
30
|
-
}
|
|
31
|
-
const [activeDescendant, setActiveDescendant] = React.useState(t2);
|
|
32
|
-
let t3;
|
|
33
|
-
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
34
|
-
t3 = hooks();
|
|
35
|
-
$[3] = t3;
|
|
36
|
-
} else {
|
|
37
|
-
t3 = $[3];
|
|
38
|
-
}
|
|
39
|
-
const [calendarDisplayDate, setCalendarDisplayDate] = React.useState(t3);
|
|
40
|
-
const calendarRef = React.useRef(null);
|
|
41
|
-
const dateContainerRef = React.useRef(null);
|
|
42
|
-
let t4;
|
|
43
|
-
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
44
|
-
t4 = (value) => setCalendarBoxOpen(value);
|
|
45
|
-
$[4] = t4;
|
|
46
|
-
} else {
|
|
47
|
-
t4 = $[4];
|
|
48
|
-
}
|
|
49
|
-
const handleSetCalendarBoxOpen = t4;
|
|
50
|
-
let t5;
|
|
51
|
-
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
52
|
-
t5 = (value_0) => setActiveDescendant(value_0);
|
|
53
|
-
$[5] = t5;
|
|
54
|
-
} else {
|
|
55
|
-
t5 = $[5];
|
|
56
|
-
}
|
|
57
|
-
const handleChangeActiveDescendant = t5;
|
|
58
|
-
let t6;
|
|
59
|
-
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
60
|
-
t6 = (value_1) => setCalendarDisplayDate(value_1);
|
|
61
|
-
$[6] = t6;
|
|
62
|
-
} else {
|
|
63
|
-
t6 = $[6];
|
|
64
|
-
}
|
|
65
|
-
const handleChangeCalendarDisplayDate = t6;
|
|
66
|
-
let t7;
|
|
67
|
-
if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
|
|
68
|
-
t7 = () => setCalendarDisplayDate(_temp);
|
|
69
|
-
$[7] = t7;
|
|
70
|
-
} else {
|
|
71
|
-
t7 = $[7];
|
|
72
|
-
}
|
|
73
|
-
const handleNextMonth = t7;
|
|
74
|
-
let t8;
|
|
75
|
-
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
76
|
-
t8 = () => setCalendarDisplayDate(_temp2);
|
|
77
|
-
$[8] = t8;
|
|
78
|
-
} else {
|
|
79
|
-
t8 = $[8];
|
|
80
|
-
}
|
|
81
|
-
const handlePreviousMonth = t8;
|
|
82
|
-
let t9;
|
|
83
|
-
if ($[9] !== inputRef) {
|
|
84
|
-
t9 = () => {
|
|
85
|
-
setCalendarBoxOpen((prevState) => {
|
|
86
|
-
if (inputRef?.current !== document.activeElement) {
|
|
87
|
-
inputRef?.current?.focus?.();
|
|
88
|
-
}
|
|
89
|
-
return !prevState;
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
$[9] = inputRef;
|
|
93
|
-
$[10] = t9;
|
|
94
|
-
} else {
|
|
95
|
-
t9 = $[10];
|
|
96
|
-
}
|
|
97
|
-
const handleToggleCalendarBox = t9;
|
|
98
|
-
let t10;
|
|
99
|
-
if ($[11] !== max || $[12] !== min) {
|
|
100
|
-
t10 = (day) => {
|
|
101
|
-
if (min && day.isBefore(min, "day")) {
|
|
102
|
-
return min.clone().startOf("day");
|
|
103
|
-
}
|
|
104
|
-
if (max && day.isAfter(max, "day")) {
|
|
105
|
-
return max.clone().startOf("day");
|
|
106
|
-
}
|
|
107
|
-
return day;
|
|
108
|
-
};
|
|
109
|
-
$[11] = max;
|
|
110
|
-
$[12] = min;
|
|
111
|
-
$[13] = t10;
|
|
112
|
-
} else {
|
|
113
|
-
t10 = $[13];
|
|
114
|
-
}
|
|
115
|
-
const clampToBounds = t10;
|
|
116
|
-
let t11;
|
|
117
|
-
if ($[14] !== clampToBounds) {
|
|
118
|
-
t11 = (offset) => {
|
|
119
|
-
setCalendarDisplayDate((prevDisplayDate_1) => {
|
|
120
|
-
const daySelected = clampToBounds(prevDisplayDate_1.clone().add(offset, "day"));
|
|
121
|
-
setActiveDescendant(daySelected.format(TOKEN_ISO_FORMAT));
|
|
122
|
-
return daySelected;
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
$[14] = clampToBounds;
|
|
126
|
-
$[15] = t11;
|
|
127
|
-
} else {
|
|
128
|
-
t11 = $[15];
|
|
129
|
-
}
|
|
130
|
-
const handleNavigateWithDays = t11;
|
|
131
|
-
let t12;
|
|
132
|
-
if ($[16] !== clampToBounds) {
|
|
133
|
-
t12 = (when) => {
|
|
134
|
-
setCalendarDisplayDate((prevDisplayDate_2) => {
|
|
135
|
-
let daySelected_0 = prevDisplayDate_2;
|
|
136
|
-
if (when === "end") {
|
|
137
|
-
daySelected_0 = prevDisplayDate_2.clone().endOf("week");
|
|
138
|
-
}
|
|
139
|
-
if (when === "start") {
|
|
140
|
-
daySelected_0 = prevDisplayDate_2.clone().startOf("week");
|
|
141
|
-
}
|
|
142
|
-
daySelected_0 = clampToBounds(daySelected_0);
|
|
143
|
-
setActiveDescendant(daySelected_0.format(TOKEN_ISO_FORMAT));
|
|
144
|
-
return daySelected_0;
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
$[16] = clampToBounds;
|
|
148
|
-
$[17] = t12;
|
|
149
|
-
} else {
|
|
150
|
-
t12 = $[17];
|
|
151
|
-
}
|
|
152
|
-
const handleNavigateWithWeeks = t12;
|
|
153
|
-
let t13;
|
|
154
|
-
if ($[18] !== activeDescendant || $[19] !== calendarBoxOpen || $[20] !== handleNavigateWithDays || $[21] !== handleNavigateWithWeeks || $[22] !== onPressEnter) {
|
|
155
|
-
t13 = (event) => {
|
|
156
|
-
const isNavigationKey = Boolean(event.key) && !event.shiftKey && !event.altKey && NAVIGATION_KEYS.includes(event.key);
|
|
157
|
-
if (!calendarBoxOpen || !isNavigationKey) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
event.preventDefault();
|
|
161
|
-
bb84: switch (event.key) {
|
|
162
|
-
case Keys.arrowLeft: {
|
|
163
|
-
handleNavigateWithDays(-1);
|
|
164
|
-
break bb84;
|
|
165
|
-
}
|
|
166
|
-
case Keys.arrowRight: {
|
|
167
|
-
handleNavigateWithDays(1);
|
|
168
|
-
break bb84;
|
|
169
|
-
}
|
|
170
|
-
case Keys.arrowUp: {
|
|
171
|
-
handleNavigateWithDays(-7);
|
|
172
|
-
break bb84;
|
|
173
|
-
}
|
|
174
|
-
case Keys.arrowDown: {
|
|
175
|
-
handleNavigateWithDays(7);
|
|
176
|
-
break bb84;
|
|
177
|
-
}
|
|
178
|
-
case Keys.pageUp: {
|
|
179
|
-
handleNextMonth();
|
|
180
|
-
break bb84;
|
|
181
|
-
}
|
|
182
|
-
case Keys.pageDown: {
|
|
183
|
-
handlePreviousMonth();
|
|
184
|
-
break bb84;
|
|
185
|
-
}
|
|
186
|
-
case Keys.home: {
|
|
187
|
-
handleNavigateWithWeeks("start");
|
|
188
|
-
break bb84;
|
|
189
|
-
}
|
|
190
|
-
case Keys.end: {
|
|
191
|
-
handleNavigateWithWeeks("end");
|
|
192
|
-
break bb84;
|
|
193
|
-
}
|
|
194
|
-
case Keys.escape: {
|
|
195
|
-
setCalendarBoxOpen(false);
|
|
196
|
-
break bb84;
|
|
197
|
-
}
|
|
198
|
-
case Keys.enter: {
|
|
199
|
-
onPressEnter?.(activeDescendant);
|
|
200
|
-
break bb84;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
$[18] = activeDescendant;
|
|
205
|
-
$[19] = calendarBoxOpen;
|
|
206
|
-
$[20] = handleNavigateWithDays;
|
|
207
|
-
$[21] = handleNavigateWithWeeks;
|
|
208
|
-
$[22] = onPressEnter;
|
|
209
|
-
$[23] = t13;
|
|
210
|
-
} else {
|
|
211
|
-
t13 = $[23];
|
|
212
|
-
}
|
|
213
|
-
const handleKeyDownNavigation = t13;
|
|
214
|
-
let t14;
|
|
215
|
-
if ($[24] !== activeDescendant || $[25] !== calendarBoxOpen || $[26] !== calendarDisplayDate || $[27] !== handleKeyDownNavigation || $[28] !== handleToggleCalendarBox) {
|
|
216
|
-
t14 = {
|
|
217
|
-
calendarBoxOpen,
|
|
218
|
-
activeDescendant,
|
|
219
|
-
calendarDisplayDate,
|
|
220
|
-
calendarRef,
|
|
221
|
-
dateContainerRef,
|
|
222
|
-
handleNextMonth,
|
|
223
|
-
handlePreviousMonth,
|
|
224
|
-
handleToggleCalendarBox,
|
|
225
|
-
handleSetCalendarBoxOpen,
|
|
226
|
-
handleChangeActiveDescendant,
|
|
227
|
-
handleChangeCalendarDisplayDate,
|
|
228
|
-
handleKeyDownNavigation
|
|
229
|
-
};
|
|
230
|
-
$[24] = activeDescendant;
|
|
231
|
-
$[25] = calendarBoxOpen;
|
|
232
|
-
$[26] = calendarDisplayDate;
|
|
233
|
-
$[27] = handleKeyDownNavigation;
|
|
234
|
-
$[28] = handleToggleCalendarBox;
|
|
235
|
-
$[29] = t14;
|
|
236
|
-
} else {
|
|
237
|
-
t14 = $[29];
|
|
238
|
-
}
|
|
239
|
-
return t14;
|
|
240
|
-
};
|
|
241
|
-
function _temp(prevDisplayDate) {
|
|
242
|
-
return prevDisplayDate.clone().add(1, "month");
|
|
243
|
-
}
|
|
244
|
-
function _temp2(prevDisplayDate_0) {
|
|
245
|
-
return prevDisplayDate_0.clone().subtract(1, "month");
|
|
246
|
-
}
|
|
247
|
-
export {
|
|
248
|
-
useDateCalendarState
|
|
249
|
-
};
|
|
250
|
-
//# sourceMappingURL=useDateCalendarState.js.map
|