@commercetools-uikit/utils 20.2.2 → 20.3.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.
@@ -7,6 +7,7 @@ var _Object$fromEntries = require('@babel/runtime-corejs3/core-js-stable/object/
7
7
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
8
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
9
9
  var isPropValid = require('@emotion/is-prop-valid');
10
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
10
11
  var react = require('react');
11
12
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
12
13
 
@@ -16,6 +17,7 @@ var _Object$fromEntries__default = /*#__PURE__*/_interopDefault(_Object$fromEntr
16
17
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
17
18
  var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
18
19
  var isPropValid__default = /*#__PURE__*/_interopDefault(isPropValid);
20
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
19
21
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
20
22
 
21
23
  const regexpData$1 = /^data-/;
@@ -63,11 +65,12 @@ const isProduction = process.env.NODE_ENV === 'production';
63
65
  // Strip out error messages for production
64
66
  // > Not providing an inline default argument for message as the result is smaller
65
67
  const warning = function (condition, message) {
68
+ var _context;
66
69
  let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Warning';
67
70
  if (isProduction || condition) {
68
71
  return;
69
72
  }
70
- console.warn(`${prefix}: ${message}`);
73
+ console.warn(_concatInstanceProperty__default["default"](_context = "".concat(prefix, ": ")).call(_context, message));
71
74
  };
72
75
  const useWarning = (condition, message) => {
73
76
  react.useEffect(() => {
@@ -76,7 +79,10 @@ const useWarning = (condition, message) => {
76
79
  }, []);
77
80
  };
78
81
 
79
- const getMessage$1 = (componentName, additionalMessage) => `"${componentName}" has been deprecated and will be removed in the next major version.${additionalMessage ? ' ' + additionalMessage : ''}`;
82
+ const getMessage$1 = (componentName, additionalMessage) => {
83
+ var _context;
84
+ return _concatInstanceProperty__default["default"](_context = "\"".concat(componentName, "\" has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
85
+ };
80
86
  const warnDeprecatedComponent = function (componentName) {
81
87
  let additionalMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
82
88
  return process.env.NODE_ENV !== "production" ? warning(false, getMessage$1(componentName, additionalMessage)) : void 0;
@@ -87,8 +93,9 @@ const useWarnDeprecatedComponent = function (componentName) {
87
93
  };
88
94
 
89
95
  const getMessage = function (propName, componentName) {
96
+ var _context, _context2;
90
97
  let additionalMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
91
- return `"${propName}" property of "${componentName}" component has been deprecated and will be removed in the next major version.${additionalMessage ? ' ' + additionalMessage : ''}`;
98
+ 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 : '');
92
99
  };
93
100
  const warnDeprecatedProp = function (condition, propName, componentName) {
94
101
  let additionalMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
@@ -108,8 +115,9 @@ const useWarnDeprecatedProp = function (condition, propName, componentName) {
108
115
  function createSequentialId(prefix) {
109
116
  let id = 0;
110
117
  return () => {
118
+ var _context;
111
119
  id += 1;
112
- return `${prefix}${id}`;
120
+ return _concatInstanceProperty__default["default"](_context = "".concat(prefix)).call(_context, id);
113
121
  };
114
122
  }
115
123
 
@@ -144,11 +152,11 @@ const parseTime = rawTime => {
144
152
  seconds = _match[3],
145
153
  milliseconds = _match[4],
146
154
  amPm = _match[5];
147
- const parsedMinutes = Number(minutes ?? '00');
148
- const parsedSeconds = Number(seconds ?? '00');
155
+ const parsedMinutes = Number(minutes !== null && minutes !== void 0 ? minutes : '00');
156
+ const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00');
149
157
  // Parses the number as a fraction to ensure that .5, .05 and .005 are
150
158
  // parsed correctily (they are 500, 50 and 5 respectively).
151
- const parsedMilliseconds = Number(`0.${milliseconds ?? '000'}`) * 1000;
159
+ const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000;
152
160
  // edge-case: allow 24:00, but nothing over it
153
161
  const parsedHours = Number(hours) === 24 && parsedMinutes === 0 && parsedSeconds === 0 && parsedMilliseconds === 0 ? 0 : Number(hours);
154
162
  if (amPm) {
@@ -188,7 +196,7 @@ const SafeHTMLElement = canUseDOM ? window.HTMLElement : {};
188
196
  var SafeHTMLElement$1 = SafeHTMLElement;
189
197
 
190
198
  // NOTE: This string will be replaced on build time with the package version.
191
- var version = "20.2.2";
199
+ var version = "20.3.0";
192
200
 
193
201
  exports.SafeHTMLElement = SafeHTMLElement$1;
194
202
  exports.canUseDOM = canUseDOM;
@@ -7,6 +7,7 @@ var _Object$fromEntries = require('@babel/runtime-corejs3/core-js-stable/object/
7
7
  var _filterInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/filter');
8
8
  var _Object$entries = require('@babel/runtime-corejs3/core-js-stable/object/entries');
9
9
  var isPropValid = require('@emotion/is-prop-valid');
10
+ var _concatInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/concat');
10
11
  var react = require('react');
11
12
  var _trimInstanceProperty = require('@babel/runtime-corejs3/core-js-stable/instance/trim');
12
13
 
@@ -16,6 +17,7 @@ var _Object$fromEntries__default = /*#__PURE__*/_interopDefault(_Object$fromEntr
16
17
  var _filterInstanceProperty__default = /*#__PURE__*/_interopDefault(_filterInstanceProperty);
17
18
  var _Object$entries__default = /*#__PURE__*/_interopDefault(_Object$entries);
18
19
  var isPropValid__default = /*#__PURE__*/_interopDefault(isPropValid);
20
+ var _concatInstanceProperty__default = /*#__PURE__*/_interopDefault(_concatInstanceProperty);
19
21
  var _trimInstanceProperty__default = /*#__PURE__*/_interopDefault(_trimInstanceProperty);
20
22
 
21
23
  const regexpData$1 = /^data-/;
@@ -67,17 +69,28 @@ const useWarning = (condition, message) => {
67
69
  }, []);
68
70
  };
69
71
 
72
+ const getMessage$1 = (componentName, additionalMessage) => {
73
+ var _context;
74
+ return _concatInstanceProperty__default["default"](_context = "\"".concat(componentName, "\" has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
75
+ };
70
76
  const warnDeprecatedComponent = function (componentName) {
71
77
  return void 0;
72
78
  };
73
79
  const useWarnDeprecatedComponent = function (componentName) {
74
- return useWarning();
80
+ let additionalMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
81
+ return useWarning(false, getMessage$1(componentName, additionalMessage));
75
82
  };
76
83
 
84
+ const getMessage = function (propName, componentName) {
85
+ var _context, _context2;
86
+ let additionalMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
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 : '');
88
+ };
77
89
  const warnDeprecatedProp = function (condition, propName, componentName) {
78
90
  };
79
91
  const useWarnDeprecatedProp = function (condition, propName, componentName) {
80
- useWarning();
92
+ let additionalMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
93
+ useWarning(condition, getMessage(propName, componentName, additionalMessage));
81
94
  };
82
95
 
83
96
  // Whenever a field requires a unique id, this factory can be used
@@ -89,8 +102,9 @@ const useWarnDeprecatedProp = function (condition, propName, componentName) {
89
102
  function createSequentialId(prefix) {
90
103
  let id = 0;
91
104
  return () => {
105
+ var _context;
92
106
  id += 1;
93
- return `${prefix}${id}`;
107
+ return _concatInstanceProperty__default["default"](_context = "".concat(prefix)).call(_context, id);
94
108
  };
95
109
  }
96
110
 
@@ -125,11 +139,11 @@ const parseTime = rawTime => {
125
139
  seconds = _match[3],
126
140
  milliseconds = _match[4],
127
141
  amPm = _match[5];
128
- const parsedMinutes = Number(minutes ?? '00');
129
- const parsedSeconds = Number(seconds ?? '00');
142
+ const parsedMinutes = Number(minutes !== null && minutes !== void 0 ? minutes : '00');
143
+ const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00');
130
144
  // Parses the number as a fraction to ensure that .5, .05 and .005 are
131
145
  // parsed correctily (they are 500, 50 and 5 respectively).
132
- const parsedMilliseconds = Number(`0.${milliseconds ?? '000'}`) * 1000;
146
+ const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000;
133
147
  // edge-case: allow 24:00, but nothing over it
134
148
  const parsedHours = Number(hours) === 24 && parsedMinutes === 0 && parsedSeconds === 0 && parsedMilliseconds === 0 ? 0 : Number(hours);
135
149
  if (amPm) {
@@ -169,7 +183,7 @@ const SafeHTMLElement = canUseDOM ? window.HTMLElement : {};
169
183
  var SafeHTMLElement$1 = SafeHTMLElement;
170
184
 
171
185
  // NOTE: This string will be replaced on build time with the package version.
172
- var version = "20.2.2";
186
+ var version = "20.3.0";
173
187
 
174
188
  exports.SafeHTMLElement = SafeHTMLElement$1;
175
189
  exports.canUseDOM = canUseDOM;
@@ -3,6 +3,7 @@ import _Object$fromEntries from '@babel/runtime-corejs3/core-js-stable/object/fr
3
3
  import _filterInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/filter';
4
4
  import _Object$entries from '@babel/runtime-corejs3/core-js-stable/object/entries';
5
5
  import isPropValid from '@emotion/is-prop-valid';
6
+ import _concatInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/concat';
6
7
  import { useEffect } from 'react';
7
8
  import _trimInstanceProperty from '@babel/runtime-corejs3/core-js-stable/instance/trim';
8
9
 
@@ -51,11 +52,12 @@ const isProduction = process.env.NODE_ENV === 'production';
51
52
  // Strip out error messages for production
52
53
  // > Not providing an inline default argument for message as the result is smaller
53
54
  const warning = function (condition, message) {
55
+ var _context;
54
56
  let prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'Warning';
55
57
  if (isProduction || condition) {
56
58
  return;
57
59
  }
58
- console.warn(`${prefix}: ${message}`);
60
+ console.warn(_concatInstanceProperty(_context = "".concat(prefix, ": ")).call(_context, message));
59
61
  };
60
62
  const useWarning = (condition, message) => {
61
63
  useEffect(() => {
@@ -64,7 +66,10 @@ const useWarning = (condition, message) => {
64
66
  }, []);
65
67
  };
66
68
 
67
- const getMessage$1 = (componentName, additionalMessage) => `"${componentName}" has been deprecated and will be removed in the next major version.${additionalMessage ? ' ' + additionalMessage : ''}`;
69
+ const getMessage$1 = (componentName, additionalMessage) => {
70
+ var _context;
71
+ return _concatInstanceProperty(_context = "\"".concat(componentName, "\" has been deprecated and will be removed in the next major version.")).call(_context, additionalMessage ? ' ' + additionalMessage : '');
72
+ };
68
73
  const warnDeprecatedComponent = function (componentName) {
69
74
  let additionalMessage = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
70
75
  return process.env.NODE_ENV !== "production" ? warning(false, getMessage$1(componentName, additionalMessage)) : void 0;
@@ -75,8 +80,9 @@ const useWarnDeprecatedComponent = function (componentName) {
75
80
  };
76
81
 
77
82
  const getMessage = function (propName, componentName) {
83
+ var _context, _context2;
78
84
  let additionalMessage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
79
- return `"${propName}" property of "${componentName}" component has been deprecated and will be removed in the next major version.${additionalMessage ? ' ' + additionalMessage : ''}`;
85
+ 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 : '');
80
86
  };
81
87
  const warnDeprecatedProp = function (condition, propName, componentName) {
82
88
  let additionalMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
@@ -96,8 +102,9 @@ const useWarnDeprecatedProp = function (condition, propName, componentName) {
96
102
  function createSequentialId(prefix) {
97
103
  let id = 0;
98
104
  return () => {
105
+ var _context;
99
106
  id += 1;
100
- return `${prefix}${id}`;
107
+ return _concatInstanceProperty(_context = "".concat(prefix)).call(_context, id);
101
108
  };
102
109
  }
103
110
 
@@ -132,11 +139,11 @@ const parseTime = rawTime => {
132
139
  seconds = _match[3],
133
140
  milliseconds = _match[4],
134
141
  amPm = _match[5];
135
- const parsedMinutes = Number(minutes ?? '00');
136
- const parsedSeconds = Number(seconds ?? '00');
142
+ const parsedMinutes = Number(minutes !== null && minutes !== void 0 ? minutes : '00');
143
+ const parsedSeconds = Number(seconds !== null && seconds !== void 0 ? seconds : '00');
137
144
  // Parses the number as a fraction to ensure that .5, .05 and .005 are
138
145
  // parsed correctily (they are 500, 50 and 5 respectively).
139
- const parsedMilliseconds = Number(`0.${milliseconds ?? '000'}`) * 1000;
146
+ const parsedMilliseconds = Number("0.".concat(milliseconds !== null && milliseconds !== void 0 ? milliseconds : '000')) * 1000;
140
147
  // edge-case: allow 24:00, but nothing over it
141
148
  const parsedHours = Number(hours) === 24 && parsedMinutes === 0 && parsedSeconds === 0 && parsedMilliseconds === 0 ? 0 : Number(hours);
142
149
  if (amPm) {
@@ -176,6 +183,6 @@ const SafeHTMLElement = canUseDOM ? window.HTMLElement : {};
176
183
  var SafeHTMLElement$1 = SafeHTMLElement;
177
184
 
178
185
  // NOTE: This string will be replaced on build time with the package version.
179
- var version = "20.2.2";
186
+ var version = "20.3.0";
180
187
 
181
188
  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": "20.2.2",
4
+ "version": "20.3.0",
5
5
  "bugs": "https://github.com/commercetools/ui-kit/issues",
6
6
  "repository": {
7
7
  "type": "git",
@@ -21,10 +21,10 @@
21
21
  "dependencies": {
22
22
  "@babel/runtime": "^7.20.13",
23
23
  "@babel/runtime-corejs3": "^7.20.13",
24
- "@emotion/is-prop-valid": "1.3.1"
24
+ "@emotion/is-prop-valid": "1.4.0"
25
25
  },
26
26
  "devDependencies": {
27
- "react": "19.1.0"
27
+ "react": "19.2.0"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": "19.x"