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