@elliemae/ds-date-picker 3.27.0-next.1 → 3.27.0-next.12
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/cjs/index.js +3 -5
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +2 -2
- package/dist/types/index.d.ts +2 -3
- package/package.json +6 -79
- package/dist/cjs/DSDatePicker.js +0 -240
- package/dist/cjs/DSDatePicker.js.map +0 -7
- package/dist/cjs/components/DSDatePickerImpl.js +0 -293
- package/dist/cjs/components/DSDatePickerImpl.js.map +0 -7
- package/dist/cjs/components/DatePickerController/DatePickerController.js +0 -338
- package/dist/cjs/components/DatePickerController/DatePickerController.js.map +0 -7
- package/dist/cjs/components/DatePickerDay/DatePickerDay.js +0 -44
- package/dist/cjs/components/DatePickerDay/DatePickerDay.js.map +0 -7
- package/dist/cjs/components/DatePickerDropdown.js +0 -90
- package/dist/cjs/components/DatePickerDropdown.js.map +0 -7
- package/dist/cjs/components/DatePickerHeader/DatePickerHeader.js +0 -79
- package/dist/cjs/components/DatePickerHeader/DatePickerHeader.js.map +0 -7
- package/dist/cjs/components/DatePickerNavigation/DatePickerNavigation.js +0 -56
- package/dist/cjs/components/DatePickerNavigation/DatePickerNavigation.js.map +0 -7
- package/dist/cjs/components/DatePickerPicker/DatePickerPicker.js +0 -89
- package/dist/cjs/components/DatePickerPicker/DatePickerPicker.js.map +0 -7
- package/dist/cjs/components/DatePickerRange/DatePickerRange.js +0 -110
- package/dist/cjs/components/DatePickerRange/DatePickerRange.js.map +0 -7
- package/dist/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js +0 -149
- package/dist/cjs/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -7
- package/dist/cjs/components/DatePickerRenderMonth/DatePickerRenderMonth.js +0 -61
- package/dist/cjs/components/DatePickerRenderMonth/DatePickerRenderMonth.js.map +0 -7
- package/dist/cjs/components/DatePickerSingleDate/DatePickerSingleDate.js +0 -96
- package/dist/cjs/components/DatePickerSingleDate/DatePickerSingleDate.js.map +0 -7
- package/dist/cjs/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js +0 -91
- package/dist/cjs/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js.map +0 -7
- package/dist/cjs/components/index.js +0 -54
- package/dist/cjs/components/index.js.map +0 -7
- package/dist/cjs/defaultPhrases.js +0 -247
- package/dist/cjs/defaultPhrases.js.map +0 -7
- package/dist/esm/DSDatePicker.js +0 -221
- package/dist/esm/DSDatePicker.js.map +0 -7
- package/dist/esm/components/DSDatePickerImpl.js +0 -263
- package/dist/esm/components/DSDatePickerImpl.js.map +0 -7
- package/dist/esm/components/DatePickerController/DatePickerController.js +0 -308
- package/dist/esm/components/DatePickerController/DatePickerController.js.map +0 -7
- package/dist/esm/components/DatePickerDay/DatePickerDay.js +0 -14
- package/dist/esm/components/DatePickerDay/DatePickerDay.js.map +0 -7
- package/dist/esm/components/DatePickerDropdown.js +0 -60
- package/dist/esm/components/DatePickerDropdown.js.map +0 -7
- package/dist/esm/components/DatePickerHeader/DatePickerHeader.js +0 -49
- package/dist/esm/components/DatePickerHeader/DatePickerHeader.js.map +0 -7
- package/dist/esm/components/DatePickerNavigation/DatePickerNavigation.js +0 -26
- package/dist/esm/components/DatePickerNavigation/DatePickerNavigation.js.map +0 -7
- package/dist/esm/components/DatePickerPicker/DatePickerPicker.js +0 -59
- package/dist/esm/components/DatePickerPicker/DatePickerPicker.js.map +0 -7
- package/dist/esm/components/DatePickerRange/DatePickerRange.js +0 -80
- package/dist/esm/components/DatePickerRange/DatePickerRange.js.map +0 -7
- package/dist/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js +0 -119
- package/dist/esm/components/DatePickerRangeHeader/DatePickerRangeHeader.js.map +0 -7
- package/dist/esm/components/DatePickerRenderMonth/DatePickerRenderMonth.js +0 -31
- package/dist/esm/components/DatePickerRenderMonth/DatePickerRenderMonth.js.map +0 -7
- package/dist/esm/components/DatePickerSingleDate/DatePickerSingleDate.js +0 -66
- package/dist/esm/components/DatePickerSingleDate/DatePickerSingleDate.js.map +0 -7
- package/dist/esm/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js +0 -61
- package/dist/esm/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.js.map +0 -7
- package/dist/esm/components/index.js +0 -24
- package/dist/esm/components/index.js.map +0 -7
- package/dist/esm/defaultPhrases.js +0 -217
- package/dist/esm/defaultPhrases.js.map +0 -7
- package/dist/types/components/DSDatePickerImpl.d.ts +0 -21
- package/dist/types/components/DatePickerController/DatePickerController.d.ts +0 -80
- package/dist/types/components/DatePickerDay/DatePickerDay.d.ts +0 -13
- package/dist/types/components/DatePickerDropdown.d.ts +0 -27
- package/dist/types/components/DatePickerHeader/DatePickerHeader.d.ts +0 -15
- package/dist/types/components/DatePickerNavigation/DatePickerNavigation.d.ts +0 -19
- package/dist/types/components/DatePickerPicker/DatePickerPicker.d.ts +0 -43
- package/dist/types/components/DatePickerRange/DatePickerRange.d.ts +0 -9
- package/dist/types/components/DatePickerRangeHeader/DatePickerRangeHeader.d.ts +0 -23
- package/dist/types/components/DatePickerRangeHeader/tests/DatePickerRangeHeader.test.d.ts +0 -1
- package/dist/types/components/DatePickerRenderMonth/DatePickerRenderMonth.d.ts +0 -4
- package/dist/types/components/DatePickerSingleDate/DatePickerSingleDate.d.ts +0 -11
- package/dist/types/components/SingleRangeDateSwitcher/SingleRangeDateSwitcher.d.ts +0 -16
- package/dist/types/components/index.d.ts +0 -10
- package/dist/types/components/tests/DatePickerHeader.test.d.ts +0 -1
- package/dist/types/components/tests/DatePickerRange.test.d.ts +0 -1
- package/dist/types/components/tests/DatePickerRangeHeader.test.d.ts +0 -1
- package/dist/types/components/tests/DatePickerSelectedDate.test.d.ts +0 -1
- package/dist/types/components/tests/DatePickerSingleDate.test.d.ts +0 -1
- package/dist/types/components/tests/SingleRangeDateSwitcher.test.d.ts +0 -1
- package/dist/types/defaultPhrases.d.ts +0 -225
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DSDatePickerImpl_exports = {};
|
|
30
|
-
__export(DSDatePickerImpl_exports, {
|
|
31
|
-
DSDatePickerImpl: () => DSDatePickerImpl,
|
|
32
|
-
default: () => DSDatePickerImpl
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(DSDatePickerImpl_exports);
|
|
35
|
-
var React = __toESM(require("react"));
|
|
36
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_moment = __toESM(require("moment"));
|
|
39
|
-
var import_ds_form = require("@elliemae/ds-form");
|
|
40
|
-
var import_DatePickerController = require("./DatePickerController/DatePickerController.js");
|
|
41
|
-
var import_DatePickerDropdown = require("./DatePickerDropdown.js");
|
|
42
|
-
const FORMAT = "MMDDYYYY";
|
|
43
|
-
class DSDatePickerImpl extends import_react.default.Component {
|
|
44
|
-
constructor(props) {
|
|
45
|
-
super(props);
|
|
46
|
-
this.onClickPicker = () => {
|
|
47
|
-
this.setState({ inputFocused: true });
|
|
48
|
-
};
|
|
49
|
-
this.getSafeValue = () => {
|
|
50
|
-
const { value, date, defaultValue } = this.props;
|
|
51
|
-
const { selectedDate } = this.state;
|
|
52
|
-
if (value) {
|
|
53
|
-
return (0, import_moment.default)(value, FORMAT, true);
|
|
54
|
-
}
|
|
55
|
-
if (date) {
|
|
56
|
-
return (0, import_moment.default)(date, FORMAT, true);
|
|
57
|
-
}
|
|
58
|
-
if (defaultValue) {
|
|
59
|
-
return (0, import_moment.default)(defaultValue, FORMAT, true);
|
|
60
|
-
}
|
|
61
|
-
if (selectedDate) {
|
|
62
|
-
return selectedDate;
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
};
|
|
66
|
-
this.getSafeInputValue = () => {
|
|
67
|
-
const safeValue = this.getSafeValue();
|
|
68
|
-
if (safeValue && safeValue.isValid()) {
|
|
69
|
-
return safeValue.format(FORMAT);
|
|
70
|
-
}
|
|
71
|
-
const { dataInput } = this.state;
|
|
72
|
-
return dataInput;
|
|
73
|
-
};
|
|
74
|
-
this.isControlled = () => {
|
|
75
|
-
const { value, date } = this.props;
|
|
76
|
-
return Boolean(value) || Boolean(date);
|
|
77
|
-
};
|
|
78
|
-
this.handleDateChange = (date, event) => {
|
|
79
|
-
const { readOnly, onDateChange, keepOpenOnDateSelect, onChange, onBlur } = this.props;
|
|
80
|
-
if (!readOnly) {
|
|
81
|
-
if (!this.isControlled()) {
|
|
82
|
-
this.setState({ dataInput: date.format(FORMAT), selectedDate: date });
|
|
83
|
-
}
|
|
84
|
-
onChange(date.format(FORMAT), date);
|
|
85
|
-
onDateChange(date);
|
|
86
|
-
if (!keepOpenOnDateSelect || event.key === "Enter") {
|
|
87
|
-
this.setState({ inputFocused: false });
|
|
88
|
-
onBlur(date.format(FORMAT), date);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
this.handleInputChange = (dataInput, newDate) => {
|
|
93
|
-
const { onChange } = this.props;
|
|
94
|
-
const newState = {
|
|
95
|
-
dataInput,
|
|
96
|
-
selectedDate: newDate
|
|
97
|
-
};
|
|
98
|
-
this.setState(() => newState);
|
|
99
|
-
onChange(dataInput, newDate);
|
|
100
|
-
};
|
|
101
|
-
this.handleChange = (newDate) => {
|
|
102
|
-
if (!newDate)
|
|
103
|
-
return;
|
|
104
|
-
const { onDateChange } = this.props;
|
|
105
|
-
const momentValue = (0, import_moment.default)(newDate, FORMAT, true);
|
|
106
|
-
if (!momentValue.isValid())
|
|
107
|
-
return;
|
|
108
|
-
this.setState({ selectedDate: momentValue });
|
|
109
|
-
onDateChange(momentValue);
|
|
110
|
-
};
|
|
111
|
-
this.handleFocus = ({ focused }) => {
|
|
112
|
-
this.setState({ inputFocused: focused });
|
|
113
|
-
};
|
|
114
|
-
this.handleCalendarClose = () => {
|
|
115
|
-
const { onClose } = this.props;
|
|
116
|
-
this.setState({ inputFocused: false });
|
|
117
|
-
this.handleOnBlur();
|
|
118
|
-
onClose();
|
|
119
|
-
};
|
|
120
|
-
this.handleClickEscape = () => {
|
|
121
|
-
const { onClose } = this.props;
|
|
122
|
-
this.setState({ inputFocused: false });
|
|
123
|
-
this.handleOnBlur();
|
|
124
|
-
onClose();
|
|
125
|
-
};
|
|
126
|
-
this.handleOnBlur = () => {
|
|
127
|
-
setTimeout(() => {
|
|
128
|
-
const { onBlur, autoClear } = this.props;
|
|
129
|
-
const { dataInput, selectedDate } = this.state;
|
|
130
|
-
if ((0, import_moment.default)(selectedDate, FORMAT, true).isValid()) {
|
|
131
|
-
onBlur(dataInput, selectedDate);
|
|
132
|
-
} else {
|
|
133
|
-
if (autoClear) {
|
|
134
|
-
this.setState({ dataInput: void 0 });
|
|
135
|
-
}
|
|
136
|
-
onBlur(dataInput, null);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
};
|
|
140
|
-
this.handleInputFocus = (dataInput) => {
|
|
141
|
-
const { onFocus } = this.props;
|
|
142
|
-
onFocus(dataInput);
|
|
143
|
-
};
|
|
144
|
-
this.state = {
|
|
145
|
-
pickerRef: import_react.default.createRef(),
|
|
146
|
-
dataInput: "",
|
|
147
|
-
selectedDate: null,
|
|
148
|
-
inputFocused: false
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
static getDerivedStateFromProps(nextProps, prevState) {
|
|
152
|
-
const { dataInput: prevVal, selectedDate: prevDate } = prevState || {};
|
|
153
|
-
const { value: nextVal, date: nextDate } = nextProps;
|
|
154
|
-
const isPrevValMoment = prevVal instanceof import_moment.default;
|
|
155
|
-
const isPrevDateMoment = prevDate instanceof import_moment.default;
|
|
156
|
-
const prevValAsString = isPrevValMoment ? prevVal.format(FORMAT) : prevVal;
|
|
157
|
-
if (nextVal == null && nextDate == null) {
|
|
158
|
-
return {
|
|
159
|
-
dataInput: "",
|
|
160
|
-
selectedDate: null
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
if (prevValAsString?.length < 8) {
|
|
164
|
-
return null;
|
|
165
|
-
}
|
|
166
|
-
const prevDateAsString = isPrevDateMoment ? prevDate.format(FORMAT) : prevDate;
|
|
167
|
-
const isNextValMoment = nextVal instanceof import_moment.default;
|
|
168
|
-
const isNextDateMoment = nextDate instanceof import_moment.default;
|
|
169
|
-
const nextValAsString = isNextValMoment ? nextVal.format(FORMAT) : nextVal;
|
|
170
|
-
const nextValAsMoment = isNextValMoment ? nextVal : (0, import_moment.default)(nextVal);
|
|
171
|
-
const nextDateAsString = isNextDateMoment ? nextDate.format(FORMAT) : nextDate;
|
|
172
|
-
const nextDateAsMoment = isNextDateMoment ? nextDate : (0, import_moment.default)(nextDate);
|
|
173
|
-
const hasValChanged = nextValAsString !== prevValAsString;
|
|
174
|
-
const hasDateChanged = nextDateAsString !== prevDateAsString;
|
|
175
|
-
const newState = {};
|
|
176
|
-
let skipStateChange = true;
|
|
177
|
-
if (hasDateChanged) {
|
|
178
|
-
skipStateChange = false;
|
|
179
|
-
newState.dataInput = nextDateAsString;
|
|
180
|
-
newState.selectedDate = nextDateAsMoment;
|
|
181
|
-
}
|
|
182
|
-
if (hasValChanged) {
|
|
183
|
-
skipStateChange = false;
|
|
184
|
-
newState.dataInput = nextValAsString;
|
|
185
|
-
newState.selectedDate = nextValAsMoment;
|
|
186
|
-
}
|
|
187
|
-
if (skipStateChange)
|
|
188
|
-
return null;
|
|
189
|
-
return newState;
|
|
190
|
-
}
|
|
191
|
-
render() {
|
|
192
|
-
const { inputFocused } = this.state;
|
|
193
|
-
const {
|
|
194
|
-
disabled,
|
|
195
|
-
numberOfMonths,
|
|
196
|
-
readOnly,
|
|
197
|
-
enableOutsideDays,
|
|
198
|
-
transitionDuration,
|
|
199
|
-
firstDayOfWeek,
|
|
200
|
-
keepOpenOnDateSelect,
|
|
201
|
-
hideKeyboardShortcutsPanel,
|
|
202
|
-
onPrevMonthClick,
|
|
203
|
-
onNextMonthClick,
|
|
204
|
-
onClose,
|
|
205
|
-
phrases,
|
|
206
|
-
placeholder,
|
|
207
|
-
displayFormatDay,
|
|
208
|
-
isDayBlocked,
|
|
209
|
-
isOutsideRange,
|
|
210
|
-
isDayHighlighted,
|
|
211
|
-
tabIndex,
|
|
212
|
-
zIndex,
|
|
213
|
-
pickerProps,
|
|
214
|
-
calendarProps,
|
|
215
|
-
focusCurrentDate
|
|
216
|
-
} = this.props;
|
|
217
|
-
const safedate = this.getSafeValue();
|
|
218
|
-
const safeInputValue = this.getSafeInputValue();
|
|
219
|
-
const hasSelectedDate = !!safedate;
|
|
220
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
221
|
-
import_ds_form.DSInputGroup,
|
|
222
|
-
{
|
|
223
|
-
rightAddon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
224
|
-
import_DatePickerDropdown.DatePickerDropdown,
|
|
225
|
-
{
|
|
226
|
-
pickerRef: this.state.pickerRef,
|
|
227
|
-
disabled,
|
|
228
|
-
isOpen: inputFocused,
|
|
229
|
-
menu: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
230
|
-
"div",
|
|
231
|
-
{
|
|
232
|
-
style: { minHeight: "310px", zIndex: 1 },
|
|
233
|
-
className: hasSelectedDate ? "has-selected-date" : "without-selected-date",
|
|
234
|
-
"data-testid": "date-picker-portal-wrapper",
|
|
235
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
236
|
-
import_DatePickerController.DSDatePickerController,
|
|
237
|
-
{
|
|
238
|
-
date: safedate,
|
|
239
|
-
displayFormatDay,
|
|
240
|
-
enableOutsideDays,
|
|
241
|
-
firstDayOfWeek,
|
|
242
|
-
hideKeyboardShortcutsPanel,
|
|
243
|
-
isDayBlocked,
|
|
244
|
-
isDayHighlighted,
|
|
245
|
-
isOutsideRange,
|
|
246
|
-
keepOpenOnDateSelect,
|
|
247
|
-
numberOfMonths,
|
|
248
|
-
onClickEscape: this.handleClickEscape,
|
|
249
|
-
onClose: (...args) => {
|
|
250
|
-
if (this.state.pickerRef.current)
|
|
251
|
-
this.state.pickerRef.current.focus();
|
|
252
|
-
onClose(...args);
|
|
253
|
-
this.setState({ inputFocused: false });
|
|
254
|
-
},
|
|
255
|
-
onDateChange: this.handleDateChange,
|
|
256
|
-
onFocusChange: this.handleFocus,
|
|
257
|
-
onNextMonthClick,
|
|
258
|
-
onOutsideClick: this.handleCalendarClose,
|
|
259
|
-
onPrevMonthClick,
|
|
260
|
-
phrases,
|
|
261
|
-
transitionDuration,
|
|
262
|
-
calendarProps,
|
|
263
|
-
focusCurrentDate
|
|
264
|
-
}
|
|
265
|
-
)
|
|
266
|
-
}
|
|
267
|
-
),
|
|
268
|
-
onClick: this.onClickPicker,
|
|
269
|
-
readOnly,
|
|
270
|
-
zIndex,
|
|
271
|
-
pickerProps
|
|
272
|
-
}
|
|
273
|
-
),
|
|
274
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
-
import_ds_form.DSDateInputV2,
|
|
276
|
-
{
|
|
277
|
-
"data-testid": "datepicker-input",
|
|
278
|
-
"aria-label": placeholder || "Date Picker Input",
|
|
279
|
-
disabled,
|
|
280
|
-
onBlur: this.handleOnBlur,
|
|
281
|
-
onChange: this.handleInputChange,
|
|
282
|
-
onDateChange: this.handleChange,
|
|
283
|
-
onFocus: this.handleInputFocus,
|
|
284
|
-
placeholder,
|
|
285
|
-
tabIndex,
|
|
286
|
-
value: safeInputValue
|
|
287
|
-
}
|
|
288
|
-
)
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
//# sourceMappingURL=DSDatePickerImpl.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/DSDatePickerImpl.tsx", "../../../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-statements */\n/* eslint-disable complexity */\n/* eslint-disable no-underscore-dangle */\n/* eslint-disable react/state-in-constructor */\n/* eslint-disable no-restricted-globals */\n/* eslint-disable react/prop-types */\n/* eslint-disable max-lines */\nimport React from 'react';\nimport moment from 'moment';\nimport { DSInputGroup, DSDateInputV2 } from '@elliemae/ds-form';\nimport { DSDatePickerController } from './DatePickerController/DatePickerController.js';\nimport { DatePickerDropdown } from './DatePickerDropdown.js';\n\nconst FORMAT = 'MMDDYYYY';\nexport default class DSDatePickerImpl extends React.Component {\n constructor(props) {\n super(props);\n this.state = {\n pickerRef: React.createRef(),\n dataInput: '',\n selectedDate: null,\n inputFocused: false,\n };\n }\n\n static getDerivedStateFromProps(nextProps, prevState) {\n const { dataInput: prevVal, selectedDate: prevDate } = prevState || {};\n const { value: nextVal, date: nextDate } = nextProps;\n\n const isPrevValMoment = prevVal instanceof moment;\n const isPrevDateMoment = prevDate instanceof moment;\n const prevValAsString = isPrevValMoment ? prevVal.format(FORMAT) : prevVal;\n\n // if users wants to clear, we use '==' to catch both undefined AND null\n if (nextVal == null && nextDate == null) {\n return {\n dataInput: '',\n selectedDate: null,\n };\n }\n\n // when val is an incomplete state, we don't want to mess with the state\n // it's incomplete when length is not the full mmddyyyy (length === 8)\n if (prevValAsString?.length < 8) {\n return null;\n }\n\n const prevDateAsString = isPrevDateMoment ? prevDate.format(FORMAT) : prevDate;\n\n const isNextValMoment = nextVal instanceof moment;\n const isNextDateMoment = nextDate instanceof moment;\n const nextValAsString = isNextValMoment ? nextVal.format(FORMAT) : nextVal;\n const nextValAsMoment = isNextValMoment ? nextVal : moment(nextVal);\n const nextDateAsString = isNextDateMoment ? nextDate.format(FORMAT) : nextDate;\n const nextDateAsMoment = isNextDateMoment ? nextDate : moment(nextDate);\n\n const hasValChanged = nextValAsString !== prevValAsString;\n const hasDateChanged = nextDateAsString !== prevDateAsString;\n\n const newState = {};\n let skipStateChange = true;\n\n // value has priority over date, if both date and value change we take date\n // as such, order of condition is meaningful\n if (hasDateChanged) {\n skipStateChange = false;\n newState.dataInput = nextDateAsString;\n newState.selectedDate = nextDateAsMoment;\n }\n\n if (hasValChanged) {\n skipStateChange = false;\n newState.dataInput = nextValAsString;\n newState.selectedDate = nextValAsMoment;\n }\n\n if (skipStateChange) return null;\n return newState;\n }\n\n onClickPicker = () => {\n this.setState({ inputFocused: true });\n };\n\n getSafeValue = () => {\n const { value, date, defaultValue } = this.props;\n const { selectedDate } = this.state;\n if (value) {\n return moment(value, FORMAT, true);\n }\n if (date) {\n return moment(date, FORMAT, true);\n }\n if (defaultValue) {\n return moment(defaultValue, FORMAT, true);\n }\n if (selectedDate) {\n return selectedDate;\n }\n return null;\n };\n\n getSafeInputValue = () => {\n const safeValue = this.getSafeValue();\n if (safeValue && safeValue.isValid()) {\n return safeValue.format(FORMAT);\n }\n const { dataInput } = this.state;\n return dataInput;\n };\n\n isControlled = () => {\n const { value, date } = this.props;\n return Boolean(value) || Boolean(date);\n };\n\n handleDateChange = (date, event) => {\n const { readOnly, onDateChange, keepOpenOnDateSelect, onChange, onBlur } = this.props;\n\n if (!readOnly) {\n if (!this.isControlled()) {\n this.setState({ dataInput: date.format(FORMAT), selectedDate: date });\n }\n onChange(date.format(FORMAT), date);\n onDateChange(date);\n if (!keepOpenOnDateSelect || event.key === 'Enter') {\n this.setState({ inputFocused: false });\n onBlur(date.format(FORMAT), date);\n }\n }\n };\n\n handleInputChange = (dataInput, newDate) => {\n const { onChange } = this.props;\n const newState = {\n dataInput,\n selectedDate: newDate,\n };\n this.setState(() => newState);\n onChange(dataInput, newDate);\n };\n\n handleChange = (newDate) => {\n if (!newDate) return;\n const { onDateChange } = this.props;\n const momentValue = moment(newDate, FORMAT, true);\n if (!momentValue.isValid()) return;\n this.setState({ selectedDate: momentValue });\n\n onDateChange(momentValue);\n };\n\n handleFocus = ({ focused }) => {\n this.setState({ inputFocused: focused });\n };\n\n handleCalendarClose = () => {\n const { onClose } = this.props;\n\n this.setState({ inputFocused: false });\n this.handleOnBlur();\n onClose();\n };\n\n handleClickEscape = () => {\n const { onClose } = this.props;\n\n this.setState({ inputFocused: false });\n this.handleOnBlur();\n onClose();\n };\n\n handleOnBlur = () => {\n setTimeout(() => {\n const { onBlur, autoClear } = this.props;\n const { dataInput, selectedDate } = this.state;\n\n if (moment(selectedDate, FORMAT, true).isValid()) {\n onBlur(dataInput, selectedDate);\n } else {\n if (autoClear) {\n this.setState({ dataInput: undefined });\n }\n onBlur(dataInput, null);\n }\n });\n };\n\n handleInputFocus = (dataInput) => {\n const { onFocus } = this.props;\n onFocus(dataInput);\n };\n\n render() {\n const { inputFocused } = this.state;\n const {\n disabled,\n numberOfMonths,\n readOnly,\n enableOutsideDays,\n transitionDuration,\n firstDayOfWeek,\n keepOpenOnDateSelect,\n hideKeyboardShortcutsPanel,\n onPrevMonthClick,\n onNextMonthClick,\n onClose,\n phrases,\n placeholder,\n displayFormatDay,\n isDayBlocked,\n isOutsideRange,\n isDayHighlighted,\n tabIndex,\n zIndex,\n pickerProps,\n calendarProps,\n focusCurrentDate,\n } = this.props;\n const safedate = this.getSafeValue();\n const safeInputValue = this.getSafeInputValue();\n const hasSelectedDate = !!safedate;\n return (\n <DSInputGroup\n rightAddon={\n <DatePickerDropdown\n pickerRef={this.state.pickerRef}\n disabled={disabled}\n isOpen={inputFocused}\n menu={\n <div\n style={{ minHeight: '310px', zIndex: 1 }}\n className={hasSelectedDate ? 'has-selected-date' : 'without-selected-date'}\n data-testid=\"date-picker-portal-wrapper\"\n >\n <DSDatePickerController\n date={safedate}\n displayFormatDay={displayFormatDay}\n enableOutsideDays={enableOutsideDays}\n firstDayOfWeek={firstDayOfWeek}\n hideKeyboardShortcutsPanel={hideKeyboardShortcutsPanel}\n isDayBlocked={isDayBlocked}\n isDayHighlighted={isDayHighlighted}\n isOutsideRange={isOutsideRange}\n keepOpenOnDateSelect={keepOpenOnDateSelect}\n numberOfMonths={numberOfMonths}\n onClickEscape={this.handleClickEscape}\n onClose={(...args) => {\n if (this.state.pickerRef.current) this.state.pickerRef.current.focus();\n onClose(...args);\n this.setState({ inputFocused: false });\n }}\n onDateChange={this.handleDateChange}\n onFocusChange={this.handleFocus}\n onNextMonthClick={onNextMonthClick}\n onOutsideClick={this.handleCalendarClose}\n onPrevMonthClick={onPrevMonthClick}\n phrases={phrases}\n transitionDuration={transitionDuration}\n calendarProps={calendarProps}\n focusCurrentDate={focusCurrentDate}\n />\n </div>\n }\n onClick={this.onClickPicker}\n readOnly={readOnly}\n zIndex={zIndex}\n pickerProps={pickerProps}\n />\n }\n >\n <DSDateInputV2\n data-testid=\"datepicker-input\"\n aria-label={placeholder || 'Date Picker Input'}\n disabled={disabled}\n onBlur={this.handleOnBlur}\n onChange={this.handleInputChange}\n onDateChange={this.handleChange}\n onFocus={this.handleInputFocus}\n placeholder={placeholder}\n tabIndex={tabIndex}\n value={safeInputValue}\n />\n </DSInputGroup>\n );\n }\n}\n\nexport { DSDatePickerImpl };\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;AD2OP;AApOhB,mBAAkB;AAClB,oBAAmB;AACnB,qBAA4C;AAC5C,kCAAuC;AACvC,gCAAmC;AAEnC,MAAM,SAAS;AACf,MAAO,yBAAuC,aAAAA,QAAM,UAAU;AAAA,EAC5D,YAAY,OAAO;AACjB,UAAM,KAAK;AAgEb,yBAAgB,MAAM;AACpB,WAAK,SAAS,EAAE,cAAc,KAAK,CAAC;AAAA,IACtC;AAEA,wBAAe,MAAM;AACnB,YAAM,EAAE,OAAO,MAAM,aAAa,IAAI,KAAK;AAC3C,YAAM,EAAE,aAAa,IAAI,KAAK;AAC9B,UAAI,OAAO;AACT,mBAAO,cAAAC,SAAO,OAAO,QAAQ,IAAI;AAAA,MACnC;AACA,UAAI,MAAM;AACR,mBAAO,cAAAA,SAAO,MAAM,QAAQ,IAAI;AAAA,MAClC;AACA,UAAI,cAAc;AAChB,mBAAO,cAAAA,SAAO,cAAc,QAAQ,IAAI;AAAA,MAC1C;AACA,UAAI,cAAc;AAChB,eAAO;AAAA,MACT;AACA,aAAO;AAAA,IACT;AAEA,6BAAoB,MAAM;AACxB,YAAM,YAAY,KAAK,aAAa;AACpC,UAAI,aAAa,UAAU,QAA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|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var DatePickerController_exports = {};
|
|
30
|
-
__export(DatePickerController_exports, {
|
|
31
|
-
DSDatePickerController: () => DSDatePickerController,
|
|
32
|
-
default: () => DSDatePickerController
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(DatePickerController_exports);
|
|
35
|
-
var React = __toESM(require("react"));
|
|
36
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
-
var import_react = __toESM(require("react"));
|
|
38
|
-
var import_lodash = require("lodash");
|
|
39
|
-
var import_prop_types = __toESM(require("prop-types"));
|
|
40
|
-
var import_moment = __toESM(require("moment"));
|
|
41
|
-
var import_initialize = require("react-dates/initialize.js");
|
|
42
|
-
var import_react_dates = require("react-dates");
|
|
43
|
-
var import_ds_classnames = require("@elliemae/ds-classnames");
|
|
44
|
-
var import_ds_icons = require("@elliemae/ds-icons");
|
|
45
|
-
var import_defaultPhrases = require("../../defaultPhrases.js");
|
|
46
|
-
var import_DatePickerRenderMonth = require("../DatePickerRenderMonth/DatePickerRenderMonth.js");
|
|
47
|
-
var import_DatePickerNavigation = require("../DatePickerNavigation/DatePickerNavigation.js");
|
|
48
|
-
var import_DatePickerDay = require("../DatePickerDay/DatePickerDay.js");
|
|
49
|
-
const { classNameElement, classNameBlock } = (0, import_ds_classnames.convertPropToCssClassName)("datepicker-range");
|
|
50
|
-
const focusElementOnOpen = (0, import_lodash.debounce)((datePickerDom, firstFocusableItemDom, focusCurrentDate) => {
|
|
51
|
-
if (datePickerDom) {
|
|
52
|
-
const currentDay = Array.from(datePickerDom?.getElementsByClassName("CalendarDay__today")).filter(
|
|
53
|
-
(el) => !el.className.includes("CalendarDay__outside")
|
|
54
|
-
)[0];
|
|
55
|
-
const [calendarDaySelected] = datePickerDom?.getElementsByClassName("CalendarDay__selected");
|
|
56
|
-
if (calendarDaySelected) {
|
|
57
|
-
calendarDaySelected?.focus?.();
|
|
58
|
-
} else if (focusCurrentDate && !calendarDaySelected)
|
|
59
|
-
currentDay.focus();
|
|
60
|
-
else {
|
|
61
|
-
const navButton = firstFocusableItemDom?.closest(".DayPickerNavigation_button>div");
|
|
62
|
-
navButton?.focus?.();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, 100);
|
|
66
|
-
class DSDatePickerController extends import_react.default.Component {
|
|
67
|
-
constructor(props) {
|
|
68
|
-
super(props);
|
|
69
|
-
this.handleMouseUp = () => {
|
|
70
|
-
const focusedElement = document.activeElement;
|
|
71
|
-
focusedElement?.blur?.();
|
|
72
|
-
};
|
|
73
|
-
this.handleKeyDown = (event) => {
|
|
74
|
-
const [firstDay, ...restOfDays] = document.getElementsByClassName("CalendarMonthGrid_month__horizontal")[1].getElementsByClassName("CalendarDay");
|
|
75
|
-
const [lastDay] = restOfDays.slice(-1);
|
|
76
|
-
const { onClickEscape } = this.props;
|
|
77
|
-
switch (event.key) {
|
|
78
|
-
case "Home":
|
|
79
|
-
firstDay.focus();
|
|
80
|
-
break;
|
|
81
|
-
case "End":
|
|
82
|
-
lastDay.focus();
|
|
83
|
-
break;
|
|
84
|
-
case "Escape":
|
|
85
|
-
onClickEscape();
|
|
86
|
-
break;
|
|
87
|
-
default:
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
this.getSafeValue = () => {
|
|
92
|
-
const { value, date, defaultValue } = this.props;
|
|
93
|
-
const { selectedDate } = this.state;
|
|
94
|
-
if (value)
|
|
95
|
-
return (0, import_moment.default)(value);
|
|
96
|
-
if (date)
|
|
97
|
-
return (0, import_moment.default)(date);
|
|
98
|
-
if (defaultValue)
|
|
99
|
-
return (0, import_moment.default)(defaultValue);
|
|
100
|
-
if (selectedDate)
|
|
101
|
-
return (0, import_moment.default)(selectedDate);
|
|
102
|
-
return null;
|
|
103
|
-
};
|
|
104
|
-
this.isControlled = () => {
|
|
105
|
-
const { value, date } = this.props;
|
|
106
|
-
return Boolean(value) || Boolean(date);
|
|
107
|
-
};
|
|
108
|
-
this.handleDateChange = (date) => {
|
|
109
|
-
const { readOnly, onDateChange, onChange } = this.props;
|
|
110
|
-
if (!readOnly) {
|
|
111
|
-
if (!this.isControlled()) {
|
|
112
|
-
this.setState({ selectedDate: date });
|
|
113
|
-
}
|
|
114
|
-
onDateChange(date);
|
|
115
|
-
onChange(date);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
this.handleChange = (dataInput) => {
|
|
119
|
-
const { onDateChange, onChange } = this.props;
|
|
120
|
-
const momentvalue = (0, import_moment.default)(dataInput.target.value);
|
|
121
|
-
this.setState({ selectedDate: momentvalue });
|
|
122
|
-
onDateChange(momentvalue);
|
|
123
|
-
onChange(momentvalue);
|
|
124
|
-
};
|
|
125
|
-
this.handleNavClick = (date, nav) => {
|
|
126
|
-
const [prev, next] = document.getElementsByClassName("DayPickerNavigation_button");
|
|
127
|
-
const { onPrevMonthClick, onNextMonthClick } = this.props;
|
|
128
|
-
if (nav === "prev") {
|
|
129
|
-
prev?.focus?.();
|
|
130
|
-
onPrevMonthClick(date);
|
|
131
|
-
} else {
|
|
132
|
-
next?.focus?.();
|
|
133
|
-
onNextMonthClick(date);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
this.insideBlur = (event) => {
|
|
137
|
-
const { datePicker } = this.state;
|
|
138
|
-
if (!datePicker.current.contains(event.currentTarget)) {
|
|
139
|
-
this.props.onClose();
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
this.state = {
|
|
143
|
-
selectedDate: null,
|
|
144
|
-
firstFocusableItem: import_react.default.createRef(),
|
|
145
|
-
datePicker: import_react.default.createRef()
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
componentDidMount() {
|
|
149
|
-
const { datePicker, firstFocusableItem } = this.state;
|
|
150
|
-
datePicker.current.addEventListener("mouseup", this.handleMouseUp, false);
|
|
151
|
-
document.addEventListener("keydown", this.handleKeyDown, false);
|
|
152
|
-
setTimeout(() => {
|
|
153
|
-
focusElementOnOpen(datePicker?.current, firstFocusableItem?.current, this.props.focusCurrentDate);
|
|
154
|
-
}, 400);
|
|
155
|
-
}
|
|
156
|
-
componentWillUnmount() {
|
|
157
|
-
const { datePicker } = this.state;
|
|
158
|
-
datePicker.current.removeEventListener("mouseup", this.handleMouseUp, false);
|
|
159
|
-
document.removeEventListener("keydown", this.handleKeyDown, false);
|
|
160
|
-
}
|
|
161
|
-
render() {
|
|
162
|
-
const {
|
|
163
|
-
numberOfMonths,
|
|
164
|
-
enableOutsideDays,
|
|
165
|
-
transitionDuration,
|
|
166
|
-
initialVisibleMonth,
|
|
167
|
-
firstDayOfWeek,
|
|
168
|
-
keepOpenOnDateSelect,
|
|
169
|
-
hideKeyboardShortcutsPanel,
|
|
170
|
-
onClose,
|
|
171
|
-
phrases,
|
|
172
|
-
displayFormatDay,
|
|
173
|
-
isDayBlocked,
|
|
174
|
-
isOutsideRange,
|
|
175
|
-
isDayHighlighted,
|
|
176
|
-
onOutsideClick,
|
|
177
|
-
key,
|
|
178
|
-
calendarProps
|
|
179
|
-
} = this.props;
|
|
180
|
-
const { datePicker, firstFocusableItem } = this.state;
|
|
181
|
-
const safedate = this.getSafeValue();
|
|
182
|
-
const safeinitialMonth = safedate && safedate.isValid() ? () => safedate : () => initialVisibleMonth;
|
|
183
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
184
|
-
"div",
|
|
185
|
-
{
|
|
186
|
-
onBlur: this.insideBlur,
|
|
187
|
-
ref: datePicker,
|
|
188
|
-
className: classNameBlock("wrapper-day-picker-single-date-controller"),
|
|
189
|
-
"data-testid": "calendar-wrapper",
|
|
190
|
-
...calendarProps,
|
|
191
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
192
|
-
import_react_dates.DayPickerSingleDateController,
|
|
193
|
-
{
|
|
194
|
-
date: safedate,
|
|
195
|
-
enableOutsideDays,
|
|
196
|
-
firstDayOfWeek,
|
|
197
|
-
focused: true,
|
|
198
|
-
hideKeyboardShortcutsPanel,
|
|
199
|
-
initialVisibleMonth: safeinitialMonth,
|
|
200
|
-
isDayBlocked,
|
|
201
|
-
isDayHighlighted,
|
|
202
|
-
isOutsideRange,
|
|
203
|
-
keepOpenOnDateSelect,
|
|
204
|
-
navNext: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DatePickerNavigation.DatePickerNavigation, { className: classNameElement("navigation-next") }),
|
|
205
|
-
navPrev: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
206
|
-
import_DatePickerNavigation.DatePickerNavigation,
|
|
207
|
-
{
|
|
208
|
-
className: classNameElement("navigation-prev"),
|
|
209
|
-
icon: import_ds_icons.ChevronLeft,
|
|
210
|
-
innerRef: firstFocusableItem
|
|
211
|
-
}
|
|
212
|
-
),
|
|
213
|
-
renderMonthElement: import_DatePickerRenderMonth.renderMonthElement,
|
|
214
|
-
numberOfMonths,
|
|
215
|
-
onClose,
|
|
216
|
-
onDateChange: this.handleDateChange,
|
|
217
|
-
onNextMonthClick: this.handleNavClick("next"),
|
|
218
|
-
onOutsideClick,
|
|
219
|
-
onPrevMonthClick: this.handleNavClick("prev"),
|
|
220
|
-
phrases,
|
|
221
|
-
renderDayContents: (date) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_DatePickerDay.DatePickerDay, { className: classNameElement("day-contents"), date: date.format(displayFormatDay) }),
|
|
222
|
-
transitionDuration,
|
|
223
|
-
onTab: (e) => {
|
|
224
|
-
if (e.target.classList.contains("CalendarDay")) {
|
|
225
|
-
e.preventDefault();
|
|
226
|
-
onClose();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
key
|
|
231
|
-
)
|
|
232
|
-
}
|
|
233
|
-
) });
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
// eslint-disable-next-line react/static-property-placement
|
|
237
|
-
DSDatePickerController.defaultProps = {
|
|
238
|
-
date: "",
|
|
239
|
-
value: "",
|
|
240
|
-
enableOutsideDays: false,
|
|
241
|
-
initialVisibleMonth: (0, import_moment.default)(),
|
|
242
|
-
firstDayOfWeek: 0,
|
|
243
|
-
keepOpenOnDateSelect: true,
|
|
244
|
-
hideKeyboardShortcutsPanel: true,
|
|
245
|
-
onPrevMonthClick: () => null,
|
|
246
|
-
onNextMonthClick: () => null,
|
|
247
|
-
onClose: () => null,
|
|
248
|
-
onChange: () => null,
|
|
249
|
-
onClickEscape: () => null,
|
|
250
|
-
onDateChange: () => null,
|
|
251
|
-
phrases: import_defaultPhrases.SingleDatePickerPhrases,
|
|
252
|
-
// displayFormat: 'L',
|
|
253
|
-
displayFormatDay: "D",
|
|
254
|
-
transitionDuration: 0,
|
|
255
|
-
// verticalSpacing: 0,
|
|
256
|
-
isDayBlocked: () => false,
|
|
257
|
-
isOutsideRange: () => false,
|
|
258
|
-
isDayHighlighted: () => false,
|
|
259
|
-
numberOfMonths: 1
|
|
260
|
-
};
|
|
261
|
-
DSDatePickerController.propTypes = {
|
|
262
|
-
date: import_prop_types.default.instanceOf(Date, import_moment.default),
|
|
263
|
-
value: import_prop_types.default.oneOf([import_prop_types.default.instanceOf(Date), import_prop_types.default.instanceOf(import_moment.default)]),
|
|
264
|
-
enableOutsideDays: import_prop_types.default.bool,
|
|
265
|
-
initialVisibleMonth: import_prop_types.default.instanceOf(Date, import_moment.default),
|
|
266
|
-
firstDayOfWeek: import_prop_types.default.number,
|
|
267
|
-
keepOpenOnDateSelect: import_prop_types.default.bool,
|
|
268
|
-
hideKeyboardShortcutsPanel: import_prop_types.default.bool,
|
|
269
|
-
onPrevMonthClick: import_prop_types.default.func,
|
|
270
|
-
onNextMonthClick: import_prop_types.default.func,
|
|
271
|
-
onClose: import_prop_types.default.func,
|
|
272
|
-
onClickEscape: import_prop_types.default.func,
|
|
273
|
-
onChange: import_prop_types.default.func,
|
|
274
|
-
onDateChange: import_prop_types.default.func,
|
|
275
|
-
phrases: import_defaultPhrases.SingleDatePickerPhrases,
|
|
276
|
-
// displayFormat: PropTypes.string,
|
|
277
|
-
displayFormatDay: import_prop_types.default.string,
|
|
278
|
-
transitionDuration: import_prop_types.default.number,
|
|
279
|
-
// verticalSpacing: PropTypes.number,
|
|
280
|
-
isDayBlocked: import_prop_types.default.func,
|
|
281
|
-
isOutsideRange: import_prop_types.default.func,
|
|
282
|
-
isDayHighlighted: import_prop_types.default.func,
|
|
283
|
-
numberOfMonths: import_prop_types.default.number
|
|
284
|
-
};
|
|
285
|
-
DSDatePickerController.defaultProps = {
|
|
286
|
-
date: "",
|
|
287
|
-
value: "",
|
|
288
|
-
enableOutsideDays: false,
|
|
289
|
-
initialVisibleMonth: (0, import_moment.default)(),
|
|
290
|
-
firstDayOfWeek: 0,
|
|
291
|
-
keepOpenOnDateSelect: true,
|
|
292
|
-
hideKeyboardShortcutsPanel: true,
|
|
293
|
-
onPrevMonthClick: () => null,
|
|
294
|
-
onNextMonthClick: () => null,
|
|
295
|
-
onClose: () => null,
|
|
296
|
-
onClickEscape: () => null,
|
|
297
|
-
onChange: () => null,
|
|
298
|
-
onDateChange: () => null,
|
|
299
|
-
phrases: import_prop_types.default.shape({
|
|
300
|
-
calendarLabel: import_prop_types.default.string,
|
|
301
|
-
closeDatePicker: import_prop_types.default.string,
|
|
302
|
-
clearDates: import_prop_types.default.string,
|
|
303
|
-
focusStartDate: import_prop_types.default.string,
|
|
304
|
-
jumpToPrevMonth: import_prop_types.default.string,
|
|
305
|
-
jumpToNextMonth: import_prop_types.default.string,
|
|
306
|
-
keyboardShortcuts: import_prop_types.default.string,
|
|
307
|
-
showKeyboardShortcutsPanel: import_prop_types.default.string,
|
|
308
|
-
hideKeyboardShortcutsPanel: import_prop_types.default.string,
|
|
309
|
-
openThisPanel: import_prop_types.default.string,
|
|
310
|
-
enterKey: import_prop_types.default.string,
|
|
311
|
-
leftArrowRightArrow: import_prop_types.default.string,
|
|
312
|
-
upArrowDownArrow: import_prop_types.default.string,
|
|
313
|
-
pageUpPageDown: import_prop_types.default.string,
|
|
314
|
-
homeEnd: import_prop_types.default.string,
|
|
315
|
-
escape: import_prop_types.default.string,
|
|
316
|
-
questionMark: import_prop_types.default.string,
|
|
317
|
-
selectFocusedDate: import_prop_types.default.string,
|
|
318
|
-
moveFocusByOneDay: import_prop_types.default.string,
|
|
319
|
-
moveFocusByOneWeek: import_prop_types.default.string,
|
|
320
|
-
moveFocusByOneMonth: import_prop_types.default.string,
|
|
321
|
-
moveFocustoStartAndEndOfWeek: import_prop_types.default.string,
|
|
322
|
-
returnFocusToInput: import_prop_types.default.string,
|
|
323
|
-
keyboardNavigationInstructions: import_prop_types.default.string,
|
|
324
|
-
chooseAvailableStartDate: import_prop_types.default.func,
|
|
325
|
-
chooseAvailableEndDate: import_prop_types.default.func,
|
|
326
|
-
dateIsUnavailable: import_prop_types.default.func,
|
|
327
|
-
dateIsSelected: import_prop_types.default.func
|
|
328
|
-
}),
|
|
329
|
-
// displayFormat: 'L',
|
|
330
|
-
displayFormatDay: "D",
|
|
331
|
-
transitionDuration: 0,
|
|
332
|
-
// verticalSpacing: 0,
|
|
333
|
-
isDayBlocked: () => false,
|
|
334
|
-
isOutsideRange: () => false,
|
|
335
|
-
isDayHighlighted: () => false,
|
|
336
|
-
numberOfMonths: 1
|
|
337
|
-
};
|
|
338
|
-
//# sourceMappingURL=DatePickerController.js.map
|