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