@auth0/quantum-product 2.6.0 → 2.7.1
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-context.d.ts +2 -0
- package/date-picker/date-picker-context.js +2 -0
- package/date-picker/date-picker-popover.js +114 -137
- package/date-picker/date-picker-time-input.d.ts +21 -0
- package/date-picker/date-picker-time-input.js +362 -0
- package/date-picker/date-picker-types.d.ts +4 -0
- package/date-picker/date-picker.js +4 -2
- package/dropdown-menu/dropdown-menu-list-item/dropdown-menu-list-item.d.ts +1 -0
- package/dropdown-menu/dropdown-menu-list-item/dropdown-menu-list-item.js +2 -2
- package/esm/date-picker/date-picker-context.js +2 -0
- package/esm/date-picker/date-picker-popover.js +114 -137
- package/esm/date-picker/date-picker-time-input.js +336 -0
- package/esm/date-picker/date-picker.js +4 -2
- package/esm/dropdown-menu/dropdown-menu-list-item/dropdown-menu-list-item.js +2 -2
- package/esm/panel/panel/panel-classes.js +1 -0
- package/esm/panel/panel/panel.js +1 -0
- package/package.json +1 -1
- package/panel/panel/panel-classes.d.ts +1 -1
- package/panel/panel/panel-classes.js +1 -0
- package/panel/panel/panel.d.ts +1 -1
- package/panel/panel/panel.js +1 -0
- package/panel/panel-context.d.ts +1 -1
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.DatePickerTimeInput = void 0;
|
|
38
|
+
var React = __importStar(require("react"));
|
|
39
|
+
var styled_1 = require("../styled");
|
|
40
|
+
var text_field_1 = require("../text-field");
|
|
41
|
+
var date_picker_classes_1 = require("./date-picker-classes");
|
|
42
|
+
var TimeInputContainer = (0, styled_1.styled)('div', { name: date_picker_classes_1.datePickerPopoverComponentName, slot: 'TimeInput' })(function (_a) {
|
|
43
|
+
var theme = _a.theme;
|
|
44
|
+
return ({
|
|
45
|
+
display: 'flex',
|
|
46
|
+
justifyContent: 'flex-start',
|
|
47
|
+
gap: theme.spacing(0.5),
|
|
48
|
+
padding: theme.spacing(1),
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
borderTop: "1px solid ".concat(theme.tokens.color_border_default),
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
var EndTimeInputContainer = (0, styled_1.styled)('div', { name: date_picker_classes_1.datePickerPopoverComponentName, slot: 'EndTimeInput' })(function (_a) {
|
|
54
|
+
var theme = _a.theme;
|
|
55
|
+
return ({
|
|
56
|
+
display: 'flex',
|
|
57
|
+
justifyContent: 'flex-start',
|
|
58
|
+
gap: theme.spacing(0.5),
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
marginLeft: theme.spacing(2),
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
var TimeInput = (0, styled_1.styled)(text_field_1.TextField, { name: date_picker_classes_1.datePickerPopoverComponentName, slot: 'TimeInputField' })({
|
|
64
|
+
minWidth: '3rem',
|
|
65
|
+
width: '3rem',
|
|
66
|
+
'& .MuiOutlinedInput-input': {
|
|
67
|
+
textAlign: 'center',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
var TimeInputLabel = (0, styled_1.styled)('span', { name: date_picker_classes_1.datePickerPopoverComponentName, slot: 'TimeInputLabel' })(function (_a) {
|
|
71
|
+
var theme = _a.theme;
|
|
72
|
+
return ({
|
|
73
|
+
color: theme.tokens.color_fg_default,
|
|
74
|
+
fontSize: theme.typography.caption.fontSize,
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
exports.DatePickerTimeInput = React.forwardRef(function (props, ref) {
|
|
78
|
+
var startTime = props.startTime, endTime = props.endTime, _a = props.isRangeSelection, isRangeSelection = _a === void 0 ? false : _a, onStartTimeChange = props.onStartTimeChange, onEndTimeChange = props.onEndTimeChange, onClear = props.onClear;
|
|
79
|
+
// Refs for time input navigation
|
|
80
|
+
var hoursRef = React.useRef(null);
|
|
81
|
+
var minutesRef = React.useRef(null);
|
|
82
|
+
var secondsRef = React.useRef(null);
|
|
83
|
+
var endHoursRef = React.useRef(null);
|
|
84
|
+
var endMinutesRef = React.useRef(null);
|
|
85
|
+
var endSecondsRef = React.useRef(null);
|
|
86
|
+
var handleTimeChange = function (value, timeType, field, max) {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
var numValue = value.replace(/\D/g, '');
|
|
89
|
+
var parsed = parseInt(numValue, 10);
|
|
90
|
+
var newValue = '00';
|
|
91
|
+
if (!isNaN(parsed) && parsed >= 0 && parsed <= max) {
|
|
92
|
+
newValue = parsed.toString().padStart(2, '0');
|
|
93
|
+
}
|
|
94
|
+
else if (value === '') {
|
|
95
|
+
newValue = '00';
|
|
96
|
+
}
|
|
97
|
+
if (timeType === 'start') {
|
|
98
|
+
var newTime = __assign(__assign({}, startTime), (_a = {}, _a[field] = newValue, _a));
|
|
99
|
+
onStartTimeChange(newTime);
|
|
100
|
+
}
|
|
101
|
+
else if (timeType === 'end' && endTime && onEndTimeChange) {
|
|
102
|
+
var newTime = __assign(__assign({}, endTime), (_b = {}, _b[field] = newValue, _b));
|
|
103
|
+
onEndTimeChange(newTime);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var clearAllTimeInputs = React.useCallback(function () {
|
|
107
|
+
var clearedTime = { hours: '00', minutes: '00', seconds: '00' };
|
|
108
|
+
onStartTimeChange(clearedTime);
|
|
109
|
+
if (isRangeSelection && onEndTimeChange) {
|
|
110
|
+
onEndTimeChange(clearedTime);
|
|
111
|
+
}
|
|
112
|
+
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
113
|
+
setTimeout(function () {
|
|
114
|
+
var _a, _b;
|
|
115
|
+
(_a = hoursRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
116
|
+
(_b = hoursRef.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(0, 0);
|
|
117
|
+
}, 0);
|
|
118
|
+
}, [onStartTimeChange, onEndTimeChange, onClear, isRangeSelection]);
|
|
119
|
+
var handleArrowKeys = function (e, config, target, isAtStart, isAtEnd) {
|
|
120
|
+
var _a, _b;
|
|
121
|
+
switch (e.key) {
|
|
122
|
+
case 'ArrowUp': {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
var upValue = parseInt(config.currentValue, 10) || 0;
|
|
125
|
+
var newUpValue = upValue === config.max ? 0 : upValue + 1;
|
|
126
|
+
var newValueStr = newUpValue.toString().padStart(2, '0');
|
|
127
|
+
handleTimeChange(newValueStr, config.timeType, config.field, config.max);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case 'ArrowDown': {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
var downValue = parseInt(config.currentValue, 10) || 0;
|
|
133
|
+
var newDownValue = downValue === 0 ? config.max : downValue - 1;
|
|
134
|
+
var newValueStr = newDownValue.toString().padStart(2, '0');
|
|
135
|
+
handleTimeChange(newValueStr, config.timeType, config.field, config.max);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case 'ArrowRight':
|
|
139
|
+
if (isAtEnd && ((_a = config.nextRef) === null || _a === void 0 ? void 0 : _a.current)) {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
config.nextRef.current.focus();
|
|
142
|
+
config.nextRef.current.setSelectionRange(0, 0);
|
|
143
|
+
}
|
|
144
|
+
break;
|
|
145
|
+
case 'ArrowLeft':
|
|
146
|
+
if (isAtStart && ((_b = config.prevRef) === null || _b === void 0 ? void 0 : _b.current)) {
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
config.prevRef.current.focus();
|
|
149
|
+
config.prevRef.current.setSelectionRange(2, 2);
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
var handleEditKeys = function (e, config, target, startPos, endPos, isAtStart) {
|
|
155
|
+
var _a;
|
|
156
|
+
switch (e.key) {
|
|
157
|
+
case 'Backspace':
|
|
158
|
+
if (isAtStart && ((_a = config.prevRef) === null || _a === void 0 ? void 0 : _a.current)) {
|
|
159
|
+
e.preventDefault();
|
|
160
|
+
config.prevRef.current.focus();
|
|
161
|
+
config.prevRef.current.setSelectionRange(2, 2);
|
|
162
|
+
}
|
|
163
|
+
else if (startPos === endPos) {
|
|
164
|
+
e.preventDefault();
|
|
165
|
+
var newPos_1 = Math.max(0, startPos - 1);
|
|
166
|
+
var newValue = target.value.substring(0, newPos_1) + '0' + target.value.substring(startPos);
|
|
167
|
+
var parsed = parseInt(newValue, 10) || 0;
|
|
168
|
+
if (parsed <= config.max) {
|
|
169
|
+
handleTimeChange(newValue, config.timeType, config.field, config.max);
|
|
170
|
+
setTimeout(function () { return target.setSelectionRange(newPos_1, newPos_1); }, 0);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case 'Delete':
|
|
175
|
+
if (startPos === endPos) {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
var newValue = target.value.substring(0, startPos) + '0' + target.value.substring(startPos + 1);
|
|
178
|
+
var parsed = parseInt(newValue, 10) || 0;
|
|
179
|
+
if (parsed <= config.max) {
|
|
180
|
+
handleTimeChange(newValue, config.timeType, config.field, config.max);
|
|
181
|
+
setTimeout(function () { return target.setSelectionRange(startPos, startPos); }, 0);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var handleNumberInput = function (e, config, target, startPos, endPos) {
|
|
188
|
+
if (!/^[0-9]$/.test(e.key))
|
|
189
|
+
return;
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
var newValue = target.value;
|
|
192
|
+
if (startPos === endPos) {
|
|
193
|
+
if (target.value.length < 2) {
|
|
194
|
+
newValue = target.value + e.key;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
newValue = target.value.substring(0, startPos) + e.key + target.value.substring(startPos + 1);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
newValue = target.value.substring(0, startPos) + e.key + target.value.substring(endPos);
|
|
202
|
+
}
|
|
203
|
+
var parsed = parseInt(newValue, 10) || 0;
|
|
204
|
+
if (parsed <= config.max) {
|
|
205
|
+
handleTimeChange(newValue, config.timeType, config.field, config.max);
|
|
206
|
+
var newPos_2 = Math.min(startPos + 1, 2);
|
|
207
|
+
setTimeout(function () {
|
|
208
|
+
var _a;
|
|
209
|
+
target.setSelectionRange(newPos_2, newPos_2);
|
|
210
|
+
if (newValue.length === 2 && startPos === 1 && ((_a = config.nextRef) === null || _a === void 0 ? void 0 : _a.current)) {
|
|
211
|
+
config.nextRef.current.focus();
|
|
212
|
+
config.nextRef.current.setSelectionRange(0, 0);
|
|
213
|
+
}
|
|
214
|
+
}, 0);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
var handleTimeKeyDown = function (e, currentValue, timeType, field, max, nextRef, prevRef) {
|
|
218
|
+
var target = e.target;
|
|
219
|
+
var selectionStart = target.selectionStart, selectionEnd = target.selectionEnd;
|
|
220
|
+
var startPos = selectionStart !== null && selectionStart !== void 0 ? selectionStart : 0;
|
|
221
|
+
var endPos = selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : 0;
|
|
222
|
+
var isAtStart = startPos === 0;
|
|
223
|
+
var isAtEnd = startPos === target.value.length;
|
|
224
|
+
var config = {
|
|
225
|
+
currentValue: currentValue,
|
|
226
|
+
timeType: timeType,
|
|
227
|
+
field: field,
|
|
228
|
+
max: max,
|
|
229
|
+
nextRef: nextRef,
|
|
230
|
+
prevRef: prevRef,
|
|
231
|
+
};
|
|
232
|
+
// Clear all inputs with Cmd/Ctrl + Backspace
|
|
233
|
+
if (e.key === 'Backspace' && (e.metaKey || e.ctrlKey)) {
|
|
234
|
+
e.preventDefault();
|
|
235
|
+
clearAllTimeInputs();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.key)) {
|
|
239
|
+
handleArrowKeys(e, config, target, isAtStart, isAtEnd);
|
|
240
|
+
}
|
|
241
|
+
else if (['Backspace', 'Delete'].includes(e.key)) {
|
|
242
|
+
handleEditKeys(e, config, target, startPos, endPos, isAtStart);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
handleNumberInput(e, config, target, startPos, endPos);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var parseTimeFromDigits = function (digitsOnly) {
|
|
249
|
+
var hours = '00';
|
|
250
|
+
var minutes = '00';
|
|
251
|
+
var seconds = '00';
|
|
252
|
+
if (digitsOnly.length === 6) {
|
|
253
|
+
hours = Math.min(parseInt(digitsOnly.substring(0, 2), 10), 23)
|
|
254
|
+
.toString()
|
|
255
|
+
.padStart(2, '0');
|
|
256
|
+
minutes = Math.min(parseInt(digitsOnly.substring(2, 4), 10), 59)
|
|
257
|
+
.toString()
|
|
258
|
+
.padStart(2, '0');
|
|
259
|
+
seconds = Math.min(parseInt(digitsOnly.substring(4, 6), 10), 59)
|
|
260
|
+
.toString()
|
|
261
|
+
.padStart(2, '0');
|
|
262
|
+
}
|
|
263
|
+
else if (digitsOnly.length === 4) {
|
|
264
|
+
hours = Math.min(parseInt(digitsOnly.substring(0, 2), 10), 23)
|
|
265
|
+
.toString()
|
|
266
|
+
.padStart(2, '0');
|
|
267
|
+
minutes = Math.min(parseInt(digitsOnly.substring(2, 4), 10), 59)
|
|
268
|
+
.toString()
|
|
269
|
+
.padStart(2, '0');
|
|
270
|
+
}
|
|
271
|
+
else if (digitsOnly.length <= 2) {
|
|
272
|
+
hours = Math.min(parseInt(digitsOnly, 10), 23).toString().padStart(2, '0');
|
|
273
|
+
}
|
|
274
|
+
else {
|
|
275
|
+
var paddedDigits = digitsOnly.padStart(4, '0');
|
|
276
|
+
hours = Math.min(parseInt(paddedDigits.substring(0, 2), 10), 23)
|
|
277
|
+
.toString()
|
|
278
|
+
.padStart(2, '0');
|
|
279
|
+
minutes = Math.min(parseInt(paddedDigits.substring(2, 4), 10), 59)
|
|
280
|
+
.toString()
|
|
281
|
+
.padStart(2, '0');
|
|
282
|
+
}
|
|
283
|
+
return { hours: hours, minutes: minutes, seconds: seconds };
|
|
284
|
+
};
|
|
285
|
+
var getFocusTargetAfterPaste = function (digitsOnly, timeType) {
|
|
286
|
+
var isStart = timeType === 'start';
|
|
287
|
+
if (digitsOnly.length === 6) {
|
|
288
|
+
return isStart ? secondsRef : endSecondsRef;
|
|
289
|
+
}
|
|
290
|
+
else if (digitsOnly.length === 4) {
|
|
291
|
+
return isStart ? minutesRef : endMinutesRef;
|
|
292
|
+
}
|
|
293
|
+
else if (digitsOnly.length <= 2) {
|
|
294
|
+
return isStart ? hoursRef : endHoursRef;
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
return isStart ? minutesRef : endMinutesRef;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var handleTimePaste = function (e, timeType) {
|
|
301
|
+
e.preventDefault();
|
|
302
|
+
var pastedText = e.clipboardData.getData('text').trim();
|
|
303
|
+
var digitsOnly = pastedText.replace(/\D/g, '').substring(0, 6);
|
|
304
|
+
if (digitsOnly.length === 0)
|
|
305
|
+
return;
|
|
306
|
+
var newTime = parseTimeFromDigits(digitsOnly);
|
|
307
|
+
var focusTargetRef = getFocusTargetAfterPaste(digitsOnly, timeType);
|
|
308
|
+
if (timeType === 'start') {
|
|
309
|
+
onStartTimeChange(newTime);
|
|
310
|
+
}
|
|
311
|
+
else if (timeType === 'end' && onEndTimeChange) {
|
|
312
|
+
onEndTimeChange(newTime);
|
|
313
|
+
}
|
|
314
|
+
setTimeout(function () {
|
|
315
|
+
var _a, _b;
|
|
316
|
+
(_a = focusTargetRef === null || focusTargetRef === void 0 ? void 0 : focusTargetRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
317
|
+
(_b = focusTargetRef === null || focusTargetRef === void 0 ? void 0 : focusTargetRef.current) === null || _b === void 0 ? void 0 : _b.setSelectionRange(2, 2);
|
|
318
|
+
}, 0);
|
|
319
|
+
};
|
|
320
|
+
var getAccessibilityProps = function (timeType, field, value) {
|
|
321
|
+
var max = field === 'hours' ? 23 : 59;
|
|
322
|
+
var fieldLabel = field === 'hours' ? 'Hours' : field === 'minutes' ? 'Minutes' : 'Seconds';
|
|
323
|
+
var typeLabel = isRangeSelection ? (timeType === 'start' ? 'Start time' : 'End time') : 'Time';
|
|
324
|
+
return {
|
|
325
|
+
'aria-label': "".concat(typeLabel, " ").concat(fieldLabel.toLowerCase()),
|
|
326
|
+
'aria-describedby': 'time-input-help',
|
|
327
|
+
role: 'spinbutton',
|
|
328
|
+
'aria-valuemin': 0,
|
|
329
|
+
'aria-valuemax': max,
|
|
330
|
+
'aria-valuenow': parseInt(value, 10) || 0,
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
return (React.createElement(TimeInputContainer, { ref: ref },
|
|
334
|
+
React.createElement(TimeInputLabel, null, "Time:"),
|
|
335
|
+
React.createElement(TimeInput, { size: "small", value: startTime.hours, onChange: function (e) { return handleTimeChange(e.target.value, 'start', 'hours', 23); }, inputRef: hoursRef, placeholder: "HH", InputProps: {
|
|
336
|
+
onKeyDown: function (e) { return handleTimeKeyDown(e, startTime.hours, 'start', 'hours', 23, minutesRef, null); },
|
|
337
|
+
}, inputProps: __assign({ onPaste: function (e) { return handleTimePaste(e, 'start'); } }, getAccessibilityProps('start', 'hours', startTime.hours)) }),
|
|
338
|
+
React.createElement("span", null, ":"),
|
|
339
|
+
React.createElement(TimeInput, { size: "small", value: startTime.minutes, onChange: function (e) { return handleTimeChange(e.target.value, 'start', 'minutes', 59); }, inputRef: minutesRef, placeholder: "MM", InputProps: {
|
|
340
|
+
onKeyDown: function (e) { return handleTimeKeyDown(e, startTime.minutes, 'start', 'minutes', 59, secondsRef, hoursRef); },
|
|
341
|
+
}, inputProps: __assign({ onPaste: function (e) { return handleTimePaste(e, 'start'); } }, getAccessibilityProps('start', 'minutes', startTime.minutes)) }),
|
|
342
|
+
React.createElement("span", null, ":"),
|
|
343
|
+
React.createElement(TimeInput, { size: "small", value: startTime.seconds, onChange: function (e) { return handleTimeChange(e.target.value, 'start', 'seconds', 59); }, inputRef: secondsRef, placeholder: "SS", InputProps: {
|
|
344
|
+
onKeyDown: function (e) {
|
|
345
|
+
return handleTimeKeyDown(e, startTime.seconds, 'start', 'seconds', 59, isRangeSelection ? endHoursRef : null, minutesRef);
|
|
346
|
+
},
|
|
347
|
+
}, inputProps: __assign({ onPaste: function (e) { return handleTimePaste(e, 'start'); } }, getAccessibilityProps('start', 'seconds', startTime.seconds)) }),
|
|
348
|
+
isRangeSelection && endTime && onEndTimeChange && (React.createElement(EndTimeInputContainer, null,
|
|
349
|
+
React.createElement(TimeInputLabel, null, "End Time:"),
|
|
350
|
+
React.createElement(TimeInput, { size: "small", value: endTime.hours, onChange: function (e) { return handleTimeChange(e.target.value, 'end', 'hours', 23); }, inputRef: endHoursRef, placeholder: "HH", InputProps: {
|
|
351
|
+
onKeyDown: function (e) { return handleTimeKeyDown(e, endTime.hours, 'end', 'hours', 23, endMinutesRef, secondsRef); },
|
|
352
|
+
}, inputProps: __assign({ onPaste: function (e) { return handleTimePaste(e, 'end'); } }, getAccessibilityProps('end', 'hours', endTime.hours)) }),
|
|
353
|
+
React.createElement("span", null, ":"),
|
|
354
|
+
React.createElement(TimeInput, { size: "small", value: endTime.minutes, onChange: function (e) { return handleTimeChange(e.target.value, 'end', 'minutes', 59); }, inputRef: endMinutesRef, placeholder: "MM", InputProps: {
|
|
355
|
+
onKeyDown: function (e) { return handleTimeKeyDown(e, endTime.minutes, 'end', 'minutes', 59, endSecondsRef, endHoursRef); },
|
|
356
|
+
}, inputProps: __assign({ onPaste: function (e) { return handleTimePaste(e, 'end'); } }, getAccessibilityProps('end', 'minutes', endTime.minutes)) }),
|
|
357
|
+
React.createElement("span", null, ":"),
|
|
358
|
+
React.createElement(TimeInput, { size: "small", value: endTime.seconds, onChange: function (e) { return handleTimeChange(e.target.value, 'end', 'seconds', 59); }, inputRef: endSecondsRef, placeholder: "SS", InputProps: {
|
|
359
|
+
onKeyDown: function (e) { return handleTimeKeyDown(e, endTime.seconds, 'end', 'seconds', 59, null, endMinutesRef); },
|
|
360
|
+
}, inputProps: __assign({ onPaste: function (e) { return handleTimePaste(e, 'end'); } }, getAccessibilityProps('end', 'seconds', endTime.seconds)) })))));
|
|
361
|
+
});
|
|
362
|
+
exports.DatePickerTimeInput.displayName = 'DatePickerTimeInput';
|
|
@@ -10,6 +10,8 @@ export interface IDatePickerBaseProps {
|
|
|
10
10
|
onChange?: (value: string) => void;
|
|
11
11
|
dateFormat?: string;
|
|
12
12
|
timeFormat?: string;
|
|
13
|
+
minDate?: string | number | Date;
|
|
14
|
+
maxDate?: string | number | Date;
|
|
13
15
|
placeholder?: string;
|
|
14
16
|
disabled?: boolean;
|
|
15
17
|
fullWidth?: boolean;
|
|
@@ -35,6 +37,8 @@ export interface IDatePickerPopoverProps {
|
|
|
35
37
|
value?: string;
|
|
36
38
|
dateFormat?: string;
|
|
37
39
|
timeFormat?: string;
|
|
40
|
+
minDate?: string | number | Date;
|
|
41
|
+
maxDate?: string | number | Date;
|
|
38
42
|
PopoverProps?: Partial<IPopoverProps>;
|
|
39
43
|
showTwoMonths?: boolean;
|
|
40
44
|
isRangeSelection?: boolean;
|
|
@@ -81,7 +81,7 @@ var Root = (0, styled_1.styled)('div', { name: date_picker_classes_1.datePickerC
|
|
|
81
81
|
width: '100%',
|
|
82
82
|
});
|
|
83
83
|
exports.DatePicker = React.forwardRef(function (props, ref) {
|
|
84
|
-
var value = props.value, onChange = props.onChange, _a = props.dateFormat, dateFormat = _a === void 0 ? 'MM/dd/yyyy' : _a, _b = props.timeFormat, timeFormat = _b === void 0 ? 'HH:mm:ss' : _b, _c = props.placeholder, placeholder = _c === void 0 ? dateFormat + (props.showTimeInput ? ' ' + timeFormat : '') : _c, _d = props.disabled, disabled = _d === void 0 ? false : _d, _e = props.fullWidth, fullWidth = _e === void 0 ? false : _e, _f = props.size, size = _f === void 0 ? 'medium' : _f, _g = props.readOnly, readOnly = _g === void 0 ? false : _g, _h = props.required, required = _h === void 0 ? false : _h, _j = props.error, error = _j === void 0 ? false : _j, helperText = props.helperText, options = props.options, _k = props.isRangeSelection, isRangeSelection = _k === void 0 ? false : _k, _l = props.showTwoMonths, showTwoMonths = _l === void 0 ? false : _l, _m = props.showTimeInput, showTimeInput = _m === void 0 ? false : _m, _o = props.allowTimestampPasting, allowTimestampPasting = _o === void 0 ? false : _o, _p = props.timestampUnit, timestampUnit = _p === void 0 ? 'ms' : _p, _q = props.TextFieldProps, TextFieldProps = _q === void 0 ? {} : _q, propClasses = props.classes, externalState = props.state, rootProps = __rest(props, ["value", "onChange", "dateFormat", "timeFormat", "placeholder", "disabled", "fullWidth", "size", "readOnly", "required", "error", "helperText", "options", "isRangeSelection", "showTwoMonths", "showTimeInput", "allowTimestampPasting", "timestampUnit", "TextFieldProps", "classes", "state"]);
|
|
84
|
+
var value = props.value, onChange = props.onChange, _a = props.dateFormat, dateFormat = _a === void 0 ? 'MM/dd/yyyy' : _a, _b = props.timeFormat, timeFormat = _b === void 0 ? 'HH:mm:ss' : _b, minDate = props.minDate, maxDate = props.maxDate, _c = props.placeholder, placeholder = _c === void 0 ? dateFormat + (props.showTimeInput ? ' ' + timeFormat : '') : _c, _d = props.disabled, disabled = _d === void 0 ? false : _d, _e = props.fullWidth, fullWidth = _e === void 0 ? false : _e, _f = props.size, size = _f === void 0 ? 'medium' : _f, _g = props.readOnly, readOnly = _g === void 0 ? false : _g, _h = props.required, required = _h === void 0 ? false : _h, _j = props.error, error = _j === void 0 ? false : _j, helperText = props.helperText, options = props.options, _k = props.isRangeSelection, isRangeSelection = _k === void 0 ? false : _k, _l = props.showTwoMonths, showTwoMonths = _l === void 0 ? false : _l, _m = props.showTimeInput, showTimeInput = _m === void 0 ? false : _m, _o = props.allowTimestampPasting, allowTimestampPasting = _o === void 0 ? false : _o, _p = props.timestampUnit, timestampUnit = _p === void 0 ? 'ms' : _p, _q = props.TextFieldProps, TextFieldProps = _q === void 0 ? {} : _q, propClasses = props.classes, externalState = props.state, rootProps = __rest(props, ["value", "onChange", "dateFormat", "timeFormat", "minDate", "maxDate", "placeholder", "disabled", "fullWidth", "size", "readOnly", "required", "error", "helperText", "options", "isRangeSelection", "showTwoMonths", "showTimeInput", "allowTimestampPasting", "timestampUnit", "TextFieldProps", "classes", "state"]);
|
|
85
85
|
var classes = (0, classes_1.useMergedClasses)(date_picker_classes_1.datePickerClasses, date_picker_classes_1.getDatePickerUtilityClass, propClasses);
|
|
86
86
|
var internalState = (0, date_picker_state_1.useDatePickerState)();
|
|
87
87
|
var _r = externalState || internalState, triggerProps = _r.triggerProps, popoverProps = _r.popoverProps;
|
|
@@ -147,6 +147,8 @@ exports.DatePicker = React.forwardRef(function (props, ref) {
|
|
|
147
147
|
return (React.createElement(date_picker_context_1.DatePickerContext.Provider, { value: {
|
|
148
148
|
dateFormat: dateFormat,
|
|
149
149
|
timeFormat: timeFormat,
|
|
150
|
+
minDate: minDate,
|
|
151
|
+
maxDate: maxDate,
|
|
150
152
|
onSelectDate: handleDateSelect,
|
|
151
153
|
isRangeSelection: isRangeSelection,
|
|
152
154
|
showTimeInput: showTimeInput,
|
|
@@ -160,5 +162,5 @@ exports.DatePicker = React.forwardRef(function (props, ref) {
|
|
|
160
162
|
TextFieldProps.onClick(e);
|
|
161
163
|
}
|
|
162
164
|
} }, TextFieldProps)),
|
|
163
|
-
React.createElement(date_picker_popover_1.DatePickerPopover, __assign({}, popoverProps, { onDateSelect: handleDateSelect, options: options, value: displayValue, dateFormat: dateFormat, timeFormat: timeFormat, showTwoMonths: showTwoMonths, isRangeSelection: isRangeSelection, showTimeInput: showTimeInput })))));
|
|
165
|
+
React.createElement(date_picker_popover_1.DatePickerPopover, __assign({}, popoverProps, { onDateSelect: handleDateSelect, options: options, minDate: minDate, maxDate: maxDate, value: displayValue, dateFormat: dateFormat, timeFormat: timeFormat, showTwoMonths: showTwoMonths, isRangeSelection: isRangeSelection, showTimeInput: showTimeInput })))));
|
|
164
166
|
});
|
|
@@ -14,5 +14,6 @@ export interface IDropdownMenuListItemProps extends Omit<IMenuItemProps, 'title'
|
|
|
14
14
|
target?: string;
|
|
15
15
|
rel?: string;
|
|
16
16
|
classes?: Partial<DropdownMenuListItemClasses>;
|
|
17
|
+
analyticsId?: string;
|
|
17
18
|
}
|
|
18
19
|
export declare const DropdownMenuListItem: React.ForwardRefExoticComponent<Omit<IDropdownMenuListItemProps, "ref"> & React.RefAttributes<HTMLElement>>;
|
|
@@ -159,7 +159,7 @@ var SelectedIcon = (0, styled_1.styled)('div', { name: dropdown_menu_list_item_c
|
|
|
159
159
|
});
|
|
160
160
|
});
|
|
161
161
|
exports.DropdownMenuListItem = React.forwardRef(function (props, ref) {
|
|
162
|
-
var _a = props.component, component = _a === void 0 ? 'button' : _a, title = props.title, children = props.children, description = props.description, startIcon = props.startIcon, endIcon = props.endIcon, className = props.className, selected = props.selected, color = props.color, disabled = props.disabled, propClasses = props.classes, rootProps = __rest(props, ["component", "title", "children", "description", "startIcon", "endIcon", "className", "selected", "color", "disabled", "classes"]);
|
|
162
|
+
var _a = props.component, component = _a === void 0 ? 'button' : _a, title = props.title, children = props.children, description = props.description, startIcon = props.startIcon, endIcon = props.endIcon, className = props.className, selected = props.selected, color = props.color, disabled = props.disabled, propClasses = props.classes, analyticsId = props.analyticsId, rootProps = __rest(props, ["component", "title", "children", "description", "startIcon", "endIcon", "className", "selected", "color", "disabled", "classes", "analyticsId"]);
|
|
163
163
|
var classes = (0, classes_1.useMergedClasses)(dropdown_menu_list_item_classes_1.dropdownMenuListItemClasses, dropdown_menu_list_item_classes_1.getDropdownMenuListItemUtilityClass, propClasses);
|
|
164
164
|
var _b = (0, dropdown_menu_context_1.useDropdownMenuContext)(), size = _b.size, onSelectItem = _b.onSelectItem;
|
|
165
165
|
var isDetailed = !!description;
|
|
@@ -192,7 +192,7 @@ exports.DropdownMenuListItem = React.forwardRef(function (props, ref) {
|
|
|
192
192
|
color: color,
|
|
193
193
|
disabled: disabled,
|
|
194
194
|
};
|
|
195
|
-
return (React.createElement(Root, __assign({ selected: selected, onClick: handleItemClick, ownerState: ownerState, className: (0, clsx_1.default)(classes.root, isDetailed && classes.detailed, className), component: ComponentProp, disabled: disabled, ref: ref, title: typeof titleContent === 'string' ? titleContent : undefined }, rootProps, buttonProps),
|
|
195
|
+
return (React.createElement(Root, __assign({ selected: selected, onClick: handleItemClick, ownerState: ownerState, className: (0, clsx_1.default)(classes.root, isDetailed && classes.detailed, className), component: ComponentProp, disabled: disabled, ref: ref, title: typeof titleContent === 'string' ? titleContent : undefined }, rootProps, buttonProps, (analyticsId && { 'data-analytics-id': analyticsId })),
|
|
196
196
|
!!startIcon && React.createElement(StartIcon, { className: (0, clsx_1.default)(classes.icon, classes.startIcon) }, startIcon),
|
|
197
197
|
React.createElement(Content, { className: classes.content },
|
|
198
198
|
React.createElement(Title, { ownerState: { isDetailed: isDetailed }, className: classes.title }, titleContent),
|
|
@@ -2,6 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
export var DatePickerContext = React.createContext({
|
|
3
3
|
dateFormat: 'MM/dd/yyyy',
|
|
4
4
|
timeFormat: 'HH:mm:ss',
|
|
5
|
+
minDate: undefined,
|
|
6
|
+
maxDate: undefined,
|
|
5
7
|
onSelectDate: function () { return undefined; },
|
|
6
8
|
isRangeSelection: false,
|
|
7
9
|
showTimeInput: false,
|