@instructure/ui-date-input 8.56.2 → 8.56.4

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,26 @@
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
+ ## [8.56.4](https://github.com/instructure/instructure-ui/compare/v8.56.3...v8.56.4) (2024-10-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-calendar,ui-date-input:** fix locale and timezone for simple api ([94209df](https://github.com/instructure/instructure-ui/commit/94209dfdfaeca8c8ae452771c4bf2688e6345272))
12
+ * **ui-date-input:** fix date format and validation when locale isn't us english ([67e6d1f](https://github.com/instructure/instructure-ui/commit/67e6d1fb4aedda60ab430b69e14a0c93ac57f2bc))
13
+
14
+
15
+
16
+
17
+
18
+ ## [8.56.3](https://github.com/instructure/instructure-ui/compare/v8.56.2...v8.56.3) (2024-09-18)
19
+
20
+ **Note:** Version bump only for package @instructure/ui-date-input
21
+
22
+
23
+
24
+
25
+
6
26
  ## [8.56.2](https://github.com/instructure/instructure-ui/compare/v8.56.1...v8.56.2) (2024-08-06)
7
27
 
8
28
  **Note:** Version bump only for package @instructure/ui-date-input
@@ -588,5 +588,27 @@ describe('<DateInput />', () => {
588
588
  expect(calendarDays).toHaveLength(42);
589
589
  });
590
590
  });
591
+ it('should change weekdays according to locale', async () => {
592
+ const onChange = jest.fn();
593
+ render( /*#__PURE__*/React.createElement(DateInput, {
594
+ renderLabel: "Choose date",
595
+ assistiveText: "Type a date or use arrow keys to navigate date picker.",
596
+ width: "20rem",
597
+ isInline: true,
598
+ value: '2023-11-23',
599
+ onChange: onChange,
600
+ currentDate: "2023-12-23",
601
+ disabledDates: ['2023-12-22', '2023-12-12', '2023-12-11'],
602
+ disabledDateErrorMessage: "disabled date",
603
+ invalidDateErrorMessage: "invalid date",
604
+ locale: "fr"
605
+ }));
606
+ const dateInput = screen.getByLabelText('Choose date');
607
+ fireEvent.click(dateInput);
608
+ const frenchMonday = screen.getByText('lu');
609
+ await waitFor(() => {
610
+ expect(typeof frenchMonday).toBe('object');
611
+ });
612
+ });
591
613
  });
592
614
  });
@@ -153,7 +153,7 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
153
153
  } else {
154
154
  // @ts-expect-error TODO
155
155
  onChange(event, {
156
- value: DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('MMMM D, YYYY')
156
+ value: DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('LL')
157
157
  });
158
158
  this.setState({
159
159
  messages: []
@@ -166,7 +166,7 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
166
166
  } else {
167
167
  // @ts-expect-error TODO
168
168
  onChange(event, {
169
- value: DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('MMMM D, YYYY')
169
+ value: DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('LL')
170
170
  });
171
171
  this.setState({
172
172
  messages: []
@@ -261,6 +261,8 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
261
261
  currentDate = _this$props11.currentDate;
262
262
  const isValidDate = value ? DateTime.parse(value, this.locale(), this.timezone()).isValid() : false;
263
263
  const noChildrenProps = this.props.children ? {} : {
264
+ timezone: this.timezone(),
265
+ locale: this.locale(),
264
266
  disabledDates,
265
267
  currentDate,
266
268
  selectedDate: isValidDate ? value : void 0,
@@ -268,7 +270,7 @@ let DateInput = (_dec = withStyle(generateStyle, null), _dec2 = testable(), _dec
268
270
  onDateSelected: (dateString, momentDate, e) => {
269
271
  // @ts-expect-error TODO
270
272
  onChange === null || onChange === void 0 ? void 0 : onChange(e, {
271
- value: `${momentDate.format('MMMM')} ${momentDate.format('D')}, ${momentDate.format('YYYY')}`
273
+ value: momentDate.format('LL')
272
274
  });
273
275
  this.handleHideCalendar(e, dateString);
274
276
  }
@@ -590,5 +590,27 @@ describe('<DateInput />', () => {
590
590
  expect(calendarDays).toHaveLength(42);
591
591
  });
592
592
  });
593
+ it('should change weekdays according to locale', async () => {
594
+ const onChange = jest.fn();
595
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DateInput, {
596
+ renderLabel: "Choose date",
597
+ assistiveText: "Type a date or use arrow keys to navigate date picker.",
598
+ width: "20rem",
599
+ isInline: true,
600
+ value: '2023-11-23',
601
+ onChange: onChange,
602
+ currentDate: "2023-12-23",
603
+ disabledDates: ['2023-12-22', '2023-12-12', '2023-12-11'],
604
+ disabledDateErrorMessage: "disabled date",
605
+ invalidDateErrorMessage: "invalid date",
606
+ locale: "fr"
607
+ }));
608
+ const dateInput = _react2.screen.getByLabelText('Choose date');
609
+ _react2.fireEvent.click(dateInput);
610
+ const frenchMonday = _react2.screen.getByText('lu');
611
+ await (0, _react2.waitFor)(() => {
612
+ expect(typeof frenchMonday).toBe('object');
613
+ });
614
+ });
593
615
  });
594
616
  });
