@reykjavik/hanna-react 0.10.72 → 0.10.74

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
@@ -4,6 +4,19 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.74
8
+
9
+ _2022-12-12_
10
+
11
+ - feat: Add support for Polish to `DatePicker`
12
+ - fix: Make Icelandic the default `DatePicker` locale
13
+
14
+ ## 0.10.73
15
+
16
+ _2022-12-08_
17
+
18
+ - fix: `Datepicker` calendar not closing when date is selected
19
+
7
20
  ## 0.10.72
8
21
 
9
22
  _2022-12-07_
package/Datepicker.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare type DatepickerProps = {
9
9
  endDate?: Date;
10
10
  minDate?: Date;
11
11
  maxDate?: Date;
12
- localeCode?: 'is' | 'en';
12
+ localeCode?: 'is' | 'en' | 'pl';
13
13
  dateFormat?: string;
14
14
  isStartDate?: boolean;
15
15
  isEndDate?: boolean;
package/Datepicker.js CHANGED
@@ -9,8 +9,10 @@ const hooks_1 = require("@hugsmidjan/react/hooks");
9
9
  const getBemClass_1 = tslib_1.__importDefault(require("@hugsmidjan/react/utils/getBemClass"));
10
10
  // For more info on localization see: https://stackoverflow.com/questions/54399084/change-locale-in-react-datepicker/58306958#58306958
11
11
  const is_1 = tslib_1.__importDefault(require("date-fns/locale/is"));
12
+ const pl_1 = tslib_1.__importDefault(require("date-fns/locale/pl"));
12
13
  const FormField_1 = tslib_1.__importDefault(require("./FormField"));
13
14
  (0, react_datepicker_1.registerLocale)('is', is_1.default);
15
+ (0, react_datepicker_1.registerLocale)('pl', pl_1.default);
14
16
  const getDateDiff = (date, diff) => {
15
17
  const newDate = new Date(date);
16
18
  newDate.setDate(newDate.getDate() + diff);
@@ -34,15 +36,31 @@ const i18n = {
34
36
  chooseDayAriaLabelPrefix: 'Veldu:',
35
37
  disabledDayAriaLabelPrefix: 'Dagsetning ekki í boði',
36
38
  },
39
+ pl: {
40
+ nextMonthAriaLabel: 'Następny miesiącu',
41
+ nextMonthButtonLabel: 'Następny miesiącu',
42
+ nextYearAriaLabel: 'Następny rok',
43
+ nextYearButtonLabel: 'Następny rok',
44
+ previousMonthAriaLabel: 'Poprzedni miesiac',
45
+ previousMonthButtonLabel: 'Poprzedni miesiac',
46
+ previousYearAriaLabel: 'Poprzedni rok',
47
+ previousYearButtonLabel: 'Poprzedni rok',
48
+ timeInputLabel: 'Czas: ',
49
+ weekAriaLabelPrefix: 'Tydzień: ',
50
+ weekLabel: 'Tydzień',
51
+ ariaLabelPrefix: 'Miesiąc:',
52
+ chooseDayAriaLabelPrefix: 'Wybierać:',
53
+ disabledDayAriaLabelPrefix: 'Data niedostępna',
54
+ },
37
55
  };
38
56
  const Datepicker = (props) => {
39
- const { className, id, label, hideLabel, assistText, disabled, readOnly, invalid, errorMessage, required, reqText, placeholder, small, localeCode, dateFormat = 'd.M.yyy', initialDate, value = initialDate, name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, ssr, inputRef, } = props;
57
+ const { className, id, label, hideLabel, assistText, disabled, readOnly, invalid, errorMessage, required, reqText, placeholder, small, localeCode = 'is', dateFormat = 'd.M.yyy', initialDate, value = initialDate, name, startDate, endDate, minDate, maxDate, isStartDate = false, isEndDate = false, onChange, datepickerExtraProps, ssr, inputRef, } = props;
40
58
  const domid = (0, hooks_1.useDomid)(id);
41
59
  const txts = (localeCode && i18n[localeCode]) || {};
42
60
  const filled = !!value;
43
61
  const empty = !filled && !placeholder;
44
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) => {
45
- return (react_1.default.createElement("div", Object.assign({ className: className.input, onClick: (e) => e.currentTarget.querySelector('input').focus(), ref: inputRef &&
63
+ return (react_1.default.createElement("div", Object.assign({ className: className.input, onClick: ({ target, currentTarget }) => target === currentTarget && currentTarget.querySelector('input').focus(), ref: inputRef &&
46
64
  ((elm) => {
47
65
  inputRef.current =
48
66
  (elm === null || elm === void 0 ? void 0 : elm.querySelector('input')) || undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.72",
3
+ "version": "0.10.74",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",