@synerise/ds-time-picker 0.6.16 → 0.6.19
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 +48 -0
- package/dist/TimePicker.js +29 -35
- package/dist/Unit.js +13 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
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.6.19](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.18...@synerise/ds-time-picker@0.6.19) (2022-06-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **time-picker:** load initial values into the internal state ([7905253](https://github.com/Synerise/synerise-design/commit/7905253a7cf2e3bcbf4ca3ac1efb02fe72bc0aaf))
|
|
12
|
+
* **time-picker:** simplify selecting time ([6ee5050](https://github.com/Synerise/synerise-design/commit/6ee50508f4fee04cefd70c11dd9c0625cbe01092))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [0.6.18](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.17...@synerise/ds-time-picker@0.6.18) (2022-06-15)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **time-picker:** add ts-ignore ([3073779](https://github.com/Synerise/synerise-design/commit/30737798dc2bd6bfe74f4b534427da61af669948))
|
|
24
|
+
* **time-picker:** add ts-ignore ([2389568](https://github.com/Synerise/synerise-design/commit/2389568a57523faf0bd84d3fdb760f25d5c3b8bb))
|
|
25
|
+
* **time-picker:** change to use useMemo ([24cfb11](https://github.com/Synerise/synerise-design/commit/24cfb11566103009404788572bbc47b4478f23d5))
|
|
26
|
+
* **time-picker:** fix changing time ([ab3281d](https://github.com/Synerise/synerise-design/commit/ab3281d093b791715cdea462b7e47f05ee7ad360))
|
|
27
|
+
* **time-picker:** fix changing time ([a1c3507](https://github.com/Synerise/synerise-design/commit/a1c3507db5e361fc055e8e4afc79ad883046c99e))
|
|
28
|
+
* **time-picker:** fix changing time ([ea969ed](https://github.com/Synerise/synerise-design/commit/ea969ed02617cbc9770aee607369b2280bea6544))
|
|
29
|
+
* **time-picker:** fix changing time to not show local time ([7873cd7](https://github.com/Synerise/synerise-design/commit/7873cd76d82512ee5b73f2b72606140b3de5e353))
|
|
30
|
+
* **time-picker:** fix dependencies and add ts-ignore ([4b0be58](https://github.com/Synerise/synerise-design/commit/4b0be584249ab1ba8b669c10c05aa4a11c9e0845))
|
|
31
|
+
* **time-picker:** fix dependencies and add ts-ignore ([1771914](https://github.com/Synerise/synerise-design/commit/17719142d304cc8c11408641e24e7c16ffddac62))
|
|
32
|
+
* **time-picker:** fix dependencies and add ts-ignore ([afee591](https://github.com/Synerise/synerise-design/commit/afee5910c173414d34660362864bf44714b3aabb))
|
|
33
|
+
* **time-picker:** fix dependencies and add ts-ignore ([296476b](https://github.com/Synerise/synerise-design/commit/296476b90111532b82151b566f88222288890c16))
|
|
34
|
+
* **time-picker:** fix prop ([221c648](https://github.com/Synerise/synerise-design/commit/221c64816a87ed371dddd03baaa4f0feb128698f))
|
|
35
|
+
* **time-picker:** fix prop ([236c04e](https://github.com/Synerise/synerise-design/commit/236c04ea1e0aa9f32e0912ae0a646d9f7ea67ac5))
|
|
36
|
+
* **time-picker:** fix scroll on selected time to pop on top in dropdown ([2c2eced](https://github.com/Synerise/synerise-design/commit/2c2eced6f65d022eb60a4edc07ee6c777d50fda3))
|
|
37
|
+
* **time-picker:** fix showing data ([ac0816b](https://github.com/Synerise/synerise-design/commit/ac0816b977fba292f250a0a3b4035b5a70f9bfd2))
|
|
38
|
+
* **time-picker:** fix showing data ([153c1b0](https://github.com/Synerise/synerise-design/commit/153c1b0f647da658c7f6680ac1fc357ebf5c59a9))
|
|
39
|
+
* **time-picker:** remove console logs ([96903a4](https://github.com/Synerise/synerise-design/commit/96903a480933308254d7e9df04a4ff4cd0e0411d))
|
|
40
|
+
* **time-picker:** scroll only if scrollTo is function ([358cd3d](https://github.com/Synerise/synerise-design/commit/358cd3d9e9a360ecc2062693c88e9a688aaffe72))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [0.6.17](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.16...@synerise/ds-time-picker@0.6.17) (2022-04-29)
|
|
47
|
+
|
|
48
|
+
**Note:** Version bump only for package @synerise/ds-time-picker
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
6
54
|
## [0.6.16](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.15...@synerise/ds-time-picker@0.6.16) (2022-04-05)
|
|
7
55
|
|
|
8
56
|
**Note:** Version bump only for package @synerise/ds-time-picker
|
package/dist/TimePicker.js
CHANGED
|
@@ -52,20 +52,19 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
52
52
|
open = _React$useState[0],
|
|
53
53
|
setOpen = _React$useState[1];
|
|
54
54
|
|
|
55
|
-
var _React$useState2 = React.useState(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
var _React$useState2 = React.useState(defaultAM ? CLOCK_MODES.AM : CLOCK_MODES.PM),
|
|
56
|
+
clockMode = _React$useState2[0],
|
|
57
|
+
setClockMode = _React$useState2[1];
|
|
58
|
+
|
|
59
|
+
var getTimeString = function getTimeString(date) {
|
|
60
|
+
return dayjs(date).format(timeFormat);
|
|
61
|
+
}; // eslint-disable-next-line
|
|
62
|
+
// @ts-ignore
|
|
58
63
|
|
|
59
|
-
var _React$useState3 = React.useState(defaultAM ? CLOCK_MODES.AM : CLOCK_MODES.PM),
|
|
60
|
-
clockMode = _React$useState3[0],
|
|
61
|
-
setClockMode = _React$useState3[1];
|
|
62
64
|
|
|
63
|
-
React.useEffect(function () {
|
|
64
|
-
setLocalValue(value);
|
|
65
|
-
}, [value]);
|
|
66
65
|
var unitConfig = [{
|
|
67
66
|
unit: 'hour',
|
|
68
|
-
options: use12HourClock ? range(12
|
|
67
|
+
options: use12HourClock ? range(12) : range(24),
|
|
69
68
|
disabled: disabledHours,
|
|
70
69
|
insertSeperator: true
|
|
71
70
|
}, {
|
|
@@ -86,35 +85,26 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
86
85
|
});
|
|
87
86
|
}, [units, unitConfig]);
|
|
88
87
|
|
|
89
|
-
var getTimeString = function getTimeString(date) {
|
|
90
|
-
return dayjs(date).format(timeFormat);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
88
|
var onVisibleChange = function onVisibleChange(visible) {
|
|
94
89
|
setOpen(visible);
|
|
95
|
-
!visible && onChange && onChange(
|
|
90
|
+
!visible && onChange && onChange(value, getTimeString(value));
|
|
96
91
|
};
|
|
97
92
|
|
|
98
93
|
var handleChange = function handleChange(unit, newValue) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (res.length !== defaultUnits.length) {
|
|
111
|
-
res.forEach(function (u) {
|
|
112
|
-
newDateObject = dayjs(newDateObject).set(u, 0);
|
|
94
|
+
var wasUndefined = value === undefined;
|
|
95
|
+
var dateBuilder = dayjs(value);
|
|
96
|
+
dateBuilder = dateBuilder[unit](newValue);
|
|
97
|
+
|
|
98
|
+
if (wasUndefined) {
|
|
99
|
+
// set remaining time fields to 0, HH:00:00, 00:mm:00, 00:00:ss
|
|
100
|
+
unitConfig.filter(function (u) {
|
|
101
|
+
return u.unit !== unit;
|
|
102
|
+
}).forEach(function (unitDef) {
|
|
103
|
+
return dateBuilder = dateBuilder[unitDef.unit](0);
|
|
113
104
|
});
|
|
114
105
|
}
|
|
115
106
|
|
|
116
|
-
var newDate =
|
|
117
|
-
setLocalValue(newDate);
|
|
107
|
+
var newDate = dateBuilder.toDate();
|
|
118
108
|
onChange && onChange(newDate, getTimeString(newDate));
|
|
119
109
|
};
|
|
120
110
|
|
|
@@ -138,18 +128,18 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
138
128
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
139
129
|
key: u.unit
|
|
140
130
|
}, /*#__PURE__*/React.createElement(Unit, _extends({}, u, {
|
|
141
|
-
value:
|
|
131
|
+
value: value,
|
|
142
132
|
onSelect: function onSelect(newValue) {
|
|
143
133
|
return handleChange(u.unit, newValue);
|
|
144
134
|
}
|
|
145
135
|
})), (index !== unitsToRender.length - 1 || !!use12HourClock) && /*#__PURE__*/React.createElement(S.UnitSeperator, null));
|
|
146
136
|
}), use12HourClock && renderClockSwitch());
|
|
137
|
+
var localValue = value;
|
|
147
138
|
var dateString = localValue && getTimeString(localValue);
|
|
148
139
|
var clear = React.useCallback(function () {
|
|
149
|
-
setLocalValue(undefined);
|
|
150
140
|
setOpen(false);
|
|
151
141
|
onChange && onChange(undefined, '');
|
|
152
|
-
}, [setOpen,
|
|
142
|
+
}, [setOpen, onChange]);
|
|
153
143
|
var timePickerIcon = React.useMemo(function () {
|
|
154
144
|
return (alwaysOpen || open) && dateString ? /*#__PURE__*/React.createElement(S.ClearIcon, {
|
|
155
145
|
component: /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -165,10 +155,14 @@ var TimePicker = function TimePicker(_ref) {
|
|
|
165
155
|
});
|
|
166
156
|
}, [open, dateString, clear, clearTooltip, alwaysOpen, disabled]);
|
|
167
157
|
var placeholderValue = React.useMemo(function () {
|
|
158
|
+
if (value) {
|
|
159
|
+
return dayjs(value).format('HH:mm:ss');
|
|
160
|
+
}
|
|
161
|
+
|
|
168
162
|
return placeholder || intl.formatMessage({
|
|
169
163
|
id: 'DS.TIME-PICKER.PLACEHOLDER'
|
|
170
164
|
});
|
|
171
|
-
}, [placeholder, intl]);
|
|
165
|
+
}, [placeholder, intl, value]);
|
|
172
166
|
|
|
173
167
|
if (raw) {
|
|
174
168
|
return overlay;
|
package/dist/Unit.js
CHANGED
|
@@ -20,13 +20,13 @@ var Unit = function Unit(_ref) {
|
|
|
20
20
|
var selectedCellRef = React.useRef(null);
|
|
21
21
|
var unitContainerRef = React.useRef(null);
|
|
22
22
|
|
|
23
|
-
var _React$useState2 = React.useState(
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
var _React$useState2 = React.useState(300),
|
|
24
|
+
containerHeight = _React$useState2[0],
|
|
25
|
+
setContainerHeight = _React$useState2[1];
|
|
26
26
|
|
|
27
|
-
var _React$useState3 = React.useState(
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
var _React$useState3 = React.useState(true),
|
|
28
|
+
isFirstRender = _React$useState3[0],
|
|
29
|
+
setFirstRender = _React$useState3[1];
|
|
30
30
|
|
|
31
31
|
React.useEffect(function () {
|
|
32
32
|
if (isFirstRender) {
|
|
@@ -49,9 +49,11 @@ var Unit = function Unit(_ref) {
|
|
|
49
49
|
}, [unitContainerRef]);
|
|
50
50
|
React.useEffect(function () {
|
|
51
51
|
if (selectedCellRef.current && unitContainerRef.current) {
|
|
52
|
+
var _unitContainerRef$cur, _unitContainerRef$cur2;
|
|
53
|
+
|
|
52
54
|
var offsetToParent = selectedCellRef.current.offsetTop - unitContainerRef.current.offsetTop;
|
|
53
55
|
var scrollBehaviour = isFirstRender || !containerHeight ? 'auto' : 'smooth';
|
|
54
|
-
(unitContainerRef == null ? void 0 : unitContainerRef.current) && unitContainerRef.current.scrollTo({
|
|
56
|
+
(unitContainerRef == null ? void 0 : (_unitContainerRef$cur = unitContainerRef.current) == null ? void 0 : (_unitContainerRef$cur2 = _unitContainerRef$cur.scrollTo) == null ? void 0 : _unitContainerRef$cur2.call) && unitContainerRef.current.scrollTo({
|
|
55
57
|
top: offsetToParent,
|
|
56
58
|
behavior: scrollBehaviour
|
|
57
59
|
});
|
|
@@ -71,7 +73,10 @@ var Unit = function Unit(_ref) {
|
|
|
71
73
|
disabled: isDisabled,
|
|
72
74
|
onClick: function onClick() {
|
|
73
75
|
onSelect(option);
|
|
74
|
-
|
|
76
|
+
setTimeout(function () {
|
|
77
|
+
// timeout is required to make sure that the ref is updated
|
|
78
|
+
setForceUpdate(!forceUpdate);
|
|
79
|
+
}, 50);
|
|
75
80
|
},
|
|
76
81
|
active: isSelected,
|
|
77
82
|
ref: isSelected ? selectedCellRef : null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-time-picker",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
4
|
"description": "TimePicker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
],
|
|
33
33
|
"types": "dist/index.d.ts",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-dropdown": "^0.17.
|
|
35
|
+
"@synerise/ds-dropdown": "^0.17.18",
|
|
36
36
|
"@synerise/ds-icon": "^0.49.0",
|
|
37
37
|
"@synerise/ds-input": "^0.18.10",
|
|
38
|
-
"@synerise/ds-search-bar": "^0.
|
|
38
|
+
"@synerise/ds-search-bar": "^0.6.0",
|
|
39
39
|
"@synerise/ds-typography": "^0.12.2",
|
|
40
40
|
"dayjs": "^1.8.19",
|
|
41
41
|
"debounce": "^1.2.0"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/debounce": "^1.2.0"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "b2b8c9f85179763159e3c83801b568943f132741"
|
|
51
51
|
}
|