@terraware/web-components 2.12.9-rc.1 → 2.12.9-rc.3
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.
@@ -2,7 +2,13 @@ import React, { KeyboardEventHandler } from 'react';
|
|
2
2
|
import { DateTime } from 'luxon';
|
3
3
|
import './styles.scss';
|
4
4
|
import { DateType } from '../../utils/date';
|
5
|
-
|
5
|
+
/**
|
6
|
+
* TODO: remove support for JS Date in DatePickerDateType once
|
7
|
+
* clients have moved to only using DateTime objects in input props
|
8
|
+
* and callback arguments.
|
9
|
+
* export type DatePickerDateType = Exclude<DateType, Date> | null;
|
10
|
+
*/
|
11
|
+
export type DatePickerDateType = DateType | null;
|
6
12
|
export interface Props {
|
7
13
|
'aria-label': string;
|
8
14
|
autoFocus?: boolean;
|
@@ -16,7 +22,17 @@ export interface Props {
|
|
16
22
|
locale?: string;
|
17
23
|
maxDate?: DatePickerDateType;
|
18
24
|
minDate?: DatePickerDateType;
|
19
|
-
|
25
|
+
/**
|
26
|
+
* @deprecated Use onDateChange and switch to
|
27
|
+
* handling luxon DateTime arguments.
|
28
|
+
*/
|
29
|
+
onChange: (value?: Date | null) => void;
|
30
|
+
/**
|
31
|
+
* TODO: remove deprecated onChange and
|
32
|
+
* make onDateChange required once all clients
|
33
|
+
* have migrated to using onDateChange.
|
34
|
+
*/
|
35
|
+
onDateChange?: (value?: DateTime) => void;
|
20
36
|
onError?: (reason: any, value: any) => void;
|
21
37
|
onKeyPress?: KeyboardEventHandler;
|
22
38
|
value?: DatePickerDateType;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DatePicker/DatePicker.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAY,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAI9D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,OAAO,eAAe,CAAC;AACvB,O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AAkB,CAAC;CAC5B;AAYD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAqE5D"}
|
@@ -15,15 +15,19 @@ var _AdapterLuxon = require("@mui/x-date-pickers/AdapterLuxon");
|
|
15
15
|
var _Icon = _interopRequireDefault(require("../Icon/Icon"));
|
16
16
|
require("./styles.scss");
|
17
17
|
var _date = require("../../utils/date");
|
18
|
+
/**
|
19
|
+
* TODO: remove support for JS Date in DatePickerDateType once
|
20
|
+
* clients have moved to only using DateTime objects in input props
|
21
|
+
* and callback arguments.
|
22
|
+
* export type DatePickerDateType = Exclude<DateType, Date> | null;
|
23
|
+
*/
|
24
|
+
|
18
25
|
var initializeDate = function initializeDate(value, defaultTimeZone) {
|
19
26
|
if (!value) {
|
20
27
|
return null;
|
21
28
|
}
|
22
|
-
|
23
|
-
|
24
|
-
return date !== null && date !== void 0 && date.isValid ? date : null;
|
25
|
-
}
|
26
|
-
return value;
|
29
|
+
var date = (0, _date.getDate)(value, defaultTimeZone);
|
30
|
+
return date !== null && date !== void 0 && date.isValid ? date : null;
|
27
31
|
};
|
28
32
|
function DatePicker(props) {
|
29
33
|
var _props$locale;
|
@@ -80,7 +84,11 @@ function DatePicker(props) {
|
|
80
84
|
maxDate: initializeDate(props.maxDate, props.defaultTimeZone) || undefined,
|
81
85
|
onChange: function onChange(newValue) {
|
82
86
|
setTemporalValue(newValue);
|
83
|
-
|
87
|
+
// TODO: remove onChange and make onDateChange required
|
88
|
+
props.onChange(newValue && newValue.isValid ? newValue.toJSDate() : null);
|
89
|
+
if (props.onDateChange) {
|
90
|
+
props.onDateChange(newValue && newValue.isValid ? newValue : undefined);
|
91
|
+
}
|
84
92
|
},
|
85
93
|
onError: props.onError,
|
86
94
|
renderInput: renderInput,
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"DatePicker.stories.d.ts","sourceRoot":"","sources":["../../src/stories/DatePicker.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AACtD,OAAO,UAAU,EAAE,EAAsB,KAAK,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;;;;yBAOnG,OAAO,MAAM,SAAS,KAAG,YAAY;;AAJjD,wBAQE;
|
1
|
+
{"version":3,"file":"DatePicker.stories.d.ts","sourceRoot":"","sources":["../../src/stories/DatePicker.stories.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AACtD,OAAO,UAAU,EAAE,EAAsB,KAAK,IAAI,eAAe,EAAE,MAAM,qCAAqC,CAAC;;;;yBAOnG,OAAO,MAAM,SAAS,KAAG,YAAY;;AAJjD,wBAQE;AA4BF,eAAO,MAAM,OAAO,gHAAoB,CAAC;AAczC,eAAO,MAAM,0BAA0B,gHAAoB,CAAC;AAe5D,eAAO,MAAM,qBAAqB,gHAAoB,CAAC;AAevD,eAAO,MAAM,2BAA2B,gHAAoB,CAAC;AAe7D,eAAO,MAAM,yBAAyB,gHAAoB,CAAC"}
|