@synerise/ds-time-picker 0.9.19 → 0.10.1

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,25 @@
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.10.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.10.0...@synerise/ds-time-picker@0.10.1) (2024-04-02)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-time-picker
9
+
10
+
11
+
12
+
13
+
14
+ # [0.10.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.9.19...@synerise/ds-time-picker@0.10.0) (2024-03-29)
15
+
16
+
17
+ ### Features
18
+
19
+ * **scrollbar:** added prop to control wheel event bubbling ([ef0b8e9](https://github.com/Synerise/synerise-design/commit/ef0b8e939a5293b62b99f01553b6d78350957360))
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.9.19](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.9.18...@synerise/ds-time-picker@0.9.19) (2024-03-20)
7
26
 
8
27
  **Note:** Version bump only for package @synerise/ds-time-picker
@@ -1,8 +1,11 @@
1
- import * as React from 'react';
1
+ import dayjs from 'dayjs';
2
2
  import { TimePickerProps } from './types/TimePicker.types';
3
- declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<TimePickerProps, "intl"> & {
4
- forwardedRef?: React.Ref<any> | undefined;
5
- } & React.RefAttributes<any>> & {
6
- WrappedComponent: React.ComponentType<TimePickerProps>;
3
+ declare const TimePicker: {
4
+ ({ placement, placeholder, trigger, value, units, defaultOpen, onChange, containerStyle, timeFormat, valueFormatOptions, use12HourClock, alwaysOpen, dropdownProps, inputProps, disabled, disabledHours, disabledMinutes, disabledSeconds, overlayClassName, className, clearTooltip, raw, onClockModeChange, errorText, }: TimePickerProps): JSX.Element;
5
+ defaultProps: {
6
+ placement: string;
7
+ trigger: string[];
8
+ units: dayjs.UnitType[];
9
+ };
7
10
  };
8
- export default _default;
11
+ export default TimePicker;
@@ -6,9 +6,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  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; }
8
8
 
9
- import * as React from 'react';
10
- import { useCallback } from 'react';
11
- import { FormattedMessage, injectIntl } from 'react-intl';
9
+ import React, { Fragment, useCallback, useMemo, useState } from 'react';
10
+ import { FormattedMessage, useIntl } from 'react-intl';
12
11
  import { range } from 'lodash';
13
12
  import dayjs from 'dayjs';
14
13
  import customParseFormatPlugin from 'dayjs/plugin/customParseFormat';
@@ -54,25 +53,27 @@ var TimePicker = function TimePicker(_ref) {
54
53
  }) : _ref$clearTooltip,
55
54
  raw = _ref.raw,
56
55
  onClockModeChange = _ref.onClockModeChange,
57
- intl = _ref.intl,
58
56
  errorText = _ref.errorText;
59
57
 
60
58
  var _useDataFormat = useDataFormat(),
61
59
  formatValue = _useDataFormat.formatValue,
62
60
  is12HoursClockFromDataFormat = _useDataFormat.is12HoursClock;
63
61
 
64
- var _React$useState = React.useState(defaultOpen || false),
65
- open = _React$useState[0],
66
- setOpen = _React$useState[1];
62
+ var _useState = useState(defaultOpen || false),
63
+ open = _useState[0],
64
+ setOpen = _useState[1];
67
65
 
