@commercetools-uikit/utils 15.14.3 → 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.
- package/dist/commercetools-uikit-utils.cjs.d.ts +1 -0
- package/dist/commercetools-uikit-utils.cjs.d.ts.map +1 -0
- package/dist/commercetools-uikit-utils.cjs.dev.js +45 -47
- package/dist/commercetools-uikit-utils.cjs.prod.js +41 -43
- package/dist/commercetools-uikit-utils.esm.js +45 -47
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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,
|
|
28
|
-
|
|
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
|
-
|
|
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,
|
|
40
|
-
|
|
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,
|
|
51
|
-
|
|
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
|
-
|
|
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
|
-
|
|
71
|
+
const warning = function (condition, message) {
|
|
72
72
|
var _context;
|
|
73
73
|
|
|
74
|
-
|
|
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
|
-
|
|
83
|
-
react.useEffect(
|
|
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
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
-
|
|
99
|
-
|
|
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
|
-
|
|
103
|
+
const getMessage = function (propName, componentName) {
|
|
104
104
|
var _context, _context2;
|
|
105
105
|
|
|
106
|
-
|
|
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
|
-
|
|
111
|
-
|
|
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
|
-
|
|
115
|
-
|
|
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
|
-
|
|
127
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
153
|
+
const parseTime = rawTime => {
|
|
156
154
|
if (!rawTime || typeof rawTime !== 'string') return null;
|
|
157
155
|
|
|
158
|
-
|
|
156
|
+
const time = _trimInstanceProperty__default["default"](rawTime).call(rawTime).toLowerCase();
|
|
159
157
|
|
|
160
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
172
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
209
|
+
const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
212
210
|
|
|
213
|
-
|
|
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.
|
|
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
|
-
|
|
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,
|
|
28
|
-
|
|
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
|
-
|
|
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,
|
|
40
|
-
|
|
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,
|
|
51
|
-
|
|
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
|
-
|
|
67
|
+
const warning = function (condition, message) {
|
|
68
68
|
|
|
69
69
|
{
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
|
-
|
|
74
|
-
react.useEffect(
|
|
73
|
+
const useWarning = (condition, message) => {
|
|
74
|
+
react.useEffect(() => {
|
|
75
75
|
}, []);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
|
|
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
|
-
|
|
84
|
+
const warnDeprecatedComponent = function (componentName) {
|
|
85
85
|
return void 0;
|
|
86
86
|
};
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
92
|
+
const getMessage = function (propName, componentName) {
|
|
93
93
|
var _context, _context2;
|
|
94
94
|
|
|
95
|
-
|
|
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
|
-
|
|
99
|
+
const warnDeprecatedProp = function (condition, propName, componentName) {
|
|
100
100
|
};
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
114
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
140
|
+
const parseTime = rawTime => {
|
|
143
141
|
if (!rawTime || typeof rawTime !== 'string') return null;
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
const time = _trimInstanceProperty__default["default"](rawTime).call(rawTime).toLowerCase();
|
|
146
144
|
|
|
147
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
196
|
+
const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
199
197
|
|
|
200
|
-
|
|
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.
|
|
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
|
-
|
|
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,
|
|
15
|
-
|
|
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
|
-
|
|
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,
|
|
27
|
-
|
|
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,
|
|
38
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
+
const warning = function (condition, message) {
|
|
59
59
|
var _context;
|
|
60
60
|
|
|
61
|
-
|
|
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
|
-
|
|
70
|
-
useEffect(
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
86
|
-
|
|
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
|
-
|
|
90
|
+
const getMessage = function (propName, componentName) {
|
|
91
91
|
var _context, _context2;
|
|
92
92
|
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
114
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
140
|
+
const parseTime = rawTime => {
|
|
143
141
|
if (!rawTime || typeof rawTime !== 'string') return null;
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
const time = _trimInstanceProperty(rawTime).call(rawTime).toLowerCase();
|
|
146
144
|
|
|
147
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
-
|
|
159
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
196
|
+
const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
199
197
|
|
|
200
|
-
|
|
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.
|
|
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