@@ -164,7 +164,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
164
164
  } else {
165
165
  // @ts-expect-error TODO
166
166
  onChange(event, {
167
- value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('MMMM D, YYYY')
167
+ value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).subtract(1, 'day').format('LL')
168
168
  });
169
169
  this.setState({
170
170
  messages: []
@@ -177,7 +177,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
177
177
  } else {
178
178
  // @ts-expect-error TODO
179
179
  onChange(event, {
180
- value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('MMMM D, YYYY')
180
+ value: _DateTime.DateTime.parse(isValueValid ? value : currentDate, this.locale(), this.timezone()).add(1, 'day').format('LL')
181
181
  });
182
182
  this.setState({
183
183
  messages: []
@@ -272,6 +272,8 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
272
272
  currentDate = _this$props11.currentDate;
273
273
  const isValidDate = value ? _DateTime.DateTime.parse(value, this.locale(), this.timezone()).isValid() : false;
274
274
  const noChildrenProps = this.props.children ? {} : {
275
+ timezone: this.timezone(),
276
+ locale: this.locale(),
275
277
  disabledDates,
276
278
  currentDate,
277
279
  selectedDate: isValidDate ? value : void 0,
@@ -279,7 +281,7 @@ let DateInput = exports.DateInput = (_dec = (0, _emotion.withStyle)(_styles.defa
279
281
  onDateSelected: (dateString, momentDate, e) => {
280
282
  // @ts-expect-error TODO
281
283
  onChange === null || onChange === void 0 ? void 0 : onChange(e, {
282
- value: `${momentDate.format('MMMM')} ${momentDate.format('D')}, ${momentDate.format('YYYY')}`
284
+ value: momentDate.format('LL')
283
285
  });
284
286
  this.handleHideCalendar(e, dateString);
285
287
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-date-input",
3
- "version": "8.56.2",
3
+ "version": "8.56.4",
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,29 +23,29 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-axe-check": "8.56.2",
27
- "@instructure/ui-babel-preset": "8.56.2",
28
- "@instructure/ui-scripts": "8.56.2",
29
- "@instructure/ui-test-utils": "8.56.2",
26
+ "@instructure/ui-axe-check": "8.56.4",
27
+ "@instructure/ui-babel-preset": "8.56.4",
28
+ "@instructure/ui-scripts": "8.56.4",
29
+ "@instructure/ui-test-utils": "8.56.4",
30
30
  "@testing-library/jest-dom": "^6.1.4",
31
31
  "@testing-library/react": "^14.1.2",
32
32
  "@testing-library/user-event": "^14.5.1"
33
33
  },
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.23.2",
36
- "@instructure/emotion": "8.56.2",
37
- "@instructure/ui-calendar": "8.56.2",
38
- "@instructure/ui-form-field": "8.56.2",
39
- "@instructure/ui-i18n": "8.56.2",
40
- "@instructure/ui-icons": "8.56.2",
41
- "@instructure/ui-popover": "8.56.2",
42
- "@instructure/ui-position": "8.56.2",
43
- "@instructure/ui-prop-types": "8.56.2",
44
- "@instructure/ui-react-utils": "8.56.2",
45
- "@instructure/ui-selectable": "8.56.2",
46
- "@instructure/ui-testable": "8.56.2",
47
- "@instructure/ui-text-input": "8.56.2",
48
- "@instructure/ui-utils": "8.56.2",
36
+ "@instructure/emotion": "8.56.4",
37
+ "@instructure/ui-calendar": "8.56.4",
38
+ "@instructure/ui-form-field": "8.56.4",
39
+ "@instructure/ui-i18n": "8.56.4",
40
+ "@instructure/ui-icons": "8.56.4",
41
+ "@instructure/ui-popover": "8.56.4",
42
+ "@instructure/ui-position": "8.56.4",
43
+ "@instructure/ui-prop-types": "8.56.4",
44
+ "@instructure/ui-react-utils": "8.56.4",
45
+ "@instructure/ui-selectable": "8.56.4",
46
+ "@instructure/ui-testable": "8.56.4",
47
+ "@instructure/ui-text-input": "8.56.4",
48
+ "@instructure/ui-utils": "8.56.4",
49
49
  "prop-types": "^15.8.1"
50
50
  },
51
51
  "peerDependencies": {
@@ -842,5 +842,31 @@ describe('<DateInput />', () => {
842
842
  expect(calendarDays).toHaveLength(42)
843
843
  })
844
844
  })
845
+ it('should change weekdays according to locale', async () => {
846
+ const onChange = jest.fn()
847
+ render(
848
+ <DateInput
849
+ renderLabel="Choose date"
850
+ assistiveText="Type a date or use arrow keys to navigate date picker."
851
+ width="20rem"
852
+ isInline
853
+ value={'2023-11-23'}
854
+ onChange={onChange}
855
+ currentDate="2023-12-23"
856
+ disabledDates={['2023-12-22', '2023-12-12', '2023-12-11']}
857
+ disabledDateErrorMessage="disabled date"
858
+ invalidDateErrorMessage="invalid date"
859
+ locale="fr"
860
+ ></DateInput>
861
+ )
862
+ const dateInput = screen.getByLabelText('Choose date')
863
+
864
+ fireEvent.click(dateInput)
865
+
866
+ const frenchMonday = screen.getByText('lu')
867
+ await waitFor(() => {
868
+ expect(typeof frenchMonday).toBe('object')
869
+ })
870
+ })
845
871
  })
846
872
  })
@@ -265,7 +265,7 @@ class DateInput extends Component<DateInputProps, DateInputState> {
265
265
  this.timezone()
266
266
  )
267
267
  .subtract(1, 'day')
268
- .format('MMMM D, YYYY')
268
+ .format('LL')
269
269
  })
