@khanacademy/wonder-blocks-birthday-picker 3.2.2 → 3.3.0
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 +6 -0
- package/dist/components/birthday-picker.d.ts +2 -2
- package/dist/es/index.js +16 -3
- package/dist/index.js +16 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -36,9 +36,9 @@ type Props = {
|
|
|
36
36
|
/**
|
|
37
37
|
* Whether we want to hide the day field.
|
|
38
38
|
*
|
|
39
|
-
* **NOTE:** We will set the day to the
|
|
39
|
+
* **NOTE:** We will set the day to the _last_ day of the _selected_ month
|
|
40
40
|
* if the day field is hidden. Please make sure to modify the passed date
|
|
41
|
-
* value to fit different needs (e.g. if you want to set the
|
|
41
|
+
* value to fit different needs (e.g. if you want to set the _last_ day of
|
|
42
42
|
* the _following_ month instead).
|
|
43
43
|
*/
|
|
44
44
|
monthYearOnly?: boolean;
|
package/dist/es/index.js
CHANGED
|
@@ -54,11 +54,21 @@ class BirthdayPicker extends React.Component {
|
|
|
54
54
|
day,
|
|
55
55
|
year
|
|
56
56
|
} = this.state;
|
|
57
|
-
|
|
57
|
+
const {
|
|
58
|
+
monthYearOnly
|
|
59
|
+
} = this.props;
|
|
60
|
+
const dateFields = [year, month];
|
|
61
|
+
if (!monthYearOnly) {
|
|
62
|
+
dateFields.push(day);
|
|
63
|
+
}
|
|
64
|
+
if (dateFields.some(field => field === null)) {
|
|
58
65
|
this.reportChange(null);
|
|
59
66
|
return;
|
|
60
67
|
}
|
|
61
|
-
|
|
68
|
+
let date = moment(dateFields);
|
|
69
|
+
if (monthYearOnly) {
|
|
70
|
+
date = date.endOf("month");
|
|
71
|
+
}
|
|
62
72
|
if (date.isAfter() || !date.isValid()) {
|
|
63
73
|
this.setState({
|
|
64
74
|
error: this.labels.errorMessage
|
|
@@ -102,8 +112,11 @@ class BirthdayPicker extends React.Component {
|
|
|
102
112
|
};
|
|
103
113
|
this.labels = _extends({}, defaultLabels, this.props.labels);
|
|
104
114
|
if (defaultValue) {
|
|
105
|
-
|
|
115
|
+
let date = moment(defaultValue);
|
|
106
116
|
if (date.isValid()) {
|
|
117
|
+
if (monthYearOnly) {
|
|
118
|
+
date = date.endOf("month");
|
|
119
|
+
}
|
|
107
120
|
initialState.month = String(date.month());
|
|
108
121
|
initialState.day = String(date.date());
|
|
109
122
|
initialState.year = String(date.year());
|
package/dist/index.js
CHANGED
|
@@ -81,11 +81,21 @@ class BirthdayPicker extends React__namespace.Component {
|
|
|
81
81
|
day,
|
|
82
82
|
year
|
|
83
83
|
} = this.state;
|
|
84
|
-
|
|
84
|
+
const {
|
|
85
|
+
monthYearOnly
|
|
86
|
+
} = this.props;
|
|
87
|
+
const dateFields = [year, month];
|
|
88
|
+
if (!monthYearOnly) {
|
|
89
|
+
dateFields.push(day);
|
|
90
|
+
}
|
|
91
|
+
if (dateFields.some(field => field === null)) {
|
|
85
92
|
this.reportChange(null);
|
|
86
93
|
return;
|
|
87
94
|
}
|
|
88
|
-
|
|
95
|
+
let date = moment__default["default"](dateFields);
|
|
96
|
+
if (monthYearOnly) {
|
|
97
|
+
date = date.endOf("month");
|
|
98
|
+
}
|
|
89
99
|
if (date.isAfter() || !date.isValid()) {
|
|
90
100
|
this.setState({
|
|
91
101
|
error: this.labels.errorMessage
|
|
@@ -129,8 +139,11 @@ class BirthdayPicker extends React__namespace.Component {
|
|
|
129
139
|
};
|
|
130
140
|
this.labels = _extends__default["default"]({}, defaultLabels, this.props.labels);
|
|
131
141
|
if (defaultValue) {
|
|
132
|
-
|
|
142
|
+
let date = moment__default["default"](defaultValue);
|
|
133
143
|
if (date.isValid()) {
|
|
144
|
+
if (monthYearOnly) {
|
|
145
|
+
date = date.endOf("month");
|
|
146
|
+
}
|
|
134
147
|
initialState.month = String(date.month());
|
|
135
148
|
initialState.day = String(date.date());
|
|
136
149
|
initialState.year = String(date.year());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-birthday-picker",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@babel/runtime": "^7.24.5",
|
|
14
14
|
"@khanacademy/wonder-blocks-core": "12.2.0",
|
|
15
|
-
"@khanacademy/wonder-blocks-dropdown": "9.1.2",
|
|
16
15
|
"@khanacademy/wonder-blocks-icon": "5.1.2",
|
|
17
|
-
"@khanacademy/wonder-blocks-layout": "3.1.2",
|
|
18
16
|
"@khanacademy/wonder-blocks-tokens": "5.0.0",
|
|
19
|
-
"@khanacademy/wonder-blocks-
|
|
17
|
+
"@khanacademy/wonder-blocks-layout": "3.1.2",
|
|
18
|
+
"@khanacademy/wonder-blocks-typography": "3.1.2",
|
|
19
|
+
"@khanacademy/wonder-blocks-dropdown": "9.1.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@phosphor-icons/core": "^2.0.2",
|