@synerise/ds-time-picker 0.6.2 → 0.6.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,42 @@
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.6](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.5...@synerise/ds-time-picker@0.6.6) (2021-12-29)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-time-picker
9
+
10
+
11
+
12
+
13
+
14
+ ## [0.6.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.4...@synerise/ds-time-picker@0.6.5) (2021-12-22)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **time-picker:** _.range, because [...array] transpiles to [].concat ([c475433](https://github.com/Synerise/synerise-design/commit/c475433cfcac69b54c0ce2fa3c812cab3f947c9c))
20
+ * **time-picker:** update component ([2fb6363](https://github.com/Synerise/synerise-design/commit/2fb6363641f149135118b7b656c5e548925aeae0))
21
+
22
+
23
+
24
+
25
+
26
+ ## [0.6.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.3...@synerise/ds-time-picker@0.6.4) (2021-11-23)
27
+
28
+ **Note:** Version bump only for package @synerise/ds-time-picker
29
+
30
+
31
+
32
+
33
+
34
+ ## [0.6.3](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.2...@synerise/ds-time-picker@0.6.3) (2021-11-22)
35
+
36
+ **Note:** Version bump only for package @synerise/ds-time-picker
37
+
38
+
39
+
40
+
41
+
6
42
  ## [0.6.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-time-picker@0.6.1...@synerise/ds-time-picker@0.6.2) (2021-11-16)
7
43
 
8
44
  **Note:** Version bump only for package @synerise/ds-time-picker
@@ -1,27 +1,8 @@
1
1
  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); }
2
2
 
3
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
-
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
-
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
-
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
12
-
13
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
14
-
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
16
-
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
18
-
19
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
20
-
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
-
23
3
  import * as React from 'react';
24
4
  import dayjs from 'dayjs';
5
+ import { range } from 'lodash';
25
6
  import Icon, { ClockM, Close3S } from '@synerise/ds-icon';
26
7
  import Dropdown from '@synerise/ds-dropdown';
27
8
  import Tooltip from '@synerise/ds-tooltip/dist/Tooltip';
