@instructure/ui-utils 11.6.0 → 11.6.1-pr-snapshot-1779894247159

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/lib/index.js DELETED
@@ -1,173 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "camelize", {
7
- enumerable: true,
8
- get: function () {
9
- return _camelize.camelize;
10
- }
11
- });
12
- Object.defineProperty(exports, "capitalizeFirstLetter", {
13
- enumerable: true,
14
- get: function () {
15
- return _capitalizeFirstLetter.capitalizeFirstLetter;
16
- }
17
- });
18
- Object.defineProperty(exports, "cloneArray", {
19
- enumerable: true,
20
- get: function () {
21
- return _cloneArray.cloneArray;
22
- }
23
- });
24
- Object.defineProperty(exports, "combineDataCid", {
25
- enumerable: true,
26
- get: function () {
27
- return _combineDataCid.combineDataCid;
28
- }
29
- });
30
- Object.defineProperty(exports, "createChainedFunction", {
31
- enumerable: true,
32
- get: function () {
33
- return _createChainedFunction.createChainedFunction;
34
- }
35
- });
36
- Object.defineProperty(exports, "deepEqual", {
37
- enumerable: true,
38
- get: function () {
39
- return _deepEqual.deepEqual;
40
- }
41
- });
42
- Object.defineProperty(exports, "generateId", {
43
- enumerable: true,
44
- get: function () {
45
- return _generateId.generateId;
46
- }
47
- });
48
- Object.defineProperty(exports, "getBrowser", {
49
- enumerable: true,
50
- get: function () {
51
- return _getBrowser.getBrowser;
52
- }
53
- });
54
- Object.defineProperty(exports, "hash", {
55
- enumerable: true,
56
- get: function () {
57
- return _hash.hash;
58
- }
59
- });
60
- Object.defineProperty(exports, "isAndroidOrIOS", {
61
- enumerable: true,
62
- get: function () {
63
- return _getBrowser.isAndroidOrIOS;
64
- }
65
- });
66
- Object.defineProperty(exports, "isBaseTheme", {
67
- enumerable: true,
68
- get: function () {
69
- return _isBaseTheme.isBaseTheme;
70
- }
71
- });
72
- Object.defineProperty(exports, "isChromium", {
73
- enumerable: true,
74
- get: function () {
75
- return _getBrowser.isChromium;
76
- }
77
- });
78
- Object.defineProperty(exports, "isEdge", {
79
- enumerable: true,
80
- get: function () {
81
- return _getBrowser.isEdge;
82
- }
83
- });
84
- Object.defineProperty(exports, "isEmpty", {
85
- enumerable: true,
86
- get: function () {
87
- return _isEmpty.isEmpty;
88
- }
89
- });
90
- Object.defineProperty(exports, "isFirefox", {
91
- enumerable: true,
92
- get: function () {
93
- return _getBrowser.isFirefox;
94
- }
95
- });
96
- Object.defineProperty(exports, "isIE", {
97
- enumerable: true,
98
- get: function () {
99
- return _getBrowser.isIE;
100
- }
101
- });
102
- Object.defineProperty(exports, "isMac", {
103
- enumerable: true,
104
- get: function () {
105
- return _getBrowser.isMac;
106
- }
107
- });
108
- Object.defineProperty(exports, "isSafari", {
109
- enumerable: true,
110
- get: function () {
111
- return _getBrowser.isSafari;
112
- }
113
- });
114
- Object.defineProperty(exports, "mergeDeep", {
115
- enumerable: true,
116
- get: function () {
117
- return _mergeDeep.mergeDeep;
118
- }
119
- });
120
- Object.defineProperty(exports, "ms", {
121
- enumerable: true,
122
- get: function () {
123
- return _ms.ms;
124
- }
125
- });
126
- Object.defineProperty(exports, "parseUnit", {
127
- enumerable: true,
128
- get: function () {
129
- return _parseUnit.parseUnit;
130
- }
131
- });
132
- Object.defineProperty(exports, "pascalize", {
133
- enumerable: true,
134
- get: function () {
135
- return _pascalize.pascalize;
136
- }
137
- });
138
- Object.defineProperty(exports, "px", {
139
- enumerable: true,
140
- get: function () {
141
- return _px.px;
142
- }
143
- });
144
- Object.defineProperty(exports, "shallowEqual", {
145
- enumerable: true,
146
- get: function () {
147
- return _shallowEqual.shallowEqual;
148
- }
149
- });
150
- Object.defineProperty(exports, "within", {
151
- enumerable: true,
152
- get: function () {
153
- return _within.within;
154
- }
155
- });
156
- var _capitalizeFirstLetter = require("./capitalizeFirstLetter");
157
- var _cloneArray = require("./cloneArray");
158
- var _createChainedFunction = require("./createChainedFunction");
159
- var _deepEqual = require("./deepEqual");
160
- var _hash = require("./hash");
161
- var _generateId = require("./generateId");
162
- var _isEmpty = require("./isEmpty");
163
- var _mergeDeep = require("./mergeDeep");
164
- var _ms = require("./ms");
165
- var _parseUnit = require("./parseUnit");
166
- var _px = require("./px");
167
- var _shallowEqual = require("./shallowEqual");
168
- var _within = require("./within");
169
- var _camelize = require("./camelize");
170
- var _pascalize = require("./pascalize");
171
- var _isBaseTheme = require("./isBaseTheme");
172
- var _getBrowser = require("./getBrowser");
173
- var _combineDataCid = require("./combineDataCid");
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isBaseTheme = exports.default = void 0;
7
- /*
8
- * The MIT License (MIT)
9
- *
10
- * Copyright (c) 2015 - present Instructure, Inc.
11
- *
12
- * Permission is hereby granted, free of charge, to any person obtaining a copy
13
- * of this software and associated documentation files (the "Software"), to deal
14
- * in the Software without restriction, including without limitation the rights
15
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
- * copies of the Software, and to permit persons to whom the Software is
17
- * furnished to do so, subject to the following conditions:
18
- *
19
- * The above copyright notice and this permission notice shall be included in all
20
- * copies or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
- * SOFTWARE.
29
- */
30
-
31
- const baseThemeProps = ['borders', 'breakpoints', 'colors', 'forms', 'media', 'shadows', 'spacing', 'stacking', 'transitions', 'typography'];
32
-
33
- /**
34
- * Checks if the given param is an object with all the keys needed for an
35
- * Instructure theme.
36
- * @param theme Anything. This function will throw an error if it's not a theme
37
- * object.
38
- */
39
- const isBaseTheme = theme => {
40
- if (Array.isArray(theme) || typeof theme === 'function') {
41
- throw new Error();
42
- }
43
- try {
44
- return 'key' in theme && baseThemeProps.every(prop => prop in theme);
45
- } catch {
46
- throw new Error();
47
- }
48
- };
49
- exports.isBaseTheme = isBaseTheme;
50
- var _default = exports.default = isBaseTheme;
package/lib/mergeDeep.js DELETED
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.mergeDeep = mergeDeep;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /**
33
- * ---
34
- * category: utilities/utils
35
- * ---
36
- * Deep merge N objects into a single result object.
37
- * Merging creates a new object, so that none of the arguments are modified.
38
- *
39
- * @module mergeDeep
40
- *
41
- * @param {Object} args objects to merge
42
- * @returns {Object} a new object with items from all arguments
43
- */
44
- function mergeDeep(...args) {
45
- // note: This could be typed as the union of its args, but since
46
- // its barely used its not worth the effort currently
47
- let target = {};
48
- args.forEach(arg => {
49
- target = mergeSourceIntoTarget(target, arg);
50
- });
51
- return target;
52
- }
53
- function mergeSourceIntoTarget(target, source) {
54
- if (isObject(source)) {
55
- const keys = [...Object.keys(source), ...Object.getOwnPropertySymbols(source)];
56
- const merged = {
57
- ...target
58
- };
59
- keys.forEach(key => {
60
- if (isObject(target[key]) && isObject(source[key])) {
61
- merged[key] = mergeSourceIntoTarget(target[key], source[key]);
62
- } else if (isArray(source[key]) && isArray(target[key])) {
63
- merged[key] = [...new Set([...target[key], ...source[key]])];
64
- } else if (isArray(target[key])) {
65
- merged[key] = [...new Set([...target[key], ...[source[key]]])];
66
- } else {
67
- merged[key] = source[key];
68
- }
69
- });
70
- return merged;
71
- } else {
72
- return {
73
- ...target
74
- };
75
- }
76
- }
77
- function isObject(item) {
78
- return item && (typeof item === 'object' || typeof item === 'function') && !Array.isArray(item);
79
- }
80
- function isArray(item) {
81
- return Array.isArray(item);
82
- }
83
- var _default = exports.default = mergeDeep;
package/lib/ms.js DELETED
@@ -1,67 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- exports.ms = ms;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _parseUnit3 = require("./parseUnit");
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
-
35
- /**
36
- * ---
37
- * category: utilities/utils
38
- * ---
39
- * Converts a unit value time combination (s, ms) to a number representing ms
40
- *
41
- * @module ms
42
- *
43
- * Example inputs:
44
- * - '100s'
45
- * - '20ms'
46
- *
47
- * @param {String|Number} val
48
- * @returns {Number} Returns numerical representation of milliseconds
49
- */
50
- function ms(val) {
51
- // TODO: throw an error if val is not number or string
52
- if (!val || typeof val === 'number') {
53
- return val;
54
- }
55
- const _parseUnit = (0, _parseUnit3.parseUnit)(val),
56
- _parseUnit2 = (0, _slicedToArray2.default)(_parseUnit, 2),
57
- num = _parseUnit2[0],
58
- unit = _parseUnit2[1];
59
- if (unit === 'ms') {
60
- return num;
61
- } else if (unit === 's') {
62
- return num * 1000;
63
- } else {
64
- return num;
65
- }
66
- }
67
- var _default = exports.default = ms;
package/lib/package.json DELETED
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
package/lib/parseUnit.js DELETED
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.parseUnit = parseUnit;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /**
33
- * ---
34
- * category: utilities/utils
35
- * ---
36
- * Converts a CSS unit value combination into an array of type [ value, unit ]
37
- *
38
- * @module parseUnit
39
- *
40
- * Example inputs:
41
- * - '100px'
42
- * - '20rem'
43
- * - '10vh'
44
- * - '400vmin'
45
- *
46
- * @param {string|number} str
47
- * @returns {Array} Returns array of shape [ value, unit ] Unit is '' if it could
48
- * not be parsed
49
- */
50
-
51
- function parseUnit(str) {
52
- const value = `${str}`;
53
- // eslint-disable-next-line no-useless-escape
54
- const match = value.match(/[\d.\-\+]*\s*(.*)/);
55
- return [parseFloat(value), match && match.length > 0 ? match[1] : ''];
56
- }
57
- var _default = exports.default = parseUnit;
package/lib/pascalize.js DELETED
@@ -1,55 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.pascalize = pascalize;
8
- var _capitalizeFirstLetter = require("./capitalizeFirstLetter");
9
- var _camelize = require("./camelize");
10
- /*
11
- * The MIT License (MIT)
12
- *
13
- * Copyright (c) 2015 - present Instructure, Inc.
14
- *
15
- * Permission is hereby granted, free of charge, to any person obtaining a copy
16
- * of this software and associated documentation files (the "Software"), to deal
17
- * in the Software without restriction, including without limitation the rights
18
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
- * copies of the Software, and to permit persons to whom the Software is
20
- * furnished to do so, subject to the following conditions:
21
- *
22
- * The above copyright notice and this permission notice shall be included in all
23
- * copies or substantial portions of the Software.
24
- *
25
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
- * SOFTWARE.
32
- */
33
-
34
- /**
35
- * ---
36
- * category: utilities/utils
37
- * ---
38
- * Converts a hyphenated or camel cased string to pascal case
39
- *
40
- * Example inputs:
41
- * - 'foo-bar'
42
- * - 'baz-qux'
43
- *
44
- * Example outputs:
45
- * - 'FooBar'
46
- * - 'BazQux'
47
- *
48
- * @module pascalize
49
- * @param {String} str
50
- * @returns {String} Returns pascal cased string
51
- */
52
- function pascalize(str) {
53
- return (0, _capitalizeFirstLetter.capitalizeFirstLetter)((0, _camelize.camelize)(str));
54
- }
55
- var _default = exports.default = pascalize;
package/lib/px.js DELETED
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- exports.px = px;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _canUseDOM = require("@instructure/ui-dom-utils/lib/canUseDOM.js");
11
- var _getFontSize = require("@instructure/ui-dom-utils/lib/getFontSize.js");
12
- var _parseUnit3 = require("./parseUnit");
13
- /*
14
- * The MIT License (MIT)
15
- *
16
- * Copyright (c) 2015 - present Instructure, Inc.
17
- *
18
- * Permission is hereby granted, free of charge, to any person obtaining a copy
19
- * of this software and associated documentation files (the "Software"), to deal
20
- * in the Software without restriction, including without limitation the rights
21
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
- * copies of the Software, and to permit persons to whom the Software is
23
- * furnished to do so, subject to the following conditions:
24
- *
25
- * The above copyright notice and this permission notice shall be included in all
26
- * copies or substantial portions of the Software.
27
- *
28
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34
- * SOFTWARE.
35
- */
36
-
37
- /**
38
- * ---
39
- * category: utilities/utils
40
- * ---
41
- * Converts a unit value size combination (em, rem, px) to a number representing px
42
- *
43
- * Example inputs:
44
- * - '100rem'
45
- * - '20em'
46
- * - '40px'
47
- *
48
- * @module px
49
- *
50
- * @param {String|number} val The value to look up. If it's a number its just returned as is.
51
- * @param {Document|Window|Node|React.ReactElement |React.Component|null} el - containing element, for context measure is em (defaults to `document.body`)
52
- * @returns {Number} Returns numerical representation of pixels
53
- */
54
- function px(val, el) {
55
- // TODO !val should not be needed
56
- if (!val || typeof val === 'number') {
57
- return val;
58
- }
59
- const _parseUnit = (0, _parseUnit3.parseUnit)(val),
60
- _parseUnit2 = (0, _slicedToArray2.default)(_parseUnit, 2),
61
- num = _parseUnit2[0],
62
- unit = _parseUnit2[1];
63
- if (unit === 'rem') {
64
- return num * (0, _getFontSize.getFontSize)();
65
- } else if (unit === 'em') {
66
- const doc = _canUseDOM.canUseDOM ? document.body : null;
67
- const container = el || doc;
68
- return num * (0, _getFontSize.getFontSize)(container);
69
- } else {
70
- return num;
71
- }
72
- }
73
- var _default = exports.default = px;
@@ -1,85 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.shallowEqual = shallowEqual;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- // https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/shallowEqual.js
33
- const hasOwnProperty = Object.prototype.hasOwnProperty;
34
-
35
- /**
36
- * ---
37
- * category: utilities/utils
38
- * ---
39
- * Performs equality by iterating through keys on an object and returning false
40
- * when any key has values which are not strictly equal between the arguments.
41
- *
42
- * @module shallowEqual
43
- *
44
- * @param {Object} objA
45
- * @param {Object} objB
46
- * @returns {Boolean} Returns true when the values of all keys are strictly equal
47
- */
48
- function shallowEqual(objA, objB) {
49
- if (is(objA, objB)) {
50
- return true;
51
- }
52
- if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
53
- return false;
54
- }
55
- const keysA = Object.keys(objA);
56
- const keysB = Object.keys(objB);
57
- if (keysA.length !== keysB.length) {
58
- return false;
59
- }
60
-
61
- // Test for A's keys different from B.
62
- for (let i = 0; i < keysA.length; i++) {
63
- if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
64
- return false;
65
- }
66
- }
67
- return true;
68
- }
69
-
70
- /*
71
- * inlined Object.is polyfill to avoid requiring consumers ship their own
72
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
73
- */
74
- function is(x, y) {
75
- // SameValue algorithm
76
- if (x === y) {
77
- // Steps 1-5, 7-10
78
- // Steps 6.b-6.e: +0 != -0
79
- return x !== 0 || y !== 0 || 1 / x === 1 / y;
80
- } else {
81
- // Step 6.a: NaN == NaN
82
- return x !== x && y !== y;
83
- }
84
- }
85
- var _default = exports.default = shallowEqual;
package/lib/within.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.within = within;
8
- /*
9
- * The MIT License (MIT)
10
- *
11
- * Copyright (c) 2015 - present Instructure, Inc.
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
- * copies of the Software, and to permit persons to whom the Software is
18
- * furnished to do so, subject to the following conditions:
19
- *
20
- * The above copyright notice and this permission notice shall be included in all
21
- * copies or substantial portions of the Software.
22
- *
23
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
- * SOFTWARE.
30
- */
31
-
32
- /**
33
- * ---
34
- * category: utilities/utils
35
- * ---
36
- * Determines if one numerical value (a) is within a designated range (diff) of another (b)
37
- *
38
- * @module within
39
- *
40
- * @param {number} a
41
- * @param {number} b
42
- * @param {number} [diff=1]
43
- * @returns {Boolean} Returns true if a is within the diff range of b
44
- */
45
- function within(a, b, diff = 1) {
46
- return a + diff >= b && b >= a - diff;
47
- }
48
- var _default = exports.default = within;