@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/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
+ ## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
7
+
8
+ **Note:** Version bump only for package @instructure/ui-utils
9
+
10
+
11
+
12
+
13
+
6
14
  # [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
7
15
 
8
16
  **Note:** Version bump only for package @instructure/ui-utils
@@ -1,10 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- exports.isEmpty = isEmpty;
8
1
  /*
9
2
  * The MIT License (MIT)
10
3
  *
@@ -28,12 +21,17 @@ exports.isEmpty = isEmpty;
28
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
22
  * SOFTWARE.
30
23
  */
31
- const hasOwnProperty = Object.prototype.hasOwnProperty;
32
- function isEmpty(obj) {
33
- if (typeof obj !== 'object') return true;
34
- for (const key in obj) {
35
- if (hasOwnProperty.call(obj, key)) return false;
36
- }
37
- return true;
24
+
25
+ module.exports = {
26
+ presets: [
27
+ [
28
+ require('@instructure/ui-babel-preset'),
29
+ {
30
+ coverage: Boolean(process.env.COVERAGE),
31
+ esModules: Boolean(process.env.ES_MODULES),
32
+ removeConsole: process.env.NODE_ENV === 'production',
33
+ transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
34
+ }
35
+ ]
36
+ ]
38
37
  }
39
- var _default = exports.default = isEmpty;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-utils",
3
- "version": "11.6.0",
3
+ "version": "11.6.1-pr-snapshot-1779894247159",
4
+ "type": "module",
4
5
  "description": "A collection of utilities for UI components",
5
6
  "author": "Instructure, Inc. Engineering and Product Design",
6
7
  "module": "./es/index.js",
7
- "main": "./lib/index.js",
8
8
  "types": "./types/index.d.ts",
9
9
  "repository": {
10
10
  "type": "git",
@@ -19,16 +19,16 @@
19
19
  "fast-deep-equal": "^3.1.3",
20
20
  "json-stable-stringify": "^1.3.0",
21
21
  "ua-parser-js": "^1.0.39",
22
- "@instructure/console": "11.6.0",
23
- "@instructure/shared-types": "11.6.0",
24
- "@instructure/ui-dom-utils": "11.6.0"
22
+ "@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
23
+ "@instructure/console": "11.6.1-pr-snapshot-1779894247159",
24
+ "@instructure/ui-dom-utils": "11.6.1-pr-snapshot-1779894247159"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@testing-library/jest-dom": "^6.6.3",
28
28
  "@testing-library/react": "15.0.7",
29
29
  "@types/json-stable-stringify": "^1.2.0",
30
30
  "vitest": "^3.2.2",
31
- "@instructure/ui-babel-preset": "11.6.0"
31
+ "@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "react": ">=18 <=19",
@@ -42,10 +42,8 @@
42
42
  ".": {
43
43
  "types": "./types/index.d.ts",
44
44
  "import": "./es/index.js",
45
- "require": "./lib/index.js",
46
45
  "default": "./es/index.js"
47
46
  },
48
- "./lib/*": "./lib/*",
49
47
  "./es/*": "./es/*",
50
48
  "./types/*": "./types/*",
51
49
  "./package.json": "./package.json",
@@ -55,7 +53,7 @@
55
53
  "lint": "ui-scripts lint",
56
54
  "lint:fix": "ui-scripts lint --fix",
57
55
  "clean": "ui-scripts clean",
58
- "build": "ui-scripts build --modules es,cjs",
56
+ "build": "ui-scripts build",
59
57
  "build:watch": "ui-scripts build --watch",
60
58
  "build:types": "tsc -p tsconfig.build.json"
61
59
  }
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,86 +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
- var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
9
- /*
10
- * The MIT License (MIT)
11
- *
12
- * Copyright (c) 2015 - present Instructure, Inc.
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in all
22
- * copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
- * SOFTWARE.
31
- */
32
-
33
- /**
34
- * ---
35
- * category: utilities/utils
36
- * ---
37
- * A utility module using the [ua-parser-js](https://www.npmjs.com/package/ua-parser-js) browser
38
- * detection library.
39
- *
40
- * @module getBrowser
41
- */
42
-
43
- const getBrowser = () => {
44
- const parser = new _uaParserJs.default();
45
- const _parser$getResult = parser.getResult(),
46
- browser = _parser$getResult.browser;
47
- return browser;
48
- };
49
- exports.getBrowser = getBrowser;
50
- const isSafari = () => {
51
- return getBrowser().name === 'Safari';
52
- };
53
- exports.isSafari = isSafari;
54
- const isEdge = () => {
55
- return getBrowser().name === 'Edge';
56
- };
57
- exports.isEdge = isEdge;
58
- const isIE = () => {
59
- return getBrowser().name === 'IE';
60
- };
61
- exports.isIE = isIE;
62
- const isChromium = () => {
63
- const chromiumBasedBrowsers = ['Chrome', 'Chromium', 'Opera', 'Edge'];
64
- return chromiumBasedBrowsers.some(browser => {
65
- var _getBrowser$name;
66
- return (_getBrowser$name = getBrowser().name) === null || _getBrowser$name === void 0 ? void 0 : _getBrowser$name.includes(browser);
67
- });
68
- };
69
- exports.isChromium = isChromium;
70
- const isFirefox = () => {
71
- return getBrowser().name === 'Firefox';
72
- };
73
- exports.isFirefox = isFirefox;
74
- const isAndroidOrIOS = () => {
75
- const parser = new _uaParserJs.default();
76
- const result = parser.getResult();
77
- const device = parser.getDevice();
78
- return result.os.name === 'Android' || device.model === 'iPhone' || device.model === 'iPad' ? true : false;
79
- };
80
- exports.isAndroidOrIOS = isAndroidOrIOS;
81
- const isMac = () => {
82
- const parser = new _uaParserJs.default();
83
- const result = parser.getResult();
84
- return result.os.name === 'Mac OS';
85
- };
86
- exports.isMac = isMac;
package/lib/hash.js DELETED
@@ -1,82 +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.hash = hash;
9
- var _jsonStableStringify = _interopRequireDefault(require("json-stable-stringify"));
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
- function toBase64(input) {
35
- const tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
36
- let output = '';
37
- const length = input.length;
38
- let triplet;
39
- const b64pad = '=';
40
- for (let i = 0; i < length; i += 3) {
41
- triplet = input.charCodeAt(i) << 16 | (i + 1 < length ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < length ? input.charCodeAt(i + 2) : 0);
42
- for (let j = 0; j < 4; j += 1) {
43
- if (i * 8 + j * 6 > input.length * 8) {
44
- output += b64pad;
45
- } else {
46
- output += tab.charAt(triplet >>> 6 * (3 - j) & 0x3f);
47
- }
48
- }
49
- }
50
- return output;
51
- }
52
- function executeHash(input) {
53
- let hash = 0;
54
- if (input.length === 0) return '0';
55
- for (let i = 0; i < input.length; i++) {
56
- const c = input.charCodeAt(i);
57
- hash = (hash << 5) - hash + c;
58
- hash |= 0; // Convert to 32bit integer
59
- }
60
- return toBase64(String(hash));
61
- }
62
- function hash(value, maxLength = 0) {
63
- if (typeof value === 'undefined') {
64
- throw new Error('Cannot hash a value which is undefined');
65
- }
66
- let hashedValue = '';
67
- let valueToHash = value;
68
- if (typeof value !== 'string') {
69
- if (typeof value === 'object') {
70
- // Ensure we are robust to things like objects that are identical, but with keys in diff orders
71
- valueToHash = (0, _jsonStableStringify.default)(value);
72
- } else {
73
- valueToHash = value.toString();
74
- }
75
- }
76
- hashedValue = executeHash(valueToHash);
77
- if (maxLength) {
78
- hashedValue = hashedValue.slice(0, maxLength);
79
- }
80
- return hashedValue;
81
- }
82
- var _default = exports.default = hash;