@instructure/ui-utils 8.33.1 → 8.33.2-snapshot-5
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/CHANGELOG.md +8 -0
- package/es/Browser.js +1 -1
- package/es/camelize.js +0 -1
- package/es/capitalizeFirstLetter.js +0 -1
- package/es/cloneArray.js +0 -3
- package/es/convertCase.js +1 -0
- package/es/createChainedFunction.js +6 -11
- package/es/deepEqual.js +2 -1
- package/es/generateId.js +1 -2
- package/es/hash.js +1 -14
- package/es/isBaseTheme.js +1 -3
- package/es/isEdge.js +2 -1
- package/es/isEmpty.js +0 -4
- package/es/isIE11.js +2 -1
- package/es/mergeDeep.js +4 -8
- package/es/ms.js +5 -8
- package/es/parseUnit.js +3 -3
- package/es/pascalize.js +1 -2
- package/es/px.js +6 -9
- package/es/shallowEqual.js +5 -9
- package/es/within.js +0 -1
- package/lib/Browser.js +0 -4
- package/lib/camelize.js +0 -2
- package/lib/capitalizeFirstLetter.js +0 -2
- package/lib/cloneArray.js +0 -4
- package/lib/convertCase.js +0 -2
- package/lib/createChainedFunction.js +6 -12
- package/lib/deepEqual.js +0 -4
- package/lib/generateId.js +1 -3
- package/lib/hash.js +1 -16
- package/lib/index.js +0 -19
- package/lib/isBaseTheme.js +1 -4
- package/lib/isEdge.js +2 -2
- package/lib/isEmpty.js +0 -5
- package/lib/isIE11.js +2 -2
- package/lib/mergeDeep.js +4 -9
- package/lib/ms.js +3 -10
- package/lib/parseUnit.js +3 -4
- package/lib/pascalize.js +0 -4
- package/lib/px.js +5 -12
- package/lib/shallowEqual.js +5 -11
- package/lib/within.js +0 -2
- package/package.json +5 -5
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.33.2-snapshot-5](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2-snapshot-5) (2023-01-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-utils
|
package/es/Browser.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import Browser from 'bowser';
|
|
25
26
|
/**
|
|
26
27
|
* ---
|
|
@@ -32,6 +33,5 @@ import Browser from 'bowser';
|
|
|
32
33
|
* DEPRECATED This is just a re-export of the Bowser library
|
|
33
34
|
* @module Browser
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
36
|
export default Browser;
|
|
37
37
|
export { Browser };
|
package/es/camelize.js
CHANGED
package/es/cloneArray.js
CHANGED
|
@@ -34,16 +34,13 @@
|
|
|
34
34
|
function cloneArray(arr) {
|
|
35
35
|
if (Array.isArray(arr)) {
|
|
36
36
|
const copy = arr.slice(0);
|
|
37
|
-
|
|
38
37
|
for (let i = 0; i < copy.length; i++) {
|
|
39
38
|
copy[i] = cloneArray(copy[i]);
|
|
40
39
|
}
|
|
41
|
-
|
|
42
40
|
return copy;
|
|
43
41
|
} else {
|
|
44
42
|
return arr;
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
|
|
48
45
|
export default cloneArray;
|
|
49
46
|
export { cloneArray };
|
package/es/convertCase.js
CHANGED
|
@@ -36,38 +36,36 @@
|
|
|
36
36
|
* @param {function} funcs to chain
|
|
37
37
|
* @returns {function|null}
|
|
38
38
|
*/
|
|
39
|
+
|
|
39
40
|
function createChainedFunction() {
|
|
40
41
|
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
41
42
|
funcs[_key] = arguments[_key];
|
|
42
43
|
}
|
|
43
|
-
|
|
44
44
|
return funcs.filter((f, i) => {
|
|
45
45
|
if (f == null) {
|
|
46
46
|
return false;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
}
|
|
48
|
+
// Only allow the first of identical functions
|
|
50
49
|
const indexes = getAllIndexes(funcs, f);
|
|
51
50
|
return indexes.length === 1 || i === indexes[0];
|
|
52
51
|
}).reduce((acc, f) => {
|
|
53
52
|
if (typeof f !== 'function') {
|
|
54
53
|
throw new Error('Invalid Argument Type, must only provide functions, undefined, or null.');
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
if (acc === null) {
|
|
58
56
|
return f;
|
|
59
57
|
}
|
|
60
|
-
|
|
61
58
|
return function chainedFunction() {
|
|
62
59
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
63
60
|
args[_key2] = arguments[_key2];
|
|
64
61
|
}
|
|
65
|
-
|
|
66
62
|
acc.apply(this, args);
|
|
67
63
|
f.apply(this, args);
|
|
68
|
-
};
|
|
64
|
+
};
|
|
65
|
+
// TODO I think it can return null too
|
|
69
66
|
}, null);
|
|
70
67
|
}
|
|
68
|
+
|
|
71
69
|
/**
|
|
72
70
|
* Find all indexes for a value in an Array
|
|
73
71
|
*
|
|
@@ -75,8 +73,6 @@ function createChainedFunction() {
|
|
|
75
73
|
* @param {*} val The value to find indexes for
|
|
76
74
|
* @return {array} All the indexes of the Array matching val
|
|
77
75
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
76
|
function getAllIndexes(arr, val) {
|
|
81
77
|
const indexes = [];
|
|
82
78
|
arr.forEach((e, i) => {
|
|
@@ -86,6 +82,5 @@ function getAllIndexes(arr, val) {
|
|
|
86
82
|
});
|
|
87
83
|
return indexes;
|
|
88
84
|
}
|
|
89
|
-
|
|
90
85
|
export default createChainedFunction;
|
|
91
86
|
export { createChainedFunction };
|
package/es/deepEqual.js
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
import deepEqual from 'fast-deep-equal';
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* ---
|
|
27
29
|
* category: utilities
|
|
@@ -29,6 +31,5 @@ import deepEqual from 'fast-deep-equal';
|
|
|
29
31
|
* A wrapper for [fast-deep-equal](https://www.npmjs.com/package/fast-deep-equal)
|
|
30
32
|
* @module deepEqual
|
|
31
33
|
*/
|
|
32
|
-
|
|
33
34
|
export default deepEqual;
|
|
34
35
|
export { deepEqual };
|
package/es/generateId.js
CHANGED
|
@@ -28,15 +28,14 @@
|
|
|
28
28
|
* @param map - a Map<string, counter>, which counts how many times the given element/instance was rendered
|
|
29
29
|
* @returns a string in a format `instanceName_intanceRenderedCount`: `Alert_4`
|
|
30
30
|
*/
|
|
31
|
+
|
|
31
32
|
const generateId = (instanceName, map) => {
|
|
32
33
|
if (!map.has(instanceName)) {
|
|
33
34
|
map.set(instanceName, 0);
|
|
34
35
|
} else {
|
|
35
36
|
map.set(instanceName, map.get(instanceName) + 1);
|
|
36
37
|
}
|
|
37
|
-
|
|
38
38
|
return `${instanceName}_${map.get(instanceName)}`;
|
|
39
39
|
};
|
|
40
|
-
|
|
41
40
|
export default generateId;
|
|
42
41
|
export { generateId };
|
package/es/hash.js
CHANGED
|
@@ -21,18 +21,16 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
import stringify from 'json-stable-stringify';
|
|
25
24
|
|
|
25
|
+
import stringify from 'json-stable-stringify';
|
|
26
26
|
function toBase64(input) {
|
|
27
27
|
const tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
28
28
|
let output = '';
|
|
29
29
|
const length = input.length;
|
|
30
30
|
let triplet;
|
|
31
31
|
const b64pad = '=';
|
|
32
|
-
|
|
33
32
|
for (let i = 0; i < length; i += 3) {
|
|
34
33
|
triplet = input.charCodeAt(i) << 16 | (i + 1 < length ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < length ? input.charCodeAt(i + 2) : 0);
|
|
35
|
-
|
|
36
34
|
for (let j = 0; j < 4; j += 1) {
|
|
37
35
|
if (i * 8 + j * 6 > input.length * 8) {
|
|
38
36
|
output += b64pad;
|
|
@@ -41,14 +39,11 @@ function toBase64(input) {
|
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
|
|
45
42
|
return output;
|
|
46
43
|
}
|
|
47
|
-
|
|
48
44
|
function executeHash(input) {
|
|
49
45
|
let hash = 0;
|
|
50
46
|
if (input.length === 0) return '0';
|
|
51
|
-
|
|
52
47
|
for (let i = 0; i < input.length; i++) {
|
|
53
48
|
const c = input.charCodeAt(i);
|
|
54
49
|
hash = (hash << 5) - hash + c;
|
|
@@ -57,17 +52,13 @@ function executeHash(input) {
|
|
|
57
52
|
|
|
58
53
|
return toBase64(String(hash));
|
|
59
54
|
}
|
|
60
|
-
|
|
61
55
|
function hash(value) {
|
|
62
56
|
let maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
63
|
-
|
|
64
57
|
if (typeof value === 'undefined') {
|
|
65
58
|
throw new Error('Cannot hash a value which is undefined');
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
let hashedValue = '';
|
|
69
61
|
let valueToHash = value;
|
|
70
|
-
|
|
71
62
|
if (typeof valueToHash !== 'string') {
|
|
72
63
|
if (typeof valueToHash === 'object') {
|
|
73
64
|
// Ensure we are robust to things like objects that are identical, but with keys in diff orders
|
|
@@ -76,15 +67,11 @@ function hash(value) {
|
|
|
76
67
|
valueToHash = valueToHash.toString();
|
|
77
68
|
}
|
|
78
69
|
}
|
|
79
|
-
|
|
80
70
|
hashedValue = executeHash(valueToHash);
|
|
81
|
-
|
|
82
71
|
if (maxLength) {
|
|
83
72
|
hashedValue = hashedValue.slice(0, maxLength);
|
|
84
73
|
}
|
|
85
|
-
|
|
86
74
|
return hashedValue;
|
|
87
75
|
}
|
|
88
|
-
|
|
89
76
|
export default hash;
|
|
90
77
|
export { hash };
|
package/es/isBaseTheme.js
CHANGED
|
@@ -21,19 +21,17 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
const baseThemeProps = ['borders', 'breakpoints', 'colors', 'forms', 'media', 'shadows', 'spacing', 'stacking', 'transitions', 'typography'];
|
|
25
24
|
|
|
25
|
+
const baseThemeProps = ['borders', 'breakpoints', 'colors', 'forms', 'media', 'shadows', 'spacing', 'stacking', 'transitions', 'typography'];
|
|
26
26
|
const isBaseTheme = theme => {
|
|
27
27
|
if (Array.isArray(theme) || typeof theme === 'function') {
|
|
28
28
|
throw new Error();
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
try {
|
|
32
31
|
return 'key' in theme && baseThemeProps.every(prop => prop in theme);
|
|
33
32
|
} catch {
|
|
34
33
|
throw new Error();
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
|
-
|
|
38
36
|
export default isBaseTheme;
|
|
39
37
|
export { isBaseTheme };
|
package/es/isEdge.js
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* ---
|
|
27
29
|
* category: utilities
|
|
@@ -30,5 +32,4 @@ const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
|
30
32
|
* of [bowser](https://www.npmjs.com/package/bowser).
|
|
31
33
|
* @module isEdge
|
|
32
34
|
*/
|
|
33
|
-
|
|
34
35
|
export const isEdge = /Edge/.test(userAgent);
|
package/es/isEmpty.js
CHANGED
|
@@ -22,16 +22,12 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
25
|
-
|
|
26
25
|
function isEmpty(obj) {
|
|
27
26
|
if (typeof obj !== 'object') return true;
|
|
28
|
-
|
|
29
27
|
for (const key in obj) {
|
|
30
28
|
if (hasOwnProperty.call(obj, key)) return false;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
return true;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
32
|
export default isEmpty;
|
|
37
33
|
export { isEmpty };
|
package/es/isIE11.js
CHANGED
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
26
|
+
|
|
25
27
|
/**
|
|
26
28
|
* ---
|
|
27
29
|
* category: utilities
|
|
@@ -30,5 +32,4 @@ const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
|
30
32
|
* Use when you don't need all of [bowser](https://www.npmjs.com/package/bowser).
|
|
31
33
|
* @module isIE11
|
|
32
34
|
*/
|
|
33
|
-
|
|
34
35
|
export const isIE11 = /msie|trident/i.test(userAgent);
|
package/es/mergeDeep.js
CHANGED
|
@@ -38,21 +38,19 @@ function mergeDeep() {
|
|
|
38
38
|
// note: This could be typed as the union of its args, but since
|
|
39
39
|
// its barely used its not worth the effort currently
|
|
40
40
|
let target = {};
|
|
41
|
-
|
|
42
41
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
43
42
|
args[_key] = arguments[_key];
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
args.forEach(arg => {
|
|
47
45
|
target = mergeSourceIntoTarget(target, arg);
|
|
48
46
|
});
|
|
49
47
|
return target;
|
|
50
48
|
}
|
|
51
|
-
|
|
52
49
|
function mergeSourceIntoTarget(target, source) {
|
|
53
50
|
if (isObject(source)) {
|
|
54
51
|
const keys = [...Object.keys(source), ...Object.getOwnPropertySymbols(source)];
|
|
55
|
-
const merged = {
|
|
52
|
+
const merged = {
|
|
53
|
+
...target
|
|
56
54
|
};
|
|
57
55
|
keys.forEach(key => {
|
|
58
56
|
if (isObject(target[key]) && isObject(source[key])) {
|
|
@@ -67,18 +65,16 @@ function mergeSourceIntoTarget(target, source) {
|
|
|
67
65
|
});
|
|
68
66
|
return merged;
|
|
69
67
|
} else {
|
|
70
|
-
return {
|
|
68
|
+
return {
|
|
69
|
+
...target
|
|
71
70
|
};
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
|
|
75
73
|
function isObject(item) {
|
|
76
74
|
return item && (typeof item === 'object' || typeof item === 'function') && !Array.isArray(item);
|
|
77
75
|
}
|
|
78
|
-
|
|
79
76
|
function isArray(item) {
|
|
80
77
|
return Array.isArray(item);
|
|
81
78
|
}
|
|
82
|
-
|
|
83
79
|
export default mergeDeep;
|
|
84
80
|
export { mergeDeep };
|
package/es/ms.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,7 +22,9 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
25
|
+
|
|
26
26
|
import { parseUnit } from './parseUnit';
|
|
27
|
+
|
|
27
28
|
/**
|
|
28
29
|
* ---
|
|
29
30
|
* category: utilities
|
|
@@ -39,18 +40,15 @@ import { parseUnit } from './parseUnit';
|
|
|
39
40
|
* @param {String|Number} val
|
|
40
41
|
* @returns {Number} Returns numerical representation of milliseconds
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
43
|
function ms(val) {
|
|
44
44
|
// TODO: throw an error if val is not number or string
|
|
45
45
|
if (!val || typeof val === 'number') {
|
|
46
46
|
return val;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
48
|
const _parseUnit = parseUnit(val),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
_parseUnit2 = _slicedToArray(_parseUnit, 2),
|
|
50
|
+
num = _parseUnit2[0],
|
|
51
|
+
unit = _parseUnit2[1];
|
|
54
52
|
if (unit === 'ms') {
|
|
55
53
|
return num;
|
|
56
54
|
} else if (unit === 's') {
|
|
@@ -59,6 +57,5 @@ function ms(val) {
|
|
|
59
57
|
return num;
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
export default ms;
|
|
64
61
|
export { ms };
|
package/es/parseUnit.js
CHANGED
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
* @returns {Array} Returns array of shape [ value, unit ] Unit is '' if it could
|
|
41
41
|
* not be parsed
|
|
42
42
|
*/
|
|
43
|
-
function parseUnit(str) {
|
|
44
|
-
const value = `${str}`; // eslint-disable-next-line no-useless-escape
|
|
45
43
|
|
|
44
|
+
function parseUnit(str) {
|
|
45
|
+
const value = `${str}`;
|
|
46
|
+
// eslint-disable-next-line no-useless-escape
|
|
46
47
|
const match = value.match(/[\d.\-\+]*\s*(.*)/);
|
|
47
48
|
return [parseFloat(value), match && match.length > 0 ? match[1] : ''];
|
|
48
49
|
}
|
|
49
|
-
|
|
50
50
|
export default parseUnit;
|
|
51
51
|
export { parseUnit };
|
package/es/pascalize.js
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { capitalizeFirstLetter } from './capitalizeFirstLetter';
|
|
25
25
|
import { camelize } from './camelize';
|
|
26
|
+
|
|
26
27
|
/**
|
|
27
28
|
* ---
|
|
28
29
|
* category: utilities
|
|
@@ -41,10 +42,8 @@ import { camelize } from './camelize';
|
|
|
41
42
|
* @param {String} str
|
|
42
43
|
* @returns {String} Returns pascal cased string
|
|
43
44
|
*/
|
|
44
|
-
|
|
45
45
|
function pascalize(str) {
|
|
46
46
|
return capitalizeFirstLetter(camelize(str));
|
|
47
47
|
}
|
|
48
|
-
|
|
49
48
|
export default pascalize;
|
|
50
49
|
export { pascalize };
|
package/es/px.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,9 +22,9 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
25
|
+
|
|
26
26
|
import { getFontSize } from '@instructure/ui-dom-utils';
|
|
27
27
|
import { parseUnit } from './parseUnit';
|
|
28
|
-
|
|
29
28
|
/**
|
|
30
29
|
* ---
|
|
31
30
|
* category: utilities
|
|
@@ -44,17 +43,16 @@ import { parseUnit } from './parseUnit';
|
|
|
44
43
|
* @returns {Number} Returns numerical representation of pixels
|
|
45
44
|
*/
|
|
46
45
|
function px(val, el) {
|
|
47
|
-
const container = el || document.body;
|
|
46
|
+
const container = el || document.body;
|
|
48
47
|
|
|
48
|
+
// TODO !val should not be needed
|
|
49
49
|
if (!val || typeof val === 'number') {
|
|
50
50
|
return val;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
const _parseUnit = parseUnit(val),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
_parseUnit2 = _slicedToArray(_parseUnit, 2),
|
|
54
|
+
num = _parseUnit2[0],
|
|
55
|
+
unit = _parseUnit2[1];
|
|
58
56
|
if (unit === 'rem') {
|
|
59
57
|
return num * getFontSize();
|
|
60
58
|
} else if (unit === 'em') {
|
|
@@ -63,6 +61,5 @@ function px(val, el) {
|
|
|
63
61
|
return num;
|
|
64
62
|
}
|
|
65
63
|
}
|
|
66
|
-
|
|
67
64
|
export default px;
|
|
68
65
|
export { px };
|
package/es/shallowEqual.js
CHANGED
|
@@ -21,8 +21,10 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
+
|
|
24
25
|
// https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/shallowEqual.js
|
|
25
26
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
27
|
+
|
|
26
28
|
/**
|
|
27
29
|
* ---
|
|
28
30
|
* category: utilities
|
|
@@ -36,38 +38,32 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
36
38
|
* @param {Object} objB
|
|
37
39
|
* @returns {Boolean} Returns true when the values of all keys are strictly equal
|
|
38
40
|
*/
|
|
39
|
-
|
|
40
41
|
function shallowEqual(objA, objB) {
|
|
41
42
|
if (is(objA, objB)) {
|
|
42
43
|
return true;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
45
|
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
46
46
|
return false;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
48
|
const keysA = Object.keys(objA);
|
|
50
49
|
const keysB = Object.keys(objB);
|
|
51
|
-
|
|
52
50
|
if (keysA.length !== keysB.length) {
|
|
53
51
|
return false;
|
|
54
|
-
}
|
|
55
|
-
|
|
52
|
+
}
|
|
56
53
|
|
|
54
|
+
// Test for A's keys different from B.
|
|
57
55
|
for (let i = 0; i < keysA.length; i++) {
|
|
58
56
|
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
59
57
|
return false;
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
return true;
|
|
64
61
|
}
|
|
62
|
+
|
|
65
63
|
/*
|
|
66
64
|
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
67
65
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
68
66
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
67
|
function is(x, y) {
|
|
72
68
|
// SameValue algorithm
|
|
73
69
|
if (x === y) {
|
package/es/within.js
CHANGED
package/lib/Browser.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -12,9 +11,7 @@ Object.defineProperty(exports, "Browser", {
|
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
13
|
exports.default = void 0;
|
|
15
|
-
|
|
16
14
|
var _bowser = _interopRequireDefault(require("bowser"));
|
|
17
|
-
|
|
18
15
|
/*
|
|
19
16
|
* The MIT License (MIT)
|
|
20
17
|
*
|
|
@@ -38,7 +35,6 @@ var _bowser = _interopRequireDefault(require("bowser"));
|
|
|
38
35
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
39
36
|
* SOFTWARE.
|
|
40
37
|
*/
|
|
41
|
-
|
|
42
38
|
/**
|
|
43
39
|
* ---
|
|
44
40
|
* category: components/deprecated
|
package/lib/camelize.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.camelize = camelize;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -51,6 +50,5 @@ exports.default = void 0;
|
|
|
51
50
|
function camelize(str) {
|
|
52
51
|
return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
|
|
53
52
|
}
|
|
54
|
-
|
|
55
53
|
var _default = camelize;
|
|
56
54
|
exports.default = _default;
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -41,6 +40,5 @@ exports.default = void 0;
|
|
|
41
40
|
function capitalizeFirstLetter(str) {
|
|
42
41
|
return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
|
|
43
42
|
}
|
|
44
|
-
|
|
45
43
|
var _default = capitalizeFirstLetter;
|
|
46
44
|
exports.default = _default;
|
package/lib/cloneArray.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.cloneArray = cloneArray;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -42,16 +41,13 @@ exports.default = void 0;
|
|
|
42
41
|
function cloneArray(arr) {
|
|
43
42
|
if (Array.isArray(arr)) {
|
|
44
43
|
const copy = arr.slice(0);
|
|
45
|
-
|
|
46
44
|
for (let i = 0; i < copy.length; i++) {
|
|
47
45
|
copy[i] = cloneArray(copy[i]);
|
|
48
46
|
}
|
|
49
|
-
|
|
50
47
|
return copy;
|
|
51
48
|
} else {
|
|
52
49
|
return arr;
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
|
-
|
|
56
52
|
var _default = cloneArray;
|
|
57
53
|
exports.default = _default;
|