@instructure/ui-date-input 10.13.0 → 10.13.1-pr-snapshot-1741357986437
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 +8 -0
- package/lib/DateInput/__new-tests__/DateInput.test.js +8 -8
- package/lib/DateInput/index.js +30 -34
- package/lib/DateInput/props.js +8 -9
- package/lib/DateInput2/__new-tests__/DateInput2.test.js +2 -2
- package/lib/DateInput2/index.js +18 -22
- package/lib/DateInput2/props.js +4 -4
- package/package.json +20 -20
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
## [10.13.1-pr-snapshot-1741357986437](https://github.com/instructure/instructure-ui/compare/v10.13.0...v10.13.1-pr-snapshot-1741357986437) (2025-03-07)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @instructure/ui-date-input
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
6
14
|
# [10.13.0](https://github.com/instructure/instructure-ui/compare/v10.12.0...v10.13.0) (2025-03-06)
|
7
15
|
|
8
16
|
|
@@ -7,8 +7,8 @@ var _vitest = require("vitest");
|
|
7
7
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
8
8
|
require("@testing-library/jest-dom");
|
9
9
|
var _generateA11yTests = require("@instructure/ui-scripts/lib/test/generateA11yTests");
|
10
|
-
var
|
11
|
-
var
|
10
|
+
var _uiAxeCheck = require("@instructure/ui-axe-check");
|
11
|
+
var _uiCalendar = require("@instructure/ui-calendar");
|
12
12
|
var _DateInput = _interopRequireDefault(require("../__examples__/DateInput.examples"));
|
13
13
|
var _index = require("../index");
|
14
14
|
var _Calendar$Day, _button, _button2, _Calendar$Day2, _Calendar$Day3;
|
@@ -38,11 +38,11 @@ var _Calendar$Day, _button, _button2, _Calendar$Day2, _Calendar$Day3;
|
|
38
38
|
// eslint-disable-next-line no-restricted-imports
|
39
39
|
describe('<DateInput />', () => {
|
40
40
|
const weekdayLabels = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
41
|
-
const generateDays = (count =
|
41
|
+
const generateDays = (count = _uiCalendar.Calendar.DAY_COUNT) => {
|
42
42
|
const days = [];
|
43
43
|
const date = new Date('2019-07-28');
|
44
44
|
while (days.length < count) {
|
45
|
-
days.push(/*#__PURE__*/_react.default.createElement(
|
45
|
+
days.push(/*#__PURE__*/_react.default.createElement(_uiCalendar.Calendar.Day, {
|
46
46
|
key: date.toISOString(),
|
47
47
|
date: date.toISOString(),
|
48
48
|
label: date.toISOString()
|
@@ -441,7 +441,7 @@ describe('<DateInput />', () => {
|
|
441
441
|
const onRequestHideCalendar = _vitest.vi.fn();
|
442
442
|
const onRequestValidateDate = _vitest.vi.fn();
|
443
443
|
const days = generateDays();
|
444
|
-
days[4] = _Calendar$Day || (_Calendar$Day = /*#__PURE__*/_react.default.createElement(
|
444
|
+
days[4] = _Calendar$Day || (_Calendar$Day = /*#__PURE__*/_react.default.createElement(_uiCalendar.Calendar.Day, {
|
445
445
|
key: "4",
|
446
446
|
label: "4",
|
447
447
|
date: "2019-09-28",
|
@@ -514,7 +514,7 @@ describe('<DateInput />', () => {
|
|
514
514
|
});
|
515
515
|
it('should render days with the correct role', async () => {
|
516
516
|
const days = generateDays();
|
517
|
-
days[5] = _Calendar$Day2 || (_Calendar$Day2 = /*#__PURE__*/_react.default.createElement(
|
517
|
+
days[5] = _Calendar$Day2 || (_Calendar$Day2 = /*#__PURE__*/_react.default.createElement(_uiCalendar.Calendar.Day, {
|
518
518
|
key: "5",
|
519
519
|
label: "5",
|
520
520
|
date: "2019-09-28",
|
@@ -538,7 +538,7 @@ describe('<DateInput />', () => {
|
|
538
538
|
});
|
539
539
|
it('should assign aria-selected to the selected date and link it to the input', async () => {
|
540
540
|
const days = generateDays();
|
541
|
-
days[7] = _Calendar$Day3 || (_Calendar$Day3 = /*#__PURE__*/_react.default.createElement(
|
541
|
+
days[7] = _Calendar$Day3 || (_Calendar$Day3 = /*#__PURE__*/_react.default.createElement(_uiCalendar.Calendar.Day, {
|
542
542
|
key: "7",
|
543
543
|
label: "7",
|
544
544
|
date: "2019-09-28",
|
@@ -572,7 +572,7 @@ describe('<DateInput />', () => {
|
|
572
572
|
}) => {
|
573
573
|
const _render7 = (0, _react2.render)(content),
|
574
574
|
container = _render7.container;
|
575
|
-
const axeCheck = await (0,
|
575
|
+
const axeCheck = await (0, _uiAxeCheck.runAxeCheck)(container);
|
576
576
|
expect(axeCheck).toBe(true);
|
577
577
|
});
|
578
578
|
});
|
package/lib/DateInput/index.js
CHANGED
@@ -8,19 +8,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
exports.default = exports.DateInput = void 0;
|
9
9
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
11
|
-
var
|
12
|
-
var
|
13
|
-
var
|
14
|
-
var
|
15
|
-
var
|
16
|
-
var
|
17
|
-
var
|
18
|
-
var
|
19
|
-
var
|
20
|
-
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
21
|
-
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
22
|
-
var _DateTime = require("@instructure/ui-i18n/lib/DateTime.js");
|
23
|
-
var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
|
11
|
+
var _uiCalendar = require("@instructure/ui-calendar");
|
12
|
+
var _uiIcons = require("@instructure/ui-icons");
|
13
|
+
var _uiPopover = require("@instructure/ui-popover");
|
14
|
+
var _uiSelectable = require("@instructure/ui-selectable");
|
15
|
+
var _uiTextInput = require("@instructure/ui-text-input");
|
16
|
+
var _uiUtils = require("@instructure/ui-utils");
|
17
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
18
|
+
var _uiTestable = require("@instructure/ui-testable");
|
19
|
+
var _uiI18n = require("@instructure/ui-i18n");
|
24
20
|
var _emotion = require("@instructure/emotion");
|
25
21
|
var _styles = _interopRequireDefault(require("./styles"));
|
26
22
|
var _props2 = require("./props");
|
@@ -56,7 +52,7 @@ var _dec, _dec2, _class, _DateInput, _IconCalendarMonthLin;
|
|
56
52
|
category: components
|
57
53
|
---
|
58
54
|
**/
|
59
|
-
let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (0,
|
55
|
+
let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.default, null), _dec2 = (0, _uiTestable.testable)(), _dec(_class = _dec2(_class = (_DateInput = class DateInput extends _react.Component {
|
60
56
|
constructor(...args) {
|
61
57
|
super(...args);
|
62
58
|
this.state = {
|
@@ -107,7 +103,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
107
103
|
const messages = [];
|
108
104
|
// check if date is enabled
|
109
105
|
const disabledDates = this.props.disabledDates;
|
110
|
-
if (typeof disabledDates === 'function' && disabledDates(date) || Array.isArray(disabledDates) && disabledDates.find(dateString =>
|
106
|
+
if (typeof disabledDates === 'function' && disabledDates(date) || Array.isArray(disabledDates) && disabledDates.find(dateString => _uiI18n.DateTime.parse(dateString, this.locale(), this.timezone()).isSame(_uiI18n.DateTime.parse(date, this.locale(), this.timezone()), 'day'))) {
|
111
107
|
messages.push(typeof disabledDateErrorMessage === 'function' ? disabledDateErrorMessage(date) : {
|
112
108
|
type: 'error',
|
113
109
|
text: disabledDateErrorMessage
|
@@ -115,7 +111,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
115
111
|
}
|
116
112
|
|
117
113
|
// check if date is valid
|
118
|
-
if (!
|
114
|
+
if (!_uiI18n.DateTime.parse(date, this.locale(), this.timezone(), [_uiI18n.DateTime.momentISOFormat, 'llll', 'LLLL', 'lll', 'LLL', 'll', 'LL', 'l', 'L'], true).isValid()) {
|
119
115
|
messages.push(typeof invalidDateErrorMessage === 'function' ? invalidDateErrorMessage(date) : {
|
120
116
|
type: 'error',
|
121
117
|
text: invalidDateErrorMessage
|
@@ -155,14 +151,14 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
155
151
|
onChange = _this$props7.onChange,
|
156
152
|
value = _this$props7.value,
|
157
153
|
currentDate = _this$props7.currentDate;
|
158
|
-
const isValueValid = value &&
|
154
|
+
const isValueValid = value && _uiI18n.DateTime.parse(value, this.locale(), this.timezone()).isValid();
|
159
155
|
if (direction === -1) {
|
160
156
|
if (onRequestSelectPrevDay) {
|
161
157
|
onRequestSelectPrevDay === null || onRequestSelectPrevDay === void 0 ? void 0 : onRequestSelectPrevDay(event);
|
162
158
|
} else {
|
163
159
|
// @ts-expect-error TODO
|
164
160
|
onChange(event, {
|
165
|
-
value:
|
161
|
+
value: _uiI18n.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('MMMM D, YYYY')
|
166
162
|
});
|
167
163
|
this.setState({
|
168
164
|
messages: []
|
@@ -175,7 +171,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
175
171
|
} else {
|
176
172
|
// @ts-expect-error TODO
|
177
173
|
onChange(event, {
|
178
|
-
value:
|
174
|
+
value: _uiI18n.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('MMMM D, YYYY')
|
179
175
|
});
|
180
176
|
this.setState({
|
181
177
|
messages: []
|
@@ -191,7 +187,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
191
187
|
} else if (this.context && this.context.locale) {
|
192
188
|
return this.context.locale;
|
193
189
|
}
|
194
|
-
return
|
190
|
+
return _uiI18n.Locale.browserLocale();
|
195
191
|
}
|
196
192
|
timezone() {
|
197
193
|
if (this.props.timezone) {
|
@@ -199,7 +195,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
199
195
|
} else if (this.context && this.context.timezone) {
|
200
196
|
return this.context.timezone;
|
201
197
|
}
|
202
|
-
return
|
198
|
+
return _uiI18n.DateTime.browserTimeZone();
|
203
199
|
}
|
204
200
|
componentDidMount() {
|
205
201
|
var _this$props$makeStyle, _this$props8;
|
@@ -222,7 +218,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
222
218
|
return selectedDateId;
|
223
219
|
}
|
224
220
|
get interaction() {
|
225
|
-
return (0,
|
221
|
+
return (0, _uiReactUtils.getInteraction)({
|
226
222
|
props: this.props
|
227
223
|
});
|
228
224
|
}
|
@@ -231,7 +227,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
231
227
|
renderPrevMonthButton = _this$props10.renderPrevMonthButton,
|
232
228
|
renderNextMonthButton = _this$props10.renderNextMonthButton;
|
233
229
|
const button = type === 'prev' ? renderPrevMonthButton : renderNextMonthButton;
|
234
|
-
return button && (0,
|
230
|
+
return button && (0, _uiReactUtils.safeCloneElement)((0, _uiReactUtils.callRenderProp)(button), {
|
235
231
|
tabIndex: -1
|
236
232
|
});
|
237
233
|
}
|
@@ -252,7 +248,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
252
248
|
onClick: optionProps.onClick,
|
253
249
|
role: 'presentation'
|
254
250
|
} : optionProps;
|
255
|
-
return (0,
|
251
|
+
return (0, _uiReactUtils.safeCloneElement)(day, propsAdded);
|
256
252
|
});
|
257
253
|
}
|
258
254
|
renderCalendar({
|
@@ -268,7 +264,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
268
264
|
onChange = _this$props11.onChange,
|
269
265
|
disabledDates = _this$props11.disabledDates,
|
270
266
|
currentDate = _this$props11.currentDate;
|
271
|
-
const isValidDate = value ?
|
267
|
+
const isValidDate = value ? _uiI18n.DateTime.parse(value, this.locale(), this.timezone()).isValid() : false;
|
272
268
|
const noChildrenProps = this.props.children ? {} : {
|
273
269
|
disabledDates,
|
274
270
|
currentDate,
|
@@ -282,7 +278,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
282
278
|
this.handleHideCalendar(e, dateString);
|
283
279
|
}
|
284
280
|
};
|
285
|
-
return (0, _emotion.jsx)(
|
281
|
+
return (0, _emotion.jsx)(_uiCalendar.Calendar, Object.assign({}, getListProps({
|
286
282
|
onRequestRenderNextMonth,
|
287
283
|
onRequestRenderPrevMonth,
|
288
284
|
renderNavigationLabel,
|
@@ -318,8 +314,8 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
318
314
|
ref = _getTriggerProps.ref,
|
319
315
|
triggerProps = (0, _objectWithoutProperties2.default)(_getTriggerProps, _excluded2);
|
320
316
|
const messages = this.props.messages || this.state.messages;
|
321
|
-
return (0, _emotion.jsx)(
|
322
|
-
renderLabel: (0,
|
317
|
+
return (0, _emotion.jsx)(_uiTextInput.TextInput, Object.assign({}, triggerProps, (0, _uiReactUtils.passthroughProps)(rest), getInputProps({
|
318
|
+
renderLabel: (0, _uiReactUtils.callRenderProp)(renderLabel),
|
323
319
|
value,
|
324
320
|
placeholder,
|
325
321
|
size,
|
@@ -327,12 +323,12 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
327
323
|
width,
|
328
324
|
messages,
|
329
325
|
onChange: this.handleInputChange,
|
330
|
-
onBlur: (0,
|
331
|
-
inputRef: (0,
|
326
|
+
onBlur: (0, _uiUtils.createChainedFunction)(onBlur, this.handleHideCalendar),
|
327
|
+
inputRef: (0, _uiUtils.createChainedFunction)(ref, this.handleInputRef),
|
332
328
|
interaction,
|
333
329
|
isRequired,
|
334
330
|
display: isInline ? 'inline-block' : 'block',
|
335
|
-
renderAfterInput: _IconCalendarMonthLin || (_IconCalendarMonthLin = (0, _emotion.jsx)(
|
331
|
+
renderAfterInput: _IconCalendarMonthLin || (_IconCalendarMonthLin = (0, _emotion.jsx)(_uiIcons.IconCalendarMonthLine, {
|
336
332
|
inline: false
|
337
333
|
}))
|
338
334
|
}), {
|
@@ -354,7 +350,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
354
350
|
assistiveText = _this$props13.assistiveText,
|
355
351
|
styles = _this$props13.styles;
|
356
352
|
const isShowingCalendar = this.shouldShowCalendar();
|
357
|
-
return (0, _emotion.jsx)(
|
353
|
+
return (0, _emotion.jsx)(_uiSelectable.Selectable, {
|
358
354
|
isShowingOptions: isShowingCalendar,
|
359
355
|
onRequestShowOptions: this.handleShowCalendar,
|
360
356
|
onRequestHideOptions: this.handleHideCalendar,
|
@@ -378,7 +374,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
378
374
|
getTriggerProps
|
379
375
|
}), (0, _emotion.jsx)("span", Object.assign({}, getDescriptionProps(), {
|
380
376
|
css: styles === null || styles === void 0 ? void 0 : styles.assistiveText
|
381
|
-
}), assistiveText), (0, _emotion.jsx)(
|
377
|
+
}), assistiveText), (0, _emotion.jsx)(_uiPopover.Popover, {
|
382
378
|
placement: placement,
|
383
379
|
isShowingContent: isShowingCalendar,
|
384
380
|
positionTarget: this._input,
|
@@ -389,7 +385,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
|
|
389
385
|
getOptionProps
|
390
386
|
}))));
|
391
387
|
}
|
392
|
-
}, _DateInput.displayName = "DateInput", _DateInput.componentId = 'DateInput', _DateInput.Day =
|
388
|
+
}, _DateInput.displayName = "DateInput", _DateInput.componentId = 'DateInput', _DateInput.Day = _uiCalendar.Calendar.Day, _DateInput.propTypes = _props2.propTypes, _DateInput.allowedProps = _props2.allowedProps, _DateInput.defaultProps = {
|
393
389
|
value: '',
|
394
390
|
size: 'medium',
|
395
391
|
onBlur: () => {},
|
package/lib/DateInput/props.js
CHANGED
@@ -6,11 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.propTypes = exports.allowedProps = void 0;
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
9
|
-
var
|
10
|
-
var
|
11
|
-
var
|
12
|
-
var
|
13
|
-
var _Calendar = require("@instructure/ui-calendar/lib/Calendar");
|
9
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
10
|
+
var _uiFormField = require("@instructure/ui-form-field");
|
11
|
+
var _uiPosition = require("@instructure/ui-position");
|
12
|
+
var _uiCalendar = require("@instructure/ui-calendar");
|
14
13
|
/*
|
15
14
|
* The MIT License (MIT)
|
16
15
|
*
|
@@ -37,7 +36,7 @@ var _Calendar = require("@instructure/ui-calendar/lib/Calendar");
|
|
37
36
|
|
38
37
|
const propTypes = exports.propTypes = {
|
39
38
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
40
|
-
value: (0,
|
39
|
+
value: (0, _uiPropTypes.controllable)(_propTypes.default.string),
|
41
40
|
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
42
41
|
placeholder: _propTypes.default.string,
|
43
42
|
onChange: _propTypes.default.func,
|
@@ -50,8 +49,8 @@ const propTypes = exports.propTypes = {
|
|
50
49
|
width: _propTypes.default.string,
|
51
50
|
display: _propTypes.default.oneOf(['inline-block', 'block']),
|
52
51
|
inputRef: _propTypes.default.func,
|
53
|
-
messages: _propTypes.default.arrayOf(
|
54
|
-
placement:
|
52
|
+
messages: _propTypes.default.arrayOf(_uiFormField.FormPropTypes.message),
|
53
|
+
placement: _uiPosition.PositionPropTypes.placement,
|
55
54
|
isShowingCalendar: _propTypes.default.bool,
|
56
55
|
onRequestValidateDate: _propTypes.default.func,
|
57
56
|
onRequestShowCalendar: _propTypes.default.func,
|
@@ -64,7 +63,7 @@ const propTypes = exports.propTypes = {
|
|
64
63
|
renderWeekdayLabels: _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node])),
|
65
64
|
renderNextMonthButton: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
66
65
|
renderPrevMonthButton: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.node]),
|
67
|
-
children:
|
66
|
+
children: _uiPropTypes.Children.oneOf([_uiCalendar.Calendar.Day]),
|
68
67
|
disabledDates: _propTypes.default.oneOfType([_propTypes.default.array, _propTypes.default.func]),
|
69
68
|
currentDate: _propTypes.default.string,
|
70
69
|
disabledDateErrorMessage: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
@@ -8,7 +8,7 @@ var _react2 = require("@testing-library/react");
|
|
8
8
|
var _vitest = require("vitest");
|
9
9
|
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
10
10
|
require("@testing-library/jest-dom");
|
11
|
-
var
|
11
|
+
var _uiIcons = require("@instructure/ui-icons");
|
12
12
|
var _index = require("../index");
|
13
13
|
var _DateInputExample, _DateInputExample2, _IconHeartLine, _DateInputExample3, _DateInputExample4;
|
14
14
|
/*
|
@@ -121,7 +121,7 @@ describe('<DateInput2 />', () => {
|
|
121
121
|
prevMonthButton: 'Previous month'
|
122
122
|
},
|
123
123
|
value: "",
|
124
|
-
renderCalendarIcon: _IconHeartLine || (_IconHeartLine = /*#__PURE__*/_react.default.createElement(
|
124
|
+
renderCalendarIcon: _IconHeartLine || (_IconHeartLine = /*#__PURE__*/_react.default.createElement(_uiIcons.IconHeartLine, null))
|
125
125
|
})),
|
126
126
|
container = _render4.container;
|
127
127
|
const calendarIcon = container.querySelector('svg[name="IconHeart"]');
|
package/lib/DateInput2/index.js
CHANGED
@@ -7,17 +7,13 @@ 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
|
16
|
-
var
|
17
|
-
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
18
|
-
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
19
|
-
var _ApplyLocaleContext = require("@instructure/ui-i18n/lib/ApplyLocale/ApplyLocaleContext.js");
|
20
|
-
var _Locale = require("@instructure/ui-i18n/lib/Locale.js");
|
10
|
+
var _uiCalendar = require("@instructure/ui-calendar");
|
11
|
+
var _uiButtons = require("@instructure/ui-buttons");
|
12
|
+
var _uiIcons = require("@instructure/ui-icons");
|
13
|
+
var _uiPopover = require("@instructure/ui-popover");
|
14
|
+
var _uiTextInput = require("@instructure/ui-text-input");
|
15
|
+
var _uiReactUtils = require("@instructure/ui-react-utils");
|
16
|
+
var _uiI18n = require("@instructure/ui-i18n");
|
21
17
|
var _emotion = require("@instructure/emotion");
|
22
18
|
var _props = require("./props");
|
23
19
|
var _IconCalendarMonthLin, _IconArrowOpenEndSoli, _IconArrowOpenStartSo;
|
@@ -145,7 +141,7 @@ const DateInput2 = ({
|
|
145
141
|
inputRef,
|
146
142
|
...rest
|
147
143
|
}) => {
|
148
|
-
const localeContext = (0, _react.useContext)(
|
144
|
+
const localeContext = (0, _react.useContext)(_uiI18n.ApplyLocaleContext);
|
149
145
|
const getLocale = () => {
|
150
146
|
if (locale) {
|
151
147
|
return locale;
|
@@ -153,7 +149,7 @@ const DateInput2 = ({
|
|
153
149
|
return localeContext.locale;
|
154
150
|
}
|
155
151
|
// default to the system's locale
|
156
|
-
return
|
152
|
+
return _uiI18n.Locale.browserLocale();
|
157
153
|
};
|
158
154
|
const getTimezone = () => {
|
159
155
|
if (timezone) {
|
@@ -259,7 +255,7 @@ const DateInput2 = ({
|
|
259
255
|
onBlur === null || onBlur === void 0 ? void 0 : onBlur(e, value || '', utcIsoDate);
|
260
256
|
};
|
261
257
|
const selectedDate = parseDate(value)[1];
|
262
|
-
return (0, _emotion.jsx)(
|
258
|
+
return (0, _emotion.jsx)(_uiTextInput.TextInput, Object.assign({}, (0, _uiReactUtils.passthroughProps)(rest), {
|
263
259
|
inputRef: inputRef,
|
264
260
|
renderLabel: renderLabel,
|
265
261
|
onChange: handleInputChange,
|
@@ -272,14 +268,14 @@ const DateInput2 = ({
|
|
272
268
|
messages: inputMessages,
|
273
269
|
interaction: interaction,
|
274
270
|
margin: margin,
|
275
|
-
renderAfterInput: (0, _emotion.jsx)(
|
276
|
-
renderTrigger: (0, _emotion.jsx)(
|
271
|
+
renderAfterInput: (0, _emotion.jsx)(_uiPopover.Popover, {
|
272
|
+
renderTrigger: (0, _emotion.jsx)(_uiButtons.IconButton, {
|
277
273
|
withBackground: false,
|
278
274
|
withBorder: false,
|
279
275
|
screenReaderLabel: screenReaderLabels.calendarIcon,
|
280
276
|
shape: "circle",
|
281
277
|
interaction: interaction
|
282
|
-
}, renderCalendarIcon ? (0,
|
278
|
+
}, renderCalendarIcon ? (0, _uiReactUtils.callRenderProp)(renderCalendarIcon) : _IconCalendarMonthLin || (_IconCalendarMonthLin = (0, _emotion.jsx)(_uiIcons.IconCalendarMonthLine, null))),
|
283
279
|
isShowingContent: showPopover,
|
284
280
|
onShowContent: () => setShowPopover(true),
|
285
281
|
onHideContent: () => setShowPopover(false),
|
@@ -287,7 +283,7 @@ const DateInput2 = ({
|
|
287
283
|
shouldContainFocus: true,
|
288
284
|
shouldReturnFocus: true,
|
289
285
|
shouldCloseOnDocumentClick: true
|
290
|
-
}, (0, _emotion.jsx)(
|
286
|
+
}, (0, _emotion.jsx)(_uiCalendar.Calendar, {
|
291
287
|
withYearPicker: withYearPicker,
|
292
288
|
onDateSelected: handleDateSelected,
|
293
289
|
selectedDate: selectedDate,
|
@@ -295,20 +291,20 @@ const DateInput2 = ({
|
|
295
291
|
visibleMonth: selectedDate,
|
296
292
|
locale: getLocale(),
|
297
293
|
timezone: getTimezone(),
|
298
|
-
renderNextMonthButton: (0, _emotion.jsx)(
|
294
|
+
renderNextMonthButton: (0, _emotion.jsx)(_uiButtons.IconButton, {
|
299
295
|
size: "small",
|
300
296
|
withBackground: false,
|
301
297
|
withBorder: false,
|
302
|
-
renderIcon: _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(
|
298
|
+
renderIcon: _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _emotion.jsx)(_uiIcons.IconArrowOpenEndSolid, {
|
303
299
|
color: "primary"
|
304
300
|
})),
|
305
301
|
screenReaderLabel: screenReaderLabels.nextMonthButton
|
306
302
|
}),
|
307
|
-
renderPrevMonthButton: (0, _emotion.jsx)(
|
303
|
+
renderPrevMonthButton: (0, _emotion.jsx)(_uiButtons.IconButton, {
|
308
304
|
size: "small",
|
309
305
|
withBackground: false,
|
310
306
|
withBorder: false,
|
311
|
-
renderIcon: _IconArrowOpenStartSo || (_IconArrowOpenStartSo = (0, _emotion.jsx)(
|
307
|
+
renderIcon: _IconArrowOpenStartSo || (_IconArrowOpenStartSo = (0, _emotion.jsx)(_uiIcons.IconArrowOpenStartSolid, {
|
312
308
|
color: "primary"
|
313
309
|
})),
|
314
310
|
screenReaderLabel: screenReaderLabels.prevMonthButton
|
package/lib/DateInput2/props.js
CHANGED
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
});
|
7
7
|
exports.propTypes = void 0;
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
9
|
-
var
|
10
|
-
var
|
9
|
+
var _uiPropTypes = require("@instructure/ui-prop-types");
|
10
|
+
var _uiFormField = require("@instructure/ui-form-field");
|
11
11
|
/*
|
12
12
|
* The MIT License (MIT)
|
13
13
|
*
|
@@ -35,7 +35,7 @@ var _FormPropTypes = require("@instructure/ui-form-field/lib/FormPropTypes.js");
|
|
35
35
|
const propTypes = exports.propTypes = {
|
36
36
|
renderLabel: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func]).isRequired,
|
37
37
|
screenReaderLabels: _propTypes.default.object.isRequired,
|
38
|
-
value: (0,
|
38
|
+
value: (0, _uiPropTypes.controllable)(_propTypes.default.string),
|
39
39
|
placeholder: _propTypes.default.string,
|
40
40
|
onChange: _propTypes.default.func,
|
41
41
|
onBlur: _propTypes.default.func,
|
@@ -43,7 +43,7 @@ const propTypes = exports.propTypes = {
|
|
43
43
|
isRequired: _propTypes.default.bool,
|
44
44
|
isInline: _propTypes.default.bool,
|
45
45
|
width: _propTypes.default.string,
|
46
|
-
messages: _propTypes.default.arrayOf(
|
46
|
+
messages: _propTypes.default.arrayOf(_uiFormField.FormPropTypes.message),
|
47
47
|
invalidDateErrorMessage: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.string]),
|
48
48
|
locale: _propTypes.default.string,
|
49
49
|
timezone: _propTypes.default.string,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-date-input",
|
3
|
-
"version": "10.13.
|
3
|
+
"version": "10.13.1-pr-snapshot-1741357986437",
|
4
4
|
"description": "A UI component library made by Instructure Inc.",
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
6
6
|
"module": "./es/index.js",
|
@@ -23,11 +23,11 @@
|
|
23
23
|
},
|
24
24
|
"license": "MIT",
|
25
25
|
"devDependencies": {
|
26
|
-
"@instructure/ui-axe-check": "10.13.
|
27
|
-
"@instructure/ui-babel-preset": "10.13.
|
28
|
-
"@instructure/ui-buttons": "10.13.
|
29
|
-
"@instructure/ui-scripts": "10.13.
|
30
|
-
"@instructure/ui-test-utils": "10.13.
|
26
|
+
"@instructure/ui-axe-check": "10.13.1-pr-snapshot-1741357986437",
|
27
|
+
"@instructure/ui-babel-preset": "10.13.1-pr-snapshot-1741357986437",
|
28
|
+
"@instructure/ui-buttons": "10.13.1-pr-snapshot-1741357986437",
|
29
|
+
"@instructure/ui-scripts": "10.13.1-pr-snapshot-1741357986437",
|
30
|
+
"@instructure/ui-test-utils": "10.13.1-pr-snapshot-1741357986437",
|
31
31
|
"@testing-library/jest-dom": "^6.6.3",
|
32
32
|
"@testing-library/react": "^16.0.1",
|
33
33
|
"@testing-library/user-event": "^14.5.2",
|
@@ -35,20 +35,20 @@
|
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
37
|
"@babel/runtime": "^7.26.0",
|
38
|
-
"@instructure/emotion": "10.13.
|
39
|
-
"@instructure/shared-types": "10.13.
|
40
|
-
"@instructure/ui-calendar": "10.13.
|
41
|
-
"@instructure/ui-form-field": "10.13.
|
42
|
-
"@instructure/ui-i18n": "10.13.
|
43
|
-
"@instructure/ui-icons": "10.13.
|
44
|
-
"@instructure/ui-popover": "10.13.
|
45
|
-
"@instructure/ui-position": "10.13.
|
46
|
-
"@instructure/ui-prop-types": "10.13.
|
47
|
-
"@instructure/ui-react-utils": "10.13.
|
48
|
-
"@instructure/ui-selectable": "10.13.
|
49
|
-
"@instructure/ui-testable": "10.13.
|
50
|
-
"@instructure/ui-text-input": "10.13.
|
51
|
-
"@instructure/ui-utils": "10.13.
|
38
|
+
"@instructure/emotion": "10.13.1-pr-snapshot-1741357986437",
|
39
|
+
"@instructure/shared-types": "10.13.1-pr-snapshot-1741357986437",
|
40
|
+
"@instructure/ui-calendar": "10.13.1-pr-snapshot-1741357986437",
|
41
|
+
"@instructure/ui-form-field": "10.13.1-pr-snapshot-1741357986437",
|
42
|
+
"@instructure/ui-i18n": "10.13.1-pr-snapshot-1741357986437",
|
43
|
+
"@instructure/ui-icons": "10.13.1-pr-snapshot-1741357986437",
|
44
|
+
"@instructure/ui-popover": "10.13.1-pr-snapshot-1741357986437",
|
45
|
+
"@instructure/ui-position": "10.13.1-pr-snapshot-1741357986437",
|
46
|
+
"@instructure/ui-prop-types": "10.13.1-pr-snapshot-1741357986437",
|
47
|
+
"@instructure/ui-react-utils": "10.13.1-pr-snapshot-1741357986437",
|
48
|
+
"@instructure/ui-selectable": "10.13.1-pr-snapshot-1741357986437",
|
49
|
+
"@instructure/ui-testable": "10.13.1-pr-snapshot-1741357986437",
|
50
|
+
"@instructure/ui-text-input": "10.13.1-pr-snapshot-1741357986437",
|
51
|
+
"@instructure/ui-utils": "10.13.1-pr-snapshot-1741357986437",
|
52
52
|
"moment-timezone": "^0.5.45",
|
53
53
|
"prop-types": "^15.8.1"
|
54
54
|
},
|