@@ -68,41 +49,38 @@ var TimePicker = function TimePicker(_ref) {
68
49
  intl = _ref.intl;
69
50
 
70
51
  var _React$useState = React.useState(defaultOpen || false),
71
- _React$useState2 = _slicedToArray(_React$useState, 2),
72
- open = _React$useState2[0],
73
- setOpen = _React$useState2[1];
52
+ open = _React$useState[0],
53
+ setOpen = _React$useState[1];
74
54
 
75
- var _React$useState3 = React.useState(value),
76
- _React$useState4 = _slicedToArray(_React$useState3, 2),
77
- localValue = _React$useState4[0],
78
- setLocalValue = _React$useState4[1];
55
+ var _React$useState2 = React.useState(value),
56
+ localValue = _React$useState2[0],
57
+ setLocalValue = _React$useState2[1];
79
58
 
80
- var _React$useState5 = React.useState(defaultAM ? CLOCK_MODES.AM : CLOCK_MODES.PM),
81
- _React$useState6 = _slicedToArray(_React$useState5, 2),
82
- clockMode = _React$useState6[0],
83
- setClockMode = _React$useState6[1];
59
+ var _React$useState3 = React.useState(defaultAM ? CLOCK_MODES.AM : CLOCK_MODES.PM),
60
+ clockMode = _React$useState3[0],
61
+ setClockMode = _React$useState3[1];
84
62
 
85
63
  React.useEffect(function () {
86
64
  setLocalValue(value);
87
65
  }, [value]);
88
66
  var unitConfig = [{
89
67
  unit: 'hour',
90
- options: use12HourClock ? _toConsumableArray(Array(13).keys()) : _toConsumableArray(Array(24).keys()),
68
+ options: use12HourClock ? range(12 + 1) : range(24),
91
69
  disabled: disabledHours,
92
70
  insertSeperator: true
93
71
  }, {
94
72
  unit: 'minute',
95
- options: _toConsumableArray(Array(60).keys()),
73
+ options: range(60),
96
74
  disabled: disabledMinutes,
97
75
  insertSeperator: true
98
76
  }, {
99
77
  unit: 'second',
100
- options: _toConsumableArray(Array(60).keys()),
78
+ options: range(60),
101
79
  disabled: disabledSeconds,
102
80
  insertSeperator: !!use12HourClock
103
81
  }];
104
82
  var unitsToRender = React.useMemo(function () {
105
- var availableUnits = units !== null && units !== void 0 && units.length ? units : defaultUnits;
83
+ var availableUnits = units != null && units.length ? units : defaultUnits;
106
84
  return unitConfig.filter(function (u) {
107
85
  return availableUnits && availableUnits.includes(u.unit);
108
86
  });
@@ -197,7 +175,7 @@ var TimePicker = function TimePicker(_ref) {
197
175
  }
198
176
 
199
177
  return /*#__PURE__*/React.createElement(S.Container, {
200
- className: "ds-time-picker ".concat(className || ''),
178
+ className: "ds-time-picker " + (className || ''),
201
179
  "data-testid": "tp-container",
202
180
  style: containerStyle
203
181
  }, /*#__PURE__*/React.createElement(Dropdown, _extends({
@@ -209,9 +187,9 @@ var TimePicker = function TimePicker(_ref) {
209
187
  disabled: disabled
210
188
  }, dropdownProps), /*#__PURE__*/React.createElement(S.TimePickerInput, _extends({
211
189
  disabled: disabled,
212
- className: "".concat(alwaysOpen || open ? 'active' : ''),
190
+ className: "" + (alwaysOpen || open ? 'active' : ''),
213
191
  "data-testid": "tp-input",
214
- value: use12HourClock && !!dateString ? "".concat(dateString, " ").concat(clockMode) : dateString,
192
+ value: use12HourClock && !!dateString ? dateString + " " + clockMode : dateString,
215
193
  placeholder: placeholderValue,
216
194
  readOnly: true,
217
195
  icon1: timePickerIcon
package/dist/Unit.js CHANGED
@@ -1,15 +1,3 @@
1
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
1
  import * as React from 'react';
14
2
  import dayjs from 'dayjs';
15
3
  import { debounce } from 'debounce';
@@ -26,22 +14,19 @@ var Unit = function Unit(_ref) {
26
14
  var selected = value && dayjs(value).get(unit);
27
15
 
28
16
  var _React$useState = React.useState(false),
29
- _React$useState2 = _slicedToArray(_React$useState, 2),
30
- forceUpdate = _React$useState2[0],
31
- setForceUpdate = _React$useState2[1];
17
+ forceUpdate = _React$useState[0],
18
+ setForceUpdate = _React$useState[1];
32
19
 
33
20
  var selectedCellRef = React.useRef(null);
34
21
  var unitContainerRef = React.useRef(null);
35
22
 
36
- var _React$useState3 = React.useState(true),
37
- _React$useState4 = _slicedToArray(_React$useState3, 2),
38
- isFirstRender = _React$useState4[0],
39
- setFirstRender = _React$useState4[1];
23
+ var _React$useState2 = React.useState(true),
24
+ isFirstRender = _React$useState2[0],
25
+ setFirstRender = _React$useState2[1];
40
26
 
41
- var _React$useState5 = React.useState(300),
42
- _React$useState6 = _slicedToArray(_React$useState5, 2),
43
- containerHeight = _React$useState6[0],
44
- setContainerHeight = _React$useState6[1];
27
+ var _React$useState3 = React.useState(300),
28
+ containerHeight = _React$useState3[0],
29
+ setContainerHeight = _React$useState3[1];
45
30
 
46
31
  React.useEffect(function () {
47
32
  if (isFirstRender) {
@@ -66,7 +51,7 @@ var Unit = function Unit(_ref) {
66
51
  if (selectedCellRef.current && unitContainerRef.current) {
67
52
  var offsetToParent = selectedCellRef.current.offsetTop - unitContainerRef.current.offsetTop;
68
53
  var scrollBehaviour = isFirstRender || !containerHeight ? 'auto' : 'smooth';
69
- (unitContainerRef === null || unitContainerRef === void 0 ? void 0 : unitContainerRef.current) && unitContainerRef.current.scrollTo({
54
+ (unitContainerRef == null ? void 0 : unitContainerRef.current) && unitContainerRef.current.scrollTo({
70
55
  top: offsetToParent,
71
56
  behavior: scrollBehaviour
72
57
  });
@@ -74,15 +59,15 @@ var Unit = function Unit(_ref) {
74
59
  }
75
60
  }, [selectedCellRef, unitContainerRef, isFirstRender, forceUpdate, containerHeight]);
76
61
  return /*#__PURE__*/React.createElement(S.Unit, {
77
- "data-testid": "ds-time-picker-unit-".concat(unit),
62
+ "data-testid": "ds-time-picker-unit-" + unit,
78
63
  ref: unitContainerRef,
79
64
  onScroll: debounce(scrollHandler, DEBOUNCE_DELAY)
80
65
  }, options.map(function (option) {
81
- var normalizedStringValue = option < 10 ? "0".concat(option) : option.toString();
66
+ var normalizedStringValue = option < 10 ? "0" + option : option.toString();
82
67
  var isDisabled = disabled && disabled.includes(option);
83
68
  var isSelected = selected === option;
84
69
  return /*#__PURE__*/React.createElement(S.Cell, {
85
- key: "".concat(unit, "-").concat(option),
70
+ key: unit + "-" + option,
86
71
  disabled: isDisabled,
87
72
  onClick: function onClick() {
88
73
  onSelect(option);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-time-picker",
3
- "version": "0.6.2",
3
+ "version": "0.6.6",
4
4
  "description": "TimePicker UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -32,11 +32,11 @@
32
32
  ],
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
- "@synerise/ds-dropdown": "^0.17.2",
36
- "@synerise/ds-icon": "^0.46.1",
37
- "@synerise/ds-input": "^0.18.1",
38
- "@synerise/ds-search-bar": "^0.5.1",
39
- "@synerise/ds-typography": "^0.12.1",
35
+ "@synerise/ds-dropdown": "^0.17.6",
36
+ "@synerise/ds-icon": "^0.46.2",
37
+ "@synerise/ds-input": "^0.18.3",
38
+ "@synerise/ds-search-bar": "^0.5.4",
39
+ "@synerise/ds-typography": "^0.12.2",
40
40
  "dayjs": "^1.8.19",
41
41
  "debounce": "^1.2.0"
42
42
  },
@@ -47,5 +47,5 @@
47
47
  "devDependencies": {
48
48
  "@types/debounce": "^1.2.0"
49
49
  },
50
- "gitHead": "8e667a88a48d774c550ff4766de71c4aab01f5a9"
50
+ "gitHead": "7ddae11318ca2906145c9f48e74df41ca5f15d49"
51
51
  }