@reykjavik/hanna-react 0.10.78 → 0.10.79
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 +7 -1
- package/Datepicker.d.ts +1 -1
- package/Datepicker.js +13 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.79
|
|
8
|
+
|
|
9
|
+
_2023-01-23_
|
|
10
|
+
|
|
11
|
+
- feat: Support passing Array of `dateFormat`s to `Datepicker`
|
|
12
|
+
|
|
7
13
|
## 0.10.77 – 0.10.78
|
|
8
14
|
|
|
9
|
-
|
|
15
|
+
_2023-01-18_
|
|
10
16
|
|
|
11
17
|
- feat: Add standalone component `.CheckboxButton`
|
|
12
18
|
- feat: Add `.CheckboxButton__label__wrap` and `.RadioButton__label__wrap`
|
package/Datepicker.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type DatepickerProps = {
|
|
|
10
10
|
minDate?: Date;
|
|
11
11
|
maxDate?: Date;
|
|
12
12
|
localeCode?: 'is' | 'en' | 'pl';
|
|
13
|
-
dateFormat?: string
|
|
13
|
+
dateFormat?: string | Array<string>;
|
|
14
14
|
isStartDate?: boolean;
|
|
15
15
|
isEndDate?: boolean;
|
|
16
16
|
inputRef?: RefObject<HTMLInputElement>;
|
package/Datepicker.js
CHANGED
|
@@ -56,17 +56,26 @@ const i18n = {
|
|
|
56
56
|
const Datepicker = (props) => {
|
|
57
57
|
const { className, id, label, hideLabel, assistText, disabled, readOnly, invalid, errorMessage, required, reqText, placeholder, small, localeCode = 'is', dateFormat = 'd.M.yyyy', initialDate, value = initialDate, name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, ssr, inputRef, } = props;
|
|
58
58
|
const domid = (0, hooks_1.useDomid)(id);
|
|
59
|
-
const txts =
|
|
59
|
+
const txts = i18n[localeCode] || {};
|
|
60
60
|
const filled = !!value;
|
|
61
61
|
const empty = !filled && !placeholder;
|
|
62
62
|
return (react_1.default.createElement(FormField_1.default, { className: (0, getBemClass_1.default)('Datepicker', [], className), ssr: ssr, label: label, small: small, assistText: assistText, hideLabel: hideLabel, invalid: invalid, required: required, reqText: reqText, disabled: disabled, readOnly: readOnly, filled: filled, empty: empty, errorMessage: errorMessage, renderInput: (className, inputProps, addFocusProps) => {
|
|
63
|
-
return (react_1.default.createElement("div", Object.assign({ className: className.input, onClick: ({ target, currentTarget }) => target === currentTarget && currentTarget.querySelector('input').focus(), ref: inputRef &&
|
|
63
|
+
return (react_1.default.createElement("div", Object.assign({ className: className.input, onClick: ({ target, currentTarget }) => { var _a; return target === currentTarget && ((_a = currentTarget.querySelector('input')) === null || _a === void 0 ? void 0 : _a.focus()); }, ref: inputRef &&
|
|
64
64
|
((elm) => {
|
|
65
65
|
inputRef.current =
|
|
66
66
|
(elm === null || elm === void 0 ? void 0 : elm.querySelector('input')) || undefined;
|
|
67
67
|
return elm;
|
|
68
68
|
}) }, addFocusProps()),
|
|
69
|
-
react_1.default.createElement(react_datepicker_1.default, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: name, locale: localeCode, dateFormat:
|
|
69
|
+
react_1.default.createElement(react_datepicker_1.default, Object.assign({ id: domid, required: inputProps.required, disabled: inputProps.disabled, readOnly: inputProps.readOnly, selected: value, name: name, locale: localeCode, dateFormat:
|
|
70
|
+
// NOTE: Force all dateFormat values into Array<string> to temporarily work around
|
|
71
|
+
// a bug in the current version of react-datepicker where invalid **string** values
|
|
72
|
+
// are re-parsed with `new Date()`, causing surprising behavior in certain situations
|
|
73
|
+
// AND wheree Arrayed formats get parsed in order of "increasing priority".
|
|
74
|
+
// Revert back to the plain `dateFormat={dateFormat}` pass-through once this PR has been
|
|
75
|
+
// accepted and released: https://github.com/Hacker0x01/react-datepicker/pull/3903
|
|
76
|
+
typeof dateFormat === 'string'
|
|
77
|
+
? [dateFormat]
|
|
78
|
+
: dateFormat.slice(0).reverse(), onChange: (date) => {
|
|
70
79
|
onChange(date || undefined);
|
|
71
80
|
const inputElm = inputRef === null || inputRef === void 0 ? void 0 : inputRef.current;
|
|
72
81
|
if (inputElm) {
|
|
@@ -75,10 +84,7 @@ const Datepicker = (props) => {
|
|
|
75
84
|
}, placeholderText: placeholder,
|
|
76
85
|
// TODO: Implement this
|
|
77
86
|
// selectsRange
|
|
78
|
-
minDate: minDate, maxDate: maxDate, startDate: startDate, endDate: endDate, selectsStart: isStartDate, selectsEnd: isEndDate, formatWeekDay: (weekday) =>
|
|
79
|
-
// TODO: if we use costom locale we don't need this
|
|
80
|
-
return weekday.charAt(0).toUpperCase();
|
|
81
|
-
}, showYearDropdown: true, scrollableYearDropdown: true, yearDropdownItemNumber: 15, showMonthDropdown: true }, inputProps, txts, datepickerExtraProps))));
|
|
87
|
+
minDate: minDate, 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))));
|
|
82
88
|
} }));
|
|
83
89
|
};
|
|
84
90
|
exports.Datepicker = Datepicker;
|