@instructure/ui-date-input 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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 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
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-date-input
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
 
@@ -1,9 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
1
  /*
8
2
  * The MIT License (MIT)
9
3
  *
@@ -28,25 +22,16 @@ exports.default = void 0;
28
22
  * SOFTWARE.
29
23
  */
30
24
 
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;
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
37
+ }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-input",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A UI component library made by Instructure Inc.",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -16,27 +16,27 @@
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.27.6",
18
18
  "moment-timezone": "^0.6.0",
19
- "@instructure/emotion": "11.6.0",
20
- "@instructure/shared-types": "11.6.0",
21
- "@instructure/ui-calendar": "11.6.0",
22
- "@instructure/ui-i18n": "11.6.0",
23
- "@instructure/ui-form-field": "11.6.0",
24
- "@instructure/ui-icons": "11.6.0",
25
- "@instructure/ui-popover": "11.6.0",
26
- "@instructure/ui-selectable": "11.6.0",
27
- "@instructure/ui-text-input": "11.6.0",
28
- "@instructure/ui-utils": "11.6.0",
29
- "@instructure/ui-react-utils": "11.6.0",
30
- "@instructure/ui-position": "11.6.0"
19
+ "@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
20
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
21
+ "@instructure/ui-calendar": "11.6.1-pr-snapshot-1779894247159",
22
+ "@instructure/ui-i18n": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/ui-form-field": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-icons": "11.6.1-pr-snapshot-1779894247159",
25
+ "@instructure/ui-popover": "11.6.1-pr-snapshot-1779894247159",
26
+ "@instructure/ui-position": "11.6.1-pr-snapshot-1779894247159",
27
+ "@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
28
+ "@instructure/ui-selectable": "11.6.1-pr-snapshot-1779894247159",
29
+ "@instructure/ui-utils": "11.6.1-pr-snapshot-1779894247159",
30
+ "@instructure/ui-text-input": "11.6.1-pr-snapshot-1779894247159"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@testing-library/jest-dom": "^6.6.3",
34
34
  "@testing-library/react": "15.0.7",
35
35
  "@testing-library/user-event": "^14.6.1",
36
36
  "vitest": "^3.2.2",
37
- "@instructure/ui-babel-preset": "11.6.0",
38
- "@instructure/ui-buttons": "11.6.0",
39
- "@instructure/ui-scripts": "11.6.0"
37
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
38
+ "@instructure/ui-buttons": "11.6.1-pr-snapshot-1779894247159",
39
+ "@instructure/ui-scripts": "11.6.1-pr-snapshot-1779894247159"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": ">=18 <=19"
@@ -49,10 +49,8 @@
49
49
  ".": {
50
50
  "types": "./types/index.d.ts",
51
51
  "import": "./es/index.js",
52
- "require": "./lib/index.js",
53
52
  "default": "./es/index.js"
54
53
  },
55
- "./lib/*": "./lib/*",
56
54
  "./es/*": "./es/*",
57
55
  "./types/*": "./types/*",
58
56
  "./package.json": "./package.json",
@@ -62,7 +60,7 @@
62
60
  "lint": "ui-scripts lint",
63
61
  "lint:fix": "ui-scripts lint --fix",
64
62
  "clean": "ui-scripts clean",
65
- "build": "ui-scripts build --modules es,cjs",
63
+ "build": "ui-scripts build",
66
64
  "build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
67
65
  "build:types": "tsc -p tsconfig.build.json",
68
66
  "ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
