@atlaskit/datetime-picker 12.3.7 → 12.3.8

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.
@@ -5,22 +5,16 @@ import _inherits from "@babel/runtime/helpers/inherits";
5
5
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
6
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
-
13
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
16
-
17
12
  import React from 'react';
18
13
  import ScrollLock from 'react-scrolllock';
19
14
  import noop from '@atlaskit/ds-lib/noop';
20
15
  import { sizes } from '@atlaskit/icon';
21
16
  import { Manager, Popper, Reference } from '@atlaskit/popper';
22
17
  import { gridSize, layers } from '@atlaskit/theme/constants';
23
-
24
18
  /**
25
19
  * This component renders layered content with fixed positioning.
26
20
  * Scroll is locked outside the layer to prevent the layered content from detaching from the
@@ -28,25 +22,17 @@ import { gridSize, layers } from '@atlaskit/theme/constants';
28
22
  */
29
23
  var FixedLayer = /*#__PURE__*/function (_React$Component) {
30
24
  _inherits(FixedLayer, _React$Component);
31
-
32
25
  var _super = _createSuper(FixedLayer);
33
-
34
26
  function FixedLayer() {
35
27
  var _this;
36
-
37
28
  _classCallCheck(this, FixedLayer);
38
-
39
29
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
40
30
  args[_key] = arguments[_key];
41
31
  }
42
-
43
32
  _this = _super.call.apply(_super, [this].concat(args));
44
-
45
33
  _defineProperty(_assertThisInitialized(_this), "update", noop);
46
-
47
34
  return _this;
48
35
  }
