@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 +19 -0
- package/dist/TimePicker.d.ts +9 -6
- package/dist/TimePicker.js +18 -17
- package/dist/Unit.js +17 -16
- package/dist/types/TimePicker.types.d.ts +0 -2
- package/package.json +8 -8
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
|
package/dist/TimePicker.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
2
|
import { TimePickerProps } from './types/TimePicker.types';
|
|
3
|
-
declare const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
11
|
+
export default TimePicker;
|
package/dist/TimePicker.js
CHANGED
|
@@ -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
|
|
10
|
-
import {
|
|
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
|
|
65
|
-
open =
|
|
66
|
-
setOpen =
|
|
62
|
+
var _useState = useState(defaultOpen || false),
|
|
63
|
+
open = _useState[0],
|
|
64
|
+
setOpen = _useState[1];
|
|
67
65
|
|
|
68
|
-
var
|
|
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 =
|
|
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 =
|
|
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(
|
|
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 =
|
|
191
|
+
var clear = useCallback(function () {
|
|
191
192
|
setOpen(false);
|
|
192
193
|
onChange && onChange(undefined, '');
|
|
193
194
|
}, [setOpen, onChange]);
|
|
194
|
-
var timePickerIcon =
|
|
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 =
|
|
209
|
+
var placeholderValue = useMemo(function () {
|
|
209
210
|
if (value) {
|
|
210
211
|
return getTimeString(value);
|
|
211
212
|
}
|
|
212
213
|
|
|
213
|
-
return placeholder ||
|
|
214
|
+
return placeholder || formatMessage({
|
|
214
215
|
id: 'DS.TIME-PICKER.PLACEHOLDER'
|
|
215
216
|
});
|
|
216
|
-
}, [placeholder,
|
|
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
|
|
251
|
+
export default TimePicker;
|
package/dist/Unit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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 =
|
|
16
|
+
var selected = useMemo(function () {
|
|
17
17
|
return getUnitSelectedNumber(value, unit, use12HourClock);
|
|
18
18
|
}, [unit, use12HourClock, value]);
|
|
19
19
|
|
|
20
|
-
var
|
|
21
|
-
forceUpdate =
|
|
22
|
-
setForceUpdate =
|
|
20
|
+
var _useState = useState(false),
|
|
21
|
+
forceUpdate = _useState[0],
|
|
22
|
+
setForceUpdate = _useState[1];
|
|
23
23
|
|
|
24
|
-
var selectedCellRef =
|
|
25
|
-
var unitContainerRef =
|
|
24
|
+
var selectedCellRef = useRef(null);
|
|
25
|
+
var unitContainerRef = useRef(null);
|
|
26
26
|
|
|
27
|
-
var
|
|
28
|
-
containerHeight =
|
|
29
|
-
setContainerHeight =
|
|
27
|
+
var _useState2 = useState(300),
|
|
28
|
+
containerHeight = _useState2[0],
|
|
29
|
+
setContainerHeight = _useState2[1];
|
|
30
30
|
|
|
31
|
-
var
|
|
32
|
-
isFirstRender =
|
|
33
|
-
setFirstRender =
|
|
31
|
+
var _useState3 = useState(true),
|
|
32
|
+
isFirstRender = _useState3[0],
|
|
33
|
+
setFirstRender = _useState3[1];
|
|
34
34
|
|
|
35
|
-
|
|
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
|
-
|
|
57
|
+
useEffect(function () {
|
|
58
58
|
return function () {
|
|
59
59
|
debouncedScrollHandler.clear();
|
|
60
60
|
};
|
|
61
61
|
}, [debouncedScrollHandler]);
|
|
62
|
-
|
|
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.
|
|
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.
|
|
38
|
-
"@synerise/ds-icon": "^0.60.
|
|
39
|
-
"@synerise/ds-input": "^0.20.
|
|
40
|
-
"@synerise/ds-scrollbar": "^0.
|
|
41
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
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.
|
|
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": "
|
|
58
|
+
"gitHead": "67108cb227db0024b189fa289840cfb5a5d0de8c"
|
|
59
59
|
}
|