@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/es/safeHref.js
CHANGED
|
@@ -1,109 +1,77 @@
|
|
|
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 createDOMPurify from 'dompurify';
|
|
26
|
-
|
|
27
|
-
// Use a dedicated DOMPurify instance instead of the shared singleton so our
|
|
28
|
-
// HTML profile never leaks onto the global instance other code relies on, and
|
|
29
|
-
// our validation stays correct even if someone else mutates the singleton via
|
|
30
|
-
// setConfig(). `window` is guarded for SSR; passing `undefined` yields an
|
|
31
|
-
// unsupported instance, in which case we fall back to `ssrSafeHref`.
|
|
32
2
|
const purify = createDOMPurify(typeof window === 'undefined' ? undefined : window);
|
|
33
3
|
if (purify.isSupported) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
4
|
+
purify.setConfig({
|
|
5
|
+
USE_PROFILES: {
|
|
6
|
+
html: true
|
|
7
|
+
}
|
|
8
|
+
});
|
|
39
9
|
}
|
|
40
|
-
const SAFE_SCHEMES = [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
10
|
+
const SAFE_SCHEMES = [
|
|
11
|
+
'http:',
|
|
12
|
+
'https:',
|
|
13
|
+
'ftp:',
|
|
14
|
+
'ftps:',
|
|
15
|
+
'mailto:',
|
|
16
|
+
'tel:',
|
|
17
|
+
'sms:',
|
|
18
|
+
'callto:',
|
|
19
|
+
'cid:',
|
|
20
|
+
'xmpp:',
|
|
21
|
+
'matrix:',
|
|
22
|
+
'webcal:',
|
|
23
|
+
'feed:',
|
|
24
|
+
'geo:'
|
|
25
|
+
];
|
|
46
26
|
function normalizeValue(value) {
|
|
47
|
-
|
|
48
|
-
return value.replace(/[\u0000-\u001F\u007F]/g, '').trim();
|
|
27
|
+
return value.replace(/[\u0000-\u001F\u007F]/g, '').trim();
|
|
49
28
|
}
|
|
50
|
-
|
|
51
|
-
// Extract the scheme from a URL-ish value, or `null` if it has none.
|
|
52
29
|
function extractScheme(value) {
|
|
53
|
-
|
|
54
|
-
|
|
30
|
+
const schemeMatch = normalizeValue(value).match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);
|
|
31
|
+
return schemeMatch ? schemeMatch[1].toLowerCase() + ':' : null;
|
|
55
32
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
33
|
+
const DATA_URI_TAGS = [
|
|
34
|
+
[
|
|
35
|
+
'img',
|
|
36
|
+
'src'
|
|
37
|
+
],
|
|
38
|
+
[
|
|
39
|
+
'source',
|
|
40
|
+
'src'
|
|
41
|
+
],
|
|
42
|
+
[
|
|
43
|
+
'source',
|
|
44
|
+
'srcset'
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
'video',
|
|
48
|
+
'poster'
|
|
49
|
+
]
|
|
50
|
+
];
|
|
65
51
|
function ssrSafeHref(value, tag, attr) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
52
|
+
const normalized = normalizeValue(value);
|
|
53
|
+
if (normalized === '') return true;
|
|
54
|
+
const firstChar = normalized.charAt(0);
|
|
55
|
+
if (firstChar === '#' || firstChar === '/' || firstChar === '?') return true;
|
|
56
|
+
const scheme = extractScheme(normalized);
|
|
57
|
+
if (!scheme) return true;
|
|
58
|
+
if (SAFE_SCHEMES.includes(scheme)) return true;
|
|
59
|
+
if (scheme === 'data:' && DATA_URI_TAGS.some(([t, a])=>t === tag && a === attr)) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
77
63
|
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* ---
|
|
81
|
-
* category: utilities/utils
|
|
82
|
-
* ---
|
|
83
|
-
* Validates an attribute value and returns it only when the value is safe to
|
|
84
|
-
* render. Delegates to `DOMPurify.isValidAttribute` in the browser; falls back
|
|
85
|
-
* to a minimal scheme allow-list under SSR.
|
|
86
|
-
*
|
|
87
|
-
* @module safeHref
|
|
88
|
-
*
|
|
89
|
-
* @param href The value to validate
|
|
90
|
-
* @param tag Element name the value will be applied to (e.g. `'a'`, `'img'`)
|
|
91
|
-
* @param attr Attribute name (e.g. `'href'`, `'src'`)
|
|
92
|
-
* @returns The original value if safe, `undefined` if blocked
|
|
93
|
-
*/
|
|
94
64
|
function safeHref(href, tag, attr) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
return href;
|
|
65
|
+
if (href == null || typeof href === 'undefined') return undefined;
|
|
66
|
+
const value = String(href);
|
|
67
|
+
const scheme = extractScheme(value);
|
|
68
|
+
if (scheme && SAFE_SCHEMES.includes(scheme)) return href;
|
|
69
|
+
const isSafe = purify.isSupported ? purify.isValidAttribute(tag, attr, value) : ssrSafeHref(value, tag, attr);
|
|
70
|
+
if (!isSafe) {
|
|
71
|
+
void 0;
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return href;
|
|
107
75
|
}
|
|
108
76
|
export default safeHref;
|
|
109
|
-
export { safeHref };
|
|
77
|
+
export { safeHref };
|
package/es/safeLinkProps.js
CHANGED
|
@@ -1,54 +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
1
|
import { safeHref } from './safeHref.js';
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* ---
|
|
29
|
-
* category: utilities/utils
|
|
30
|
-
* ---
|
|
31
|
-
* Centralizes the security-related normalization for link-rendering
|
|
32
|
-
* components: validates `href`, and supplies a safe default `rel` when
|
|
33
|
-
* `target="_blank"` is in use.
|
|
34
|
-
*
|
|
35
|
-
* @module safeLinkProps
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
2
|
function safeLinkProps(input) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
rel
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
href,
|
|
49
|
-
target,
|
|
50
|
-
rel: finalRel
|
|
51
|
-
};
|
|
3
|
+
const { target, rel, tag, attr } = input;
|
|
4
|
+
const href = safeHref(input.href, tag, attr);
|
|
5
|
+
const finalRel = target === '_blank' && rel == null ? 'noopener noreferrer' : rel;
|
|
6
|
+
return {
|
|
7
|
+
href,
|
|
8
|
+
target,
|
|
9
|
+
rel: finalRel
|
|
10
|
+
};
|
|
52
11
|
}
|
|
53
12
|
export default safeLinkProps;
|
|
54
|
-
export { safeLinkProps };
|
|
13
|
+
export { safeLinkProps };
|
package/es/shallowEqual.js
CHANGED
|
@@ -1,79 +1,29 @@
|
|
|
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
|
-
// https://github.com/facebook/fbjs/blob/master/packages/fbjs/src/core/shallowEqual.js
|
|
26
1
|
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* ---
|
|
30
|
-
* category: utilities/Misc
|
|
31
|
-
* ---
|
|
32
|
-
* Performs equality by iterating through keys on an object and returning false
|
|
33
|
-
* when any key has values which are not strictly equal between the arguments.
|
|
34
|
-
*
|
|
35
|
-
* @module shallowEqual
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} objA
|
|
38
|
-
* @param {Object} objB
|
|
39
|
-
* @returns {Boolean} Returns true when the values of all keys are strictly equal
|
|
40
|
-
*/
|
|
41
2
|
function shallowEqual(objA, objB) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Test for A's keys different from B.
|
|
55
|
-
for (let i = 0; i < keysA.length; i++) {
|
|
56
|
-
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
57
|
-
return false;
|
|
3
|
+
if (is(objA, objB)) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
const keysA = Object.keys(objA);
|
|
10
|
+
const keysB = Object.keys(objB);
|
|
11
|
+
if (keysA.length !== keysB.length) {
|
|
12
|
+
return false;
|
|
58
13
|
}
|
|
59
|
-
|
|
60
|
-
|
|
14
|
+
for(let i = 0; i < keysA.length; i++){
|
|
15
|
+
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
61
20
|
}
|
|
62
|
-
|
|
63
|
-
/*
|
|
64
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
65
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
66
|
-
*/
|
|
67
21
|
function is(x, y) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else {
|
|
74
|
-
// Step 6.a: NaN == NaN
|
|
75
|
-
return x !== x && y !== y;
|
|
76
|
-
}
|
|
22
|
+
if (x === y) {
|
|
23
|
+
return x !== 0 || y !== 0 || 1 / x === 1 / y;
|
|
24
|
+
} else {
|
|
25
|
+
return x !== x && y !== y;
|
|
26
|
+
}
|
|
77
27
|
}
|
|
78
28
|
export default shallowEqual;
|
|
79
|
-
export { shallowEqual };
|
|
29
|
+
export { shallowEqual };
|
package/es/within.js
CHANGED
|
@@ -1,42 +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
|
-
* Determines if one numerical value (a) is within a designated range (diff) of another (b)
|
|
30
|
-
*
|
|
31
|
-
* @module within
|
|
32
|
-
*
|
|
33
|
-
* @param {number} a
|
|
34
|
-
* @param {number} b
|
|
35
|
-
* @param {number} [diff=1]
|
|
36
|
-
* @returns {Boolean} Returns true if a is within the diff range of b
|
|
37
|
-
*/
|
|
38
1
|
function within(a, b, diff = 1) {
|
|
39
|
-
|
|
2
|
+
return a + diff >= b && b >= a - diff;
|
|
40
3
|
}
|
|
41
4
|
export default within;
|
|
42
|
-
export { within };
|
|
5
|
+
export { within };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-utils",
|
|
3
|
-
"version": "11.7.
|
|
3
|
+
"version": "11.7.9-pr-snapshot-1792147648392",
|
|
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",
|
|
@@ -14,19 +14,18 @@
|
|
|
14
14
|
"bugs": "https://github.com/instructure/instructure-ui/issues",
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@
|
|
17
|
+
"@swc/helpers": "^0.5.23",
|
|
18
18
|
"@types/ua-parser-js": "^0.7.39",
|
|
19
19
|
"dompurify": "^3.4.2",
|
|
20
20
|
"fast-deep-equal": "^3.1.3",
|
|
21
21
|
"json-stable-stringify": "^1.3.0",
|
|
22
22
|
"ua-parser-js": "^1.0.39",
|
|
23
|
-
"@instructure/console": "11.7.
|
|
24
|
-
"@instructure/shared-types": "11.7.
|
|
25
|
-
"@instructure/ui-dom-utils": "11.7.
|
|
23
|
+
"@instructure/console": "11.7.9-pr-snapshot-1792147648392",
|
|
24
|
+
"@instructure/shared-types": "11.7.9-pr-snapshot-1792147648392",
|
|
25
|
+
"@instructure/ui-dom-utils": "11.7.9-pr-snapshot-1792147648392"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"vitest": "^5.0.0"
|
|
29
|
-
"@instructure/ui-babel-preset": "11.7.8"
|
|
28
|
+
"vitest": "^5.0.0"
|
|
30
29
|
},
|
|
31
30
|
"//dependency-comments": {
|
|
32
31
|
"ua-parser-js": "Do not upgrade to 2.x, it has a problematic license"
|
|
@@ -44,10 +43,8 @@
|
|
|
44
43
|
"src": "./src/index.ts",
|
|
45
44
|
"types": "./types/index.d.ts",
|
|
46
45
|
"import": "./es/index.js",
|
|
47
|
-
"require": "./lib/index.js",
|
|
48
46
|
"default": "./es/index.js"
|
|
49
47
|
},
|
|
50
|
-
"./lib/*": "./lib/*",
|
|
51
48
|
"./es/*": "./es/*",
|
|
52
49
|
"./types/*": "./types/*",
|
|
53
50
|
"./package.json": "./package.json",
|
|
@@ -57,7 +54,7 @@
|
|
|
57
54
|
"lint": "ui-scripts lint",
|
|
58
55
|
"lint:fix": "ui-scripts lint --fix",
|
|
59
56
|
"clean": "ui-scripts clean",
|
|
60
|
-
"build": "ui-scripts build
|
|
57
|
+
"build": "ui-scripts build",
|
|
61
58
|
"build:watch": "ui-scripts build --watch",
|
|
62
59
|
"build:types": "tsc -p tsconfig.build.json"
|
|
63
60
|
}
|
package/tsconfig.build.json
CHANGED
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/Misc
|
|
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/Misc
|
|
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/Misc
|
|
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;
|
package/lib/combineDataCid.js
DELETED
|
@@ -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;
|
package/lib/convertCase.js
DELETED
|
@@ -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.js");
|
|
19
|
-
var _pascalize = require("./pascalize.js");
|