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