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