@aotearoan/neon 10.0.4 → 10.1.0
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/common/utils/NeonColorUtils.cjs.js +2 -0
- package/dist/common/utils/NeonColorUtils.cjs.js.map +1 -0
- package/dist/common/utils/NeonColorUtils.es.js +245 -0
- package/dist/common/utils/NeonColorUtils.es.js.map +1 -0
- package/dist/common/utils/NeonJazziconUtils.cjs.js +2 -0
- package/dist/common/utils/NeonJazziconUtils.cjs.js.map +1 -0
- package/dist/common/utils/NeonJazziconUtils.es.js +160 -0
- package/dist/common/utils/NeonJazziconUtils.es.js.map +1 -0
- package/dist/common/utils/NeonRandomUtils.cjs.js +2 -0
- package/dist/common/utils/NeonRandomUtils.cjs.js.map +1 -0
- package/dist/common/utils/NeonRandomUtils.es.js +33 -0
- package/dist/common/utils/NeonRandomUtils.es.js.map +1 -0
- package/dist/components/presentation/badge/NeonBadge.cjs.js +1 -1
- package/dist/components/presentation/badge/NeonBadge.es.js +13 -8
- package/dist/components/presentation/badge/NeonBadge.es.js.map +1 -1
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js +2 -0
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js.map +1 -0
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js +55 -0
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js.map +1 -0
- package/dist/neon.cjs.js +1 -1
- package/dist/neon.es.js +2 -0
- package/dist/neon.es.js.map +1 -1
- package/dist/src/common/utils/NeonJazziconUtils.d.ts +19 -0
- package/dist/src/common/utils/NeonRandomUtils.d.ts +5 -0
- package/dist/src/components/presentation/badge/NeonBadge.d.ts +18 -1
- package/dist/src/neon.d.ts +2 -0
- package/package.json +1 -1
- package/src/sass/components/_badge.scss +2 -0
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.cjs.js +0 -2
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.cjs.js.map +0 -1
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.es.js +0 -23
- package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.es.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var z=(R,e,a)=>e in R?y(R,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):R[e]=a;var u=(R,e,a)=>(z(R,typeof e!="symbol"?e+"":e,a),a);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=class{static luminance([e,a,r]){const n=[e,a,r].map(o=>(o/=255,o<=.03928?o/12.92:Math.pow((o+.055)/1.055,t.gamma)));return n[0]*t.red+n[1]*t.green+n[2]*t.blue}static toRgb(e){return[Number.parseInt(e.substring(1,3),16),Number.parseInt(e.substring(3,5),16),Number.parseInt(e.substring(5,7),16)]}static rgbToXyz(e){const[a,r,n]=e,o=t.rgbValueToXyz(a),b=t.rgbValueToXyz(r),c=t.rgbValueToXyz(n),i=t.xyzToLab((.4124564*o+.3575761*b+.1804375*c)/t.labXn),h=t.xyzToLab((.2126729*o+.7151522*b+.072175*c)/t.labYn),s=t.xyzToLab((.0193339*o+.119192*b+.9503041*c)/t.labZn);return[i,h,s]}static rgbToLab(e){const[a,r,n]=t.rgbToXyz(e),o=116*r-16;return[Math.max(o,0),500*(a-r),200*(r-n)]}static rgbToHcl(e){const a=t.rgbToLab(e);return t.labToHcl(a)}static isAccessible(e,a){const r=t.contrast(t.toRgb(e),t.toRgb(a)),n={largeAA:!1,largeAAA:!1,normalAA:!1,normalAAA:!1,ratio:Math.round(100*r)/100};return r>=3&&(n.largeAA=!0,r>=4.5&&(n.normalAA=!0,n.largeAAA=!0,r>=7&&(n.normalAAA=!0))),n}static contrast(e,a){const r=t.luminance(e),n=t.luminance(a),o=Math.max(r,n),b=Math.min(r,n);return(o+.05)/(b+.05)}static rgbToHex(e){const[a,r,n]=e,o=a.toString(16),b=r.toString(16),c=n.toString(16);return`#${o.length===1?`0${o}`:o}${b.length===1?`0${b}`:b}${c.length===1?`0${c}`:c}`}static generatePalette(e,a,r){const n=t.toRgb(e),[o,b,c]=n,i=t.toRgb(a),h=t.toRgb(r),[s,x]=t.rgbToHcl(n),[H,M,d]=t.lightReferenceColor(n,i),[A,f,m]=t.darkReferenceColor(n,h),l=t.generateChromaCurve(M),g=t.generateLuminanceCurve(d,m);return c>2*b&&c>2*o?{l5:t.rgbToHex(t.hclToRgb(s-30,l[0],g[0])),l4:t.rgbToHex(t.hclToRgb(s-25,l[1],g[1])),l3:t.rgbToHex(t.hclToRgb(s-20,l[2],g[2])),l2:t.rgbToHex(t.hclToRgb(s-15,l[3],g[3])),l1:t.rgbToHex(t.hclToRgb(s-10,l[4],g[4])),d1:t.rgbToHex(t.hclToRgb(s-10,l[5],g[5])),d2:t.rgbToHex(t.hclToRgb(s-10,l[6],g[6])),d3:t.rgbToHex(t.hclToRgb(s-10,l[7],g[7])),d4:t.rgbToHex(t.hclToRgb(s-10,l[8],g[8])),d5:t.rgbToHex(t.hclToRgb(s-10,l[9],g[9]))}:{l5:t.rgbToHex(t.hclToRgb(s,l[0],g[0])),l4:t.rgbToHex(t.hclToRgb(s,l[1],g[1])),l3:t.rgbToHex(t.hclToRgb(s,l[2],g[2])),l2:t.rgbToHex(t.hclToRgb(s,l[3],g[3])),l1:t.rgbToHex(t.hclToRgb(s,l[4],g[4])),d1:t.rgbToHex(t.hclToRgb(s,l[5],g[5])),d2:t.rgbToHex(t.hclToRgb(s,l[6],g[6])),d3:t.rgbToHex(t.hclToRgb(s,l[7],g[7])),d4:t.rgbToHex(t.hclToRgb(s,l[8],g[8])),d5:t.rgbToHex(t.hclToRgb(s,l[9],g[9]))}}static generateChromaCurve(e){const a=.25*Math.abs(e-10),r=.25*Math.abs(e-10);return[e-4*a,e-3*a+4,e-2*a+6,e-a+4,e,e,e-r+4,e-2*r+6,e-3*r+4,e-4*r]}static generateLuminanceCurve(e,a){const r=.25*(96-e),n=.25*(a-10);return[e+4*r,e+3*r,e+2*r,e+r,e,a,a-n+2,a-2*n+1,a-3*n-1,a-4*n]}static xyzToLab(e){return e>t.labT3?Math.pow(e,1/3):e/t.labT2+t.labT0}static rgbValueToXyz(e){const a=e/255;return a<=.04045?a/12.92:Math.pow((a+.055)/1.055,2.4)}static labToHcl(e){const[a,r,n]=e,o=Math.sqrt(r*r+n*n),b=(Math.atan2(n,r)*t.radiansToDegrees+360)%360;return[Math.round(b),o,a]}static luminanceByChannel(e){return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}static relativeLuminance(e){const[a,r,n]=e,o=t.luminanceByChannel(a/255),b=t.luminanceByChannel(r/255),c=t.luminanceByChannel(n/255);return .2126*o+.7152*b+.0722*c}static contrastRatio(e,a){const r=t.relativeLuminance(e),n=t.relativeLuminance(a),o=Math.max(r,n),b=Math.min(r,n),c=(o+.05)/(b+.05);return Math.floor(c*100)/100}static labToXyz(e){return e>t.labT1?e*e*e:t.labT2*(e-t.labT0)}static xyzToRgb(e){return e<=.00304?255*12.92*e:255*(1.055*Math.pow(e,1/2.4)-.055)}static labToRgb(e,a,r){const n=(e+16)/116,o=n+a/500,b=n-r/200,c=t.labXn*t.labToXyz(o),i=t.labYn*t.labToXyz(n),h=t.labZn*t.labToXyz(b),s=Math.round(Math.min(255,Math.max(0,t.xyzToRgb(3.2404542*c-1.5371385*i-.4985314*h)))),x=Math.round(Math.min(255,Math.max(0,t.xyzToRgb(-.969266*c+1.8760108*i+.041556*h)))),H=Math.round(Math.min(255,Math.max(0,t.xyzToRgb(.0556434*c-.2040259*i+1.0572252*h))));return[s,x,H]}static hclToLab(e,a,r){const n=e*t.degreesToRadians;return[r,Math.cos(n)*a,Math.sin(n)*a]}static hclToRgb(e,a,r){const[n,o,b]=t.hclToLab(e,a,r);return t.labToRgb(n,o,b)}static lightReferenceColor(e,a){let r=e;const[n,o,b]=t.rgbToHcl(r);let c=b;for(;t.contrastRatio(r,a)<4.5;)c=c+1,r=t.hclToRgb(n,o,c);return[n,o,c]}static darkReferenceColor(e,a){let r=e;const[n,o,b]=t.rgbToHcl(r);let c=b;for(;t.contrastRatio(r,a)<4.5;)c=c-1,r=t.hclToRgb(n,o,c);return[n,o,c]}};let T=t;u(T,"red",.2126),u(T,"green",.7152),u(T,"blue",.0722),u(T,"labXn",.95047),u(T,"labYn",1),u(T,"labZn",1.08883),u(T,"labT0",.137931034),u(T,"labT1",.206896552),u(T,"labT2",.12841855),u(T,"labT3",.008856452),u(T,"degreesToRadians",Math.PI/180),u(T,"radiansToDegrees",180/Math.PI),u(T,"gamma",2.4);exports.NeonColorUtils=T;
|
|
2
|
+
//# sourceMappingURL=NeonColorUtils.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonColorUtils.cjs.js","sources":["../../../src/common/utils/NeonColorUtils.ts"],"sourcesContent":["import type { NeonContrastAccessibility } from '@/common/models/NeonContrastAccessibility';\n\n/**\n * Utility class with helpers for calculating relative contrast & determining accessibility.\n */\nexport class NeonColorUtils {\n private static red = 0.2126;\n private static green = 0.7152;\n private static blue = 0.0722;\n private static labXn = 0.95047;\n private static labYn = 1;\n private static labZn = 1.08883;\n private static labT0 = 0.137931034; // 4 / 29\n private static labT1 = 0.206896552; // 6 / 29\n private static labT2 = 0.12841855; // 3 * t1 * t1\n private static labT3 = 0.008856452; // t1 * t1 * t1\n private static degreesToRadians = Math.PI / 180;\n private static radiansToDegrees = 180 / Math.PI;\n\n private static gamma = 2.4;\n\n public static luminance([r, g, b]: Array<number>) {\n const a = [r, g, b].map((v) => {\n v /= 255;\n return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, NeonColorUtils.gamma);\n });\n return a[0] * NeonColorUtils.red + a[1] * NeonColorUtils.green + a[2] * NeonColorUtils.blue;\n }\n\n public static toRgb(hexString: string): Array<number> {\n return [\n Number.parseInt(hexString.substring(1, 3), 16),\n Number.parseInt(hexString.substring(3, 5), 16),\n Number.parseInt(hexString.substring(5, 7), 16),\n ];\n }\n\n public static rgbToXyz(rgb: Array<number>): Array<number> {\n const [r, g, b] = rgb;\n const r1 = NeonColorUtils.rgbValueToXyz(r);\n const g1 = NeonColorUtils.rgbValueToXyz(g);\n const b1 = NeonColorUtils.rgbValueToXyz(b);\n\n const x = NeonColorUtils.xyzToLab((0.4124564 * r1 + 0.3575761 * g1 + 0.1804375 * b1) / NeonColorUtils.labXn);\n const y = NeonColorUtils.xyzToLab((0.2126729 * r1 + 0.7151522 * g1 + 0.072175 * b1) / NeonColorUtils.labYn);\n const z = NeonColorUtils.xyzToLab((0.0193339 * r1 + 0.119192 * g1 + 0.9503041 * b1) / NeonColorUtils.labZn);\n\n return [x, y, z];\n }\n\n public static rgbToLab(rgb: Array<number>): Array<number> {\n const [x, y, z] = NeonColorUtils.rgbToXyz(rgb);\n const l = 116 * y - 16;\n return [Math.max(l, 0), 500 * (x - y), 200 * (y - z)];\n }\n\n public static rgbToHcl(rgb: Array<number>): Array<number> {\n const lab = NeonColorUtils.rgbToLab(rgb);\n return NeonColorUtils.labToHcl(lab);\n }\n\n public static isAccessible(rgb1: string, rgb2: string): NeonContrastAccessibility {\n const ratio = NeonColorUtils.contrast(NeonColorUtils.toRgb(rgb1), NeonColorUtils.toRgb(rgb2));\n\n const result = {\n largeAA: false,\n largeAAA: false,\n normalAA: false,\n normalAAA: false,\n ratio: Math.round(100 * ratio) / 100,\n };\n\n if (ratio >= 3) {\n result.largeAA = true;\n\n if (ratio >= 4.5) {\n result.normalAA = true;\n result.largeAAA = true;\n\n if (ratio >= 7) {\n result.normalAAA = true;\n }\n }\n }\n\n return result;\n }\n\n public static contrast(rgb1: Array<number>, rgb2: Array<number>) {\n const lum1 = NeonColorUtils.luminance(rgb1);\n const lum2 = NeonColorUtils.luminance(rgb2);\n const brightest = Math.max(lum1, lum2);\n const darkest = Math.min(lum1, lum2);\n return (brightest + 0.05) / (darkest + 0.05);\n }\n\n public static rgbToHex(rgb: Array<number>): string {\n const [r, g, b] = rgb;\n const rHex = r.toString(16);\n const gHex = g.toString(16);\n const bHex = b.toString(16);\n return `#${rHex.length === 1 ? `0${rHex}` : rHex}${gHex.length === 1 ? `0${gHex}` : gHex}${\n bHex.length === 1 ? `0${bHex}` : bHex\n }`;\n }\n\n public static generatePalette(\n referenceColor: string,\n darkTextHex: string,\n lightTextHex: string,\n ): Record<string, string> {\n const referenceRgb = NeonColorUtils.toRgb(referenceColor);\n const [r, g, b] = referenceRgb;\n const darkTextRgb = NeonColorUtils.toRgb(darkTextHex);\n const lightTextRgb = NeonColorUtils.toRgb(lightTextHex);\n\n const [hue, _rest] = NeonColorUtils.rgbToHcl(referenceRgb);\n\n const [_l1Hue, l1Chroma, l1Luminance] = NeonColorUtils.lightReferenceColor(referenceRgb, darkTextRgb);\n const [_d1Hue, _d1Chroma, d1Luminance] = NeonColorUtils.darkReferenceColor(referenceRgb, lightTextRgb);\n\n const chromaCurve = NeonColorUtils.generateChromaCurve(l1Chroma);\n const luminanceCurve = NeonColorUtils.generateLuminanceCurve(l1Luminance, d1Luminance);\n\n // if blue is the dominant channel then adjust hue so it's not too purple\n // TODO: rework for some blue colors as they are still too purple\n if (b > 2 * g && b > 2 * r) {\n return {\n l5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 30, chromaCurve[0], luminanceCurve[0])),\n l4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 25, chromaCurve[1], luminanceCurve[1])),\n l3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 20, chromaCurve[2], luminanceCurve[2])),\n l2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 15, chromaCurve[3], luminanceCurve[3])),\n l1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[4], luminanceCurve[4])),\n d1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[5], luminanceCurve[5])),\n d2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[6], luminanceCurve[6])),\n d3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[7], luminanceCurve[7])),\n d4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[8], luminanceCurve[8])),\n d5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[9], luminanceCurve[9])),\n };\n } else {\n return {\n l5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[0], luminanceCurve[0])),\n l4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[1], luminanceCurve[1])),\n l3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[2], luminanceCurve[2])),\n l2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[3], luminanceCurve[3])),\n l1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[4], luminanceCurve[4])),\n d1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[5], luminanceCurve[5])),\n d2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[6], luminanceCurve[6])),\n d3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[7], luminanceCurve[7])),\n d4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[8], luminanceCurve[8])),\n d5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[9], luminanceCurve[9])),\n };\n }\n }\n\n private static generateChromaCurve(chroma: number) {\n const lStep = 0.25 * Math.abs(chroma - 10);\n const dStep = 0.25 * Math.abs(chroma - 10);\n\n return [\n chroma - 4 * lStep,\n chroma - 3 * lStep + 4,\n chroma - 2 * lStep + 6,\n chroma - lStep + 4,\n chroma,\n chroma,\n chroma - dStep + 4,\n chroma - 2 * dStep + 6,\n chroma - 3 * dStep + 4,\n chroma - 4 * dStep,\n ];\n }\n\n private static generateLuminanceCurve(lightLuminance: number, darkLuminance: number) {\n const lStep = 0.25 * (96 - lightLuminance);\n const dStep = 0.25 * (darkLuminance - 10);\n\n return [\n lightLuminance + 4 * lStep,\n lightLuminance + 3 * lStep,\n lightLuminance + 2 * lStep,\n lightLuminance + lStep,\n lightLuminance,\n darkLuminance,\n darkLuminance - dStep + 2,\n darkLuminance - 2 * dStep + 1,\n darkLuminance - 3 * dStep - 1,\n darkLuminance - 4 * dStep,\n ];\n }\n\n private static xyzToLab(t: number) {\n return t > NeonColorUtils.labT3 ? Math.pow(t, 1 / 3) : t / NeonColorUtils.labT2 + NeonColorUtils.labT0;\n }\n\n private static rgbValueToXyz(value: number) {\n const v1 = value / 255;\n return v1 <= 0.04045 ? v1 / 12.92 : Math.pow((v1 + 0.055) / 1.055, 2.4);\n }\n\n private static labToHcl(lab: Array<number>) {\n const [l, a, b] = lab;\n const c = Math.sqrt(a * a + b * b);\n const h = (Math.atan2(b, a) * NeonColorUtils.radiansToDegrees + 360) % 360;\n return [Math.round(h), c, l];\n }\n\n private static luminanceByChannel(channel: number) {\n return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);\n }\n\n private static relativeLuminance(rgb: Array<number>) {\n const [r, g, b] = rgb;\n const r1 = NeonColorUtils.luminanceByChannel(r / 255);\n const g1 = NeonColorUtils.luminanceByChannel(g / 255);\n const b1 = NeonColorUtils.luminanceByChannel(b / 255);\n return 0.2126 * r1 + 0.7152 * g1 + 0.0722 * b1;\n }\n\n private static contrastRatio(backgroundColor: Array<number>, textColor: Array<number>) {\n const lum1 = NeonColorUtils.relativeLuminance(backgroundColor);\n const lum2 = NeonColorUtils.relativeLuminance(textColor);\n\n const lightest = Math.max(lum1, lum2);\n const darkest = Math.min(lum1, lum2);\n\n const contrast = (lightest + 0.05) / (darkest + 0.05);\n\n return Math.floor(contrast * 100) / 100;\n }\n\n private static labToXyz(t: number) {\n return t > NeonColorUtils.labT1 ? t * t * t : NeonColorUtils.labT2 * (t - NeonColorUtils.labT0);\n }\n\n private static xyzToRgb(r: number) {\n return r <= 0.00304 ? 255 * 12.92 * r : 255 * (1.055 * Math.pow(r, 1 / 2.4) - 0.055);\n }\n\n private static labToRgb(l: number, a: number, b: number): Array<number> {\n const y0 = (l + 16) / 116;\n const x0 = y0 + a / 500;\n const z0 = y0 - b / 200;\n\n const x1 = NeonColorUtils.labXn * NeonColorUtils.labToXyz(x0);\n const y1 = NeonColorUtils.labYn * NeonColorUtils.labToXyz(y0);\n const z1 = NeonColorUtils.labZn * NeonColorUtils.labToXyz(z0);\n const r = Math.round(\n Math.min(255, Math.max(0, NeonColorUtils.xyzToRgb(3.2404542 * x1 - 1.5371385 * y1 - 0.4985314 * z1))),\n ); // D65 -> sRGB\n const g = Math.round(\n Math.min(255, Math.max(0, NeonColorUtils.xyzToRgb(-0.969266 * x1 + 1.8760108 * y1 + 0.041556 * z1))),\n );\n const b_ = Math.round(\n Math.min(255, Math.max(0, NeonColorUtils.xyzToRgb(0.0556434 * x1 - 0.2040259 * y1 + 1.0572252 * z1))),\n );\n\n return [r, g, b_];\n }\n\n private static hclToLab(h: number, c: number, l: number) {\n const hue = h * NeonColorUtils.degreesToRadians;\n return [l, Math.cos(hue) * c, Math.sin(hue) * c];\n }\n\n private static hclToRgb(h: number, c: number, l: number): Array<number> {\n const [l_, a, b] = NeonColorUtils.hclToLab(h, c, l);\n return NeonColorUtils.labToRgb(l_, a, b);\n }\n\n private static lightReferenceColor(backgroundRgb: Array<number>, textRgb: Array<number>) {\n let referenceRgb = backgroundRgb;\n const [hue, chroma, l] = NeonColorUtils.rgbToHcl(referenceRgb);\n let luminance = l;\n // check contrast and adjust lightness up if contrast ratio too low\n while (NeonColorUtils.contrastRatio(referenceRgb, textRgb) < 4.5) {\n luminance = luminance + 1;\n referenceRgb = NeonColorUtils.hclToRgb(hue, chroma, luminance);\n }\n\n return [hue, chroma, luminance];\n }\n\n private static darkReferenceColor(backgroundRgb: Array<number>, textRgb: Array<number>) {\n let referenceRgb = backgroundRgb;\n const [hue, chroma, l] = NeonColorUtils.rgbToHcl(referenceRgb);\n let luminance = l;\n // check contrast and adjust lightness down if contrast ratio too low\n while (NeonColorUtils.contrastRatio(referenceRgb, textRgb) < 4.5) {\n luminance = luminance - 1;\n referenceRgb = NeonColorUtils.hclToRgb(hue, chroma, luminance);\n }\n\n return [hue, chroma, luminance];\n }\n}\n"],"names":["_NeonColorUtils","r","g","b","a","v","hexString","rgb","r1","g1","b1","x","y","z","l","lab","rgb1","rgb2","ratio","result","lum1","lum2","brightest","darkest","rHex","gHex","bHex","referenceColor","darkTextHex","lightTextHex","referenceRgb","darkTextRgb","lightTextRgb","hue","_rest","_l1Hue","l1Chroma","l1Luminance","_d1Hue","_d1Chroma","d1Luminance","chromaCurve","luminanceCurve","chroma","lStep","dStep","lightLuminance","darkLuminance","t","value","v1","c","h","channel","backgroundColor","textColor","lightest","contrast","y0","x0","z0","x1","y1","z1","b_","l_","backgroundRgb","textRgb","luminance","NeonColorUtils","__publicField"],"mappings":"oRAKO,MAAMA,EAAN,KAAqB,CAgB1B,OAAc,UAAU,CAACC,EAAGC,EAAGC,CAAC,EAAkB,CAC1C,MAAAC,EAAI,CAACH,EAAGC,EAAGC,CAAC,EAAE,IAAKE,IAClBA,GAAA,IACEA,GAAK,OAAUA,EAAI,MAAQ,KAAK,KAAKA,EAAI,MAAS,MAAOL,EAAe,KAAK,EACrF,EACM,OAAAI,EAAE,GAAKJ,EAAe,IAAMI,EAAE,GAAKJ,EAAe,MAAQI,EAAE,GAAKJ,EAAe,IACzF,CAEA,OAAc,MAAMM,EAAkC,CAC7C,MAAA,CACL,OAAO,SAASA,EAAU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IAAIsC,EAAYtD,EAEhB,KAAOd,EAAe,cAAc8B,EAAcqC,CAAO,EAAI,KAC3DC,EAAYA,EAAY,EACxBtC,EAAe9B,EAAe,SAASiC,EAAKU,EAAQyB,CAAS,EAGxD,MAAA,CAACnC,EAAKU,EAAQyB,CAAS,CAChC,CAEA,OAAe,mBAAmBF,EAA8BC,EAAwB,CACtF,IAAIrC,EAAeoC,EACnB,KAAM,CAACjC,EAAKU,EAAQ7B,CAAC,EAAId,EAAe,SAAS8B,CAAY,EAC7D,IAAIsC,EAAYtD,EAEhB,KAAOd,EAAe,cAAc8B,EAAcqC,CAAO,EAAI,KAC3DC,EAAYA,EAAY,EACxBtC,EAAe9B,EAAe,SAASiC,EAAKU,EAAQyB,CAAS,EAGxD,MAAA,CAACnC,EAAKU,EAAQyB,CAAS,CAChC,CACF,EAlSO,IAAMC,EAANrE,EACLsE,EADWD,EACI,MAAM,OACrBC,EAFWD,EAEI,QAAQ,OACvBC,EAHWD,EAGI,OAAO,OACtBC,EAJWD,EAII,QAAQ,QACvBC,EALWD,EAKI,QAAQ,GACvBC,EANWD,EAMI,QAAQ,SACvBC,EAPWD,EAOI,QAAQ,YACvBC,EARWD,EAQI,QAAQ,YACvBC,EATWD,EASI,QAAQ,WACvBC,EAVWD,EAUI,QAAQ,YACvBC,EAXWD,EAWI,mBAAmB,KAAK,GAAK,KAC5CC,EAZWD,EAYI,mBAAmB,IAAM,KAAK,IAE7CC,EAdWD,EAcI,QAAQ"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
const _NeonColorUtils = class {
|
|
8
|
+
static luminance([r, g, b]) {
|
|
9
|
+
const a = [r, g, b].map((v) => {
|
|
10
|
+
v /= 255;
|
|
11
|
+
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, _NeonColorUtils.gamma);
|
|
12
|
+
});
|
|
13
|
+
return a[0] * _NeonColorUtils.red + a[1] * _NeonColorUtils.green + a[2] * _NeonColorUtils.blue;
|
|
14
|
+
}
|
|
15
|
+
static toRgb(hexString) {
|
|
16
|
+
return [
|
|
17
|
+
Number.parseInt(hexString.substring(1, 3), 16),
|
|
18
|
+
Number.parseInt(hexString.substring(3, 5), 16),
|
|
19
|
+
Number.parseInt(hexString.substring(5, 7), 16)
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
static rgbToXyz(rgb) {
|
|
23
|
+
const [r, g, b] = rgb;
|
|
24
|
+
const r1 = _NeonColorUtils.rgbValueToXyz(r);
|
|
25
|
+
const g1 = _NeonColorUtils.rgbValueToXyz(g);
|
|
26
|
+
const b1 = _NeonColorUtils.rgbValueToXyz(b);
|
|
27
|
+
const x = _NeonColorUtils.xyzToLab((0.4124564 * r1 + 0.3575761 * g1 + 0.1804375 * b1) / _NeonColorUtils.labXn);
|
|
28
|
+
const y = _NeonColorUtils.xyzToLab((0.2126729 * r1 + 0.7151522 * g1 + 0.072175 * b1) / _NeonColorUtils.labYn);
|
|
29
|
+
const z = _NeonColorUtils.xyzToLab((0.0193339 * r1 + 0.119192 * g1 + 0.9503041 * b1) / _NeonColorUtils.labZn);
|
|
30
|
+
return [x, y, z];
|
|
31
|
+
}
|
|
32
|
+
static rgbToLab(rgb) {
|
|
33
|
+
const [x, y, z] = _NeonColorUtils.rgbToXyz(rgb);
|
|
34
|
+
const l = 116 * y - 16;
|
|
35
|
+
return [Math.max(l, 0), 500 * (x - y), 200 * (y - z)];
|
|
36
|
+
}
|
|
37
|
+
static rgbToHcl(rgb) {
|
|
38
|
+
const lab = _NeonColorUtils.rgbToLab(rgb);
|
|
39
|
+
return _NeonColorUtils.labToHcl(lab);
|
|
40
|
+
}
|
|
41
|
+
static isAccessible(rgb1, rgb2) {
|
|
42
|
+
const ratio = _NeonColorUtils.contrast(_NeonColorUtils.toRgb(rgb1), _NeonColorUtils.toRgb(rgb2));
|
|
43
|
+
const result = {
|
|
44
|
+
largeAA: false,
|
|
45
|
+
largeAAA: false,
|
|
46
|
+
normalAA: false,
|
|
47
|
+
normalAAA: false,
|
|
48
|
+
ratio: Math.round(100 * ratio) / 100
|
|
49
|
+
};
|
|
50
|
+
if (ratio >= 3) {
|
|
51
|
+
result.largeAA = true;
|
|
52
|
+
if (ratio >= 4.5) {
|
|
53
|
+
result.normalAA = true;
|
|
54
|
+
result.largeAAA = true;
|
|
55
|
+
if (ratio >= 7) {
|
|
56
|
+
result.normalAAA = true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
static contrast(rgb1, rgb2) {
|
|
63
|
+
const lum1 = _NeonColorUtils.luminance(rgb1);
|
|
64
|
+
const lum2 = _NeonColorUtils.luminance(rgb2);
|
|
65
|
+
const brightest = Math.max(lum1, lum2);
|
|
66
|
+
const darkest = Math.min(lum1, lum2);
|
|
67
|
+
return (brightest + 0.05) / (darkest + 0.05);
|
|
68
|
+
}
|
|
69
|
+
static rgbToHex(rgb) {
|
|
70
|
+
const [r, g, b] = rgb;
|
|
71
|
+
const rHex = r.toString(16);
|
|
72
|
+
const gHex = g.toString(16);
|
|
73
|
+
const bHex = b.toString(16);
|
|
74
|
+
return `#${rHex.length === 1 ? `0${rHex}` : rHex}${gHex.length === 1 ? `0${gHex}` : gHex}${bHex.length === 1 ? `0${bHex}` : bHex}`;
|
|
75
|
+
}
|
|
76
|
+
static generatePalette(referenceColor, darkTextHex, lightTextHex) {
|
|
77
|
+
const referenceRgb = _NeonColorUtils.toRgb(referenceColor);
|
|
78
|
+
const [r, g, b] = referenceRgb;
|
|
79
|
+
const darkTextRgb = _NeonColorUtils.toRgb(darkTextHex);
|
|
80
|
+
const lightTextRgb = _NeonColorUtils.toRgb(lightTextHex);
|
|
81
|
+
const [hue, _rest] = _NeonColorUtils.rgbToHcl(referenceRgb);
|
|
82
|
+
const [_l1Hue, l1Chroma, l1Luminance] = _NeonColorUtils.lightReferenceColor(referenceRgb, darkTextRgb);
|
|
83
|
+
const [_d1Hue, _d1Chroma, d1Luminance] = _NeonColorUtils.darkReferenceColor(referenceRgb, lightTextRgb);
|
|
84
|
+
const chromaCurve = _NeonColorUtils.generateChromaCurve(l1Chroma);
|
|
85
|
+
const luminanceCurve = _NeonColorUtils.generateLuminanceCurve(l1Luminance, d1Luminance);
|
|
86
|
+
if (b > 2 * g && b > 2 * r) {
|
|
87
|
+
return {
|
|
88
|
+
l5: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 30, chromaCurve[0], luminanceCurve[0])),
|
|
89
|
+
l4: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 25, chromaCurve[1], luminanceCurve[1])),
|
|
90
|
+
l3: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 20, chromaCurve[2], luminanceCurve[2])),
|
|
91
|
+
l2: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 15, chromaCurve[3], luminanceCurve[3])),
|
|
92
|
+
l1: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 10, chromaCurve[4], luminanceCurve[4])),
|
|
93
|
+
d1: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 10, chromaCurve[5], luminanceCurve[5])),
|
|
94
|
+
d2: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 10, chromaCurve[6], luminanceCurve[6])),
|
|
95
|
+
d3: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 10, chromaCurve[7], luminanceCurve[7])),
|
|
96
|
+
d4: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 10, chromaCurve[8], luminanceCurve[8])),
|
|
97
|
+
d5: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue - 10, chromaCurve[9], luminanceCurve[9]))
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
return {
|
|
101
|
+
l5: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[0], luminanceCurve[0])),
|
|
102
|
+
l4: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[1], luminanceCurve[1])),
|
|
103
|
+
l3: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[2], luminanceCurve[2])),
|
|
104
|
+
l2: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[3], luminanceCurve[3])),
|
|
105
|
+
l1: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[4], luminanceCurve[4])),
|
|
106
|
+
d1: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[5], luminanceCurve[5])),
|
|
107
|
+
d2: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[6], luminanceCurve[6])),
|
|
108
|
+
d3: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[7], luminanceCurve[7])),
|
|
109
|
+
d4: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[8], luminanceCurve[8])),
|
|
110
|
+
d5: _NeonColorUtils.rgbToHex(_NeonColorUtils.hclToRgb(hue, chromaCurve[9], luminanceCurve[9]))
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
static generateChromaCurve(chroma) {
|
|
115
|
+
const lStep = 0.25 * Math.abs(chroma - 10);
|
|
116
|
+
const dStep = 0.25 * Math.abs(chroma - 10);
|
|
117
|
+
return [
|
|
118
|
+
chroma - 4 * lStep,
|
|
119
|
+
chroma - 3 * lStep + 4,
|
|
120
|
+
chroma - 2 * lStep + 6,
|
|
121
|
+
chroma - lStep + 4,
|
|
122
|
+
chroma,
|
|
123
|
+
chroma,
|
|
124
|
+
chroma - dStep + 4,
|
|
125
|
+
chroma - 2 * dStep + 6,
|
|
126
|
+
chroma - 3 * dStep + 4,
|
|
127
|
+
chroma - 4 * dStep
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
static generateLuminanceCurve(lightLuminance, darkLuminance) {
|
|
131
|
+
const lStep = 0.25 * (96 - lightLuminance);
|
|
132
|
+
const dStep = 0.25 * (darkLuminance - 10);
|
|
133
|
+
return [
|
|
134
|
+
lightLuminance + 4 * lStep,
|
|
135
|
+
lightLuminance + 3 * lStep,
|
|
136
|
+
lightLuminance + 2 * lStep,
|
|
137
|
+
lightLuminance + lStep,
|
|
138
|
+
lightLuminance,
|
|
139
|
+
darkLuminance,
|
|
140
|
+
darkLuminance - dStep + 2,
|
|
141
|
+
darkLuminance - 2 * dStep + 1,
|
|
142
|
+
darkLuminance - 3 * dStep - 1,
|
|
143
|
+
darkLuminance - 4 * dStep
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
static xyzToLab(t) {
|
|
147
|
+
return t > _NeonColorUtils.labT3 ? Math.pow(t, 1 / 3) : t / _NeonColorUtils.labT2 + _NeonColorUtils.labT0;
|
|
148
|
+
}
|
|
149
|
+
static rgbValueToXyz(value) {
|
|
150
|
+
const v1 = value / 255;
|
|
151
|
+
return v1 <= 0.04045 ? v1 / 12.92 : Math.pow((v1 + 0.055) / 1.055, 2.4);
|
|
152
|
+
}
|
|
153
|
+
static labToHcl(lab) {
|
|
154
|
+
const [l, a, b] = lab;
|
|
155
|
+
const c = Math.sqrt(a * a + b * b);
|
|
156
|
+
const h = (Math.atan2(b, a) * _NeonColorUtils.radiansToDegrees + 360) % 360;
|
|
157
|
+
return [Math.round(h), c, l];
|
|
158
|
+
}
|
|
159
|
+
static luminanceByChannel(channel) {
|
|
160
|
+
return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);
|
|
161
|
+
}
|
|
162
|
+
static relativeLuminance(rgb) {
|
|
163
|
+
const [r, g, b] = rgb;
|
|
164
|
+
const r1 = _NeonColorUtils.luminanceByChannel(r / 255);
|
|
165
|
+
const g1 = _NeonColorUtils.luminanceByChannel(g / 255);
|
|
166
|
+
const b1 = _NeonColorUtils.luminanceByChannel(b / 255);
|
|
167
|
+
return 0.2126 * r1 + 0.7152 * g1 + 0.0722 * b1;
|
|
168
|
+
}
|
|
169
|
+
static contrastRatio(backgroundColor, textColor) {
|
|
170
|
+
const lum1 = _NeonColorUtils.relativeLuminance(backgroundColor);
|
|
171
|
+
const lum2 = _NeonColorUtils.relativeLuminance(textColor);
|
|
172
|
+
const lightest = Math.max(lum1, lum2);
|
|
173
|
+
const darkest = Math.min(lum1, lum2);
|
|
174
|
+
const contrast = (lightest + 0.05) / (darkest + 0.05);
|
|
175
|
+
return Math.floor(contrast * 100) / 100;
|
|
176
|
+
}
|
|
177
|
+
static labToXyz(t) {
|
|
178
|
+
return t > _NeonColorUtils.labT1 ? t * t * t : _NeonColorUtils.labT2 * (t - _NeonColorUtils.labT0);
|
|
179
|
+
}
|
|
180
|
+
static xyzToRgb(r) {
|
|
181
|
+
return r <= 304e-5 ? 255 * 12.92 * r : 255 * (1.055 * Math.pow(r, 1 / 2.4) - 0.055);
|
|
182
|
+
}
|
|
183
|
+
static labToRgb(l, a, b) {
|
|
184
|
+
const y0 = (l + 16) / 116;
|
|
185
|
+
const x0 = y0 + a / 500;
|
|
186
|
+
const z0 = y0 - b / 200;
|
|
187
|
+
const x1 = _NeonColorUtils.labXn * _NeonColorUtils.labToXyz(x0);
|
|
188
|
+
const y1 = _NeonColorUtils.labYn * _NeonColorUtils.labToXyz(y0);
|
|
189
|
+
const z1 = _NeonColorUtils.labZn * _NeonColorUtils.labToXyz(z0);
|
|
190
|
+
const r = Math.round(
|
|
191
|
+
Math.min(255, Math.max(0, _NeonColorUtils.xyzToRgb(3.2404542 * x1 - 1.5371385 * y1 - 0.4985314 * z1)))
|
|
192
|
+
);
|
|
193
|
+
const g = Math.round(
|
|
194
|
+
Math.min(255, Math.max(0, _NeonColorUtils.xyzToRgb(-0.969266 * x1 + 1.8760108 * y1 + 0.041556 * z1)))
|
|
195
|
+
);
|
|
196
|
+
const b_ = Math.round(
|
|
197
|
+
Math.min(255, Math.max(0, _NeonColorUtils.xyzToRgb(0.0556434 * x1 - 0.2040259 * y1 + 1.0572252 * z1)))
|
|
198
|
+
);
|
|
199
|
+
return [r, g, b_];
|
|
200
|
+
}
|
|
201
|
+
static hclToLab(h, c, l) {
|
|
202
|
+
const hue = h * _NeonColorUtils.degreesToRadians;
|
|
203
|
+
return [l, Math.cos(hue) * c, Math.sin(hue) * c];
|
|
204
|
+
}
|
|
205
|
+
static hclToRgb(h, c, l) {
|
|
206
|
+
const [l_, a, b] = _NeonColorUtils.hclToLab(h, c, l);
|
|
207
|
+
return _NeonColorUtils.labToRgb(l_, a, b);
|
|
208
|
+
}
|
|
209
|
+
static lightReferenceColor(backgroundRgb, textRgb) {
|
|
210
|
+
let referenceRgb = backgroundRgb;
|
|
211
|
+
const [hue, chroma, l] = _NeonColorUtils.rgbToHcl(referenceRgb);
|
|
212
|
+
let luminance = l;
|
|
213
|
+
while (_NeonColorUtils.contrastRatio(referenceRgb, textRgb) < 4.5) {
|
|
214
|
+
luminance = luminance + 1;
|
|
215
|
+
referenceRgb = _NeonColorUtils.hclToRgb(hue, chroma, luminance);
|
|
216
|
+
}
|
|
217
|
+
return [hue, chroma, luminance];
|
|
218
|
+
}
|
|
219
|
+
static darkReferenceColor(backgroundRgb, textRgb) {
|
|
220
|
+
let referenceRgb = backgroundRgb;
|
|
221
|
+
const [hue, chroma, l] = _NeonColorUtils.rgbToHcl(referenceRgb);
|
|
222
|
+
let luminance = l;
|
|
223
|
+
while (_NeonColorUtils.contrastRatio(referenceRgb, textRgb) < 4.5) {
|
|
224
|
+
luminance = luminance - 1;
|
|
225
|
+
referenceRgb = _NeonColorUtils.hclToRgb(hue, chroma, luminance);
|
|
226
|
+
}
|
|
227
|
+
return [hue, chroma, luminance];
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
let NeonColorUtils = _NeonColorUtils;
|
|
231
|
+
__publicField(NeonColorUtils, "red", 0.2126);
|
|
232
|
+
__publicField(NeonColorUtils, "green", 0.7152);
|
|
233
|
+
__publicField(NeonColorUtils, "blue", 0.0722);
|
|
234
|
+
__publicField(NeonColorUtils, "labXn", 0.95047);
|
|
235
|
+
__publicField(NeonColorUtils, "labYn", 1);
|
|
236
|
+
__publicField(NeonColorUtils, "labZn", 1.08883);
|
|
237
|
+
__publicField(NeonColorUtils, "labT0", 0.137931034);
|
|
238
|
+
__publicField(NeonColorUtils, "labT1", 0.206896552);
|
|
239
|
+
__publicField(NeonColorUtils, "labT2", 0.12841855);
|
|
240
|
+
__publicField(NeonColorUtils, "labT3", 8856452e-9);
|
|
241
|
+
__publicField(NeonColorUtils, "degreesToRadians", Math.PI / 180);
|
|
242
|
+
__publicField(NeonColorUtils, "radiansToDegrees", 180 / Math.PI);
|
|
243
|
+
__publicField(NeonColorUtils, "gamma", 2.4);
|
|
244
|
+
export { NeonColorUtils };
|
|
245
|
+
//# sourceMappingURL=NeonColorUtils.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonColorUtils.es.js","sources":["../../../src/common/utils/NeonColorUtils.ts"],"sourcesContent":["import type { NeonContrastAccessibility } from '@/common/models/NeonContrastAccessibility';\n\n/**\n * Utility class with helpers for calculating relative contrast & determining accessibility.\n */\nexport class NeonColorUtils {\n private static red = 0.2126;\n private static green = 0.7152;\n private static blue = 0.0722;\n private static labXn = 0.95047;\n private static labYn = 1;\n private static labZn = 1.08883;\n private static labT0 = 0.137931034; // 4 / 29\n private static labT1 = 0.206896552; // 6 / 29\n private static labT2 = 0.12841855; // 3 * t1 * t1\n private static labT3 = 0.008856452; // t1 * t1 * t1\n private static degreesToRadians = Math.PI / 180;\n private static radiansToDegrees = 180 / Math.PI;\n\n private static gamma = 2.4;\n\n public static luminance([r, g, b]: Array<number>) {\n const a = [r, g, b].map((v) => {\n v /= 255;\n return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, NeonColorUtils.gamma);\n });\n return a[0] * NeonColorUtils.red + a[1] * NeonColorUtils.green + a[2] * NeonColorUtils.blue;\n }\n\n public static toRgb(hexString: string): Array<number> {\n return [\n Number.parseInt(hexString.substring(1, 3), 16),\n Number.parseInt(hexString.substring(3, 5), 16),\n Number.parseInt(hexString.substring(5, 7), 16),\n ];\n }\n\n public static rgbToXyz(rgb: Array<number>): Array<number> {\n const [r, g, b] = rgb;\n const r1 = NeonColorUtils.rgbValueToXyz(r);\n const g1 = NeonColorUtils.rgbValueToXyz(g);\n const b1 = NeonColorUtils.rgbValueToXyz(b);\n\n const x = NeonColorUtils.xyzToLab((0.4124564 * r1 + 0.3575761 * g1 + 0.1804375 * b1) / NeonColorUtils.labXn);\n const y = NeonColorUtils.xyzToLab((0.2126729 * r1 + 0.7151522 * g1 + 0.072175 * b1) / NeonColorUtils.labYn);\n const z = NeonColorUtils.xyzToLab((0.0193339 * r1 + 0.119192 * g1 + 0.9503041 * b1) / NeonColorUtils.labZn);\n\n return [x, y, z];\n }\n\n public static rgbToLab(rgb: Array<number>): Array<number> {\n const [x, y, z] = NeonColorUtils.rgbToXyz(rgb);\n const l = 116 * y - 16;\n return [Math.max(l, 0), 500 * (x - y), 200 * (y - z)];\n }\n\n public static rgbToHcl(rgb: Array<number>): Array<number> {\n const lab = NeonColorUtils.rgbToLab(rgb);\n return NeonColorUtils.labToHcl(lab);\n }\n\n public static isAccessible(rgb1: string, rgb2: string): NeonContrastAccessibility {\n const ratio = NeonColorUtils.contrast(NeonColorUtils.toRgb(rgb1), NeonColorUtils.toRgb(rgb2));\n\n const result = {\n largeAA: false,\n largeAAA: false,\n normalAA: false,\n normalAAA: false,\n ratio: Math.round(100 * ratio) / 100,\n };\n\n if (ratio >= 3) {\n result.largeAA = true;\n\n if (ratio >= 4.5) {\n result.normalAA = true;\n result.largeAAA = true;\n\n if (ratio >= 7) {\n result.normalAAA = true;\n }\n }\n }\n\n return result;\n }\n\n public static contrast(rgb1: Array<number>, rgb2: Array<number>) {\n const lum1 = NeonColorUtils.luminance(rgb1);\n const lum2 = NeonColorUtils.luminance(rgb2);\n const brightest = Math.max(lum1, lum2);\n const darkest = Math.min(lum1, lum2);\n return (brightest + 0.05) / (darkest + 0.05);\n }\n\n public static rgbToHex(rgb: Array<number>): string {\n const [r, g, b] = rgb;\n const rHex = r.toString(16);\n const gHex = g.toString(16);\n const bHex = b.toString(16);\n return `#${rHex.length === 1 ? `0${rHex}` : rHex}${gHex.length === 1 ? `0${gHex}` : gHex}${\n bHex.length === 1 ? `0${bHex}` : bHex\n }`;\n }\n\n public static generatePalette(\n referenceColor: string,\n darkTextHex: string,\n lightTextHex: string,\n ): Record<string, string> {\n const referenceRgb = NeonColorUtils.toRgb(referenceColor);\n const [r, g, b] = referenceRgb;\n const darkTextRgb = NeonColorUtils.toRgb(darkTextHex);\n const lightTextRgb = NeonColorUtils.toRgb(lightTextHex);\n\n const [hue, _rest] = NeonColorUtils.rgbToHcl(referenceRgb);\n\n const [_l1Hue, l1Chroma, l1Luminance] = NeonColorUtils.lightReferenceColor(referenceRgb, darkTextRgb);\n const [_d1Hue, _d1Chroma, d1Luminance] = NeonColorUtils.darkReferenceColor(referenceRgb, lightTextRgb);\n\n const chromaCurve = NeonColorUtils.generateChromaCurve(l1Chroma);\n const luminanceCurve = NeonColorUtils.generateLuminanceCurve(l1Luminance, d1Luminance);\n\n // if blue is the dominant channel then adjust hue so it's not too purple\n // TODO: rework for some blue colors as they are still too purple\n if (b > 2 * g && b > 2 * r) {\n return {\n l5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 30, chromaCurve[0], luminanceCurve[0])),\n l4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 25, chromaCurve[1], luminanceCurve[1])),\n l3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 20, chromaCurve[2], luminanceCurve[2])),\n l2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 15, chromaCurve[3], luminanceCurve[3])),\n l1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[4], luminanceCurve[4])),\n d1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[5], luminanceCurve[5])),\n d2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[6], luminanceCurve[6])),\n d3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[7], luminanceCurve[7])),\n d4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[8], luminanceCurve[8])),\n d5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue - 10, chromaCurve[9], luminanceCurve[9])),\n };\n } else {\n return {\n l5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[0], luminanceCurve[0])),\n l4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[1], luminanceCurve[1])),\n l3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[2], luminanceCurve[2])),\n l2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[3], luminanceCurve[3])),\n l1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[4], luminanceCurve[4])),\n d1: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[5], luminanceCurve[5])),\n d2: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[6], luminanceCurve[6])),\n d3: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[7], luminanceCurve[7])),\n d4: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[8], luminanceCurve[8])),\n d5: NeonColorUtils.rgbToHex(NeonColorUtils.hclToRgb(hue, chromaCurve[9], luminanceCurve[9])),\n };\n }\n }\n\n private static generateChromaCurve(chroma: number) {\n const lStep = 0.25 * Math.abs(chroma - 10);\n const dStep = 0.25 * Math.abs(chroma - 10);\n\n return [\n chroma - 4 * lStep,\n chroma - 3 * lStep + 4,\n chroma - 2 * lStep + 6,\n chroma - lStep + 4,\n chroma,\n chroma,\n chroma - dStep + 4,\n chroma - 2 * dStep + 6,\n chroma - 3 * dStep + 4,\n chroma - 4 * dStep,\n ];\n }\n\n private static generateLuminanceCurve(lightLuminance: number, darkLuminance: number) {\n const lStep = 0.25 * (96 - lightLuminance);\n const dStep = 0.25 * (darkLuminance - 10);\n\n return [\n lightLuminance + 4 * lStep,\n lightLuminance + 3 * lStep,\n lightLuminance + 2 * lStep,\n lightLuminance + lStep,\n lightLuminance,\n darkLuminance,\n darkLuminance - dStep + 2,\n darkLuminance - 2 * dStep + 1,\n darkLuminance - 3 * dStep - 1,\n darkLuminance - 4 * dStep,\n ];\n }\n\n private static xyzToLab(t: number) {\n return t > NeonColorUtils.labT3 ? Math.pow(t, 1 / 3) : t / NeonColorUtils.labT2 + NeonColorUtils.labT0;\n }\n\n private static rgbValueToXyz(value: number) {\n const v1 = value / 255;\n return v1 <= 0.04045 ? v1 / 12.92 : Math.pow((v1 + 0.055) / 1.055, 2.4);\n }\n\n private static labToHcl(lab: Array<number>) {\n const [l, a, b] = lab;\n const c = Math.sqrt(a * a + b * b);\n const h = (Math.atan2(b, a) * NeonColorUtils.radiansToDegrees + 360) % 360;\n return [Math.round(h), c, l];\n }\n\n private static luminanceByChannel(channel: number) {\n return channel <= 0.03928 ? channel / 12.92 : Math.pow((channel + 0.055) / 1.055, 2.4);\n }\n\n private static relativeLuminance(rgb: Array<number>) {\n const [r, g, b] = rgb;\n const r1 = NeonColorUtils.luminanceByChannel(r / 255);\n const g1 = NeonColorUtils.luminanceByChannel(g / 255);\n const b1 = NeonColorUtils.luminanceByChannel(b / 255);\n return 0.2126 * r1 + 0.7152 * g1 + 0.0722 * b1;\n }\n\n private static contrastRatio(backgroundColor: Array<number>, textColor: Array<number>) {\n const lum1 = NeonColorUtils.relativeLuminance(backgroundColor);\n const lum2 = NeonColorUtils.relativeLuminance(textColor);\n\n const lightest = Math.max(lum1, lum2);\n const darkest = Math.min(lum1, lum2);\n\n const contrast = (lightest + 0.05) / (darkest + 0.05);\n\n return Math.floor(contrast * 100) / 100;\n }\n\n private static labToXyz(t: number) {\n return t > NeonColorUtils.labT1 ? t * t * t : NeonColorUtils.labT2 * (t - NeonColorUtils.labT0);\n }\n\n private static xyzToRgb(r: number) {\n return r <= 0.00304 ? 255 * 12.92 * r : 255 * (1.055 * Math.pow(r, 1 / 2.4) - 0.055);\n }\n\n private static labToRgb(l: number, a: number, b: number): Array<number> {\n const y0 = (l + 16) / 116;\n const x0 = y0 + a / 500;\n const z0 = y0 - b / 200;\n\n const x1 = NeonColorUtils.labXn * NeonColorUtils.labToXyz(x0);\n const y1 = NeonColorUtils.labYn * NeonColorUtils.labToXyz(y0);\n const z1 = NeonColorUtils.labZn * NeonColorUtils.labToXyz(z0);\n const r = Math.round(\n Math.min(255, Math.max(0, NeonColorUtils.xyzToRgb(3.2404542 * x1 - 1.5371385 * y1 - 0.4985314 * z1))),\n ); // D65 -> sRGB\n const g = Math.round(\n Math.min(255, Math.max(0, NeonColorUtils.xyzToRgb(-0.969266 * x1 + 1.8760108 * y1 + 0.041556 * z1))),\n );\n const b_ = Math.round(\n Math.min(255, Math.max(0, NeonColorUtils.xyzToRgb(0.0556434 * x1 - 0.2040259 * y1 + 1.0572252 * z1))),\n );\n\n return [r, g, b_];\n }\n\n private static hclToLab(h: number, c: number, l: number) {\n const hue = h * NeonColorUtils.degreesToRadians;\n return [l, Math.cos(hue) * c, Math.sin(hue) * c];\n }\n\n private static hclToRgb(h: number, c: number, l: number): Array<number> {\n const [l_, a, b] = NeonColorUtils.hclToLab(h, c, l);\n return NeonColorUtils.labToRgb(l_, a, b);\n }\n\n private static lightReferenceColor(backgroundRgb: Array<number>, textRgb: Array<number>) {\n let referenceRgb = backgroundRgb;\n const [hue, chroma, l] = NeonColorUtils.rgbToHcl(referenceRgb);\n let luminance = l;\n // check contrast and adjust lightness up if contrast ratio too low\n while (NeonColorUtils.contrastRatio(referenceRgb, textRgb) < 4.5) {\n luminance = luminance + 1;\n referenceRgb = NeonColorUtils.hclToRgb(hue, chroma, luminance);\n }\n\n return [hue, chroma, luminance];\n }\n\n private static darkReferenceColor(backgroundRgb: Array<number>, textRgb: Array<number>) {\n let referenceRgb = backgroundRgb;\n const [hue, chroma, l] = NeonColorUtils.rgbToHcl(referenceRgb);\n let luminance = l;\n // check contrast and adjust lightness down if contrast ratio too low\n while (NeonColorUtils.contrastRatio(referenceRgb, textRgb) < 4.5) {\n luminance = luminance - 1;\n referenceRgb = NeonColorUtils.hclToRgb(hue, chroma, luminance);\n }\n\n return [hue, chroma, luminance];\n }\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,kBAAN,MAAqB;AAAA,EAgB1B,OAAc,UAAU,CAAC,GAAG,GAAG,CAAC,GAAkB;AAC1C,UAAA,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM;AACxB,WAAA;AACE,aAAA,KAAK,UAAU,IAAI,QAAQ,KAAK,KAAK,IAAI,SAAS,OAAO,gBAAe,KAAK;AAAA,IAAA,CACrF;AACM,WAAA,EAAE,KAAK,gBAAe,MAAM,EAAE,KAAK,gBAAe,QAAQ,EAAE,KAAK,gBAAe;AAAA,EACzF;AAAA,EAEA,OAAc,MAAM,WAAkC;AAC7C,WAAA;AAAA,MACL,OAAO,SAAS,UAAU,UAAU,GAAG,CAAC,GAAG,EAAE;AAAA,MAC7C,OAAO,SAAS,UAAU,UAAU,G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,cAZW,gBAYI,oBAAmB,MAAM,KAAK;AAE7C,cAdW,gBAcI,SAAQ;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var A=Object.defineProperty;var C=(S,e,t)=>e in S?A(S,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):S[e]=t;var M=(S,e,t)=>(C(S,typeof e!="symbol"?e+"":e,t),t);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var w=require("./NeonRandomUtils.cjs.js");const i=class{static genSvg(e,t,n){return i.generateIdenticon(e,n,w.NeonRandomUtils.rand(t)).outerHTML}static generateIdenticon(e,t,n){const o=i.hueShift(e.slice(),n),l=document.createElementNS(i.svgns,"svg");l.setAttribute("xmlns",i.svgns),l.setAttributeNS(null,"x","0"),l.setAttributeNS(null,"y","0"),l.setAttributeNS(null,"width",`${t}`),l.setAttributeNS(null,"height",`${t}`),i.genShape([i.genColor(o,n)],t,0,i.shapeCount-1,l,()=>0);for(let r=0;r<i.shapeCount-1;r++)i.genShape(o,t,r,i.shapeCount-1,l,n);return l}static genShape(e,t,n,o,l,r){const u=t/2,s=document.createElementNS(i.svgns,"rect");s.setAttributeNS(null,"x","0"),s.setAttributeNS(null,"y","0"),s.setAttributeNS(null,"width",`${t}`),s.setAttributeNS(null,"height",`${t}`);const a=r(),c=Math.PI*2*a,h=t/o*r()+n*t/o,b=Math.cos(c)*h,f=Math.sin(c)*h,p=`translate(${b} ${f})`,d=r(),x=a*360+d*180,m="rotate("+x.toFixed(1)+" "+u+" "+u+")",v=p+" "+m;s.setAttributeNS(null,"transform",v);const N=i.genColor(e,r);s.setAttributeNS(null,"fill",N),l.appendChild(s)}static genColor(e,t){const n=Math.floor(e.length*t());return e.splice(n,1)[0]}static hueShift(e,t){const n=t()*30-i.wobble/2,o=l=>i.colorRotate(l,n);return e.map(o)}static colorRotate(e,t){const n=i.hexToHSL(e);let o=n.h;return o=(o+t)%360,o=o<0?360+o:o,n.h=o,i.hslToHex(n)}static hexToHSL(e){let t=+("0x"+e[1]+e[2]),n=+("0x"+e[3]+e[4]),o=+("0x"+e[5]+e[6]);t/=255,n/=255,o/=255;const l=Math.min(t,n,o),r=Math.max(t,n,o),u=r-l;let s=0,a=0,c=0;return u===0?s=0:r===t?s=(n-o)/u%6:r===n?s=(o-t)/u+2:s=(t-n)/u+4,s=Math.round(s*60),s<0&&(s+=360),c=(r+l)/2,a=u===0?0:u/(1-Math.abs(2*c-1)),a=+(a*100).toFixed(1),c=+(c*100).toFixed(1),{h:s,s:a,l:c}}static hslToHex(e){const t=e.h;let{s:n,l:o}=e;n/=100,o/=100;const l=(1-Math.abs(2*o-1))*n,r=l*(1-Math.abs(t/60%2-1)),u=o-l/2;let s=0,a=0,c=0;t>=0&&t<60?(s=l,a=r,c=0):t>=60&&t<120?(s=r,a=l,c=0):t>=120&&t<180?(s=0,a=l,c=r):t>=180&&t<240?(s=0,a=r,c=l):t>=240&&t<300?(s=r,a=0,c=l):t>=300&&t<360&&(s=l,a=0,c=r);let h=Math.round((s+u)*255).toString(16),b=Math.round((a+u)*255).toString(16),f=Math.round((c+u)*255).toString(16);return h.length===1&&(h="0"+s),b.length===1&&(b="0"+a),f.length===1&&(f="0"+c),"#"+h+b+f}};let g=i;M(g,"shapeCount",4),M(g,"svgns","http://www.w3.org/2000/svg"),M(g,"wobble",30);exports.NeonJazziconUtils=g;
|
|
2
|
+
//# sourceMappingURL=NeonJazziconUtils.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonJazziconUtils.cjs.js","sources":["../../../src/common/utils/NeonJazziconUtils.ts"],"sourcesContent":["import { NeonRandomUtils } from './NeonRandomUtils';\n\nexport class NeonJazziconUtils {\n private static readonly shapeCount = 4;\n private static readonly svgns = 'http://www.w3.org/2000/svg';\n private static readonly wobble = 30;\n\n /**\n * Returns base-64 encoded data URI\n * @param palette the color palettes to use when generating the Jazzicon\n * @param name used for random seed\n * @param size size in pixels to generate\n */\n public static genSvg(palette: Array<string>, name: string, size: number): string {\n return NeonJazziconUtils.generateIdenticon(palette, size, NeonRandomUtils.rand(name)).outerHTML;\n }\n\n private static generateIdenticon(palette: Array<string>, diameter: number, rand: () => number): SVGElement {\n const remainingColors = NeonJazziconUtils.hueShift(palette.slice(), rand);\n\n const svg = document.createElementNS(NeonJazziconUtils.svgns, 'svg');\n svg.setAttribute('xmlns', NeonJazziconUtils.svgns);\n svg.setAttributeNS(null, 'x', '0');\n svg.setAttributeNS(null, 'y', '0');\n svg.setAttributeNS(null, 'width', `${diameter}`);\n svg.setAttributeNS(null, 'height', `${diameter}`);\n\n NeonJazziconUtils.genShape(\n [NeonJazziconUtils.genColor(remainingColors, rand)],\n diameter,\n 0,\n NeonJazziconUtils.shapeCount - 1,\n svg,\n () => 0,\n );\n\n for (let i = 0; i < NeonJazziconUtils.shapeCount - 1; i++) {\n NeonJazziconUtils.genShape(remainingColors, diameter, i, NeonJazziconUtils.shapeCount - 1, svg, rand);\n }\n\n return svg;\n }\n\n private static genShape(\n remainingColors: string[],\n diameter: number,\n i: number,\n total: number,\n svg: SVGElement,\n rand: () => number,\n ) {\n const center = diameter / 2;\n\n const shape = document.createElementNS(NeonJazziconUtils.svgns, 'rect');\n shape.setAttributeNS(null, 'x', '0');\n shape.setAttributeNS(null, 'y', '0');\n shape.setAttributeNS(null, 'width', `${diameter}`);\n shape.setAttributeNS(null, 'height', `${diameter}`);\n\n const firstRot = rand();\n const angle = Math.PI * 2 * firstRot;\n const velocity = (diameter / total) * rand() + (i * diameter) / total;\n\n const tx = Math.cos(angle) * velocity;\n const ty = Math.sin(angle) * velocity;\n\n const translate = `translate(${tx} ${ty})`;\n\n // Third random is a shape rotation on top of all of that.\n const secondRot = rand();\n const rot = firstRot * 360 + secondRot * 180;\n const rotate = 'rotate(' + rot.toFixed(1) + ' ' + center + ' ' + center + ')';\n const transform = translate + ' ' + rotate;\n shape.setAttributeNS(null, 'transform', transform);\n const fill = NeonJazziconUtils.genColor(remainingColors, rand);\n shape.setAttributeNS(null, 'fill', fill);\n\n svg.appendChild(shape);\n }\n\n private static genColor(colors: string[], rand: () => number) {\n const idx = Math.floor(colors.length * rand());\n return colors.splice(idx, 1)[0];\n }\n\n private static hueShift(colors: Array<string>, rand: () => number) {\n const amount = rand() * 30 - NeonJazziconUtils.wobble / 2;\n const rotate = (hex: string) => NeonJazziconUtils.colorRotate(hex, amount);\n return colors.map(rotate);\n }\n\n private static colorRotate(hex: string, degrees: number) {\n const hsl = NeonJazziconUtils.hexToHSL(hex);\n let hue = hsl.h;\n hue = (hue + degrees) % 360;\n hue = hue < 0 ? 360 + hue : hue;\n hsl.h = hue;\n return NeonJazziconUtils.hslToHex(hsl);\n }\n\n private static hexToHSL(hex: string) {\n // Convert hex to RGB first\n let r = +('0x' + hex[1] + hex[2]);\n let g = +('0x' + hex[3] + hex[4]);\n let b = +('0x' + hex[5] + hex[6]);\n // Then to HSL\n r /= 255;\n g /= 255;\n b /= 255;\n const cmin = Math.min(r, g, b);\n const cmax = Math.max(r, g, b);\n const delta = cmax - cmin;\n let h = 0;\n let s = 0;\n let l = 0;\n\n if (delta === 0) {\n h = 0;\n } else if (cmax === r) {\n h = ((g - b) / delta) % 6;\n } else if (cmax === g) {\n h = (b - r) / delta + 2;\n } else {\n h = (r - g) / delta + 4;\n }\n\n h = Math.round(h * 60);\n\n if (h < 0) {\n h += 360;\n }\n\n l = (cmax + cmin) / 2;\n s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n s = +(s * 100).toFixed(1);\n l = +(l * 100).toFixed(1);\n\n return { h, s, l };\n }\n\n private static hslToHex(hsl: Record<string, any>) {\n const h = hsl.h;\n let { s, l } = hsl;\n s /= 100;\n l /= 100;\n\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1));\n const m = l - c / 2;\n let r = 0;\n let g = 0;\n let b = 0;\n\n if (h >= 0 && h < 60) {\n r = c;\n g = x;\n b = 0;\n } else if (h >= 60 && h < 120) {\n r = x;\n g = c;\n b = 0;\n } else if (h >= 120 && h < 180) {\n r = 0;\n g = c;\n b = x;\n } else if (h >= 180 && h < 240) {\n r = 0;\n g = x;\n b = c;\n } else if (h >= 240 && h < 300) {\n r = x;\n g = 0;\n b = c;\n } else if (h >= 300 && h < 360) {\n r = c;\n g = 0;\n b = x;\n }\n // Having obtained RGB, convert channels to hex\n let rStr = Math.round((r + m) * 255).toString(16);\n let gStr = Math.round((g + m) * 255).toString(16);\n let bStr = Math.round((b + m) * 255).toString(16);\n\n // Prepend 0s, if necessary\n if (rStr.length === 1) {\n rStr = '0' + r;\n }\n\n if (gStr.length === 1) {\n gStr = '0' + g;\n }\n\n if (bStr.length === 1) {\n bStr = '0' + b;\n }\n\n return '#' + rStr + gStr + bStr;\n }\n}\n"],"names":["_NeonJazziconUtils","palette","name","size","NeonRandomUtils","diameter","rand","remainingColors","svg","i","total","center","shape","firstRot","angle","velocity","tx","ty","translate","secondRot","rot","rotate","transform","fill","colors","idx","amount","hex","degrees","hsl","hue","r","g","b","cmin","cmax","delta","h","s","l","c","x","m","rStr","gStr","bStr","NeonJazziconUtils","__publicField"],"mappings":"8TAEO,MAAMA,EAAN,KAAwB,CAW7B,OAAc,OAAOC,EAAwBC,EAAcC,EAAsB,CACxE,OAAAH,EAAkB,kBAAkBC,EAASE,EAAMC,kBAAgB,KAAKF,CAAI,CAAC,EAAE,SACxF,CAEA,OAAe,kBAAkBD,EAAwBI,EAAkBC,EAAgC,CACzG,MAAMC,EAAkBP,EAAkB,SAASC,EAAQ,MAAA,EAASK,CAAI,EAElEE,EAAM,SAAS,gBAAgBR,EAAkB,MAAO,KAAK,EAC/DQ,EAAA,aAAa,QAASR,EAAkB,KAAK,EAC7CQ,EAAA,eAAe,KAAM,IAAK,GAAG,EAC7BA,EAAA,eAAe,KAAM,IAAK,GAAG,EACjCA,EAAI,eAAe,KAAM,QAAS,GAAGH,GAAU,EAC/CG,EAAI,eAAe,KA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BAChCC,EAHWD,EAGa,SAAS"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { NeonRandomUtils } from "./NeonRandomUtils.es.js";
|
|
8
|
+
const _NeonJazziconUtils = class {
|
|
9
|
+
static genSvg(palette, name, size) {
|
|
10
|
+
return _NeonJazziconUtils.generateIdenticon(palette, size, NeonRandomUtils.rand(name)).outerHTML;
|
|
11
|
+
}
|
|
12
|
+
static generateIdenticon(palette, diameter, rand) {
|
|
13
|
+
const remainingColors = _NeonJazziconUtils.hueShift(palette.slice(), rand);
|
|
14
|
+
const svg = document.createElementNS(_NeonJazziconUtils.svgns, "svg");
|
|
15
|
+
svg.setAttribute("xmlns", _NeonJazziconUtils.svgns);
|
|
16
|
+
svg.setAttributeNS(null, "x", "0");
|
|
17
|
+
svg.setAttributeNS(null, "y", "0");
|
|
18
|
+
svg.setAttributeNS(null, "width", `${diameter}`);
|
|
19
|
+
svg.setAttributeNS(null, "height", `${diameter}`);
|
|
20
|
+
_NeonJazziconUtils.genShape(
|
|
21
|
+
[_NeonJazziconUtils.genColor(remainingColors, rand)],
|
|
22
|
+
diameter,
|
|
23
|
+
0,
|
|
24
|
+
_NeonJazziconUtils.shapeCount - 1,
|
|
25
|
+
svg,
|
|
26
|
+
() => 0
|
|
27
|
+
);
|
|
28
|
+
for (let i = 0; i < _NeonJazziconUtils.shapeCount - 1; i++) {
|
|
29
|
+
_NeonJazziconUtils.genShape(remainingColors, diameter, i, _NeonJazziconUtils.shapeCount - 1, svg, rand);
|
|
30
|
+
}
|
|
31
|
+
return svg;
|
|
32
|
+
}
|
|
33
|
+
static genShape(remainingColors, diameter, i, total, svg, rand) {
|
|
34
|
+
const center = diameter / 2;
|
|
35
|
+
const shape = document.createElementNS(_NeonJazziconUtils.svgns, "rect");
|
|
36
|
+
shape.setAttributeNS(null, "x", "0");
|
|
37
|
+
shape.setAttributeNS(null, "y", "0");
|
|
38
|
+
shape.setAttributeNS(null, "width", `${diameter}`);
|
|
39
|
+
shape.setAttributeNS(null, "height", `${diameter}`);
|
|
40
|
+
const firstRot = rand();
|
|
41
|
+
const angle = Math.PI * 2 * firstRot;
|
|
42
|
+
const velocity = diameter / total * rand() + i * diameter / total;
|
|
43
|
+
const tx = Math.cos(angle) * velocity;
|
|
44
|
+
const ty = Math.sin(angle) * velocity;
|
|
45
|
+
const translate = `translate(${tx} ${ty})`;
|
|
46
|
+
const secondRot = rand();
|
|
47
|
+
const rot = firstRot * 360 + secondRot * 180;
|
|
48
|
+
const rotate = "rotate(" + rot.toFixed(1) + " " + center + " " + center + ")";
|
|
49
|
+
const transform = translate + " " + rotate;
|
|
50
|
+
shape.setAttributeNS(null, "transform", transform);
|
|
51
|
+
const fill = _NeonJazziconUtils.genColor(remainingColors, rand);
|
|
52
|
+
shape.setAttributeNS(null, "fill", fill);
|
|
53
|
+
svg.appendChild(shape);
|
|
54
|
+
}
|
|
55
|
+
static genColor(colors, rand) {
|
|
56
|
+
const idx = Math.floor(colors.length * rand());
|
|
57
|
+
return colors.splice(idx, 1)[0];
|
|
58
|
+
}
|
|
59
|
+
static hueShift(colors, rand) {
|
|
60
|
+
const amount = rand() * 30 - _NeonJazziconUtils.wobble / 2;
|
|
61
|
+
const rotate = (hex) => _NeonJazziconUtils.colorRotate(hex, amount);
|
|
62
|
+
return colors.map(rotate);
|
|
63
|
+
}
|
|
64
|
+
static colorRotate(hex, degrees) {
|
|
65
|
+
const hsl = _NeonJazziconUtils.hexToHSL(hex);
|
|
66
|
+
let hue = hsl.h;
|
|
67
|
+
hue = (hue + degrees) % 360;
|
|
68
|
+
hue = hue < 0 ? 360 + hue : hue;
|
|
69
|
+
hsl.h = hue;
|
|
70
|
+
return _NeonJazziconUtils.hslToHex(hsl);
|
|
71
|
+
}
|
|
72
|
+
static hexToHSL(hex) {
|
|
73
|
+
let r = +("0x" + hex[1] + hex[2]);
|
|
74
|
+
let g = +("0x" + hex[3] + hex[4]);
|
|
75
|
+
let b = +("0x" + hex[5] + hex[6]);
|
|
76
|
+
r /= 255;
|
|
77
|
+
g /= 255;
|
|
78
|
+
b /= 255;
|
|
79
|
+
const cmin = Math.min(r, g, b);
|
|
80
|
+
const cmax = Math.max(r, g, b);
|
|
81
|
+
const delta = cmax - cmin;
|
|
82
|
+
let h = 0;
|
|
83
|
+
let s = 0;
|
|
84
|
+
let l = 0;
|
|
85
|
+
if (delta === 0) {
|
|
86
|
+
h = 0;
|
|
87
|
+
} else if (cmax === r) {
|
|
88
|
+
h = (g - b) / delta % 6;
|
|
89
|
+
} else if (cmax === g) {
|
|
90
|
+
h = (b - r) / delta + 2;
|
|
91
|
+
} else {
|
|
92
|
+
h = (r - g) / delta + 4;
|
|
93
|
+
}
|
|
94
|
+
h = Math.round(h * 60);
|
|
95
|
+
if (h < 0) {
|
|
96
|
+
h += 360;
|
|
97
|
+
}
|
|
98
|
+
l = (cmax + cmin) / 2;
|
|
99
|
+
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
100
|
+
s = +(s * 100).toFixed(1);
|
|
101
|
+
l = +(l * 100).toFixed(1);
|
|
102
|
+
return { h, s, l };
|
|
103
|
+
}
|
|
104
|
+
static hslToHex(hsl) {
|
|
105
|
+
const h = hsl.h;
|
|
106
|
+
let { s, l } = hsl;
|
|
107
|
+
s /= 100;
|
|
108
|
+
l /= 100;
|
|
109
|
+
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
110
|
+
const x = c * (1 - Math.abs(h / 60 % 2 - 1));
|
|
111
|
+
const m = l - c / 2;
|
|
112
|
+
let r = 0;
|
|
113
|
+
let g = 0;
|
|
114
|
+
let b = 0;
|
|
115
|
+
if (h >= 0 && h < 60) {
|
|
116
|
+
r = c;
|
|
117
|
+
g = x;
|
|
118
|
+
b = 0;
|
|
119
|
+
} else if (h >= 60 && h < 120) {
|
|
120
|
+
r = x;
|
|
121
|
+
g = c;
|
|
122
|
+
b = 0;
|
|
123
|
+
} else if (h >= 120 && h < 180) {
|
|
124
|
+
r = 0;
|
|
125
|
+
g = c;
|
|
126
|
+
b = x;
|
|
127
|
+
} else if (h >= 180 && h < 240) {
|
|
128
|
+
r = 0;
|
|
129
|
+
g = x;
|
|
130
|
+
b = c;
|
|
131
|
+
} else if (h >= 240 && h < 300) {
|
|
132
|
+
r = x;
|
|
133
|
+
g = 0;
|
|
134
|
+
b = c;
|
|
135
|
+
} else if (h >= 300 && h < 360) {
|
|
136
|
+
r = c;
|
|
137
|
+
g = 0;
|
|
138
|
+
b = x;
|
|
139
|
+
}
|
|
140
|
+
let rStr = Math.round((r + m) * 255).toString(16);
|
|
141
|
+
let gStr = Math.round((g + m) * 255).toString(16);
|
|
142
|
+
let bStr = Math.round((b + m) * 255).toString(16);
|
|
143
|
+
if (rStr.length === 1) {
|
|
144
|
+
rStr = "0" + r;
|
|
145
|
+
}
|
|
146
|
+
if (gStr.length === 1) {
|
|
147
|
+
gStr = "0" + g;
|
|
148
|
+
}
|
|
149
|
+
if (bStr.length === 1) {
|
|
150
|
+
bStr = "0" + b;
|
|
151
|
+
}
|
|
152
|
+
return "#" + rStr + gStr + bStr;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
let NeonJazziconUtils = _NeonJazziconUtils;
|
|
156
|
+
__publicField(NeonJazziconUtils, "shapeCount", 4);
|
|
157
|
+
__publicField(NeonJazziconUtils, "svgns", "http://www.w3.org/2000/svg");
|
|
158
|
+
__publicField(NeonJazziconUtils, "wobble", 30);
|
|
159
|
+
export { NeonJazziconUtils };
|
|
160
|
+
//# sourceMappingURL=NeonJazziconUtils.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonJazziconUtils.es.js","sources":["../../../src/common/utils/NeonJazziconUtils.ts"],"sourcesContent":["import { NeonRandomUtils } from './NeonRandomUtils';\n\nexport class NeonJazziconUtils {\n private static readonly shapeCount = 4;\n private static readonly svgns = 'http://www.w3.org/2000/svg';\n private static readonly wobble = 30;\n\n /**\n * Returns base-64 encoded data URI\n * @param palette the color palettes to use when generating the Jazzicon\n * @param name used for random seed\n * @param size size in pixels to generate\n */\n public static genSvg(palette: Array<string>, name: string, size: number): string {\n return NeonJazziconUtils.generateIdenticon(palette, size, NeonRandomUtils.rand(name)).outerHTML;\n }\n\n private static generateIdenticon(palette: Array<string>, diameter: number, rand: () => number): SVGElement {\n const remainingColors = NeonJazziconUtils.hueShift(palette.slice(), rand);\n\n const svg = document.createElementNS(NeonJazziconUtils.svgns, 'svg');\n svg.setAttribute('xmlns', NeonJazziconUtils.svgns);\n svg.setAttributeNS(null, 'x', '0');\n svg.setAttributeNS(null, 'y', '0');\n svg.setAttributeNS(null, 'width', `${diameter}`);\n svg.setAttributeNS(null, 'height', `${diameter}`);\n\n NeonJazziconUtils.genShape(\n [NeonJazziconUtils.genColor(remainingColors, rand)],\n diameter,\n 0,\n NeonJazziconUtils.shapeCount - 1,\n svg,\n () => 0,\n );\n\n for (let i = 0; i < NeonJazziconUtils.shapeCount - 1; i++) {\n NeonJazziconUtils.genShape(remainingColors, diameter, i, NeonJazziconUtils.shapeCount - 1, svg, rand);\n }\n\n return svg;\n }\n\n private static genShape(\n remainingColors: string[],\n diameter: number,\n i: number,\n total: number,\n svg: SVGElement,\n rand: () => number,\n ) {\n const center = diameter / 2;\n\n const shape = document.createElementNS(NeonJazziconUtils.svgns, 'rect');\n shape.setAttributeNS(null, 'x', '0');\n shape.setAttributeNS(null, 'y', '0');\n shape.setAttributeNS(null, 'width', `${diameter}`);\n shape.setAttributeNS(null, 'height', `${diameter}`);\n\n const firstRot = rand();\n const angle = Math.PI * 2 * firstRot;\n const velocity = (diameter / total) * rand() + (i * diameter) / total;\n\n const tx = Math.cos(angle) * velocity;\n const ty = Math.sin(angle) * velocity;\n\n const translate = `translate(${tx} ${ty})`;\n\n // Third random is a shape rotation on top of all of that.\n const secondRot = rand();\n const rot = firstRot * 360 + secondRot * 180;\n const rotate = 'rotate(' + rot.toFixed(1) + ' ' + center + ' ' + center + ')';\n const transform = translate + ' ' + rotate;\n shape.setAttributeNS(null, 'transform', transform);\n const fill = NeonJazziconUtils.genColor(remainingColors, rand);\n shape.setAttributeNS(null, 'fill', fill);\n\n svg.appendChild(shape);\n }\n\n private static genColor(colors: string[], rand: () => number) {\n const idx = Math.floor(colors.length * rand());\n return colors.splice(idx, 1)[0];\n }\n\n private static hueShift(colors: Array<string>, rand: () => number) {\n const amount = rand() * 30 - NeonJazziconUtils.wobble / 2;\n const rotate = (hex: string) => NeonJazziconUtils.colorRotate(hex, amount);\n return colors.map(rotate);\n }\n\n private static colorRotate(hex: string, degrees: number) {\n const hsl = NeonJazziconUtils.hexToHSL(hex);\n let hue = hsl.h;\n hue = (hue + degrees) % 360;\n hue = hue < 0 ? 360 + hue : hue;\n hsl.h = hue;\n return NeonJazziconUtils.hslToHex(hsl);\n }\n\n private static hexToHSL(hex: string) {\n // Convert hex to RGB first\n let r = +('0x' + hex[1] + hex[2]);\n let g = +('0x' + hex[3] + hex[4]);\n let b = +('0x' + hex[5] + hex[6]);\n // Then to HSL\n r /= 255;\n g /= 255;\n b /= 255;\n const cmin = Math.min(r, g, b);\n const cmax = Math.max(r, g, b);\n const delta = cmax - cmin;\n let h = 0;\n let s = 0;\n let l = 0;\n\n if (delta === 0) {\n h = 0;\n } else if (cmax === r) {\n h = ((g - b) / delta) % 6;\n } else if (cmax === g) {\n h = (b - r) / delta + 2;\n } else {\n h = (r - g) / delta + 4;\n }\n\n h = Math.round(h * 60);\n\n if (h < 0) {\n h += 360;\n }\n\n l = (cmax + cmin) / 2;\n s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));\n s = +(s * 100).toFixed(1);\n l = +(l * 100).toFixed(1);\n\n return { h, s, l };\n }\n\n private static hslToHex(hsl: Record<string, any>) {\n const h = hsl.h;\n let { s, l } = hsl;\n s /= 100;\n l /= 100;\n\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1));\n const m = l - c / 2;\n let r = 0;\n let g = 0;\n let b = 0;\n\n if (h >= 0 && h < 60) {\n r = c;\n g = x;\n b = 0;\n } else if (h >= 60 && h < 120) {\n r = x;\n g = c;\n b = 0;\n } else if (h >= 120 && h < 180) {\n r = 0;\n g = c;\n b = x;\n } else if (h >= 180 && h < 240) {\n r = 0;\n g = x;\n b = c;\n } else if (h >= 240 && h < 300) {\n r = x;\n g = 0;\n b = c;\n } else if (h >= 300 && h < 360) {\n r = c;\n g = 0;\n b = x;\n }\n // Having obtained RGB, convert channels to hex\n let rStr = Math.round((r + m) * 255).toString(16);\n let gStr = Math.round((g + m) * 255).toString(16);\n let bStr = Math.round((b + m) * 255).toString(16);\n\n // Prepend 0s, if necessary\n if (rStr.length === 1) {\n rStr = '0' + r;\n }\n\n if (gStr.length === 1) {\n gStr = '0' + g;\n }\n\n if (bStr.length === 1) {\n bStr = '0' + b;\n }\n\n return '#' + rStr + gStr + bStr;\n }\n}\n"],"names":[],"mappings":";;;;;;;AAEO,MAAM,qBAAN,MAAwB;AAAA,EAW7B,OAAc,OAAO,SAAwB,MAAc,MAAsB;AACxE,WAAA,mBAAkB,kBAAkB,SAAS,MAAM,gBAAgB,KAAK,IAAI,CAAC,EAAE;AAAA,EACxF;AAAA,EAEA,OAAe,kBAAkB,SAAwB,UAAkB,MAAgC;AACzG,UAAM,kBAAkB,mBAAkB,SAAS,QAAQ,MAAA,GAAS,IAAI;AAExE,UAAM,MAAM,SAAS,gBAAgB,mBAAkB,OAAO,KAAK;AAC/D,QAAA,aAAa,SAAS,mBAAkB,KAAK;AAC7C,QAAA,eAAe,MAAM,KAAK,GAAG;AAC7B,QAAA,eA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,EAAE;AAG5C,QAAA,KAAK,WAAW,GAAG;AACrB,aAAO,MAAM;AAAA,IACf;AAEI,QAAA,KAAK,WAAW,GAAG;AACrB,aAAO,MAAM;AAAA,IACf;AAEI,QAAA,KAAK,WAAW,GAAG;AACrB,aAAO,MAAM;AAAA,IACf;AAEO,WAAA,MAAM,OAAO,OAAO;AAAA,EAC7B;AACF;AApMO,IAAM,oBAAN;AACL,cADW,mBACa,cAAa;AACrC,cAFW,mBAEa,SAAQ;AAChC,cAHW,mBAGa,UAAS;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});class i{static rand(r){return i.mulberry32(i.cyrb128(r)[0])}static cyrb128(r){let t=1779033703,e=3144134277,l=1013904242,u=2773480762;for(let h=0,a;h<r.length;h++)a=r.charCodeAt(h),t=e^Math.imul(t^a,597399067),e=l^Math.imul(e^a,2869860233),l=u^Math.imul(l^a,951274213),u=t^Math.imul(u^a,2716044179);return t=Math.imul(l^t>>>18,597399067),e=Math.imul(u^e>>>22,2869860233),l=Math.imul(t^l>>>17,951274213),u=Math.imul(e^u>>>19,2716044179),[(t^e^l^u)>>>0,(e^t)>>>0,(l^t)>>>0,(u^t)>>>0]}static mulberry32(r){return()=>{let t=r+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}}exports.NeonRandomUtils=i;
|
|
2
|
+
//# sourceMappingURL=NeonRandomUtils.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonRandomUtils.cjs.js","sources":["../../../src/common/utils/NeonRandomUtils.ts"],"sourcesContent":["export class NeonRandomUtils {\n public static rand(seed: string): () => number {\n return NeonRandomUtils.mulberry32(NeonRandomUtils.cyrb128(seed)[0]);\n }\n\n private static cyrb128(str: string) {\n let h1 = 1779033703;\n let h2 = 3144134277;\n let h3 = 1013904242;\n let h4 = 2773480762;\n\n for (let i = 0, k; i < str.length; i++) {\n k = str.charCodeAt(i);\n h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\n h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\n h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\n h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\n }\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\n return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];\n }\n\n private static mulberry32(a: number) {\n return () => {\n let t = (a += 1831565813);\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n }\n}\n"],"names":["NeonRandomUtils","seed","str","h1","h2","h3","h4","i","k","a"],"mappings":"4GAAO,MAAMA,CAAgB,CAC3B,OAAc,KAAKC,EAA4B,CAC7C,OAAOD,EAAgB,WAAWA,EAAgB,QAAQC,CAAI,EAAE,EAAE,CACpE,CAEA,OAAe,QAAQC,EAAa,CAClC,IAAIC,EAAK,WACLC,EAAK,WACLC,EAAK,WACLC,EAAK,WAET,QAASC,EAAI,EAAGC,EAAGD,EAAIL,EAAI,OAAQK,IAC7BC,EAAAN,EAAI,WAAWK,CAAC,EACpBJ,EAAKC,EAAK,KAAK,KAAKD,EAAKK,EAAG,SAAS,EACrCJ,EAAKC,EAAK,KAAK,KAAKD,EAAKI,EAAG,UAAU,EACtCH,EAAKC,EAAK,KAAK,KAAKD,EAAKG,EAAG,SAAS,EACrCF,EAAKH,EAAK,KAAK,KAAKG,EAAKE,EAAG,UAAU,EAExC,OAAAL,EAAK,KAAK,KAAKE,EAAMF,IAAO,GAAK,SAAS,EAC1CC,EAAK,KAAK,KAAKE,EAAMF,IAAO,GAAK,UAAU,EAC3CC,EAAK,KAAK,KAAKF,EAAME,IAAO,GAAK,SAAS,EAC1CC,EAAK,KAAK,KAAKF,EAAME,IAAO,GAAK,UAAU,EACpC,EAAEH,EAAKC,EAAKC,EAAKC,KAAQ,GAAIF,EAAKD,KAAQ,GAAIE,EAAKF,KAAQ,GAAIG,EAAKH,KAAQ,CAAC,CACtF,CAEA,OAAe,WAAWM,EAAW,CACnC,MAAO,IAAM,CACX,IAAI,EAAKA,GAAK,WACd,SAAI,KAAK,KAAK,EAAK,IAAM,GAAK,EAAI,CAAC,EACnC,GAAK,EAAI,KAAK,KAAK,EAAK,IAAM,EAAI,EAAI,EAAE,IAC/B,EAAK,IAAM,MAAS,GAAK,UAAA,CAEtC,CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class NeonRandomUtils {
|
|
2
|
+
static rand(seed) {
|
|
3
|
+
return NeonRandomUtils.mulberry32(NeonRandomUtils.cyrb128(seed)[0]);
|
|
4
|
+
}
|
|
5
|
+
static cyrb128(str) {
|
|
6
|
+
let h1 = 1779033703;
|
|
7
|
+
let h2 = 3144134277;
|
|
8
|
+
let h3 = 1013904242;
|
|
9
|
+
let h4 = 2773480762;
|
|
10
|
+
for (let i = 0, k; i < str.length; i++) {
|
|
11
|
+
k = str.charCodeAt(i);
|
|
12
|
+
h1 = h2 ^ Math.imul(h1 ^ k, 597399067);
|
|
13
|
+
h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);
|
|
14
|
+
h3 = h4 ^ Math.imul(h3 ^ k, 951274213);
|
|
15
|
+
h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);
|
|
16
|
+
}
|
|
17
|
+
h1 = Math.imul(h3 ^ h1 >>> 18, 597399067);
|
|
18
|
+
h2 = Math.imul(h4 ^ h2 >>> 22, 2869860233);
|
|
19
|
+
h3 = Math.imul(h1 ^ h3 >>> 17, 951274213);
|
|
20
|
+
h4 = Math.imul(h2 ^ h4 >>> 19, 2716044179);
|
|
21
|
+
return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];
|
|
22
|
+
}
|
|
23
|
+
static mulberry32(a) {
|
|
24
|
+
return () => {
|
|
25
|
+
let t = a += 1831565813;
|
|
26
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
27
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
28
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export { NeonRandomUtils };
|
|
33
|
+
//# sourceMappingURL=NeonRandomUtils.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonRandomUtils.es.js","sources":["../../../src/common/utils/NeonRandomUtils.ts"],"sourcesContent":["export class NeonRandomUtils {\n public static rand(seed: string): () => number {\n return NeonRandomUtils.mulberry32(NeonRandomUtils.cyrb128(seed)[0]);\n }\n\n private static cyrb128(str: string) {\n let h1 = 1779033703;\n let h2 = 3144134277;\n let h3 = 1013904242;\n let h4 = 2773480762;\n\n for (let i = 0, k; i < str.length; i++) {\n k = str.charCodeAt(i);\n h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\n h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\n h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\n h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\n }\n h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\n h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\n h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\n h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\n return [(h1 ^ h2 ^ h3 ^ h4) >>> 0, (h2 ^ h1) >>> 0, (h3 ^ h1) >>> 0, (h4 ^ h1) >>> 0];\n }\n\n private static mulberry32(a: number) {\n return () => {\n let t = (a += 1831565813);\n t = Math.imul(t ^ (t >>> 15), t | 1);\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61);\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n }\n}\n"],"names":[],"mappings":"AAAO,MAAM,gBAAgB;AAAA,EAC3B,OAAc,KAAK,MAA4B;AAC7C,WAAO,gBAAgB,WAAW,gBAAgB,QAAQ,IAAI,EAAE,EAAE;AAAA,EACpE;AAAA,EAEA,OAAe,QAAQ,KAAa;AAClC,QAAI,KAAK;AACT,QAAI,KAAK;AACT,QAAI,KAAK;AACT,QAAI,KAAK;AAET,aAAS,IAAI,GAAG,GAAG,IAAI,IAAI,QAAQ,KAAK;AAClC,UAAA,IAAI,WAAW,CAAC;AACpB,WAAK,KAAK,KAAK,KAAK,KAAK,GAAG,SAAS;AACrC,WAAK,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU;AACtC,WAAK,KAAK,KAAK,KAAK,KAAK,GAAG,SAAS;AACrC,WAAK,KAAK,KAAK,KAAK,KAAK,GAAG,UAAU;AAAA,IACxC;AACA,SAAK,KAAK,KAAK,KAAM,OAAO,IAAK,SAAS;AAC1C,SAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AAC3C,SAAK,KAAK,KAAK,KAAM,OAAO,IAAK,SAAS;AAC1C,SAAK,KAAK,KAAK,KAAM,OAAO,IAAK,UAAU;AAC3C,WAAO,EAAE,KAAK,KAAK,KAAK,QAAQ,IAAI,KAAK,QAAQ,IAAI,KAAK,QAAQ,IAAI,KAAK,QAAQ,CAAC;AAAA,EACtF;AAAA,EAEA,OAAe,WAAW,GAAW;AACnC,WAAO,MAAM;AACX,UAAI,IAAK,KAAK;AACd,UAAI,KAAK,KAAK,IAAK,MAAM,IAAK,IAAI,CAAC;AACnC,WAAK,IAAI,KAAK,KAAK,IAAK,MAAM,GAAI,IAAI,EAAE;AAC/B,eAAA,IAAK,MAAM,QAAS,KAAK;AAAA,IAAA;AAAA,EAEtC;AACF;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("./NeonBadge.
|
|
1
|
+
"use strict";var o=require("./NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js"),n=require("vue"),l=require("../../../_virtual/plugin-vue_export-helper.cjs.js");const r=["innerHTML"],s={key:1,class:"neon-badge__label"},i=["alt","src"];function c(e,t,g,b,p,u){const a=n.resolveComponent("neon-icon");return n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass([[`neon-badge--${e.color}`,e.alternateColor?`neon-badge--alternate-color-${e.alternateColor}`:"",`neon-badge--${e.size}`,{"neon-badge--with-label":e.label,"neon-badge--disabled":e.disabled,"neon-badge--with-image":e.image,"neon-badge--with-icon":e.icon},e.circular?"neon-badge--circular":"neon-badge--square"],"neon-badge"])},[e.jazziconId?(n.openBlock(),n.createElementBlock("div",{key:0,class:"neon-badge__image",innerHTML:e.svg},null,8,r)):e.label?(n.openBlock(),n.createElementBlock("span",s,n.toDisplayString(e.label),1)):e.image?(n.openBlock(),n.createElementBlock("img",{key:2,alt:e.imageAlt,src:e.image,class:"neon-badge__image"},null,8,i)):e.icon?(n.openBlock(),n.createBlock(a,{key:3,disabled:e.disabled,inverse:!!e.color,name:e.icon,class:"neon-badge__icon"},null,8,["disabled","inverse","name"])):n.createCommentVNode("",!0)],2)}var d=l(o,[["render",c]]);module.exports=d;
|
|
2
2
|
//# sourceMappingURL=NeonBadge.cjs.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import _sfc_main from "./NeonBadge.
|
|
1
|
+
import _sfc_main from "./NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js";
|
|
2
2
|
import { resolveComponent, openBlock, createElementBlock, normalizeClass, toDisplayString, createBlock, createCommentVNode } from "vue";
|
|
3
3
|
import _export_sfc from "../../../_virtual/plugin-vue_export-helper.es.js";
|
|
4
|
-
const _hoisted_1 =
|
|
5
|
-
|
|
4
|
+
const _hoisted_1 = ["innerHTML"];
|
|
5
|
+
const _hoisted_2 = {
|
|
6
|
+
key: 1,
|
|
6
7
|
class: "neon-badge__label"
|
|
7
8
|
};
|
|
8
|
-
const
|
|
9
|
+
const _hoisted_3 = ["alt", "src"];
|
|
9
10
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
10
11
|
const _component_neon_icon = resolveComponent("neon-icon");
|
|
11
12
|
return openBlock(), createElementBlock("div", {
|
|
@@ -22,13 +23,17 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
22
23
|
_ctx.circular ? "neon-badge--circular" : "neon-badge--square"
|
|
23
24
|
], "neon-badge"])
|
|
24
25
|
}, [
|
|
25
|
-
_ctx.
|
|
26
|
-
key:
|
|
26
|
+
_ctx.jazziconId ? (openBlock(), createElementBlock("div", {
|
|
27
|
+
key: 0,
|
|
28
|
+
class: "neon-badge__image",
|
|
29
|
+
innerHTML: _ctx.svg
|
|
30
|
+
}, null, 8, _hoisted_1)) : _ctx.label ? (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(_ctx.label), 1)) : _ctx.image ? (openBlock(), createElementBlock("img", {
|
|
31
|
+
key: 2,
|
|
27
32
|
alt: _ctx.imageAlt,
|
|
28
33
|
src: _ctx.image,
|
|
29
34
|
class: "neon-badge__image"
|
|
30
|
-
}, null, 8,
|
|
31
|
-
key:
|
|
35
|
+
}, null, 8, _hoisted_3)) : _ctx.icon ? (openBlock(), createBlock(_component_neon_icon, {
|
|
36
|
+
key: 3,
|
|
32
37
|
disabled: _ctx.disabled,
|
|
33
38
|
inverse: !!_ctx.color,
|
|
34
39
|
name: _ctx.icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeonBadge.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NeonBadge.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var l=require("vue"),r=require("../../../common/enums/NeonSize.cjs.js"),e=require("../../../common/enums/NeonFunctionalColor.cjs.js"),s=require("../icon/NeonIcon.cjs.js"),m=require("../../../common/utils/NeonJazziconUtils.cjs.js"),d=require("../../../common/utils/NeonColorUtils.cjs.js"),g=l.defineComponent({name:"NeonBadge",components:{NeonIcon:s},props:{label:{type:String,default:null},image:{type:String,default:null},icon:{type:String,default:null},circular:{type:Boolean,default:!1},size:{type:String,default:r.NeonSize.Medium},color:{type:String,default:e.NeonFunctionalColor.LowContrast},alternateColor:{type:String,default:null},disabled:{type:Boolean,default:!1},jazziconId:{type:String,default:null},imageAlt:{type:String,default:"Badge"}},setup(n){const o=a=>{let t=getComputedStyle(document.documentElement).getPropertyValue(`--neon-rgb-${a}-l1`);t.length===0&&(t="0, 0, 0");const u=t.trim().split(", ").map(c=>+c);return d.NeonColorUtils.rgbToHex(u)},i=l.computed(()=>["#000000",o(e.NeonFunctionalColor.Brand),o(e.NeonFunctionalColor.Primary),o(e.NeonFunctionalColor.Info),o(e.NeonFunctionalColor.Success),o(e.NeonFunctionalColor.Warn),o(e.NeonFunctionalColor.Error)]);return{svg:l.computed(()=>n.jazziconId?m.NeonJazziconUtils.genSvg(i.value,n.jazziconId,n.size===r.NeonSize.Small?32:n.size===r.NeonSize.Medium?40:48):null)}}});module.exports=g;
|
|
2
|
+
//# sourceMappingURL=NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js.map
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonBadge.ts_vue_type_script_src_720ca9b0_lang.cjs.js","sources":["../../../../src/components/presentation/badge/NeonBadge.ts?vue&type=script&src=720ca9b0&lang.ts"],"sourcesContent":["import { computed, defineComponent } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport { NeonJazziconUtils } from '@/common/utils/NeonJazziconUtils';\nimport { NeonColorUtils } from '@/common/utils/NeonColorUtils';\n\n/**\n * A badge is a small square or circular component for representing user avatars. These can be in the form of an image, an icon or a two character string (e.g. the user's initials).\n */\nexport default defineComponent({\n name: 'NeonBadge',\n components: {\n NeonIcon,\n },\n props: {\n /**\n * The two character <em>initials</em> to display on the badge.\n */\n label: { type: String, default: null },\n /**\n * URL of the image to display on the badge.\n */\n image: { type: String, default: null },\n /**\n * An icon to display on the badge.\n */\n icon: { type: String, default: null },\n /**\n * If true, render the badge as a circle, instead of a square.\n */\n circular: { type: Boolean, default: false },\n /**\n * The size of the badge - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the badge. This is one of the provided NeonFunctionalColors.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Alternate color for creating gradient badges. NOTE: can also be the same color as 'color'.\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * Display the badge in the disable style\n */\n disabled: { type: Boolean, default: false },\n /**\n * Apply the generated Jazzicon style based on the unique identified provided (e.g. a wallet address, name, etc)\n */\n jazziconId: { type: String, default: null },\n /**\n * Badge image alt text.\n */\n imageAlt: { type: String, default: 'Badge' },\n },\n setup(props) {\n const getColor = (key: NeonFunctionalColor) => {\n let colorString = getComputedStyle(document.documentElement).getPropertyValue(`--neon-rgb-${key}-l1`);\n if (colorString.length === 0) {\n colorString = '0, 0, 0';\n }\n const colorRgb = colorString\n .trim()\n .split(', ')\n .map((str) => +str);\n return NeonColorUtils.rgbToHex(colorRgb);\n };\n\n const palette = computed(() => [\n '#000000',\n getColor(NeonFunctionalColor.Brand),\n getColor(NeonFunctionalColor.Primary),\n getColor(NeonFunctionalColor.Info),\n getColor(NeonFunctionalColor.Success),\n getColor(NeonFunctionalColor.Warn),\n getColor(NeonFunctionalColor.Error),\n ]);\n\n const svg = computed(() =>\n props.jazziconId\n ? NeonJazziconUtils.genSvg(\n palette.value,\n props.jazziconId,\n props.size === NeonSize.Small ? 32 : props.size === NeonSize.Medium ? 40 : 48,\n )\n : null,\n );\n\n return {\n svg,\n };\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonIcon","NeonSize","NeonFunctionalColor","props","getColor","key","colorString","colorRgb","str","NeonColorUtils","palette","computed","NeonJazziconUtils"],"mappings":"6SAUAA,EAAeC,kBAAgB,CAC7B,KAAM,YACN,WAAY,CACV,SAAAC,CACF,EACA,MAAO,CAIL,MAAO,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIrC,MAAO,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIrC,KAAM,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIpC,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,KAAM,CAAE,KAAM,OAA0B,QAASC,EAAAA,SAAS,MAAO,EAIjE,MAAO,CAAE,KAAM,OAAqC,QAASC,EAAAA,oBAAoB,WAAY,EAI7F,eAAgB,CAAE,KAAM,OAAqC,QAAS,IAAK,EAI3E,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,WAAY,CAAE,KAAM,OAAQ,QAAS,IAAK,EAI1C,SAAU,CAAE,KAAM,OAAQ,QAAS,OAAQ,CAC7C,EACA,MAAMC,EAAO,CACL,MAAAC,EAAYC,GAA6B,CAC7C,IAAIC,EAAc,iBAAiB,SAAS,eAAe,EAAE,iBAAiB,cAAcD,MAAQ,EAChGC,EAAY,SAAW,IACXA,EAAA,WAEV,MAAAC,EAAWD,EACd,KAAA,EACA,MAAM,IAAI,EACV,IAAKE,GAAQ,CAACA,CAAG,EACb,OAAAC,EAAA,eAAe,SAASF,CAAQ,CAAA,EAGnCG,EAAUC,EAAAA,SAAS,IAAM,CAC7B,UACAP,EAASF,sBAAoB,KAAK,EAClCE,EAASF,sBAAoB,OAAO,EACpCE,EAASF,sBAAoB,IAAI,EACjCE,EAASF,sBAAoB,OAAO,EACpCE,EAASF,sBAAoB,IAAI,EACjCE,EAASF,sBAAoB,KAAK,CAAA,CACnC,EAYM,MAAA,CACL,IAXUS,EAAA,SAAS,IACnBR,EAAM,WACFS,EAAAA,kBAAkB,OAClBF,EAAQ,MACRP,EAAM,WACNA,EAAM,OAASF,WAAS,MAAQ,GAAKE,EAAM,OAASF,EAAS,SAAA,OAAS,GAAK,EAAA,EAE3E,IAAA,CAIJ,CAEJ,CACF,CAAC"}
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { defineComponent, computed } from "vue";
|
|
2
|
+
import { NeonSize } from "../../../common/enums/NeonSize.es.js";
|
|
3
|
+
import { NeonFunctionalColor } from "../../../common/enums/NeonFunctionalColor.es.js";
|
|
4
|
+
import NeonIcon from "../icon/NeonIcon.es.js";
|
|
5
|
+
import { NeonJazziconUtils } from "../../../common/utils/NeonJazziconUtils.es.js";
|
|
6
|
+
import { NeonColorUtils } from "../../../common/utils/NeonColorUtils.es.js";
|
|
7
|
+
var _sfc_main = defineComponent({
|
|
8
|
+
name: "NeonBadge",
|
|
9
|
+
components: {
|
|
10
|
+
NeonIcon
|
|
11
|
+
},
|
|
12
|
+
props: {
|
|
13
|
+
label: { type: String, default: null },
|
|
14
|
+
image: { type: String, default: null },
|
|
15
|
+
icon: { type: String, default: null },
|
|
16
|
+
circular: { type: Boolean, default: false },
|
|
17
|
+
size: { type: String, default: NeonSize.Medium },
|
|
18
|
+
color: { type: String, default: NeonFunctionalColor.LowContrast },
|
|
19
|
+
alternateColor: { type: String, default: null },
|
|
20
|
+
disabled: { type: Boolean, default: false },
|
|
21
|
+
jazziconId: { type: String, default: null },
|
|
22
|
+
imageAlt: { type: String, default: "Badge" }
|
|
23
|
+
},
|
|
24
|
+
setup(props) {
|
|
25
|
+
const getColor = (key) => {
|
|
26
|
+
let colorString = getComputedStyle(document.documentElement).getPropertyValue(`--neon-rgb-${key}-l1`);
|
|
27
|
+
if (colorString.length === 0) {
|
|
28
|
+
colorString = "0, 0, 0";
|
|
29
|
+
}
|
|
30
|
+
const colorRgb = colorString.trim().split(", ").map((str) => +str);
|
|
31
|
+
return NeonColorUtils.rgbToHex(colorRgb);
|
|
32
|
+
};
|
|
33
|
+
const palette = computed(() => [
|
|
34
|
+
"#000000",
|
|
35
|
+
getColor(NeonFunctionalColor.Brand),
|
|
36
|
+
getColor(NeonFunctionalColor.Primary),
|
|
37
|
+
getColor(NeonFunctionalColor.Info),
|
|
38
|
+
getColor(NeonFunctionalColor.Success),
|
|
39
|
+
getColor(NeonFunctionalColor.Warn),
|
|
40
|
+
getColor(NeonFunctionalColor.Error)
|
|
41
|
+
]);
|
|
42
|
+
const svg = computed(
|
|
43
|
+
() => props.jazziconId ? NeonJazziconUtils.genSvg(
|
|
44
|
+
palette.value,
|
|
45
|
+
props.jazziconId,
|
|
46
|
+
props.size === NeonSize.Small ? 32 : props.size === NeonSize.Medium ? 40 : 48
|
|
47
|
+
) : null
|
|
48
|
+
);
|
|
49
|
+
return {
|
|
50
|
+
svg
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export { _sfc_main as default };
|
|
55
|
+
//# sourceMappingURL=NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js.map
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeonBadge.ts_vue_type_script_src_720ca9b0_lang.es.js","sources":["../../../../src/components/presentation/badge/NeonBadge.ts?vue&type=script&src=720ca9b0&lang.ts"],"sourcesContent":["import { computed, defineComponent } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\nimport { NeonJazziconUtils } from '@/common/utils/NeonJazziconUtils';\nimport { NeonColorUtils } from '@/common/utils/NeonColorUtils';\n\n/**\n * A badge is a small square or circular component for representing user avatars. These can be in the form of an image, an icon or a two character string (e.g. the user's initials).\n */\nexport default defineComponent({\n name: 'NeonBadge',\n components: {\n NeonIcon,\n },\n props: {\n /**\n * The two character <em>initials</em> to display on the badge.\n */\n label: { type: String, default: null },\n /**\n * URL of the image to display on the badge.\n */\n image: { type: String, default: null },\n /**\n * An icon to display on the badge.\n */\n icon: { type: String, default: null },\n /**\n * If true, render the badge as a circle, instead of a square.\n */\n circular: { type: Boolean, default: false },\n /**\n * The size of the badge - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the badge. This is one of the provided NeonFunctionalColors.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Alternate color for creating gradient badges. NOTE: can also be the same color as 'color'.\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * Display the badge in the disable style\n */\n disabled: { type: Boolean, default: false },\n /**\n * Apply the generated Jazzicon style based on the unique identified provided (e.g. a wallet address, name, etc)\n */\n jazziconId: { type: String, default: null },\n /**\n * Badge image alt text.\n */\n imageAlt: { type: String, default: 'Badge' },\n },\n setup(props) {\n const getColor = (key: NeonFunctionalColor) => {\n let colorString = getComputedStyle(document.documentElement).getPropertyValue(`--neon-rgb-${key}-l1`);\n if (colorString.length === 0) {\n colorString = '0, 0, 0';\n }\n const colorRgb = colorString\n .trim()\n .split(', ')\n .map((str) => +str);\n return NeonColorUtils.rgbToHex(colorRgb);\n };\n\n const palette = computed(() => [\n '#000000',\n getColor(NeonFunctionalColor.Brand),\n getColor(NeonFunctionalColor.Primary),\n getColor(NeonFunctionalColor.Info),\n getColor(NeonFunctionalColor.Success),\n getColor(NeonFunctionalColor.Warn),\n getColor(NeonFunctionalColor.Error),\n ]);\n\n const svg = computed(() =>\n props.jazziconId\n ? NeonJazziconUtils.genSvg(\n palette.value,\n props.jazziconId,\n props.size === NeonSize.Small ? 32 : props.size === NeonSize.Medium ? 40 : 48,\n )\n : null,\n );\n\n return {\n svg,\n };\n },\n});\n"],"names":[],"mappings":";;;;;;AAUA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIpC,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,MAAM,EAAE,MAAM,QAA0B,SAAS,SAAS,OAAO;AAAA,IAIjE,OAAO,EAAE,MAAM,QAAqC,SAAS,oBAAoB,YAAY;AAAA,IAI7F,gBAAgB,EAAE,MAAM,QAAqC,SAAS,KAAK;AAAA,IAI3E,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,YAAY,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAI1C,UAAU,EAAE,MAAM,QAAQ,SAAS,QAAQ;AAAA,EAC7C;AAAA,EACA,MAAM,OAAO;AACL,UAAA,WAAW,CAAC,QAA6B;AAC7C,UAAI,cAAc,iBAAiB,SAAS,eAAe,EAAE,iBAAiB,cAAc,QAAQ;AAChG,UAAA,YAAY,WAAW,GAAG;AACd,sBAAA;AAAA,MAChB;AACM,YAAA,WAAW,YACd,KAAA,EACA,MAAM,IAAI,EACV,IAAI,CAAC,QAAQ,CAAC,GAAG;AACb,aAAA,eAAe,SAAS,QAAQ;AAAA,IAAA;AAGnC,UAAA,UAAU,SAAS,MAAM;AAAA,MAC7B;AAAA,MACA,SAAS,oBAAoB,KAAK;AAAA,MAClC,SAAS,oBAAoB,OAAO;AAAA,MACpC,SAAS,oBAAoB,IAAI;AAAA,MACjC,SAAS,oBAAoB,OAAO;AAAA,MACpC,SAAS,oBAAoB,IAAI;AAAA,MACjC,SAAS,oBAAoB,KAAK;AAAA,IAAA,CACnC;AAED,UAAM,MAAM;AAAA,MAAS,MACnB,MAAM,aACF,kBAAkB;AAAA,QAClB,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,MAAM,SAAS,SAAS,QAAQ,KAAK,MAAM,SAAS,SAAS,SAAS,KAAK;AAAA,MAAA,IAE3E;AAAA,IAAA;AAGC,WAAA;AAAA,MACL;AAAA,IAAA;AAAA,EAEJ;AACF,CAAC;;"}
|
package/dist/neon.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var o=require("./components/navigation/action-menu/NeonActionMenu.cjs.js"),n=require("./components/feedback/alert/NeonAlert.cjs.js"),r=require("./components/feedback/alert/container/NeonAlertContainer.cjs.js"),s=require("./components/navigation/anchor/NeonAnchor.cjs.js"),t=require("./components/presentation/badge/NeonBadge.cjs.js"),i=require("./components/user-input/button/NeonButton.cjs.js"),a=require("./components/layout/card/NeonCard.cjs.js"),N=require("./components/layout/card/body/NeonCardBody.cjs.js"),c=require("./components/layout/card/footer/NeonCardFooter.cjs.js"),l=require("./components/layout/card/header/NeonCardHeader.cjs.js"),u=require("./components/user-input/chip/NeonChip.cjs.js"),p=require("./components/user-input/color/NeonColor.cjs.js"),m=require("./components/user-input/date-picker/NeonDatePicker.cjs.js"),j=require("./components/feedback/dialog/NeonDialog.cjs.js"),d=require("./components/layout/drawer/NeonDrawer.cjs.js"),v=require("./components/presentation/dropdown/NeonDropdown.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var o=require("./components/navigation/action-menu/NeonActionMenu.cjs.js"),n=require("./components/feedback/alert/NeonAlert.cjs.js"),r=require("./components/feedback/alert/container/NeonAlertContainer.cjs.js"),s=require("./components/navigation/anchor/NeonAnchor.cjs.js"),t=require("./components/presentation/badge/NeonBadge.cjs.js"),i=require("./components/user-input/button/NeonButton.cjs.js"),a=require("./components/layout/card/NeonCard.cjs.js"),N=require("./components/layout/card/body/NeonCardBody.cjs.js"),c=require("./components/layout/card/footer/NeonCardFooter.cjs.js"),l=require("./components/layout/card/header/NeonCardHeader.cjs.js"),u=require("./components/user-input/chip/NeonChip.cjs.js"),p=require("./components/user-input/color/NeonColor.cjs.js"),m=require("./components/user-input/date-picker/NeonDatePicker.cjs.js"),j=require("./components/feedback/dialog/NeonDialog.cjs.js"),d=require("./components/layout/drawer/NeonDrawer.cjs.js"),v=require("./components/presentation/dropdown/NeonDropdown.cjs.js"),q=require("./components/navigation/dropdown-menu/NeonDropdownMenu.cjs.js"),S=require("./components/user-input/drop-zone/NeonDropZone.cjs.js"),g=require("./components/presentation/expansion-indicator/NeonExpansionIndicator.cjs.js"),b=require("./components/presentation/expansion-panel/NeonExpansionPanel.cjs.js"),P=require("./components/user-input/field-group/NeonFieldGroup.cjs.js"),C=require("./components/user-input/field/NeonField.cjs.js"),y=require("./components/user-input/file/NeonFile.cjs.js"),U=require("./components/user-input/filter-list/NeonFilterList.cjs.js"),T=require("./components/layout/footer/NeonFooter.cjs.js"),D=require("./components/layout/grid/NeonGrid.cjs.js"),h=require("./components/layout/grid/grid-area/NeonGridArea.cjs.js"),w=require("./components/presentation/icon/NeonIcon.cjs.js"),L=require("./components/user-input/input/NeonInput.cjs.js"),A=require("./components/user-input/input-indicator/NeonInputIndicator.cjs.js"),I=require("./components/presentation/label/NeonLabel.cjs.js"),z=require("./components/feedback/linear-progress/NeonLinearProgress.cjs.js"),M=require("./components/navigation/link/NeonLink.cjs.js"),R=require("./components/user-input/list/NeonList.cjs.js"),k=require("./components/navigation/menu/NeonMenu.cjs.js"),F=require("./components/layout/modal/NeonModal.cjs.js"),f=require("./components/feedback/note/NeonNote.cjs.js"),B=require("./components/feedback/notification-counter/NeonNotificationCounter.cjs.js"),E=require("./components/user-input/number/NeonNumber.cjs.js"),G=require("./components/layout/page/NeonPage.cjs.js"),O=require("./components/user-input/password/NeonPassword.cjs.js"),x=require("./components/user-input/range-slider/NeonRangeSlider.cjs.js"),H=require("./components/layout/side-nav/NeonSideNav.cjs.js"),J=require("./components/user-input/search/NeonSearch.cjs.js"),V=require("./components/user-input/select/NeonSelect.cjs.js"),Z=require("./components/user-input/selectable-card/NeonSelectableCard.cjs.js"),_=require("./components/feedback/skeleton-loader/NeonSkeletonLoader.cjs.js"),K=require("./components/user-input/slider/NeonSlider.cjs.js"),Q=require("./components/feedback/splash-loader/NeonSplashLoader.cjs.js"),W=require("./components/navigation/stepper/NeonStepper.cjs.js"),X=require("./components/user-input/switch/NeonSwitch.cjs.js"),Y=require("./components/presentation/tabs/tab/NeonTab.cjs.js"),$=require("./components/presentation/tabs/NeonTabs.cjs.js"),ee=require("./components/feedback/alert/container/NeonToastContainer.cjs.js"),oe=require("./components/user-input/toggle/NeonToggle.cjs.js"),ne=require("./components/user-input/toggle-chip/NeonToggleChip.cjs.js"),re=require("./components/feedback/tooltip/NeonTooltip.cjs.js"),se=require("./components/layout/top-nav/NeonTopNav.cjs.js"),te=require("./components/navigation/tree-menu/NeonTreeMenu.cjs.js"),ie=require("./common/enums/NeonAlertLevel.cjs.js"),ae=require("./common/enums/NeonAlertPlacement.cjs.js"),Ne=require("./common/enums/NeonButtonSize.cjs.js"),ce=require("./common/enums/NeonButtonStyle.cjs.js"),le=require("./common/enums/NeonChipAction.cjs.js"),ue=require("./common/enums/NeonDropdownPlacement.cjs.js"),pe=require("./common/enums/NeonDropdownStyle.cjs.js"),me=require("./common/enums/NeonFunctionalColor.cjs.js"),je=require("./common/enums/NeonHorizontalPosition.cjs.js"),de=require("./common/enums/NeonInputMode.cjs.js"),ve=require("./common/enums/NeonInputType.cjs.js"),qe=require("./common/enums/NeonLabelSize.cjs.js"),Se=require("./common/enums/NeonMode.cjs.js"),ge=require("./common/enums/NeonOrientation.cjs.js"),be=require("./common/enums/NeonOutlineStyle.cjs.js"),Pe=require("./common/enums/NeonPlacement.cjs.js"),Ce=require("./common/enums/NeonPosition.cjs.js"),ye=require("./common/enums/NeonResponsive.cjs.js"),Ue=require("./common/enums/NeonSize.cjs.js"),Te=require("./common/enums/NeonSplashLoaderSize.cjs.js"),De=require("./common/enums/NeonState.cjs.js"),he=require("./common/enums/NeonSwitchStyle.cjs.js"),we=require("./common/enums/NeonToggleStyle.cjs.js"),Le=require("./common/enums/NeonTooltipStyle.cjs.js"),Ae=require("./common/enums/NeonVerticalPosition.cjs.js"),Ie=require("./common/utils/NeonAlertService.cjs.js"),e=require("./common/utils/NeonClipboardService.cjs.js"),ze=require("./common/utils/NeonClosableUtils.cjs.js"),Me=require("./common/utils/NeonDateUtils.cjs.js"),Re=require("./common/utils/NeonDebounceUtils.cjs.js"),ke=require("./common/utils/NeonDropdownPlacementUtils.cjs.js"),Fe=require("./common/utils/NeonEventBus.cjs.js"),fe=require("./common/utils/NeonIconRegistry.cjs.js"),Be=require("./common/utils/NeonJazziconUtils.cjs.js"),Ee=require("./common/utils/NeonModeUtils.cjs.js"),Ge=require("./common/utils/NeonNumberUtils.cjs.js"),Oe=require("./common/utils/NeonPlacementUtils.cjs.js"),xe=require("./common/utils/NeonRandomUtils.cjs.js"),He=require("./common/utils/NeonResponsiveUtils.cjs.js"),Je=require("./common/utils/NeonScrollUtils.cjs.js"),Ve=require("./common/utils/NeonToastService.cjs.js"),Ze=require("./common/utils/NeonTooltipPlacementUtils.cjs.js"),_e=require("./common/utils/RegisterIcons.cjs.js");exports.NeonActionMenu=o;exports.NeonAlert=n;exports.NeonAlertContainer=r;exports.NeonAnchor=s;exports.NeonBadge=t;exports.NeonButton=i;exports.NeonCard=a;exports.NeonCardBody=N;exports.NeonCardFooter=c;exports.NeonCardHeader=l;exports.NeonChip=u;exports.NeonColor=p;exports.NeonDatePicker=m;exports.NeonDialog=j;exports.NeonDrawer=d;exports.NeonDropdown=v;exports.NeonDropdownMenu=q;exports.NeonDropZone=S;exports.NeonExpansionIndicator=g;exports.NeonExpansionPanel=b;exports.NeonFieldGroup=P;exports.NeonField=C;exports.NeonFile=y;exports.NeonFilterList=U;exports.NeonFooter=T;exports.NeonGrid=D;exports.NeonGridArea=h;exports.NeonIcon=w;exports.NeonInput=L;exports.NeonInputIndicator=A;exports.NeonLabel=I;exports.NeonLinearProgress=z;exports.NeonLink=M;exports.NeonList=R;exports.NeonMenu=k;exports.NeonModal=F;exports.NeonNote=f;exports.NeonNotificationCounter=B;exports.NeonNumber=E;exports.NeonPage=G;exports.NeonPassword=O;exports.NeonRangeSlider=x;exports.NeonSideNav=H;exports.NeonSearch=J;exports.NeonSelect=V;exports.NeonSelectableCard=Z;exports.NeonSkeletonLoader=_;exports.NeonSlider=K;exports.NeonSplashLoader=Q;exports.NeonStepper=W;exports.NeonSwitch=X;exports.NeonTab=Y;exports.NeonTabs=$;exports.NeonToastContainer=ee;exports.NeonToggle=oe;exports.NeonToggleChip=ne;exports.NeonTooltip=re;exports.NeonTopNav=se;exports.NeonTreeMenu=te;exports.NeonAlertLevel=ie.NeonAlertLevel;exports.NeonAlertPlacement=ae.NeonAlertPlacement;exports.NeonButtonSize=Ne.NeonButtonSize;exports.NeonButtonStyle=ce.NeonButtonStyle;exports.NeonChipAction=le.NeonChipAction;exports.NeonDropdownPlacement=ue.NeonDropdownPlacement;exports.NeonDropdownStyle=pe.NeonDropdownStyle;exports.NeonFunctionalColor=me.NeonFunctionalColor;exports.NeonHorizontalPosition=je.NeonHorizontalPosition;exports.NeonInputMode=de.NeonInputMode;exports.NeonInputType=ve.NeonInputType;exports.NeonLabelSize=qe.NeonLabelSize;exports.NeonMode=Se.NeonMode;exports.NeonOrientation=ge.NeonOrientation;exports.NeonOutlineStyle=be.NeonOutlineStyle;exports.NeonPlacement=Pe.NeonPlacement;exports.NeonPosition=Ce.NeonPosition;exports.NeonResponsive=ye.NeonResponsive;exports.NeonSize=Ue.NeonSize;exports.NeonSplashLoaderSize=Te.NeonSplashLoaderSize;exports.NeonState=De.NeonState;exports.NeonSwitchStyle=he.NeonSwitchStyle;exports.NeonToggleStyle=we.NeonToggleStyle;exports.NeonTooltipStyle=Le.NeonTooltipStyle;exports.NeonVerticalPosition=Ae.NeonVerticalPosition;exports.NeonAlertService=Ie.NeonAlertService;exports.NeonClipboardService=e.NeonClipboardService;exports.NeonClipboardSupport=e.NeonClipboardSupport;exports.NeonClosableUtils=ze.NeonClosableUtils;exports.NeonDateUtils=Me.NeonDateUtils;exports.NeonDebounceUtils=Re.NeonDebounceUtils;exports.NeonDropdownPlacementUtils=ke.NeonDropdownPlacementUtils;exports.NeonEventBus=Fe.NeonEventBus;exports.NeonIconRegistry=fe.NeonIconRegistry;exports.NeonJazziconUtils=Be.NeonJazziconUtils;exports.NeonModeUtils=Ee.NeonModeUtils;exports.NeonNumberUtils=Ge.NeonNumberUtils;exports.NeonPlacementUtils=Oe.NeonPlacementUtils;exports.NeonRandomUtils=xe.NeonRandomUtils;exports.NeonResponsiveUtils=He.NeonResponsiveUtils;exports.NeonScrollUtils=Je.NeonScrollUtils;exports.NeonToastService=Ve.NeonToastService;exports.NeonTooltipPlacementUtils=Ze.NeonTooltipPlacementUtils;exports.RegisterIcons=_e.RegisterIcons;
|
|
2
2
|
//# sourceMappingURL=neon.cjs.js.map
|
package/dist/neon.es.js
CHANGED
|
@@ -90,9 +90,11 @@ export { NeonDebounceUtils } from "./common/utils/NeonDebounceUtils.es.js";
|
|
|
90
90
|
export { NeonDropdownPlacementUtils } from "./common/utils/NeonDropdownPlacementUtils.es.js";
|
|
91
91
|
export { NeonEventBus } from "./common/utils/NeonEventBus.es.js";
|
|
92
92
|
export { NeonIconRegistry } from "./common/utils/NeonIconRegistry.es.js";
|
|
93
|
+
export { NeonJazziconUtils } from "./common/utils/NeonJazziconUtils.es.js";
|
|
93
94
|
export { NeonModeUtils } from "./common/utils/NeonModeUtils.es.js";
|
|
94
95
|
export { NeonNumberUtils } from "./common/utils/NeonNumberUtils.es.js";
|
|
95
96
|
export { NeonPlacementUtils } from "./common/utils/NeonPlacementUtils.es.js";
|
|
97
|
+
export { NeonRandomUtils } from "./common/utils/NeonRandomUtils.es.js";
|
|
96
98
|
export { NeonResponsiveUtils } from "./common/utils/NeonResponsiveUtils.es.js";
|
|
97
99
|
export { NeonScrollUtils } from "./common/utils/NeonScrollUtils.es.js";
|
|
98
100
|
export { NeonToastService } from "./common/utils/NeonToastService.es.js";
|
package/dist/neon.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neon.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"neon.es.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class NeonJazziconUtils {
|
|
2
|
+
private static readonly shapeCount;
|
|
3
|
+
private static readonly svgns;
|
|
4
|
+
private static readonly wobble;
|
|
5
|
+
/**
|
|
6
|
+
* Returns base-64 encoded data URI
|
|
7
|
+
* @param palette the color palettes to use when generating the Jazzicon
|
|
8
|
+
* @param name used for random seed
|
|
9
|
+
* @param size size in pixels to generate
|
|
10
|
+
*/
|
|
11
|
+
static genSvg(palette: Array<string>, name: string, size: number): string;
|
|
12
|
+
private static generateIdenticon;
|
|
13
|
+
private static genShape;
|
|
14
|
+
private static genColor;
|
|
15
|
+
private static hueShift;
|
|
16
|
+
private static colorRotate;
|
|
17
|
+
private static hexToHSL;
|
|
18
|
+
private static hslToHex;
|
|
19
|
+
}
|
|
@@ -60,6 +60,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
60
60
|
type: BooleanConstructor;
|
|
61
61
|
default: boolean;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Apply the generated Jazzicon style based on the unique identified provided (e.g. a wallet address, name, etc)
|
|
65
|
+
*/
|
|
66
|
+
jazziconId: {
|
|
67
|
+
type: StringConstructor;
|
|
68
|
+
default: null;
|
|
69
|
+
};
|
|
63
70
|
/**
|
|
64
71
|
* Badge image alt text.
|
|
65
72
|
*/
|
|
@@ -67,7 +74,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
67
74
|
type: StringConstructor;
|
|
68
75
|
default: string;
|
|
69
76
|
};
|
|
70
|
-
},
|
|
77
|
+
}, {
|
|
78
|
+
svg: import("vue").ComputedRef<string | null>;
|
|
79
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
71
80
|
/**
|
|
72
81
|
* The two character <em>initials</em> to display on the badge.
|
|
73
82
|
*/
|
|
@@ -124,6 +133,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
124
133
|
type: BooleanConstructor;
|
|
125
134
|
default: boolean;
|
|
126
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* Apply the generated Jazzicon style based on the unique identified provided (e.g. a wallet address, name, etc)
|
|
138
|
+
*/
|
|
139
|
+
jazziconId: {
|
|
140
|
+
type: StringConstructor;
|
|
141
|
+
default: null;
|
|
142
|
+
};
|
|
127
143
|
/**
|
|
128
144
|
* Badge image alt text.
|
|
129
145
|
*/
|
|
@@ -140,6 +156,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
140
156
|
circular: boolean;
|
|
141
157
|
size: NeonSize;
|
|
142
158
|
alternateColor: NeonFunctionalColor;
|
|
159
|
+
jazziconId: string;
|
|
143
160
|
imageAlt: string;
|
|
144
161
|
}>;
|
|
145
162
|
export default _default;
|
package/dist/src/neon.d.ts
CHANGED
|
@@ -115,9 +115,11 @@ export { NeonDebounceUtils } from './common/utils/NeonDebounceUtils';
|
|
|
115
115
|
export { NeonDropdownPlacementUtils } from './common/utils/NeonDropdownPlacementUtils';
|
|
116
116
|
export { NeonEventBus } from './common/utils/NeonEventBus';
|
|
117
117
|
export { NeonIconRegistry } from './common/utils/NeonIconRegistry';
|
|
118
|
+
export { NeonJazziconUtils } from './common/utils/NeonJazziconUtils';
|
|
118
119
|
export { NeonModeUtils } from './common/utils/NeonModeUtils';
|
|
119
120
|
export { NeonNumberUtils } from './common/utils/NeonNumberUtils';
|
|
120
121
|
export { NeonPlacementUtils } from './common/utils/NeonPlacementUtils';
|
|
122
|
+
export { NeonRandomUtils } from './common/utils/NeonRandomUtils';
|
|
121
123
|
export { NeonResponsiveUtils } from './common/utils/NeonResponsiveUtils';
|
|
122
124
|
export { NeonScrollUtils } from './common/utils/NeonScrollUtils';
|
|
123
125
|
export { NeonToastService } from './common/utils/NeonToastService';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aotearoan/neon",
|
|
3
3
|
"description": "Neon is a lightweight design library of Vue 3 components with minimal dependencies.",
|
|
4
|
-
"version": "10.0
|
|
4
|
+
"version": "10.1.0",
|
|
5
5
|
"main": "./dist/neon.cjs.js",
|
|
6
6
|
"module": "./dist/neon.es.js",
|
|
7
7
|
"types": "./dist/src/neon.d.ts",
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.cjs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var e=require("vue"),n=require("../../../common/enums/NeonSize.cjs.js"),o=require("../../../common/enums/NeonFunctionalColor.cjs.js"),t=require("../icon/NeonIcon.cjs.js"),l=e.defineComponent({name:"NeonBadge",components:{NeonIcon:t},props:{label:{type:String,default:null},image:{type:String,default:null},icon:{type:String,default:null},circular:{type:Boolean,default:!1},size:{type:String,default:n.NeonSize.Medium},color:{type:String,default:o.NeonFunctionalColor.LowContrast},alternateColor:{type:String,default:null},disabled:{type:Boolean,default:!1},imageAlt:{type:String,default:"Badge"}}});module.exports=l;
|
|
2
|
-
//# sourceMappingURL=NeonBadge.ts_vue_type_script_src_3224431b_lang.cjs.js.map
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NeonBadge.ts_vue_type_script_src_3224431b_lang.cjs.js","sources":["../../../../src/components/presentation/badge/NeonBadge.ts?vue&type=script&src=3224431b&lang.ts"],"sourcesContent":["import { defineComponent } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\n\n/**\n * A badge is a small square or circular component for representing user avatars. These can be in the form of an image, an icon or a two character string (e.g. the user's initials).\n */\nexport default defineComponent({\n name: 'NeonBadge',\n components: {\n NeonIcon,\n },\n props: {\n /**\n * The two character <em>initials</em> to display on the badge.\n */\n label: { type: String, default: null },\n /**\n * URL of the image to display on the badge.\n */\n image: { type: String, default: null },\n /**\n * An icon to display on the badge.\n */\n icon: { type: String, default: null },\n /**\n * If true, render the badge as a circle, instead of a square.\n */\n circular: { type: Boolean, default: false },\n /**\n * The size of the badge - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the badge. This is one of the provided NeonFunctionalColors.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Alternate color for creating gradient badges. NOTE: can also be the same color as 'color'.\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * Display the badge in the disable style\n */\n disabled: { type: Boolean, default: false },\n /**\n * Badge image alt text.\n */\n imageAlt: { type: String, default: 'Badge' },\n },\n});\n"],"names":["_sfc_main","defineComponent","NeonIcon","NeonSize","NeonFunctionalColor"],"mappings":"wLAQAA,EAAeC,kBAAgB,CAC7B,KAAM,YACN,WAAY,CACV,SAAAC,CACF,EACA,MAAO,CAIL,MAAO,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIrC,MAAO,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIrC,KAAM,CAAE,KAAM,OAAQ,QAAS,IAAK,EAIpC,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,KAAM,CAAE,KAAM,OAA0B,QAASC,EAAAA,SAAS,MAAO,EAIjE,MAAO,CAAE,KAAM,OAAqC,QAASC,EAAAA,oBAAoB,WAAY,EAI7F,eAAgB,CAAE,KAAM,OAAqC,QAAS,IAAK,EAI3E,SAAU,CAAE,KAAM,QAAS,QAAS,EAAM,EAI1C,SAAU,CAAE,KAAM,OAAQ,QAAS,OAAQ,CAC7C,CACF,CAAC"}
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.es.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineComponent } from "vue";
|
|
2
|
-
import { NeonSize } from "../../../common/enums/NeonSize.es.js";
|
|
3
|
-
import { NeonFunctionalColor } from "../../../common/enums/NeonFunctionalColor.es.js";
|
|
4
|
-
import NeonIcon from "../icon/NeonIcon.es.js";
|
|
5
|
-
var _sfc_main = defineComponent({
|
|
6
|
-
name: "NeonBadge",
|
|
7
|
-
components: {
|
|
8
|
-
NeonIcon
|
|
9
|
-
},
|
|
10
|
-
props: {
|
|
11
|
-
label: { type: String, default: null },
|
|
12
|
-
image: { type: String, default: null },
|
|
13
|
-
icon: { type: String, default: null },
|
|
14
|
-
circular: { type: Boolean, default: false },
|
|
15
|
-
size: { type: String, default: NeonSize.Medium },
|
|
16
|
-
color: { type: String, default: NeonFunctionalColor.LowContrast },
|
|
17
|
-
alternateColor: { type: String, default: null },
|
|
18
|
-
disabled: { type: Boolean, default: false },
|
|
19
|
-
imageAlt: { type: String, default: "Badge" }
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
export { _sfc_main as default };
|
|
23
|
-
//# sourceMappingURL=NeonBadge.ts_vue_type_script_src_3224431b_lang.es.js.map
|
package/dist/components/presentation/badge/NeonBadge.ts_vue_type_script_src_3224431b_lang.es.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NeonBadge.ts_vue_type_script_src_3224431b_lang.es.js","sources":["../../../../src/components/presentation/badge/NeonBadge.ts?vue&type=script&src=3224431b&lang.ts"],"sourcesContent":["import { defineComponent } from 'vue';\nimport { NeonSize } from '@/common/enums/NeonSize';\nimport { NeonFunctionalColor } from '@/common/enums/NeonFunctionalColor';\nimport NeonIcon from '@/components/presentation/icon/NeonIcon.vue';\n\n/**\n * A badge is a small square or circular component for representing user avatars. These can be in the form of an image, an icon or a two character string (e.g. the user's initials).\n */\nexport default defineComponent({\n name: 'NeonBadge',\n components: {\n NeonIcon,\n },\n props: {\n /**\n * The two character <em>initials</em> to display on the badge.\n */\n label: { type: String, default: null },\n /**\n * URL of the image to display on the badge.\n */\n image: { type: String, default: null },\n /**\n * An icon to display on the badge.\n */\n icon: { type: String, default: null },\n /**\n * If true, render the badge as a circle, instead of a square.\n */\n circular: { type: Boolean, default: false },\n /**\n * The size of the badge - Small, Medium or Large.\n */\n size: { type: String as () => NeonSize, default: NeonSize.Medium },\n /**\n * The color of the badge. This is one of the provided NeonFunctionalColors.\n */\n color: { type: String as () => NeonFunctionalColor, default: NeonFunctionalColor.LowContrast },\n /**\n * Alternate color for creating gradient badges. NOTE: can also be the same color as 'color'.\n */\n alternateColor: { type: String as () => NeonFunctionalColor, default: null },\n /**\n * Display the badge in the disable style\n */\n disabled: { type: Boolean, default: false },\n /**\n * Badge image alt text.\n */\n imageAlt: { type: String, default: 'Badge' },\n },\n});\n"],"names":[],"mappings":";;;;AAQA,IAAA,YAAe,gBAAgB;AAAA,EAC7B,MAAM;AAAA,EACN,YAAY;AAAA,IACV;AAAA,EACF;AAAA,EACA,OAAO;AAAA,IAIL,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,OAAO,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIrC,MAAM,EAAE,MAAM,QAAQ,SAAS,KAAK;AAAA,IAIpC,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,MAAM,EAAE,MAAM,QAA0B,SAAS,SAAS,OAAO;AAAA,IAIjE,OAAO,EAAE,MAAM,QAAqC,SAAS,oBAAoB,YAAY;AAAA,IAI7F,gBAAgB,EAAE,MAAM,QAAqC,SAAS,KAAK;AAAA,IAI3E,UAAU,EAAE,MAAM,SAAS,SAAS,MAAM;AAAA,IAI1C,UAAU,EAAE,MAAM,QAAQ,SAAS,QAAQ;AAAA,EAC7C;AACF,CAAC;;"}
|