@@ -1,418 +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 _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
- var _react = require("react");
10
- var _Calendar = require("@instructure/ui-calendar/lib/Calendar");
11
- var _IconCalendarMonthLine = require("@instructure/ui-icons/lib/IconCalendarMonthLine.js");
12
- var _Popover = require("@instructure/ui-popover/lib/Popover");
13
- var _Selectable = require("@instructure/ui-selectable/lib/Selectable");
14
- var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
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, _IconCalendarMonthLin;
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, null), _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)(_Calendar.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)(_TextInput.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: _IconCalendarMonthLin || (_IconCalendarMonthLin = (0, _jsxRuntime.jsx)(_IconCalendarMonthLine.IconCalendarMonthLine, {
341
- inline: false
342
- }))
343
- }),
344
- onKeyDown: e => {
345
- var _triggerProps$onKeyDo;
346
- if (!this.props.children) {
347
- if (e.key === 'Enter') {
348
- // @ts-expect-error TODO
349
- this.handleHideCalendar(e);
350
- }
351
- }
352
- (_triggerProps$onKeyDo = triggerProps.onKeyDown) === null || _triggerProps$onKeyDo === void 0 ? void 0 : _triggerProps$onKeyDo.call(triggerProps, e);
353
- }
354
- });
355
- }
356
- render() {
357
- const _this$props11 = this.props,
358
- placement = _this$props11.placement,
359
- assistiveText = _this$props11.assistiveText,
360
- styles = _this$props11.styles;
361
- const isShowingCalendar = this.shouldShowCalendar();
362
- return (0, _jsxRuntime.jsx)(_Selectable.Selectable, {
363
- isShowingOptions: isShowingCalendar,
364
- onRequestShowOptions: this.handleShowCalendar,
365
- onRequestHideOptions: this.handleHideCalendar,
366
- onRequestHighlightOption: this.handleHighlightOption,
367
- onRequestSelectOption: e => this.handleHideCalendar(e),
368
- selectedOptionId: this.selectedDateId,
369
- highlightedOptionId: this.selectedDateId,
370
- children: ({
371
- getRootProps,
372
- getInputProps,
373
- getTriggerProps,
374
- getListProps,
375
- getOptionProps,
376
- getDescriptionProps
377
- }) => (0, _jsxRuntime.jsxs)("span", {
378
- ...getRootProps({
379
- css: styles === null || styles === void 0 ? void 0 : styles.dateInput
380
- }),
381
- ref: el => {
382
- this.ref = el;
383
- },
384
- "data-cid": "DateInput",
385
- children: [this.renderInput({
386
- getInputProps,
387
- getTriggerProps
388
- }), (0, _jsxRuntime.jsx)("span", {
389
- ...getDescriptionProps(),
390
- css: styles === null || styles === void 0 ? void 0 : styles.assistiveText,
391
- children: assistiveText
392
- }), (0, _jsxRuntime.jsx)(_Popover.Popover, {
393
- placement: placement,
394
- isShowingContent: isShowingCalendar,
395
- positionTarget: this._input,
396
- shouldReturnFocus: false,
397
- shouldFocusContentOnTriggerBlur: true,
398
- children: this.renderCalendar({
399
- getListProps,
400
- getOptionProps
401
- })
402
- })]
403
- })
404
- });
405
- }
406
- }, _DateInput.displayName = "DateInput", _DateInput.componentId = 'DateInput', _DateInput.Day = _Calendar.Calendar.Day, _DateInput.allowedProps = _props2.allowedProps, _DateInput.defaultProps = {
407
- value: '',
408
- size: 'medium',
409
- onBlur: () => {},
410
- // must have a default so createChainedFunction works
411
- isRequired: false,
412
- isInline: false,
413
- layout: 'stacked',
414
- display: 'inline-block',
415
- placement: 'bottom center',
416
- isShowingCalendar: false
417
- }, _DateInput)) || _class);
418
- 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'];
@@ -1,303 +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.DateInput2 = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = require("react");
10
- var _Calendar = require("@instructure/ui-calendar/lib/Calendar");
11
- var _IconButton = require("@instructure/ui-buttons/lib/IconButton");
12
- var _IconCalendarMonthLine = require("@instructure/ui-icons/lib/IconCalendarMonthLine.js");
13
- var _IconArrowOpenEndSolid = require("@instructure/ui-icons/lib/IconArrowOpenEndSolid.js");
14
- var _IconArrowOpenStartSolid = require("@instructure/ui-icons/lib/IconArrowOpenStartSolid.js");
15
- var _Popover = require("@instructure/ui-popover/lib/Popover");
16
- var _TextInput = require("@instructure/ui-text-input/lib/TextInput");
17
- var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
18
- var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
19
- var _getLocale = require("@instructure/ui-i18n/lib/getLocale.js");
20
- var _getTimezone = require("@instructure/ui-i18n/lib/getTimezone.js");
21
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
22
- var _IconCalendarMonthLin, _IconArrowOpenEndSoli, _IconArrowOpenStartSo;
23
- /*
24
- * The MIT License (MIT)
25
- *
26
- * Copyright (c) 2015 - present Instructure, Inc.
27
- *
28
- * Permission is hereby granted, free of charge, to any person obtaining a copy
29
- * of this software and associated documentation files (the "Software"), to deal
30
- * in the Software without restriction, including without limitation the rights
31
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
32
- * copies of the Software, and to permit persons to whom the Software is
33
- * furnished to do so, subject to the following conditions:
34
- *
35
- * The above copyright notice and this permission notice shall be included in all
36
- * copies or substantial portions of the Software.
37
- *
38
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
39
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
40
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
41
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
42
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44
- * SOFTWARE.
45
- */
46
- function parseLocaleDate(dateString = '', locale, timeZone) {
47
- // This function may seem complicated but it basically does one thing:
48
- // Given a dateString, a locale and a timeZone. The dateString is assumed to be formatted according
49
- // to the locale. So if the locale is `en-us` the dateString is expected to be in the format of M/D/YYYY.
50
- // The dateString is also assumed to be in the given timeZone, so "1/1/2020" in "America/Los_Angeles" timezone is
51
- // expected to be "2020-01-01T08:00:00.000Z" in UTC time.
52
- // This function tries to parse the dateString taking these variables into account and return a javascript Date object
53
- // that is adjusted to be in UTC.
54
-
55
- // Split string on '.', whitespace, '/', ',' or '-' using regex: /[.\s/.-]+/.
56
- // The '+' allows splitting on consecutive delimiters.
57
- // `.filter(Boolean)` is needed because some locales have a delimeter at the end (e.g.: hungarian dates are formatted as `2024. 09. 19.`)
58
- const splitDate = dateString.split(/[,.\s/.-]+/).filter(Boolean);
59
-
60
- // create a locale formatted new date to later extract the order and delimeter information
61
- const localeDate = new Intl.DateTimeFormat(locale).formatToParts(new Date());
62
- let index = 0;
63
- let day, month, year;
64
- localeDate.forEach(part => {
65
- if (part.type === 'month') {
66
- month = parseInt(splitDate[index], 10);
67
- index++;
68
- } else if (part.type === 'day') {
69
- day = parseInt(splitDate[index], 10);
70
- index++;
71
- } else if (part.type === 'year') {
72
- year = parseInt(splitDate[index], 10);
73
- index++;
74
- }
75
- });
76
-
77
- // sensible limitations
78
- if (!year || !month || !day || year < 1000 || year > 9999) return null;
79
-
80
- // create utc date from year, month (zero indexed) and day
81
- const date = new Date(Date.UTC(year, month - 1, day));
82
-
83
- // Format date string in the provided timezone. The locale here is irrelevant, we only care about how to time is adjusted for the timezone.
84
- const parts = new Intl.DateTimeFormat('en-US', {
85
- timeZone,
86
- year: 'numeric',
87
- month: '2-digit',
88
- day: '2-digit',
89
- hour: '2-digit',
90
- minute: '2-digit',
91
- second: '2-digit',
92
- hour12: false
93
- }).formatToParts(date);
94
-
95
- // Extract the date and time parts from the formatted string
96
- const dateStringInTimezone = parts.reduce((acc, part) => {
97
- return part.type === 'literal' ? acc : {
98
- ...acc,
99
- [part.type]: part.value
100
- };
101
- }, {});
102
-
103
- // Create a date string in the format 'YYYY-MM-DDTHH:mm:ss'
104
- const dateInTimezone = `${dateStringInTimezone.year}-${dateStringInTimezone.month}-${dateStringInTimezone.day}T${dateStringInTimezone.hour}:${dateStringInTimezone.minute}:${dateStringInTimezone.second}`;
105
-
106
- // Calculate time difference for timezone offset
107
- const timeDiff = new Date(dateInTimezone + 'Z').getTime() - date.getTime();
108
- const utcTime = new Date(date.getTime() - timeDiff);
109
- // Return the UTC Date corresponding to the time in the specified timezone
110
- return utcTime;
111
- }
112
-
113
- /**
114
- ---
115
- category: components
116
- ---
117
- **/
118
- const DateInput2 = exports.DateInput2 = /*#__PURE__*/(0, _react.forwardRef)(({
119
- renderLabel,
120
- screenReaderLabels,
121
- isRequired = false,
122
- interaction = 'enabled',
123
- isInline = false,
124
- value,
125
- messages,
126
- width,
127
- onChange,
128
- onBlur,
129
- withYearPicker,
130
- invalidDateErrorMessage,
131
- locale,
132
- timezone,
133
- placeholder,
134
- dateFormat,
135
- onRequestValidateDate,
136
- disabledDates,
137
- renderCalendarIcon,
138
- margin,
139
- inputRef,
140
- ...rest
141
- }, ref) => {
142
- const userLocale = locale || (0, _getLocale.getLocale)();
143
- const userTimezone = timezone || (0, _getTimezone.getTimezone)();
144
- const _useState = (0, _react.useState)(messages || []),
145
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
146
- inputMessages = _useState2[0],
147
- setInputMessages = _useState2[1];
148
- const _useState3 = (0, _react.useState)(false),
149
- _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
150
- showPopover = _useState4[0],
151
- setShowPopover = _useState4[1];
152
- (0, _react.useEffect)(() => {
153
- // don't set input messages if there is an internal error set already
154
- if (inputMessages.find(m => m.text === invalidDateErrorMessage)) return;
155
- setInputMessages(messages || []);
156
- }, [messages]);
157
- (0, _react.useEffect)(() => {
158
- const _parseDate = parseDate(value),
159
- _parseDate2 = (0, _slicedToArray2.default)(_parseDate, 2),
160
- utcIsoDate = _parseDate2[1];
161
- // clear error messages if date becomes valid
162
- if (utcIsoDate || !value) {
163
- setInputMessages(messages || []);
164
- }
165
- }, [value]);
166
- const parseDate = (dateString = '') => {
167
- let date = null;
168
- if (dateFormat) {
169
- if (typeof dateFormat === 'string') {
170
- // use dateFormat instead of the user locale
171
- date = parseLocaleDate(dateString, dateFormat, userTimezone);
172
- } else if (dateFormat.parser) {
173
- date = dateFormat.parser(dateString);
174
- }
175
- } else {
176
- // no dateFormat prop passed, use locale for formatting
177
- date = parseLocaleDate(dateString, userLocale, userTimezone);
178
- }
179
- return date ? [formatDate(date), date.toISOString()] : ['', ''];
180
- };
181
- const formatDate = (date, timeZone = userTimezone) => {
182
- // use formatter function if provided
183
- if (typeof dateFormat !== 'string' && dateFormat !== null && dateFormat !== void 0 && dateFormat.formatter) {
184
- return dateFormat.formatter(date);
185
- }
186
- // if dateFormat set to a locale, use that, otherwise default to the user's locale
187
- return date.toLocaleDateString(typeof dateFormat === 'string' ? dateFormat : userLocale, {
188
- timeZone,
189
- calendar: 'gregory',
190
- numberingSystem: 'latn'
191
- });
192
- };
193
- const getDateFormatHint = () => {
194
- const exampleDate = new Date('2024-09-01');
195
- const formattedDate = formatDate(exampleDate, 'UTC'); // exampleDate is in UTC so format it as such
196
-
197
- // Create a regular expression to find the exact match of the number
198
- const regex = n => {
199
- return new RegExp(`(?<!\\d)0*${n}(?!\\d)`, 'g');
200
- };
201
-
202
- // Replace the matched number with the same number of dashes
203
- const year = '2024';
204
- const month = '9';
205
- const day = '1';
206
- return formattedDate.replace(regex(year), match => 'Y'.repeat(match.length)).replace(regex(month), match => 'M'.repeat(match.length)).replace(regex(day), match => 'D'.repeat(match.length));
207
- };
208
- const handleInputChange = (e, newValue) => {
209
- const _parseDate3 = parseDate(newValue),
210
- _parseDate4 = (0, _slicedToArray2.default)(_parseDate3, 2),
211
- utcIsoDate = _parseDate4[1];
212
- onChange === null || onChange === void 0 ? void 0 : onChange(e, newValue, utcIsoDate);
213
- };
214
- const handleDateSelected = (dateString, _momentDate, e) => {
215
- setShowPopover(false);
216
- const newValue = formatDate(new Date(dateString));
217
- onChange === null || onChange === void 0 ? void 0 : onChange(e, newValue, dateString);
218
- onRequestValidateDate === null || onRequestValidateDate === void 0 ? void 0 : onRequestValidateDate(e, newValue, dateString);
219
- };
220
- const handleBlur = e => {
221
- const _parseDate5 = parseDate(value),
222
- _parseDate6 = (0, _slicedToArray2.default)(_parseDate5, 2),
223
- localeDate = _parseDate6[0],
224
- utcIsoDate = _parseDate6[1];
225
- if (localeDate) {
226
- if (localeDate !== value) {
227
- onChange === null || onChange === void 0 ? void 0 : onChange(e, localeDate, utcIsoDate);
228
- }
229
- } else if (value && invalidDateErrorMessage) {
230
- setInputMessages([{
231
- type: 'error',
232
- text: invalidDateErrorMessage
233
- }]);
234
- }
235
- onRequestValidateDate === null || onRequestValidateDate === void 0 ? void 0 : onRequestValidateDate(e, value || '', utcIsoDate);
236
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(e, value || '', utcIsoDate);
237
- };
238
- const selectedDate = parseDate(value)[1];
239
- return (0, _jsxRuntime.jsx)(_TextInput.TextInput, {
240
- ...(0, _passthroughProps.passthroughProps)(rest),
241
- ref: ref,
242
- inputRef: inputRef,
243
- renderLabel: renderLabel,
244
- onChange: handleInputChange,
245
- onBlur: handleBlur,
246
- isRequired: isRequired,
247
- value: value,
248
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : getDateFormatHint(),
249
- width: width,
250
- display: isInline ? 'inline-block' : 'block',
251
- messages: inputMessages,
252
- interaction: interaction,
253
- margin: margin,
254
- renderAfterInput: (0, _jsxRuntime.jsx)(_Popover.Popover, {
255
- renderTrigger: (0, _jsxRuntime.jsx)(_IconButton.IconButton, {
256
- withBackground: false,
257
- withBorder: false,
258
- screenReaderLabel: screenReaderLabels.calendarIcon,
259
- interaction: interaction,
260
- children: renderCalendarIcon ? (0, _callRenderProp.callRenderProp)(renderCalendarIcon) : _IconCalendarMonthLin || (_IconCalendarMonthLin = (0, _jsxRuntime.jsx)(_IconCalendarMonthLine.IconCalendarMonthLine, {}))
261
- }),
262
- isShowingContent: showPopover,
263
- onShowContent: () => setShowPopover(true),
264
- onHideContent: () => setShowPopover(false),
265
- on: "click",
266
- shouldContainFocus: true,
267
- shouldReturnFocus: true,
268
- shouldCloseOnDocumentClick: true,
269
- screenReaderLabel: screenReaderLabels.datePickerDialog,
270
- children: (0, _jsxRuntime.jsx)(_Calendar.Calendar, {
271
- withYearPicker: withYearPicker,
272
- onDateSelected: handleDateSelected,
273
- selectedDate: selectedDate,
274
- disabledDates: disabledDates,
275
- visibleMonth: selectedDate,
276
- locale: userLocale,
277
- timezone: userTimezone,
278
- renderNextMonthButton: (0, _jsxRuntime.jsx)(_IconButton.IconButton, {
279
- size: "small",
280
- withBackground: false,
281
- withBorder: false,
282
- renderIcon: _IconArrowOpenEndSoli || (_IconArrowOpenEndSoli = (0, _jsxRuntime.jsx)(_IconArrowOpenEndSolid.IconArrowOpenEndSolid, {
283
- color: "primary"
284
- })),
285
- screenReaderLabel: screenReaderLabels.nextMonthButton
286
- }),
287
- renderPrevMonthButton: (0, _jsxRuntime.jsx)(_IconButton.IconButton, {
288
- size: "small",
289
- withBackground: false,
290
- withBorder: false,
291
- renderIcon: _IconArrowOpenStartSo || (_IconArrowOpenStartSo = (0, _jsxRuntime.jsx)(_IconArrowOpenStartSolid.IconArrowOpenStartSolid, {
292
- color: "primary"
293
- })),
294
- screenReaderLabel: screenReaderLabels.prevMonthButton
295
- })
296
- })
297
- })
298
- });
299
- });
300
-
301
- // TODO this is probably needed?
302
- DateInput2.displayName = 'DateInput2';
303
- var _default = exports.default = DateInput2;
@@ -1,5 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
package/lib/index.js DELETED
@@ -1,19 +0,0 @@
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 _DateInput.DateInput;
10
- }
11
- });
12
- Object.defineProperty(exports, "DateInput2", {
13
- enumerable: true,
14
- get: function () {
15
- return _DateInput2.DateInput2;
16
- }
17
- });
18
- var _DateInput = require("./DateInput");
19
- var _DateInput2 = require("./DateInput2");
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}