@protonradio/proton-ui 0.6.18-beta.5 → 0.6.18-beta.6
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/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/utils-CfmTFcgh.mjs +119 -0
- package/dist/utils-CfmTFcgh.mjs.map +1 -0
- package/dist/utils-HYp3o7mD.js +2 -0
- package/dist/utils-HYp3o7mD.js.map +1 -0
- package/dist/utils.cjs.js +1 -1
- package/dist/utils.d.ts +12 -0
- package/dist/utils.es.js +8 -7
- package/package.json +1 -1
- package/dist/utils-B_UbuIoU.mjs +0 -114
- package/dist/utils-B_UbuIoU.mjs.map +0 -1
- package/dist/utils-DQj80-_6.js +0 -2
- package/dist/utils-DQj80-_6.js.map +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),we=require("react-dom"),y=require("react-aria"),q=require("react-stately"),E=require("./utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),we=require("react-dom"),y=require("react-aria"),q=require("react-stately"),E=require("./utils-HYp3o7mD.js"),Z=require("./constants.cjs.js"),oe=require("color2k"),k=require("./colors-BdogYmJi.js");var Ye={exports:{}},he={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
package/dist/index.es.js
CHANGED
|
@@ -2,7 +2,7 @@ import g, { useLayoutEffect as pr, useState as D, useRef as S, createElement as
|
|
|
2
2
|
import en, { createPortal as tn } from "react-dom";
|
|
3
3
|
import { useMenu as nn, useOverlay as mr, FocusScope as pt, useMenuItem as rn, useButton as De, useRadioGroup as br, useRadio as gr, VisuallyHidden as on, useDialog as yr, useTextField as xr, useClipboard as _r, useSearchField as $r, useOverlayTrigger as Sr, usePopover as Er, Overlay as wr, DismissButton as Cr, useFocusRing as we, useHover as Rr, useId as Lt, mergeProps as me, useMenuTrigger as Pr, useMenuSection as Tr, useTooltipTrigger as jr, OverlayContainer as Nr, useOverlayPosition as Mr, useTooltip as kr, useListBox as Ar, useOption as Or, useSelect as an, HiddenSelect as ln, useSwitch as Ir, useTableHeaderRow as Dr, useTableColumnHeader as Lr, useTableRowGroup as Br, useTableRow as Hr, useTableCell as Vr, useTable as Kr } from "react-aria";
|
|
4
4
|
import { useTreeState as sn, Item as ht, useRadioGroupState as Wr, useOverlayTriggerState as Fr, useMenuTriggerState as Gr, useTooltipTriggerState as cn, useSelectState as un, useToggleState as Ur, useTableState as zr } from "react-stately";
|
|
5
|
-
import { b as E, i as vt, h as dn } from "./utils-
|
|
5
|
+
import { b as E, i as vt, h as dn } from "./utils-CfmTFcgh.mjs";
|
|
6
6
|
import { THEMES as le, BREAKPOINTS as fn } from "./constants.es.js";
|
|
7
7
|
import { transparentize as ve, toRgba as Xe } from "color2k";
|
|
8
8
|
import { G as Q, S as Ne, W as Me, D as ke, B as Yr } from "./colors-Dwh4VIMR.mjs";
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { B as D, G as e } from "./colors-Dwh4VIMR.mjs";
|
|
2
|
+
import { toRgba as s, transparentize as P, getScale as G, desaturate as M, saturate as T, adjustHue as L, getLuminance as u, lighten as m, darken as H } from "color2k";
|
|
3
|
+
const f = {
|
|
4
|
+
BRAND: {
|
|
5
|
+
PRIMARY: D.PRIMARY,
|
|
6
|
+
PRIMARY_LIGHT: D.PRIMARY_LIGHT,
|
|
7
|
+
SECONDARY: D.SECONDARY
|
|
8
|
+
},
|
|
9
|
+
PRIMARY: {
|
|
10
|
+
PRIMARY_SUPER_DARK: e.GRAY_SUPER_DARK,
|
|
11
|
+
PRIMARY_DARK: e.GRAY_DARK,
|
|
12
|
+
PRIMARY_MEDIUM: e.GRAY_MEDIUM,
|
|
13
|
+
PRIMARY_MEDIUM_LIGHT: e.GRAY_MEDIUM_LIGHT,
|
|
14
|
+
PRIMARY_LIGHT: e.GRAY_LIGHT,
|
|
15
|
+
PRIMARY_LIGHTEST: e.GRAY_LIGHTEST,
|
|
16
|
+
PRIMARY_SUPER_LIGHT: e.GRAY_SUPER_LIGHT
|
|
17
|
+
},
|
|
18
|
+
SECONDARY: {
|
|
19
|
+
SECONDARY_SUPER_DARK: e.GRAY_SUPER_DARK,
|
|
20
|
+
SECONDARY_DARK: e.GRAY_DARK,
|
|
21
|
+
SECONDARY_MEDIUM: e.GRAY_MEDIUM,
|
|
22
|
+
SECONDARY_MEDIUM_LIGHT: e.GRAY_MEDIUM_LIGHT,
|
|
23
|
+
SECONDARY_LIGHT: e.GRAY_LIGHT,
|
|
24
|
+
SECONDARY_LIGHTEST: e.GRAY_LIGHTEST,
|
|
25
|
+
SECONDARY_SUPER_LIGHT: e.GRAY_SUPER_LIGHT
|
|
26
|
+
}
|
|
27
|
+
// Success, Warning & Danger palettes go here...
|
|
28
|
+
}, h = (t, n) => n === void 0 ? `rgb(${t[0]}, ${t[1]}, ${t[2]})` : `rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n})`, y = (t, n) => s(P(t, n)), Y = ([t, n, R]) => t * 0.2126 + n * 0.7152 + R * 0.0722, U = (t) => t.map((n) => 255 - n), C = (t, n) => {
|
|
29
|
+
const R = Y(t), a = Y(n);
|
|
30
|
+
return (Math.max(R, a) + 0.05) / (Math.min(R, a) + 0.05);
|
|
31
|
+
}, K = (t, n = 4.5) => {
|
|
32
|
+
const R = U(t);
|
|
33
|
+
if (C(t, R) >= n) return R;
|
|
34
|
+
const r = Y(t), o = r < 128;
|
|
35
|
+
if (o && r > 255 / n)
|
|
36
|
+
return [255, 255, 255];
|
|
37
|
+
const I = Y(R), E = (Math.min(r, I) + 0.05) * n - (Math.max(r, I) + 0.05);
|
|
38
|
+
return o ? R.map(
|
|
39
|
+
(A) => Math.min(255, Math.round(A + E))
|
|
40
|
+
) : R.map(
|
|
41
|
+
(A) => Math.max(0, Math.round(A - E))
|
|
42
|
+
);
|
|
43
|
+
}, F = (t, n = !0) => {
|
|
44
|
+
const R = h(t), a = G("#FFFFFF", R, "#000000"), r = Array.from({ length: 12 }, (_, i) => {
|
|
45
|
+
const S = a(i / 11);
|
|
46
|
+
return s(M(S, 0.1));
|
|
47
|
+
}), o = n ? r.map(
|
|
48
|
+
(_) => s(M(l(_), 0.1))
|
|
49
|
+
) : r, I = s(T(L(R, 180), 1)), E = G("#FFFFFF", I, "#000000"), A = Array.from({ length: 12 }, (_, i) => {
|
|
50
|
+
const S = E(i / 11);
|
|
51
|
+
return s(M(S, 0.1));
|
|
52
|
+
}), c = n ? A.map(
|
|
53
|
+
(_) => s(M(l(_), 0.1))
|
|
54
|
+
) : A;
|
|
55
|
+
return {
|
|
56
|
+
BRAND: {
|
|
57
|
+
PRIMARY: o[5],
|
|
58
|
+
PRIMARY_LIGHT: o[3],
|
|
59
|
+
SECONDARY: c[4]
|
|
60
|
+
},
|
|
61
|
+
PRIMARY: {
|
|
62
|
+
PRIMARY_SUPER_DARK: r[10],
|
|
63
|
+
PRIMARY_DARK: r[9],
|
|
64
|
+
PRIMARY_MEDIUM: o[7],
|
|
65
|
+
PRIMARY_MEDIUM_LIGHT: o[6],
|
|
66
|
+
PRIMARY_LIGHT: o[5],
|
|
67
|
+
PRIMARY_LIGHTEST: o[4],
|
|
68
|
+
PRIMARY_SUPER_LIGHT: o[3]
|
|
69
|
+
},
|
|
70
|
+
SECONDARY: {
|
|
71
|
+
SECONDARY_SUPER_DARK: A[10],
|
|
72
|
+
SECONDARY_DARK: A[9],
|
|
73
|
+
SECONDARY_MEDIUM: c[7],
|
|
74
|
+
SECONDARY_MEDIUM_LIGHT: c[6],
|
|
75
|
+
SECONDARY_LIGHT: c[5],
|
|
76
|
+
SECONDARY_LIGHTEST: c[4],
|
|
77
|
+
SECONDARY_SUPER_LIGHT: c[3]
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, l = (t) => {
|
|
81
|
+
let n = t, R = u(s(n)), a = 0;
|
|
82
|
+
const r = 6;
|
|
83
|
+
for (; R < 0.16 && a < r; )
|
|
84
|
+
a++, n = m(n, 0.1), R = u(s(n));
|
|
85
|
+
for (; R > 0.6 && a < r; )
|
|
86
|
+
a++, n = H(n, 0.1), R = u(s(n));
|
|
87
|
+
return n;
|
|
88
|
+
}, d = (t) => typeof t == "string" || t instanceof String;
|
|
89
|
+
function g(...t) {
|
|
90
|
+
return t.filter(d).join(" ");
|
|
91
|
+
}
|
|
92
|
+
const p = (t) => {
|
|
93
|
+
if (/^https?:\/\//.test(t)) {
|
|
94
|
+
const n = document.createElement("a");
|
|
95
|
+
return n.href = t, n.hostname;
|
|
96
|
+
}
|
|
97
|
+
return window.location.hostname;
|
|
98
|
+
}, w = (t) => {
|
|
99
|
+
const n = window.location.hostname, R = p(t);
|
|
100
|
+
return n !== R;
|
|
101
|
+
}, $ = (t, n) => {
|
|
102
|
+
if (t.metaKey || t.altKey || t.ctrlKey || t.shiftKey || t.button && t.button !== 0)
|
|
103
|
+
return;
|
|
104
|
+
t.preventDefault();
|
|
105
|
+
const R = n.startsWith("/") ? n : `/${n}`;
|
|
106
|
+
window.history.pushState({}, "", R), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
107
|
+
};
|
|
108
|
+
export {
|
|
109
|
+
f as D,
|
|
110
|
+
h as a,
|
|
111
|
+
g as b,
|
|
112
|
+
K as c,
|
|
113
|
+
F as g,
|
|
114
|
+
$ as h,
|
|
115
|
+
w as i,
|
|
116
|
+
Y as l,
|
|
117
|
+
y as t
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=utils-CfmTFcgh.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-CfmTFcgh.mjs","sources":["../src/utils/color.ts","../src/utils/utils.ts"],"sourcesContent":["import { COLORS } from \"../constants\";\r\nimport {\r\n adjustHue,\r\n getLuminance,\r\n getScale,\r\n lighten,\r\n saturate,\r\n transparentize as _transparentize,\r\n desaturate,\r\n} from \"color2k\";\r\nimport { darken, toRgba } from \"color2k\";\r\n\r\nexport type RGBArray = [number, number, number];\r\n\r\nexport type Palette = {\r\n BRAND: {\r\n PRIMARY: string;\r\n PRIMARY_LIGHT: string;\r\n SECONDARY: string;\r\n };\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: string;\r\n PRIMARY_DARK: string;\r\n PRIMARY_MEDIUM: string;\r\n PRIMARY_MEDIUM_LIGHT: string;\r\n PRIMARY_LIGHT: string;\r\n PRIMARY_LIGHTEST: string;\r\n PRIMARY_SUPER_LIGHT: string;\r\n };\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: string;\r\n SECONDARY_DARK: string;\r\n SECONDARY_MEDIUM: string;\r\n SECONDARY_MEDIUM_LIGHT: string;\r\n SECONDARY_LIGHT: string;\r\n SECONDARY_LIGHTEST: string;\r\n SECONDARY_SUPER_LIGHT: string;\r\n };\r\n};\r\n\r\nexport const DEFAULT_PALETTE: Palette = {\r\n BRAND: {\r\n PRIMARY: COLORS.BRAND.PRIMARY,\r\n PRIMARY_LIGHT: COLORS.BRAND.PRIMARY_LIGHT,\r\n SECONDARY: COLORS.BRAND.SECONDARY,\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n PRIMARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n PRIMARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n PRIMARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n PRIMARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n PRIMARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n PRIMARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n SECONDARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n SECONDARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n SECONDARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n SECONDARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n SECONDARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n SECONDARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n // Success, Warning & Danger palettes go here...\r\n};\r\n\r\n/**\r\n * Converts an RGB array to a CSS string representation.\r\n * @param rgb - The RGB array to convert.\r\n * @param opacity - Optional opacity value.\r\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\r\n */\r\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\r\n return opacity === undefined\r\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\r\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\r\n};\r\n\r\n/**\r\n * Transparentizes an input color and returns the result after adjustment to ensure a minimum contrast ratio.\r\n *\r\n * @param color - The color string to transparentize.\r\n * @param amount - The amount to increase the opacity of the color by, given as a decimal between 0 and 1.\r\n * @returns An RGBA color string.\r\n */\r\nexport const transparentize = (color: string, amount: number): string => {\r\n return toRgba(_transparentize(color, amount));\r\n};\r\n\r\n/**\r\n\r\n/**\r\n * Calculates the relative luminance of an RGB color according to WCAG 2.2 specifications.\r\n\r\n * This is used in calculating contrast ratios between colors.\r\n *\r\n * @param param0 - RGB color array containing red, green and blue values (0-255)\r\n * @returns The relative luminance value\r\n * @see formula from https://www.w3.org/WAI/WCAG22/Techniques/general/G18 (see step 1 in `Procedure`)\r\n */\r\nexport const luminance = ([r, g, b]: RGBArray): number => {\r\n return r * 0.2126 + g * 0.7152 + b * 0.0722;\r\n};\r\n\r\nconst invertColor = (rgb: RGBArray): RGBArray => {\r\n return rgb.map((value) => 255 - value) as RGBArray;\r\n};\r\n\r\nconst contrastRatio = (color1: RGBArray, color2: RGBArray): number => {\r\n const luminance1 = luminance(color1);\r\n const luminance2 = luminance(color2);\r\n\r\n return (\r\n (Math.max(luminance1, luminance2) + 0.05) /\r\n (Math.min(luminance1, luminance2) + 0.05)\r\n );\r\n};\r\n\r\n/**\r\n * Inverts an input color and returns the result after adjustment to ensure a minimum contrast ratio.\r\n *\r\n * @param color - The RGB color array to invert.\r\n * @param minContrast - The contrast ratio to exceed. Defaults to 4.5, which is the minimum for text to be considered accessible.\r\n */\r\n\r\nexport const contrastColor = (\r\n color: RGBArray,\r\n minContrast: number = 4.5\r\n): RGBArray => {\r\n const newColor = invertColor(color);\r\n const contrast = contrastRatio(color, newColor);\r\n if (contrast >= minContrast) return newColor;\r\n\r\n const colorLuminance = luminance(color);\r\n const isColorDark = colorLuminance < 128;\r\n\r\n if (isColorDark && colorLuminance > 255 / minContrast) {\r\n return [255, 255, 255]; // not dark enough to find color meeting minimum contrast, return white\r\n }\r\n\r\n const newColorLuminance = luminance(newColor);\r\n\r\n const difference =\r\n (Math.min(colorLuminance, newColorLuminance) + 0.05) * minContrast -\r\n (Math.max(colorLuminance, newColorLuminance) + 0.05);\r\n\r\n return isColorDark\r\n ? (newColor.map((value) =>\r\n Math.min(255, Math.round(value + difference))\r\n ) as RGBArray)\r\n : (newColor.map((value) =>\r\n Math.max(0, Math.round(value - difference))\r\n ) as RGBArray);\r\n};\r\n\r\n/**\r\n * Generates a complete color palette based on a primary color input.\r\n * The palette includes primary and secondary color scales with varying shades.\r\n *\r\n * @param primaryColor - The base RGB color array to generate the palette from\r\n * @param adjustForLuminance - Whether to adjust the generated colors for better luminance/contrast.\r\n * Defaults to true.\r\n * @returns A Palette object containing:\r\n * - BRAND colors (primary, light primary, and secondary)\r\n * - PRIMARY scale (7 shades from super dark to super light)\r\n * - SECONDARY scale (7 shades from super dark to super light)\r\n *\r\n * The function:\r\n * 1. Creates a 12-color scale from white to the primary color to black\r\n * 2. Generates a complementary secondary color by shifting the hue 180 degrees\r\n * 3. Creates another 12-color scale for the secondary color\r\n * 4. Maps specific positions from these scales to create the final palette structure\r\n */\r\nexport const generatePalette = (\r\n primaryColor: RGBArray,\r\n adjustForLuminance: boolean = true\r\n): Palette => {\r\n const primaryRgba = arrayToRgbString(primaryColor);\r\n\r\n const primaryScaleFunc = getScale(\"#FFFFFF\", primaryRgba, \"#000000\");\r\n const primaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = primaryScaleFunc(i / 11);\r\n return toRgba(desaturate(color, 0.1));\r\n });\r\n\r\n const adjustedPrimaryScale = adjustForLuminance\r\n ? primaryScale.map((color) =>\r\n toRgba(desaturate(adjustBrightnessForLuminance(color), 0.1))\r\n )\r\n : primaryScale;\r\n\r\n const secondaryColor = toRgba(saturate(adjustHue(primaryRgba, 180), 1));\r\n\r\n const secondaryScaleFunc = getScale(\"#FFFFFF\", secondaryColor, \"#000000\");\r\n const secondaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = secondaryScaleFunc(i / 11);\r\n return toRgba(desaturate(color, 0.1));\r\n });\r\n\r\n const adjustedSecondaryScale = adjustForLuminance\r\n ? secondaryScale.map((color) =>\r\n toRgba(desaturate(adjustBrightnessForLuminance(color), 0.1))\r\n )\r\n : secondaryScale;\r\n\r\n return {\r\n BRAND: {\r\n PRIMARY: adjustedPrimaryScale[5],\r\n PRIMARY_LIGHT: adjustedPrimaryScale[3],\r\n SECONDARY: adjustedSecondaryScale[4],\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: primaryScale[10],\r\n PRIMARY_DARK: primaryScale[9],\r\n PRIMARY_MEDIUM: adjustedPrimaryScale[7],\r\n PRIMARY_MEDIUM_LIGHT: adjustedPrimaryScale[6],\r\n PRIMARY_LIGHT: adjustedPrimaryScale[5],\r\n PRIMARY_LIGHTEST: adjustedPrimaryScale[4],\r\n PRIMARY_SUPER_LIGHT: adjustedPrimaryScale[3],\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: secondaryScale[10],\r\n SECONDARY_DARK: secondaryScale[9],\r\n SECONDARY_MEDIUM: adjustedSecondaryScale[7],\r\n SECONDARY_MEDIUM_LIGHT: adjustedSecondaryScale[6],\r\n SECONDARY_LIGHT: adjustedSecondaryScale[5],\r\n SECONDARY_LIGHTEST: adjustedSecondaryScale[4],\r\n SECONDARY_SUPER_LIGHT: adjustedSecondaryScale[3],\r\n },\r\n };\r\n};\r\n\r\nconst adjustBrightnessForLuminance = (color: string): string => {\r\n let currentColor = color;\r\n let currentLuminance = getLuminance(toRgba(currentColor));\r\n let adjustmentAttempts = 0;\r\n const MAX_ATTEMPTS = 6;\r\n\r\n while (currentLuminance < 0.16 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = lighten(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n while (currentLuminance > 0.6 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = darken(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n return currentColor;\r\n};\r\n","const isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\n/**\r\n * [getLinkHost] - get the host of a link.\r\n * Referenced from is-url-external npm package\r\n * https://github.com/mrded/is-url-external/blob/master/index.js\r\n */\r\nconst getLinkHost = (url) => {\r\n if (/^https?:\\/\\//.test(url)) {\r\n // Absolute URL.\r\n // The easy way to parse an URL, is to create <a> element.\r\n // @see: https://gist.github.com/jlong/2428561\r\n const parser = document.createElement(\"a\");\r\n parser.href = url;\r\n return parser.hostname;\r\n }\r\n return window.location.hostname;\r\n};\r\n\r\n/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url) => {\r\n const host = window.location.hostname;\r\n const linkHost = getLinkHost(url);\r\n\r\n return host !== linkHost;\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n"],"names":["DEFAULT_PALETTE","COLORS.BRAND","COLORS.GRAYSCALE","arrayToRgbString","rgb","opacity","transparentize","color","amount","toRgba","_transparentize","luminance","r","g","b","invertColor","value","contrastRatio","color1","color2","luminance1","luminance2","contrastColor","minContrast","newColor","colorLuminance","isColorDark","newColorLuminance","difference","generatePalette","primaryColor","adjustForLuminance","primaryRgba","primaryScaleFunc","getScale","primaryScale","desaturate","adjustedPrimaryScale","adjustBrightnessForLuminance","secondaryColor","saturate","adjustHue","secondaryScaleFunc","secondaryScale","adjustedSecondaryScale","currentColor","currentLuminance","getLuminance","adjustmentAttempts","MAX_ATTEMPTS","lighten","darken","isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath"],"mappings":";;AAwCO,MAAMA,IAA2B;AAAA,EACtC,OAAO;AAAA,IACL,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HTEST:r.GRAYSCALE.GRAY_LIGHTEST,PRIMARY_SUPER_LIGHT:r.GRAYSCALE.GRAY_SUPER_LIGHT},SECONDARY:{SECONDARY_SUPER_DARK:r.GRAYSCALE.GRAY_SUPER_DARK,SECONDARY_DARK:r.GRAYSCALE.GRAY_DARK,SECONDARY_MEDIUM:r.GRAYSCALE.GRAY_MEDIUM,SECONDARY_MEDIUM_LIGHT:r.GRAYSCALE.GRAY_MEDIUM_LIGHT,SECONDARY_LIGHT:r.GRAYSCALE.GRAY_LIGHT,SECONDARY_LIGHTEST:r.GRAYSCALE.GRAY_LIGHTEST,SECONDARY_SUPER_LIGHT:r.GRAYSCALE.GRAY_SUPER_LIGHT}},G=(t,n)=>n===void 0?`rgb(${t[0]}, ${t[1]}, ${t[2]})`:`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n})`,D=(t,n)=>R.toRgba(R.transparentize(t,n)),Y=([t,n,e])=>t*.2126+n*.7152+e*.0722,L=t=>t.map(n=>255-n),l=(t,n)=>{const e=Y(t),A=Y(n);return(Math.max(e,A)+.05)/(Math.min(e,A)+.05)},T=(t,n=4.5)=>{const e=L(t);if(l(t,e)>=n)return e;const a=Y(t),o=a<128;if(o&&a>255/n)return[255,255,255];const _=Y(e),S=(Math.min(a,_)+.05)*n-(Math.max(a,_)+.05);return o?e.map(s=>Math.min(255,Math.round(s+S))):e.map(s=>Math.max(0,Math.round(s-S)))},P=(t,n=!0)=>{const e=G(t),A=R.getScale("#FFFFFF",e,"#000000"),a=Array.from({length:12},(E,I)=>{const i=A(I/11);return R.toRgba(R.desaturate(i,.1))}),o=n?a.map(E=>R.toRgba(R.desaturate(M(E),.1))):a,_=R.toRgba(R.saturate(R.adjustHue(e,180),1)),S=R.getScale("#FFFFFF",_,"#000000"),s=Array.from({length:12},(E,I)=>{const i=S(I/11);return R.toRgba(R.desaturate(i,.1))}),c=n?s.map(E=>R.toRgba(R.desaturate(M(E),.1))):s;return{BRAND:{PRIMARY:o[5],PRIMARY_LIGHT:o[3],SECONDARY:c[4]},PRIMARY:{PRIMARY_SUPER_DARK:a[10],PRIMARY_DARK:a[9],PRIMARY_MEDIUM:o[7],PRIMARY_MEDIUM_LIGHT:o[6],PRIMARY_LIGHT:o[5],PRIMARY_LIGHTEST:o[4],PRIMARY_SUPER_LIGHT:o[3]},SECONDARY:{SECONDARY_SUPER_DARK:s[10],SECONDARY_DARK:s[9],SECONDARY_MEDIUM:c[7],SECONDARY_MEDIUM_LIGHT:c[6],SECONDARY_LIGHT:c[5],SECONDARY_LIGHTEST:c[4],SECONDARY_SUPER_LIGHT:c[3]}}},M=t=>{let n=t,e=R.getLuminance(R.toRgba(n)),A=0;const a=6;for(;e<.16&&A<a;)A++,n=R.lighten(n,.1),e=R.getLuminance(R.toRgba(n));for(;e>.6&&A<a;)A++,n=R.darken(n,.1),e=R.getLuminance(R.toRgba(n));return n},C=t=>typeof t=="string"||t instanceof String;function m(...t){return t.filter(C).join(" ")}const H=t=>{if(/^https?:\/\//.test(t)){const n=document.createElement("a");return n.href=t,n.hostname}return window.location.hostname},d=t=>{const n=window.location.hostname,e=H(t);return n!==e},g=(t,n)=>{if(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.button&&t.button!==0)return;t.preventDefault();const e=n.startsWith("/")?n:`/${n}`;window.history.pushState({},"",e),window.dispatchEvent(new PopStateEvent("popstate"))};exports.DEFAULT_PALETTE=u;exports.arrayToRgbString=G;exports.contrastColor=T;exports.csx=m;exports.generatePalette=P;exports.handleInternalNavigation=g;exports.isUrlExternal=d;exports.luminance=Y;exports.transparentize=D;
|
|
2
|
+
//# sourceMappingURL=utils-HYp3o7mD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-HYp3o7mD.js","sources":["../src/utils/color.ts","../src/utils/utils.ts"],"sourcesContent":["import { COLORS } from \"../constants\";\r\nimport {\r\n adjustHue,\r\n getLuminance,\r\n getScale,\r\n lighten,\r\n saturate,\r\n transparentize as _transparentize,\r\n desaturate,\r\n} from \"color2k\";\r\nimport { darken, toRgba } from \"color2k\";\r\n\r\nexport type RGBArray = [number, number, number];\r\n\r\nexport type Palette = {\r\n BRAND: {\r\n PRIMARY: string;\r\n PRIMARY_LIGHT: string;\r\n SECONDARY: string;\r\n };\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: string;\r\n PRIMARY_DARK: string;\r\n PRIMARY_MEDIUM: string;\r\n PRIMARY_MEDIUM_LIGHT: string;\r\n PRIMARY_LIGHT: string;\r\n PRIMARY_LIGHTEST: string;\r\n PRIMARY_SUPER_LIGHT: string;\r\n };\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: string;\r\n SECONDARY_DARK: string;\r\n SECONDARY_MEDIUM: string;\r\n SECONDARY_MEDIUM_LIGHT: string;\r\n SECONDARY_LIGHT: string;\r\n SECONDARY_LIGHTEST: string;\r\n SECONDARY_SUPER_LIGHT: string;\r\n };\r\n};\r\n\r\nexport const DEFAULT_PALETTE: Palette = {\r\n BRAND: {\r\n PRIMARY: COLORS.BRAND.PRIMARY,\r\n PRIMARY_LIGHT: COLORS.BRAND.PRIMARY_LIGHT,\r\n SECONDARY: COLORS.BRAND.SECONDARY,\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n PRIMARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n PRIMARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n PRIMARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n PRIMARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n PRIMARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n PRIMARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n SECONDARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n SECONDARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n SECONDARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n SECONDARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n SECONDARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n SECONDARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n // Success, Warning & Danger palettes go here...\r\n};\r\n\r\n/**\r\n * Converts an RGB array to a CSS string representation.\r\n * @param rgb - The RGB array to convert.\r\n * @param opacity - Optional opacity value.\r\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\r\n */\r\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\r\n return opacity === undefined\r\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\r\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\r\n};\r\n\r\n/**\r\n * Transparentizes an input color and returns the result after adjustment to ensure a minimum contrast ratio.\r\n *\r\n * @param color - The color string to transparentize.\r\n * @param amount - The amount to increase the opacity of the color by, given as a decimal between 0 and 1.\r\n * @returns An RGBA color string.\r\n */\r\nexport const transparentize = (color: string, amount: number): string => {\r\n return toRgba(_transparentize(color, amount));\r\n};\r\n\r\n/**\r\n\r\n/**\r\n * Calculates the relative luminance of an RGB color according to WCAG 2.2 specifications.\r\n\r\n * This is used in calculating contrast ratios between colors.\r\n *\r\n * @param param0 - RGB color array containing red, green and blue values (0-255)\r\n * @returns The relative luminance value\r\n * @see formula from https://www.w3.org/WAI/WCAG22/Techniques/general/G18 (see step 1 in `Procedure`)\r\n */\r\nexport const luminance = ([r, g, b]: RGBArray): number => {\r\n return r * 0.2126 + g * 0.7152 + b * 0.0722;\r\n};\r\n\r\nconst invertColor = (rgb: RGBArray): RGBArray => {\r\n return rgb.map((value) => 255 - value) as RGBArray;\r\n};\r\n\r\nconst contrastRatio = (color1: RGBArray, color2: RGBArray): number => {\r\n const luminance1 = luminance(color1);\r\n const luminance2 = luminance(color2);\r\n\r\n return (\r\n (Math.max(luminance1, luminance2) + 0.05) /\r\n (Math.min(luminance1, luminance2) + 0.05)\r\n );\r\n};\r\n\r\n/**\r\n * Inverts an input color and returns the result after adjustment to ensure a minimum contrast ratio.\r\n *\r\n * @param color - The RGB color array to invert.\r\n * @param minContrast - The contrast ratio to exceed. Defaults to 4.5, which is the minimum for text to be considered accessible.\r\n */\r\n\r\nexport const contrastColor = (\r\n color: RGBArray,\r\n minContrast: number = 4.5\r\n): RGBArray => {\r\n const newColor = invertColor(color);\r\n const contrast = contrastRatio(color, newColor);\r\n if (contrast >= minContrast) return newColor;\r\n\r\n const colorLuminance = luminance(color);\r\n const isColorDark = colorLuminance < 128;\r\n\r\n if (isColorDark && colorLuminance > 255 / minContrast) {\r\n return [255, 255, 255]; // not dark enough to find color meeting minimum contrast, return white\r\n }\r\n\r\n const newColorLuminance = luminance(newColor);\r\n\r\n const difference =\r\n (Math.min(colorLuminance, newColorLuminance) + 0.05) * minContrast -\r\n (Math.max(colorLuminance, newColorLuminance) + 0.05);\r\n\r\n return isColorDark\r\n ? (newColor.map((value) =>\r\n Math.min(255, Math.round(value + difference))\r\n ) as RGBArray)\r\n : (newColor.map((value) =>\r\n Math.max(0, Math.round(value - difference))\r\n ) as RGBArray);\r\n};\r\n\r\n/**\r\n * Generates a complete color palette based on a primary color input.\r\n * The palette includes primary and secondary color scales with varying shades.\r\n *\r\n * @param primaryColor - The base RGB color array to generate the palette from\r\n * @param adjustForLuminance - Whether to adjust the generated colors for better luminance/contrast.\r\n * Defaults to true.\r\n * @returns A Palette object containing:\r\n * - BRAND colors (primary, light primary, and secondary)\r\n * - PRIMARY scale (7 shades from super dark to super light)\r\n * - SECONDARY scale (7 shades from super dark to super light)\r\n *\r\n * The function:\r\n * 1. Creates a 12-color scale from white to the primary color to black\r\n * 2. Generates a complementary secondary color by shifting the hue 180 degrees\r\n * 3. Creates another 12-color scale for the secondary color\r\n * 4. Maps specific positions from these scales to create the final palette structure\r\n */\r\nexport const generatePalette = (\r\n primaryColor: RGBArray,\r\n adjustForLuminance: boolean = true\r\n): Palette => {\r\n const primaryRgba = arrayToRgbString(primaryColor);\r\n\r\n const primaryScaleFunc = getScale(\"#FFFFFF\", primaryRgba, \"#000000\");\r\n const primaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = primaryScaleFunc(i / 11);\r\n return toRgba(desaturate(color, 0.1));\r\n });\r\n\r\n const adjustedPrimaryScale = adjustForLuminance\r\n ? primaryScale.map((color) =>\r\n toRgba(desaturate(adjustBrightnessForLuminance(color), 0.1))\r\n )\r\n : primaryScale;\r\n\r\n const secondaryColor = toRgba(saturate(adjustHue(primaryRgba, 180), 1));\r\n\r\n const secondaryScaleFunc = getScale(\"#FFFFFF\", secondaryColor, \"#000000\");\r\n const secondaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = secondaryScaleFunc(i / 11);\r\n return toRgba(desaturate(color, 0.1));\r\n });\r\n\r\n const adjustedSecondaryScale = adjustForLuminance\r\n ? secondaryScale.map((color) =>\r\n toRgba(desaturate(adjustBrightnessForLuminance(color), 0.1))\r\n )\r\n : secondaryScale;\r\n\r\n return {\r\n BRAND: {\r\n PRIMARY: adjustedPrimaryScale[5],\r\n PRIMARY_LIGHT: adjustedPrimaryScale[3],\r\n SECONDARY: adjustedSecondaryScale[4],\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: primaryScale[10],\r\n PRIMARY_DARK: primaryScale[9],\r\n PRIMARY_MEDIUM: adjustedPrimaryScale[7],\r\n PRIMARY_MEDIUM_LIGHT: adjustedPrimaryScale[6],\r\n PRIMARY_LIGHT: adjustedPrimaryScale[5],\r\n PRIMARY_LIGHTEST: adjustedPrimaryScale[4],\r\n PRIMARY_SUPER_LIGHT: adjustedPrimaryScale[3],\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: secondaryScale[10],\r\n SECONDARY_DARK: secondaryScale[9],\r\n SECONDARY_MEDIUM: adjustedSecondaryScale[7],\r\n SECONDARY_MEDIUM_LIGHT: adjustedSecondaryScale[6],\r\n SECONDARY_LIGHT: adjustedSecondaryScale[5],\r\n SECONDARY_LIGHTEST: adjustedSecondaryScale[4],\r\n SECONDARY_SUPER_LIGHT: adjustedSecondaryScale[3],\r\n },\r\n };\r\n};\r\n\r\nconst adjustBrightnessForLuminance = (color: string): string => {\r\n let currentColor = color;\r\n let currentLuminance = getLuminance(toRgba(currentColor));\r\n let adjustmentAttempts = 0;\r\n const MAX_ATTEMPTS = 6;\r\n\r\n while (currentLuminance < 0.16 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = lighten(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n while (currentLuminance > 0.6 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = darken(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n return currentColor;\r\n};\r\n","const isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\n/**\r\n * [getLinkHost] - get the host of a link.\r\n * Referenced from is-url-external npm package\r\n * https://github.com/mrded/is-url-external/blob/master/index.js\r\n */\r\nconst getLinkHost = (url) => {\r\n if (/^https?:\\/\\//.test(url)) {\r\n // Absolute URL.\r\n // The easy way to parse an URL, is to create <a> element.\r\n // @see: https://gist.github.com/jlong/2428561\r\n const parser = document.createElement(\"a\");\r\n parser.href = url;\r\n return parser.hostname;\r\n }\r\n return window.location.hostname;\r\n};\r\n\r\n/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url) => {\r\n const host = window.location.hostname;\r\n const linkHost = getLinkHost(url);\r\n\r\n return host !== linkHost;\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n"],"names":["DEFAULT_PALETTE","COLORS.BRAND","COLORS.GRAYSCALE","arrayToRgbString","rgb","opacity","transparentize","color","amount","toRgba","_transparentize","luminance","r","g","b","invertColor","value","contrastRatio","color1","color2","luminance1","luminance2","contrastColor","minContrast","newColor","colorLuminance","isColorDark","newColorLuminance","difference","generatePalette","primaryColor","adjustForLuminance","primaryRgba","primaryScaleFunc","getScale","primaryScale","_","i","desaturate","adjustedPrimaryScale","adjustBrightnessForLuminance","secondaryColor","saturate","adjustHue","secondaryScaleFunc","secondaryScale","adjustedSecondaryScale","currentColor","currentLuminance","getLuminance","adjustmentAttempts","MAX_ATTEMPTS","lighten","darken","isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath"],"mappings":"0EAwCaA,EAA2B,CACtC,MAAO,CACL,QAASC,EAAa,MAAA,QACtB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I,EAAeC,GAAQ,CACvB,GAAA,eAAe,KAAKA,CAAG,EAAG,CAItB,MAAAC,EAAS,SAAS,cAAc,GAAG,EACzC,OAAAA,EAAO,KAAOD,EACPC,EAAO,QAChB,CACA,OAAO,OAAO,SAAS,QACzB,EAKaC,EAAiBF,GAAQ,CAC9B,MAAAG,EAAO,OAAO,SAAS,SACvBC,EAAWL,EAAYC,CAAG,EAEhC,OAAOG,IAASC,CAClB,EAaaC,EAA2B,CACtCC,EACAC,IACG,CAOH,GALID,EAAE,SAAWA,EAAE,QAAUA,EAAE,SAAWA,EAAE,UAKxCA,EAAE,QAAUA,EAAE,SAAW,EAC3B,OAGFA,EAAE,eAAe,EAGjB,MAAME,EAAeD,EAAG,WAAW,GAAG,EAAIA,EAAK,IAAIA,CAAE,GACrD,OAAO,QAAQ,UAAU,CAAC,EAAG,GAAIC,CAAY,EAC7C,OAAO,cAAc,IAAI,cAAc,UAAU,CAAC,CACpD"}
|
package/dist/utils.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils-HYp3o7mD.js");exports.DEFAULT_PALETTE=e.DEFAULT_PALETTE;exports.arrayToRgbString=e.arrayToRgbString;exports.contrastColor=e.contrastColor;exports.csx=e.csx;exports.generatePalette=e.generatePalette;exports.handleInternalNavigation=e.handleInternalNavigation;exports.isUrlExternal=e.isUrlExternal;exports.luminance=e.luminance;exports.transparentize=e.transparentize;
|
|
2
2
|
//# sourceMappingURL=utils.cjs.js.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -57,7 +57,10 @@ export declare const handleInternalNavigation: (e: React.MouseEvent<HTMLAnchorEl
|
|
|
57
57
|
export declare const isUrlExternal: (url: any) => boolean;
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
+
|
|
61
|
+
/**
|
|
60
62
|
* Calculates the relative luminance of an RGB color according to WCAG 2.2 specifications.
|
|
63
|
+
|
|
61
64
|
* This is used in calculating contrast ratios between colors.
|
|
62
65
|
*
|
|
63
66
|
* @param param0 - RGB color array containing red, green and blue values (0-255)
|
|
@@ -94,6 +97,15 @@ export declare type Palette = {
|
|
|
94
97
|
|
|
95
98
|
export declare type RGBArray = [number, number, number];
|
|
96
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Transparentizes an input color and returns the result after adjustment to ensure a minimum contrast ratio.
|
|
102
|
+
*
|
|
103
|
+
* @param color - The color string to transparentize.
|
|
104
|
+
* @param amount - The amount to increase the opacity of the color by, given as a decimal between 0 and 1.
|
|
105
|
+
* @returns An RGBA color string.
|
|
106
|
+
*/
|
|
107
|
+
export declare const transparentize: (color: string, amount: number) => string;
|
|
108
|
+
|
|
97
109
|
export { }
|
|
98
110
|
|
|
99
111
|
|
package/dist/utils.es.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { D as s, a as
|
|
1
|
+
import { D as s, a as t, c as e, b as n, g as l, h as i, i as o, l as g, t as c } from "./utils-CfmTFcgh.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as DEFAULT_PALETTE,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
t as arrayToRgbString,
|
|
5
|
+
e as contrastColor,
|
|
6
|
+
n as csx,
|
|
7
7
|
l as generatePalette,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
g as luminance
|
|
8
|
+
i as handleInternalNavigation,
|
|
9
|
+
o as isUrlExternal,
|
|
10
|
+
g as luminance,
|
|
11
|
+
c as transparentize
|
|
11
12
|
};
|
|
12
13
|
//# sourceMappingURL=utils.es.js.map
|
package/package.json
CHANGED
package/dist/utils-B_UbuIoU.mjs
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { B as i, G as e } from "./colors-Dwh4VIMR.mjs";
|
|
2
|
-
import { getScale as S, toRgba as A, saturate as u, adjustHue as G, getLuminance as D, lighten as P, darken as T } from "color2k";
|
|
3
|
-
const d = {
|
|
4
|
-
BRAND: {
|
|
5
|
-
PRIMARY: i.PRIMARY,
|
|
6
|
-
PRIMARY_LIGHT: i.PRIMARY_LIGHT,
|
|
7
|
-
SECONDARY: i.SECONDARY
|
|
8
|
-
},
|
|
9
|
-
PRIMARY: {
|
|
10
|
-
PRIMARY_SUPER_DARK: e.GRAY_SUPER_DARK,
|
|
11
|
-
PRIMARY_DARK: e.GRAY_DARK,
|
|
12
|
-
PRIMARY_MEDIUM: e.GRAY_MEDIUM,
|
|
13
|
-
PRIMARY_MEDIUM_LIGHT: e.GRAY_MEDIUM_LIGHT,
|
|
14
|
-
PRIMARY_LIGHT: e.GRAY_LIGHT,
|
|
15
|
-
PRIMARY_LIGHTEST: e.GRAY_LIGHTEST,
|
|
16
|
-
PRIMARY_SUPER_LIGHT: e.GRAY_SUPER_LIGHT
|
|
17
|
-
},
|
|
18
|
-
SECONDARY: {
|
|
19
|
-
SECONDARY_SUPER_DARK: e.GRAY_SUPER_DARK,
|
|
20
|
-
SECONDARY_DARK: e.GRAY_DARK,
|
|
21
|
-
SECONDARY_MEDIUM: e.GRAY_MEDIUM,
|
|
22
|
-
SECONDARY_MEDIUM_LIGHT: e.GRAY_MEDIUM_LIGHT,
|
|
23
|
-
SECONDARY_LIGHT: e.GRAY_LIGHT,
|
|
24
|
-
SECONDARY_LIGHTEST: e.GRAY_LIGHTEST,
|
|
25
|
-
SECONDARY_SUPER_LIGHT: e.GRAY_SUPER_LIGHT
|
|
26
|
-
}
|
|
27
|
-
// Success, Warning & Danger palettes go here...
|
|
28
|
-
}, l = (t, n) => n === void 0 ? `rgb(${t[0]}, ${t[1]}, ${t[2]})` : `rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n})`, I = ([t, n, R]) => t * 0.2126 + n * 0.7152 + R * 0.0722, L = (t) => t.map((n) => 255 - n), m = (t, n) => {
|
|
29
|
-
const R = I(t), a = I(n);
|
|
30
|
-
return (Math.max(R, a) + 0.05) / (Math.min(R, a) + 0.05);
|
|
31
|
-
}, p = (t, n = 4.5) => {
|
|
32
|
-
const R = L(t);
|
|
33
|
-
if (m(t, R) >= n) return R;
|
|
34
|
-
const r = I(t), s = r < 128;
|
|
35
|
-
if (s && r > 255 / n)
|
|
36
|
-
return [255, 255, 255];
|
|
37
|
-
const c = I(R), _ = (Math.min(r, c) + 0.05) * n - (Math.max(r, c) + 0.05);
|
|
38
|
-
return s ? R.map(
|
|
39
|
-
(o) => Math.min(255, Math.round(o + _))
|
|
40
|
-
) : R.map(
|
|
41
|
-
(o) => Math.max(0, Math.round(o - _))
|
|
42
|
-
);
|
|
43
|
-
}, O = (t, n = !0) => {
|
|
44
|
-
const R = l(t), a = S("#FFFFFF", R, "#000000"), r = Array.from({ length: 12 }, (E, M) => {
|
|
45
|
-
const Y = a(M / 11);
|
|
46
|
-
return A(Y);
|
|
47
|
-
}), s = n ? r.map((E) => A(H(E))) : r, c = A(u(G(R, 180), 1)), _ = S("#FFFFFF", c, "#000000"), o = Array.from({ length: 12 }, (E, M) => {
|
|
48
|
-
const Y = _(M / 11);
|
|
49
|
-
return A(Y);
|
|
50
|
-
});
|
|
51
|
-
return {
|
|
52
|
-
BRAND: {
|
|
53
|
-
PRIMARY: r[5],
|
|
54
|
-
PRIMARY_LIGHT: r[3],
|
|
55
|
-
SECONDARY: o[4]
|
|
56
|
-
},
|
|
57
|
-
PRIMARY: {
|
|
58
|
-
PRIMARY_SUPER_DARK: r[10],
|
|
59
|
-
PRIMARY_DARK: r[9],
|
|
60
|
-
PRIMARY_MEDIUM: s[7],
|
|
61
|
-
PRIMARY_MEDIUM_LIGHT: s[6],
|
|
62
|
-
PRIMARY_LIGHT: s[5],
|
|
63
|
-
PRIMARY_LIGHTEST: s[4],
|
|
64
|
-
PRIMARY_SUPER_LIGHT: s[3]
|
|
65
|
-
},
|
|
66
|
-
SECONDARY: {
|
|
67
|
-
SECONDARY_SUPER_DARK: o[10],
|
|
68
|
-
SECONDARY_DARK: o[9],
|
|
69
|
-
SECONDARY_MEDIUM: o[7],
|
|
70
|
-
SECONDARY_MEDIUM_LIGHT: o[6],
|
|
71
|
-
SECONDARY_LIGHT: o[5],
|
|
72
|
-
SECONDARY_LIGHTEST: o[4],
|
|
73
|
-
SECONDARY_SUPER_LIGHT: o[3]
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}, H = (t) => {
|
|
77
|
-
let n = t, R = D(A(n)), a = 0;
|
|
78
|
-
const r = 6;
|
|
79
|
-
for (; R < 0.16 && a < r; )
|
|
80
|
-
a++, n = P(n, 0.1), R = D(A(n));
|
|
81
|
-
for (; R > 0.6 && a < r; )
|
|
82
|
-
a++, n = T(n, 0.1), R = D(A(n));
|
|
83
|
-
return n;
|
|
84
|
-
}, h = (t) => typeof t == "string" || t instanceof String;
|
|
85
|
-
function f(...t) {
|
|
86
|
-
return t.filter(h).join(" ");
|
|
87
|
-
}
|
|
88
|
-
const U = (t) => {
|
|
89
|
-
if (/^https?:\/\//.test(t)) {
|
|
90
|
-
const n = document.createElement("a");
|
|
91
|
-
return n.href = t, n.hostname;
|
|
92
|
-
}
|
|
93
|
-
return window.location.hostname;
|
|
94
|
-
}, F = (t) => {
|
|
95
|
-
const n = window.location.hostname, R = U(t);
|
|
96
|
-
return n !== R;
|
|
97
|
-
}, K = (t, n) => {
|
|
98
|
-
if (t.metaKey || t.altKey || t.ctrlKey || t.shiftKey || t.button && t.button !== 0)
|
|
99
|
-
return;
|
|
100
|
-
t.preventDefault();
|
|
101
|
-
const R = n.startsWith("/") ? n : `/${n}`;
|
|
102
|
-
window.history.pushState({}, "", R), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
103
|
-
};
|
|
104
|
-
export {
|
|
105
|
-
d as D,
|
|
106
|
-
l as a,
|
|
107
|
-
f as b,
|
|
108
|
-
p as c,
|
|
109
|
-
O as g,
|
|
110
|
-
K as h,
|
|
111
|
-
F as i,
|
|
112
|
-
I as l
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=utils-B_UbuIoU.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-B_UbuIoU.mjs","sources":["../src/utils/color.ts","../src/utils/utils.ts"],"sourcesContent":["import { COLORS } from \"../constants\";\r\nimport { adjustHue, getLuminance, getScale, lighten, saturate } from \"color2k\";\r\nimport { darken, toRgba } from \"color2k\";\r\n\r\nexport type RGBArray = [number, number, number];\r\n\r\nexport type Palette = {\r\n BRAND: {\r\n PRIMARY: string;\r\n PRIMARY_LIGHT: string;\r\n SECONDARY: string;\r\n };\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: string;\r\n PRIMARY_DARK: string;\r\n PRIMARY_MEDIUM: string;\r\n PRIMARY_MEDIUM_LIGHT: string;\r\n PRIMARY_LIGHT: string;\r\n PRIMARY_LIGHTEST: string;\r\n PRIMARY_SUPER_LIGHT: string;\r\n };\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: string;\r\n SECONDARY_DARK: string;\r\n SECONDARY_MEDIUM: string;\r\n SECONDARY_MEDIUM_LIGHT: string;\r\n SECONDARY_LIGHT: string;\r\n SECONDARY_LIGHTEST: string;\r\n SECONDARY_SUPER_LIGHT: string;\r\n };\r\n};\r\n\r\nexport const DEFAULT_PALETTE: Palette = {\r\n BRAND: {\r\n PRIMARY: COLORS.BRAND.PRIMARY,\r\n PRIMARY_LIGHT: COLORS.BRAND.PRIMARY_LIGHT,\r\n SECONDARY: COLORS.BRAND.SECONDARY,\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n PRIMARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n PRIMARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n PRIMARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n PRIMARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n PRIMARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n PRIMARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n SECONDARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n SECONDARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n SECONDARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n SECONDARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n SECONDARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n SECONDARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n // Success, Warning & Danger palettes go here...\r\n};\r\n\r\n/**\r\n * Converts an RGB array to a CSS string representation.\r\n * @param rgb - The RGB array to convert.\r\n * @param opacity - Optional opacity value.\r\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\r\n */\r\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\r\n return opacity === undefined\r\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\r\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\r\n};\r\n\r\n/**\r\n * Calculates the relative luminance of an RGB color according to WCAG 2.2 specifications.\r\n * This is used in calculating contrast ratios between colors.\r\n *\r\n * @param param0 - RGB color array containing red, green and blue values (0-255)\r\n * @returns The relative luminance value\r\n * @see formula from https://www.w3.org/WAI/WCAG22/Techniques/general/G18 (see step 1 in `Procedure`)\r\n */\r\nexport const luminance = ([r, g, b]: RGBArray): number => {\r\n return r * 0.2126 + g * 0.7152 + b * 0.0722;\r\n};\r\n\r\nconst invertColor = (rgb: RGBArray): RGBArray => {\r\n return rgb.map((value) => 255 - value) as RGBArray;\r\n};\r\n\r\nconst contrastRatio = (color1: RGBArray, color2: RGBArray): number => {\r\n const luminance1 = luminance(color1);\r\n const luminance2 = luminance(color2);\r\n\r\n return (\r\n (Math.max(luminance1, luminance2) + 0.05) /\r\n (Math.min(luminance1, luminance2) + 0.05)\r\n );\r\n};\r\n\r\n/**\r\n * Inverts an input color and returns the result after adjustment to ensure a minimum contrast ratio.\r\n *\r\n * @param color - The RGB color array to invert.\r\n * @param minContrast - The contrast ratio to exceed. Defaults to 4.5, which is the minimum for text to be considered accessible.\r\n */\r\n\r\nexport const contrastColor = (\r\n color: RGBArray,\r\n minContrast: number = 4.5\r\n): RGBArray => {\r\n const newColor = invertColor(color);\r\n const contrast = contrastRatio(color, newColor);\r\n if (contrast >= minContrast) return newColor;\r\n\r\n const colorLuminance = luminance(color);\r\n const isColorDark = colorLuminance < 128;\r\n\r\n if (isColorDark && colorLuminance > 255 / minContrast) {\r\n return [255, 255, 255]; // not dark enough to find color meeting minimum contrast, return white\r\n }\r\n\r\n const newColorLuminance = luminance(newColor);\r\n\r\n const difference =\r\n (Math.min(colorLuminance, newColorLuminance) + 0.05) * minContrast -\r\n (Math.max(colorLuminance, newColorLuminance) + 0.05);\r\n\r\n return isColorDark\r\n ? (newColor.map((value) =>\r\n Math.min(255, Math.round(value + difference))\r\n ) as RGBArray)\r\n : (newColor.map((value) =>\r\n Math.max(0, Math.round(value - difference))\r\n ) as RGBArray);\r\n};\r\n\r\n/**\r\n * Generates a complete color palette based on a primary color input.\r\n * The palette includes primary and secondary color scales with varying shades.\r\n *\r\n * @param primaryColor - The base RGB color array to generate the palette from\r\n * @param adjustForLuminance - Whether to adjust the generated colors for better luminance/contrast.\r\n * Defaults to true.\r\n * @returns A Palette object containing:\r\n * - BRAND colors (primary, light primary, and secondary)\r\n * - PRIMARY scale (7 shades from super dark to super light)\r\n * - SECONDARY scale (7 shades from super dark to super light)\r\n *\r\n * The function:\r\n * 1. Creates a 12-color scale from white to the primary color to black\r\n * 2. Generates a complementary secondary color by shifting the hue 180 degrees\r\n * 3. Creates another 12-color scale for the secondary color\r\n * 4. Maps specific positions from these scales to create the final palette structure\r\n */\r\nexport const generatePalette = (\r\n primaryColor: RGBArray,\r\n adjustForLuminance: boolean = true\r\n): Palette => {\r\n const primaryRgba = arrayToRgbString(primaryColor);\r\n\r\n const primaryScaleFunc = getScale(\"#FFFFFF\", primaryRgba, \"#000000\");\r\n const primaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = primaryScaleFunc(i / 11);\r\n return toRgba(color);\r\n });\r\n\r\n const adjustedPrimaryScale = adjustForLuminance\r\n ? primaryScale.map((color) => toRgba(adjustBrightnessForLuminance(color)))\r\n : primaryScale;\r\n\r\n const secondaryColor = toRgba(saturate(adjustHue(primaryRgba, 180), 1));\r\n\r\n const secondaryScaleFunc = getScale(\"#FFFFFF\", secondaryColor, \"#000000\");\r\n const secondaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = secondaryScaleFunc(i / 11);\r\n return toRgba(color);\r\n });\r\n\r\n return {\r\n BRAND: {\r\n PRIMARY: primaryScale[5],\r\n PRIMARY_LIGHT: primaryScale[3],\r\n SECONDARY: secondaryScale[4],\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: primaryScale[10],\r\n PRIMARY_DARK: primaryScale[9],\r\n PRIMARY_MEDIUM: adjustedPrimaryScale[7],\r\n PRIMARY_MEDIUM_LIGHT: adjustedPrimaryScale[6],\r\n PRIMARY_LIGHT: adjustedPrimaryScale[5],\r\n PRIMARY_LIGHTEST: adjustedPrimaryScale[4],\r\n PRIMARY_SUPER_LIGHT: adjustedPrimaryScale[3],\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: secondaryScale[10],\r\n SECONDARY_DARK: secondaryScale[9],\r\n SECONDARY_MEDIUM: secondaryScale[7],\r\n SECONDARY_MEDIUM_LIGHT: secondaryScale[6],\r\n SECONDARY_LIGHT: secondaryScale[5],\r\n SECONDARY_LIGHTEST: secondaryScale[4],\r\n SECONDARY_SUPER_LIGHT: secondaryScale[3],\r\n },\r\n };\r\n};\r\n\r\nconst adjustBrightnessForLuminance = (color: string): string => {\r\n let currentColor = color;\r\n let currentLuminance = getLuminance(toRgba(currentColor));\r\n let adjustmentAttempts = 0;\r\n const MAX_ATTEMPTS = 6;\r\n\r\n while (currentLuminance < 0.16 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = lighten(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n while (currentLuminance > 0.6 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = darken(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n return currentColor;\r\n};\r\n","const isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\n/**\r\n * [getLinkHost] - get the host of a link.\r\n * Referenced from is-url-external npm package\r\n * https://github.com/mrded/is-url-external/blob/master/index.js\r\n */\r\nconst getLinkHost = (url) => {\r\n if (/^https?:\\/\\//.test(url)) {\r\n // Absolute URL.\r\n // The easy way to parse an URL, is to create <a> element.\r\n // @see: https://gist.github.com/jlong/2428561\r\n const parser = document.createElement(\"a\");\r\n parser.href = url;\r\n return parser.hostname;\r\n }\r\n return window.location.hostname;\r\n};\r\n\r\n/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url) => {\r\n const host = window.location.hostname;\r\n const linkHost = getLinkHost(url);\r\n\r\n return host !== linkHost;\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n"],"names":["DEFAULT_PALETTE","COLORS.BRAND","COLORS.GRAYSCALE","arrayToRgbString","rgb","opacity","luminance","r","g","b","invertColor","value","contrastRatio","color1","color2","luminance1","luminance2","contrastColor","color","minContrast","newColor","colorLuminance","isColorDark","newColorLuminance","difference","generatePalette","primaryColor","adjustForLuminance","primaryRgba","primaryScaleFunc","getScale","primaryScale","_","i","toRgba","adjustedPrimaryScale","adjustBrightnessForLuminance","secondaryColor","saturate","adjustHue","secondaryScaleFunc","secondaryScale","currentColor","currentLuminance","getLuminance","adjustmentAttempts","MAX_ATTEMPTS","lighten","darken","isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath"],"mappings":";;AAgCO,MAAMA,IAA2B;AAAA,EACtC,OAAO;AAAA,IACL,SAASC,EAAa;AAAA,IACtB,eAAeA,EAAa;AAAA,IAC5B,WAAWA,EAAa;AAAA,EAC1B;AAAA,EACA,SAAS;AAAA,IACP,oBAAoBC,EAAiB;AAAA,IACrC,cAAcA,EAAiB;AAAA,IAC/B,gBAAgBA,EAAiB;AAAA,IACjC,sBAAsBA,EAAiB;AAAA,IACvC,eAAeA,EAAiB;AAAA,IAChC,kBAAkBA,EAAiB;AAAA,IACnC,qBAAqBA,EAAi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AE,WAAW;AAC3B;AAGF,EAAAA,EAAE,eAAe;AAGjB,QAAME,IAAeD,EAAG,WAAW,GAAG,IAAIA,IAAK,IAAIA,CAAE;AACrD,SAAO,QAAQ,UAAU,CAAC,GAAG,IAAIC,CAAY,GAC7C,OAAO,cAAc,IAAI,cAAc,UAAU,CAAC;AACpD;"}
|
package/dist/utils-DQj80-_6.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./colors-BdogYmJi.js"),A=require("color2k"),M={BRAND:{PRIMARY:e.BRAND.PRIMARY,PRIMARY_LIGHT:e.BRAND.PRIMARY_LIGHT,SECONDARY:e.BRAND.SECONDARY},PRIMARY:{PRIMARY_SUPER_DARK:e.GRAYSCALE.GRAY_SUPER_DARK,PRIMARY_DARK:e.GRAYSCALE.GRAY_DARK,PRIMARY_MEDIUM:e.GRAYSCALE.GRAY_MEDIUM,PRIMARY_MEDIUM_LIGHT:e.GRAYSCALE.GRAY_MEDIUM_LIGHT,PRIMARY_LIGHT:e.GRAYSCALE.GRAY_LIGHT,PRIMARY_LIGHTEST:e.GRAYSCALE.GRAY_LIGHTEST,PRIMARY_SUPER_LIGHT:e.GRAYSCALE.GRAY_SUPER_LIGHT},SECONDARY:{SECONDARY_SUPER_DARK:e.GRAYSCALE.GRAY_SUPER_DARK,SECONDARY_DARK:e.GRAYSCALE.GRAY_DARK,SECONDARY_MEDIUM:e.GRAYSCALE.GRAY_MEDIUM,SECONDARY_MEDIUM_LIGHT:e.GRAYSCALE.GRAY_MEDIUM_LIGHT,SECONDARY_LIGHT:e.GRAYSCALE.GRAY_LIGHT,SECONDARY_LIGHTEST:e.GRAYSCALE.GRAY_LIGHTEST,SECONDARY_SUPER_LIGHT:e.GRAYSCALE.GRAY_SUPER_LIGHT}},i=(t,n)=>n===void 0?`rgb(${t[0]}, ${t[1]}, ${t[2]})`:`rgba(${t[0]}, ${t[1]}, ${t[2]}, ${n})`,s=([t,n,R])=>t*.2126+n*.7152+R*.0722,G=t=>t.map(n=>255-n),L=(t,n)=>{const R=s(t),a=s(n);return(Math.max(R,a)+.05)/(Math.min(R,a)+.05)},D=(t,n=4.5)=>{const R=G(t);if(L(t,R)>=n)return R;const r=s(t),c=r<128;if(c&&r>255/n)return[255,255,255];const E=s(R),Y=(Math.min(r,E)+.05)*n-(Math.max(r,E)+.05);return c?R.map(o=>Math.min(255,Math.round(o+Y))):R.map(o=>Math.max(0,Math.round(o-Y)))},u=(t,n=!0)=>{const R=i(t),a=A.getScale("#FFFFFF",R,"#000000"),r=Array.from({length:12},(_,S)=>{const I=a(S/11);return A.toRgba(I)}),c=n?r.map(_=>A.toRgba(l(_))):r,E=A.toRgba(A.saturate(A.adjustHue(R,180),1)),Y=A.getScale("#FFFFFF",E,"#000000"),o=Array.from({length:12},(_,S)=>{const I=Y(S/11);return A.toRgba(I)});return{BRAND:{PRIMARY:r[5],PRIMARY_LIGHT:r[3],SECONDARY:o[4]},PRIMARY:{PRIMARY_SUPER_DARK:r[10],PRIMARY_DARK:r[9],PRIMARY_MEDIUM:c[7],PRIMARY_MEDIUM_LIGHT:c[6],PRIMARY_LIGHT:c[5],PRIMARY_LIGHTEST:c[4],PRIMARY_SUPER_LIGHT:c[3]},SECONDARY:{SECONDARY_SUPER_DARK:o[10],SECONDARY_DARK:o[9],SECONDARY_MEDIUM:o[7],SECONDARY_MEDIUM_LIGHT:o[6],SECONDARY_LIGHT:o[5],SECONDARY_LIGHTEST:o[4],SECONDARY_SUPER_LIGHT:o[3]}}},l=t=>{let n=t,R=A.getLuminance(A.toRgba(n)),a=0;const r=6;for(;R<.16&&a<r;)a++,n=A.lighten(n,.1),R=A.getLuminance(A.toRgba(n));for(;R>.6&&a<r;)a++,n=A.darken(n,.1),R=A.getLuminance(A.toRgba(n));return n},T=t=>typeof t=="string"||t instanceof String;function P(...t){return t.filter(T).join(" ")}const C=t=>{if(/^https?:\/\//.test(t)){const n=document.createElement("a");return n.href=t,n.hostname}return window.location.hostname},m=t=>{const n=window.location.hostname,R=C(t);return n!==R},H=(t,n)=>{if(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||t.button&&t.button!==0)return;t.preventDefault();const R=n.startsWith("/")?n:`/${n}`;window.history.pushState({},"",R),window.dispatchEvent(new PopStateEvent("popstate"))};exports.DEFAULT_PALETTE=M;exports.arrayToRgbString=i;exports.contrastColor=D;exports.csx=P;exports.generatePalette=u;exports.handleInternalNavigation=H;exports.isUrlExternal=m;exports.luminance=s;
|
|
2
|
-
//# sourceMappingURL=utils-DQj80-_6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils-DQj80-_6.js","sources":["../src/utils/color.ts","../src/utils/utils.ts"],"sourcesContent":["import { COLORS } from \"../constants\";\r\nimport { adjustHue, getLuminance, getScale, lighten, saturate } from \"color2k\";\r\nimport { darken, toRgba } from \"color2k\";\r\n\r\nexport type RGBArray = [number, number, number];\r\n\r\nexport type Palette = {\r\n BRAND: {\r\n PRIMARY: string;\r\n PRIMARY_LIGHT: string;\r\n SECONDARY: string;\r\n };\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: string;\r\n PRIMARY_DARK: string;\r\n PRIMARY_MEDIUM: string;\r\n PRIMARY_MEDIUM_LIGHT: string;\r\n PRIMARY_LIGHT: string;\r\n PRIMARY_LIGHTEST: string;\r\n PRIMARY_SUPER_LIGHT: string;\r\n };\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: string;\r\n SECONDARY_DARK: string;\r\n SECONDARY_MEDIUM: string;\r\n SECONDARY_MEDIUM_LIGHT: string;\r\n SECONDARY_LIGHT: string;\r\n SECONDARY_LIGHTEST: string;\r\n SECONDARY_SUPER_LIGHT: string;\r\n };\r\n};\r\n\r\nexport const DEFAULT_PALETTE: Palette = {\r\n BRAND: {\r\n PRIMARY: COLORS.BRAND.PRIMARY,\r\n PRIMARY_LIGHT: COLORS.BRAND.PRIMARY_LIGHT,\r\n SECONDARY: COLORS.BRAND.SECONDARY,\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n PRIMARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n PRIMARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n PRIMARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n PRIMARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n PRIMARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n PRIMARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: COLORS.GRAYSCALE.GRAY_SUPER_DARK,\r\n SECONDARY_DARK: COLORS.GRAYSCALE.GRAY_DARK,\r\n SECONDARY_MEDIUM: COLORS.GRAYSCALE.GRAY_MEDIUM,\r\n SECONDARY_MEDIUM_LIGHT: COLORS.GRAYSCALE.GRAY_MEDIUM_LIGHT,\r\n SECONDARY_LIGHT: COLORS.GRAYSCALE.GRAY_LIGHT,\r\n SECONDARY_LIGHTEST: COLORS.GRAYSCALE.GRAY_LIGHTEST,\r\n SECONDARY_SUPER_LIGHT: COLORS.GRAYSCALE.GRAY_SUPER_LIGHT,\r\n },\r\n // Success, Warning & Danger palettes go here...\r\n};\r\n\r\n/**\r\n * Converts an RGB array to a CSS string representation.\r\n * @param rgb - The RGB array to convert.\r\n * @param opacity - Optional opacity value.\r\n * @returns A CSS string representation of the RGB array, using `rgb()`, or `rgba()` if an opacity value is provided.\r\n */\r\nexport const arrayToRgbString = (rgb: RGBArray, opacity?: number): string => {\r\n return opacity === undefined\r\n ? `rgb(${rgb[0]}, ${rgb[1]}, ${rgb[2]})`\r\n : `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, ${opacity})`;\r\n};\r\n\r\n/**\r\n * Calculates the relative luminance of an RGB color according to WCAG 2.2 specifications.\r\n * This is used in calculating contrast ratios between colors.\r\n *\r\n * @param param0 - RGB color array containing red, green and blue values (0-255)\r\n * @returns The relative luminance value\r\n * @see formula from https://www.w3.org/WAI/WCAG22/Techniques/general/G18 (see step 1 in `Procedure`)\r\n */\r\nexport const luminance = ([r, g, b]: RGBArray): number => {\r\n return r * 0.2126 + g * 0.7152 + b * 0.0722;\r\n};\r\n\r\nconst invertColor = (rgb: RGBArray): RGBArray => {\r\n return rgb.map((value) => 255 - value) as RGBArray;\r\n};\r\n\r\nconst contrastRatio = (color1: RGBArray, color2: RGBArray): number => {\r\n const luminance1 = luminance(color1);\r\n const luminance2 = luminance(color2);\r\n\r\n return (\r\n (Math.max(luminance1, luminance2) + 0.05) /\r\n (Math.min(luminance1, luminance2) + 0.05)\r\n );\r\n};\r\n\r\n/**\r\n * Inverts an input color and returns the result after adjustment to ensure a minimum contrast ratio.\r\n *\r\n * @param color - The RGB color array to invert.\r\n * @param minContrast - The contrast ratio to exceed. Defaults to 4.5, which is the minimum for text to be considered accessible.\r\n */\r\n\r\nexport const contrastColor = (\r\n color: RGBArray,\r\n minContrast: number = 4.5\r\n): RGBArray => {\r\n const newColor = invertColor(color);\r\n const contrast = contrastRatio(color, newColor);\r\n if (contrast >= minContrast) return newColor;\r\n\r\n const colorLuminance = luminance(color);\r\n const isColorDark = colorLuminance < 128;\r\n\r\n if (isColorDark && colorLuminance > 255 / minContrast) {\r\n return [255, 255, 255]; // not dark enough to find color meeting minimum contrast, return white\r\n }\r\n\r\n const newColorLuminance = luminance(newColor);\r\n\r\n const difference =\r\n (Math.min(colorLuminance, newColorLuminance) + 0.05) * minContrast -\r\n (Math.max(colorLuminance, newColorLuminance) + 0.05);\r\n\r\n return isColorDark\r\n ? (newColor.map((value) =>\r\n Math.min(255, Math.round(value + difference))\r\n ) as RGBArray)\r\n : (newColor.map((value) =>\r\n Math.max(0, Math.round(value - difference))\r\n ) as RGBArray);\r\n};\r\n\r\n/**\r\n * Generates a complete color palette based on a primary color input.\r\n * The palette includes primary and secondary color scales with varying shades.\r\n *\r\n * @param primaryColor - The base RGB color array to generate the palette from\r\n * @param adjustForLuminance - Whether to adjust the generated colors for better luminance/contrast.\r\n * Defaults to true.\r\n * @returns A Palette object containing:\r\n * - BRAND colors (primary, light primary, and secondary)\r\n * - PRIMARY scale (7 shades from super dark to super light)\r\n * - SECONDARY scale (7 shades from super dark to super light)\r\n *\r\n * The function:\r\n * 1. Creates a 12-color scale from white to the primary color to black\r\n * 2. Generates a complementary secondary color by shifting the hue 180 degrees\r\n * 3. Creates another 12-color scale for the secondary color\r\n * 4. Maps specific positions from these scales to create the final palette structure\r\n */\r\nexport const generatePalette = (\r\n primaryColor: RGBArray,\r\n adjustForLuminance: boolean = true\r\n): Palette => {\r\n const primaryRgba = arrayToRgbString(primaryColor);\r\n\r\n const primaryScaleFunc = getScale(\"#FFFFFF\", primaryRgba, \"#000000\");\r\n const primaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = primaryScaleFunc(i / 11);\r\n return toRgba(color);\r\n });\r\n\r\n const adjustedPrimaryScale = adjustForLuminance\r\n ? primaryScale.map((color) => toRgba(adjustBrightnessForLuminance(color)))\r\n : primaryScale;\r\n\r\n const secondaryColor = toRgba(saturate(adjustHue(primaryRgba, 180), 1));\r\n\r\n const secondaryScaleFunc = getScale(\"#FFFFFF\", secondaryColor, \"#000000\");\r\n const secondaryScale = Array.from({ length: 12 }, (_, i) => {\r\n const color = secondaryScaleFunc(i / 11);\r\n return toRgba(color);\r\n });\r\n\r\n return {\r\n BRAND: {\r\n PRIMARY: primaryScale[5],\r\n PRIMARY_LIGHT: primaryScale[3],\r\n SECONDARY: secondaryScale[4],\r\n },\r\n PRIMARY: {\r\n PRIMARY_SUPER_DARK: primaryScale[10],\r\n PRIMARY_DARK: primaryScale[9],\r\n PRIMARY_MEDIUM: adjustedPrimaryScale[7],\r\n PRIMARY_MEDIUM_LIGHT: adjustedPrimaryScale[6],\r\n PRIMARY_LIGHT: adjustedPrimaryScale[5],\r\n PRIMARY_LIGHTEST: adjustedPrimaryScale[4],\r\n PRIMARY_SUPER_LIGHT: adjustedPrimaryScale[3],\r\n },\r\n SECONDARY: {\r\n SECONDARY_SUPER_DARK: secondaryScale[10],\r\n SECONDARY_DARK: secondaryScale[9],\r\n SECONDARY_MEDIUM: secondaryScale[7],\r\n SECONDARY_MEDIUM_LIGHT: secondaryScale[6],\r\n SECONDARY_LIGHT: secondaryScale[5],\r\n SECONDARY_LIGHTEST: secondaryScale[4],\r\n SECONDARY_SUPER_LIGHT: secondaryScale[3],\r\n },\r\n };\r\n};\r\n\r\nconst adjustBrightnessForLuminance = (color: string): string => {\r\n let currentColor = color;\r\n let currentLuminance = getLuminance(toRgba(currentColor));\r\n let adjustmentAttempts = 0;\r\n const MAX_ATTEMPTS = 6;\r\n\r\n while (currentLuminance < 0.16 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = lighten(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n while (currentLuminance > 0.6 && adjustmentAttempts < MAX_ATTEMPTS) {\r\n adjustmentAttempts++;\r\n currentColor = darken(currentColor, 0.1);\r\n currentLuminance = getLuminance(toRgba(currentColor));\r\n }\r\n\r\n return currentColor;\r\n};\r\n","const isString = (x: unknown): boolean =>\r\n typeof x === \"string\" || x instanceof String;\r\n\r\nexport function csx(...classnames: unknown[]): string {\r\n return classnames.filter(isString).join(\" \");\r\n}\r\n\r\n/**\r\n * [getLinkHost] - get the host of a link.\r\n * Referenced from is-url-external npm package\r\n * https://github.com/mrded/is-url-external/blob/master/index.js\r\n */\r\nconst getLinkHost = (url) => {\r\n if (/^https?:\\/\\//.test(url)) {\r\n // Absolute URL.\r\n // The easy way to parse an URL, is to create <a> element.\r\n // @see: https://gist.github.com/jlong/2428561\r\n const parser = document.createElement(\"a\");\r\n parser.href = url;\r\n return parser.hostname;\r\n }\r\n return window.location.hostname;\r\n};\r\n\r\n/**\r\n * [isUrlExternal] - determine if passed absolute url is external to the current domain.\r\n */\r\nexport const isUrlExternal = (url) => {\r\n const host = window.location.hostname;\r\n const linkHost = getLinkHost(url);\r\n\r\n return host !== linkHost;\r\n};\r\n\r\n/**\r\n * Handles internal navigation clicks by preventing default browser behavior and\r\n * programmatically updating the URL and history state.\r\n *\r\n * @param e - The click event from the anchor element\r\n * @param to - The destination path to navigate to\r\n *\r\n * @remarks\r\n * - Converts relative paths to absolute by prepending \"/\" if needed\r\n * - Updates browser history using pushState and dispatches a popstate event\r\n */\r\nexport const handleInternalNavigation = (\r\n e: React.MouseEvent<HTMLAnchorElement>,\r\n to: string\r\n) => {\r\n // Don't handle navigation if modifier keys are pressed\r\n if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) {\r\n return;\r\n }\r\n\r\n // Don't handle middle clicks or right clicks\r\n if (e.button && e.button !== 0) {\r\n return;\r\n }\r\n\r\n e.preventDefault();\r\n\r\n // Handle relative paths\r\n const resolvedPath = to.startsWith(\"/\") ? to : `/${to}`;\r\n window.history.pushState({}, \"\", resolvedPath);\r\n window.dispatchEvent(new PopStateEvent(\"popstate\"));\r\n};\r\n"],"names":["DEFAULT_PALETTE","COLORS.BRAND","COLORS.GRAYSCALE","arrayToRgbString","rgb","opacity","luminance","r","g","b","invertColor","value","contrastRatio","color1","color2","luminance1","luminance2","contrastColor","color","minContrast","newColor","colorLuminance","isColorDark","newColorLuminance","difference","generatePalette","primaryColor","adjustForLuminance","primaryRgba","primaryScaleFunc","getScale","primaryScale","i","toRgba","adjustedPrimaryScale","adjustBrightnessForLuminance","secondaryColor","saturate","adjustHue","secondaryScaleFunc","secondaryScale","currentColor","currentLuminance","getLuminance","adjustmentAttempts","MAX_ATTEMPTS","lighten","darken","isString","x","csx","classnames","getLinkHost","url","parser","isUrlExternal","host","linkHost","handleInternalNavigation","e","to","resolvedPath"],"mappings":"0EAgCaA,EAA2B,CACtC,MAAO,CACL,QAASC,EAAa,MAAA,QACtB,cAAeA,EA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