@instructure/ui-utils 11.7.3 → 11.7.4-pr-snapshot-1781695314229

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE.md +1 -0
  3. package/{lib/isEmpty.js → babel.config.cjs} +12 -15
  4. package/es/camelize.js +1 -1
  5. package/es/capitalizeFirstLetter.js +1 -1
  6. package/es/cloneArray.js +1 -1
  7. package/es/convertCase.js +3 -2
  8. package/es/getBrowser.js +1 -2
  9. package/es/index.js +18 -18
  10. package/es/mergeDeep.js +1 -1
  11. package/es/ms.js +4 -2
  12. package/es/parseUnit.js +1 -1
  13. package/es/pascalize.js +4 -3
  14. package/es/px.js +2 -2
  15. package/es/shallowEqual.js +1 -1
  16. package/es/within.js +1 -1
  17. package/package.json +7 -9
  18. package/src/camelize.ts +1 -1
  19. package/src/capitalizeFirstLetter.ts +1 -1
  20. package/src/cloneArray.ts +1 -1
  21. package/src/convertCase.ts +2 -2
  22. package/src/getBrowser.ts +1 -1
  23. package/src/index.ts +18 -18
  24. package/src/mergeDeep.ts +1 -1
  25. package/src/ms.ts +2 -2
  26. package/src/parseUnit.ts +1 -1
  27. package/src/pascalize.ts +3 -3
  28. package/src/px.ts +2 -2
  29. package/src/shallowEqual.ts +1 -1
  30. package/src/within.ts +1 -1
  31. package/tsconfig.build.tsbuildinfo +1 -1
  32. package/types/camelize.d.ts +1 -1
  33. package/types/capitalizeFirstLetter.d.ts +1 -1
  34. package/types/cloneArray.d.ts +1 -1
  35. package/types/convertCase.d.ts +2 -2
  36. package/types/convertCase.d.ts.map +1 -1
  37. package/types/getBrowser.d.ts +1 -1
  38. package/types/index.d.ts +18 -18
  39. package/types/index.d.ts.map +1 -1
  40. package/types/mergeDeep.d.ts +1 -1
  41. package/types/ms.d.ts +1 -1
  42. package/types/parseUnit.d.ts +1 -1
  43. package/types/pascalize.d.ts +1 -1
  44. package/types/px.d.ts +1 -1
  45. package/types/shallowEqual.d.ts +1 -1
  46. package/types/within.d.ts +1 -1
  47. package/lib/camelize.js +0 -53
  48. package/lib/capitalizeFirstLetter.js +0 -43
  49. package/lib/cloneArray.js +0 -52
  50. package/lib/combineDataCid.js +0 -41
  51. package/lib/convertCase.js +0 -19
  52. package/lib/createChainedFunction.js +0 -86
  53. package/lib/deepEqual.js +0 -38
  54. package/lib/generateId.js +0 -48
  55. package/lib/getBrowser.js +0 -87
  56. package/lib/hash.js +0 -82
  57. package/lib/index.js +0 -173
  58. package/lib/isBaseTheme.js +0 -50
  59. package/lib/mergeDeep.js +0 -83
  60. package/lib/ms.js +0 -62
  61. package/lib/package.json +0 -1
  62. package/lib/parseUnit.js +0 -57
  63. package/lib/pascalize.js +0 -55
  64. package/lib/px.js +0 -68
  65. package/lib/shallowEqual.js +0 -85
  66. package/lib/within.js +0 -48
@@ -1,4 +1,4 @@
1
- import { camelize } from './camelize';
2
- import { pascalize } from './pascalize';
1
+ import { camelize } from './camelize.js';
2
+ import { pascalize } from './pascalize.js';
3
3
  export { camelize, pascalize };
4
4
  //# sourceMappingURL=convertCase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertCase.d.ts","sourceRoot":"","sources":["../src/convertCase.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"convertCase.d.ts","sourceRoot":"","sources":["../src/convertCase.ts"],"names":[],"mappings":"AAwBA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA"}
@@ -1,7 +1,7 @@
1
1
  import UAParser from 'ua-parser-js';