68
- var is12HourClock = React.useMemo(function () {
66
+ var _useIntl = useIntl(),
67
+ formatMessage = _useIntl.formatMessage;
68
+
69
+ var is12HourClock = useMemo(function () {
69
70
  if (use12HourClock === undefined) return is12HoursClockFromDataFormat;
70
71
  return use12HourClock;
71
72
  }, [is12HoursClockFromDataFormat, use12HourClock]);
72
- var timeFormatByClockMode = React.useMemo(function () {
73
+ var timeFormatByClockMode = useMemo(function () {
73
74
  return timeFormat != null ? timeFormat : is12HourClock ? 'hh:mm:ss A' : 'HH:mm:ss';
74
75
  }, [timeFormat, is12HourClock]);
75
- var getTimeString = React.useCallback(function (date) {
76
+ var getTimeString = useCallback(function (date) {
76
77
  if (timeFormat) {
77
78
  return dayjs(date).format(timeFormatByClockMode);
78
79
  }
@@ -175,7 +176,7 @@ var TimePicker = function TimePicker(_ref) {
175
176
  "data-testid": "tp-overlay-container",
176
177
  className: overlayClassName
177
178
  }, unitsToRender.map(function (u, index) {
178
- return /*#__PURE__*/React.createElement(React.Fragment, {
179
+ return /*#__PURE__*/React.createElement(Fragment, {
179
180
  key: u.unit
180
181
  }, /*#__PURE__*/React.createElement(Unit, _extends({}, u, {
181
182
  value: value,
@@ -187,11 +188,11 @@ var TimePicker = function TimePicker(_ref) {
187
188
  }), is12HourClock && renderClockSwitch());
188
189
  var localValue = value;
189
190
  var dateString = localValue && getTimeString(localValue);
190
- var clear = React.useCallback(function () {
191
+ var clear = useCallback(function () {
191
192
  setOpen(false);
192
193
  onChange && onChange(undefined, '');
193
194
  }, [setOpen, onChange]);
194
- var timePickerIcon = React.useMemo(function () {
195
+ var timePickerIcon = useMemo(function () {
195
196
  return (alwaysOpen || open) && dateString ? /*#__PURE__*/React.createElement(S.ClearIcon, {
196
197
  component: /*#__PURE__*/React.createElement(Tooltip, {
197
198
  title: clearTooltip
@@ -205,15 +206,15 @@ var TimePicker = function TimePicker(_ref) {
205
206
  }
206
207
  });
207
208
  }, [open, dateString, clear, clearTooltip, alwaysOpen, disabled]);
208
- var placeholderValue = React.useMemo(function () {
209
+ var placeholderValue = useMemo(function () {
209
210
  if (value) {
210
211
  return getTimeString(value);
211
212
  }
212
213
 
213
- return placeholder || intl.formatMessage({
214
+ return placeholder || formatMessage({
214
215
  id: 'DS.TIME-PICKER.PLACEHOLDER'
215
216
  });
216
- }, [placeholder, intl, value, getTimeString]);
217
+ }, [placeholder, formatMessage, value, getTimeString]);
217
218
 
218
219
  if (raw) {
219
220
  return overlay;
@@ -247,4 +248,4 @@ TimePicker.defaultProps = {
247
248
  trigger: ['click'],
248
249
  units: defaultUnits
249
250
  };
250
- export default injectIntl(TimePicker);
251
+ export default TimePicker;
package/dist/Unit.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import React, { useRef, useMemo, useState, useEffect } from 'react';
2
2
  import { debounce } from 'debounce';
3
3
  import Scrollbar from '@synerise/ds-scrollbar';
4
4
  import * as S from './TimePicker.styles';
@@ -13,26 +13,26 @@ var Unit = function Unit(_ref) {
13
13
  unit = _ref.unit,
14
14
  onSelect = _ref.onSelect,
15
15
  use12HourClock = _ref.use12HourClock;
16
- var selected = React.useMemo(function () {
16
+ var selected = useMemo(function () {
17
17
  return getUnitSelectedNumber(value, unit, use12HourClock);
18
18
  }, [unit, use12HourClock, value]);
19
19
 
20
- var _React$useState = React.useState(false),
21
- forceUpdate = _React$useState[0],
22
- setForceUpdate = _React$useState[1];
20
+ var _useState = useState(false),
21
+ forceUpdate = _useState[0],
22
+ setForceUpdate = _useState[1];
23
23
 
24
- var selectedCellRef = React.useRef(null);
25
- var unitContainerRef = React.useRef(null);
24
+ var selectedCellRef = useRef(null);
25
+ var unitContainerRef = useRef(null);
26
26
 
27
- var _React$useState2 = React.useState(300),
28
- containerHeight = _React$useState2[0],
29
- setContainerHeight = _React$useState2[1];
27
+ var _useState2 = useState(300),
28
+ containerHeight = _useState2[0],
29
+ setContainerHeight = _useState2[1];
30
30
 
31
- var _React$useState3 = React.useState(true),
32
- isFirstRender = _React$useState3[0],
33
- setFirstRender = _React$useState3[1];
31
+ var _useState3 = useState(true),
32
+ isFirstRender = _useState3[0],
33
+ setFirstRender = _useState3[1];
34
34
 
35
- React.useEffect(function () {
35
+ useEffect(function () {
36
36
  if (isFirstRender) {
37
37
  setFirstRender(false);
38
38
 
@@ -54,12 +54,12 @@ var Unit = function Unit(_ref) {
54
54
  };
55
55
 
56
56
  var debouncedScrollHandler = debounce(scrollHandler, DEBOUNCE_DELAY);
57
- React.useEffect(function () {
57
+ useEffect(function () {
58
58
  return function () {
59
59
  debouncedScrollHandler.clear();
60
60
  };
61
61
  }, [debouncedScrollHandler]);
62
- React.useEffect(function () {
62
+ useEffect(function () {
63
63
  if (selectedCellRef.current && unitContainerRef.current) {
64
64
  var offsetToParent = selectedCellRef.current.offsetTop - unitContainerRef.current.offsetTop;
65
65
  var scrollBehaviour = isFirstRender || !containerHeight ? 'auto' : 'smooth';
@@ -77,6 +77,7 @@ var Unit = function Unit(_ref) {
77
77
  return /*#__PURE__*/React.createElement(S.Unit, {
78
78
  "data-testid": "ds-time-picker-unit-" + unit
79
79
  }, /*#__PURE__*/React.createElement(Scrollbar, {
80
+ confineScroll: true,
80
81
  ref: unitContainerRef,
81
82
  onScroll: debouncedScrollHandler,
82
83
  maxHeight: 192
@@ -1,6 +1,5 @@
1
1
  import { ReactNode, CSSProperties } from 'react';
2
2
  import dayjs from 'dayjs';
3
- import { IntlShape } from 'react-intl';
4
3
  import { InputProps } from 'antd/es/input/Input';
5
4
  import { DropdownProps } from '@synerise/ds-dropdown/dist/Dropdown';
6
5
  import { DateToFormatOptions } from '@synerise/ds-data-format';
@@ -20,7 +19,6 @@ export type TimePickerProps = TimePickerDisabledUnits & {
20
19
  disabled?: boolean;
21
20
  dropdownProps?: Partial<DropdownProps>;
22
21
  inputProps?: Partial<InputProps>;
23
- intl: IntlShape;
24
22
  onChange?: (value: Date | undefined, timeString: string) => void;
25
23
  onClockModeChange?: (mode: string) => void;
26
24
  overlayClassName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-time-picker",
3
- "version": "0.9.19",
3
+ "version": "0.10.1",
4
4
  "description": "TimePicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -34,13 +34,13 @@
34
34
  "types": "dist/index.d.ts",
35
35
  "dependencies": {
36
36
  "@synerise/ds-data-format": "^0.4.8",
37
- "@synerise/ds-dropdown": "^0.17.101",
38
- "@synerise/ds-icon": "^0.60.4",
39
- "@synerise/ds-input": "^0.20.2",
40
- "@synerise/ds-scrollbar": "^0.9.0",
41
- "@synerise/ds-tooltip": "^0.14.21",
37
+ "@synerise/ds-dropdown": "^0.17.103",
38
+ "@synerise/ds-icon": "^0.60.6",
39
+ "@synerise/ds-input": "^0.20.4",
40
+ "@synerise/ds-scrollbar": "^0.10.1",
41
+ "@synerise/ds-tooltip": "^0.14.23",
42
42
  "@synerise/ds-typography": "^0.14.3",
43
- "@synerise/ds-utils": "^0.26.0",
43
+ "@synerise/ds-utils": "^0.26.2",
44
44
  "dayjs": "^1.8.19",
45
45
  "debounce": "^1.2.0",
46
46
  "lodash": "^4.17.19",
@@ -55,5 +55,5 @@
55
55
  "@testing-library/react": "10.0.1",
56
56
  "@types/debounce": "^1.2.1"
57
57
  },
58
- "gitHead": "2df913352aa96e8aed75894489afb3a4ee303370"
58
+ "gitHead": "67108cb227db0024b189fa289840cfb5a5d0de8c"
59
59
  }