@synerise/ds-date-picker 0.8.11 → 0.9.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.9.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.8.11...@synerise/ds-date-picker@0.9.0) (2023-03-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * **data-format:** using data format tools in ds components ([ee52cba](https://github.com/Synerise/synerise-design/commit/ee52cbac5e798e048722aefb2e47a7058e0f4c9c))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.8.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.8.10...@synerise/ds-date-picker@0.8.11) (2023-03-06)
7
18
 
8
19
  **Note:** Version bump only for package @synerise/ds-date-picker
@@ -1,4 +1,4 @@
1
- var _excluded = ["autoFocus", "disabled", "texts", "format", "value", "onApply", "showTime", "onValueChange", "onClear", "errorText", "popoverPlacement", "prefixel", "error", "onDropdownVisibleChange", "dropdownProps", "suffixel", "hideNow", "readOnly"];
1
+ var _excluded = ["autoFocus", "disabled", "texts", "format", "valueFormatOptions", "value", "onApply", "showTime", "onValueChange", "onClear", "errorText", "popoverPlacement", "prefixel", "error", "onDropdownVisibleChange", "dropdownProps", "suffixel", "hideNow", "readOnly"];
2
2
 
3
3
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
@@ -16,6 +16,7 @@ var DatePicker = function DatePicker(_ref) {
16
16
  disabled = _ref.disabled,
17
17
  texts = _ref.texts,
18
18
  format = _ref.format,
19
+ valueFormatOptions = _ref.valueFormatOptions,
19
20
  value = _ref.value,
20
21
  onApply = _ref.onApply,
21
22
  showTime = _ref.showTime,
@@ -70,6 +71,7 @@ var DatePicker = function DatePicker(_ref) {
70
71
  setDropVisible(!dropVisible);
71
72
  } : undefined,
72
73
  format: format,
74
+ valueFormatOptions: valueFormatOptions,
73
75
  onClear: handleClear,
74
76
  placeholder: texts.inputPlaceholder,
75
77
  prefixel: prefixel,
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { IntlShape } from 'react-intl';
3
3
  import { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
4
+ import { DateToFormatOptions } from '@synerise/ds-data-format';
4
5
  export declare type Props = {
5
6
  autoFocus?: boolean;
6
7
  disabled?: boolean;
@@ -9,7 +10,11 @@ export declare type Props = {
9
10
  disabledMinutes: number[];
10
11
  disabledSeconds: number[];
11
12
  dropdownProps?: Partial<DropdownProps>;
13
+ /**
14
+ * @deprecated use `valueFormatOptions` instead
15
+ */
12
16
  format?: string;
17
+ valueFormatOptions?: DateToFormatOptions;
13
18
  intl?: IntlShape;
14
19
  onApply?: (date?: Date) => void;
15
20
  onClear?: () => void;
@@ -6,9 +6,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
6
6
 
7
7
  import * as React from 'react';
8
8
  import { injectIntl } from 'react-intl';
9
+ import { useDataFormat } from '@synerise/ds-data-format';
9
10
  import fnsFormat from '../../format';
10
11
  import Navbar from '../Navbar/Navbar';
11
- import { fnsAddYears, fnsAddMonths } from '../../fns';
12
+ import { fnsAddMonths, fnsAddYears } from '../../fns';
12
13
  import localeUtils from '../../localeUtils';
13
14
  import { DayPicker } from './DayPicker.styles';
14
15
  import * as S from '../Navbar/Navbar.styles';
@@ -31,6 +32,9 @@ var Picker = function Picker(props) {
31
32
  modifiers = props.modifiers,
32
33
  rest = _objectWithoutPropertiesLoose(props, _excluded);
33
34
 
35
+ var _useDataFormat = useDataFormat(),
36
+ firstDayOfWeek = _useDataFormat.firstDayOfWeek;
37
+
34
38
  return /*#__PURE__*/React.createElement(React.Fragment, null, renderNavbar ? renderNavbar(props) : /*#__PURE__*/React.createElement(Navbar, {
35
39
  title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(S.Link, {
36
40
  onClick: onMonthNameClick
@@ -52,7 +56,7 @@ var Picker = function Picker(props) {
52
56
  key: "head"
53
57
  }), /*#__PURE__*/React.createElement(DayPicker, _extends({
54
58
  month: month,
55
- firstDayOfWeek: 1,
59
+ firstDayOfWeek: firstDayOfWeek,
56
60
  captionElement: captionElement,
57
61
  key: "body",
58
62
  locale: intl.locale,
@@ -1,12 +1,19 @@
1
- var _excluded = ["autoFocus", "size", "disabled", "readOnly", "value", "format", "onChange", "showTime", "style", "placeholder", "onClear", "onClick", "clearTooltip", "highlight", "error", "errorText", "prefixel", "suffixel"];
1
+ var _excluded = ["autoFocus", "size", "disabled", "readOnly", "value", "format", "valueFormatOptions", "onChange", "showTime", "style", "placeholder", "onClear", "onClick", "clearTooltip", "highlight", "error", "errorText", "prefixel", "suffixel"];
2
2
 
3
3
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
4
 
5
+ 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; }
6
+
7
+ 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; }
8
+
9
+ 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; }
10
+
5
11
  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
12
 
7
13
  import * as React from 'react';
8
14
  import Icon, { CalendarM, Close3S } from '@synerise/ds-icon';
9
15
  import Tooltip from '@synerise/ds-tooltip';
16
+ import { getDefaultDataTimeOptions, useDataFormat } from '@synerise/ds-data-format';
10
17
  import { legacyParse } from '@date-fns/upgrade/v2';
11
18
  import * as S from './PickerInput.styles';
12
19
  import format from '../../format';
@@ -18,6 +25,7 @@ var PickerInput = function PickerInput(_ref) {
18
25
  readOnly = _ref.readOnly,
19
26
  value = _ref.value,
20
27
  dateFormat = _ref.format,
28
+ valueFormatOptions = _ref.valueFormatOptions,
21
29
  onChange = _ref.onChange,
22
30
  showTime = _ref.showTime,
23
31
  style = _ref.style,
@@ -32,6 +40,9 @@ var PickerInput = function PickerInput(_ref) {
32
40
  suffixel = _ref.suffixel,
33
41
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
34
42
 
43
+ var _useDataFormat = useDataFormat(),
44
+ formatValue = _useDataFormat.formatValue;
45
+
35
46
  var _React$useState = React.useState(false),
36
47
  hovered = _React$useState[0],
37
48
  setHovered = _React$useState[1];
@@ -43,8 +54,12 @@ var PickerInput = function PickerInput(_ref) {
43
54
  return format(legacyParse(value), dateFormat);
44
55
  }
45
56
 
46
- return format(legacyParse(value), dateFormat || showTime ? 'MMM d, yyyy, HH:mm' : 'MMM d, yyyy');
47
- }, [value, dateFormat, showTime]);
57
+ if (typeof value === 'string') {
58
+ return format(legacyParse(value), dateFormat || showTime ? 'MMM d, yyyy, HH:mm' : 'MMM d, yyyy');
59
+ }
60
+
61
+ return formatValue(value, _objectSpread({}, getDefaultDataTimeOptions(showTime), {}, valueFormatOptions));
62
+ }, [value, dateFormat, showTime, formatValue, valueFormatOptions]);
48
63
  var handleApply = React.useCallback(function (date) {
49
64
  if (!onChange) return;
50
65
  onChange(date, getText());
@@ -1,8 +1,13 @@
1
1
  import * as React from 'react';
2
+ import { DateToFormatOptions } from '@synerise/ds-data-format';
2
3
  export declare type Props = {
3
4
  autoFocus?: boolean;
4
5
  size?: 'large' | 'default' | 'small';
6
+ /**
7
+ * @deprecated use `valueFormatOptions` instead
8
+ */
5
9
  format?: string;
10
+ valueFormatOptions?: DateToFormatOptions;
6
11
  showTime?: boolean;
7
12
  allowClear?: boolean;
8
13
  value?: Date | string;
@@ -1,5 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useIntl } from 'react-intl';
3
+ import { useDataFormat } from '@synerise/ds-data-format';
3
4
  import fnsFormat from '../../format';
4
5
  import Navbar from '../Navbar/Navbar';
5
6
  import * as S from './TimePicker.styles';
@@ -17,6 +18,10 @@ var TimePicker = function TimePicker(_ref) {
17
18
  onShortNext = _ref.onShortNext,
18
19
  onShortPrev = _ref.onShortPrev;
19
20
  var intl = useIntl();
21
+
22
+ var _useDataFormat = useDataFormat(),
23
+ is12HoursClock = _useDataFormat.is12HoursClock;
24
+
20
25
  return /*#__PURE__*/React.createElement(React.Fragment, null, !!value && /*#__PURE__*/React.createElement(Navbar, {
21
26
  title: fnsFormat(value, 'iii d, yyyy', intl.locale),
22
27
  key: "head",
@@ -31,6 +36,7 @@ var TimePicker = function TimePicker(_ref) {
31
36
  disabledHours: disabledHours,
32
37
  disabledMinutes: disabledMinutes,
33
38
  disabledSeconds: disabledSeconds,
39
+ use12HourClock: is12HoursClock,
34
40
  raw: true
35
41
  })));
36
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-date-picker",
3
- "version": "0.8.11",
3
+ "version": "0.9.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.12",
37
- "@synerise/ds-core": "^0.39.1",
37
+ "@synerise/ds-core": "^0.39.2",
38
38
  "@synerise/ds-icon": "^0.54.0",
39
- "@synerise/ds-time-picker": "^0.6.57",
39
+ "@synerise/ds-time-picker": "^0.6.58",
40
40
  "@synerise/ds-tooltip": "^0.13.0",
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": "a9c9628df732abd42421880fd1aa61b7f7c580ee"
51
+ "gitHead": "55d4a4dfa9230bea883b887e4457ca86f8509d83"
52
52
  }