@instructure/ui-utils 11.7.8 → 11.7.9-pr-snapshot-1792147648392
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 +13 -0
- package/es/camelize.js +2 -44
- package/es/capitalizeFirstLetter.js +2 -34
- package/es/cloneArray.js +9 -42
- package/es/combineDataCid.js +4 -34
- package/es/convertCase.js +1 -25
- package/es/createChainedFunction.js +26 -75
- package/es/deepEqual.js +1 -25
- package/es/generateId.js +8 -50
- package/es/getBrowser.js +40 -71
- package/es/hash.js +40 -65
- package/es/index.js +1 -24
- package/es/isBaseTheme.js +22 -42
- package/es/isEmpty.js +6 -29
- package/es/mergeDeep.js +48 -74
- package/es/ms.js +12 -53
- package/es/parseUnit.js +7 -48
- package/es/pascalize.js +2 -44
- package/es/px.js +14 -56
- package/es/safeHref.js +64 -96
- package/es/safeLinkProps.js +9 -50
- package/es/shallowEqual.js +22 -72
- package/es/within.js +2 -39
- package/package.json +8 -11
- package/tsconfig.build.json +0 -3
- package/lib/camelize.js +0 -53
- package/lib/capitalizeFirstLetter.js +0 -43
- package/lib/cloneArray.js +0 -52
- package/lib/combineDataCid.js +0 -41
- package/lib/convertCase.js +0 -19
- package/lib/createChainedFunction.js +0 -86
- package/lib/deepEqual.js +0 -38
- package/lib/generateId.js +0 -58
- package/lib/getBrowser.js +0 -85
- package/lib/hash.js +0 -82
- package/lib/index.js +0 -187
- package/lib/isBaseTheme.js +0 -50
- package/lib/isEmpty.js +0 -39
- package/lib/mergeDeep.js +0 -89
- package/lib/ms.js +0 -62
- package/lib/package.json +0 -1
- package/lib/parseUnit.js +0 -57
- package/lib/pascalize.js +0 -55
- package/lib/px.js +0 -68
- package/lib/safeHref.js +0 -115
- package/lib/safeLinkProps.js +0 -59
- package/lib/shallowEqual.js +0 -85
- package/lib/within.js +0 -48
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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.7.9-pr-snapshot-1792147648392](https://github.com/instructure/instructure-ui/compare/v11.7.8...v11.7.9-pr-snapshot-1792147648392) (2026-10-16)
|
|
7
|
+
|
|
8
|
+
### Build System
|
|
9
|
+
|
|
10
|
+
* **many:** replace babel with swc ([7e36c54](https://github.com/instructure/instructure-ui/commit/7e36c54d240b4fa483801c03ab18e7f860f561e2))
|
|
11
|
+
|
|
12
|
+
### BREAKING CHANGES
|
|
13
|
+
|
|
14
|
+
* **many:** `@instructure/ui-babel-preset` and
|
|
15
|
+
`@instructure/browserslist-config-instui` are removed and will no longer be
|
|
16
|
+
published. Packages depend on `@swc/helpers` instead of `@babel/runtime`.
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [11.7.8](https://github.com/instructure/instructure-ui/compare/v11.7.7...v11.7.8) (2026-10-02)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @instructure/ui-utils
|
package/es/camelize.js
CHANGED
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ---
|
|
27
|
-
* category: utilities/Misc
|
|
28
|
-
* ---
|
|
29
|
-
* Converts a hyphenated string to camel case
|
|
30
|
-
*
|
|
31
|
-
* Example inputs:
|
|
32
|
-
* - 'foo-bar'
|
|
33
|
-
* - 'baz-qux'
|
|
34
|
-
*
|
|
35
|
-
* Example outputs:
|
|
36
|
-
* - 'fooBar'
|
|
37
|
-
* - 'bazQux'
|
|
38
|
-
*
|
|
39
|
-
* @module camelize
|
|
40
|
-
* @param {String} str
|
|
41
|
-
* @returns {String} Returns camel cased string
|
|
42
|
-
*/
|
|
43
1
|
function camelize(str) {
|
|
44
|
-
|
|
2
|
+
return str.replace(/-([a-z])/g, (g)=>g[1].toUpperCase());
|
|
45
3
|
}
|
|
46
4
|
export default camelize;
|
|
47
|
-
export { camelize };
|
|
5
|
+
export { camelize };
|
|
@@ -1,37 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ---
|
|
27
|
-
* category: utilities/Misc
|
|
28
|
-
* ---
|
|
29
|
-
* Capitalize the first letter in a string
|
|
30
|
-
* @module capitalizeFirstLetter
|
|
31
|
-
* @param {String} str
|
|
32
|
-
*/
|
|
33
1
|
function capitalizeFirstLetter(str) {
|
|
34
|
-
|
|
2
|
+
return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
|
|
35
3
|
}
|
|
36
4
|
export default capitalizeFirstLetter;
|
|
37
|
-
export { capitalizeFirstLetter };
|
|
5
|
+
export { capitalizeFirstLetter };
|
package/es/cloneArray.js
CHANGED
|
@@ -1,46 +1,13 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ---
|
|
27
|
-
* category: utilities/Misc
|
|
28
|
-
* ---
|
|
29
|
-
* Deep clones an array with sub arrays
|
|
30
|
-
* @module cloneArray
|
|
31
|
-
* @param {Array} arr
|
|
32
|
-
* @returns {Array} Returns a copy of the array
|
|
33
|
-
*/
|
|
34
1
|
function cloneArray(arr) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
if (Array.isArray(arr)) {
|
|
3
|
+
const copy = arr.slice(0);
|
|
4
|
+
for(let i = 0; i < copy.length; i++){
|
|
5
|
+
copy[i] = cloneArray(copy[i]);
|
|
6
|
+
}
|
|
7
|
+
return copy;
|
|
8
|
+
} else {
|
|
9
|
+
return arr;
|
|
39
10
|
}
|
|
40
|
-
return copy;
|
|
41
|
-
} else {
|
|
42
|
-
return arr;
|
|
43
|
-
}
|
|
44
11
|
}
|
|
45
12
|
export default cloneArray;
|
|
46
|
-
export { cloneArray };
|
|
13
|
+
export { cloneArray };
|
package/es/combineDataCid.js
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Combines a component's default data-cid with a data-cid from props
|
|
27
|
-
* @param dataCid - The default data-cid for the component
|
|
28
|
-
* @param props - The component props object that may contain a data-cid
|
|
29
|
-
* @returns A combined data-cid string, trimmed of extra whitespace
|
|
30
|
-
*/
|
|
31
|
-
const combineDataCid = (dataCid, props) => {
|
|
32
|
-
const dataCidFromProps = props['data-cid'] || '';
|
|
33
|
-
return `${dataCid} ${dataCidFromProps}`.trim();
|
|
1
|
+
const combineDataCid = (dataCid, props)=>{
|
|
2
|
+
const dataCidFromProps = props['data-cid'] || '';
|
|
3
|
+
return `${dataCid} ${dataCidFromProps}`.trim();
|
|
34
4
|
};
|
|
35
|
-
export { combineDataCid };
|
|
5
|
+
export { combineDataCid };
|
package/es/convertCase.js
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
1
|
import { camelize } from './camelize.js';
|
|
26
2
|
import { pascalize } from './pascalize.js';
|
|
27
|
-
export { camelize, pascalize };
|
|
3
|
+
export { camelize, pascalize };
|
|
@@ -1,80 +1,31 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* ---
|
|
27
|
-
* category: utilities/react
|
|
28
|
-
* ---
|
|
29
|
-
* Safe chained functions
|
|
30
|
-
*
|
|
31
|
-
* Will only create a new function if needed,
|
|
32
|
-
* otherwise will pass back existing functions or null.
|
|
33
|
-
*
|
|
34
|
-
* Forked from: https://github.com/react-bootstrap/react-overlays/blob/master/src/utils/createChainedFunction.js
|
|
35
|
-
* @module createChainedFunction
|
|
36
|
-
* @param funcs Functions to chain. It can be null/undefined
|
|
37
|
-
* @returns the functions chained after each other
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
1
|
function createChainedFunction(...funcs) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
// TODO I think it can return null too
|
|
60
|
-
}, null);
|
|
2
|
+
return funcs.filter((f, i)=>{
|
|
3
|
+
if (f == null) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const indexes = getAllIndexes(funcs, f);
|
|
7
|
+
return indexes.length === 1 || i === indexes[0];
|
|
8
|
+
}).reduce((acc, f)=>{
|
|
9
|
+
if (typeof f !== 'function') {
|
|
10
|
+
throw new Error('Invalid Argument Type, must only provide functions, undefined, or null.');
|
|
11
|
+
}
|
|
12
|
+
if (acc === null) {
|
|
13
|
+
return f;
|
|
14
|
+
}
|
|
15
|
+
return function chainedFunction(...args) {
|
|
16
|
+
acc.apply(this, args);
|
|
17
|
+
f.apply(this, args);
|
|
18
|
+
};
|
|
19
|
+
}, null);
|
|
61
20
|
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Find all indexes for a value in an Array
|
|
65
|
-
*
|
|
66
|
-
* @param {array} arr The Array to search for val
|
|
67
|
-
* @param {*} val The value to find indexes for
|
|
68
|
-
* @return {array} All the indexes of the Array matching val
|
|
69
|
-
*/
|
|
70
21
|
function getAllIndexes(arr, val) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
22
|
+
const indexes = [];
|
|
23
|
+
arr.forEach((e, i)=>{
|
|
24
|
+
if (e === val) {
|
|
25
|
+
indexes.push(i);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return indexes;
|
|
78
29
|
}
|
|
79
30
|
export default createChainedFunction;
|
|
80
|
-
export { createChainedFunction };
|
|
31
|
+
export { createChainedFunction };
|
package/es/deepEqual.js
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
1
|
import deepEqual from 'fast-deep-equal';
|
|
26
2
|
export default deepEqual;
|
|
27
|
-
export { deepEqual };
|
|
3
|
+
export { deepEqual };
|
package/es/generateId.js
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Generates unique css safe ids for elements.
|
|
27
|
-
*
|
|
28
|
-
* @deprecated Use `useDeterministicId` (function components) or the
|
|
29
|
-
* `withDeterministicId` decorator (class components) from
|
|
30
|
-
* `@instructure/ui-react-utils` instead. Both are backed by React's `useId`, so
|
|
31
|
-
* they produce the same id on the server and the client. This counter-based
|
|
32
|
-
* helper depends on render order: the count advances once per render pass, so a
|
|
33
|
-
* server render and the subsequent client render disagree, and the id changes on
|
|
34
|
-
* every re-render. It is no longer used anywhere in InstUI and will be removed
|
|
35
|
-
* in the next major version.
|
|
36
|
-
*
|
|
37
|
-
* @param instanceName - the name of the element/instance to keep track of
|
|
38
|
-
* @param map - a Map<string, counter>, which counts how many times the given element/instance was rendered
|
|
39
|
-
* @returns a string in a format `instanceName_intanceRenderedCount`: `Alert_4`
|
|
40
|
-
*/
|
|
41
|
-
const generateId = (instanceName, map) => {
|
|
42
|
-
if (!map.has(instanceName)) {
|
|
43
|
-
map.set(instanceName, 0);
|
|
44
|
-
} else {
|
|
45
|
-
map.set(instanceName, map.get(instanceName) + 1);
|
|
46
|
-
}
|
|
47
|
-
// Do not rename '___' to '_' it will cause name clash with InstUI v10.14.0
|
|
48
|
-
// or older
|
|
49
|
-
return `${instanceName}___${map.get(instanceName)}`;
|
|
1
|
+
const generateId = (instanceName, map)=>{
|
|
2
|
+
if (!map.has(instanceName)) {
|
|
3
|
+
map.set(instanceName, 0);
|
|
4
|
+
} else {
|
|
5
|
+
map.set(instanceName, map.get(instanceName) + 1);
|
|
6
|
+
}
|
|
7
|
+
return `${instanceName}___${map.get(instanceName)}`;
|
|
50
8
|
};
|
|
51
9
|
export default generateId;
|
|
52
|
-
export { generateId };
|
|
10
|
+
export { generateId };
|
package/es/getBrowser.js
CHANGED
|
@@ -1,72 +1,41 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
1
|
import UAParser from 'ua-parser-js';
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
};
|
|
67
|
-
const isMac = () => {
|
|
68
|
-
const parser = new UAParser();
|
|
69
|
-
const result = parser.getResult();
|
|
70
|
-
return result.os.name === 'Mac OS';
|
|
71
|
-
};
|
|
72
|
-
export { getBrowser, isSafari, isEdge, isIE, isFirefox, isChromium, isAndroidOrIOS, isMac };
|
|
2
|
+
const getBrowser = ()=>{
|
|
3
|
+
const parser = new UAParser();
|
|
4
|
+
const { browser } = parser.getResult();
|
|
5
|
+
return browser;
|
|
6
|
+
};
|
|
7
|
+
const isSafari = ()=>{
|
|
8
|
+
return getBrowser().name === 'Safari';
|
|
9
|
+
};
|
|
10
|
+
const isEdge = ()=>{
|
|
11
|
+
return getBrowser().name === 'Edge';
|
|
12
|
+
};
|
|
13
|
+
const isIE = ()=>{
|
|
14
|
+
return getBrowser().name === 'IE';
|
|
15
|
+
};
|
|
16
|
+
const isChromium = ()=>{
|
|
17
|
+
const chromiumBasedBrowsers = [
|
|
18
|
+
'Chrome',
|
|
19
|
+
'Chromium',
|
|
20
|
+
'Opera',
|
|
21
|
+
'Edge'
|
|
22
|
+
];
|
|
23
|
+
return chromiumBasedBrowsers.some((browser)=>{
|
|
24
|
+
return getBrowser().name?.includes(browser);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
const isFirefox = ()=>{
|
|
28
|
+
return getBrowser().name === 'Firefox';
|
|
29
|
+
};
|
|
30
|
+
const isAndroidOrIOS = ()=>{
|
|
31
|
+
const parser = new UAParser();
|
|
32
|
+
const result = parser.getResult();
|
|
33
|
+
const device = parser.getDevice();
|
|
34
|
+
return result.os.name === 'Android' || device.model === 'iPhone' || device.model === 'iPad' ? true : false;
|
|
35
|
+
};
|
|
36
|
+
const isMac = ()=>{
|
|
37
|
+
const parser = new UAParser();
|
|
38
|
+
const result = parser.getResult();
|
|
39
|
+
return result.os.name === 'Mac OS';
|
|
40
|
+
};
|
|
41
|
+
export { getBrowser, isSafari, isEdge, isIE, isFirefox, isChromium, isAndroidOrIOS, isMac };
|
package/es/hash.js
CHANGED
|
@@ -1,75 +1,50 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
1
|
import stringify from 'json-stable-stringify';
|
|
26
2
|
function toBase64(input) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
3
|
+
const tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
4
|
+
let output = '';
|
|
5
|
+
const length = input.length;
|
|
6
|
+
let triplet;
|
|
7
|
+
const b64pad = '=';
|
|
8
|
+
for(let i = 0; i < length; i += 3){
|
|
9
|
+
triplet = input.charCodeAt(i) << 16 | (i + 1 < length ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < length ? input.charCodeAt(i + 2) : 0);
|
|
10
|
+
for(let j = 0; j < 4; j += 1){
|
|
11
|
+
if (i * 8 + j * 6 > input.length * 8) {
|
|
12
|
+
output += b64pad;
|
|
13
|
+
} else {
|
|
14
|
+
output += tab.charAt(triplet >>> 6 * (3 - j) & 0x3f);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
40
17
|
}
|
|
41
|
-
|
|
42
|
-
return output;
|
|
18
|
+
return output;
|
|
43
19
|
}
|
|
44
20
|
function executeHash(input) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
21
|
+
let hash = 0;
|
|
22
|
+
if (input.length === 0) return '0';
|
|
23
|
+
for(let i = 0; i < input.length; i++){
|
|
24
|
+
const c = input.charCodeAt(i);
|
|
25
|
+
hash = (hash << 5) - hash + c;
|
|
26
|
+
hash |= 0;
|
|
27
|
+
}
|
|
28
|
+
return toBase64(String(hash));
|
|
53
29
|
}
|
|
54
30
|
function hash(value, maxLength = 0) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
31
|
+
if (typeof value === 'undefined') {
|
|
32
|
+
throw new Error('Cannot hash a value which is undefined');
|
|
33
|
+
}
|
|
34
|
+
let hashedValue = '';
|
|
35
|
+
let valueToHash = value;
|
|
36
|
+
if (typeof value !== 'string') {
|
|
37
|
+
if (typeof value === 'object') {
|
|
38
|
+
valueToHash = stringify(value);
|
|
39
|
+
} else {
|
|
40
|
+
valueToHash = value.toString();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
hashedValue = executeHash(valueToHash);
|
|
44
|
+
if (maxLength) {
|
|
45
|
+
hashedValue = hashedValue.slice(0, maxLength);
|
|
66
46
|
}
|
|
67
|
-
|
|
68
|
-
hashedValue = executeHash(valueToHash);
|
|
69
|
-
if (maxLength) {
|
|
70
|
-
hashedValue = hashedValue.slice(0, maxLength);
|
|
71
|
-
}
|
|
72
|
-
return hashedValue;
|
|
47
|
+
return hashedValue;
|
|
73
48
|
}
|
|
74
49
|
export default hash;
|
|
75
|
-
export { hash };
|
|
50
|
+
export { hash };
|