@instructure/ui-date-input 11.7.3 → 11.7.4-pr-snapshot-1781695314229
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/CHANGELOG.md +12 -0
- package/LICENSE.md +1 -0
- package/{lib/DateInput/v1/styles.js → babel.config.cjs} +12 -28
- package/es/DateInput/v1/index.js +3 -3
- package/es/DateInput/v2/index.js +9 -4
- package/es/exports/a.js +3 -2
- package/es/exports/b.js +3 -2
- package/package.json +18 -23
- package/src/DateInput/v1/index.tsx +3 -2
- package/src/DateInput/v2/index.tsx +7 -6
- package/src/exports/a.ts +2 -2
- package/src/exports/b.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DateInput/v1/index.d.ts +1 -0
- package/types/DateInput/v1/index.d.ts.map +1 -1
- package/types/DateInput/v2/index.d.ts.map +1 -1
- package/types/exports/a.d.ts +2 -2
- package/types/exports/a.d.ts.map +1 -1
- package/types/exports/b.d.ts +2 -2
- package/types/exports/b.d.ts.map +1 -1
- package/lib/DateInput/v1/index.js +0 -426
- package/lib/DateInput/v1/props.js +0 -31
- package/lib/DateInput/v2/index.js +0 -291
- package/lib/DateInput/v2/props.js +0 -5
- package/lib/DateInput2/v1/index.js +0 -290
- package/lib/DateInput2/v1/props.js +0 -5
- package/lib/exports/a.js +0 -19
- package/lib/exports/b.js +0 -19
- package/lib/package.json +0 -1
|
@@ -11,6 +11,7 @@ category: components
|
|
|
11
11
|
---
|
|
12
12
|
**/
|
|
13
13
|
declare class DateInput extends Component<DateInputProps, DateInputState> {
|
|
14
|
+
static displayName: string;
|
|
14
15
|
static readonly componentId = "DateInput";
|
|
15
16
|
static Day: typeof import("@instructure/ui-calendar/v11_6").CalendarDay;
|
|
16
17
|
context: React.ContextType<typeof ApplyLocaleContext>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DateInput/v1/index.tsx"],"names":[],"m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KACnD;IAyDD,WAAW,CAAC,EACV,aAAa,EACb,eAAe,EAChB,EAAE;QACD,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAA;QAChD,eAAe,EAAE,gBAAgB,CAAC,eAAe,CAAC,CAAA;KACnD;IA6DD,kBAAkB,4BAGgB;IAElC,MAAM;CA8CP;AAED,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DateInput/v2/index.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAS3C,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAK7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAiFpE;;;;GAIG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;2BAOE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAAA,CAAA;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/DateInput/v2/index.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AAS3C,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAA;AAK7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAiFpE;;;;GAIG;AACH,QAAA,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;2BAOE,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAAA,CAAA;;;;;;;;;;;;;;;6CA8MhB,CAAA;AAKD,eAAe,SAAS,CAAA;AACxB,OAAO,EAAE,SAAS,EAAE,CAAA"}
|
package/types/exports/a.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DateInput } from '../DateInput/v1';
|
|
2
|
-
export { DateInput2 } from '../DateInput2/v1';
|
|
1
|
+
export { DateInput } from '../DateInput/v1/index.js';
|
|
2
|
+
export { DateInput2 } from '../DateInput2/v1/index.js';
|
|
3
3
|
export type { DateInputProps } from '../DateInput/v1/props';
|
|
4
4
|
export type { DateInput2Props } from '../DateInput2/v1/props';
|
|
5
5
|
//# sourceMappingURL=a.d.ts.map
|
package/types/exports/a.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../src/exports/a.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"a.d.ts","sourceRoot":"","sources":["../../src/exports/a.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA"}
|
package/types/exports/b.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { DateInput } from '../DateInput/v2';
|
|
2
|
-
export { DateInput2 } from '../DateInput2/v1';
|
|
1
|
+
export { DateInput } from '../DateInput/v2/index.js';
|
|
2
|
+
export { DateInput2 } from '../DateInput2/v1/index.js';
|
|
3
3
|
export type { DateInputProps } from '../DateInput/v2/props';
|
|
4
4
|
export type { DateInput2Props } from '../DateInput2/v1/props';
|
|
5
5
|
//# sourceMappingURL=b.d.ts.map
|
package/types/exports/b.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"b.d.ts","sourceRoot":"","sources":["../../src/exports/b.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,YAAY,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA"}
|
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.DateInput = void 0;
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
var _v11_ = require("@instructure/ui-calendar/v11_6");
|
|
10
|
-
var _IconCalendarMonthLine = require("@instructure/ui-icons/lib/generated/IconCalendarMonthLine.js");
|
|
11
|
-
var _v11_2 = require("@instructure/ui-popover/v11_6");
|
|
12
|
-
var _Selectable = require("@instructure/ui-selectable/lib/Selectable");
|
|
13
|
-
var _v11_3 = require("@instructure/ui-text-input/v11_6");
|
|
14
|
-
var _createChainedFunction = require("@instructure/ui-utils/lib/createChainedFunction.js");
|
|
15
|
-
var _getInteraction = require("@instructure/ui-react-utils/lib/getInteraction.js");
|
|
16
|
-
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
17
|
-
var _safeCloneElement = require("@instructure/ui-react-utils/lib/safeCloneElement.js");
|
|
18
|
-
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
19
|
-
var _DateTime = require("@instructure/ui-i18n/lib/DateTime.js");
|
|
20
|
-
var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
|
|
21
|
-
var _emotion = require("@instructure/emotion");
|
|
22
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
23
|
-
var _props = require("./props");
|
|
24
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
25
|
-
var _dec, _class;
|
|
26
|
-
/*
|
|
27
|
-
* The MIT License (MIT)
|
|
28
|
-
*
|
|
29
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
30
|
-
*
|
|
31
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
32
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
33
|
-
* in the Software without restriction, including without limitation the rights
|
|
34
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
35
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
36
|
-
* furnished to do so, subject to the following conditions:
|
|
37
|
-
*
|
|
38
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
39
|
-
* copies or substantial portions of the Software.
|
|
40
|
-
*
|
|
41
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
42
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
43
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
44
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
45
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
46
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
47
|
-
* SOFTWARE.
|
|
48
|
-
*/
|
|
49
|
-
/**
|
|
50
|
-
---
|
|
51
|
-
category: components
|
|
52
|
-
---
|
|
53
|
-
**/
|
|
54
|
-
let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec(_class = class DateInput extends _react.Component {
|
|
55
|
-
static displayName = "DateInput";
|
|
56
|
-
static componentId = 'DateInput';
|
|
57
|
-
static Day = _v11_.Calendar.Day;
|
|
58
|
-
static allowedProps = _props.allowedProps;
|
|
59
|
-
static defaultProps = {
|
|
60
|
-
value: '',
|
|
61
|
-
size: 'medium',
|
|
62
|
-
onBlur: () => {},
|
|
63
|
-
// must have a default so createChainedFunction works
|
|
64
|
-
isRequired: false,
|
|
65
|
-
isInline: false,
|
|
66
|
-
layout: 'stacked',
|
|
67
|
-
display: 'inline-block',
|
|
68
|
-
placement: 'bottom center',
|
|
69
|
-
isShowingCalendar: false
|
|
70
|
-
};
|
|
71
|
-
state = {
|
|
72
|
-
hasInputRef: false,
|
|
73
|
-
isShowingCalendar: false,
|
|
74
|
-
validatedDate: undefined,
|
|
75
|
-
messages: []
|
|
76
|
-
};
|
|
77
|
-
_input = undefined;
|
|
78
|
-
ref = null;
|
|
79
|
-
locale() {
|
|
80
|
-
if (this.props.locale) {
|
|
81
|
-
return this.props.locale;
|
|
82
|
-
} else if (this.context && this.context.locale) {
|
|
83
|
-
return this.context.locale;
|
|
84
|
-
}
|
|
85
|
-
return _Locale.Locale.browserLocale();
|
|
86
|
-
}
|
|
87
|
-
timezone() {
|
|
88
|
-
if (this.props.timezone) {
|
|
89
|
-
return this.props.timezone;
|
|
90
|
-
} else if (this.context && this.context.timezone) {
|
|
91
|
-
return this.context.timezone;
|
|
92
|
-
}
|
|
93
|
-
return _DateTime.DateTime.browserTimeZone();
|
|
94
|
-
}
|
|
95
|
-
componentDidMount() {
|
|
96
|
-
this.props.makeStyles?.();
|
|
97
|
-
}
|
|
98
|
-
componentDidUpdate() {
|
|
99
|
-
this.props.makeStyles?.();
|
|
100
|
-
}
|
|
101
|
-
get selectedDateId() {
|
|
102
|
-
let selectedDateId;
|
|
103
|
-
_react.Children.toArray(this.props.children).forEach(day => {
|
|
104
|
-
const {
|
|
105
|
-
date,
|
|
106
|
-
isSelected
|
|
107
|
-
} = day.props;
|
|
108
|
-
if (isSelected) {
|
|
109
|
-
selectedDateId = this.formatDateId(date);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
return selectedDateId;
|
|
113
|
-
}
|
|
114
|
-
get interaction() {
|
|
115
|
-
return (0, _getInteraction.getInteraction)({
|
|
116
|
-
props: this.props
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
formatDateId = date => {
|
|
120
|
-
// ISO8601 strings may contain a space. Remove any spaces before using the
|
|
121
|
-
// date as the id.
|
|
122
|
-
return date.replace(/\s/g, '');
|
|
123
|
-
};
|
|
124
|
-
handleInputRef = el => {
|
|
125
|
-
// Ensures that we position the Calendar with respect to the input correctly
|
|
126
|
-
// if the Calendar is open on mount
|
|
127
|
-
if (!this.state.hasInputRef) {
|
|
128
|
-
this.setState({
|
|
129
|
-
hasInputRef: true
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
this._input = el;
|
|
133
|
-
this.props.inputRef?.(el);
|
|
134
|
-
};
|
|
135
|
-
handleInputChange = (event, value) => {
|
|
136
|
-
this.props.onChange?.(event, {
|
|
137
|
-
value
|
|
138
|
-
});
|
|
139
|
-
this.handleShowCalendar(event);
|
|
140
|
-
};
|
|
141
|
-
handleShowCalendar = event => {
|
|
142
|
-
if (!this.props.children) {
|
|
143
|
-
this.setState({
|
|
144
|
-
isShowingCalendar: true
|
|
145
|
-
});
|
|
146
|
-
} else if (this.interaction === 'enabled' && this.props.children) {
|
|
147
|
-
this.props.onRequestShowCalendar?.(event);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
validateDate = date => {
|
|
151
|
-
const {
|
|
152
|
-
invalidDateErrorMessage
|
|
153
|
-
} = this.props;
|
|
154
|
-
const disabledDateErrorMessage = this.props.disabledDateErrorMessage || invalidDateErrorMessage;
|
|
155
|
-
const messages = [];
|
|
156
|
-
// check if date is enabled
|
|
157
|
-
const {
|
|
158
|
-
disabledDates
|
|
159
|
-
} = this.props;
|
|
160
|
-
if (typeof disabledDates === 'function' && disabledDates(date) || Array.isArray(disabledDates) && disabledDates.find(dateString => _DateTime.DateTime.parse(dateString, this.locale(), this.timezone()).isSame(_DateTime.DateTime.parse(date, this.locale(), this.timezone()), 'day'))) {
|
|
161
|
-
messages.push(typeof disabledDateErrorMessage === 'function' ? disabledDateErrorMessage(date) : {
|
|
162
|
-
type: 'error',
|
|
163
|
-
text: disabledDateErrorMessage
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// check if date is valid
|
|
168
|
-
if (!_DateTime.DateTime.parse(date, this.locale(), this.timezone(), [_DateTime.DateTime.momentISOFormat, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], true).isValid()) {
|
|
169
|
-
messages.push(typeof invalidDateErrorMessage === 'function' ? invalidDateErrorMessage(date) : {
|
|
170
|
-
type: 'error',
|
|
171
|
-
text: invalidDateErrorMessage
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return messages;
|
|
175
|
-
};
|
|
176
|
-
handleHideCalendar = (event, setectedDate) => {
|
|
177
|
-
if (!this.props.children) {
|
|
178
|
-
const dateString = setectedDate || this.props.value;
|
|
179
|
-
const messages = [];
|
|
180
|
-
if (this.props.onRequestValidateDate) {
|
|
181
|
-
const userValidatedDate = this.props.onRequestValidateDate?.(event, dateString || '', this.validateDate(dateString || ''));
|
|
182
|
-
messages.push(...(userValidatedDate || []));
|
|
183
|
-
} else {
|
|
184
|
-
if (dateString) {
|
|
185
|
-
messages.push(...this.validateDate(dateString));
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
this.setState({
|
|
189
|
-
messages,
|
|
190
|
-
isShowingCalendar: false
|
|
191
|
-
});
|
|
192
|
-
} else {
|
|
193
|
-
this.props.onRequestValidateDate?.(event);
|
|
194
|
-
this.props.onRequestHideCalendar?.(event);
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
handleHighlightOption = (event, {
|
|
198
|
-
direction
|
|
199
|
-
}) => {
|
|
200
|
-
const {
|
|
201
|
-
onRequestSelectNextDay,
|
|
202
|
-
onRequestSelectPrevDay,
|
|
203
|
-
onChange,
|
|
204
|
-
value,
|
|
205
|
-
currentDate
|
|
206
|
-
} = this.props;
|
|
207
|
-
const isValueValid = value && _DateTime.DateTime.parse(value, this.locale(), this.timezone()).isValid();
|
|
208
|
-
if (direction === -1) {
|
|
209
|
-
if (onRequestSelectPrevDay) {
|
|
210
|
-
onRequestSelectPrevDay?.(event);
|
|
211
|
-
} else {
|
|
212
|
-
// @ts-expect-error TODO
|
|
213
|
-
onChange(event, {
|
|
214
|
-
value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('MMMM D, YYYY')
|
|
215
|
-
});
|
|
216
|
-
this.setState({
|
|
217
|
-
messages: []
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (direction === 1) {
|
|
222
|
-
if (onRequestSelectNextDay) {
|
|
223
|
-
onRequestSelectNextDay?.(event);
|
|
224
|
-
} else {
|
|
225
|
-
// @ts-expect-error TODO
|
|
226
|
-
onChange(event, {
|
|
227
|
-
value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('MMMM D, YYYY')
|
|
228
|
-
});
|
|
229
|
-
this.setState({
|
|
230
|
-
messages: []
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
renderMonthNavigationButton(type = 'prev') {
|
|
236
|
-
const {
|
|
237
|
-
renderPrevMonthButton,
|
|
238
|
-
renderNextMonthButton
|
|
239
|
-
} = this.props;
|
|
240
|
-
const button = type === 'prev' ? renderPrevMonthButton : renderNextMonthButton;
|
|
241
|
-
return button && (0, _safeCloneElement.safeCloneElement)((0, _callRenderProp.callRenderProp)(button), {
|
|
242
|
-
tabIndex: -1
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
renderDays(getOptionProps) {
|
|
246
|
-
const children = this.props.children;
|
|
247
|
-
if (!children) return;
|
|
248
|
-
return _react.Children.map(children, day => {
|
|
249
|
-
const {
|
|
250
|
-
date,
|
|
251
|
-
isOutsideMonth
|
|
252
|
-
} = day.props;
|
|
253
|
-
const props = {
|
|
254
|
-
tabIndex: -1,
|
|
255
|
-
id: this.formatDateId(date)
|
|
256
|
-
};
|
|
257
|
-
const optionProps = getOptionProps(props);
|
|
258
|
-
const propsAdded = isOutsideMonth ? {
|
|
259
|
-
...props,
|
|
260
|
-
onClick: optionProps.onClick,
|
|
261
|
-
role: 'presentation'
|
|
262
|
-
} : optionProps;
|
|
263
|
-
return (0, _safeCloneElement.safeCloneElement)(day, propsAdded);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
renderCalendar({
|
|
267
|
-
getListProps,
|
|
268
|
-
getOptionProps
|
|
269
|
-
}) {
|
|
270
|
-
const {
|
|
271
|
-
onRequestRenderNextMonth,
|
|
272
|
-
onRequestRenderPrevMonth,
|
|
273
|
-
renderNavigationLabel,
|
|
274
|
-
renderWeekdayLabels,
|
|
275
|
-
value,
|
|
276
|
-
onChange,
|
|
277
|
-
disabledDates,
|
|
278
|
-
currentDate,
|
|
279
|
-
selectedLabel
|
|
280
|
-
} = this.props;
|
|
281
|
-
const isValidDate = value ? _DateTime.DateTime.parse(value, this.locale(), this.timezone()).isValid() : false;
|
|
282
|
-
const noChildrenProps = this.props.children ? {} : {
|
|
283
|
-
disabledDates,
|
|
284
|
-
currentDate,
|
|
285
|
-
selectedDate: isValidDate ? value : undefined,
|
|
286
|
-
visibleMonth: isValidDate ? value : undefined,
|
|
287
|
-
onDateSelected: (dateString, momentDate, e) => {
|
|
288
|
-
// @ts-expect-error TODO
|
|
289
|
-
onChange?.(e, {
|
|
290
|
-
value: `${momentDate.format('MMMM')} ${momentDate.format('D')}, ${momentDate.format('YYYY')}`
|
|
291
|
-
});
|
|
292
|
-
this.handleHideCalendar(e, dateString);
|
|
293
|
-
}
|
|
294
|
-
};
|
|
295
|
-
return (0, _jsxRuntime.jsx)(_v11_.Calendar, {
|
|
296
|
-
...getListProps({
|
|
297
|
-
onRequestRenderNextMonth,
|
|
298
|
-
onRequestRenderPrevMonth,
|
|
299
|
-
renderNavigationLabel,
|
|
300
|
-
renderWeekdayLabels,
|
|
301
|
-
renderNextMonthButton: this.renderMonthNavigationButton('next'),
|
|
302
|
-
renderPrevMonthButton: this.renderMonthNavigationButton('prev'),
|
|
303
|
-
selectedLabel
|
|
304
|
-
}),
|
|
305
|
-
...noChildrenProps,
|
|
306
|
-
children: this.renderDays(getOptionProps)
|
|
307
|
-
});
|
|
308
|
-
}
|
|
309
|
-
renderInput({
|
|
310
|
-
getInputProps,
|
|
311
|
-
getTriggerProps
|
|
312
|
-
}) {
|
|
313
|
-
const {
|
|
314
|
-
renderLabel,
|
|
315
|
-
value,
|
|
316
|
-
placeholder,
|
|
317
|
-
onBlur,
|
|
318
|
-
isRequired,
|
|
319
|
-
size,
|
|
320
|
-
isInline,
|
|
321
|
-
layout,
|
|
322
|
-
width,
|
|
323
|
-
onRequestValidateDate,
|
|
324
|
-
onRequestShowCalendar,
|
|
325
|
-
onRequestHideCalendar,
|
|
326
|
-
onRequestSelectNextDay,
|
|
327
|
-
onRequestSelectPrevDay,
|
|
328
|
-
onRequestRenderNextMonth,
|
|
329
|
-
onRequestRenderPrevMonth,
|
|
330
|
-
...rest
|
|
331
|
-
} = this.props;
|
|
332
|
-
const {
|
|
333
|
-
interaction
|
|
334
|
-
} = this;
|
|
335
|
-
const {
|
|
336
|
-
ref,
|
|
337
|
-
// Apply this to the actual inputRef
|
|
338
|
-
...triggerProps
|
|
339
|
-
} = getTriggerProps();
|
|
340
|
-
const messages = this.props.messages || this.state.messages;
|
|
341
|
-
return (0, _jsxRuntime.jsx)(_v11_3.TextInput, {
|
|
342
|
-
...triggerProps,
|
|
343
|
-
...(0, _passthroughProps.passthroughProps)(rest),
|
|
344
|
-
...getInputProps({
|
|
345
|
-
renderLabel: (0, _callRenderProp.callRenderProp)(renderLabel),
|
|
346
|
-
value,
|
|
347
|
-
placeholder,
|
|
348
|
-
size,
|
|
349
|
-
layout,
|
|
350
|
-
width,
|
|
351
|
-
messages,
|
|
352
|
-
onChange: this.handleInputChange,
|
|
353
|
-
onBlur: (0, _createChainedFunction.createChainedFunction)(onBlur, this.handleHideCalendar),
|
|
354
|
-
inputRef: (0, _createChainedFunction.createChainedFunction)(ref, this.handleInputRef),
|
|
355
|
-
interaction,
|
|
356
|
-
isRequired,
|
|
357
|
-
display: isInline ? 'inline-block' : 'block',
|
|
358
|
-
renderAfterInput: (0, _jsxRuntime.jsx)(_IconCalendarMonthLine.IconCalendarMonthLine, {
|
|
359
|
-
inline: false
|
|
360
|
-
})
|
|
361
|
-
}),
|
|
362
|
-
onKeyDown: e => {
|
|
363
|
-
if (!this.props.children) {
|
|
364
|
-
if (e.key === 'Enter') {
|
|
365
|
-
// @ts-expect-error TODO
|
|
366
|
-
this.handleHideCalendar(e);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
triggerProps.onKeyDown?.(e);
|
|
370
|
-
}
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
shouldShowCalendar = () => this.props.children ? this.props.isShowingCalendar : this.state.isShowingCalendar;
|
|
374
|
-
render() {
|
|
375
|
-
const {
|
|
376
|
-
placement,
|
|
377
|
-
assistiveText,
|
|
378
|
-
styles
|
|
379
|
-
} = this.props;
|
|
380
|
-
const isShowingCalendar = this.shouldShowCalendar();
|
|
381
|
-
return (0, _jsxRuntime.jsx)(_Selectable.Selectable, {
|
|
382
|
-
isShowingOptions: isShowingCalendar,
|
|
383
|
-
onRequestShowOptions: this.handleShowCalendar,
|
|
384
|
-
onRequestHideOptions: this.handleHideCalendar,
|
|
385
|
-
onRequestHighlightOption: this.handleHighlightOption,
|
|
386
|
-
onRequestSelectOption: e => this.handleHideCalendar(e),
|
|
387
|
-
selectedOptionId: this.selectedDateId,
|
|
388
|
-
highlightedOptionId: this.selectedDateId,
|
|
389
|
-
children: ({
|
|
390
|
-
getRootProps,
|
|
391
|
-
getInputProps,
|
|
392
|
-
getTriggerProps,
|
|
393
|
-
getListProps,
|
|
394
|
-
getOptionProps,
|
|
395
|
-
getDescriptionProps
|
|
396
|
-
}) => (0, _jsxRuntime.jsxs)("span", {
|
|
397
|
-
...getRootProps({
|
|
398
|
-
css: styles?.dateInput
|
|
399
|
-
}),
|
|
400
|
-
ref: el => {
|
|
401
|
-
this.ref = el;
|
|
402
|
-
},
|
|
403
|
-
"data-cid": "DateInput",
|
|
404
|
-
children: [this.renderInput({
|
|
405
|
-
getInputProps,
|
|
406
|
-
getTriggerProps
|
|
407
|
-
}), (0, _jsxRuntime.jsx)("span", {
|
|
408
|
-
...getDescriptionProps(),
|
|
409
|
-
css: styles?.assistiveText,
|
|
410
|
-
children: assistiveText
|
|
411
|
-
}), (0, _jsxRuntime.jsx)(_v11_2.Popover, {
|
|
412
|
-
placement: placement,
|
|
413
|
-
isShowingContent: isShowingCalendar,
|
|
414
|
-
positionTarget: this._input,
|
|
415
|
-
shouldReturnFocus: false,
|
|
416
|
-
shouldFocusContentOnTriggerBlur: true,
|
|
417
|
-
children: this.renderCalendar({
|
|
418
|
-
getListProps,
|
|
419
|
-
getOptionProps
|
|
420
|
-
})
|
|
421
|
-
})]
|
|
422
|
-
})
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
}) || _class);
|
|
426
|
-
var _default = exports.default = DateInput;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
const allowedProps = exports.allowedProps = ['renderLabel', 'value', 'size', 'placeholder', 'onChange', 'onBlur', 'interaction', 'isRequired', 'isInline', 'assistiveText', 'layout', 'width', 'display', 'inputRef', 'messages', 'placement', 'isShowingCalendar', 'onRequestValidateDate', 'onRequestShowCalendar', 'onRequestHideCalendar', 'onRequestSelectNextDay', 'onRequestSelectPrevDay', 'onRequestRenderNextMonth', 'onRequestRenderPrevMonth', 'renderNavigationLabel', 'renderWeekdayLabels', 'renderNextMonthButton', 'renderPrevMonthButton', 'children', 'disabledDates', 'currentDate', 'disabledDateErrorMessage', 'invalidDateErrorMessage', 'locale', 'timezone', 'withYearPicker', 'selectedLabel'];
|