2
2
  /**
3
3
  * ---
4
- * category: utilities/utils
4
+ * category: utilities/Misc
5
5
  * ---
6
6
  * A utility module using the [ua-parser-js](https://www.npmjs.com/package/ua-parser-js) browser
7
7
  * detection library.
package/types/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- export { capitalizeFirstLetter } from './capitalizeFirstLetter';
2
- export { cloneArray } from './cloneArray';
3
- export { createChainedFunction } from './createChainedFunction';
4
- export { deepEqual } from './deepEqual';
5
- export { hash } from './hash';
6
- export { generateId } from './generateId';
7
- export { isEmpty } from './isEmpty';
8
- export { mergeDeep } from './mergeDeep';
9
- export { ms } from './ms';
10
- export { parseUnit } from './parseUnit';
11
- export { px } from './px';
12
- export { shallowEqual } from './shallowEqual';
13
- export { within } from './within';
14
- export { camelize } from './camelize';
15
- export { pascalize } from './pascalize';
16
- export { isBaseTheme } from './isBaseTheme';
17
- export { getBrowser, isSafari, isEdge, isIE, isFirefox, isChromium, isAndroidOrIOS, isMac } from './getBrowser';
18
- export { combineDataCid } from './combineDataCid';
1
+ export { capitalizeFirstLetter } from './capitalizeFirstLetter.js';
2
+ export { cloneArray } from './cloneArray.js';
3
+ export { createChainedFunction } from './createChainedFunction.js';
4
+ export { deepEqual } from './deepEqual.js';
5
+ export { hash } from './hash.js';
6
+ export { generateId } from './generateId.js';
7
+ export { isEmpty } from './isEmpty.js';
8
+ export { mergeDeep } from './mergeDeep.js';
9
+ export { ms } from './ms.js';
10
+ export { parseUnit } from './parseUnit.js';
11
+ export { px } from './px.js';
12
+ export { shallowEqual } from './shallowEqual.js';
13
+ export { within } from './within.js';
14
+ export { camelize } from './camelize.js';
15
+ export { pascalize } from './pascalize.js';
16
+ export { isBaseTheme } from './isBaseTheme.js';
17
+ export { getBrowser, isSafari, isEdge, isIE, isFirefox, isChromium, isAndroidOrIOS, isMac } from './getBrowser.js';
18
+ export { combineDataCid } from './combineDataCid.js';
19
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,EACT,UAAU,EACV,cAAc,EACd,KAAK,EACN,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EACL,UAAU,EACV,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,SAAS,EACT,UAAU,EACV,cAAc,EACd,KAAK,EACN,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ---
3
- * category: utilities/utils
3
+ * category: utilities/Misc
4
4
  * ---
5
5
  * Deep merge N objects into a single result object.
6
6
  * Merging creates a new object, so that none of the arguments are modified.
package/types/ms.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ---
3
- * category: utilities/utils
3
+ * category: utilities/Misc
4
4
  * ---
5
5
  * Converts a unit value time combination (s, ms) to a number representing ms
6
6
  *
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ---
3
- * category: utilities/utils
3
+ * category: utilities/Misc
4
4
  * ---
5
5
  * Converts a CSS unit value combination into an array of type [ value, unit ]
6
6
  *
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ---
3
- * category: utilities/utils
3
+ * category: utilities/Misc
4
4
  * ---
5
5
  * Converts a hyphenated or camel cased string to pascal case
6
6
  *
package/types/px.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  /**
3
3
  * ---
4
- * category: utilities/utils
4
+ * category: utilities/Misc
5
5
  * ---
6
6
  * Converts a unit value size combination (em, rem, px) to a number representing px
7
7
  *
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ---
3
- * category: utilities/utils
3
+ * category: utilities/Misc
4
4
  * ---
5
5
  * Performs equality by iterating through keys on an object and returning false
6
6
  * when any key has values which are not strictly equal between the arguments.
package/types/within.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * ---
3
- * category: utilities/utils
3
+ * category: utilities/Misc
4
4
  * ---
5
5
  * Determines if one numerical value (a) is within a designated range (diff) of another (b)
6
6
  *
package/lib/camelize.js DELETED
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.camelize = camelize;
7
- exports.default = void 0;
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 hyphenated string to camel case
37
- *
38
- * Example inputs:
39
- * - 'foo-bar'
40
- * - 'baz-qux'
41
- *
42
- * Example outputs:
43
- * - 'fooBar'
44
- * - 'bazQux'
45
- *
46
- * @module camelize
47
- * @param {String} str
48
- * @returns {String} Returns camel cased string
49
- */
50
- function camelize(str) {
51
- return str.replace(/-([a-z])/g, g => g[1].toUpperCase());
52
- }
53
- var _default = exports.default = camelize;
@@ -1,43 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.capitalizeFirstLetter = capitalizeFirstLetter;
7
- exports.default = void 0;
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
- * Capitalize the first letter in a string
37
- * @module capitalizeFirstLetter
38
- * @param {String} str
39
- */
40
- function capitalizeFirstLetter(str) {
41
- return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
42
- }
43
- var _default = exports.default = capitalizeFirstLetter;
package/lib/cloneArray.js DELETED
@@ -1,52 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.cloneArray = cloneArray;
7
- exports.default = void 0;
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 clones an array with sub arrays
37
- * @module cloneArray
38
- * @param {Array} arr
39
- * @returns {Array} Returns a copy of the array
40
- */
41
- function cloneArray(arr) {
42
- if (Array.isArray(arr)) {
43
- const copy = arr.slice(0);
44
- for (let i = 0; i < copy.length; i++) {
45
- copy[i] = cloneArray(copy[i]);
46
- }
47
- return copy;
48
- } else {
49
- return arr;
50
- }
51
- }
52
- var _default = exports.default = cloneArray;
@@ -1,41 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.combineDataCid = 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
- /**
32
- * Combines a component's default data-cid with a data-cid from props
33
- * @param dataCid - The default data-cid for the component
34
- * @param props - The component props object that may contain a data-cid
35
- * @returns A combined data-cid string, trimmed of extra whitespace
36
- */
37
- const combineDataCid = (dataCid, props) => {
38
- const dataCidFromProps = props['data-cid'] || '';
39
- return `${dataCid} ${dataCidFromProps}`.trim();
40
- };
41
- exports.combineDataCid = combineDataCid;
@@ -1,19 +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, "pascalize", {
13
- enumerable: true,
14
- get: function () {
15
- return _pascalize.pascalize;
16
- }
17
- });
18
- var _camelize = require("./camelize");
19
- var _pascalize = require("./pascalize");
@@ -1,86 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createChainedFunction = createChainedFunction;
7
- exports.default = void 0;
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/react
35
- * ---
36
- * Safe chained functions
37
- *
38
- * Will only create a new function if needed,
39
- * otherwise will pass back existing functions or null.
40
- *
41
- * Forked from: https://github.com/react-bootstrap/react-overlays/blob/master/src/utils/createChainedFunction.js
42
- * @module createChainedFunction
43
- * @param funcs Functions to chain. It can be null/undefined
44
- * @returns the functions chained after each other
45
- */
46
-
47
- function createChainedFunction(...funcs) {
48
- return funcs.filter((f, i) => {
49
- if (f == null) {
50
- return false;
51
- }
52
- // Only allow the first of identical functions
53
- const indexes = getAllIndexes(funcs, f);
54
- return indexes.length === 1 || i === indexes[0];
55
- }).reduce((acc, f) => {
56
- if (typeof f !== 'function') {
57
- throw new Error('Invalid Argument Type, must only provide functions, undefined, or null.');
58
- }
59
- if (acc === null) {
60
- return f;
61
- }
62
- return function chainedFunction(...args) {
63
- acc.apply(this, args);
64
- f.apply(this, args);
65
- };
66
- // TODO I think it can return null too
67
- }, null);
68
- }
69
-
70
- /**
71
- * Find all indexes for a value in an Array
72
- *
73
- * @param {array} arr The Array to search for val
74
- * @param {*} val The value to find indexes for
75
- * @return {array} All the indexes of the Array matching val
76
- */
77
- function getAllIndexes(arr, val) {
78
- const indexes = [];
79
- arr.forEach((e, i) => {
80
- if (e === val) {
81
- indexes.push(i);
82
- }
83
- });
84
- return indexes;
85
- }
86
- var _default = exports.default = createChainedFunction;
package/lib/deepEqual.js DELETED
@@ -1,38 +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
- Object.defineProperty(exports, "deepEqual", {
8
- enumerable: true,
9
- get: function () {
10
- return _fastDeepEqual.default;
11
- }
12
- });
13
- exports.default = void 0;
14
- var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
15
- /*
16
- * The MIT License (MIT)
17
- *
18
- * Copyright (c) 2015 - present Instructure, Inc.
19
- *
20
- * Permission is hereby granted, free of charge, to any person obtaining a copy
21
- * of this software and associated documentation files (the "Software"), to deal
22
- * in the Software without restriction, including without limitation the rights
23
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24
- * copies of the Software, and to permit persons to whom the Software is
25
- * furnished to do so, subject to the following conditions:
26
- *
27
- * The above copyright notice and this permission notice shall be included in all
28
- * copies or substantial portions of the Software.
29
- *
30
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36
- * SOFTWARE.
37
- */
38
- var _default = exports.default = _fastDeepEqual.default;
package/lib/generateId.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateId = 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
- /**
32
- * Generates unique css safe ids for elements.
33
- * @param instanceName - the name of the element/instance to keep track of
34
- * @param map - a Map<string, counter>, which counts how many times the given element/instance was rendered
35
- * @returns a string in a format `instanceName_intanceRenderedCount`: `Alert_4`
36
- */
37
- const generateId = (instanceName, map) => {
38
- if (!map.has(instanceName)) {
39
- map.set(instanceName, 0);
40
- } else {
41
- map.set(instanceName, map.get(instanceName) + 1);
42
- }
43
- // Do not rename '___' to '_' it will cause name clash with InstUI v10.14.0
44
- // or older
45
- return `${instanceName}___${map.get(instanceName)}`;
46
- };
47
- exports.generateId = generateId;
48
- var _default = exports.default = generateId;
package/lib/getBrowser.js DELETED
@@ -1,87 +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.isSafari = exports.isMac = exports.isIE = exports.isFirefox = exports.isEdge = exports.isChromium = exports.isAndroidOrIOS = exports.getBrowser = void 0;
8
- require("core-js/modules/es.array.includes.js");
9
- var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
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
- * A utility module using the [ua-parser-js](https://www.npmjs.com/package/ua-parser-js) browser
39
- * detection library.
40
- *
41
- * @module getBrowser
42
- */
43
-
44
- const getBrowser = () => {
45
- const parser = new _uaParserJs.default();
46
- const {
47
- browser
48
- } = parser.getResult();
49
- return browser;
50
- };
51
- exports.getBrowser = getBrowser;
52
- const isSafari = () => {
53
- return getBrowser().name === 'Safari';
54
- };
55
- exports.isSafari = isSafari;
56
- const isEdge = () => {
57
- return getBrowser().name === 'Edge';
58
- };
59
- exports.isEdge = isEdge;
60
- const isIE = () => {
61
- return getBrowser().name === 'IE';
62
- };
63
- exports.isIE = isIE;
64
- const isChromium = () => {
65
- const chromiumBasedBrowsers = ['Chrome', 'Chromium', 'Opera', 'Edge'];
66
- return chromiumBasedBrowsers.some(browser => {
67
- return getBrowser().name?.includes(browser);
68
- });
69
- };
70
- exports.isChromium = isChromium;
71
- const isFirefox = () => {
72
- return getBrowser().name === 'Firefox';
73
- };
74
- exports.isFirefox = isFirefox;
75
- const isAndroidOrIOS = () => {
76
- const parser = new _uaParserJs.default();
77
- const result = parser.getResult();
78
- const device = parser.getDevice();
79
- return result.os.name === 'Android' || device.model === 'iPhone' || device.model === 'iPad' ? true : false;
80
- };
81
- exports.isAndroidOrIOS = isAndroidOrIOS;
82
- const isMac = () => {
83
- const parser = new _uaParserJs.default();
84
- const result = parser.getResult();
85
- return result.os.name === 'Mac OS';
86
- };
87
- exports.isMac = isMac;