@instructure/ui-color-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 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-color-utils
package/es/alpha.js CHANGED
@@ -1,40 +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
1
  import Color from 'tinycolor2';
26
-
27
- /**
28
- * ---
29
- * category: utilities/Color
30
- * ---
31
- * Adjust the alpha transparency of a color
32
- * @module alpha
33
- * @param color
34
- * @param percent
35
- * @returns color as rgb string
36
- */
37
2
  function alpha(color, percent) {
38
- return Color(color).setAlpha(percent / 100).toRgbString();
3
+ return Color(color).setAlpha(percent / 100).toRgbString();
39
4
  }
40
- export { alpha };
5
+ export { alpha };
package/es/colorTypes.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export { };
package/es/contrast.js CHANGED
@@ -1,41 +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
1
  import Color from 'tinycolor2';
26
-
27
- /**
28
- * ---
29
- * category: utilities/Color
30
- * ---
31
- * check the contrast ratio of 2 colors. Optionally number of decimal places can be added
32
- * @module contrast
33
- * @param color1
34
- * @param color2
35
- * @param decimalPlaces
36
- * @returns color contrast ratio
37
- */
38
- const contrast = (color1, color2, decimalPlaces = -1) => {
39
- return decimalPlaces >= 0 ? Math.round(Color.readability(color1, color2) * 10 ** decimalPlaces) / 10 ** decimalPlaces : Color.readability(color1, color2);
2
+ const contrast = (color1, color2, decimalPlaces = -1)=>{
3
+ return decimalPlaces >= 0 ? Math.round(Color.readability(color1, color2) * 10 ** decimalPlaces) / 10 ** decimalPlaces : Color.readability(color1, color2);
40
4
  };
41
- export { contrast };
5
+ export { contrast };
@@ -1,52 +1,16 @@
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 { colorToRGB, colorToHex8 } from './conversions.js';
26
2
  import { overlayColors } from './overlayColors.js';
27
3
  import { contrast } from './contrast.js';
28
-
29
- /**
30
- * ---
31
- * category: utilities/Color
32
- * ---
33
- * Calculates two, not necessarily opaque color's contrast on top of each other.
34
- * The method assumes that the bottom color is on top of a white background (only important if it isn't opaque)
35
- * @module contrastWithAlpha
36
- * @param color1
37
- * @param color2
38
- * @returns color contrast ratio
39
- */
40
- const contrastWithAlpha = (color1, color2) => {
41
- const c1RGBA = colorToRGB(color1);
42
- const c2RGBA = colorToRGB(color2);
43
- const c1OnWhite = overlayColors({
44
- r: 255,
45
- g: 255,
46
- b: 255,
47
- a: 1
48
- }, c1RGBA);
49
- const c2OnC1OnWhite = overlayColors(c1OnWhite, c2RGBA);
50
- return contrast(colorToHex8(c1OnWhite), colorToHex8(c2OnC1OnWhite), 2);
4
+ const contrastWithAlpha = (color1, color2)=>{
5
+ const c1RGBA = colorToRGB(color1);
6
+ const c2RGBA = colorToRGB(color2);
7
+ const c1OnWhite = overlayColors({
8
+ r: 255,
9
+ g: 255,
10
+ b: 255,
11
+ a: 1
12
+ }, c1RGBA);
13
+ const c2OnC1OnWhite = overlayColors(c1OnWhite, c2RGBA);
14
+ return contrast(colorToHex8(c1OnWhite), colorToHex8(c2OnC1OnWhite), 2);
51
15
  };
52
- export { contrastWithAlpha };
16
+ export { contrastWithAlpha };
package/es/conversions.js CHANGED
@@ -1,74 +1,17 @@
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 Color from 'tinycolor2';
26
- /**
27
- * Converts any valid `TinyColor` colors to hex string
28
- * @param rgb a color string
29
- * @returns a hex string like `#FF0000`
30
- */
31
- const colorToHex = rgb => {
32
- return Color(rgb).toHexString().toUpperCase();
2
+ const colorToHex = (rgb)=>{
3
+ return Color(rgb).toHexString().toUpperCase();
33
4
  };
34
-
35
- /**
36
- * Transforms any `TinyColor` to 8 length HEX (alpha included)
37
- * @param color representation from `TinyColor`
38
- * @returns An 8 length hex string like `#FF0000FF`
39
- */
40
- const colorToHex8 = color => {
41
- return Color(color).toHex8String().toUpperCase();
5
+ const colorToHex8 = (color)=>{
6
+ return Color(color).toHex8String().toUpperCase();
42
7
  };
43
-
44
- /**
45
- * Transforms any `TinyColor` to RGBA object ( {r:number, g:number, b:number, a:number} )
46
- * also exported as `hexToRgb` for backward compatiblity reasons
47
- * @param color representation from `TinyColor`
48
- * @returns A `TinyColor` RGBA type
49
- */
50
- const colorToRGB = color => {
51
- return Color(color).toRgb();
8
+ const colorToRGB = (color)=>{
9
+ return Color(color).toRgb();
52
10
  };
53
-
54
- /**
55
- * Transforms any `TinyColor` to HSVA object ( {h:number, s:number, v:number, a:number} )
56
- * @param color representation from `TinyColor`
57
- * @returns A `TinyColor` HSVA type
58
- */
59
- const colorToHsva = color => {
60
- return Color(color).toHsv();
11
+ const colorToHsva = (color)=>{
12
+ return Color(color).toHsv();
61
13
  };
62
-
63
- /**
64
- * Transforms any `TinyColor` to HSLA object ( {h:number, s:number, l:number, a:number} )
65
- * @param color representation from `TinyColor`
66
- * @returns A `TinyColor` HSLA type
67
- */
68
- const colorToHsla = color => {
69
- return Color(color).toHsl();
14
+ const colorToHsla = (color)=>{
15
+ return Color(color).toHsl();
70
16
  };
71
- export { colorToHex, colorToHex8, colorToHsva, colorToHsla, colorToRGB,
72
- //this is needed for backward compatibility
73
- //TODO deprecate
74
- colorToHex as color2hex };
17
+ export { colorToHex, colorToHex8, colorToHsva, colorToHsla, colorToRGB, colorToHex as color2hex };
package/es/darken.js CHANGED
@@ -1,40 +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
1
  import Color from 'tinycolor2';
26
-
27
- /**
28
- * ---
29
- * category: utilities/Color
30
- * ---
31
- * darken a color
32
- * @module darken
33
- * @param color
34
- * @param percent
35
- * @returns color as rgb string
36
- */
37
2
  function darken(color, percent) {
38
- return Color(color).darken(percent).toRgbString();
3
+ return Color(color).darken(percent).toRgbString();
39
4
  }
40
- export { darken };
5
+ export { darken };
package/es/index.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
  export { alpha } from './alpha.js';
26
2
  export { darken } from './darken.js';
27
3
  export { lighten } from './lighten.js';
@@ -31,15 +7,3 @@ export { overlayColors } from './overlayColors.js';
31
7
  export { contrastWithAlpha } from './contrastWithAlpha.js';
32
8
  export { validateContrast } from './validateContrast.js';
33
9
  export { color2hex, colorToHex8, colorToHsva, colorToHsla, colorToRGB } from './conversions.js';
34
- import { color2hex, colorToHex8, colorToHsva, colorToHsla, colorToRGB } from './conversions.js';
35
-
36
- // TODO remove when we get rid of babel-plugin-transform-imports
37
- // This default export is needed because babel-plugin-transform-imports will
38
- // fail if the exported name is not the same as the filename
39
- export default {
40
- color2hex: color2hex,
41
- colorToHex8: colorToHex8,
42
- colorToHsva: colorToHsva,
43
- colorToHsla: colorToHsla,
44
- colorToRGB: colorToRGB
45
- };
package/es/isValid.js CHANGED
@@ -1,39 +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
1
  import Color from 'tinycolor2';
26
-
27
- /**
28
- * ---
29
- * category: utilities/Color
30
- * ---
31
- * check if a string is a valid color
32
- * @module isValid
33
- * @param color
34
- * @returns true if the string is a valid color
35
- */
36
2
  function isValid(color) {
37
- return Color(color).isValid();
3
+ return Color(color).isValid();
38
4
  }
39
- export { isValid };
5
+ export { isValid };
package/es/lighten.js CHANGED
@@ -1,40 +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
1
  import Color from 'tinycolor2';
26
-
27
- /**
28
- * ---
29
- * category: utilities/Color
30
- * ---
31
- * lighten a color
32
- * @module lighten
33
- * @param color
34
- * @param percent
35
- * @returns color as rgb string
36
- */
37
2
  function lighten(color, percent) {
38
- return Color(color).lighten(percent).toRgbString();
3
+ return Color(color).lighten(percent).toRgbString();
39
4
  }
40
- export { lighten };
5
+ export { lighten };
@@ -1,47 +1,10 @@
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/Color
28
- * ---
29
- * Place two RGBA colors on top of each other. The second one (c2) goes on top.
30
- * The method calculates what color would be visible. If the second color (c2) is opaque, the result
31
- * will be c2, if fully transparent, c1. If anything in between, it calculates the real color.
32
- * Alpha is always set to 1 after the calculation
33
- * @module overlayColors
34
- * @param c1
35
- * @param c2
36
- * @returns color as rgb string
37
- */
38
- const overlayColors = (c1, c2) => {
39
- const alpha = 1 - (1 - c1.a) * (1 - c2.a);
40
- return {
41
- r: c2.r * c2.a / alpha + c1.r * c1.a * (1 - c2.a) / alpha,
42
- g: c2.g * c2.a / alpha + c1.g * c1.a * (1 - c2.a) / alpha,
43
- b: c2.b * c2.a / alpha + c1.b * c1.a * (1 - c2.a) / alpha,
44
- a: 1
45
- };
1
+ const overlayColors = (c1, c2)=>{
2
+ const alpha = 1 - (1 - c1.a) * (1 - c2.a);
3
+ return {
4
+ r: c2.r * c2.a / alpha + c1.r * c1.a * (1 - c2.a) / alpha,
5
+ g: c2.g * c2.a / alpha + c1.g * c1.a * (1 - c2.a) / alpha,
6
+ b: c2.b * c2.a / alpha + c1.b * c1.a * (1 - c2.a) / alpha,
7
+ a: 1
8
+ };
46
9
  };
47
- export { overlayColors };
10
+ export { overlayColors };
@@ -1,56 +1,8 @@
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/Color
28
- * ---
29
- * Decides if the given contrast is sufficient for different text sizes and situations.
30
- *
31
- * According to WCAG 2.2
32
- *
33
- * AA level (https://www.w3.org/TR/WCAG22/#contrast-minimum)
34
- * - text: 4.5:1
35
- * - large text: 3:1
36
- * - non-text: 3:1 (https://www.w3.org/TR/WCAG22/#non-text-contrast)
37
- *
38
- *
39
- * AAA level (https://www.w3.org/TR/WCAG22/#contrast-enhanced)
40
- * - text: 7:1
41
- * - large text: 4.5:1
42
- * - non-text: 3:1 (https://www.w3.org/TR/WCAG22/#non-text-contrast)
43
- *
44
- * @module validateContrast
45
- * @param contrast
46
- * @param validationLevel WCAG 2.2 validation level
47
- * @returns validation object
48
- */
49
- const validateContrast = (contrast, validationLevel) => {
50
- return {
51
- isValidNormalText: contrast >= (validationLevel === 'AAA' ? 7 : 4.5),
52
- isValidLargeText: contrast >= (validationLevel === 'AAA' ? 4.5 : 3),
53
- isValidGraphicsText: contrast >= 3
54
- };
1
+ const validateContrast = (contrast, validationLevel)=>{
2
+ return {
3
+ isValidNormalText: contrast >= (validationLevel === 'AAA' ? 7 : 4.5),
4
+ isValidLargeText: contrast >= (validationLevel === 'AAA' ? 4.5 : 3),
5
+ isValidGraphicsText: contrast >= 3
6
+ };
55
7
  };
56
- export { validateContrast };
8
+ export { validateContrast };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@instructure/ui-color-utils",
3
- "version": "11.7.8",
3
+ "version": "11.7.9-pr-snapshot-1792147648392",
4
+ "type": "module",
4
5
  "description": "A color utility library made by Instructure Inc.",
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,12 +14,11 @@
14
14
  "bugs": "https://github.com/instructure/instructure-ui/issues",
15
15
  "license": "MIT",
16
16
  "dependencies": {
17
- "@babel/runtime": "^7.29.7",
17
+ "@swc/helpers": "^0.5.23",
18
18
  "tinycolor2": "^1.6.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@types/tinycolor2": "^1.4.6",
22
- "@instructure/ui-babel-preset": "11.7.8"
21
+ "@types/tinycolor2": "^1.4.6"
23
22
  },
24
23
  "publishConfig": {
25
24
  "access": "public"
@@ -30,10 +29,8 @@
30
29
  "src": "./src/index.ts",
31
30
  "types": "./types/index.d.ts",
32
31
  "import": "./es/index.js",
33
- "require": "./lib/index.js",
34
32
  "default": "./es/index.js"
35
33
  },
36
- "./lib/*": "./lib/*",
37
34
  "./es/*": "./es/*",
38
35
  "./types/*": "./types/*",
39
36
  "./package.json": "./package.json",
@@ -43,7 +40,7 @@
43
40
  "lint": "ui-scripts lint",
44
41
  "lint:fix": "ui-scripts lint --fix",
45
42
  "clean": "ui-scripts clean",
46
- "build": "ui-scripts build --modules es,cjs",
43
+ "build": "ui-scripts build",
47
44
  "build:watch": "ui-scripts build --watch",
48
45
  "build:types": "tsc -p tsconfig.build.json"
49
46
  }
package/src/index.ts CHANGED
@@ -38,23 +38,4 @@ export {
38
38
  colorToRGB
39
39
  } from './conversions.js'
40
40
 
41
- import {
42
- color2hex,
43
- colorToHex8,
44
- colorToHsva,
45
- colorToHsla,
46
- colorToRGB
47
- } from './conversions.js'
48
-
49
- // TODO remove when we get rid of babel-plugin-transform-imports
50
- // This default export is needed because babel-plugin-transform-imports will
51
- // fail if the exported name is not the same as the filename
52
- export default {
53
- color2hex: color2hex,
54
- colorToHex8: colorToHex8,
55
- colorToHsva: colorToHsva,
56
- colorToHsla: colorToHsla,
57
- colorToRGB: colorToRGB
58
- }
59
-
60
41
  export type { RGBType, HSVType, HSLType, RGBAType } from './colorTypes'
@@ -6,9 +6,5 @@
6
6
  "composite": true
7
7
  },
8
8
  "include": ["src"],
9
- "references": [
10
- {
11
- "path": "../ui-babel-preset/tsconfig.build.json"
12
- }
13
- ]
9
+ "references": []
14
10
  }