@usecapsule/core-components 3.13.0 → 3.14.0-dev.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/capsule/capsule.esm.js +1 -1
- package/dist/capsule/index.esm.js +1 -1
- package/dist/capsule/index.esm.js.map +1 -1
- package/dist/capsule/{p-41bc3c58.entry.js → p-0a4c8cdc.entry.js} +2 -2
- package/dist/capsule/p-0a4c8cdc.entry.js.map +1 -0
- package/dist/capsule/{p-52bb30d8.entry.js → p-438442c7.entry.js} +2 -2
- package/dist/capsule/p-438442c7.entry.js.map +1 -0
- package/dist/capsule/{p-286db996.js → p-497acb43.js} +2 -2
- package/dist/capsule/{p-286db996.js.map → p-497acb43.js.map} +1 -1
- package/dist/capsule/{p-07d8431a.entry.js → p-63e6f5d8.entry.js} +4 -4
- package/dist/capsule/p-63e6f5d8.entry.js.map +1 -0
- package/dist/capsule/{p-7dff759e.entry.js → p-d239d40d.entry.js} +2 -2
- package/dist/capsule/{p-7dff759e.entry.js.map → p-d239d40d.entry.js.map} +1 -1
- package/dist/capsule/p-f2393be6.js.map +1 -1
- package/dist/cjs/constants-9b1b01bb.js.map +1 -1
- package/dist/cjs/cpsl-alert_34.cjs.entry.js +18 -18
- package/dist/cjs/cpsl-alert_34.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-col.cjs.entry.js +1 -1
- package/dist/cjs/cpsl-col.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-hero.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-hero.cjs.entry.js.map +1 -1
- package/dist/cjs/cpsl-identicon.cjs.entry.js +2 -2
- package/dist/cjs/cpsl-identicon.cjs.entry.js.map +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/{prand-a35ea6b2.js → prand-76d9999c.js} +3 -4
- package/dist/cjs/prand-76d9999c.js.map +1 -0
- package/dist/collection/components/cpsl-alert/cpsl-alert.js +2 -2
- package/dist/collection/components/cpsl-alert/cpsl-alert.js.map +1 -1
- package/dist/collection/components/cpsl-auth-modal/cpsl-auth-modal.js +1 -1
- package/dist/collection/components/cpsl-auth-modal/cpsl-auth-modal.js.map +1 -1
- package/dist/collection/components/cpsl-button/cpsl-button.stories.js.map +1 -1
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js +3 -3
- package/dist/collection/components/cpsl-code-input/cpsl-code-input.js.map +1 -1
- package/dist/collection/components/cpsl-col/cpsl-col.js +2 -2
- package/dist/collection/components/cpsl-col/cpsl-col.js.map +1 -1
- package/dist/collection/components/cpsl-drawer/cpsl-drawer.js +3 -3
- package/dist/collection/components/cpsl-drawer/cpsl-drawer.js.map +1 -1
- package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js +5 -5
- package/dist/collection/components/cpsl-dropdown/cpsl-dropdown.js.map +1 -1
- package/dist/collection/components/cpsl-dropdown/dropdown-interface.js.map +1 -1
- package/dist/collection/components/cpsl-hero/cpsl-hero.js +3 -3
- package/dist/collection/components/cpsl-hero/cpsl-hero.js.map +1 -1
- package/dist/collection/components/cpsl-hero/cpsl-hero.stories.js.map +1 -1
- package/dist/collection/components/cpsl-icon/cpsl-icon.js +3 -3
- package/dist/collection/components/cpsl-icon/cpsl-icon.js.map +1 -1
- package/dist/collection/components/cpsl-icon-group/cpsl-icon-group.js +3 -3
- package/dist/collection/components/cpsl-icon-group/cpsl-icon-group.js.map +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js +3 -3
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.js.map +1 -1
- package/dist/collection/components/cpsl-identicon/cpsl-identicon.stories.js.map +1 -1
- package/dist/collection/components/cpsl-input/cpsl-input.js +6 -6
- package/dist/collection/components/cpsl-input/cpsl-input.js.map +1 -1
- package/dist/collection/components/cpsl-popover/cpsl-popover.js +2 -2
- package/dist/collection/components/cpsl-popover/cpsl-popover.js.map +1 -1
- package/dist/collection/components/cpsl-progress-indicator/cpsl-progress-indicator.js.map +1 -1
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js +3 -3
- package/dist/collection/components/cpsl-qr-code/cpsl-qr-code.js.map +1 -1
- package/dist/collection/components/cpsl-select/cpsl-select.js +3 -3
- package/dist/collection/components/cpsl-select/cpsl-select.js.map +1 -1
- package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js +3 -3
- package/dist/collection/components/cpsl-slide-button/cpsl-slide-button.js.map +1 -1
- package/dist/collection/components/cpsl-tab/cpsl-tab.js +3 -3
- package/dist/collection/components/cpsl-tab/cpsl-tab.js.map +1 -1
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.js +3 -3
- package/dist/collection/components/cpsl-tabs/cpsl-tabs.js.map +1 -1
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js +2 -2
- package/dist/collection/components/cpsl-tile-button/cpsl-tile-button.js.map +1 -1
- package/dist/collection/constants.js.map +1 -1
- package/dist/collection/index.js +4 -3
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interface.js.map +1 -1
- package/dist/collection/utils/prand.js +1 -1
- package/dist/collection/utils/prand.js.map +1 -1
- package/dist/collection/utils/theme/generateBorderRadii.js +1 -1
- package/dist/collection/utils/theme/generateBorderRadii.js.map +1 -1
- package/dist/collection/utils/theme/generateFont.js.map +1 -1
- package/dist/collection/utils/theme/generatePalette.js +2 -2
- package/dist/collection/utils/theme/generatePalette.js.map +1 -1
- package/dist/collection/utils/theme/generateTheme.js +4 -4
- package/dist/collection/utils/theme/generateTheme.js.map +1 -1
- package/dist/collection/utils/theme/utils.js.map +1 -1
- package/dist/esm/constants-fce138fa.js.map +1 -1
- package/dist/esm/cpsl-alert_34.entry.js +18 -18
- package/dist/esm/cpsl-alert_34.entry.js.map +1 -1
- package/dist/esm/cpsl-col.entry.js +1 -1
- package/dist/esm/cpsl-col.entry.js.map +1 -1
- package/dist/esm/cpsl-hero.entry.js +2 -2
- package/dist/esm/cpsl-hero.entry.js.map +1 -1
- package/dist/esm/cpsl-identicon.entry.js +2 -2
- package/dist/esm/cpsl-identicon.entry.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/{prand-c8323494.js → prand-4c0d6ea7.js} +3 -4
- package/dist/esm/prand-4c0d6ea7.js.map +1 -0
- package/dist/index.js +2 -1
- package/dist/scripts/appendLoaderExports.js +42 -0
- package/dist/scripts/appendLoaderExports.js.map +1 -0
- package/dist/types/Users/norwood/capsule-repos/web-sdk/packages/core-components/.stencil/scripts/appendLoaderExports.d.ts +0 -0
- package/dist/types/components/cpsl-alert/cpsl-alert.d.ts +1 -1
- package/dist/types/components/cpsl-button/cpsl-button.stories.d.ts +1 -1
- package/dist/types/components/cpsl-code-input/cpsl-code-input.d.ts +1 -1
- package/dist/types/components/cpsl-dropdown/cpsl-dropdown.d.ts +1 -1
- package/dist/types/components/cpsl-dropdown/dropdown-interface.d.ts +1 -1
- package/dist/types/components/cpsl-hero/cpsl-hero.stories.d.ts +1 -1
- package/dist/types/components/cpsl-icon/cpsl-icon.d.ts +1 -1
- package/dist/types/components/cpsl-icon-group/cpsl-icon-group.d.ts +1 -1
- package/dist/types/components/cpsl-identicon/cpsl-identicon.stories.d.ts +1 -1
- package/dist/types/components/cpsl-input/cpsl-input.d.ts +2 -2
- package/dist/types/components/cpsl-qr-code/cpsl-qr-code.d.ts +1 -1
- package/dist/types/components/cpsl-select/cpsl-select.d.ts +1 -1
- package/dist/types/components/cpsl-slide-button/cpsl-slide-button.d.ts +1 -1
- package/dist/types/components/cpsl-tab/cpsl-tab.d.ts +2 -2
- package/dist/types/components/cpsl-tabs/cpsl-tabs.d.ts +2 -2
- package/dist/types/components/cpsl-tile-button/cpsl-tile-button.d.ts +1 -1
- package/dist/types/components.d.ts +12 -12
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/index.d.ts +6 -4
- package/dist/types/interface.d.ts +2 -2
- package/dist/types/utils/theme/generateBorderRadii.d.ts +1 -1
- package/dist/types/utils/theme/generateFont.d.ts +1 -1
- package/dist/types/utils/theme/generatePalette.d.ts +1 -1
- package/dist/types/utils/theme/generateTheme.d.ts +1 -1
- package/dist/types/utils/theme/utils.d.ts +1 -1
- package/package.json +13 -6
- package/dist/capsule/p-07d8431a.entry.js.map +0 -1
- package/dist/capsule/p-41bc3c58.entry.js.map +0 -1
- package/dist/capsule/p-52bb30d8.entry.js.map +0 -1
- package/dist/cjs/prand-a35ea6b2.js.map +0 -1
- package/dist/esm/prand-c8323494.js.map +0 -1
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["SIZE_TO_MEDIA","xs","sm","md","lg","xl","matchBreakpoint","breakpoint","undefined","window","matchMedia","mediaQuery","matches","cpslColCss","CpslColStyle0","win","SUPPORTS_VARS","CSS","supports","BREAKPOINTS","CpslCol","onResize","forceUpdate","this","getColumns","property","matched","columns","charAt","toUpperCase","slice","calculateSize","colSize","flex","width","calculatePosition","modifier","amount","calculateOffset","isRTL","calculatePull","calculatePush","render","document","dir","h","Host","key","style","Object","assign"],"sources":["src/utils/media.ts","src/components/cpsl-col/cpsl-col.scss?tag=cpsl-col&encapsulation=shadow","src/components/cpsl-col/cpsl-col.tsx"],"sourcesContent":["export const SIZE_TO_MEDIA: any = {\n xs: '(min-width: 0px)',\n sm: '(min-width: 576px)',\n md: '(min-width: 768px)',\n lg: '(min-width: 992px)',\n xl: '(min-width: 1200px)',\n};\n\n// Check if the window matches the media query\n// at the breakpoint passed\n// e.g. matchBreakpoint('sm') => true if screen width exceeds 576px\nexport const matchBreakpoint = (breakpoint: string | undefined) => {\n if (breakpoint === undefined || breakpoint === '') {\n return true;\n }\n if ((window as any).matchMedia) {\n const mediaQuery = SIZE_TO_MEDIA[breakpoint];\n return window.matchMedia(mediaQuery).matches;\n }\n return false;\n};\n","@import './cpsl-col.vars';\n\n// Column\n// --------------------------------------------------\n\n:host {\n /**\n * @prop --cpsl-grid-columns: The number of total Columns in the Grid\n * @prop --cpsl-grid-column-padding: Padding for the Column\n * @prop --cpsl-grid-column-padding-xs: Padding for the Column on xs screens and up\n * @prop --cpsl-grid-column-padding-sm: Padding for the Column on sm screens and up\n * @prop --cpsl-grid-column-padding-md: Padding for the Column on md screens and up\n * @prop --cpsl-grid-column-padding-lg: Padding for the Column on lg screens and up\n * @prop --cpsl-grid-column-padding-xl: Padding for the Column on xl screens and up\n */\n @include make-breakpoint-padding($grid-column-paddings);\n @include margin(0);\n\n box-sizing: border-box;\n\n position: relative;\n\n flex-basis: 0;\n flex-grow: 1;\n\n width: 100%;\n max-width: 100%;\n min-height: 1px; // Prevent columns from collapsing when empty\n}\n","import { Component, Host, Listen, Prop, forceUpdate, h } from '@stencil/core';\nimport { matchBreakpoint } from '../../utils/media';\n\nconst win = typeof (window as any) !== 'undefined' ? (window as any) : undefined;\nconst SUPPORTS_VARS = win && !!(win.CSS && win.CSS.supports && win.CSS.supports('--a: 0'));\nconst BREAKPOINTS = ['', 'xs', 'sm', 'md', 'lg', 'xl'];\n\n@Component({\n tag: 'cpsl-col',\n styleUrl: 'cpsl-col.scss',\n shadow: true,\n})\nexport class CpslCol {\n /**\n * The amount to offset the column, in terms of how many columns it should shift to the end\n * of the total available.\n */\n @Prop() offset?: string;\n\n /**\n * The amount to offset the column for xs screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() offsetXs?: string;\n\n /**\n * The amount to offset the column for sm screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() offsetSm?: string;\n\n /**\n * The amount to offset the column for md screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() offsetMd?: string;\n\n /**\n * The amount to offset the column for lg screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() offsetLg?: string;\n\n /**\n * The amount to offset the column for xl screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() offsetXl?: string;\n\n /**\n * The amount to pull the column, in terms of how many columns it should shift to the start of\n * the total available.\n */\n @Prop() pull?: string;\n\n /**\n * The amount to pull the column for xs screens, in terms of how many columns it should shift\n * to the start of the total available.\n */\n @Prop() pullXs?: string;\n /**\n * The amount to pull the column for sm screens, in terms of how many columns it should shift\n * to the start of the total available.\n */\n @Prop() pullSm?: string;\n /**\n * The amount to pull the column for md screens, in terms of how many columns it should shift\n * to the start of the total available.\n */\n @Prop() pullMd?: string;\n /**\n * The amount to pull the column for lg screens, in terms of how many columns it should shift\n * to the start of the total available.\n */\n @Prop() pullLg?: string;\n /**\n * The amount to pull the column for xl screens, in terms of how many columns it should shift\n * to the start of the total available.\n */\n @Prop() pullXl?: string;\n\n /**\n * The amount to push the column, in terms of how many columns it should shift to the end\n * of the total available.\n */\n @Prop() push?: string;\n\n /**\n * The amount to push the column for xs screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() pushXs?: string;\n\n /**\n * The amount to push the column for sm screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() pushSm?: string;\n\n /**\n * The amount to push the column for md screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() pushMd?: string;\n\n /**\n * The amount to push the column for lg screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() pushLg?: string;\n\n /**\n * The amount to push the column for xl screens, in terms of how many columns it should shift\n * to the end of the total available.\n */\n @Prop() pushXl?: string;\n\n /**\n * The size of the column, in terms of how many columns it should take up out of the total\n * available. If `\"auto\"` is passed, the column will be the size of its content.\n */\n @Prop() size?: string;\n\n /**\n * The size of the column for xs screens, in terms of how many columns it should take up out\n * of the total available. If `\"auto\"` is passed, the column will be the size of its content.\n */\n @Prop() sizeXs?: string;\n\n /**\n * The size of the column for sm screens, in terms of how many columns it should take up out\n * of the total available. If `\"auto\"` is passed, the column will be the size of its content.\n */\n @Prop() sizeSm?: string;\n\n /**\n * The size of the column for md screens, in terms of how many columns it should take up out\n * of the total available. If `\"auto\"` is passed, the column will be the size of its content.\n */\n @Prop() sizeMd?: string;\n\n /**\n * The size of the column for lg screens, in terms of how many columns it should take up out\n * of the total available. If `\"auto\"` is passed, the column will be the size of its content.\n */\n @Prop() sizeLg?: string;\n\n /**\n * The size of the column for xl screens, in terms of how many columns it should take up out\n * of the total available. If `\"auto\"` is passed, the column will be the size of its content.\n */\n @Prop() sizeXl?: string;\n\n @Listen('resize', { target: 'window' })\n onResize() {\n forceUpdate(this);\n }\n\n // Loop through all of the breakpoints to see if the media query\n // matches and grab the column value from the relevant prop if so\n private getColumns(property: string) {\n let matched;\n\n for (const breakpoint of BREAKPOINTS) {\n const matches = matchBreakpoint(breakpoint);\n\n // Grab the value of the property, if it exists and our\n // media query matches we return the value\n const columns = (this as any)[property + breakpoint.charAt(0).toUpperCase() + breakpoint.slice(1)];\n\n if (matches && columns !== undefined) {\n matched = columns;\n }\n }\n\n // Return the last matched columns since the breakpoints\n // increase in size and we want to return the largest match\n return matched;\n }\n\n private calculateSize() {\n const columns = this.getColumns('size');\n\n // If size wasn't set for any breakpoint\n // or if the user set the size without a value\n // it means we need to stick with the default and return\n // e.g. <ion-col size-md>\n if (!columns || columns === '') {\n return;\n }\n\n // If the size is set to auto then don't calculate a size\n const colSize =\n columns === 'auto'\n ? 'auto'\n : // If CSS supports variables we should use the grid columns var\n SUPPORTS_VARS\n ? `calc(calc(${columns} / var(--ion-grid-columns, 12)) * 100%)`\n : // Convert the columns to a percentage by dividing by the total number\n // of columns (12) and then multiplying by 100\n (columns / 12) * 100 + '%';\n\n return {\n 'flex': `0 0 ${colSize}`,\n 'width': `${colSize}`,\n 'max-width': `${colSize}`,\n };\n }\n\n // Called by push, pull, and offset since they use the same calculations\n private calculatePosition(property: string, modifier: string) {\n const columns = this.getColumns(property);\n\n if (!columns) {\n return;\n }\n\n // If the number of columns passed are greater than 0 and less than\n // 12 we can position the column, else default to auto\n const amount = SUPPORTS_VARS\n ? // If CSS supports variables we should use the grid columns var\n `calc(calc(${columns} / var(--ion-grid-columns, 12)) * 100%)`\n : // Convert the columns to a percentage by dividing by the total number\n // of columns (12) and then multiplying by 100\n columns > 0 && columns < 12\n ? (columns / 12) * 100 + '%'\n : 'auto';\n\n return {\n [modifier]: amount,\n };\n }\n\n private calculateOffset(isRTL: boolean) {\n return this.calculatePosition('offset', isRTL ? 'margin-right' : 'margin-left');\n }\n\n private calculatePull(isRTL: boolean) {\n return this.calculatePosition('pull', isRTL ? 'left' : 'right');\n }\n\n private calculatePush(isRTL: boolean) {\n return this.calculatePosition('push', isRTL ? 'right' : 'left');\n }\n\n render() {\n const isRTL = document.dir === 'rtl';\n return (\n <Host\n style={{\n ...this.calculateOffset(isRTL),\n ...this.calculatePull(isRTL),\n ...this.calculatePush(isRTL),\n ...this.calculateSize(),\n }}\n >\n <slot></slot>\n </Host>\n );\n }\n}\n"],"mappings":"yDAAO,MAAMA,EAAqB,CAChCC,GAAI,mBACJC,GAAI,qBACJC,GAAI,qBACJC,GAAI,qBACJC,GAAI,uBAMC,MAAMC,EAAmBC,IAC9B,GAAIA,IAAeC,WAAaD,IAAe,GAAI,CACjD,OAAO,I,CAET,GAAKE,OAAeC,WAAY,CAC9B,MAAMC,EAAaX,EAAcO,GACjC,OAAOE,OAAOC,WAAWC,GAAYC,O,CAEvC,OAAO,KAAK,ECnBd,MAAMC,EAAa,i+FACnB,MAAAC,EAAeD,ECEf,MAAME,SAAcN,SAAmB,YAAeA,OAAiBD,UACvE,MAAMQ,EAAgBD,MAAUA,EAAIE,KAAOF,EAAIE,IAAIC,UAAYH,EAAIE,IAAIC,SAAS,WAChF,MAAMC,EAAc,CAAC,GAAI,KAAM,KAAM,KAAM,KAAM,M,MAOpCC,EAAO,M,6iBA8IlB,QAAAC,GACEC,EAAYC,K,CAKN,UAAAC,CAAWC,GACjB,IAAIC,EAEJ,IAAK,MAAMnB,KAAcY,EAAa,CACpC,MAAMP,EAAUN,EAAgBC,GAIhC,MAAMoB,EAAWJ,KAAaE,EAAWlB,EAAWqB,OAAO,GAAGC,cAAgBtB,EAAWuB,MAAM,IAE/F,GAAIlB,GAAWe,IAAYnB,UAAW,CACpCkB,EAAUC,C,EAMd,OAAOD,C,CAGD,aAAAK,GACN,MAAMJ,EAAUJ,KAAKC,WAAW,QAMhC,IAAKG,GAAWA,IAAY,GAAI,CAC9B,M,CAIF,MAAMK,EACJL,IAAY,OACR,OAEAX,EACE,aAAaW,2CAGZA,EAAU,GAAM,IAAM,IAE/B,MAAO,CACLM,KAAQ,OAAOD,IACfE,MAAS,GAAGF,IACZ,YAAa,GAAGA,I,CAKZ,iBAAAG,CAAkBV,EAAkBW,GAC1C,MAAMT,EAAUJ,KAAKC,WAAWC,GAEhC,IAAKE,EAAS,CACZ,M,CAKF,MAAMU,EAASrB,EAEX,aAAaW,2CAGbA,EAAU,GAAKA,EAAU,GACtBA,EAAU,GAAM,IAAM,IACvB,OAEN,MAAO,CACLS,CAACA,GAAWC,E,CAIR,eAAAC,CAAgBC,GACtB,OAAOhB,KAAKY,kBAAkB,SAAUI,EAAQ,eAAiB,c,CAG3D,aAAAC,CAAcD,GACpB,OAAOhB,KAAKY,kBAAkB,OAAQI,EAAQ,OAAS,Q,CAGjD,aAAAE,CAAcF,GACpB,OAAOhB,KAAKY,kBAAkB,OAAQI,EAAQ,QAAU,O,CAG1D,MAAAG,GACE,MAAMH,EAAQI,SAASC,MAAQ,MAC/B,OACEC,EAACC,EAAI,CAAAC,IAAA,2CACHC,MAAKC,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAA,GACA3B,KAAKe,gBAAgBC,IACrBhB,KAAKiB,cAAcD,IACnBhB,KAAKkB,cAAcF,IACnBhB,KAAKQ,kBAGVc,EAAA,QAAAE,IAAA,6C","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["cpslIdenticonCss","CpslIdenticonStyle0","SingleArc","rotation","h","class","rotate90","rotate180","rotate270","viewBox","xmlns","d","id","width","height","DoubleArc","BASE_PATTERNS","CpslIdenticon","render","props","isEmpty","this","hash","getIdenticonProps","Host","key","red","color","orange","yellow","green","blue","purple","empty","avatar","variant","style","size","shapes","rotations","map","isDouble","index","PRANDO_INTS","COLORS","length","seed","rng","Prando","iColor","iPattern","iDeviation","len","nextInt","deviationIndex","Math","floor","isDeviateShape","isDeviateFlip","s","i","r"],"sources":["src/components/cpsl-identicon/cpsl-identicon.scss?tag=cpsl-identicon&encapsulation=shadow","src/components/cpsl-identicon/cpsl-identicon.tsx"],"sourcesContent":[":host {\n --identicon-background-red: linear-gradient(136deg, #ff4270 6.86%, #ff7c7c 93.78%);\n --identicon-background-orange: linear-gradient(136deg, #f45532 6.86%, #ff9b63 93.78%);\n --identicon-background-yellow: linear-gradient(136deg, #ffa756 6.86%, #fbff47 93.78%);\n --identicon-background-green: linear-gradient(136deg, #0cae60 6.86%, #7bffd0 93.78%);\n --identicon-background-blue: linear-gradient(136deg, #476fff 6.86%, #47c8ff 93.78%);\n --identicon-background-purple: linear-gradient(136deg, #9747ff 6.86%, #da47ff 93.78%);\n --identicon-background-empty: linear-gradient(136deg, #aaaaaa 6.86%, #999999 93.78%);\n\n display: block;\n aspect-ratio: 1;\n border-radius: 25%;\n position: relative;\n border: 1px solid var(--cpsl-color-background-8);\n\n & > svg {\n fill: rgba(255, 255, 255, 0.6);\n position: absolute;\n width: 30%;\n }\n\n & > svg.rotate90 {\n transform: rotate(0.25turn);\n }\n\n & > svg.rotate180 {\n transform: rotate(0.5turn);\n }\n\n & > svg.rotate270 {\n transform: rotate(0.75turn);\n }\n\n & > svg:nth-child(1) {\n right: 50%;\n bottom: 50%;\n }\n\n & > svg:nth-child(2) {\n left: 50%;\n bottom: 50%;\n }\n\n & > svg:nth-child(3) {\n right: 50%;\n top: 50%;\n }\n\n & > svg:nth-child(4) {\n left: 50%;\n top: 50%;\n }\n}\n\n:host(.red) {\n background: var(--identicon-background-red);\n}\n\n:host(.orange) {\n background: var(--identicon-background-orange);\n}\n\n:host(.green) {\n background: var(--identicon-background-green);\n}\n\n:host(.yellow) {\n background: var(--identicon-background-yellow);\n}\n\n:host(.blue) {\n background: var(--identicon-background-blue);\n}\n\n:host(.purple) {\n background: var(--identicon-background-purple);\n}\n\n:host(.empty) {\n background: var(--identicon-background-empty);\n}\n\n:host(.avatar) {\n border-radius: 1000px;\n}\n","import { Component, Host, Prop, h } from '@stencil/core';\nimport Prando from '../../lib/prando';\nimport { Color, COLORS } from '../../utils/prand';\n\nconst SingleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_66)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_66\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\nconst DoubleArc = (rotation: number) => (\n <svg\n class={{\n rotate90: rotation === 1,\n rotate180: rotation === 2,\n rotate270: rotation === 3,\n }}\n viewBox=\"0 0 12 12\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <g clip-path=\"url(#clip0_674_255)\">\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24ZM12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z\"\n />\n <path\n fill-rule=\"evenodd\"\n clip-rule=\"evenodd\"\n d=\"M12 18C15.3137 18 18 15.3137 18 12C18 8.68629 15.3137 6 12 6C8.68629 6 6 8.68629 6 12C6 15.3137 8.68629 18 12 18ZM12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z\"\n />\n </g>\n <defs>\n <clipPath id=\"clip0_674_255\">\n <rect width=\"12\" height=\"12\" />\n </clipPath>\n </defs>\n </svg>\n);\n\nconst BASE_PATTERNS = [\n [\n [0, 0, 0, 0],\n [0, 1, 3, 2],\n ],\n [\n [1, 1, 0, 0],\n [0, 1, 3, 2],\n ],\n [\n [0, 1, 0, 1],\n [0, 1, 3, 2],\n ],\n [\n [0, 0, 1, 1],\n [0, 1, 3, 2],\n ],\n [\n [1, 0, 1, 0],\n [0, 1, 3, 2],\n ],\n [\n [1, 1, 1, 1],\n [0, 1, 3, 2],\n ],\n [\n [0, 0, 0, 0],\n [2, 3, 1, 0],\n ],\n [\n [1, 1, 1, 1],\n [2, 3, 1, 0],\n ],\n [\n [1, 1, 1, 1],\n [0, 1, 2, 3],\n ],\n];\n\n@Component({\n tag: 'cpsl-identicon',\n styleUrl: 'cpsl-identicon.scss',\n shadow: true,\n})\nexport class CpslIdenticon {\n @Prop() hash?: string | undefined;\n\n /**\n * The CSS width and height of the identicon.\n * Default is: 40px.\n */\n @Prop() size: string = '40px';\n\n @Prop() variant: 'default' | 'avatar' = 'default';\n\n render() {\n let props;\n const isEmpty = !this.hash;\n if (!isEmpty) props = getIdenticonProps(this.hash);\n\n return (\n <Host\n class={{\n red: props?.color === 'red',\n orange: props?.color === 'orange',\n yellow: props?.color === 'yellow',\n green: props?.color === 'green',\n blue: props?.color === 'blue',\n purple: props?.color === 'purple',\n empty: !props?.color && !this.hash,\n avatar: this.variant === 'avatar',\n }}\n style={{\n width: this.size,\n height: this.size,\n }}\n >\n {props?.shapes &&\n props?.rotations &&\n props.shapes.map((isDouble, index) => {\n return isDouble ? DoubleArc(props.rotations[index]) : SingleArc(props.rotations[index]);\n })}\n </Host>\n );\n }\n}\n\nconst PRANDO_INTS = [COLORS.length, BASE_PATTERNS.length, 16];\n\nfunction getIdenticonProps(seed: string): { color: Color; shapes: boolean[]; rotations: number[] } {\n const rng = new Prando(seed);\n\n const [iColor, iPattern, iDeviation] = PRANDO_INTS.map(len => rng.nextInt(0, len - 1));\n\n const deviationIndex = Math.floor(iDeviation / 4);\n const [isDeviateShape, isDeviateFlip] = [iDeviation % 2 === 1, iDeviation % 4 >= 2];\n\n return {\n color: COLORS[iColor],\n shapes: BASE_PATTERNS[iPattern][0].map((s, i) => {\n return i === deviationIndex ? (isDeviateShape ? (s === 1 ? false : true) : s === 1) : s === 1;\n }),\n rotations: BASE_PATTERNS[iPattern][1].map((r, i) => (i === deviationIndex ? (isDeviateFlip ? (r + 2) % 4 : r) : r)),\n };\n}\n"],"mappings":"6FAAA,MAAMA,EAAmB,8/CACzB,MAAAC,EAAeD,ECGf,MAAME,EAAaC,GACjBC,EAAA,OACEC,MAAO,CACLC,SAAUH,IAAa,EACvBI,UAAWJ,IAAa,EACxBK,UAAWL,IAAa,GAE1BM,QAAQ,YACRC,MAAM,8BAENN,EAAA,iBAAa,sBACXA,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,wOAGNP,EAAA,YACEA,EAAA,YAAUQ,GAAG,gBACXR,EAAA,QAAMS,MAAM,KAAKC,OAAO,UAMhC,MAAMC,EAAaZ,GACjBC,EAAA,OACEC,MAAO,CACLC,SAAUH,IAAa,EACvBI,UAAWJ,IAAa,EACxBK,UAAWL,IAAa,GAE1BM,QAAQ,YACRC,MAAM,8BAENN,EAAA,iBAAa,uBACXA,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,uOAEJP,EAAA,oBACY,UAAS,YACT,UACVO,EAAE,wOAGNP,EAAA,YACEA,EAAA,YAAUQ,GAAG,iBACXR,EAAA,QAAMS,MAAM,KAAKC,OAAO,UAMhC,MAAME,EAAgB,CACpB,CACE,CAAC,EAAG,EAAG,EAAG,GACV,CAAC,EAAG,EAAG,EAAG,IAEZ,CACE,CAAC,EAAG,EAAG,EAAG,GACV,CAAC,EAAG,EAA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,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC5B;SACF;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KAC/B;IAEO,WAAW,CAAC,IAAY;QAC9B,IAAI,IAAI,KAAK,CAAC;YAAE,OAAO,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;KACb;;AA/KuB,UAAG,GAAW,CAAC,UAAU,CAAC;AAC1B,UAAG,GAAW,UAAU,CAAC;iBAF9B,MAAM;;MCpBd,MAAM,GAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;AAEtF,MAAM,SAAS,GAAG;IAChB,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC7B,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC5B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,CAAC;SAEc,yBAAyB,CAAC,IAAY;IACpD,MAAM,GAAG,GAAG,IAAIA,QAAM,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,OAAO,2BAA2B,KAAK,WAAW,IAAI,UAAU,CAAC;AACnE;;;;;;","names":["Prando"],"sources":["src/lib/prando.ts","src/utils/prand.ts"],"sourcesContent":["/*\n * This file contains code from prando, which is licensed under the MIT License:\n *\n * Copyright (c) 2016 Zeh Fernando\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport default class Prando {\n private static readonly MIN: number = -2147483648; // Int32 min\n private static readonly MAX: number = 2147483647; // Int32 max\n\n private _seed: number;\n private _value = NaN;\n\n // ================================================================================================================\n // CONSTRUCTOR ----------------------------------------------------------------------------------------------------\n\n /**\n * Generate a new Prando pseudo-random number generator.\n *\n * @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.\n */\n constructor(seed?: number | string) {\n if (typeof seed === 'string') {\n // String seed\n this._seed = this.hashCode(seed);\n } else if (typeof seed === 'number') {\n // Numeric seed\n this._seed = this.getSafeSeed(seed);\n } else {\n // Pseudo-random seed\n this._seed = this.getSafeSeed(Prando.MIN + Math.floor((Prando.MAX - Prando.MIN) * Math.random()));\n }\n this.reset();\n }\n\n // ================================================================================================================\n // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------\n\n /**\n * Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.\n *\n * @param min - The minimum number that can be randomly generated.\n * @param pseudoMax - The maximum number that can be randomly generated (exclusive).\n * @return The generated pseudo-random number.\n */\n public next(min = 0, pseudoMax = 1): number {\n this.recalculate();\n return this.map(this._value, Prando.MIN, Prando.MAX, min, pseudoMax);\n }\n\n /**\n * Generates a pseudo-random integer number in a range (inclusive).\n *\n * @param min - The minimum number that can be randomly generated.\n * @param max - The maximum number that can be randomly generated.\n * @return The generated pseudo-random number.\n */\n public nextInt(min = 10, max = 100): number {\n this.recalculate();\n return Math.floor(this.map(this._value, Prando.MIN, Prando.MAX, min, max + 1));\n }\n\n /**\n * Generates a pseudo-random string sequence of a particular length from a specific character range.\n *\n * Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a\n * 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for\n * pre-existing ids, or employ a robust GUID/UUID generator.\n *\n * @param length - Length of the string to be generated.\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated string sequence.\n */\n public nextString(length = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n let str = '';\n while (str.length < length) {\n str += this.nextChar(chars);\n }\n return str;\n }\n\n /**\n * Generates a pseudo-random string of 1 character specific character range.\n *\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated character.\n */\n public nextChar(chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n return chars.substr(this.nextInt(0, chars.length - 1), 1);\n }\n\n /**\n * Picks a pseudo-random item from an array. The array is left unmodified.\n *\n * Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time\n * does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to\n * *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to\n * apply a *shuffle* transformation to the array instead, then read it linearly.\n *\n * @param array - Array of any type containing one or more candidates for random picking.\n * @return An item from the array.\n */\n public nextArrayItem<T>(array: T[]): T {\n return array[this.nextInt(0, array.length - 1)];\n }\n\n /**\n * Generates a pseudo-random boolean.\n *\n * @return A value of true or false.\n */\n public nextBoolean(): boolean {\n this.recalculate();\n return this._value > 0.5;\n }\n\n /**\n * Skips ahead in the sequence of numbers that are being generated. This is equivalent to\n * calling next() a specified number of times, but faster since it doesn't need to map the\n * new random numbers to a range and return it.\n *\n * @param iterations - The number of items to skip ahead.\n */\n public skip(iterations = 1): void {\n while (iterations-- > 0) {\n this.recalculate();\n }\n }\n\n /**\n * Reset the pseudo-random number sequence back to its starting seed. Further calls to next()\n * will then produce the same sequence of numbers it had produced before. This is equivalent to\n * creating a new Prando instance with the same seed as another Prando instance.\n *\n * Example:\n * let rng = new Prando(12345678);\n * console.log(rng.next()); // 0.6177754114889017\n * console.log(rng.next()); // 0.5784605181725837\n * rng.reset();\n * console.log(rng.next()); // 0.6177754114889017 again\n * console.log(rng.next()); // 0.5784605181725837 again\n */\n public reset(): void {\n this._value = this._seed;\n }\n\n // ================================================================================================================\n // PRIVATE INTERFACE ----------------------------------------------------------------------------------------------\n\n private recalculate(): void {\n this._value = this.xorshift(this._value);\n }\n\n private xorshift(value: number): number {\n // Xorshift*32\n // Based on George Marsaglia's work: http://www.jstatsoft.org/v08/i14/paper\n value ^= value << 13;\n value ^= value >> 17;\n value ^= value << 5;\n return value;\n }\n\n private map(val: number, minFrom: number, maxFrom: number, minTo: number, maxTo: number): number {\n return ((val - minFrom) / (maxFrom - minFrom)) * (maxTo - minTo) + minTo;\n }\n\n private hashCode(str: string): number {\n let hash = 0;\n if (str) {\n const l = str.length;\n for (let i = 0; i < l; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i);\n hash |= 0;\n hash = this.xorshift(hash);\n }\n }\n return this.getSafeSeed(hash);\n }\n\n private getSafeSeed(seed: number): number {\n if (seed === 0) return 1;\n return seed;\n }\n}\n","import Prando from '../lib/prando';\n\nexport type Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';\n\nexport const COLORS: Color[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];\n\nconst GRADIENTS = {\n red: ['#FF4270', '#FF7C7C'],\n orange: ['#F45532', '#FF9B63'],\n yellow: ['#FFA756', '#FBFF47'],\n green: ['#0CAE60', '#7BFFD0'],\n blue: ['#476FFF', '#47C8FF'],\n purple: ['#9747FF', '#DA47FF'],\n};\n\nexport function getPseudoRandomBackground(seed: string): string {\n const rng = new Prando(seed);\n\n const [start, stop] = GRADIENTS[COLORS[rng.nextInt(0, COLORS.length - 1)]];\n\n return `linear-gradient(136deg, ${start} 6.86%, ${stop} 93.78%)`;\n}\n"],"version":3}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"prand-c8323494.js","mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAqB,MAAM;;;;;;;;IAezB,YAAY,IAAsB;QAV1B,WAAM,GAAG,GAAG,CAAC;QAWnB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;;YAE5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAClC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;;YAEnC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;SACrC;aAAM;;YAEL,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;SACnG;QACD,IAAI,CAAC,KAAK,EAAE,CAAC;KACd;;;;;;;;;;IAYM,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC;QAChC,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,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Bd,MAAM,GAAY,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE;AAEtF,MAAM,SAAS,GAAG;IAChB,GAAG,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC3B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,KAAK,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC7B,IAAI,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;IAC5B,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,CAAC;SAEc,yBAAyB,CAAC,IAAY;IACpD,MAAM,GAAG,GAAG,IAAIA,QAAM,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3E,OAAO,2BAA2B,KAAK,WAAW,IAAI,UAAU,CAAC;AACnE;;;;","names":["Prando"],"sources":["src/lib/prando.ts","src/utils/prand.ts"],"sourcesContent":["/*\n * This file contains code from prando, which is licensed under the MIT License:\n *\n * Copyright (c) 2016 Zeh Fernando\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nexport default class Prando {\n private static readonly MIN: number = -2147483648; // Int32 min\n private static readonly MAX: number = 2147483647; // Int32 max\n\n private _seed: number;\n private _value = NaN;\n\n // ================================================================================================================\n // CONSTRUCTOR ----------------------------------------------------------------------------------------------------\n\n /**\n * Generate a new Prando pseudo-random number generator.\n *\n * @param seed - A number or string seed that determines which pseudo-random number sequence will be created. Defaults to a random seed based on `Math.random()`.\n */\n constructor(seed?: number | string) {\n if (typeof seed === 'string') {\n // String seed\n this._seed = this.hashCode(seed);\n } else if (typeof seed === 'number') {\n // Numeric seed\n this._seed = this.getSafeSeed(seed);\n } else {\n // Pseudo-random seed\n this._seed = this.getSafeSeed(Prando.MIN + Math.floor((Prando.MAX - Prando.MIN) * Math.random()));\n }\n this.reset();\n }\n\n // ================================================================================================================\n // PUBLIC INTERFACE -----------------------------------------------------------------------------------------------\n\n /**\n * Generates a pseudo-random number between a lower (inclusive) and a higher (exclusive) bounds.\n *\n * @param min - The minimum number that can be randomly generated.\n * @param pseudoMax - The maximum number that can be randomly generated (exclusive).\n * @return The generated pseudo-random number.\n */\n public next(min = 0, pseudoMax = 1): number {\n this.recalculate();\n return this.map(this._value, Prando.MIN, Prando.MAX, min, pseudoMax);\n }\n\n /**\n * Generates a pseudo-random integer number in a range (inclusive).\n *\n * @param min - The minimum number that can be randomly generated.\n * @param max - The maximum number that can be randomly generated.\n * @return The generated pseudo-random number.\n */\n public nextInt(min = 10, max = 100): number {\n this.recalculate();\n return Math.floor(this.map(this._value, Prando.MIN, Prando.MAX, min, max + 1));\n }\n\n /**\n * Generates a pseudo-random string sequence of a particular length from a specific character range.\n *\n * Note: keep in mind that creating a random string sequence does not guarantee uniqueness; there is always a\n * 1 in (char_length^string_length) chance of collision. For real unique string ids, always check for\n * pre-existing ids, or employ a robust GUID/UUID generator.\n *\n * @param length - Length of the string to be generated.\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated string sequence.\n */\n public nextString(length = 16, chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n let str = '';\n while (str.length < length) {\n str += this.nextChar(chars);\n }\n return str;\n }\n\n /**\n * Generates a pseudo-random string of 1 character specific character range.\n *\n * @param chars - Characters that are used when creating the random string. Defaults to all alphanumeric chars (A-Z, a-z, 0-9).\n * @return The generated character.\n */\n public nextChar(chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'): string {\n return chars.substr(this.nextInt(0, chars.length - 1), 1);\n }\n\n /**\n * Picks a pseudo-random item from an array. The array is left unmodified.\n *\n * Note: keep in mind that while the returned item will be random enough, picking one item from the array at a time\n * does not guarantee nor imply that a sequence of random non-repeating items will be picked. If you want to\n * *pick items in a random order* from an array, instead of *pick one random item from an array*, it's best to\n * apply a *shuffle* transformation to the array instead, then read it linearly.\n *\n * @param array - Array of any type containing one or more candidates for random picking.\n * @return An item from the array.\n */\n public nextArrayItem<T>(array: T[]): T {\n return array[this.nextInt(0, array.length - 1)];\n }\n\n /**\n * Generates a pseudo-random boolean.\n *\n * @return A value of true or false.\n */\n public nextBoolean(): boolean {\n this.recalculate();\n return this._value > 0.5;\n }\n\n /**\n * Skips ahead in the sequence of numbers that are being generated. This is equivalent to\n * calling next() a specified number of times, but faster since it doesn't need to map the\n * new random numbers to a range and return it.\n *\n * @param iterations - The number of items to skip ahead.\n */\n public skip(iterations = 1): void {\n while (iterations-- > 0) {\n this.recalculate();\n }\n }\n\n /**\n * Reset the pseudo-random number sequence back to its starting seed. Further calls to next()\n * will then produce the same sequence of numbers it had produced before. This is equivalent to\n * creating a new Prando instance with the same seed as another Prando instance.\n *\n * Example:\n * let rng = new Prando(12345678);\n * console.log(rng.next()); // 0.6177754114889017\n * console.log(rng.next()); // 0.5784605181725837\n * rng.reset();\n * console.log(rng.next()); // 0.6177754114889017 again\n * console.log(rng.next()); // 0.5784605181725837 again\n */\n public reset(): void {\n this._value = this._seed;\n }\n\n // ================================================================================================================\n // PRIVATE INTERFACE ----------------------------------------------------------------------------------------------\n\n private recalculate(): void {\n this._value = this.xorshift(this._value);\n }\n\n private xorshift(value: number): number {\n // Xorshift*32\n // Based on George Marsaglia's work: http://www.jstatsoft.org/v08/i14/paper\n value ^= value << 13;\n value ^= value >> 17;\n value ^= value << 5;\n return value;\n }\n\n private map(val: number, minFrom: number, maxFrom: number, minTo: number, maxTo: number): number {\n return ((val - minFrom) / (maxFrom - minFrom)) * (maxTo - minTo) + minTo;\n }\n\n private hashCode(str: string): number {\n let hash = 0;\n if (str) {\n const l = str.length;\n for (let i = 0; i < l; i++) {\n hash = (hash << 5) - hash + str.charCodeAt(i);\n hash |= 0;\n hash = this.xorshift(hash);\n }\n }\n return this.getSafeSeed(hash);\n }\n\n private getSafeSeed(seed: number): number {\n if (seed === 0) return 1;\n return seed;\n }\n}\n","import Prando from '../lib/prando';\n\nexport type Color = 'red' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple';\n\nexport const COLORS: Color[] = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'];\n\nconst GRADIENTS = {\n red: ['#FF4270', '#FF7C7C'],\n orange: ['#F45532', '#FF9B63'],\n yellow: ['#FFA756', '#FBFF47'],\n green: ['#0CAE60', '#7BFFD0'],\n blue: ['#476FFF', '#47C8FF'],\n purple: ['#9747FF', '#DA47FF'],\n};\n\nexport function getPseudoRandomBackground(seed: string): string {\n const rng = new Prando(seed);\n\n const [start, stop] = GRADIENTS[COLORS[rng.nextInt(0, COLORS.length - 1)]];\n\n return `linear-gradient(136deg, ${start} 6.86%, ${stop} 93.78%)`;\n}\n"],"version":3}
|