@synerise/ds-date-picker 0.6.43 → 0.7.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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.7.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.6.43...@synerise/ds-date-picker@0.7.0) (2022-10-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * **date-picker:** fix intl in date pickers ([4e9cbce](https://github.com/Synerise/synerise-design/commit/4e9cbceace0e3e794523448120db6a1934242d81))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.6.43](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.6.42...@synerise/ds-date-picker@0.6.43) (2022-10-18)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-date-picker
@@ -5,13 +5,13 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
5
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
6
 
7
7
  import * as React from 'react';
8
- import MomentLocaleUtils from 'react-day-picker/moment';
9
8
  import { injectIntl } from 'react-intl';
10
9
  import fnsFormat from '../../format';
11
10
  import Navbar from '../Navbar/Navbar';
11
+ import { fnsAddYears, fnsAddMonths } from '../../fns';
12
+ import localeUtils from '../../localeUtils';
12
13
  import { DayPicker } from './DayPicker.styles';
13
14
  import * as S from '../Navbar/Navbar.styles';
14
- import { fnsAddYears, fnsAddMonths } from '../../fns';
15
15
 
16
16
  var captionElement = function captionElement() {
17
17
  return null;
@@ -56,7 +56,7 @@ var Picker = function Picker(props) {
56
56
  captionElement: captionElement,
57
57
  key: "body",
58
58
  locale: intl.locale,
59
- localeUtils: MomentLocaleUtils,
59
+ localeUtils: localeUtils,
60
60
  modifiers: modifiers
61
61
  }, rest)));
62
62
  };
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import { useIntl } from 'react-intl';
2
3
  import fnsFormat from '../../format';
3
4
  import Navbar from '../Navbar/Navbar';
4
5
  import * as S from './TimePicker.styles';