49
-
50
36
  _createClass(FixedLayer, [{
51
37
  key: "componentDidUpdate",
52
38
  value: function componentDidUpdate(prevProps) {
@@ -58,20 +44,18 @@ var FixedLayer = /*#__PURE__*/function (_React$Component) {
58
44
  key: "render",
59
45
  value: function render() {
60
46
  var _this2 = this;
61
-
62
47
  var _this$props = this.props,
63
- containerRef = _this$props.containerRef,
64
- content = _this$props.content,
65
- testId = _this$props.testId; // Wait for containerRef callback to cause a re-render
48
+ containerRef = _this$props.containerRef,
49
+ content = _this$props.content,
50
+ testId = _this$props.testId;
66
51
 
52
+ // Wait for containerRef callback to cause a re-render
67
53
  if (!containerRef) {
68
54
  return /*#__PURE__*/React.createElement("div", null);
69
55
  }
70
-
71
56
  var containerRect = containerRef.getBoundingClientRect();
72
57
  return (
73
58
  /*#__PURE__*/
74
-
75
59
  /* Need to wrap layer in a fixed position div so that it will render its content as fixed
76
60
  * We need to set the intial top value to where the container is and zIndex so that it still
77
61
  * applies since we're creating a new stacking context. */
@@ -91,8 +75,8 @@ var FixedLayer = /*#__PURE__*/function (_React$Component) {
91
75
  });
92
76
  }), /*#__PURE__*/React.createElement(Popper, null, function (_ref2) {
93
77
  var ref = _ref2.ref,
94
- style = _ref2.style,
95
- update = _ref2.update;
78
+ style = _ref2.style,
79
+ update = _ref2.update;
96
80
  _this2.update = update;
97
81
  return /*#__PURE__*/React.createElement("div", {
98
82
  ref: ref,
@@ -105,8 +89,6 @@ var FixedLayer = /*#__PURE__*/function (_React$Component) {
105
89
  );
106
90
  }
107
91
  }]);
108
-
109
92
  return FixedLayer;
110
93
  }(React.Component);
111
-
112
94
  export { FixedLayer as default };
@@ -1,9 +1,11 @@
1
1
  /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
2
3
  export var EmptyComponent = function EmptyComponent() {
3
4
  return null;
4
- }; // This date was chosen to clearly show date and time formats (day > 12)
5
- // e.g. 18/02/1993 vs. 2/18/1993 and 1:00 PM vs 13:00
5
+ };
6
6
 
7
+ // This date was chosen to clearly show date and time formats (day > 12)
8
+ // e.g. 18/02/1993 vs. 2/18/1993 and 1:00 PM vs 13:00
7
9
  export var placeholderDatetime = new Date(1993, 1, 18, 13);
8
10
  export var defaultTimes = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00'];
9
11
  export var defaultTimeFormat = 'h:mma';
@@ -16,23 +16,18 @@ export function isValid(timeString) {
16
16
  var time = timeString.trim().match(/(\d+)(?::(\d\d))?\s*(a|p)?/i);
17
17
  var time24hr = timeString.trim().match(/(\d\d)[:.]?(\d\d)/);
18
18
  var num = timeString.replace(/[^0-9]/g, '');
19
-
20
19
  if (!time && !time24hr) {
21
20
  return false;
22
21
  }
23
-
24
22
  if (time && !time[1]) {
25
23
  return false;
26
24
  }
27
-
28
25
  if (num.length > 4) {
29
26
  return false;
30
27
  }
31
-
32
28
  if (num.length === 2 && parseInt(num, 10) > 12) {
33
29
  return false;
34
30
  }
35
-
36
31
  return true;
37
32
  }
38
33
  export function removeSpacer(time) {
@@ -42,37 +37,30 @@ export function formatSemi24(time) {
42
37
  if (time.length === 1) {
43
38
  return "0".concat(time, "00");
44
39
  }
45
-
46
40
  if (time.length === 2) {
47
41
  return "".concat(time, "00");
48
42
  }
49
-
50
43
  if (time.length === 3) {
51
44
  return "0".concat(time);
52
45
  }
53
-
54
46
  return time;
55
47
  }
56
48
  export function checkHour(hour, meridiem) {
57
49
  if (hour > '24') {
58
50
  return null;
59
51
  }
60
-
61
52
  if (hour === '12' && meridiem === 'a') {
62
53
  return '00';
63
54
  }
64
-
65
55
  if (hour < '12' && meridiem === 'p') {
66
56
  return map24[hour];
67
57
  }
68
-
69
58
  return hour;
70
59
  }
71
60
  export function checkMinute(minute) {
72
61
  if (minute > '59') {
73
62
  return null;
74
63
  }
75
-
76
64
  return minute;
77
65
  }
78
66
  export function convertTo24hrTime(time) {
@@ -81,11 +69,9 @@ export function convertTo24hrTime(time) {
81
69
  var semi24 = formatSemi24(timeArray[0].trim());
82
70
  var hour = checkHour(semi24.substring(0, 2), meridiem);
83
71
  var minute = checkMinute(semi24.substring(2, 4));
84
-
85
72
  if (!hour || !minute) {
86
73
  return null;
87
74
  }
88
-
89
75
  return {
90
76
  hour: parseInt(hour, 10),
91
77
  minute: parseInt(minute, 10)
@@ -100,17 +86,13 @@ export function assignToDate(time) {
100
86
  }
101
87
  export default function (time) {
102
88
  var trimmedTime = time.toString().trim();
103
-
104
89
  if (!isValid(trimmedTime)) {
105
90
  throw RangeError('invalid time format');
106
91
  }
107
-
108
92
  var time1 = removeSpacer(trimmedTime);
109
93
  var time2 = convertTo24hrTime(time1);
110
-
111
94
  if (!time2) {
112
95
  throw RangeError('invalid time format');
113
96
  }
114
-
115
97
  return assignToDate(time2);
116
98
  }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "12.3.7",
3
+ "version": "12.3.8",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "12.3.7",
3
+ "version": "12.3.8",
4
4
  "description": "A date time picker allows the user to select an associated date and time.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,7 +33,7 @@
33
33
  "@atlaskit/popper": "^5.4.0",
34
34
  "@atlaskit/select": "^16.1.0",
35
35
  "@atlaskit/theme": "^12.2.0",
36
- "@atlaskit/tokens": "^0.13.0",
36
+ "@atlaskit/tokens": "^1.0.0",
37
37
  "@babel/runtime": "^7.0.0",
38
38
  "@emotion/react": "^11.7.1",
39
39
  "date-fns": "^2.17.0",