@commercetools-uikit/utils 15.15.1 → 16.1.0

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.
@@ -23,11 +23,9 @@ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceP
23
23
  const regexpData$1 = /^data-/;
24
24
  function filterDataAttributes(obj) {
25
25
  var _context;
26
-
27
26
  return _Object$fromEntries__default["default"](_filterInstanceProperty__default["default"](_context = _Object$entries__default["default"](obj)).call(_context, _ref => {
28
27
  let _ref2 = _slicedToArray(_ref, 1),
29
- propFromEntry = _ref2[0];
30
-
28
+ propFromEntry = _ref2[0];
31
29
  return regexpData$1.test(propFromEntry);
32
30
  }));
33
31
  }
@@ -35,22 +33,18 @@ function filterDataAttributes(obj) {
35
33
  const regexpData = /^aria-/;
36
34
  function filterAriaAttributes(obj) {
37
35
  var _context;
38
-
39
36
  return _Object$fromEntries__default["default"](_filterInstanceProperty__default["default"](_context = _Object$entries__default["default"](obj)).call(_context, _ref => {
40
37
  let _ref2 = _slicedToArray(_ref, 1),
41
- propFromEntry = _ref2[0];
42
-
38
+ propFromEntry = _ref2[0];
43
39
  return regexpData.test(propFromEntry);
44
40
  }));
45
41
  }
46
42
 
47
43
  function filterInvalidAttributes(obj) {
48
44
  var _context;
49
-
50
45
  return _Object$fromEntries__default["default"](_filterInstanceProperty__default["default"](_context = _Object$entries__default["default"](obj)).call(_context, _ref => {
51
46
  let _ref2 = _slicedToArray(_ref, 1),
52
- propFromEntry = _ref2[0];
53
-
47
+ propFromEntry = _ref2[0];
54
48
  return isPropValid__default["default"](propFromEntry);
55
49
  }));
56
50
  }
@@ -61,36 +55,33 @@ function isNumberish(number) {
61
55
  return !/[^(\-?)\d,.\s]/.test(number);
62
56
  }
63
57
 
58
+ // To avoid getting the following error, we type the entire function.
64
59
  // "Assertions require every name in the call target to be declared with an explicit type annotation."
65
60
  // See https://github.com/microsoft/TypeScript/pull/33622#issuecomment-575301357
61
+ const isProduction = process.env.NODE_ENV === 'production';
66
62
 
67
- const isProduction = process.env.NODE_ENV === 'production'; // Throw an error if the condition fails
63
+ // Throw an error if the condition fails
68
64
  // Strip out error messages for production
69
65
  // > Not providing an inline default argument for message as the result is smaller
70
-
71
66
  const warning = function (condition, message) {
72
67
  var _context;
73
-
74
68
  let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Warning';
75
-
76
69
  if (isProduction || condition) {
77
70
  return;
78
71
  }
79
-
80
72
  console.warn(_concatInstanceProperty__default["default"](_context = "".concat(prefix, ": ")).call(_context, message));
81
73
  };
82
74
  const useWarning = (condition, message) => {
83
75
  react.useEffect(() => {
84
- process.env.NODE_ENV !== "production" ? warning(condition, message) : void 0; // eslint-disable-next-line react-hooks/exhaustive-deps
76
+ process.env.NODE_ENV !== "production" ? warning(condition, message) : void 0;
77
+ // eslint-disable-next-line react-hooks/exhaustive-deps
85
78
  }, []);
86
79
  };
87
80
 
88
81
  const getMessage$1 = (componentName, additionalMessage) => {
89
82
  var _context;
90
-
91
83
  return _concatInstanceProperty__default["default"](_context = "\"".concat(componentName, "\" has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
92
84
  };
93
-
94
85
  const warnDeprecatedComponent = function (componentName) {
95
86
  let additionalMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
96
87
  return process.env.NODE_ENV !== "production" ? warning(false, getMessage$1(componentName, additionalMessage)) : void 0;
@@ -102,11 +93,9 @@ const useWarnDeprecatedComponent = function (componentName) {
102
93
 
103
94
  const getMessage = function (propName, componentName) {
104
95
  var _context, _context2;
105
-
106
96
  let additionalMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
107
97
  return _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "\"".concat(propName, "\" property of \"")).call(_context2, componentName, "\" component has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
108
98
  };
109
-
110
99
  const warnDeprecatedProp = function (condition, propName, componentName) {
111
100
  let additionalMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
112
101
  process.env.NODE_ENV !== "production" ? warning(condition, getMessage(propName, componentName, additionalMessage)) : void 0;
@@ -126,14 +115,12 @@ function createSequentialId(prefix) {
126
115
  let id = 0;
127
116
  return () => {
128
117
  var _context;
129
-
130
118
  id += 1;
131
119
  return _concatInstanceProperty__default["default"](_context = "".concat(prefix)).call(_context, id);
132
120
  };
133
121
  }
134
122
 
135
123
  const getFieldId = (props, state, createId) => props.id || state.id || createId();
136
-
137
124
  var getFieldId$1 = getFieldId;
138
125
 
139
126
  // Attempts to parse a string containing a time in either 12h or 24h format,
@@ -152,28 +139,25 @@ var getFieldId$1 = getFieldId;
152
139
  // eslint-disable-next-line import/prefer-default-export
153
140
  const parseTime = rawTime => {
154
141
  if (!rawTime || typeof rawTime !== 'string') return null;
155
-
156
142
  const time = _trimInstanceProperty__default["default"](rawTime).call(rawTime).toLowerCase();
157
-
158
143
  const match = time.match(/^(\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?\s*(am|pm)?$/);
159
- if (!match) return null; // As we accept eg "3 AM" there might not be a value for minutes, seconds or
160
- // milliseconds, so we default them
144
+ if (!match) return null;
161
145
 
146
+ // As we accept eg "3 AM" there might not be a value for minutes, seconds or
147
+ // milliseconds, so we default them
162
148
  const _match = _slicedToArray(match, 6),
163
- hours = _match[1],
164
- minutes = _match[2],
165
- seconds = _match[3],
166
- milliseconds = _match[4],
167
- amPm = _match[5];
168
-
149
+ hours = _match[1],
150
+ minutes = _match[2],
151
+ seconds = _match[3],
152
+ milliseconds = _match[4],
153
+ amPm = _match[5];
169
154
  const parsedMinutes = Number(minutes !== null && minutes !== void 0 ? minutes : '00');
170
- const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00'); // Parses the number as a fraction to ensure that .5, .05 and .005 are
155
+ const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00');
156
+ // Parses the number as a fraction to ensure that .5, .05 and .005 are
171
157
  // parsed correctily (they are 500, 50 and 5 respectively).
172
-
173
- const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000; // edge-case: allow 24:00, but nothing over it
174
-
158
+ const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000;
159
+ // edge-case: allow 24:00, but nothing over it
175
160
  const parsedHours = Number(hours) === 24 && parsedMinutes === 0 && parsedSeconds === 0 && parsedMilliseconds === 0 ? 0 : Number(hours);
176
-
177
161
  if (amPm) {
178
162
  if (parsedHours > 12) return null;
179
163
  if (parsedHours === 0) return null;
@@ -182,9 +166,10 @@ const parseTime = rawTime => {
182
166
  if (parsedHours > 23) return null;
183
167
  if (parsedMinutes > 59) return null;
184
168
  }
185
-
186
169
  if (parsedSeconds > 59) return null;
187
- if (parsedMilliseconds > 999) return null; // 12 pm (just like 24:00) would be on the next day, so we treat it as an
170
+ if (parsedMilliseconds > 999) return null;
171
+
172
+ // 12 pm (just like 24:00) would be on the next day, so we treat it as an
188
173
  // invalid value to avoid edge cases like the day jumping forward
189
174
  // if (amPm === 'pm' && Number(hours) === 12) return null;
190
175
 
@@ -194,7 +179,6 @@ const parseTime = rawTime => {
194
179
  if (amPm === 'pm' && parsedHours !== 12) return 12;
195
180
  return 0;
196
181
  })();
197
-
198
182
  return {
199
183
  hours: parsedHours + hourOffset,
200
184
  minutes: parsedMinutes,
@@ -202,7 +186,6 @@ const parseTime = rawTime => {
202
186
  milliseconds: parsedMilliseconds
203
187
  };
204
188
  };
205
-
206
189
  var parseTime$1 = parseTime;
207
190
 
208
191
  // eslint-disable-next-line import/prefer-default-export
@@ -212,7 +195,7 @@ const SafeHTMLElement = canUseDOM ? window.HTMLElement : {};
212
195
  var SafeHTMLElement$1 = SafeHTMLElement;
213
196
 
214
197
  // NOTE: This string will be replaced on build time with the package version.
215
- var version = "15.15.1";
198
+ var version = "16.1.0";
216
199
 
217
200
  exports.SafeHTMLElement = SafeHTMLElement$1;
218
201
  exports.canUseDOM = canUseDOM;
@@ -23,11 +23,9 @@ var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceP
23
23
  const regexpData$1 = /^data-/;
24
24
  function filterDataAttributes(obj) {
25
25
  var _context;
26
-
27
26
  return _Object$fromEntries__default["default"](_filterInstanceProperty__default["default"](_context = _Object$entries__default["default"](obj)).call(_context, _ref => {
28
27
  let _ref2 = _slicedToArray(_ref, 1),
29
- propFromEntry = _ref2[0];
30
-
28
+ propFromEntry = _ref2[0];
31
29
  return regexpData$1.test(propFromEntry);
32
30
  }));
33
31
  }
@@ -35,22 +33,18 @@ function filterDataAttributes(obj) {
35
33
  const regexpData = /^aria-/;
36
34
  function filterAriaAttributes(obj) {
37
35
  var _context;
38
-
39
36
  return _Object$fromEntries__default["default"](_filterInstanceProperty__default["default"](_context = _Object$entries__default["default"](obj)).call(_context, _ref => {
40
37
  let _ref2 = _slicedToArray(_ref, 1),
41
- propFromEntry = _ref2[0];
42
-
38
+ propFromEntry = _ref2[0];
43
39
  return regexpData.test(propFromEntry);
44
40
  }));
45
41
  }
46
42
 
47
43
  function filterInvalidAttributes(obj) {
48
44
  var _context;
49
-
50
45
  return _Object$fromEntries__default["default"](_filterInstanceProperty__default["default"](_context = _Object$entries__default["default"](obj)).call(_context, _ref => {
51
46
  let _ref2 = _slicedToArray(_ref, 1),
52
- propFromEntry = _ref2[0];
53
-
47
+ propFromEntry = _ref2[0];
54
48
  return isPropValid__default["default"](propFromEntry);
55
49
  }));
56
50
  }
@@ -61,26 +55,24 @@ function isNumberish(number) {
61
55
  return !/[^(\-?)\d,.\s]/.test(number);
62
56
  }
63
57
 
58
+ // Throw an error if the condition fails
64
59
  // Strip out error messages for production
65
60
  // > Not providing an inline default argument for message as the result is smaller
66
-
67
61
  const warning = function (condition, message) {
68
-
69
62
  {
70
63
  return;
71
64
  }
72
65
  };
73
66
  const useWarning = (condition, message) => {
74
67
  react.useEffect(() => {
68
+ // eslint-disable-next-line react-hooks/exhaustive-deps
75
69
  }, []);
76
70
  };
77
71
 
78
72
  const getMessage$1 = (componentName, additionalMessage) => {
79
73
  var _context;
80
-
81
74
  return _concatInstanceProperty__default["default"](_context = "\"".concat(componentName, "\" has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
82
75
  };
83
-
84
76
  const warnDeprecatedComponent = function (componentName) {
85
77
  return void 0;
86
78
  };
@@ -91,11 +83,9 @@ const useWarnDeprecatedComponent = function (componentName) {
91
83
 
92
84
  const getMessage = function (propName, componentName) {
93
85
  var _context, _context2;
94
-
95
86
  let additionalMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
96
87
  return _concatInstanceProperty__default["default"](_context = _concatInstanceProperty__default["default"](_context2 = "\"".concat(propName, "\" property of \"")).call(_context2, componentName, "\" component has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
97
88
  };
98
-
99
89
  const warnDeprecatedProp = function (condition, propName, componentName) {
100
90
  };
101
91
  const useWarnDeprecatedProp = function (condition, propName, componentName) {
@@ -113,14 +103,12 @@ function createSequentialId(prefix) {
113
103
  let id = 0;
114
104
  return () => {
115
105
  var _context;
116
-
117
106
  id += 1;
118
107
  return _concatInstanceProperty__default["default"](_context = "".concat(prefix)).call(_context, id);
119
108
  };
120
109
  }
121
110
 
122
111
  const getFieldId = (props, state, createId) => props.id || state.id || createId();
123
-
124
112
  var getFieldId$1 = getFieldId;
125
113
 
126
114
  // Attempts to parse a string containing a time in either 12h or 24h format,
@@ -139,28 +127,25 @@ var getFieldId$1 = getFieldId;
139
127
  // eslint-disable-next-line import/prefer-default-export
140
128
  const parseTime = rawTime => {
141
129
  if (!rawTime || typeof rawTime !== 'string') return null;
142
-
143
130
  const time = _trimInstanceProperty__default["default"](rawTime).call(rawTime).toLowerCase();
144
-
145
131
  const match = time.match(/^(\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?\s*(am|pm)?$/);
146
- if (!match) return null; // As we accept eg "3 AM" there might not be a value for minutes, seconds or
147
- // milliseconds, so we default them
132
+ if (!match) return null;
148
133
 
134
+ // As we accept eg "3 AM" there might not be a value for minutes, seconds or
135
+ // milliseconds, so we default them
149
136
  const _match = _slicedToArray(match, 6),
150
- hours = _match[1],
151
- minutes = _match[2],
152
- seconds = _match[3],
153
- milliseconds = _match[4],
154
- amPm = _match[5];
155
-
137
+ hours = _match[1],
138
+ minutes = _match[2],
139
+ seconds = _match[3],
140
+ milliseconds = _match[4],
141
+ amPm = _match[5];
156
142
  const parsedMinutes = Number(minutes !== null && minutes !== void 0 ? minutes : '00');
157
- const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00'); // Parses the number as a fraction to ensure that .5, .05 and .005 are
143
+ const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00');
144
+ // Parses the number as a fraction to ensure that .5, .05 and .005 are
158
145
  // parsed correctily (they are 500, 50 and 5 respectively).
159
-
160
- const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000; // edge-case: allow 24:00, but nothing over it
161
-
146
+ const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000;
147
+ // edge-case: allow 24:00, but nothing over it
162
148
  const parsedHours = Number(hours) === 24 && parsedMinutes === 0 && parsedSeconds === 0 && parsedMilliseconds === 0 ? 0 : Number(hours);
163
-
164
149
  if (amPm) {
165
150
  if (parsedHours > 12) return null;
166
151
  if (parsedHours === 0) return null;
@@ -169,9 +154,10 @@ const parseTime = rawTime => {
169
154
  if (parsedHours > 23) return null;
170
155
  if (parsedMinutes > 59) return null;
171
156
  }
172
-
173
157
  if (parsedSeconds > 59) return null;
174
- if (parsedMilliseconds > 999) return null; // 12 pm (just like 24:00) would be on the next day, so we treat it as an
158
+ if (parsedMilliseconds > 999) return null;
159
+
160
+ // 12 pm (just like 24:00) would be on the next day, so we treat it as an
175
161
  // invalid value to avoid edge cases like the day jumping forward
176
162
  // if (amPm === 'pm' && Number(hours) === 12) return null;
177
163
 
@@ -181,7 +167,6 @@ const parseTime = rawTime => {
181
167
  if (amPm === 'pm' && parsedHours !== 12) return 12;
182
168
  return 0;
183
169
  })();
184
-
185
170
  return {
186
171
  hours: parsedHours + hourOffset,
187
172
  minutes: parsedMinutes,
@@ -189,7 +174,6 @@ const parseTime = rawTime => {
189
174
  milliseconds: parsedMilliseconds
190
175
  };
191
176
  };
192
-
193
177
  var parseTime$1 = parseTime;
194
178
 
195
179
  // eslint-disable-next-line import/prefer-default-export
@@ -199,7 +183,7 @@ const SafeHTMLElement = canUseDOM ? window.HTMLElement : {};
199
183
  var SafeHTMLElement$1 = SafeHTMLElement;
200
184
 
201
185
  // NOTE: This string will be replaced on build time with the package version.
202
- var version = "15.15.1";
186
+ var version = "16.1.0";
203
187
 
204
188
  exports.SafeHTMLElement = SafeHTMLElement$1;
205
189
  exports.canUseDOM = canUseDOM;
@@ -10,11 +10,9 @@ import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instanc
10
10
  const regexpData$1 = /^data-/;
11
11
  function filterDataAttributes(obj) {
12
12
  var _context;
13
-
14
13
  return _Object$fromEntries(_filterInstanceProperty(_context = _Object$entries(obj)).call(_context, _ref => {
15
14
  let _ref2 = _slicedToArray(_ref, 1),
16
- propFromEntry = _ref2[0];
17
-
15
+ propFromEntry = _ref2[0];
18
16
  return regexpData$1.test(propFromEntry);
19
17
  }));
20
18
  }
@@ -22,22 +20,18 @@ function filterDataAttributes(obj) {
22
20
  const regexpData = /^aria-/;
23
21
  function filterAriaAttributes(obj) {
24
22
  var _context;
25
-
26
23
  return _Object$fromEntries(_filterInstanceProperty(_context = _Object$entries(obj)).call(_context, _ref => {
27
24
  let _ref2 = _slicedToArray(_ref, 1),
28
- propFromEntry = _ref2[0];
29
-
25
+ propFromEntry = _ref2[0];
30
26
  return regexpData.test(propFromEntry);
31
27
  }));
32
28
  }
33
29
 
34
30
  function filterInvalidAttributes(obj) {
35
31
  var _context;
36
-
37
32
  return _Object$fromEntries(_filterInstanceProperty(_context = _Object$entries(obj)).call(_context, _ref => {
38
33
  let _ref2 = _slicedToArray(_ref, 1),
39
- propFromEntry = _ref2[0];
40
-
34
+ propFromEntry = _ref2[0];
41
35
  return isPropValid(propFromEntry);
42
36
  }));
43
37
  }
@@ -48,36 +42,33 @@ function isNumberish(number) {
48
42
  return !/[^(\-?)\d,.\s]/.test(number);
49
43
  }
50
44
 
45
+ // To avoid getting the following error, we type the entire function.
51
46
  // "Assertions require every name in the call target to be declared with an explicit type annotation."
52
47
  // See https://github.com/microsoft/TypeScript/pull/33622#issuecomment-575301357
48
+ const isProduction = process.env.NODE_ENV === 'production';
53
49
 
54
- const isProduction = process.env.NODE_ENV === 'production'; // Throw an error if the condition fails
50
+ // Throw an error if the condition fails
55
51
  // Strip out error messages for production
56
52
  // > Not providing an inline default argument for message as the result is smaller
57
-
58
53
  const warning = function (condition, message) {
59
54
  var _context;
60
-
61
55
  let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Warning';
62
-
63
56
  if (isProduction || condition) {
64
57
  return;
65
58
  }
66
-
67
59
  console.warn(_concatInstanceProperty(_context = "".concat(prefix, ": ")).call(_context, message));
68
60
  };
69
61
  const useWarning = (condition, message) => {
70
62
  useEffect(() => {
71
- process.env.NODE_ENV !== "production" ? warning(condition, message) : void 0; // eslint-disable-next-line react-hooks/exhaustive-deps
63
+ process.env.NODE_ENV !== "production" ? warning(condition, message) : void 0;
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
72
65
  }, []);
73
66
  };
74
67
 
75
68
  const getMessage$1 = (componentName, additionalMessage) => {
76
69
  var _context;
77
-
78
70
  return _concatInstanceProperty(_context = "\"".concat(componentName, "\" has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
79
71
  };
80
-
81
72
  const warnDeprecatedComponent = function (componentName) {
82
73
  let additionalMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
83
74
  return process.env.NODE_ENV !== "production" ? warning(false, getMessage$1(componentName, additionalMessage)) : void 0;
@@ -89,11 +80,9 @@ const useWarnDeprecatedComponent = function (componentName) {
89
80
 
90
81
  const getMessage = function (propName, componentName) {
91
82
  var _context, _context2;
92
-
93
83
  let additionalMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
94
84
  return _concatInstanceProperty(_context = _concatInstanceProperty(_context2 = "\"".concat(propName, "\" property of \"")).call(_context2, componentName, "\" component has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
95
85
  };
96
-
97
86
  const warnDeprecatedProp = function (condition, propName, componentName) {
98
87
  let additionalMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
99
88
  process.env.NODE_ENV !== "production" ? warning(condition, getMessage(propName, componentName, additionalMessage)) : void 0;
@@ -113,14 +102,12 @@ function createSequentialId(prefix) {
113
102
  let id = 0;
114
103
  return () => {
115
104
  var _context;
116
-
117
105
  id += 1;
118
106
  return _concatInstanceProperty(_context = "".concat(prefix)).call(_context, id);
119
107
  };
120
108
  }
121
109
 
122
110
  const getFieldId = (props, state, createId) => props.id || state.id || createId();
123
-
124
111
  var getFieldId$1 = getFieldId;
125
112
 
126
113
  // Attempts to parse a string containing a time in either 12h or 24h format,
@@ -139,28 +126,25 @@ var getFieldId$1 = getFieldId;
139
126
  // eslint-disable-next-line import/prefer-default-export
140
127
  const parseTime = rawTime => {
141
128
  if (!rawTime || typeof rawTime !== 'string') return null;
142
-
143
129
  const time = _trimInstanceProperty(rawTime).call(rawTime).toLowerCase();
144
-
145
130
  const match = time.match(/^(\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:\.(\d{1,3}))?)?)?\s*(am|pm)?$/);
146
- if (!match) return null; // As we accept eg "3 AM" there might not be a value for minutes, seconds or
147
- // milliseconds, so we default them
131
+ if (!match) return null;
148
132
 
133
+ // As we accept eg "3 AM" there might not be a value for minutes, seconds or
134
+ // milliseconds, so we default them
149
135
  const _match = _slicedToArray(match, 6),
150
- hours = _match[1],
151
- minutes = _match[2],
152
- seconds = _match[3],
153
- milliseconds = _match[4],
154
- amPm = _match[5];
155
-
136
+ hours = _match[1],
137
+ minutes = _match[2],
138
+ seconds = _match[3],
139
+ milliseconds = _match[4],
140
+ amPm = _match[5];
156
141
  const parsedMinutes = Number(minutes !== null && minutes !== void 0 ? minutes : '00');
157
- const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00'); // Parses the number as a fraction to ensure that .5, .05 and .005 are
142
+ const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00');
143
+ // Parses the number as a fraction to ensure that .5, .05 and .005 are
158
144
  // parsed correctily (they are 500, 50 and 5 respectively).
159
-
160
- const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000; // edge-case: allow 24:00, but nothing over it
161
-
145
+ const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000;
146
+ // edge-case: allow 24:00, but nothing over it
162
147
  const parsedHours = Number(hours) === 24 && parsedMinutes === 0 && parsedSeconds === 0 && parsedMilliseconds === 0 ? 0 : Number(hours);
163
-
164
148
  if (amPm) {
165
149
  if (parsedHours > 12) return null;
166
150
  if (parsedHours === 0) return null;
@@ -169,9 +153,10 @@ const parseTime = rawTime => {
169
153
  if (parsedHours > 23) return null;
170
154
  if (parsedMinutes > 59) return null;
171
155
  }
172
-
173
156
  if (parsedSeconds > 59) return null;
174
- if (parsedMilliseconds > 999) return null; // 12 pm (just like 24:00) would be on the next day, so we treat it as an
157
+ if (parsedMilliseconds > 999) return null;
158
+
159
+ // 12 pm (just like 24:00) would be on the next day, so we treat it as an
175
160
  // invalid value to avoid edge cases like the day jumping forward
176
161
  // if (amPm === 'pm' && Number(hours) === 12) return null;
177
162
 
@@ -181,7 +166,6 @@ const parseTime = rawTime => {
181
166
  if (amPm === 'pm' && parsedHours !== 12) return 12;
182
167
  return 0;
183
168
  })();
184
-
185
169
  return {
186
170
  hours: parsedHours + hourOffset,
187
171
  minutes: parsedMinutes,
@@ -189,7 +173,6 @@ const parseTime = rawTime => {
189
173
  milliseconds: parsedMilliseconds
190
174
  };
191
175
  };
192
-
193
176
  var parseTime$1 = parseTime;
194
177
 
195
178
  // eslint-disable-next-line import/prefer-default-export
@@ -199,6 +182,6 @@ const SafeHTMLElement = canUseDOM ? window.HTMLElement : {};
199
182
  var SafeHTMLElement$1 = SafeHTMLElement;
200
183
 
201
184
  // NOTE: This string will be replaced on build time with the package version.
202
- var version = "15.15.1";
185
+ var version = "16.1.0";
203
186
 
204
187
  export { SafeHTMLElement$1 as SafeHTMLElement, canUseDOM, createSequentialId, filterAriaAttributes, filterDataAttributes, filterInvalidAttributes, getFieldId$1 as getFieldId, isNumberish, parseTime$1 as parseTime, useWarnDeprecatedComponent, useWarnDeprecatedProp, useWarning, version, warnDeprecatedComponent, warnDeprecatedProp, warning };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@commercetools-uikit/utils",
3
3
  "description": "A collection of utilities shared across the other packages.",
4
- "version": "15.15.1",
4
+ "version": "16.1.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@emotion/is-prop-valid": "1.2.0"
24
+ "@emotion/is-prop-valid": "1.2.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "react": "17.0.2"