@reykjavik/hanna-react 0.10.141 → 0.10.143
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 +15 -0
- package/Datepicker.js +11 -2
- package/esm/Datepicker.js +11 -2
- package/esm/focus-visible.js +8 -0
- package/focus-visible.js +8 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.143
|
|
8
|
+
|
|
9
|
+
_2024-12-06_
|
|
10
|
+
+
|
|
11
|
+
- `Datepicker:`
|
|
12
|
+
- fix: Timezone mismatch in `isoMode` (emitted UTC-based dates, not local)
|
|
13
|
+
|
|
14
|
+
## 0.10.142
|
|
15
|
+
|
|
16
|
+
_2024-11-28_
|
|
17
|
+
|
|
18
|
+
- feat: Deprecate `focus-visible` polyfill module; browser support is now good
|
|
19
|
+
- `Datepicker`:
|
|
20
|
+
- fix: Set `minDate` prop values to `T00:00` to allow manual min date input
|
|
21
|
+
|
|
7
22
|
## 0.10.141
|
|
8
23
|
|
|
9
24
|
_2024-11-25_
|
package/Datepicker.js
CHANGED
|
@@ -108,6 +108,13 @@ const defaultDatepickerTexts = {
|
|
|
108
108
|
],
|
|
109
109
|
},
|
|
110
110
|
};
|
|
111
|
+
const toLocalIsoDate = (date) => {
|
|
112
|
+
if (!date) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
const localDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
116
|
+
return localDate.toISOString().split('T')[0];
|
|
117
|
+
};
|
|
111
118
|
/**
|
|
112
119
|
* A compo
|
|
113
120
|
*
|
|
@@ -116,6 +123,8 @@ const defaultDatepickerTexts = {
|
|
|
116
123
|
const Datepicker = (props) => {
|
|
117
124
|
const { placeholder, dateFormat, name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, inputRef, isoMode, texts, lang = props.localeCode, // eslint-disable-line deprecation/deprecation
|
|
118
125
|
fieldWrapperProps, } = (0, FormField_js_1.groupFormFieldWrapperProps)(props);
|
|
126
|
+
// Make sure all minDates are at the start of the day
|
|
127
|
+
const minDateNormalized = minDate ? new Date(minDate.setHours(0, 0, 0, 0)) : undefined;
|
|
119
128
|
const [value, setValue] = utils_js_1.useMixedControlState.raw(props.value || props.initialDate, // eslint-disable-line deprecation/deprecation
|
|
120
129
|
props.defaultValue, 'value');
|
|
121
130
|
/*
|
|
@@ -152,7 +161,7 @@ const Datepicker = (props) => {
|
|
|
152
161
|
(elm === null || elm === void 0 ? void 0 : elm.querySelector('input')) || undefined;
|
|
153
162
|
return elm;
|
|
154
163
|
}) }, addFocusProps()),
|
|
155
|
-
isoMode &&
|
|
164
|
+
isoMode && react_1.default.createElement("input", { type: "hidden", name: name, value: toLocalIsoDate(value) }),
|
|
156
165
|
react_1.default.createElement(ReactDatepicker_js_1.ReactDatePicker, Object.assign({ required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: isoMode ? undefined : name, locale: lang || i18n_1.DEFAULT_LANG, dateFormat: normalizedDateFormats, onChange: (date) => {
|
|
157
166
|
date = date || undefined;
|
|
158
167
|
setValue(date);
|
|
@@ -164,7 +173,7 @@ const Datepicker = (props) => {
|
|
|
164
173
|
}, placeholderText: placeholder,
|
|
165
174
|
// TODO: Implement this
|
|
166
175
|
// selectsRange
|
|
167
|
-
minDate:
|
|
176
|
+
minDate: minDateNormalized, maxDate: maxDate, startDate: startDate, endDate: endDate, selectsStart: isStartDate, selectsEnd: isEndDate, formatWeekDay: (weekday) => weekday.charAt(0).toUpperCase(), showYearDropdown: true, scrollableYearDropdown: true, yearDropdownItemNumber: 15, showMonthDropdown: true }, inputProps, txts, datepickerExtraProps))));
|
|
168
177
|
} })));
|
|
169
178
|
};
|
|
170
179
|
exports.Datepicker = Datepicker;
|
package/esm/Datepicker.js
CHANGED
|
@@ -103,6 +103,13 @@ const defaultDatepickerTexts = {
|
|
|
103
103
|
],
|
|
104
104
|
},
|
|
105
105
|
};
|
|
106
|
+
const toLocalIsoDate = (date) => {
|
|
107
|
+
if (!date) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const localDate = new Date(date.getTime() - date.getTimezoneOffset() * 60000);
|
|
111
|
+
return localDate.toISOString().split('T')[0];
|
|
112
|
+
};
|
|
106
113
|
/**
|
|
107
114
|
* A compo
|
|
108
115
|
*
|
|
@@ -111,6 +118,8 @@ const defaultDatepickerTexts = {
|
|
|
111
118
|
export const Datepicker = (props) => {
|
|
112
119
|
const { placeholder, dateFormat, name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, inputRef, isoMode, texts, lang = props.localeCode, // eslint-disable-line deprecation/deprecation
|
|
113
120
|
fieldWrapperProps, } = groupFormFieldWrapperProps(props);
|
|
121
|
+
// Make sure all minDates are at the start of the day
|
|
122
|
+
const minDateNormalized = minDate ? new Date(minDate.setHours(0, 0, 0, 0)) : undefined;
|
|
114
123
|
const [value, setValue] = useMixedControlState.raw(props.value || props.initialDate, // eslint-disable-line deprecation/deprecation
|
|
115
124
|
props.defaultValue, 'value');
|
|
116
125
|
/*
|
|
@@ -147,7 +156,7 @@ export const Datepicker = (props) => {
|
|
|
147
156
|
(elm === null || elm === void 0 ? void 0 : elm.querySelector('input')) || undefined;
|
|
148
157
|
return elm;
|
|
149
158
|
}) }, addFocusProps()),
|
|
150
|
-
isoMode &&
|
|
159
|
+
isoMode && React.createElement("input", { type: "hidden", name: name, value: toLocalIsoDate(value) }),
|
|
151
160
|
React.createElement(ReactDatePicker, Object.assign({ required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: isoMode ? undefined : name, locale: lang || DEFAULT_LANG, dateFormat: normalizedDateFormats, onChange: (date) => {
|
|
152
161
|
date = date || undefined;
|
|
153
162
|
setValue(date);
|
|
@@ -159,7 +168,7 @@ export const Datepicker = (props) => {
|
|
|
159
168
|
}, placeholderText: placeholder,
|
|
160
169
|
// TODO: Implement this
|
|
161
170
|
// selectsRange
|
|
162
|
-
minDate:
|
|
171
|
+
minDate: minDateNormalized, maxDate: maxDate, startDate: startDate, endDate: endDate, selectsStart: isStartDate, selectsEnd: isEndDate, formatWeekDay: (weekday) => weekday.charAt(0).toUpperCase(), showYearDropdown: true, scrollableYearDropdown: true, yearDropdownItemNumber: 15, showMonthDropdown: true }, inputProps, txts, datepickerExtraProps))));
|
|
163
172
|
} })));
|
|
164
173
|
};
|
|
165
174
|
export default Datepicker;
|
package/esm/focus-visible.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
// expose `focus-visible` to consumers of `@reykjavik/hanna-react`
|
|
2
2
|
// without requiring them to install it as a dependency in their project.
|
|
3
3
|
import '@reykjavik/hanna-utils/focus-visible';
|
|
4
|
+
/** @deprecated This polyfill is not needed anymore (Will be removed in v0.11) */
|
|
5
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6
|
+
console.warn('Deprecation Warning:\n' +
|
|
7
|
+
'The `focus-visible` polyfill isn not needed anymore as browser support ' +
|
|
8
|
+
' is now widespread. You can safely remove all imports of the ' +
|
|
9
|
+
'`@reykjavik/hanna-react/focus-visible` module from your project..\n' +
|
|
10
|
+
'(This module will be removed in v0.11 of `@reykjavik/hanna-react`)');
|
|
11
|
+
}
|
package/focus-visible.js
CHANGED
|
@@ -3,3 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
// expose `focus-visible` to consumers of `@reykjavik/hanna-react`
|
|
4
4
|
// without requiring them to install it as a dependency in their project.
|
|
5
5
|
require("@reykjavik/hanna-utils/focus-visible");
|
|
6
|
+
/** @deprecated This polyfill is not needed anymore (Will be removed in v0.11) */
|
|
7
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8
|
+
console.warn('Deprecation Warning:\n' +
|
|
9
|
+
'The `focus-visible` polyfill isn not needed anymore as browser support ' +
|
|
10
|
+
' is now widespread. You can safely remove all imports of the ' +
|
|
11
|
+
'`@reykjavik/hanna-react/focus-visible` module from your project..\n' +
|
|
12
|
+
'(This module will be removed in v0.11 of `@reykjavik/hanna-react`)');
|
|
13
|
+
}
|