@instructure/ui-date-input 10.16.4-snapshot-5 → 10.16.4-snapshot-7
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,9 +3,12 @@
|
|
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.16.4-snapshot-
|
6
|
+
## [10.16.4-snapshot-7](https://github.com/instructure/instructure-ui/compare/v10.16.3...v10.16.4-snapshot-7) (2025-05-09)
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* **ui-date-input:** correctly format the DateInput2 placeholder in every timezone ([f8229df](https://github.com/instructure/instructure-ui/commit/f8229df71ae6ad67fc089f7e1ff143842d7a0979))
|
9
12
|
|
10
13
|
|
11
14
|
|
package/es/DateInput2/index.js
CHANGED
@@ -191,21 +191,21 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
|
|
191
191
|
}
|
192
192
|
return date ? [formatDate(date), date.toISOString()] : ['', ''];
|
193
193
|
};
|
194
|
-
const formatDate = date => {
|
194
|
+
const formatDate = (date, timeZone = getTimezone()) => {
|
195
195
|
// use formatter function if provided
|
196
196
|
if (typeof dateFormat !== 'string' && dateFormat !== null && dateFormat !== void 0 && dateFormat.formatter) {
|
197
197
|
return dateFormat.formatter(date);
|
198
198
|
}
|
199
199
|
// if dateFormat set to a locale, use that, otherwise default to the user's locale
|
200
200
|
return date.toLocaleDateString(typeof dateFormat === 'string' ? dateFormat : getLocale(), {
|
201
|
-
timeZone
|
201
|
+
timeZone,
|
202
202
|
calendar: 'gregory',
|
203
203
|
numberingSystem: 'latn'
|
204
204
|
});
|
205
205
|
};
|
206
|
-
const
|
206
|
+
const getDateFormatHint = () => {
|
207
207
|
const exampleDate = new Date('2024-09-01');
|
208
|
-
const formattedDate = formatDate(exampleDate);
|
208
|
+
const formattedDate = formatDate(exampleDate, 'UTC'); // exampleDate is in UTC so format it as such
|
209
209
|
|
210
210
|
// Create a regular expression to find the exact match of the number
|
211
211
|
const regex = n => {
|
@@ -258,7 +258,7 @@ const DateInput2 = /*#__PURE__*/forwardRef(({
|
|
258
258
|
onBlur: handleBlur,
|
259
259
|
isRequired: isRequired,
|
260
260
|
value: value,
|
261
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder :
|
261
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : getDateFormatHint(),
|
262
262
|
width: width,
|
263
263
|
display: isInline ? 'inline-block' : 'block',
|
264
264
|
messages: inputMessages,
|
package/lib/DateInput2/index.js
CHANGED
@@ -201,21 +201,21 @@ const DateInput2 = exports.DateInput2 = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
201
201
|
}
|
202
202
|
return date ? [formatDate(date), date.toISOString()] : ['', ''];
|
203
203
|
};
|
204
|
-
const formatDate = date => {
|
204
|
+
const formatDate = (date, timeZone = getTimezone()) => {
|
205
205
|
// use formatter function if provided
|
206
206
|
if (typeof dateFormat !== 'string' && dateFormat !== null && dateFormat !== void 0 && dateFormat.formatter) {
|
207
207
|
return dateFormat.formatter(date);
|
208
208
|
}
|
209
209
|
// if dateFormat set to a locale, use that, otherwise default to the user's locale
|
210
210
|
return date.toLocaleDateString(typeof dateFormat === 'string' ? dateFormat : getLocale(), {
|
211
|
-
timeZone
|
211
|
+
timeZone,
|
212
212
|
calendar: 'gregory',
|
213
213
|
numberingSystem: 'latn'
|
214
214
|
});
|
215
215
|
};
|
216
|
-
const
|
216
|
+
const getDateFormatHint = () => {
|
217
217
|
const exampleDate = new Date('2024-09-01');
|
218
|
-
const formattedDate = formatDate(exampleDate);
|
218
|
+
const formattedDate = formatDate(exampleDate, 'UTC'); // exampleDate is in UTC so format it as such
|
219
219
|
|
220
220
|
// Create a regular expression to find the exact match of the number
|
221
221
|
const regex = n => {
|
@@ -268,7 +268,7 @@ const DateInput2 = exports.DateInput2 = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
268
268
|
onBlur: handleBlur,
|
269
269
|
isRequired: isRequired,
|
270
270
|
value: value,
|
271
|
-
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder :
|
271
|
+
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : getDateFormatHint(),
|
272
272
|
width: width,
|
273
273
|
display: isInline ? 'inline-block' : 'block',
|
274
274
|
messages: inputMessages,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@instructure/ui-date-input",
|
3
|
-
"version": "10.16.4-snapshot-
|
3
|
+
"version": "10.16.4-snapshot-7",
|
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.16.4-snapshot-
|
27
|
-
"@instructure/ui-babel-preset": "10.16.4-snapshot-
|
28
|
-
"@instructure/ui-buttons": "10.16.4-snapshot-
|
29
|
-
"@instructure/ui-scripts": "10.16.4-snapshot-
|
30
|
-
"@instructure/ui-test-utils": "10.16.4-snapshot-
|
26
|
+
"@instructure/ui-axe-check": "10.16.4-snapshot-7",
|
27
|
+
"@instructure/ui-babel-preset": "10.16.4-snapshot-7",
|
28
|
+
"@instructure/ui-buttons": "10.16.4-snapshot-7",
|
29
|
+
"@instructure/ui-scripts": "10.16.4-snapshot-7",
|
30
|
+
"@instructure/ui-test-utils": "10.16.4-snapshot-7",
|
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.16.4-snapshot-
|
39
|
-
"@instructure/shared-types": "10.16.4-snapshot-
|
40
|
-
"@instructure/ui-calendar": "10.16.4-snapshot-
|
41
|
-
"@instructure/ui-form-field": "10.16.4-snapshot-
|
42
|
-
"@instructure/ui-i18n": "10.16.4-snapshot-
|
43
|
-
"@instructure/ui-icons": "10.16.4-snapshot-
|
44
|
-
"@instructure/ui-popover": "10.16.4-snapshot-
|
45
|
-
"@instructure/ui-position": "10.16.4-snapshot-
|
46
|
-
"@instructure/ui-prop-types": "10.16.4-snapshot-
|
47
|
-
"@instructure/ui-react-utils": "10.16.4-snapshot-
|
48
|
-
"@instructure/ui-selectable": "10.16.4-snapshot-
|
49
|
-
"@instructure/ui-testable": "10.16.4-snapshot-
|
50
|
-
"@instructure/ui-text-input": "10.16.4-snapshot-
|
51
|
-
"@instructure/ui-utils": "10.16.4-snapshot-
|
38
|
+
"@instructure/emotion": "10.16.4-snapshot-7",
|
39
|
+
"@instructure/shared-types": "10.16.4-snapshot-7",
|
40
|
+
"@instructure/ui-calendar": "10.16.4-snapshot-7",
|
41
|
+
"@instructure/ui-form-field": "10.16.4-snapshot-7",
|
42
|
+
"@instructure/ui-i18n": "10.16.4-snapshot-7",
|
43
|
+
"@instructure/ui-icons": "10.16.4-snapshot-7",
|
44
|
+
"@instructure/ui-popover": "10.16.4-snapshot-7",
|
45
|
+
"@instructure/ui-position": "10.16.4-snapshot-7",
|
46
|
+
"@instructure/ui-prop-types": "10.16.4-snapshot-7",
|
47
|
+
"@instructure/ui-react-utils": "10.16.4-snapshot-7",
|
48
|
+
"@instructure/ui-selectable": "10.16.4-snapshot-7",
|
49
|
+
"@instructure/ui-testable": "10.16.4-snapshot-7",
|
50
|
+
"@instructure/ui-text-input": "10.16.4-snapshot-7",
|
51
|
+
"@instructure/ui-utils": "10.16.4-snapshot-7",
|
52
52
|
"moment-timezone": "^0.5.45",
|
53
53
|
"prop-types": "^15.8.1"
|
54
54
|
},
|
package/src/DateInput2/index.tsx
CHANGED
@@ -224,7 +224,10 @@ const DateInput2 = forwardRef(
|
|
224
224
|
return date ? [formatDate(date), date.toISOString()] : ['', '']
|
225
225
|
}
|
226
226
|
|
227
|
-
const formatDate = (
|
227
|
+
const formatDate = (
|
228
|
+
date: Date,
|
229
|
+
timeZone: string = getTimezone()
|
230
|
+
): string => {
|
228
231
|
// use formatter function if provided
|
229
232
|
if (typeof dateFormat !== 'string' && dateFormat?.formatter) {
|
230
233
|
return dateFormat.formatter(date)
|
@@ -233,16 +236,16 @@ const DateInput2 = forwardRef(
|
|
233
236
|
return date.toLocaleDateString(
|
234
237
|
typeof dateFormat === 'string' ? dateFormat : getLocale(),
|
235
238
|
{
|
236
|
-
timeZone
|
239
|
+
timeZone,
|
237
240
|
calendar: 'gregory',
|
238
241
|
numberingSystem: 'latn'
|
239
242
|
}
|
240
243
|
)
|
241
244
|
}
|
242
245
|
|
243
|
-
const
|
246
|
+
const getDateFormatHint = () => {
|
244
247
|
const exampleDate = new Date('2024-09-01')
|
245
|
-
const formattedDate = formatDate(exampleDate)
|
248
|
+
const formattedDate = formatDate(exampleDate, 'UTC') // exampleDate is in UTC so format it as such
|
246
249
|
|
247
250
|
// Create a regular expression to find the exact match of the number
|
248
251
|
const regex = (n: string) => {
|
@@ -300,7 +303,7 @@ const DateInput2 = forwardRef(
|
|
300
303
|
onBlur={handleBlur}
|
301
304
|
isRequired={isRequired}
|
302
305
|
value={value}
|
303
|
-
placeholder={placeholder ??
|
306
|
+
placeholder={placeholder ?? getDateFormatHint()}
|
304
307
|
width={width}
|
305
308
|
display={isInline ? 'inline-block' : 'block'}
|
306
309
|
messages={inputMessages}
|