@@ -15,8 +16,9 @@ var TimePicker = function TimePicker(_ref) {
15
16
  onChange = _ref.onChange,
16
17
  onShortNext = _ref.onShortNext,
17
18
  onShortPrev = _ref.onShortPrev;
19
+ var intl = useIntl();
18
20
  return /*#__PURE__*/React.createElement(React.Fragment, null, !!value && /*#__PURE__*/React.createElement(Navbar, {
19
- title: fnsFormat(value, 'iii d, yyyy'),
21
+ title: fnsFormat(value, 'iii d, yyyy', intl.locale),
20
22
  key: "head",
21
23
  onShortNext: onShortNext,
22
24
  onShortPrev: onShortPrev
@@ -1,9 +1,3 @@
1
- export declare type LocaleUtils = {
2
- formatDay: (d: Date, locale: string) => string;
3
- formatMonthTitle: (d: Date, locale: string) => string;
4
- formatWeekdayShort: (i: string, locale: string) => string;
5
- formatWeekdayLong: (i: string, locale: string) => string;
6
- getFirstDayOfWeek: (locale: string) => string;
7
- };
1
+ import type { LocaleUtils } from 'react-day-picker/types';
8
2
  declare const localeUtils: LocaleUtils;
9
3
  export default localeUtils;
@@ -1,10 +1,17 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import MomentLocaleUtils from 'react-day-picker/moment';
1
8
  var WEEKDAYS_LONG = {
2
9
  en: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
3
10
  pl: ['Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'obota']
4
11
  };
5
12
  var WEEKDAYS_SHORT = {
6
13
  en: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
7
- pl: ['N', 'P', 'W', 'Ś', 'C', 'P', 'S']
14
+ pl: ['Nd', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'Sb']
8
15
  };
9
16
  var MONTHS = {
10
17
  en: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
@@ -14,40 +21,64 @@ var FIRST_DAY = {
14
21
  en: 0,
15
22
  pl: 1
16
23
  };
24
+ var DEFAULT_LOCALE = 'en';
25
+ var DEFAULT_FORMAT = 'MMM DD, YYYY';
26
+
27
+ var getValidLocale = function getValidLocale(locale) {
28
+ return Object.keys(MONTHS).includes(locale) ? locale : DEFAULT_LOCALE;
29
+ }; // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+
31
+
32
+ function formatDay(d, format, locale) {
33
+ if (format === void 0) {
34
+ format = DEFAULT_FORMAT;
35
+ }
17
36
 
18
- function formatDay(d, locale) {
19
37
  if (locale === void 0) {
20
- locale = 'en';
38
+ locale = DEFAULT_LOCALE;
21
39
  }
22
40
 
23
- return WEEKDAYS_LONG[locale][d.getDay()] + ", " + d.getDate() + " " + MONTHS[locale][d.getMonth()] + " " + d.getFullYear();
41
+ return WEEKDAYS_LONG[getValidLocale(locale)][d.getDay()] + ", " + d.getDate() + " " + MONTHS[getValidLocale(locale)][d.getMonth()] + " " + d.getFullYear();
24
42
  }
25
43
 
26
44
  function formatMonthTitle(d, locale) {
27
45
  if (locale === void 0) {
28
- locale = 'en';
46
+ locale = DEFAULT_LOCALE;
29
47
  }
30
48
 
31
- return MONTHS[locale][d.getMonth()] + " " + d.getFullYear();
49
+ return MONTHS[getValidLocale(locale)][d.getMonth()] + " " + d.getFullYear();
32
50
  }
33
51
 
34
52
  function formatWeekdayShort(i, locale) {
35
- return WEEKDAYS_SHORT[locale][i];
53
+ if (locale === void 0) {
54
+ locale = DEFAULT_LOCALE;
55
+ }
56
+
57
+ return WEEKDAYS_SHORT[getValidLocale(locale)][i];
36
58
  }
37
59
 
38
- function formatWeekdayLong(i, locale) {
39
- return WEEKDAYS_SHORT[locale][i];
60
+ function formatWeekdayLong(weekday, locale) {
61
+ if (locale === void 0) {
62
+ locale = DEFAULT_LOCALE;
63
+ }
64
+
65
+ return WEEKDAYS_SHORT[getValidLocale(locale)][weekday];
40
66
  }
41
67
 
42
68
  function getFirstDayOfWeek(locale) {
43
- return FIRST_DAY[locale];
69
+ if (locale === void 0) {
70
+ locale = DEFAULT_LOCALE;
71
+ }
72
+
73
+ return FIRST_DAY[getValidLocale(locale)];
44
74
  }
45
75
 
46
- var localeUtils = {
76
+ var localeUtils = _objectSpread({}, MomentLocaleUtils, {
47
77
  formatDay: formatDay,
48
78
  formatMonthTitle: formatMonthTitle,
49
79
  formatWeekdayShort: formatWeekdayShort,
50
80
  formatWeekdayLong: formatWeekdayLong,
51
81
  getFirstDayOfWeek: getFirstDayOfWeek
52
- };
82
+ });
83
+
53
84
  export default localeUtils;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-date-picker",
3
- "version": "0.6.43",
3
+ "version": "0.7.0",
4
4
  "description": "DatePicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,9 +34,9 @@
34
34
  "dependencies": {
35
35
  "@date-fns/upgrade": "^1.0.3",
36
36
  "@synerise/ds-button": "^0.17.9",
37
- "@synerise/ds-core": "^0.37.0",
37
+ "@synerise/ds-core": "^0.38.0",
38
38
  "@synerise/ds-icon": "^0.51.0",
39
- "@synerise/ds-time-picker": "^0.6.42",
39
+ "@synerise/ds-time-picker": "^0.6.43",
40
40
  "@synerise/ds-tooltip": "^0.11.17",
41
41
  "classnames": "^2.2.6",
42
42
  "date-fns": "2.16.1",
@@ -48,5 +48,5 @@
48
48
  "@synerise/ds-core": "*",
49
49
  "react": ">=16.9.0 < 17.0.0"
50
50
  },
51
- "gitHead": "deb64331c66a792832b3843c19054890de4726eb"
51
+ "gitHead": "6f71f891413ba05d50a0ab86f22266c0c8386b31"
52
52
  }