@auth0/quantum-product 2.5.7 → 2.5.9
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/date-picker/date-picker-classes.d.ts +10 -0
- package/date-picker/date-picker-classes.js +21 -0
- package/date-picker/date-picker-context.d.ts +10 -0
- package/date-picker/date-picker-context.js +36 -0
- package/date-picker/date-picker-popover.d.ts +4 -0
- package/date-picker/date-picker-popover.js +458 -0
- package/date-picker/date-picker-state.d.ts +24 -0
- package/date-picker/date-picker-state.js +95 -0
- package/date-picker/date-picker-types.d.ts +43 -0
- package/date-picker/date-picker-types.js +2 -0
- package/date-picker/date-picker-utils.d.ts +47 -0
- package/date-picker/date-picker-utils.js +165 -0
- package/date-picker/date-picker.d.ts +9 -0
- package/date-picker/date-picker.js +164 -0
- package/date-picker/index.d.ts +11 -0
- package/date-picker/index.js +17 -0
- package/esm/date-picker/date-picker-classes.js +16 -0
- package/esm/date-picker/date-picker-context.js +9 -0
- package/esm/date-picker/date-picker-popover.js +429 -0
- package/esm/date-picker/date-picker-state.js +66 -0
- package/esm/date-picker/date-picker-types.js +1 -0
- package/esm/date-picker/date-picker-utils.js +153 -0
- package/esm/date-picker/date-picker.js +135 -0
- package/esm/date-picker/index.js +5 -0
- package/esm/icon/index.js +3 -1
- package/esm/icon-button/icon-button.js +14 -3
- package/esm/index.js +1 -0
- package/esm/stepper/step-label/step-label.js +19 -3
- package/icon/index.d.ts +2 -0
- package/icon/index.js +8 -6
- package/icon-button/icon-button.d.ts +3 -0
- package/icon-button/icon-button.js +14 -3
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +3 -2
- package/stepper/step-label/step-label.js +18 -2
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
24
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
25
|
+
if (!m) return o;
|
|
26
|
+
var i = m.call(o), r, ar = [], e;
|
|
27
|
+
try {
|
|
28
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
29
|
+
}
|
|
30
|
+
catch (error) { e = { error: error }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e) throw e.error; }
|
|
36
|
+
}
|
|
37
|
+
return ar;
|
|
38
|
+
};
|
|
39
|
+
import 'react-day-picker/style.css';
|
|
40
|
+
import * as React from 'react';
|
|
41
|
+
import { DayPicker } from 'react-day-picker';
|
|
42
|
+
import { Box } from '../box';
|
|
43
|
+
import { Button } from '../button';
|
|
44
|
+
import { Card } from '../card';
|
|
45
|
+
import { DropdownMenuList, DropdownMenuListItem } from '../dropdown-menu';
|
|
46
|
+
import { Popover } from '../popover';
|
|
47
|
+
import { styled } from '../styled';
|
|
48
|
+
import { useMergedClasses } from '../styles/classes';
|
|
49
|
+
import { TextField } from '../text-field';
|
|
50
|
+
import clsx from '../utils/clsx';
|
|
51
|
+
import { datePickerPopoverClasses, datePickerPopoverComponentName, getDatePickerPopoverUtilityClass, } from './date-picker-classes';
|
|
52
|
+
import { applyTimeToDate, extractTimeComponents, formatDate, formatDateRange, parseDate, parseDateRange, } from './date-picker-utils';
|
|
53
|
+
var Root = styled(Popover, { name: datePickerPopoverComponentName, slot: 'Root' })(function (_a) {
|
|
54
|
+
var theme = _a.theme;
|
|
55
|
+
return ({
|
|
56
|
+
marginTop: theme.spacing(0.5),
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
var Content = styled(Card, { name: datePickerPopoverComponentName, slot: 'Content' })(function (_a) {
|
|
60
|
+
var theme = _a.theme, ownerState = _a.ownerState;
|
|
61
|
+
return ({
|
|
62
|
+
maxHeight: 'calc(100% - 96px)',
|
|
63
|
+
minWidth: theme.typography.pxToRem(180),
|
|
64
|
+
width: ownerState.currentView === 'options'
|
|
65
|
+
? ownerState.inputWidth
|
|
66
|
+
? "".concat(ownerState.inputWidth, "px")
|
|
67
|
+
: 'auto'
|
|
68
|
+
: ownerState.showTwoMonths
|
|
69
|
+
? theme.typography.pxToRem(514) // Width for two months calendar view
|
|
70
|
+
: theme.typography.pxToRem(256),
|
|
71
|
+
WebkitOverflowScrolling: 'touch',
|
|
72
|
+
padding: theme.spacing(1),
|
|
73
|
+
border: "1px solid ".concat(theme.tokens.color_border_default),
|
|
74
|
+
borderRadius: 8,
|
|
75
|
+
borderColor: theme.tokens.color_border_default,
|
|
76
|
+
boxShadow: "0px 33px 80px rgba(0, 0, 0, 0.07), 0px 13.7866px 33.4221px rgba(0, 0, 0, 0.0503198), 0px 7.37098px 17.869px rgba(0, 0, 0, 0.0417275), 0px 4.13211px 10.0172px rgba(0, 0, 0, 0.035), 0px 2.19453px 5.32008px rgba(0, 0, 0, 0.0282725), 0px 0.913195px 2.21381px rgba(0, 0, 0, 0.0196802)",
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
var CalendarWrapper = styled('div', { name: datePickerPopoverComponentName, slot: 'CalendarWrapper' })(function (_a) {
|
|
80
|
+
var theme = _a.theme;
|
|
81
|
+
return ({
|
|
82
|
+
padding: theme.spacing(1),
|
|
83
|
+
'.rdp': {
|
|
84
|
+
'--rdp-cell-size': theme.spacing(2),
|
|
85
|
+
'--rdp-accent-color': theme.tokens.color_bg_button_primary,
|
|
86
|
+
'--rdp-background-color': theme.tokens.color_bg_link_primary_hover,
|
|
87
|
+
'--rdp-day-width': theme.spacing(2),
|
|
88
|
+
'--rdp-day-height': theme.spacing(2),
|
|
89
|
+
'--rdp-day_button-width': theme.spacing(2),
|
|
90
|
+
'--rdp-day_button-height': theme.spacing(2),
|
|
91
|
+
margin: 0,
|
|
92
|
+
},
|
|
93
|
+
'.rdp-nav': {
|
|
94
|
+
width: '100%',
|
|
95
|
+
},
|
|
96
|
+
'.rdp-day': {
|
|
97
|
+
color: theme.tokens.color_fg_default,
|
|
98
|
+
fontSize: theme.spacing(1.75),
|
|
99
|
+
width: theme.spacing(4),
|
|
100
|
+
height: theme.spacing(4),
|
|
101
|
+
},
|
|
102
|
+
'.rdp-month_caption': {
|
|
103
|
+
justifyContent: 'center',
|
|
104
|
+
},
|
|
105
|
+
'.rdp-button_previous': {
|
|
106
|
+
'&:focus': {
|
|
107
|
+
outline: "2px solid ".concat(theme.tokens.color_border_focus_bold),
|
|
108
|
+
outlineOffset: 2,
|
|
109
|
+
},
|
|
110
|
+
border: "1px solid ".concat(theme.tokens.color_border_default),
|
|
111
|
+
position: 'absolute',
|
|
112
|
+
left: 0,
|
|
113
|
+
width: theme.spacing(3),
|
|
114
|
+
height: theme.spacing(3),
|
|
115
|
+
borderRadius: theme.spacing(0.5),
|
|
116
|
+
display: 'flex',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
justifyContent: 'center',
|
|
119
|
+
},
|
|
120
|
+
'.rdp-button_next': {
|
|
121
|
+
'&:focus': {
|
|
122
|
+
outline: "2px solid ".concat(theme.tokens.color_border_focus_bold),
|
|
123
|
+
outlineOffset: 2,
|
|
124
|
+
},
|
|
125
|
+
border: "1px solid ".concat(theme.tokens.color_border_default),
|
|
126
|
+
position: 'absolute',
|
|
127
|
+
right: 0,
|
|
128
|
+
width: theme.spacing(3),
|
|
129
|
+
height: theme.spacing(3),
|
|
130
|
+
borderRadius: theme.spacing(0.5),
|
|
131
|
+
display: 'flex',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
},
|
|
135
|
+
'.rdp-chevron': {
|
|
136
|
+
width: theme.spacing(2),
|
|
137
|
+
height: theme.spacing(2),
|
|
138
|
+
display: 'inline-block',
|
|
139
|
+
margin: 0,
|
|
140
|
+
fill: theme.tokens.color_fg_bold,
|
|
141
|
+
},
|
|
142
|
+
'.rdp-day_button': {
|
|
143
|
+
width: theme.spacing(4),
|
|
144
|
+
height: theme.spacing(4),
|
|
145
|
+
},
|
|
146
|
+
'.rdp-range_start .rdp-day_button': {
|
|
147
|
+
backgroundColor: theme.tokens.color_bg_button_primary,
|
|
148
|
+
border: 'none',
|
|
149
|
+
borderRadius: theme.spacing(0.75),
|
|
150
|
+
},
|
|
151
|
+
'.rdp-range_end .rdp-day_button': {
|
|
152
|
+
backgroundColor: theme.tokens.color_bg_button_primary,
|
|
153
|
+
border: 'none',
|
|
154
|
+
borderRadius: theme.spacing(0.75),
|
|
155
|
+
},
|
|
156
|
+
'.rdp-range_middle': {
|
|
157
|
+
backgroundColor: theme.tokens.color_bg_brand_primary_subtle,
|
|
158
|
+
},
|
|
159
|
+
'.rdp-selected': {
|
|
160
|
+
color: theme.tokens.color_fg_bold,
|
|
161
|
+
fontWeight: 'inherit',
|
|
162
|
+
fontSize: theme.spacing(1.75),
|
|
163
|
+
},
|
|
164
|
+
'.rdp-caption_label': {
|
|
165
|
+
fontSize: 14,
|
|
166
|
+
},
|
|
167
|
+
'.rdp-day_selected': {
|
|
168
|
+
backgroundColor: theme.tokens.color_bg_button_primary,
|
|
169
|
+
color: theme.tokens.color_fg_on_button_primary,
|
|
170
|
+
},
|
|
171
|
+
'.rdp-day_selected:hover': {
|
|
172
|
+
backgroundColor: theme.tokens.color_bg_button_primary_hover,
|
|
173
|
+
},
|
|
174
|
+
'.rdp-day_range_start, .rdp-day_range_end': {
|
|
175
|
+
backgroundColor: theme.tokens.color_bg_button_primary,
|
|
176
|
+
color: theme.tokens.color_fg_on_button_primary,
|
|
177
|
+
},
|
|
178
|
+
'.rdp-day_range_middle': {
|
|
179
|
+
backgroundColor: theme.tokens.color_bg_link_primary_hover,
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
var ButtonContainer = styled(Box, { name: datePickerPopoverComponentName, slot: 'ButtonContainer' })(function (_a) {
|
|
184
|
+
var theme = _a.theme;
|
|
185
|
+
return ({
|
|
186
|
+
display: 'flex',
|
|
187
|
+
justifyContent: 'flex-end',
|
|
188
|
+
padding: theme.spacing(1),
|
|
189
|
+
borderTop: "1px solid ".concat(theme.tokens.color_border_default),
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
var TimeInputContainer = styled('div', { name: datePickerPopoverComponentName, slot: 'TimeInput' })(function (_a) {
|
|
193
|
+
var theme = _a.theme;
|
|
194
|
+
return ({
|
|
195
|
+
display: 'flex',
|
|
196
|
+
justifyContent: 'flex-start',
|
|
197
|
+
gap: theme.spacing(0.5),
|
|
198
|
+
padding: theme.spacing(1),
|
|
199
|
+
alignItems: 'center',
|
|
200
|
+
borderTop: "1px solid ".concat(theme.tokens.color_border_default),
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
var EndTimeInputContainer = styled('div', { name: datePickerPopoverComponentName, slot: 'EndTimeInput' })(function (_a) {
|
|
204
|
+
var theme = _a.theme;
|
|
205
|
+
return ({
|
|
206
|
+
display: 'flex',
|
|
207
|
+
justifyContent: 'flex-start',
|
|
208
|
+
gap: theme.spacing(0.5),
|
|
209
|
+
alignItems: 'center',
|
|
210
|
+
marginLeft: theme.spacing(2),
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
var TimeInput = styled(TextField, { name: datePickerPopoverComponentName, slot: 'TimeInputField' })({
|
|
214
|
+
width: '3rem',
|
|
215
|
+
});
|
|
216
|
+
var TimeInputLabel = styled('span', { name: datePickerPopoverComponentName, slot: 'TimeInputLabel' })(function (_a) {
|
|
217
|
+
var theme = _a.theme;
|
|
218
|
+
return ({
|
|
219
|
+
color: theme.tokens.color_fg_default,
|
|
220
|
+
fontSize: theme.typography.caption.fontSize,
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
export var DatePickerPopover = React.forwardRef(function (props, ref) {
|
|
224
|
+
var anchorEl = props.anchorEl, open = props.open, onClose = props.onClose, onDateSelect = props.onDateSelect, options = props.options, value = props.value, _a = props.dateFormat, dateFormat = _a === void 0 ? 'MM/dd/yyyy' : _a, _b = props.timeFormat, timeFormat = _b === void 0 ? 'HH:mm:ss' : _b, PopoverProps = props.PopoverProps, _c = props.showTwoMonths, showTwoMonths = _c === void 0 ? false : _c, _d = props.isRangeSelection, isRangeSelection = _d === void 0 ? false : _d, _e = props.showTimeInput, showTimeInput = _e === void 0 ? false : _e, propClasses = props.classes, rootProps = __rest(props, ["anchorEl", "open", "onClose", "onDateSelect", "options", "value", "dateFormat", "timeFormat", "PopoverProps", "showTwoMonths", "isRangeSelection", "showTimeInput", "classes"]);
|
|
225
|
+
var classes = useMergedClasses(datePickerPopoverClasses, getDatePickerPopoverUtilityClass, propClasses);
|
|
226
|
+
// State to track the current view: 'options' or 'calendar'
|
|
227
|
+
var _f = __read(React.useState(options ? 'options' : 'calendar'), 2), currentView = _f[0], setCurrentView = _f[1];
|
|
228
|
+
// State to track the current range selection
|
|
229
|
+
var _g = __read(React.useState({}), 2), rangeSelection = _g[0], setRangeSelection = _g[1];
|
|
230
|
+
// Time state for single date or range start/end
|
|
231
|
+
var _h = __read(React.useState('00'), 2), hours = _h[0], setHours = _h[1];
|
|
232
|
+
var _j = __read(React.useState('00'), 2), minutes = _j[0], setMinutes = _j[1];
|
|
233
|
+
var _k = __read(React.useState('00'), 2), seconds = _k[0], setSeconds = _k[1];
|
|
234
|
+
// For range selection - end time
|
|
235
|
+
var _l = __read(React.useState('00'), 2), endHours = _l[0], setEndHours = _l[1];
|
|
236
|
+
var _m = __read(React.useState('00'), 2), endMinutes = _m[0], setEndMinutes = _m[1];
|
|
237
|
+
var _o = __read(React.useState('00'), 2), endSeconds = _o[0], setEndSeconds = _o[1];
|
|
238
|
+
// Reset selection and view when popover opens/closes
|
|
239
|
+
React.useEffect(function () {
|
|
240
|
+
if (!open) {
|
|
241
|
+
setRangeSelection({});
|
|
242
|
+
// Reset the view to options if there are options available
|
|
243
|
+
if (options) {
|
|
244
|
+
setCurrentView('options');
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else if (value) {
|
|
248
|
+
if (isRangeSelection && value.includes('-')) {
|
|
249
|
+
// Parse range selection
|
|
250
|
+
var _a = parseDateRange(value, dateFormat, showTimeInput ? timeFormat : undefined), from = _a.from, to = _a.to;
|
|
251
|
+
if (from) {
|
|
252
|
+
// Extract time components for range start
|
|
253
|
+
var _b = extractTimeComponents(from), h = _b.hours, m = _b.minutes, s = _b.seconds;
|
|
254
|
+
setHours(h);
|
|
255
|
+
setMinutes(m);
|
|
256
|
+
setSeconds(s);
|
|
257
|
+
}
|
|
258
|
+
if (to) {
|
|
259
|
+
// Extract time components for range end
|
|
260
|
+
var _c = extractTimeComponents(to), h = _c.hours, m = _c.minutes, s = _c.seconds;
|
|
261
|
+
setEndHours(h);
|
|
262
|
+
setEndMinutes(m);
|
|
263
|
+
setEndSeconds(s);
|
|
264
|
+
}
|
|
265
|
+
if (from && to) {
|
|
266
|
+
setRangeSelection({ from: from, to: to });
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
else if (!isRangeSelection) {
|
|
270
|
+
// For single date, try to parse with time format first if showTimeInput is enabled
|
|
271
|
+
var formatString = showTimeInput ? "".concat(dateFormat, " ").concat(timeFormat) : dateFormat;
|
|
272
|
+
var date = parseDate(value, formatString);
|
|
273
|
+
if (date) {
|
|
274
|
+
setRangeSelection({ from: date });
|
|
275
|
+
if (showTimeInput) {
|
|
276
|
+
// Extract time components
|
|
277
|
+
var _d = extractTimeComponents(date), h = _d.hours, m = _d.minutes, s = _d.seconds;
|
|
278
|
+
setHours(h);
|
|
279
|
+
setMinutes(m);
|
|
280
|
+
setSeconds(s);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}, [open, value, isRangeSelection, dateFormat, timeFormat, options, showTimeInput]);
|
|
286
|
+
// Handle calendar selections
|
|
287
|
+
var handleCalendarSelect = function (selection) {
|
|
288
|
+
if (!selection)
|
|
289
|
+
return;
|
|
290
|
+
// Keep the time values when date changes
|
|
291
|
+
if (selection.from && !selection.to) {
|
|
292
|
+
// Single date or range start
|
|
293
|
+
if (showTimeInput) {
|
|
294
|
+
var newFrom = applyTimeToDate(selection.from, { hours: hours, minutes: minutes, seconds: seconds });
|
|
295
|
+
setRangeSelection({ from: newFrom });
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
setRangeSelection({ from: selection.from });
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
else if (selection.from && selection.to) {
|
|
302
|
+
// Range selection
|
|
303
|
+
if (showTimeInput) {
|
|
304
|
+
var newFrom = applyTimeToDate(selection.from, { hours: hours, minutes: minutes, seconds: seconds });
|
|
305
|
+
var newTo = applyTimeToDate(selection.to, { hours: endHours, minutes: endMinutes, seconds: endSeconds });
|
|
306
|
+
setRangeSelection({ from: newFrom, to: newTo });
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
setRangeSelection(selection);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
// Only auto-apply selection for non-range selection mode and when not showing time input
|
|
313
|
+
if (!isRangeSelection && !showTimeInput) {
|
|
314
|
+
applySelection(selection.from);
|
|
315
|
+
}
|
|
316
|
+
// For range selection or time input, we'll wait for user to click Apply
|
|
317
|
+
};
|
|
318
|
+
var handleTimeChange = function (value, setter, max) {
|
|
319
|
+
var numValue = value.replace(/\D/g, '');
|
|
320
|
+
var parsed = parseInt(numValue, 10);
|
|
321
|
+
if (!isNaN(parsed) && parsed >= 0 && parsed <= max) {
|
|
322
|
+
setter(parsed.toString().padStart(2, '0'));
|
|
323
|
+
}
|
|
324
|
+
else if (value === '') {
|
|
325
|
+
setter('00');
|
|
326
|
+
}
|
|
327
|
+
updateDateWithTime();
|
|
328
|
+
};
|
|
329
|
+
var updateDateWithTime = function () {
|
|
330
|
+
if (!rangeSelection.from)
|
|
331
|
+
return;
|
|
332
|
+
var newFrom = applyTimeToDate(rangeSelection.from, { hours: hours, minutes: minutes, seconds: seconds });
|
|
333
|
+
if (isRangeSelection && rangeSelection.to) {
|
|
334
|
+
var newTo = applyTimeToDate(rangeSelection.to, {
|
|
335
|
+
hours: endHours,
|
|
336
|
+
minutes: endMinutes,
|
|
337
|
+
seconds: endSeconds,
|
|
338
|
+
});
|
|
339
|
+
setRangeSelection({ from: newFrom, to: newTo });
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
setRangeSelection({ from: newFrom });
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var applySelection = function (singleDate) {
|
|
346
|
+
if (isRangeSelection) {
|
|
347
|
+
if (rangeSelection.from && rangeSelection.to) {
|
|
348
|
+
var formattedRange = formatDateRange(rangeSelection.from, rangeSelection.to, dateFormat, showTimeInput ? timeFormat : undefined);
|
|
349
|
+
onDateSelect(formattedRange, true);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else if (singleDate || rangeSelection.from) {
|
|
353
|
+
var dateToFormat = singleDate || rangeSelection.from;
|
|
354
|
+
if (dateToFormat) {
|
|
355
|
+
var formatString = showTimeInput ? "".concat(dateFormat, " ").concat(timeFormat) : dateFormat;
|
|
356
|
+
var formattedDate = formatDate(dateToFormat, formatString);
|
|
357
|
+
onDateSelect(formattedDate, true);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
var cancelSelection = function () {
|
|
362
|
+
if (options) {
|
|
363
|
+
setCurrentView('options');
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
onClose();
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var handleOptionSelect = function (optionValue) {
|
|
370
|
+
if (optionValue === 'custom') {
|
|
371
|
+
setCurrentView('calendar');
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
onDateSelect(optionValue, true);
|
|
375
|
+
};
|
|
376
|
+
var selectedValue;
|
|
377
|
+
if (rangeSelection.from) {
|
|
378
|
+
selectedValue = { from: rangeSelection.from, to: rangeSelection.to };
|
|
379
|
+
}
|
|
380
|
+
else if (value && !isRangeSelection) {
|
|
381
|
+
var formatString = showTimeInput ? "".concat(dateFormat, " ").concat(timeFormat) : dateFormat;
|
|
382
|
+
var parsedDate = parseDate(value, formatString);
|
|
383
|
+
if (parsedDate) {
|
|
384
|
+
selectedValue = parsedDate;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
// Determine if we should show the action buttons - now for both range selection and time input
|
|
388
|
+
var showActionButtons = isRangeSelection || showTimeInput;
|
|
389
|
+
var canApply = isRangeSelection ? rangeSelection.from && rangeSelection.to : !!rangeSelection.from;
|
|
390
|
+
var _p = __read(React.useState(null), 2), inputWidth = _p[0], setInputWidth = _p[1];
|
|
391
|
+
React.useEffect(function () {
|
|
392
|
+
if (open && anchorEl) {
|
|
393
|
+
var width = anchorEl.getBoundingClientRect().width;
|
|
394
|
+
setInputWidth(width);
|
|
395
|
+
}
|
|
396
|
+
}, [open, anchorEl]);
|
|
397
|
+
var ownerState = {
|
|
398
|
+
showTwoMonths: showTwoMonths,
|
|
399
|
+
isRangeSelection: isRangeSelection,
|
|
400
|
+
};
|
|
401
|
+
return (React.createElement(Root, __assign({ open: open, anchorEl: anchorEl, onClose: onClose, className: clsx(classes.root), ownerState: ownerState, ref: ref, anchorOrigin: {
|
|
402
|
+
vertical: 'bottom',
|
|
403
|
+
horizontal: 'left',
|
|
404
|
+
}, transformOrigin: {
|
|
405
|
+
vertical: 'top',
|
|
406
|
+
horizontal: 'left',
|
|
407
|
+
}, marginThreshold: 30, style: { marginTop: '-24px' } }, PopoverProps, rootProps),
|
|
408
|
+
React.createElement(Content, { className: classes.content, ownerState: __assign(__assign({}, ownerState), { inputWidth: inputWidth, currentView: currentView }) }, currentView === 'options' && options ? (React.createElement(DropdownMenuList, null, options.map(function (option, index) { return (React.createElement(DropdownMenuListItem, { key: index, title: option.text, selected: option.value === value, onClick: function () { return handleOptionSelect(option.value); } })); }))) : (React.createElement(React.Fragment, null,
|
|
409
|
+
React.createElement(CalendarWrapper, { className: classes.calendarWrapper },
|
|
410
|
+
React.createElement(DayPicker, { mode: "range", selected: selectedValue, onSelect: handleCalendarSelect, showOutsideDays: true, numberOfMonths: showTwoMonths ? 2 : 1, pagedNavigation: showTwoMonths })),
|
|
411
|
+
showTimeInput && (React.createElement(React.Fragment, null,
|
|
412
|
+
React.createElement(TimeInputContainer, null,
|
|
413
|
+
React.createElement(TimeInputLabel, null, "Time:"),
|
|
414
|
+
React.createElement(TimeInput, { size: "small", value: hours, onChange: function (e) { return handleTimeChange(e.target.value, setHours, 23); }, placeholder: "HH" }),
|
|
415
|
+
React.createElement("span", null, ":"),
|
|
416
|
+
React.createElement(TimeInput, { size: "small", value: minutes, onChange: function (e) { return handleTimeChange(e.target.value, setMinutes, 59); }, placeholder: "MM" }),
|
|
417
|
+
React.createElement("span", null, ":"),
|
|
418
|
+
React.createElement(TimeInput, { size: "small", value: seconds, onChange: function (e) { return handleTimeChange(e.target.value, setSeconds, 59); }, placeholder: "SS" }),
|
|
419
|
+
isRangeSelection && (React.createElement(EndTimeInputContainer, null,
|
|
420
|
+
React.createElement(TimeInputLabel, null, "End Time:"),
|
|
421
|
+
React.createElement(TimeInput, { size: "small", value: endHours, onChange: function (e) { return handleTimeChange(e.target.value, setEndHours, 23); }, placeholder: "HH" }),
|
|
422
|
+
React.createElement("span", null, ":"),
|
|
423
|
+
React.createElement(TimeInput, { size: "small", value: endMinutes, onChange: function (e) { return handleTimeChange(e.target.value, setEndMinutes, 59); }, placeholder: "MM" }),
|
|
424
|
+
React.createElement("span", null, ":"),
|
|
425
|
+
React.createElement(TimeInput, { size: "small", value: endSeconds, onChange: function (e) { return handleTimeChange(e.target.value, setEndSeconds, 59); }, placeholder: "SS" })))))),
|
|
426
|
+
showActionButtons && (React.createElement(ButtonContainer, { className: classes.buttonContainer },
|
|
427
|
+
React.createElement(Button, { size: "small", variant: "outlined", onClick: cancelSelection, style: { marginRight: 8 } }, "Cancel"),
|
|
428
|
+
React.createElement(Button, { size: "small", variant: "contained", color: "primary", onClick: function () { return applySelection(); }, disabled: !canApply }, "Apply"))))))));
|
|
429
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
import * as React from 'react';
|
|
29
|
+
import { useId } from '../utils/use-id';
|
|
30
|
+
export var useDatePickerState = function (_a) {
|
|
31
|
+
var _b = _a === void 0 ? {} : _a, propBaseId = _b.baseId;
|
|
32
|
+
var baseId = useId(propBaseId);
|
|
33
|
+
var triggerId = "".concat(baseId, "-trigger");
|
|
34
|
+
var popoverId = "".concat(baseId, "-popover");
|
|
35
|
+
var _c = __read(React.useState(null), 2), anchorEl = _c[0], setAnchorEl = _c[1];
|
|
36
|
+
var handleTriggerClick = function (event) {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
setAnchorEl(event.currentTarget);
|
|
39
|
+
};
|
|
40
|
+
var handlePopoverClose = function () { return setAnchorEl(null); };
|
|
41
|
+
var isOpen = Boolean(anchorEl);
|
|
42
|
+
return {
|
|
43
|
+
triggerProps: {
|
|
44
|
+
onClick: handleTriggerClick,
|
|
45
|
+
id: triggerId,
|
|
46
|
+
'aria-controls': popoverId,
|
|
47
|
+
'aria-haspopup': 'dialog',
|
|
48
|
+
'aria-expanded': isOpen,
|
|
49
|
+
},
|
|
50
|
+
popoverProps: {
|
|
51
|
+
anchorEl: anchorEl,
|
|
52
|
+
open: isOpen,
|
|
53
|
+
onClose: handlePopoverClose,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
export var DatePickerStateContext = React.createContext({
|
|
58
|
+
triggerProps: { onClick: function () { return undefined; } },
|
|
59
|
+
popoverProps: { anchorEl: null, open: false, onClose: function () { return undefined; } },
|
|
60
|
+
});
|
|
61
|
+
export var useDatePickerStateContext = function () { return React.useContext(DatePickerStateContext); };
|
|
62
|
+
export var DatePickerStateProvider = function (_a) {
|
|
63
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
64
|
+
var state = useDatePickerState(props);
|
|
65
|
+
return (React.createElement(DatePickerStateContext.Provider, { value: state }, typeof children === 'function' ? children(state) : children));
|
|
66
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
import { format, isValid, parse } from 'date-fns';
|
|
29
|
+
/**
|
|
30
|
+
* Formats a date object using the specified format string
|
|
31
|
+
*/
|
|
32
|
+
export var formatDate = function (date, formatString) {
|
|
33
|
+
return format(date, formatString);
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Parses a date string using the specified format
|
|
37
|
+
*/
|
|
38
|
+
export var parseDate = function (dateString, formatString, referenceDate) {
|
|
39
|
+
if (referenceDate === void 0) { referenceDate = new Date(); }
|
|
40
|
+
try {
|
|
41
|
+
var parsed = parse(dateString, formatString, referenceDate);
|
|
42
|
+
return isValid(parsed) ? parsed : null;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Try to parse a date string using multiple formats
|
|
50
|
+
*/
|
|
51
|
+
export var tryParseDate = function (dateString, formatStrings, referenceDate) {
|
|
52
|
+
var e_1, _a;
|
|
53
|
+
if (referenceDate === void 0) { referenceDate = new Date(); }
|
|
54
|
+
try {
|
|
55
|
+
for (var formatStrings_1 = __values(formatStrings), formatStrings_1_1 = formatStrings_1.next(); !formatStrings_1_1.done; formatStrings_1_1 = formatStrings_1.next()) {
|
|
56
|
+
var formatString = formatStrings_1_1.value;
|
|
57
|
+
var parsed = parseDate(dateString, formatString, referenceDate);
|
|
58
|
+
if (parsed) {
|
|
59
|
+
return parsed;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
64
|
+
finally {
|
|
65
|
+
try {
|
|
66
|
+
if (formatStrings_1_1 && !formatStrings_1_1.done && (_a = formatStrings_1.return)) _a.call(formatStrings_1);
|
|
67
|
+
}
|
|
68
|
+
finally { if (e_1) throw e_1.error; }
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Handles parsing a timestamp (number) into a Date
|
|
74
|
+
*/
|
|
75
|
+
export var parseTimestamp = function (timestamp, unit) {
|
|
76
|
+
if (unit === void 0) { unit = 'ms'; }
|
|
77
|
+
try {
|
|
78
|
+
var date = new Date(unit === 's' ? timestamp * 1000 : timestamp);
|
|
79
|
+
return isValid(date) ? date : null;
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Parses a date range string (format: "start - end")
|
|
87
|
+
*/
|
|
88
|
+
export var parseDateRange = function (rangeString, dateFormat, timeFormat) {
|
|
89
|
+
if (!rangeString.includes('-')) {
|
|
90
|
+
return { from: null, to: null };
|
|
91
|
+
}
|
|
92
|
+
var _a = __read(rangeString.split('-').map(function (s) { return s.trim(); }), 2), fromStr = _a[0], toStr = _a[1];
|
|
93
|
+
var fullFormat = timeFormat ? "".concat(dateFormat, " ").concat(timeFormat) : dateFormat;
|
|
94
|
+
var from = parseDate(fromStr, fullFormat);
|
|
95
|
+
var to = parseDate(toStr, fullFormat);
|
|
96
|
+
if (!from) {
|
|
97
|
+
from = parseDate(fromStr, dateFormat);
|
|
98
|
+
}
|
|
99
|
+
if (!to) {
|
|
100
|
+
to = parseDate(toStr, dateFormat);
|
|
101
|
+
}
|
|
102
|
+
return { from: from, to: to };
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Format a date range as a string
|
|
106
|
+
*/
|
|
107
|
+
export var formatDateRange = function (from, to, dateFormat, timeFormat) {
|
|
108
|
+
if (!from)
|
|
109
|
+
return '';
|
|
110
|
+
var formatString = timeFormat ? "".concat(dateFormat, " ").concat(timeFormat) : dateFormat;
|
|
111
|
+
if (!to) {
|
|
112
|
+
return formatDate(from, formatString);
|
|
113
|
+
}
|
|
114
|
+
return "".concat(formatDate(from, formatString), " - ").concat(formatDate(to, formatString));
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Extract time components from a date
|
|
118
|
+
*/
|
|
119
|
+
export var extractTimeComponents = function (date) {
|
|
120
|
+
return {
|
|
121
|
+
hours: formatDate(date, 'HH'),
|
|
122
|
+
minutes: formatDate(date, 'mm'),
|
|
123
|
+
seconds: formatDate(date, 'ss'),
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Apply time components to a date
|
|
128
|
+
*/
|
|
129
|
+
export var applyTimeToDate = function (date, time) {
|
|
130
|
+
var newDate = new Date(date);
|
|
131
|
+
newDate.setHours(parseInt(time.hours, 10) || 0);
|
|
132
|
+
newDate.setMinutes(parseInt(time.minutes, 10) || 0);
|
|
133
|
+
newDate.setSeconds(parseInt(time.seconds, 10) || 0);
|
|
134
|
+
return newDate;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Safely parses a value that might be a timestamp or a date string
|
|
138
|
+
*/
|
|
139
|
+
export var parseSmartDate = function (value, dateFormat, timeFormat) {
|
|
140
|
+
var timestamp = parseInt(value, 10);
|
|
141
|
+
if (!isNaN(timestamp)) {
|
|
142
|
+
var date = parseTimestamp(timestamp);
|
|
143
|
+
if (date)
|
|
144
|
+
return date;
|
|
145
|
+
}
|
|
146
|
+
if (timeFormat) {
|
|
147
|
+
var fullFormat = "".concat(dateFormat, " ").concat(timeFormat);
|
|
148
|
+
var date = parseDate(value, fullFormat);
|
|
149
|
+
if (date)
|
|
150
|
+
return date;
|
|
151
|
+
}
|
|
152
|
+
return parseDate(value, dateFormat);
|
|
153
|
+
};
|