@synerise/ds-date-picker 0.11.4 → 0.11.6

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,28 @@
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.11.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.11.5...@synerise/ds-date-picker@0.11.6) (2024-07-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **date-picker:** fixes of types ([1b09748](https://github.com/Synerise/synerise-design/commit/1b097484782a5dc37e71711d7308511eb8103a45))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.11.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.11.4...@synerise/ds-date-picker@0.11.5) (2024-07-02)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **date-picker:** fixed display value in input ([72e58c2](https://github.com/Synerise/synerise-design/commit/72e58c2c3f2eb01f3e24163ba5f821adc1cec9f5))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.11.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-picker@0.11.3...@synerise/ds-date-picker@0.11.4) (2024-06-27)
7
29
 
8
30
  **Note:** Version bump only for package @synerise/ds-date-picker
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
2
- import { Props } from './DatePicker.types';
3
- declare const DatePicker: React.FC<Props>;
1
+ import React from 'react';
2
+ import type { DatePickerProps } from './DatePicker.types';
3
+ declare const DatePicker: ({ autoFocus, disabled, texts, format, valueFormatOptions, value, onApply, showTime, onValueChange, onClear, errorText, popoverPlacement, prefixel, error, onDropdownVisibleChange, dropdownProps, suffixel, hideNow, readOnly, renderTrigger, inputProps, ...rest }: DatePickerProps) => React.JSX.Element;
4
4
  export default DatePicker;
@@ -4,12 +4,14 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
4
4
 
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
- import * as React from 'react';
7
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
8
+ import { useIntl } from 'react-intl';
8
9
  import Dropdown from '@synerise/ds-dropdown';
9
10
  import { useOnClickOutside } from '@synerise/ds-utils';
10
11
  import RawDatePicker from './RawDatePicker/RawDatePicker';
11
12
  import PickerInput from './Elements/PickerInput/PickerInput';
12
13
  import * as S from './DatePicker.styles';
14
+ import { getDefaultTexts } from './utils/getDefaultTexts';
13
15
 
14
16
  var DatePicker = function DatePicker(_ref) {
15
17
  var autoFocus = _ref.autoFocus,
@@ -35,31 +37,32 @@ var DatePicker = function DatePicker(_ref) {
35
37
  inputProps = _ref.inputProps,
36
38
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
37
39
 
38
- var _React$useState = React.useState(autoFocus || false),
39
- dropVisible = _React$useState[0],
40
- setDropVisible = _React$useState[1];
40
+ var _useState = useState(autoFocus || false),
41
+ dropVisible = _useState[0],
42
+ setDropVisible = _useState[1];
41
43
 
42
- var _React$useState2 = React.useState(value),
43
- selectedDate = _React$useState2[0],
44
- setSelectedDate = _React$useState2[1];
44
+ var _useState2 = useState(value),
45
+ selectedDate = _useState2[0],
46
+ setSelectedDate = _useState2[1];
45
47
 
46
- var ref = React.useRef(null);
48
+ var ref = useRef(null);
49
+ var intl = useIntl();
50
+ var allTexts = getDefaultTexts(intl, texts);
47
51
  useOnClickOutside(ref, function () {
48
52
  !!dropVisible && setDropVisible(false);
49
53
  });
50
- React.useEffect(function () {
54
+ useEffect(function () {
51
55
  setSelectedDate(value);
52
56
  }, [value]);
53
- var onValueChangeCallback = React.useCallback(function (val) {
57
+ var onValueChangeCallback = useCallback(function (val) {
54
58
  onValueChange && onValueChange(val);
55
- setSelectedDate(val);
56
59
  }, [onValueChange]);
57
- var onApplyCallback = React.useCallback(function (val) {
60
+ var onApplyCallback = useCallback(function (val) {
58
61
  onApply && onApply(val);
59
62
  setSelectedDate(val);
60
63
  setDropVisible(false);
61
64
  }, [onApply]);
62
- var handleClear = React.useCallback(function () {
65
+ var handleClear = useCallback(function () {
63
66
  setDropVisible(false);
64
67
  setSelectedDate(undefined);
65
68
  onClear && onClear();
@@ -75,10 +78,10 @@ var DatePicker = function DatePicker(_ref) {
75
78
  format: format,
76
79
  valueFormatOptions: valueFormatOptions,
77
80
  onClear: handleClear,
78
- placeholder: texts.inputPlaceholder,
81
+ placeholder: allTexts.inputPlaceholder,
79
82
  prefixel: prefixel,
80
83
  suffixel: suffixel,
81
- clearTooltip: texts.clearTooltip,
84
+ clearTooltip: allTexts.clearTooltip,
82
85
  highlight: !!dropVisible && !disabled,
83
86
  error: error,
84
87
  errorText: errorText,
@@ -89,7 +92,7 @@ var DatePicker = function DatePicker(_ref) {
89
92
  ref: ref
90
93
  }, /*#__PURE__*/React.createElement(RawDatePicker, _extends({}, rest, {
91
94
  showTime: showTime,
92
- texts: texts,
95
+ texts: allTexts,
93
96
  onApply: onApplyCallback,
94
97
  onValueChange: onValueChangeCallback,
95
98
  value: selectedDate,
@@ -3,21 +3,21 @@ import type { IntlShape } from 'react-intl';
3
3
  import type { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
4
4
  import type { DateToFormatOptions } from '@synerise/ds-data-format';
5
5
  import type { InputProps } from '@synerise/ds-input';
6
- export type Props = {
6
+ export type DatePickerProps = {
7
7
  autoFocus?: boolean;
8
8
  disabled?: boolean;
9
9
  disabledDates?: (date?: Date) => boolean;
10
- disabledHours: number[];
11
- disabledMinutes: number[];
12
- disabledSeconds: number[];
10
+ disabledHours?: number[];
11
+ disabledMinutes?: number[];
12
+ disabledSeconds?: number[];
13
13
  dropdownProps?: Partial<DropdownProps>;
14
14
  /**
15
15
  * @deprecated use `valueFormatOptions` instead
16
16
  */
17
17
  format?: string;
18
18
  valueFormatOptions?: DateToFormatOptions;
19
- intl?: IntlShape;
20
- onApply?: (date?: Date) => void;
19
+ intl: IntlShape;
20
+ onApply: (date?: Date) => void;
21
21
  onClear?: () => void;
22
22
  onDropdownVisibleChange?: (visible: boolean) => void;
23
23
  onValueChange?: (date?: Date) => void;
@@ -27,7 +27,7 @@ export type Props = {
27
27
  prefixel?: ReactNode;
28
28
  suffixel?: ReactNode;
29
29
  showTime?: boolean;
30
- texts: Texts;
30
+ texts?: Partial<Texts>;
31
31
  renderTrigger?: () => ReactElement;
32
32
  value?: Date;
33
33
  useStartOfDay?: boolean;
@@ -36,6 +36,7 @@ export type Props = {
36
36
  readOnly?: boolean;
37
37
  inputProps?: Pick<InputProps, 'autoResize'>;
38
38
  };
39
+ export type Props = DatePickerProps;
39
40
  export type State = {
40
41
  mode: string;
41
42
  month: Date;
@@ -56,6 +57,6 @@ export type Modifier = {
56
57
  export type Texts = {
57
58
  apply: ReactNode;
58
59
  now: ReactNode;
59
- inputPlaceholder?: string;
60
- clearTooltip?: ReactNode;
60
+ inputPlaceholder: string;
61
+ clearTooltip: ReactNode;
61
62
  };
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { PickerInputProps } from './PickerInput.types';
3
3
  declare const PickerInput: ({ autoFocus, size, disabled, readOnly, value, format: dateFormat, valueFormatOptions, onChange, showTime, placeholder, onClear, onClick, clearTooltip, highlight, error, errorText, prefixel, suffixel, ...rest }: PickerInputProps) => React.JSX.Element;
4
4
  export default PickerInput;
@@ -10,7 +10,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
10
10
 
11
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; }
12
12
 
13
- import * as React from 'react';
13
+ import React, { useCallback, useMemo, useState } from 'react';
14
14
  import Icon, { CalendarM, Close3S } from '@synerise/ds-icon';
15
15
  import Tooltip from '@synerise/ds-tooltip';
16
16
  import { getDefaultDataTimeOptions, useDataFormat } from '@synerise/ds-data-format';
@@ -42,11 +42,11 @@ var PickerInput = function PickerInput(_ref) {
42
42
  var _useDataFormat = useDataFormat(),
43
43
  formatValue = _useDataFormat.formatValue;
44
44
 
45
- var _React$useState = React.useState(false),
46
- hovered = _React$useState[0],
47
- setHovered = _React$useState[1];
45
+ var _useState = useState(false),
46
+ hovered = _useState[0],
47
+ setHovered = _useState[1];
48
48
 
49
- var getText = React.useCallback(function () {
49
+ var getText = useCallback(function () {
50
50
  if (!value) return '';
51
51
 
52
52
  if (dateFormat) {
@@ -59,20 +59,20 @@ var PickerInput = function PickerInput(_ref) {
59
59
 
60
60
  return formatValue(value, _objectSpread({}, getDefaultDataTimeOptions(showTime), {}, valueFormatOptions));
61
61
  }, [value, dateFormat, showTime, formatValue, valueFormatOptions]);
62
- var handleApply = React.useCallback(function (date) {
62
+ var handleApply = useCallback(function (date) {
63
63
  if (!onChange) return;
64
64
  onChange(date, getText());
65
65
  }, [onChange, getText]);
66
- var handleIconClick = React.useCallback(function (e) {
67
- e.stopPropagation();
66
+ var handleIconClick = useCallback(function (event) {
67
+ event.stopPropagation();
68
68
  onClear && onClear();
69
69
  handleApply(null);
70
70
  }, [onClear, handleApply]);
71
- var handleInputClick = React.useCallback(function (e) {
72
- e.stopPropagation();
71
+ var handleInputClick = useCallback(function (event) {
72
+ event.stopPropagation();
73
73
  onClick && onClick();
74
74
  }, [onClick]);
75
- var iconInput = React.useMemo(function () {
75
+ var iconInput = useMemo(function () {
76
76
  return (hovered || highlight) && !readOnly && !!value ? /*#__PURE__*/React.createElement(S.ClearIconWrapper, null, /*#__PURE__*/React.createElement(Tooltip, {
77
77
  title: clearTooltip
78
78
  }, /*#__PURE__*/React.createElement(Icon, {
@@ -2,9 +2,9 @@ export type TimePickerProps = {
2
2
  format?: string;
3
3
  value?: Date;
4
4
  onChange: (date?: Date | undefined) => void;
5
- disabledHours: number[];
6
- disabledMinutes: number[];
7
- disabledSeconds: number[];
5
+ disabledHours?: number[];
6
+ disabledMinutes?: number[];
7
+ disabledSeconds?: number[];
8
8
  inactivePrev?: boolean;
9
9
  inactiveNext?: boolean;
10
10
  onShortNext?: () => void;
@@ -1,30 +1,7 @@
1
- import * as React from 'react';
2
- import { DayModifiers } from 'react-day-picker';
3
- import { Props, State, Texts } from '../DatePicker.types';
4
- import { RawDatePickerProps } from './RawDatePicker.types';
5
- declare class RawDatePicker extends React.Component<RawDatePickerProps, State> {
6
- static defaultProps: {
7
- showTime: boolean;
8
- disabledHours: never[];
9
- disabledMinutes: never[];
10
- disabledSeconds: never[];
11
- };
12
- constructor(props: Props);
13
- getTexts(): Texts;
14
- getSnapshotBeforeUpdate(prevProps: Readonly<Props>): null;
15
- handleChange: (value: Date | undefined) => void;
16
- handleDayMouseEnter: (day: Date) => void;
17
- handleDayMouseLeave: () => void;
18
- handleDayClick: (day: Date, modifiers: DayModifiers) => void;
19
- handleModeSwitch: (mode: string) => void;
20
- handleApply: (date: Date | undefined) => void;
21
- handleMonthChange: (month: Date, mode: string) => void;
22
- renderDay: (day: Date) => React.ReactNode;
23
- renderYearPicker: () => React.ReactNode;
24
- renderMonthPicker: () => React.ReactNode;
25
- renderDayPicker: () => React.ReactNode;
26
- handleDaySwitch: (day: Date) => void;
27
- renderTimePicker: () => React.ReactNode;
28
- render(): React.ReactNode;
29
- }
30
- export default RawDatePicker;
1
+ import React from 'react';
2
+ declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<import("../DatePicker.types").DatePickerProps, "intl"> & {
3
+ forwardedRef?: React.Ref<any> | undefined;
4
+ } & React.RefAttributes<any>> & {
5
+ WrappedComponent: React.ComponentType<import("../DatePicker.types").DatePickerProps>;
6
+ };
7
+ export default _default;
@@ -2,8 +2,8 @@ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.crea
2
2
 
3
3
  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; }
4
4
 
5
- import * as React from 'react';
6
- import { FormattedMessage } from 'react-intl';
5
+ import React from 'react';
6
+ import { injectIntl } from 'react-intl';
7
7
  import { legacyParse } from '@date-fns/upgrade/v2';
8
8
  import Footer from '../Elements/Footer/Footer';
9
9
  import * as S from '../DatePicker.styles';
@@ -15,6 +15,7 @@ import TimePicker from '../Elements/TimePicker/TimePicker';
15
15
  import { DayBackground, DayText, DayForeground } from '../Elements/DayPicker/DayPicker.styles';
16
16
  import { fnsStartOfMonth, fnsSetYear, fnsSetMonth, fnsSetDate, fnsStartOfDay, fnsEndOfDay, fnsAddDays } from '../fns';
17
17
  import { changeDayWithHoursPreserved } from '../utils';
18
+ import { getDefaultTexts } from '../utils/getDefaultTexts';
18
19
 
19
20
  var RawDatePicker = /*#__PURE__*/function (_React$Component) {
20
21
  function RawDatePicker(props) {
@@ -236,18 +237,7 @@ var RawDatePicker = /*#__PURE__*/function (_React$Component) {
236
237
  var _this$props3 = this.props,
237
238
  texts = _this$props3.texts,
238
239
  intl = _this$props3.intl;
239
- var updatedTexts = {
240
- apply: (texts == null ? void 0 : texts.apply) || /*#__PURE__*/React.createElement(FormattedMessage, {
241
- id: "DS.DATE-PICKER.APPLY"
242
- }),
243
- now: (texts == null ? void 0 : texts.now) || /*#__PURE__*/React.createElement(FormattedMessage, {
244
- id: "DS.DATE-PICKER.NOW"
245
- }),
246
- inputPlaceholder: (texts == null ? void 0 : texts.inputPlaceholder) || (intl == null ? void 0 : intl.formatMessage({
247
- id: 'DS.DATE-PICKER.SELECT-DATE'
248
- })) || ''
249
- };
250
- return updatedTexts;
240
+ return getDefaultTexts(intl, texts);
251
241
  };
252
242
 
253
243
  _proto.getSnapshotBeforeUpdate = function getSnapshotBeforeUpdate(prevProps) {
@@ -326,4 +316,4 @@ _defineProperty(RawDatePicker, "defaultProps", {
326
316
  disabledSeconds: []
327
317
  });
328
318
 
329
- export default RawDatePicker;
319
+ export default injectIntl(RawDatePicker);
@@ -0,0 +1,3 @@
1
+ import { IntlShape } from 'react-intl';
2
+ import { Texts } from '../DatePicker.types';
3
+ export declare const getDefaultTexts: (intl: IntlShape, texts?: Partial<Texts>) => Texts;
@@ -0,0 +1,28 @@
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 React from 'react';
8
+ import { FormattedMessage } from 'react-intl';
9
+ export var getDefaultTexts = function getDefaultTexts(intl, texts) {
10
+ var defaultTexts = {
11
+ apply: /*#__PURE__*/React.createElement(FormattedMessage, {
12
+ id: "DS.DATE-PICKER.APPLY",
13
+ defaultMessage: "Apply"
14
+ }),
15
+ now: /*#__PURE__*/React.createElement(FormattedMessage, {
16
+ id: "DS.DATE-PICKER.NOW",
17
+ defaultMessage: "Now"
18
+ }),
19
+ inputPlaceholder: intl.formatMessage({
20
+ id: 'DS.DATE-PICKER.SELECT-DATE'
21
+ }),
22
+ clearTooltip: /*#__PURE__*/React.createElement(FormattedMessage, {
23
+ id: "DS.DATE-PICKER.CLEAR-TOOLTIP",
24
+ defaultMessage: "Clear"
25
+ })
26
+ };
27
+ return texts ? _objectSpread({}, defaultTexts, {}, texts) : defaultTexts;
28
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-date-picker",
3
- "version": "0.11.4",
3
+ "version": "0.11.6",
4
4
  "description": "DatePicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,14 +34,14 @@
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
36
  "@date-fns/upgrade": "^1.0.3",
37
- "@synerise/ds-button": "^0.21.1",
38
- "@synerise/ds-data-format": "^0.5.0",
39
- "@synerise/ds-dropdown": "^0.18.2",
40
- "@synerise/ds-icon": "^0.63.0",
41
- "@synerise/ds-input": "^0.22.1",
42
- "@synerise/ds-time-picker": "^0.10.12",
43
- "@synerise/ds-tooltip": "^0.14.31",
44
- "@synerise/ds-utils": "^0.27.0",
37
+ "@synerise/ds-button": "^0.21.2",
38
+ "@synerise/ds-data-format": "^0.5.1",
39
+ "@synerise/ds-dropdown": "^0.18.4",
40
+ "@synerise/ds-icon": "^0.64.0",
41
+ "@synerise/ds-input": "^0.23.1",
42
+ "@synerise/ds-time-picker": "^0.10.14",
43
+ "@synerise/ds-tooltip": "^0.14.32",
44
+ "@synerise/ds-utils": "^0.28.0",
45
45
  "classnames": "2.3.2",
46
46
  "date-fns": "2.16.1",
47
47
  "lodash": "^4.17.20",
@@ -52,8 +52,8 @@
52
52
  "peerDependencies": {
53
53
  "@synerise/ds-core": "*",
54
54
  "antd": "4.7.0",
55
- "react": ">=16.9.0 < 17.0.0",
55
+ "react": ">=16.9.0 <= 17.0.2",
56
56
  "styled-components": "5.0.1"
57
57
  },
58
- "gitHead": "587eb113074985ae21e4f0c25ec33c3e3e2e072b"
58
+ "gitHead": "6e5e5202d6c6f1c2caf6bfef799009813b437b3d"
59
59
  }