270
270
  this.setState({ messages: [] })
271
271
  }
@@ -282,7 +282,7 @@ class DateInput extends Component<DateInputProps, DateInputState> {
282
282
  this.timezone()
283
283
  )
284
284
  .add(1, 'day')
285
- .format('MMMM D, YYYY')
285
+ .format('LL')
286
286
  })
287
287
  this.setState({ messages: [] })
288
288
  }
@@ -341,6 +341,8 @@ class DateInput extends Component<DateInputProps, DateInputState> {
341
341
  const noChildrenProps = this.props.children
342
342
  ? {}
343
343
  : {
344
+ timezone: this.timezone(),
345
+ locale: this.locale(),
344
346
  disabledDates,
345
347
  currentDate,
346
348
  selectedDate: isValidDate ? value : undefined,
@@ -352,9 +354,7 @@ class DateInput extends Component<DateInputProps, DateInputState> {
352
354
  ) => {
353
355
  // @ts-expect-error TODO
354
356
  onChange?.(e, {
355
- value: `${momentDate.format('MMMM')} ${momentDate.format(
356
- 'D'
357
- )}, ${momentDate.format('YYYY')}`
357
+ value: momentDate.format('LL')
358
358
  })
359
359
  this.handleHideCalendar(e, dateString)
360
360
  }