@superdispatch/dates 0.16.0-alpha.0 → 0.16.0-alpha.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/dist-node/index.js +41 -1757
- package/dist-node/index.js.map +1 -1
- package/dist-src/base-date-picker/BaseDatePicker.js +2 -2
- package/dist-src/calendar/Calendar.js +4 -4
- package/dist-src/calendar/CalendarQuickSelection.js +1 -1
- package/dist-src/calendar/InternalCalendarComponents.js +2 -2
- package/dist-src/date-range-field/DateRangeField.js +1 -1
- package/dist-src/index.js +1 -3
- package/dist-src/time-field/TimeField.js +1 -2
- package/dist-types/index.d.ts +1 -448
- package/dist-web/index.js +2 -1715
- package/dist-web/index.js.map +1 -1
- package/package.json +2 -2
- package/dist-src/v5/base-date-picker/BaseDatePicker.js +0 -123
- package/dist-src/v5/calendar/Calendar.js +0 -403
- package/dist-src/v5/calendar/CalendarQuickSelection.js +0 -34
- package/dist-src/v5/calendar/InternalCalendarComponents.js +0 -71
- package/dist-src/v5/date-config/DateConfig.js +0 -47
- package/dist-src/v5/date-field/DateField.js +0 -96
- package/dist-src/v5/date-range-field/DateRangeField.js +0 -204
- package/dist-src/v5/date-time-utils/DateTimeUtils.js +0 -238
- package/dist-src/v5/date-utils/DateUtils.js +0 -274
- package/dist-src/v5/formatted-date/FormattedDate.js +0 -35
- package/dist-src/v5/formatted-relative-time/FormattedRelativeTime.js +0 -44
- package/dist-src/v5/index.js +0 -12
- package/dist-src/v5/time-field/TimeField.js +0 -148
- package/dist-src/v5/use-date-time/useDateTime.js +0 -19
- package/dist-src/v5/use-date-time-range/useDateTimeRange.js +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdispatch/dates",
|
|
3
|
-
"version": "0.16.0-alpha.
|
|
3
|
+
"version": "0.16.0-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist-*/",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "https://github.com/superdispatch/ui.git"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@superdispatch/ui": "^0.16.0-alpha.
|
|
16
|
+
"@superdispatch/ui": "^0.16.0-alpha.1",
|
|
17
17
|
"luxon": "^1.27.0",
|
|
18
18
|
"react-day-picker": "7.4.10"
|
|
19
19
|
},
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["id", "api", "onClear", "onClick", "onClose", "onKeyDown", "disabled", "children", "enableClearable", "inputRef", "InputProps"];
|
|
4
|
-
import { mdiCalendarMonth } from '@mdi/js';
|
|
5
|
-
import { Clear } from '@mui/icons-material';
|
|
6
|
-
import { IconButton, InputAdornment, Popover, SvgIcon, TextField } from '@mui/material';
|
|
7
|
-
import { useValueObserver } from '@superdispatch/hooks';
|
|
8
|
-
import { v5 } from '@superdispatch/ui';
|
|
9
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
var {
|
|
14
|
-
mergeRefs,
|
|
15
|
-
useUID
|
|
16
|
-
} = v5;
|
|
17
|
-
export var BaseDatePicker = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
18
|
-
var {
|
|
19
|
-
id,
|
|
20
|
-
api,
|
|
21
|
-
onClear,
|
|
22
|
-
onClick: _onClick,
|
|
23
|
-
onClose,
|
|
24
|
-
onKeyDown: _onKeyDown,
|
|
25
|
-
disabled,
|
|
26
|
-
children,
|
|
27
|
-
enableClearable,
|
|
28
|
-
inputRef: inputRefProp,
|
|
29
|
-
InputProps: inputProps
|
|
30
|
-
} = _ref,
|
|
31
|
-
textFieldProps = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
-
|
|
33
|
-
var uid = useUID(id);
|
|
34
|
-
var labelID = "".concat(uid, "-label");
|
|
35
|
-
var clearIconID = "".concat(uid, "-clear-icon");
|
|
36
|
-
var inputRef = useRef(null);
|
|
37
|
-
var textFieldRef = useRef(null);
|
|
38
|
-
var [popoverAnchor, setPopoverAnchor] = useState(null);
|
|
39
|
-
|
|
40
|
-
function handleOpen() {
|
|
41
|
-
if (!disabled && textFieldRef.current) {
|
|
42
|
-
setPopoverAnchor(textFieldRef.current);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function handleClose() {
|
|
47
|
-
setPopoverAnchor(null);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
useImperativeHandle(api, () => ({
|
|
51
|
-
close: handleClose
|
|
52
|
-
})); // We want to trigger close event only when UI will be ready after updates.
|
|
53
|
-
|
|
54
|
-
useValueObserver(popoverAnchor, () => {
|
|
55
|
-
if (!popoverAnchor) {
|
|
56
|
-
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
60
|
-
children: [/*#__PURE__*/_jsx(Popover, {
|
|
61
|
-
open: !!popoverAnchor,
|
|
62
|
-
onClose: handleClose,
|
|
63
|
-
anchorEl: popoverAnchor,
|
|
64
|
-
anchorOrigin: {
|
|
65
|
-
vertical: 'bottom',
|
|
66
|
-
horizontal: 'left'
|
|
67
|
-
},
|
|
68
|
-
transformOrigin: {
|
|
69
|
-
vertical: 'top',
|
|
70
|
-
horizontal: 'left'
|
|
71
|
-
},
|
|
72
|
-
children: children
|
|
73
|
-
}), /*#__PURE__*/_jsx(TextField, _objectSpread(_objectSpread({}, textFieldProps), {}, {
|
|
74
|
-
id: uid,
|
|
75
|
-
ref: mergeRefs(ref, textFieldRef),
|
|
76
|
-
disabled: disabled,
|
|
77
|
-
inputRef: mergeRefs(inputRef, inputRefProp),
|
|
78
|
-
onClick: event => {
|
|
79
|
-
_onClick === null || _onClick === void 0 ? void 0 : _onClick(event);
|
|
80
|
-
|
|
81
|
-
if (!event.defaultPrevented) {
|
|
82
|
-
handleOpen();
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
onKeyDown: event => {
|
|
86
|
-
_onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(event);
|
|
87
|
-
|
|
88
|
-
if (!event.defaultPrevented && (event.key === ' ' || event.key === 'Enter')) {
|
|
89
|
-
handleOpen();
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
inputProps: {
|
|
93
|
-
readOnly: true
|
|
94
|
-
},
|
|
95
|
-
InputProps: _objectSpread(_objectSpread({}, inputProps), {}, {
|
|
96
|
-
endAdornment: /*#__PURE__*/_jsx(InputAdornment, {
|
|
97
|
-
position: "end",
|
|
98
|
-
children: enableClearable ? /*#__PURE__*/_jsx(IconButton, {
|
|
99
|
-
disabled: disabled,
|
|
100
|
-
"aria-labelledby": "".concat(clearIconID, " ").concat(labelID),
|
|
101
|
-
onClick: event => {
|
|
102
|
-
// Do not bubble up clicks.
|
|
103
|
-
event.stopPropagation();
|
|
104
|
-
onClear === null || onClear === void 0 ? void 0 : onClear();
|
|
105
|
-
},
|
|
106
|
-
children: /*#__PURE__*/_jsx(Clear, {
|
|
107
|
-
id: clearIconID,
|
|
108
|
-
"aria-label": "clear"
|
|
109
|
-
})
|
|
110
|
-
}) : /*#__PURE__*/_jsx(IconButton, {
|
|
111
|
-
disabled: disabled,
|
|
112
|
-
children: /*#__PURE__*/_jsx(SvgIcon, {
|
|
113
|
-
children: /*#__PURE__*/_jsx("path", {
|
|
114
|
-
d: mdiCalendarMonth
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
})
|
|
118
|
-
})
|
|
119
|
-
})
|
|
120
|
-
}))]
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
if (process.env.NODE_ENV !== "production") BaseDatePicker.displayName = "BaseDatePicker";
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["footer", "classes", "direction", "quickSelection", "selectedDays", "disabledDays", "onDayClick", "onDayKeyDown", "onDayMouseEnter", "onDayMouseLeave", "onDayMouseDown", "onDayMouseUp", "onDayTouchEnd", "onDayTouchStart", "modifiers", "highlightedDays", "format", "initialTime", "initialMonth"];
|
|
4
|
-
import { Divider, Grid, Hidden } from '@mui/material';
|
|
5
|
-
import { makeStyles } from '@mui/styles';
|
|
6
|
-
import { Color } from '@superdispatch/ui';
|
|
7
|
-
import { DateTime } from 'luxon';
|
|
8
|
-
import { forwardRef, useMemo } from 'react';
|
|
9
|
-
import DayPicker from 'react-day-picker';
|
|
10
|
-
import { useDateConfig } from "../date-config/DateConfig.js";
|
|
11
|
-
import { stringifyDate } from "../date-time-utils/DateTimeUtils.js";
|
|
12
|
-
import { useDateTime } from "../use-date-time/useDateTime.js";
|
|
13
|
-
import { CalendarCaption, CalendarNavbar, CalendarWeekDay } from "./InternalCalendarComponents.js"; //
|
|
14
|
-
// Styles
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
-
var useStyles = /*#__PURE__*/makeStyles(theme => ({
|
|
21
|
-
container: {
|
|
22
|
-
display: 'inline-block'
|
|
23
|
-
},
|
|
24
|
-
wrapper: {
|
|
25
|
-
userSelect: 'none',
|
|
26
|
-
position: 'relative',
|
|
27
|
-
flexDirection: 'row',
|
|
28
|
-
paddingBottom: theme.spacing(2),
|
|
29
|
-
'&:focus': {
|
|
30
|
-
outline: 'none'
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
interactionDisabled: {},
|
|
34
|
-
navBar: {},
|
|
35
|
-
navButtonPrev: {
|
|
36
|
-
position: 'absolute !important',
|
|
37
|
-
top: theme.spacing(1.5),
|
|
38
|
-
left: theme.spacing(1.5)
|
|
39
|
-
},
|
|
40
|
-
navButtonNext: {
|
|
41
|
-
position: 'absolute !important',
|
|
42
|
-
top: theme.spacing(1.5),
|
|
43
|
-
right: theme.spacing(1.5)
|
|
44
|
-
},
|
|
45
|
-
navButtonInteractionDisabled: {},
|
|
46
|
-
months: {
|
|
47
|
-
display: 'flex',
|
|
48
|
-
flexWrap: 'wrap',
|
|
49
|
-
justifyContent: 'center'
|
|
50
|
-
},
|
|
51
|
-
month: {
|
|
52
|
-
userSelect: 'none',
|
|
53
|
-
margin: theme.spacing(2, 2, 0, 2)
|
|
54
|
-
},
|
|
55
|
-
caption: {
|
|
56
|
-
textAlign: 'center',
|
|
57
|
-
display: 'table-caption',
|
|
58
|
-
marginBottom: theme.spacing(1),
|
|
59
|
-
padding: theme.spacing(0, 1)
|
|
60
|
-
},
|
|
61
|
-
weekdays: {
|
|
62
|
-
display: 'table-header-group'
|
|
63
|
-
},
|
|
64
|
-
weekdaysRow: {
|
|
65
|
-
display: 'flex',
|
|
66
|
-
margin: theme.spacing(1, 0)
|
|
67
|
-
},
|
|
68
|
-
weekday: {
|
|
69
|
-
margin: '1px',
|
|
70
|
-
display: 'flex',
|
|
71
|
-
alignItems: 'center',
|
|
72
|
-
justifyContent: 'center',
|
|
73
|
-
textDecoration: 'none',
|
|
74
|
-
color: Color.Dark300,
|
|
75
|
-
width: theme.spacing(5),
|
|
76
|
-
height: theme.spacing(5)
|
|
77
|
-
},
|
|
78
|
-
weekNumber: {},
|
|
79
|
-
body: {
|
|
80
|
-
display: 'flex',
|
|
81
|
-
flexDirection: 'column'
|
|
82
|
-
},
|
|
83
|
-
week: {
|
|
84
|
-
display: 'flex'
|
|
85
|
-
},
|
|
86
|
-
// Day modifiers.
|
|
87
|
-
today: {},
|
|
88
|
-
outside: {},
|
|
89
|
-
selected: {},
|
|
90
|
-
disabled: {},
|
|
91
|
-
firstDayOfMonth: {},
|
|
92
|
-
lastDayOfMonth: {},
|
|
93
|
-
blue: {},
|
|
94
|
-
green: {},
|
|
95
|
-
purple: {},
|
|
96
|
-
red: {},
|
|
97
|
-
teal: {},
|
|
98
|
-
yellow: {},
|
|
99
|
-
day: {
|
|
100
|
-
zIndex: 1,
|
|
101
|
-
margin: '1px',
|
|
102
|
-
width: theme.spacing(5),
|
|
103
|
-
height: theme.spacing(5),
|
|
104
|
-
borderRadius: theme.spacing(0.5),
|
|
105
|
-
position: 'relative',
|
|
106
|
-
display: 'flex',
|
|
107
|
-
alignItems: 'center',
|
|
108
|
-
justifyContent: 'center',
|
|
109
|
-
transition: theme.transitions.create(['color', 'background-color']),
|
|
110
|
-
'&:before': {
|
|
111
|
-
content: '""',
|
|
112
|
-
top: 0,
|
|
113
|
-
left: -1,
|
|
114
|
-
right: -1,
|
|
115
|
-
bottom: 0,
|
|
116
|
-
zIndex: -1,
|
|
117
|
-
position: 'absolute',
|
|
118
|
-
backgroundColor: Color.Transparent,
|
|
119
|
-
transition: theme.transitions.create('background-color')
|
|
120
|
-
},
|
|
121
|
-
'&:first-child, &$firstDayOfMonth': {
|
|
122
|
-
'&:before': {
|
|
123
|
-
borderRadius: theme.spacing(0.5, 0, 0, 0.5)
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
'&:last-child, &$lastDayOfMonth': {
|
|
127
|
-
'&:before': {
|
|
128
|
-
borderRadius: theme.spacing(0, 0.5, 0.5, 0)
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
'&:after': {
|
|
132
|
-
content: '""',
|
|
133
|
-
borderRadius: theme.spacing(0.5),
|
|
134
|
-
top: 0,
|
|
135
|
-
left: 0,
|
|
136
|
-
right: 0,
|
|
137
|
-
bottom: 0,
|
|
138
|
-
zIndex: -1,
|
|
139
|
-
position: 'absolute',
|
|
140
|
-
backgroundColor: Color.Transparent,
|
|
141
|
-
transition: theme.transitions.create('background-color')
|
|
142
|
-
},
|
|
143
|
-
'&:hover, &:focus': {
|
|
144
|
-
outline: 'none'
|
|
145
|
-
},
|
|
146
|
-
'&$disabled': {
|
|
147
|
-
color: Color.Dark100,
|
|
148
|
-
'&$selected:not($outside):after': {
|
|
149
|
-
backgroundColor: Color.Silver300
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
'&:not($outside):not($disabled)': {
|
|
153
|
-
cursor: 'pointer',
|
|
154
|
-
color: Color.Dark500,
|
|
155
|
-
'&:not($selected):not(:active)': {
|
|
156
|
-
'&$today': {
|
|
157
|
-
color: Color.Blue300
|
|
158
|
-
},
|
|
159
|
-
'&:hover, &:focus': {
|
|
160
|
-
backgroundColor: Color.Silver100
|
|
161
|
-
},
|
|
162
|
-
'&$blue': {
|
|
163
|
-
color: Color.Blue500,
|
|
164
|
-
'&': {
|
|
165
|
-
backgroundColor: Color.Blue50
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
'&$green': {
|
|
169
|
-
color: Color.Green500,
|
|
170
|
-
'&': {
|
|
171
|
-
backgroundColor: Color.Green50
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
'&$purple': {
|
|
175
|
-
color: Color.Purple500,
|
|
176
|
-
'&': {
|
|
177
|
-
backgroundColor: Color.Purple50
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
'&$red': {
|
|
181
|
-
color: Color.Red500,
|
|
182
|
-
'&': {
|
|
183
|
-
backgroundColor: Color.Red50
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
'&$teal': {
|
|
187
|
-
color: Color.Teal500,
|
|
188
|
-
'&': {
|
|
189
|
-
backgroundColor: Color.Teal50
|
|
190
|
-
}
|
|
191
|
-
},
|
|
192
|
-
'&$yellow': {
|
|
193
|
-
color: Color.Yellow500,
|
|
194
|
-
'&': {
|
|
195
|
-
backgroundColor: Color.Yellow50
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
'&:active, &$selected': {
|
|
200
|
-
color: Color.White,
|
|
201
|
-
'&:after': {
|
|
202
|
-
backgroundColor: Color.Blue300
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
footer: {
|
|
208
|
-
padding: theme.spacing(2)
|
|
209
|
-
},
|
|
210
|
-
todayButton: {}
|
|
211
|
-
}), {
|
|
212
|
-
name: 'SD-Calendar'
|
|
213
|
-
}); //
|
|
214
|
-
// Utility Types
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
//
|
|
218
|
-
// Internal Utils
|
|
219
|
-
//
|
|
220
|
-
function toDayPickerModifier(config, modifier) {
|
|
221
|
-
if (!modifier) {
|
|
222
|
-
return undefined;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return localDate => {
|
|
226
|
-
var dateValue = DateTime.fromObject({
|
|
227
|
-
year: localDate.getFullYear(),
|
|
228
|
-
month: localDate.getMonth() + 1,
|
|
229
|
-
day: localDate.getDate(),
|
|
230
|
-
hour: localDate.getHours(),
|
|
231
|
-
minute: localDate.getMinutes(),
|
|
232
|
-
second: localDate.getSeconds(),
|
|
233
|
-
millisecond: localDate.getMilliseconds()
|
|
234
|
-
});
|
|
235
|
-
return modifier({
|
|
236
|
-
config,
|
|
237
|
-
dateValue,
|
|
238
|
-
stringValue: stringifyDate(dateValue, config)
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
function toDayPickerHandler(config, classes, initialTime, handler) {
|
|
244
|
-
if (!handler) {
|
|
245
|
-
return undefined;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
return (localDate, modifiers) => {
|
|
249
|
-
var dateValue = DateTime.fromObject({
|
|
250
|
-
year: localDate.getFullYear(),
|
|
251
|
-
month: localDate.getMonth() + 1,
|
|
252
|
-
day: localDate.getDate(),
|
|
253
|
-
hour: initialTime.hour,
|
|
254
|
-
minute: initialTime.minute,
|
|
255
|
-
second: initialTime.second,
|
|
256
|
-
millisecond: initialTime.millisecond
|
|
257
|
-
});
|
|
258
|
-
handler({
|
|
259
|
-
disabled: !!modifiers[classes.disabled],
|
|
260
|
-
selected: !!modifiers[classes.selected],
|
|
261
|
-
config,
|
|
262
|
-
dateValue,
|
|
263
|
-
stringValue: stringifyDate(dateValue, config)
|
|
264
|
-
});
|
|
265
|
-
};
|
|
266
|
-
} //
|
|
267
|
-
// Calendar
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
export var Calendar = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
272
|
-
var {
|
|
273
|
-
footer,
|
|
274
|
-
classes,
|
|
275
|
-
direction,
|
|
276
|
-
quickSelection,
|
|
277
|
-
selectedDays,
|
|
278
|
-
disabledDays,
|
|
279
|
-
onDayClick,
|
|
280
|
-
onDayKeyDown,
|
|
281
|
-
onDayMouseEnter,
|
|
282
|
-
onDayMouseLeave,
|
|
283
|
-
onDayMouseDown,
|
|
284
|
-
onDayMouseUp,
|
|
285
|
-
onDayTouchEnd,
|
|
286
|
-
onDayTouchStart,
|
|
287
|
-
modifiers,
|
|
288
|
-
highlightedDays,
|
|
289
|
-
format: formatProp,
|
|
290
|
-
initialTime: initialTimeInputProp,
|
|
291
|
-
initialMonth: initialMonthInputProp
|
|
292
|
-
} = _ref,
|
|
293
|
-
dayPickerProps = _objectWithoutProperties(_ref, _excluded);
|
|
294
|
-
|
|
295
|
-
var styles = useStyles({
|
|
296
|
-
classes
|
|
297
|
-
});
|
|
298
|
-
var config = useDateConfig({
|
|
299
|
-
format: formatProp
|
|
300
|
-
});
|
|
301
|
-
var initialTimeInput = useDateTime(initialTimeInputProp, config);
|
|
302
|
-
var initialMonthInput = useDateTime(initialMonthInputProp, config);
|
|
303
|
-
var [initialTime, initialMonth] = useMemo(() => {
|
|
304
|
-
var time = initialTimeInput;
|
|
305
|
-
var month = initialMonthInput;
|
|
306
|
-
|
|
307
|
-
if (!month.isValid) {
|
|
308
|
-
month = DateTime.local().startOf('month');
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
if (!time.isValid) {
|
|
312
|
-
time = month;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return [time, new Date(month.year, month.month - 1, month.day, month.hour, month.minute, month.second, month.millisecond)];
|
|
316
|
-
}, [initialTimeInput, initialMonthInput]);
|
|
317
|
-
var wrapModifier = toDayPickerModifier.bind(null, config);
|
|
318
|
-
var wrapHandler = toDayPickerHandler.bind(null, config, styles, initialTime);
|
|
319
|
-
var dayPickerModifiers = {
|
|
320
|
-
[styles.firstDayOfMonth]: wrapModifier(_ref2 => {
|
|
321
|
-
var {
|
|
322
|
-
dateValue
|
|
323
|
-
} = _ref2;
|
|
324
|
-
return dateValue.day === 1;
|
|
325
|
-
}),
|
|
326
|
-
[styles.lastDayOfMonth]: wrapModifier(_ref3 => {
|
|
327
|
-
var {
|
|
328
|
-
dateValue
|
|
329
|
-
} = _ref3;
|
|
330
|
-
return dateValue.day === dateValue.daysInMonth;
|
|
331
|
-
})
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
if (modifiers) {
|
|
335
|
-
for (var [key, modifier] of Object.entries(modifiers)) {
|
|
336
|
-
dayPickerModifiers[key] = wrapModifier(modifier);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
if (highlightedDays) {
|
|
341
|
-
for (var [_key, _modifier] of Object.entries(highlightedDays)) {
|
|
342
|
-
dayPickerModifiers[styles[_key]] = wrapModifier(_modifier);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return /*#__PURE__*/_jsxs(Grid, {
|
|
347
|
-
ref: ref,
|
|
348
|
-
container: true,
|
|
349
|
-
direction: direction,
|
|
350
|
-
children: [!!quickSelection && /*#__PURE__*/_jsxs(_Fragment, {
|
|
351
|
-
children: [/*#__PURE__*/_jsx(Grid, {
|
|
352
|
-
item: true,
|
|
353
|
-
xs: 12,
|
|
354
|
-
sm: "auto",
|
|
355
|
-
children: quickSelection
|
|
356
|
-
}), /*#__PURE__*/_jsx(Hidden, {
|
|
357
|
-
xsDown: true,
|
|
358
|
-
children: /*#__PURE__*/_jsx(Grid, {
|
|
359
|
-
item: true,
|
|
360
|
-
sm: "auto",
|
|
361
|
-
children: /*#__PURE__*/_jsx(Divider, {
|
|
362
|
-
orientation: "vertical"
|
|
363
|
-
})
|
|
364
|
-
})
|
|
365
|
-
}), /*#__PURE__*/_jsx(Hidden, {
|
|
366
|
-
smUp: true,
|
|
367
|
-
children: /*#__PURE__*/_jsx(Grid, {
|
|
368
|
-
item: true,
|
|
369
|
-
xs: 12,
|
|
370
|
-
children: /*#__PURE__*/_jsx(Divider, {
|
|
371
|
-
orientation: "horizontal"
|
|
372
|
-
})
|
|
373
|
-
})
|
|
374
|
-
})]
|
|
375
|
-
}), /*#__PURE__*/_jsxs(Grid, {
|
|
376
|
-
item: true,
|
|
377
|
-
xs: 12,
|
|
378
|
-
sm: "auto",
|
|
379
|
-
children: [/*#__PURE__*/_jsx(DayPicker, _objectSpread(_objectSpread({}, dayPickerProps), {}, {
|
|
380
|
-
classNames: styles,
|
|
381
|
-
navbarElement: CalendarNavbar,
|
|
382
|
-
captionElement: CalendarCaption,
|
|
383
|
-
weekdayElement: CalendarWeekDay,
|
|
384
|
-
initialMonth: initialMonth,
|
|
385
|
-
modifiers: dayPickerModifiers,
|
|
386
|
-
selectedDays: wrapModifier(selectedDays),
|
|
387
|
-
disabledDays: wrapModifier(disabledDays),
|
|
388
|
-
onDayClick: wrapHandler(onDayClick),
|
|
389
|
-
onDayKeyDown: wrapHandler(onDayKeyDown),
|
|
390
|
-
onDayMouseEnter: wrapHandler(onDayMouseEnter),
|
|
391
|
-
onDayMouseLeave: wrapHandler(onDayMouseLeave),
|
|
392
|
-
onDayMouseDown: wrapHandler(onDayMouseDown),
|
|
393
|
-
onDayMouseUp: wrapHandler(onDayMouseUp),
|
|
394
|
-
onDayTouchEnd: wrapHandler(onDayTouchEnd),
|
|
395
|
-
onDayTouchStart: wrapHandler(onDayTouchStart)
|
|
396
|
-
})), !!footer && /*#__PURE__*/_jsx("div", {
|
|
397
|
-
className: styles.footer,
|
|
398
|
-
children: footer
|
|
399
|
-
})]
|
|
400
|
-
})]
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
if (process.env.NODE_ENV !== "production") Calendar.displayName = "Calendar";
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { List, ListItem, Typography } from '@mui/material';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
export var CalendarQuickSelectionItem = /*#__PURE__*/forwardRef((_ref, ref) => {
|
|
6
|
-
var {
|
|
7
|
-
onClick,
|
|
8
|
-
selected,
|
|
9
|
-
children
|
|
10
|
-
} = _ref;
|
|
11
|
-
return /*#__PURE__*/_jsx(ListItem, {
|
|
12
|
-
ref: ref,
|
|
13
|
-
button: true,
|
|
14
|
-
selected: selected,
|
|
15
|
-
onClick: onClick,
|
|
16
|
-
children: children
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
if (process.env.NODE_ENV !== "production") CalendarQuickSelectionItem.displayName = "CalendarQuickSelectionItem";
|
|
20
|
-
export var CalendarQuickSelection = /*#__PURE__*/forwardRef((_ref2, ref) => {
|
|
21
|
-
var {
|
|
22
|
-
children
|
|
23
|
-
} = _ref2;
|
|
24
|
-
return /*#__PURE__*/_jsxs(List, {
|
|
25
|
-
ref: ref,
|
|
26
|
-
children: [/*#__PURE__*/_jsx(ListItem, {
|
|
27
|
-
children: /*#__PURE__*/_jsx(Typography, {
|
|
28
|
-
variant: "h4",
|
|
29
|
-
children: "Quick Selection"
|
|
30
|
-
})
|
|
31
|
-
}), children]
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
if (process.env.NODE_ENV !== "production") CalendarQuickSelection.displayName = "CalendarQuickSelection";
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ChevronLeft, ChevronRight } from '@mui/icons-material';
|
|
2
|
-
import { IconButton, Typography } from '@mui/material';
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
-
export function CalendarCaption(_ref) {
|
|
7
|
-
var {
|
|
8
|
-
date,
|
|
9
|
-
localeUtils,
|
|
10
|
-
classNames,
|
|
11
|
-
onClick
|
|
12
|
-
} = _ref;
|
|
13
|
-
return /*#__PURE__*/_jsx(Typography, {
|
|
14
|
-
variant: "h4",
|
|
15
|
-
onClick: onClick,
|
|
16
|
-
className: classNames.caption,
|
|
17
|
-
children: localeUtils.formatMonthTitle(date)
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
export function CalendarNavbar(_ref2) {
|
|
21
|
-
var {
|
|
22
|
-
labels,
|
|
23
|
-
classNames,
|
|
24
|
-
onNextClick,
|
|
25
|
-
onPreviousClick,
|
|
26
|
-
showNextButton,
|
|
27
|
-
showPreviousButton
|
|
28
|
-
} = _ref2;
|
|
29
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
30
|
-
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
31
|
-
size: "small",
|
|
32
|
-
color: "primary",
|
|
33
|
-
disabled: !showPreviousButton,
|
|
34
|
-
onClick: () => {
|
|
35
|
-
onPreviousClick();
|
|
36
|
-
},
|
|
37
|
-
"aria-label": labels.previousMonth,
|
|
38
|
-
className: classNames.navButtonPrev,
|
|
39
|
-
children: /*#__PURE__*/_jsx(ChevronLeft, {
|
|
40
|
-
color: "action"
|
|
41
|
-
})
|
|
42
|
-
}), /*#__PURE__*/_jsx(IconButton, {
|
|
43
|
-
size: "small",
|
|
44
|
-
color: "primary",
|
|
45
|
-
disabled: !showNextButton,
|
|
46
|
-
onClick: () => {
|
|
47
|
-
onNextClick();
|
|
48
|
-
},
|
|
49
|
-
"aria-label": labels.nextMonth,
|
|
50
|
-
className: classNames.navButtonNext,
|
|
51
|
-
children: /*#__PURE__*/_jsx(ChevronRight, {
|
|
52
|
-
color: "action"
|
|
53
|
-
})
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
var SHORT_WEEKDAYS = ['S', 'M', 'T', 'W', 'T', 'F', 'S'];
|
|
58
|
-
export function CalendarWeekDay(_ref3) {
|
|
59
|
-
var {
|
|
60
|
-
weekday,
|
|
61
|
-
className,
|
|
62
|
-
localeUtils
|
|
63
|
-
} = _ref3;
|
|
64
|
-
return /*#__PURE__*/_jsx(Typography, {
|
|
65
|
-
variant: "h5",
|
|
66
|
-
component: "abbr",
|
|
67
|
-
className: className,
|
|
68
|
-
title: localeUtils.formatWeekdayLong(weekday),
|
|
69
|
-
children: SHORT_WEEKDAYS[weekday]
|
|
70
|
-
});
|
|
71
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { FixedOffsetZone, Settings } from 'luxon';
|
|
2
|
-
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
export function setDefaultTimeZone(offset) {
|
|
5
|
-
if (offset === 'local') {
|
|
6
|
-
Settings.defaultZoneName = offset;
|
|
7
|
-
} else {
|
|
8
|
-
var zone = FixedOffsetZone.instance(offset);
|
|
9
|
-
|
|
10
|
-
if (zone.isValid) {
|
|
11
|
-
Settings.defaultZoneName = zone.name;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return Settings.defaultZoneName;
|
|
16
|
-
}
|
|
17
|
-
export function useDefaultTimeZone(offset) {
|
|
18
|
-
return useMemo(() => setDefaultTimeZone(offset), [offset]);
|
|
19
|
-
}
|
|
20
|
-
export var defaultDateConfig = {
|
|
21
|
-
format: 'DateTimeISO'
|
|
22
|
-
};
|
|
23
|
-
var Context = /*#__PURE__*/createContext(defaultDateConfig);
|
|
24
|
-
export function useDateConfig() {
|
|
25
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
|
-
var config = useContext(Context);
|
|
27
|
-
var {
|
|
28
|
-
format = config.format
|
|
29
|
-
} = options;
|
|
30
|
-
return useMemo(() => ({
|
|
31
|
-
format
|
|
32
|
-
}), [format]);
|
|
33
|
-
}
|
|
34
|
-
export function DateConfigProvider(_ref) {
|
|
35
|
-
var {
|
|
36
|
-
format,
|
|
37
|
-
children
|
|
38
|
-
} = _ref;
|
|
39
|
-
var prev = useDateConfig();
|
|
40
|
-
var ctx = useMemo(() => ({
|
|
41
|
-
format: format || prev.format
|
|
42
|
-
}), [format, prev.format]);
|
|
43
|
-
return /*#__PURE__*/_jsx(Context.Provider, {
|
|
44
|
-
value: ctx,
|
|
45
|
-
children: children
|
|
46
|
-
});
|
|
47
|
-
}
|