@instructure/ui-utils 8.33.1-snapshot-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 +4 -8
- 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
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createChainedFunction = createChainedFunction;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -44,38 +43,36 @@ exports.default = void 0;
|
|
|
44
43
|
* @param {function} funcs to chain
|
|
45
44
|
* @returns {function|null}
|
|
46
45
|
*/
|
|
46
|
+
|
|
47
47
|
function createChainedFunction() {
|
|
48
48
|
for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
49
|
funcs[_key] = arguments[_key];
|
|
50
50
|
}
|
|
51
|
-
|
|
52
51
|
return funcs.filter((f, i) => {
|
|
53
52
|
if (f == null) {
|
|
54
53
|
return false;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
}
|
|
55
|
+
// Only allow the first of identical functions
|
|
58
56
|
const indexes = getAllIndexes(funcs, f);
|
|
59
57
|
return indexes.length === 1 || i === indexes[0];
|
|
60
58
|
}).reduce((acc, f) => {
|
|
61
59
|
if (typeof f !== 'function') {
|
|
62
60
|
throw new Error('Invalid Argument Type, must only provide functions, undefined, or null.');
|
|
63
61
|
}
|
|
64
|
-
|
|
65
62
|
if (acc === null) {
|
|
66
63
|
return f;
|
|
67
64
|
}
|
|
68
|
-
|
|
69
65
|
return function chainedFunction() {
|
|
70
66
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
71
67
|
args[_key2] = arguments[_key2];
|
|
72
68
|
}
|
|
73
|
-
|
|
74
69
|
acc.apply(this, args);
|
|
75
70
|
f.apply(this, args);
|
|
76
|
-
};
|
|
71
|
+
};
|
|
72
|
+
// TODO I think it can return null too
|
|
77
73
|
}, null);
|
|
78
74
|
}
|
|
75
|
+
|
|
79
76
|
/**
|
|
80
77
|
* Find all indexes for a value in an Array
|
|
81
78
|
*
|
|
@@ -83,8 +80,6 @@ function createChainedFunction() {
|
|
|
83
80
|
* @param {*} val The value to find indexes for
|
|
84
81
|
* @return {array} All the indexes of the Array matching val
|
|
85
82
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
83
|
function getAllIndexes(arr, val) {
|
|
89
84
|
const indexes = [];
|
|
90
85
|
arr.forEach((e, i) => {
|
|
@@ -94,6 +89,5 @@ function getAllIndexes(arr, val) {
|
|
|
94
89
|
});
|
|
95
90
|
return indexes;
|
|
96
91
|
}
|
|
97
|
-
|
|
98
92
|
var _default = createChainedFunction;
|
|
99
93
|
exports.default = _default;
|
package/lib/deepEqual.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, "deepEqual", {
|
|
|
12
11
|
}
|
|
13
12
|
});
|
|
14
13
|
exports.default = void 0;
|
|
15
|
-
|
|
16
14
|
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
|
|
17
|
-
|
|
18
15
|
/*
|
|
19
16
|
* The MIT License (MIT)
|
|
20
17
|
*
|
|
@@ -38,7 +35,6 @@ var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
|
|
|
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: utilities
|
package/lib/generateId.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateId = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -35,16 +34,15 @@ exports.generateId = exports.default = void 0;
|
|
|
35
34
|
* @param map - a Map<string, counter>, which counts how many times the given element/instance was rendered
|
|
36
35
|
* @returns a string in a format `instanceName_intanceRenderedCount`: `Alert_4`
|
|
37
36
|
*/
|
|
37
|
+
|
|
38
38
|
const generateId = (instanceName, map) => {
|
|
39
39
|
if (!map.has(instanceName)) {
|
|
40
40
|
map.set(instanceName, 0);
|
|
41
41
|
} else {
|
|
42
42
|
map.set(instanceName, map.get(instanceName) + 1);
|
|
43
43
|
}
|
|
44
|
-
|
|
45
44
|
return `${instanceName}_${map.get(instanceName)}`;
|
|
46
45
|
};
|
|
47
|
-
|
|
48
46
|
exports.generateId = generateId;
|
|
49
47
|
var _default = generateId;
|
|
50
48
|
exports.default = _default;
|
package/lib/hash.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
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
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
8
|
exports.hash = hash;
|
|
10
|
-
|
|
11
9
|
var _jsonStableStringify = _interopRequireDefault(require("json-stable-stringify"));
|
|
12
|
-
|
|
13
10
|
/*
|
|
14
11
|
* The MIT License (MIT)
|
|
15
12
|
*
|
|
@@ -33,16 +30,15 @@ var _jsonStableStringify = _interopRequireDefault(require("json-stable-stringify
|
|
|
33
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
34
31
|
* SOFTWARE.
|
|
35
32
|
*/
|
|
33
|
+
|
|
36
34
|
function toBase64(input) {
|
|
37
35
|
const tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
38
36
|
let output = '';
|
|
39
37
|
const length = input.length;
|
|
40
38
|
let triplet;
|
|
41
39
|
const b64pad = '=';
|
|
42
|
-
|
|
43
40
|
for (let i = 0; i < length; i += 3) {
|
|
44
41
|
triplet = input.charCodeAt(i) << 16 | (i + 1 < length ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < length ? input.charCodeAt(i + 2) : 0);
|
|
45
|
-
|
|
46
42
|
for (let j = 0; j < 4; j += 1) {
|
|
47
43
|
if (i * 8 + j * 6 > input.length * 8) {
|
|
48
44
|
output += b64pad;
|
|
@@ -51,14 +47,11 @@ function toBase64(input) {
|
|
|
51
47
|
}
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
return output;
|
|
56
51
|
}
|
|
57
|
-
|
|
58
52
|
function executeHash(input) {
|
|
59
53
|
let hash = 0;
|
|
60
54
|
if (input.length === 0) return '0';
|
|
61
|
-
|
|
62
55
|
for (let i = 0; i < input.length; i++) {
|
|
63
56
|
const c = input.charCodeAt(i);
|
|
64
57
|
hash = (hash << 5) - hash + c;
|
|
@@ -67,17 +60,13 @@ function executeHash(input) {
|
|
|
67
60
|
|
|
68
61
|
return toBase64(String(hash));
|
|
69
62
|
}
|
|
70
|
-
|
|
71
63
|
function hash(value) {
|
|
72
64
|
let maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0;
|
|
73
|
-
|
|
74
65
|
if (typeof value === 'undefined') {
|
|
75
66
|
throw new Error('Cannot hash a value which is undefined');
|
|
76
67
|
}
|
|
77
|
-
|
|
78
68
|
let hashedValue = '';
|
|
79
69
|
let valueToHash = value;
|
|
80
|
-
|
|
81
70
|
if (typeof valueToHash !== 'string') {
|
|
82
71
|
if (typeof valueToHash === 'object') {
|
|
83
72
|
// Ensure we are robust to things like objects that are identical, but with keys in diff orders
|
|
@@ -86,15 +75,11 @@ function hash(value) {
|
|
|
86
75
|
valueToHash = valueToHash.toString();
|
|
87
76
|
}
|
|
88
77
|
}
|
|
89
|
-
|
|
90
78
|
hashedValue = executeHash(valueToHash);
|
|
91
|
-
|
|
92
79
|
if (maxLength) {
|
|
93
80
|
hashedValue = hashedValue.slice(0, maxLength);
|
|
94
81
|
}
|
|
95
|
-
|
|
96
82
|
return hashedValue;
|
|
97
83
|
}
|
|
98
|
-
|
|
99
84
|
var _default = hash;
|
|
100
85
|
exports.default = _default;
|
package/lib/index.js
CHANGED
|
@@ -117,41 +117,22 @@ Object.defineProperty(exports, "within", {
|
|
|
117
117
|
return _within.within;
|
|
118
118
|
}
|
|
119
119
|
});
|
|
120
|
-
|
|
121
120
|
var _Browser = require("./Browser");
|
|
122
|
-
|
|
123
121
|
var _isEdge = require("./isEdge");
|
|
124
|
-
|
|
125
122
|
var _isIE = require("./isIE11");
|
|
126
|
-
|
|
127
123
|
var _capitalizeFirstLetter = require("./capitalizeFirstLetter");
|
|
128
|
-
|
|
129
124
|
var _cloneArray = require("./cloneArray");
|
|
130
|
-
|
|
131
125
|
var _createChainedFunction = require("./createChainedFunction");
|
|
132
|
-
|
|
133
126
|
var _deepEqual = require("./deepEqual");
|
|
134
|
-
|
|
135
127
|
var _hash = require("./hash");
|
|
136
|
-
|
|
137
128
|
var _generateId = require("./generateId");
|
|
138
|
-
|
|
139
129
|
var _isEmpty = require("./isEmpty");
|
|
140
|
-
|
|
141
130
|
var _mergeDeep = require("./mergeDeep");
|
|
142
|
-
|
|
143
131
|
var _ms = require("./ms");
|
|
144
|
-
|
|
145
132
|
var _parseUnit = require("./parseUnit");
|
|
146
|
-
|
|
147
133
|
var _px = require("./px");
|
|
148
|
-
|
|
149
134
|
var _shallowEqual = require("./shallowEqual");
|
|
150
|
-
|
|
151
135
|
var _within = require("./within");
|
|
152
|
-
|
|
153
136
|
var _camelize = require("./camelize");
|
|
154
|
-
|
|
155
137
|
var _pascalize = require("./pascalize");
|
|
156
|
-
|
|
157
138
|
var _isBaseTheme = require("./isBaseTheme");
|
package/lib/isBaseTheme.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isBaseTheme = exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -28,20 +27,18 @@ exports.isBaseTheme = exports.default = void 0;
|
|
|
28
27
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
28
|
* SOFTWARE.
|
|
30
29
|
*/
|
|
31
|
-
const baseThemeProps = ['borders', 'breakpoints', 'colors', 'forms', 'media', 'shadows', 'spacing', 'stacking', 'transitions', 'typography'];
|
|
32
30
|
|
|
31
|
+
const baseThemeProps = ['borders', 'breakpoints', 'colors', 'forms', 'media', 'shadows', 'spacing', 'stacking', 'transitions', 'typography'];
|
|
33
32
|
const isBaseTheme = theme => {
|
|
34
33
|
if (Array.isArray(theme) || typeof theme === 'function') {
|
|
35
34
|
throw new Error();
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
try {
|
|
39
37
|
return 'key' in theme && baseThemeProps.every(prop => prop in theme);
|
|
40
38
|
} catch {
|
|
41
39
|
throw new Error();
|
|
42
40
|
}
|
|
43
41
|
};
|
|
44
|
-
|
|
45
42
|
exports.isBaseTheme = isBaseTheme;
|
|
46
43
|
var _default = isBaseTheme;
|
|
47
44
|
exports.default = _default;
|
package/lib/isEdge.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isEdge = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -28,7 +27,9 @@ exports.isEdge = void 0;
|
|
|
28
27
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
28
|
* SOFTWARE.
|
|
30
29
|
*/
|
|
30
|
+
|
|
31
31
|
const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
32
|
+
|
|
32
33
|
/**
|
|
33
34
|
* ---
|
|
34
35
|
* category: utilities
|
|
@@ -37,6 +38,5 @@ const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
|
37
38
|
* of [bowser](https://www.npmjs.com/package/bowser).
|
|
38
39
|
* @module isEdge
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
41
|
const isEdge = /Edge/.test(userAgent);
|
|
42
42
|
exports.isEdge = isEdge;
|
package/lib/isEmpty.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.isEmpty = isEmpty;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -30,16 +29,12 @@ exports.isEmpty = isEmpty;
|
|
|
30
29
|
* SOFTWARE.
|
|
31
30
|
*/
|
|
32
31
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
33
|
-
|
|
34
32
|
function isEmpty(obj) {
|
|
35
33
|
if (typeof obj !== 'object') return true;
|
|
36
|
-
|
|
37
34
|
for (const key in obj) {
|
|
38
35
|
if (hasOwnProperty.call(obj, key)) return false;
|
|
39
36
|
}
|
|
40
|
-
|
|
41
37
|
return true;
|
|
42
38
|
}
|
|
43
|
-
|
|
44
39
|
var _default = isEmpty;
|
|
45
40
|
exports.default = _default;
|
package/lib/isIE11.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isIE11 = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -28,7 +27,9 @@ exports.isIE11 = void 0;
|
|
|
28
27
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
28
|
* SOFTWARE.
|
|
30
29
|
*/
|
|
30
|
+
|
|
31
31
|
const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
32
|
+
|
|
32
33
|
/**
|
|
33
34
|
* ---
|
|
34
35
|
* category: utilities
|
|
@@ -37,6 +38,5 @@ const userAgent = typeof navigator !== 'undefined' && navigator.userAgent || '';
|
|
|
37
38
|
* Use when you don't need all of [bowser](https://www.npmjs.com/package/bowser).
|
|
38
39
|
* @module isIE11
|
|
39
40
|
*/
|
|
40
|
-
|
|
41
41
|
const isIE11 = /msie|trident/i.test(userAgent);
|
|
42
42
|
exports.isIE11 = isIE11;
|
package/lib/mergeDeep.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.mergeDeep = mergeDeep;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -46,21 +45,19 @@ function mergeDeep() {
|
|
|
46
45
|
// note: This could be typed as the union of its args, but since
|
|
47
46
|
// its barely used its not worth the effort currently
|
|
48
47
|
let target = {};
|
|
49
|
-
|
|
50
48
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
51
49
|
args[_key] = arguments[_key];
|
|
52
50
|
}
|
|
53
|
-
|
|
54
51
|
args.forEach(arg => {
|
|
55
52
|
target = mergeSourceIntoTarget(target, arg);
|
|
56
53
|
});
|
|
57
54
|
return target;
|
|
58
55
|
}
|
|
59
|
-
|
|
60
56
|
function mergeSourceIntoTarget(target, source) {
|
|
61
57
|
if (isObject(source)) {
|
|
62
58
|
const keys = [...Object.keys(source), ...Object.getOwnPropertySymbols(source)];
|
|
63
|
-
const merged = {
|
|
59
|
+
const merged = {
|
|
60
|
+
...target
|
|
64
61
|
};
|
|
65
62
|
keys.forEach(key => {
|
|
66
63
|
if (isObject(target[key]) && isObject(source[key])) {
|
|
@@ -75,18 +72,16 @@ function mergeSourceIntoTarget(target, source) {
|
|
|
75
72
|
});
|
|
76
73
|
return merged;
|
|
77
74
|
} else {
|
|
78
|
-
return {
|
|
75
|
+
return {
|
|
76
|
+
...target
|
|
79
77
|
};
|
|
80
78
|
}
|
|
81
79
|
}
|
|
82
|
-
|
|
83
80
|
function isObject(item) {
|
|
84
81
|
return item && (typeof item === 'object' || typeof item === 'function') && !Array.isArray(item);
|
|
85
82
|
}
|
|
86
|
-
|
|
87
83
|
function isArray(item) {
|
|
88
84
|
return Array.isArray(item);
|
|
89
85
|
}
|
|
90
|
-
|
|
91
86
|
var _default = mergeDeep;
|
|
92
87
|
exports.default = _default;
|
package/lib/ms.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
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
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
8
|
exports.ms = ms;
|
|
10
|
-
|
|
11
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
|
|
13
10
|
var _parseUnit3 = require("./parseUnit");
|
|
14
|
-
|
|
15
11
|
/*
|
|
16
12
|
* The MIT License (MIT)
|
|
17
13
|
*
|
|
@@ -56,12 +52,10 @@ function ms(val) {
|
|
|
56
52
|
if (!val || typeof val === 'number') {
|
|
57
53
|
return val;
|
|
58
54
|
}
|
|
59
|
-
|
|
60
55
|
const _parseUnit = (0, _parseUnit3.parseUnit)(val),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
_parseUnit2 = (0, _slicedToArray2.default)(_parseUnit, 2),
|
|
57
|
+
num = _parseUnit2[0],
|
|
58
|
+
unit = _parseUnit2[1];
|
|
65
59
|
if (unit === 'ms') {
|
|
66
60
|
return num;
|
|
67
61
|
} else if (unit === 's') {
|
|
@@ -70,6 +64,5 @@ function ms(val) {
|
|
|
70
64
|
return num;
|
|
71
65
|
}
|
|
72
66
|
}
|
|
73
|
-
|
|
74
67
|
var _default = ms;
|
|
75
68
|
exports.default = _default;
|
package/lib/parseUnit.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.parseUnit = parseUnit;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -48,12 +47,12 @@ exports.parseUnit = parseUnit;
|
|
|
48
47
|
* @returns {Array} Returns array of shape [ value, unit ] Unit is '' if it could
|
|
49
48
|
* not be parsed
|
|
50
49
|
*/
|
|
51
|
-
function parseUnit(str) {
|
|
52
|
-
const value = `${str}`; // eslint-disable-next-line no-useless-escape
|
|
53
50
|
|
|
51
|
+
function parseUnit(str) {
|
|
52
|
+
const value = `${str}`;
|
|
53
|
+
// eslint-disable-next-line no-useless-escape
|
|
54
54
|
const match = value.match(/[\d.\-\+]*\s*(.*)/);
|
|
55
55
|
return [parseFloat(value), match && match.length > 0 ? match[1] : ''];
|
|
56
56
|
}
|
|
57
|
-
|
|
58
57
|
var _default = parseUnit;
|
|
59
58
|
exports.default = _default;
|
package/lib/pascalize.js
CHANGED
|
@@ -5,11 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.pascalize = pascalize;
|
|
8
|
-
|
|
9
8
|
var _capitalizeFirstLetter = require("./capitalizeFirstLetter");
|
|
10
|
-
|
|
11
9
|
var _camelize = require("./camelize");
|
|
12
|
-
|
|
13
10
|
/*
|
|
14
11
|
* The MIT License (MIT)
|
|
15
12
|
*
|
|
@@ -55,6 +52,5 @@ var _camelize = require("./camelize");
|
|
|
55
52
|
function pascalize(str) {
|
|
56
53
|
return (0, _capitalizeFirstLetter.capitalizeFirstLetter)((0, _camelize.camelize)(str));
|
|
57
54
|
}
|
|
58
|
-
|
|
59
55
|
var _default = pascalize;
|
|
60
56
|
exports.default = _default;
|
package/lib/px.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
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
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
8
|
exports.px = px;
|
|
10
|
-
|
|
11
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
|
-
|
|
13
10
|
var _getFontSize = require("@instructure/ui-dom-utils/lib/getFontSize.js");
|
|
14
|
-
|
|
15
11
|
var _parseUnit3 = require("./parseUnit");
|
|
16
|
-
|
|
17
12
|
/*
|
|
18
13
|
* The MIT License (MIT)
|
|
19
14
|
*
|
|
@@ -56,17 +51,16 @@ var _parseUnit3 = require("./parseUnit");
|
|
|
56
51
|
* @returns {Number} Returns numerical representation of pixels
|
|
57
52
|
*/
|
|
58
53
|
function px(val, el) {
|
|
59
|
-
const container = el || document.body;
|
|
54
|
+
const container = el || document.body;
|
|
60
55
|
|
|
56
|
+
// TODO !val should not be needed
|
|
61
57
|
if (!val || typeof val === 'number') {
|
|
62
58
|
return val;
|
|
63
59
|
}
|
|
64
|
-
|
|
65
60
|
const _parseUnit = (0, _parseUnit3.parseUnit)(val),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
61
|
+
_parseUnit2 = (0, _slicedToArray2.default)(_parseUnit, 2),
|
|
62
|
+
num = _parseUnit2[0],
|
|
63
|
+
unit = _parseUnit2[1];
|
|
70
64
|
if (unit === 'rem') {
|
|
71
65
|
return num * (0, _getFontSize.getFontSize)();
|
|
72
66
|
} else if (unit === 'em') {
|
|
@@ -75,6 +69,5 @@ function px(val, el) {
|
|
|
75
69
|
return num;
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
|
-
|
|
79
72
|
var _default = px;
|
|
80
73
|
exports.default = _default;
|
package/lib/shallowEqual.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.shallowEqual = shallowEqual;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -29,8 +28,10 @@ exports.shallowEqual = shallowEqual;
|
|
|
29
28
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
29
|
* SOFTWARE.
|
|
31
30
|
*/
|
|
31
|
+
|
|
32
32
|
// https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/shallowEqual.js
|
|
33
33
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
34
|
+
|
|
34
35
|
/**
|
|
35
36
|
* ---
|
|
36
37
|
* category: utilities
|
|
@@ -44,38 +45,32 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
|
44
45
|
* @param {Object} objB
|
|
45
46
|
* @returns {Boolean} Returns true when the values of all keys are strictly equal
|
|
46
47
|
*/
|
|
47
|
-
|
|
48
48
|
function shallowEqual(objA, objB) {
|
|
49
49
|
if (is(objA, objB)) {
|
|
50
50
|
return true;
|
|
51
51
|
}
|
|
52
|
-
|
|
53
52
|
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
54
53
|
return false;
|
|
55
54
|
}
|
|
56
|
-
|
|
57
55
|
const keysA = Object.keys(objA);
|
|
58
56
|
const keysB = Object.keys(objB);
|
|
59
|
-
|
|
60
57
|
if (keysA.length !== keysB.length) {
|
|
61
58
|
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
59
|
+
}
|
|
64
60
|
|
|
61
|
+
// Test for A's keys different from B.
|
|
65
62
|
for (let i = 0; i < keysA.length; i++) {
|
|
66
63
|
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
67
64
|
return false;
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
|
|
71
67
|
return true;
|
|
72
68
|
}
|
|
69
|
+
|
|
73
70
|
/*
|
|
74
71
|
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
75
72
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
76
73
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
74
|
function is(x, y) {
|
|
80
75
|
// SameValue algorithm
|
|
81
76
|
if (x === y) {
|
|
@@ -87,6 +82,5 @@ function is(x, y) {
|
|
|
87
82
|
return x !== x && y !== y; // eslint-disable-line no-self-compare
|
|
88
83
|
}
|
|
89
84
|
}
|
|
90
|
-
|
|
91
85
|
var _default = shallowEqual;
|
|
92
86
|
exports.default = _default;
|
package/lib/within.js
CHANGED
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.within = within;
|
|
8
|
-
|
|
9
8
|
/*
|
|
10
9
|
* The MIT License (MIT)
|
|
11
10
|
*
|
|
@@ -47,6 +46,5 @@ function within(a, b) {
|
|
|
47
46
|
let diff = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
|
|
48
47
|
return a + diff >= b && b >= a - diff;
|
|
49
48
|
}
|
|
50
|
-
|
|
51
49
|
var _default = within;
|
|
52
50
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-utils",
|
|
3
|
-
"version": "8.33.
|
|
3
|
+
"version": "8.33.2-snapshot-5",
|
|
4
4
|
"description": "A collection of utilities for UI components",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@instructure/ui-babel-preset": "8.33.
|
|
26
|
-
"@instructure/ui-test-utils": "8.33.
|
|
25
|
+
"@instructure/ui-babel-preset": "8.33.2-snapshot-5",
|
|
26
|
+
"@instructure/ui-test-utils": "8.33.2-snapshot-5",
|
|
27
27
|
"@types/json-stable-stringify": "^1.0.1"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@babel/runtime": "^7.13.10",
|
|
31
|
-
"@instructure/console": "8.33.
|
|
32
|
-
"@instructure/ui-dom-utils": "8.33.
|
|
31
|
+
"@instructure/console": "8.33.2-snapshot-5",
|
|
32
|
+
"@instructure/ui-dom-utils": "8.33.2-snapshot-5",
|
|
33
33
|
"bowser": "^1.9.4",
|
|
34
34
|
"fast-deep-equal": "^3",
|
|
35
35
|
"json-stable-stringify": "^1.0.1",
|