@esportsplus/ui 0.62.0 → 0.63.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.
@@ -1,2 +0,0 @@
1
- @layer components{.cc-face{position:absolute;inset:0}.cc-control-brand{position:absolute;bottom:50%;translate:0 50%}@font-face{font-display:swap;font-family:Geist;font-style:normal;font-weight:100 900;src:url(../../../css-utilities/font/geist/Geist-Variable.woff2)format("woff2")}@font-face{font-display:swap;font-family:Geist;font-style:italic;font-weight:100 900;src:url(../../../css-utilities/font/geist/Geist-Italic-Variable.woff2)format("woff2")}@font-face{font-display:swap;font-family:Geist Mono;font-style:normal;font-weight:100 900;src:url(../../../css-utilities/font/geist/GeistMono-Variable.woff2)format("woff2")}@font-face{font-display:swap;font-family:Geist Mono;font-style:italic;font-weight:100 900;src:url(../../../css-utilities/font/geist/GeistMono-Italic-Variable.woff2)format("woff2")}.cc-expires-value,.cc-field--cvc,.cc-field--expiry,.cc-field--number,.cc-number,.cc-signature-value{--font-weight-300:300;--font-weight-400:400;--font-weight-500:500;--font-weight-600:600;--font-family:"Geist Mono", monospace}.cc-live{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}.cc-brand-mark{filter:blur(var(--blur-400));opacity:0;transition:filter var(--icon-swap-duration) var(--icon-swap-timing-function), opacity var(--icon-swap-duration) var(--icon-swap-timing-function), scale var(--icon-swap-duration) var(--icon-swap-timing-function);scale:.25}@media (prefers-reduced-motion:reduce){.cc-brand-mark{transition:none}}.cc-brand-mark.--active{filter:blur();opacity:1;scale:1}.cc-error,.cc-holder-value{text-overflow:ellipsis;white-space:nowrap;max-width:100%;overflow:hidden}@keyframes text-gradient{to{background-position:var(--background-size) 0}}@keyframes text-line-shadow{0%{background-position:0 0}to{background-position:100% -100%}}@keyframes text-shiny{0%,90%,to{background-position:calc(-100% - var(--shine-width)) 0}30%,60%{background-position:calc(100% + var(--shine-width)) 0}}.cc-face{--surface-background-active:light-dark(oklch(from var(--surface-background-default) calc(l + .02) c h),oklch(from var(--surface-background-default) calc(l + .03) c h));--surface-background-default:light-dark(oklch(from var(--color-surface) clamp(0, l + max(var(--surface-level), 0) * .01 + min(var(--surface-level), 0) * .016, 1) calc(c * (1 - clamp(0, l + max(var(--surface-level), 0) * .01 + min(var(--surface-level), 0) * .016, 1)) / max(1 - l, .01)) h),oklch(from var(--color-surface) clamp(0, l + var(--surface-level) * .016, l + .096) calc(c * clamp(0, l + var(--surface-level) * .016, l + .096) / max(l, .01)) h));--surface-background-hover:light-dark(oklch(from var(--surface-background-default) calc(l + .01) c h),oklch(from var(--surface-background-default) calc(l + .02) c h));--surface-background-pressed:light-dark(oklch(from var(--surface-background-default) calc(l - .02) c h),oklch(from var(--surface-background-default) calc(l - .03) c h));--surface-border-active:light-dark(oklch(from var(--surface-background-active) max(0, l - .046) c h),oklch(from var(--surface-background-active) min(1, l + .036) c h));--surface-border-default:light-dark(oklch(from var(--surface-background-default) max(0, l - .046) c h),oklch(from var(--surface-background-default) min(1, l + .036) c h));--surface-border-hover:light-dark(oklch(from var(--surface-background-hover) max(0, l - .046) c h),oklch(from var(--surface-background-hover) min(1, l + .036) c h));--surface-border-pressed:light-dark(oklch(from var(--surface-background-pressed) max(0, l - .046) c h),oklch(from var(--surface-background-pressed) min(1, l + .036) c h));--surface-primary-active:light-dark(oklch(from var(--surface-primary-default) calc(l + .02) c h),oklch(from var(--surface-primary-default) calc(l + .03) c h));--surface-primary-default:light-dark(oklch(from var(--color-surface) clamp(0, l + max(calc(var(--surface-level) + -3.6), 0) * .01 + min(calc(var(--surface-level) + -3.6), 0) * .016, 1) calc(c * (1 - clamp(0, l + max(calc(var(--surface-level) + -3.6), 0) * .01 + min(calc(var(--surface-level) + -3.6), 0) * .016, 1)) / max(1 - l, .01)) h),oklch(from var(--color-surface) clamp(0, l + calc(var(--surface-level) + 1.6) * .016, l + .096) calc(c * clamp(0, l + calc(var(--surface-level) + 1.6) * .016, l + .096) / max(l, .01)) h));--surface-primary-hover:light-dark(oklch(from var(--surface-primary-default) calc(l + .01) c h),oklch(from var(--surface-primary-default) calc(l + .02) c h));--surface-primary-pressed:light-dark(oklch(from var(--surface-primary-default) calc(l - .02) c h),oklch(from var(--surface-primary-default) calc(l - .03) c h));--surface-shadow-active:0 25px 50px -12px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .1),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .2)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-default:0 20px 25px -5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 8px 10px -6px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-hover:0 25px 50px -12px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .1),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .2)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-pressed:0 8.5px 12.75px -2.5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 3.5px 5.5px -3.5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 4.75px 7.125px -1.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 2.25px 4.25px -2.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08))}@container style(--surface-level:-3){.cc-face{--surface-level:-2;--surface-shadow-active:0 1px 2px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px 1.75px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-default:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-hover:0 1px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px .5px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-pressed:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0))}}@container style(--surface-level:-2){.cc-face{--surface-level:-1;--surface-shadow-active:0 1px 2px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px 1.75px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-default:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-hover:0 1px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px .5px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-pressed:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0))}}@container style(--surface-level:-1){.cc-face{--surface-level:0;--surface-shadow-active:0 1px 2px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px 1.75px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-default:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-hover:0 1px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px .5px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-pressed:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0))}}@container style(--surface-level:0){.cc-face{--surface-level:1;--surface-shadow-active:0 1px 3px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 1px 2px -1px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 1px 2.875px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .075)), 0 .875px 1.75px -.875px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .07));--surface-shadow-default:0 1px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-hover:0 1px 2px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px 2.25px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .05)), 0 .25px .5px -.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02));--surface-shadow-pressed:0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0))}}@container style(--surface-level:1){.cc-face{--surface-level:2;--surface-shadow-active:0 4px 6px -1px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 2px 4px -2px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 3.625px 5.625px -.875px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 1.875px 3.75px -1.875px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-default:0 1px 2px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-hover:0 1px 3px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 1px 2px -1px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 1.75px 3.75px -.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 1.25px 2.5px -1.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-pressed:0 .75px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .015),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 .125px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .005)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0))}}@container style(--surface-level:2){.cc-face{--surface-level:3;--surface-shadow-active:0 10px 15px -3px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 4px 6px -4px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 9.25px 13.875px -2.75px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 3.75px 5.75px -3.75px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-default:0 1px 3px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 1px 2px -1px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-hover:0 4px 6px -1px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 2px 4px -2px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 5.5px 8.25px -1.5px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 2.5px 4.5px -2.5px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-pressed:0 1px 1.5px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .02),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 1px .25px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04)), 0 0px 0px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0))}}@container style(--surface-level:3){.cc-face{--surface-level:4;--surface-shadow-active:0 20px 25px -5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 8px 10px -6px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 18.75px 23.75px -4.75px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 7.5px 9.5px -5.75px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-default:0 4px 6px -1px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 2px 4px -2px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-hover:0 10px 15px -3px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 4px 6px -4px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 12.5px 17.5px -3.5px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 5px 7px -4.5px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-pressed:0 1px 2.75px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .035),transparent), 0 .75px 1.5px -.75px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .03),transparent), 0 1px 2.125px 0px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .045)), 0 .125px .25px -.125px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .01))}}@container style(--surface-level:4){.cc-face{--surface-level:5;--surface-shadow-active:0 25px 50px -12px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .1),transparent), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),transparent), 0 24.375px 46.875px -11.125px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .185)), 0 1px 1.25px -.75px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .01));--surface-shadow-default:0 10px 15px -3px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 4px 6px -4px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-hover:0 20px 25px -5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 8px 10px -6px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 21.25px 31.25px -6.75px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .11)), 0 6px 7.5px -4.5px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .06));--surface-shadow-pressed:0 3.25px 5.25px -.75px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 1.75px 3.5px -1.75px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 1.375px 3.375px -.125px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 1.125px 2.25px -1.125px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08))}}@container style(--surface-level:5){.cc-face{--surface-level:6;--surface-shadow-active:0 25px 50px -12px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .1),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .2)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-default:0 20px 25px -5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 8px 10px -6px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08));--surface-shadow-hover:0 25px 50px -12px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .1),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .2)), 0 0px 0px 0px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0),oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / 0));--surface-shadow-pressed:0 8.5px 12.75px -2.5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 3.5px 5.5px -3.5px light-dark(oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .04),transparent), 0 4.75px 7.125px -1.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08)), 0 2.25px 4.25px -2.25px light-dark(transparent,oklch(from var(--surface-background-default) calc(l * .24) calc(c * .24) h / .08))}}.cc{--color:var(--color-text-500);--gap-horizontal:0px;--gap-vertical:var(--size-500);--spring:linear(0, .035, .118, .216, .319, .424, .515, .6, .669, .728, .781, .822, .856, .885, .908, .927, .942, .954, .964, .971, .977, .982, .986, .989, .991, .993, .995, .996, .997, .997, 1);--width:min(400px, 100%)}.cc-actions{--gap-horizontal:0px;--gap-vertical:var(--size-200)}.cc-brand--large{--height:32px;--width:48px}.cc-brand--small{--height:24px;--width:36px}.cc-brand-mark{--icon-swap-duration:.3s;--icon-swap-timing-function:var(--spring)}.cc-brand-icon.icon{--color:currentColor;--height:100%;--width:100%}.cc-caption{--opacity:.6}.cc-card{--transition-duration:.764s;--transition-timing-function:linear(0, .031, .108, .205, .315, .421, .524, .614, .695, .762, .82, .865, .903, .931, .954, .97, .982, .991, .997, 1.001, 1.004, 1.005, 1.006, 1.006, 1.005, 1.005, 1.004, 1.004, 1.003, 1.002, 1)}.cc-chip.icon{--color:currentColor;--height:32px;--width:44px}.cc-control-brand{--color:var(--color-text-300);--inset-horizontal:12px}.cc-control-brand--known{--color:var(--color-text-500)}.cc-digit{--animation-duration:.15s;--animation-timing-function:ease-out}.cc-digit--gap{--gap-horizontal:.6em}.cc-digit--placeholder{--opacity:.45}.cc-disclaimer{--opacity:.6;--padding-bottom:var(--size-500);--padding-horizontal:24px}.cc-error{--color:var(--color-red-400);--offset:2px;--transition-duration:.2s;--transition-timing-function:cubic-bezier(.23, 1, .32, 1)}.cc-expires{--gap-horizontal:0px;--gap-vertical:calc(var(--size-100) / 2)}.cc-face{--background:var(--color-black-300);--border-radius:var(--border-radius-700);--color:var(--color-white-300);--transition-duration:.2s;--transition-timing-function:ease-out}.cc-face--front{--padding-horizontal:24px;--padding-vertical:24px}.cc-face-bottom{--gap-horizontal:24px;--gap-vertical:0px}.cc-field--number.input{--padding-end:64px}.cc-field.input{--background-default:transparent;--border-color-active:var(--surface-border-default);--border-color-default:var(--surface-border-default);--border-color-hover:var(--surface-border-default);--border-color-pressed:var(--surface-border-default);--border-radius:var(--border-radius-600);--border-width:var(--border-width-400);--color-default:currentColor;--font-size:var(--font-size-400);--height:44px;--padding-horizontal:14px;--placeholder-color:oklch(from var(--color-text-300) l c h / .7);--transition-duration:.15s;--transition-timing-function:ease-out}.cc-field.input[aria-invalid=true]{--border-color-active:var(--color-red-400);--border-color-default:var(--color-red-400);--border-color-hover:var(--color-red-400);--border-color-pressed:var(--color-red-400)}.cc-fields{--gap-horizontal:0px;--gap-vertical:var(--size-400)}.cc-holder{--gap-horizontal:0px;--gap-vertical:calc(var(--size-100) / 2)}.cc-label{--font-size:var(--font-size-300);--font-weight:var(--font-weight-500)}.cc-note{--color:var(--color-text-300);--gap-horizontal:calc(var(--size-300) / 2);--gap-vertical:0px}.cc-note-icon.icon{--color:currentColor;--size:14px}.cc-number{--font-size:clamp(16px, 5.2vw, 21px)}.cc-preview{--perspective:1200px}.cc-ring{--border-color:oklch(from var(--color) l c h / .35);--border-radius:var(--border-radius-400);--border-width:1px;--fade-duration:.12s;--fade-timing-function:ease-out;--transition-duration:.3s;--transition-timing-function:var(--spring)}@media (prefers-reduced-motion:reduce){.cc-ring{--transition-duration:0s}}.cc-ring.--active{--fade-duration:.2s}.cc-row{--gap-horizontal:12px;--gap-vertical:12px}.cc-shell{--gap-horizontal:0px;--gap-vertical:var(--size-100)}.cc-shell-header{--gap-horizontal:var(--size-100);--gap-vertical:0px}.cc-signature{--gap-horizontal:12px;--gap-vertical:0px;--padding-horizontal:24px;--padding-top:var(--size-500)}.cc-signature-value{--background:var(--color-white-300);--color:var(--color-black-300);--height:40px;--padding-horizontal:12px}.cc-stripe{--background:oklch(from var(--color) l c h / .15);--height:44px;--margin-top:24px}.cc-submit.button{--background-default:var(--color-primary-500);--border-radius:var(--border-radius-600);--color-default:var(--color-surface);--font-size:var(--font-size-400);--font-weight:var(--font-weight-500);--height:44px;--padding-horizontal:var(--size-500);--padding-vertical:0px}.cc{color:var(--color);gap:var(--gap-vertical) var(--gap-horizontal);width:var(--width);flex-direction:column;display:flex}.cc-actions{gap:var(--gap-vertical) var(--gap-horizontal);flex-direction:column;display:flex}.cc-brand{grid-template:100%/100%;display:grid}.cc-brand--large,.cc-brand--small{height:var(--height);width:var(--width)}.cc-brand-mark{grid-area:1/1;width:100%;height:100%}.cc-caption{font-size:var(--font-size-300);opacity:var(--opacity);text-transform:uppercase}.cc-card{height:100%;transform-style:preserve-3d;transition:transform var(--transition-duration) var(--transition-timing-function);width:100%;position:relative}.cc-card--flipped{transform:rotateY(180deg)}@media (prefers-reduced-motion:reduce){.cc-card--flipped{transform:none}.cc-card--flipped .cc-face--back{opacity:1}.cc-card--flipped .cc-face--front{opacity:0}}.cc-control{position:relative}.cc-control-brand{color:var(--color);pointer-events:none;right:var(--inset-horizontal);transition:color var(--transition-duration) var(--transition-timing-function);display:flex}.cc-digit{display:inline-block}.cc-digit--gap{margin-inline-start:var(--gap-horizontal)}.cc-digit--placeholder{opacity:var(--opacity)}.cc-digit--roll-1{animation:cc-digit--roll-1 var(--animation-duration) var(--animation-timing-function)}@media (prefers-reduced-motion:reduce){.cc-digit--roll-1{animation-name:cc-digit-fade}}@keyframes cc-digit--roll-1{0%{filter:blur(var(--blur-300));opacity:0;translate:0 -4px}}.cc-digit--roll-2{animation:cc-digit--roll-2 var(--animation-duration) var(--animation-timing-function)}@media (prefers-reduced-motion:reduce){.cc-digit--roll-2{animation-name:cc-digit-fade}}@keyframes cc-digit--roll-2{0%{filter:blur(var(--blur-300));opacity:0;translate:0 -4px}}@keyframes cc-digit-fade{0%{opacity:0}}.cc-disclaimer{font-size:var(--font-size-300);opacity:var(--opacity);padding-block:0 var(--padding-bottom);padding-inline:var(--padding-horizontal);margin:auto 0 0}.cc-error{color:var(--color);font-size:var(--font-size-300);transition:filter var(--transition-duration) var(--transition-timing-function), opacity var(--transition-duration) var(--transition-timing-function), translate var(--transition-duration) var(--transition-timing-function)}@starting-style{.cc-error{filter:blur(var(--blur-400));opacity:0;translate:0 var(--offset)}}@media (prefers-reduced-motion:reduce){@starting-style{.cc-error{filter:none;translate:0}}}.cc-expires{gap:var(--gap-vertical) var(--gap-horizontal);flex-direction:column;flex-shrink:0;display:flex}.cc-expires-value{font-family:var(--font-family);font-size:var(--font-size-400);font-weight:var(--font-weight-500)}.cc-face{backface-visibility:hidden;background:var(--background);border-radius:var(--border-radius);box-shadow:var(--surface-shadow-default);color:var(--color);transition:opacity var(--transition-duration) var(--transition-timing-function);flex-direction:column;display:flex;overflow:hidden}.cc-face--back{transform:rotateY(180deg)}@media (prefers-reduced-motion:reduce){.cc-face--back{opacity:0;transform:none}}.cc-face--front{padding-block:var(--padding-vertical);padding-inline:var(--padding-horizontal);justify-content:space-between}.cc-face-bottom{align-items:flex-end;gap:var(--gap-vertical) var(--gap-horizontal);justify-content:space-between;display:flex}.cc-face-top{justify-content:space-between;align-items:flex-start;display:flex}.cc-field--cvc,.cc-field--expiry,.cc-field--number{font-family:var(--font-family)}.cc-field--number.input{padding-inline-end:var(--padding-end)}.cc-field.input{font-variant-numeric:tabular-nums;height:var(--height);min-height:0;transition:border-color var(--transition-duration) var(--transition-timing-function);outline:none;padding-block:0}.cc-field.input::placeholder{color:var(--placeholder-color)}.cc-field.input:focus-visible{outline:var(--focus-width) solid var(--focus-color);outline-offset:var(--focus-offset)}.cc-fields{gap:var(--gap-vertical) var(--gap-horizontal);flex-direction:column;display:flex}.cc-holder{gap:var(--gap-vertical) var(--gap-horizontal);flex-direction:column;flex:1;min-width:0;display:flex}.cc-holder-value{font-size:var(--font-size-400);font-weight:var(--font-weight-500);text-transform:uppercase}.cc-label{font-size:var(--font-size);font-weight:var(--font-weight);-webkit-user-select:none;user-select:none}.cc-note{color:var(--color);font-size:var(--font-size-300);align-items:center;gap:var(--gap-vertical) var(--gap-horizontal);justify-content:center;margin:0;display:flex}.cc-number{font-family:var(--font-family);font-size:var(--font-size);white-space:nowrap;align-self:flex-start}.cc-preview{aspect-ratio:1.586;perspective:var(--perspective);-webkit-user-select:none;user-select:none;width:100%;position:relative}.cc-ring{border:var(--border-width) solid var(--border-color);border-radius:var(--border-radius);opacity:0;pointer-events:none;transition:display var(--fade-duration) allow-discrete, height var(--transition-duration) var(--transition-timing-function), left var(--transition-duration) var(--transition-timing-function), opacity var(--fade-duration) var(--fade-timing-function), top var(--transition-duration) var(--transition-timing-function), width var(--transition-duration) var(--transition-timing-function);display:none;position:absolute;top:0;left:0}.cc-ring.--active{opacity:1;display:block}@starting-style{.cc-ring.--active{opacity:0}}.cc-row{gap:var(--gap-vertical) var(--gap-horizontal);grid-template-columns:repeat(2,minmax(0,1fr));display:grid}.cc-shell{gap:var(--gap-vertical) var(--gap-horizontal);flex-direction:column;min-width:0;display:flex}.cc-shell-header{align-items:baseline;gap:var(--gap-vertical) var(--gap-horizontal);justify-content:space-between;display:flex}.cc-signature{align-items:center;gap:var(--gap-vertical) var(--gap-horizontal);padding-block:var(--padding-top) 0;padding-inline:var(--padding-horizontal);display:flex}.cc-signature-value{background:var(--background);border-radius:var(--border-radius-300);color:var(--color);font-family:var(--font-family);font-size:var(--font-size-400);height:var(--height);padding-inline:var(--padding-horizontal);flex:1;justify-content:flex-end;align-items:center;font-style:italic;display:flex}.cc-stripe{background:var(--background);height:var(--height);margin-top:var(--margin-top)}.cc-submit.button{height:var(--height);border:0;outline:none}.cc-submit.button:focus-visible{outline:var(--focus-width) solid var(--focus-color);outline-offset:var(--focus-offset)}}
2
- /*$vite$:1*/
@@ -1,562 +0,0 @@
1
- import { computed, effect, onCleanup, reactive, read } from '@esportsplus/reactivity';
2
- import { component, html, type Attributes, type Renderable } from '@esportsplus/template';
3
- import amex from '@esportsplus/ui/svg/amex.svg';
4
- import card from '@esportsplus/ui/svg/card.svg';
5
- import checkSvg from '@esportsplus/ui/svg/check.svg';
6
- import chip from '@esportsplus/ui/svg/chip.svg';
7
- import discover from '@esportsplus/ui/svg/discover.svg';
8
- import lock from '@esportsplus/ui/svg/lock.svg';
9
- import mastercard from '@esportsplus/ui/svg/mastercard.svg';
10
- import visa from '@esportsplus/ui/svg/visa.svg';
11
- import faces from '~/components/button/faces';
12
- import icon from '~/components/icon';
13
- import input from '~/components/input';
14
- import '~/components/button/scss/index.scss';
15
- import './scss/index.scss';
16
-
17
-
18
- type A = Attributes & {
19
- [CC_FIELD]?: FieldAttributes;
20
- [CC_SUBMIT]?: Attributes;
21
- note?: Renderable<unknown>;
22
- onvalid?: (card: Card) => void;
23
- state?: State;
24
- submit?: Renderable<unknown>;
25
- };
26
-
27
- type Brand = 'amex' | 'discover' | 'mastercard' | 'unknown' | 'visa';
28
-
29
- type Card = {
30
- brand: Brand;
31
- expiry: string;
32
- last4: string;
33
- name: string;
34
- };
35
-
36
- type D = Attributes & Pick<A, typeof CC_FIELD | typeof CC_SUBMIT>;
37
-
38
- type Field = 'cvc' | 'expiry' | 'name' | 'number';
39
-
40
- type FieldAttributes = Parameters<typeof input>[0];
41
-
42
- type Slot = {
43
- char: string;
44
- gap: boolean;
45
- roll: number;
46
- };
47
-
48
- type Spec = {
49
- cvc: number;
50
- gaps: number[];
51
- icon: string;
52
- // Valid lengths; the first is what the card face shows as placeholders.
53
- lengths: number[];
54
- name: string;
55
- test: RegExp;
56
- };
57
-
58
- type State = Record<Field, string>;
59
-
60
-
61
- const BRANDS: Record<Brand, Spec> = {
62
- // Amex groups 4-6-5 and puts a 4 digit code on the front.
63
- amex: { cvc: 4, gaps: [4, 10], icon: amex, lengths: [15], name: 'American Express', test: /^3[47]/ },
64
- discover: { cvc: 3, gaps: [4, 8, 12, 16], icon: discover, lengths: [16, 19], name: 'Discover', test: /^(6011|65|64[4-9])/ },
65
- mastercard: { cvc: 3, gaps: [4, 8, 12], icon: mastercard, lengths: [16], name: 'Mastercard', test: /^(5[1-5]|2[2-7])/ },
66
- // An unrecognised prefix stops at 16, the length nearly every card has, so a typo never spills past the card.
67
- unknown: { cvc: 3, gaps: [4, 8, 12, 16], icon: card, lengths: [16, 12, 13, 14, 15], name: 'Card', test: /^/ },
68
- visa: { cvc: 3, gaps: [4, 8, 12, 16], icon: visa, lengths: [16, 13, 19], name: 'Visa', test: /^4/ }
69
- };
70
-
71
- const CC_FIELD = Symbol.for('@esportsplus/ui/cc.field');
72
-
73
- const CC_SUBMIT = Symbol.for('@esportsplus/ui/cc.submit');
74
-
75
- // Long enough to read, short enough that a second check isn't blocked.
76
- const CONFIRM_FOR = 2000;
77
-
78
- const DIGIT = /\d/;
79
-
80
- const FIELDS: Field[] = ['number', 'expiry', 'cvc', 'name'];
81
-
82
- const INVALID_MONTH_START = /^[2-9]/;
83
-
84
- const NON_DIGIT = /\D/;
85
-
86
- const NON_DIGITS = /\D/g;
87
-
88
- const ORDER: Brand[] = ['visa', 'mastercard', 'amex', 'discover'];
89
-
90
-
91
- let uid = 0;
92
-
93
-
94
- function caret(value: string, count: number) {
95
- if (count <= 0) {
96
- return 0;
97
- }
98
-
99
- let seen = 0;
100
-
101
- for (let i = 0, n = value.length; i < n; i++) {
102
- if (DIGIT.test(value[i]) && ++seen === count) {
103
- return i + 1;
104
- }
105
- }
106
-
107
- return value.length;
108
- }
109
-
110
- function detect(value: string): Brand {
111
- let digits = digitsOf(value);
112
-
113
- return ORDER.find((brand) => BRANDS[brand].test.test(digits)) ?? 'unknown';
114
- }
115
-
116
- function digitsOf(value: string) {
117
- return value.replace(NON_DIGITS, '');
118
- }
119
-
120
- function expiry(digits: string) {
121
- return digits.length > 2 ? `${digits.slice(0, 2)}/${digits.slice(2)}` : digits;
122
- }
123
-
124
- function group(digits: string, gaps: number[]) {
125
- let out = '';
126
-
127
- for (let i = 0, n = digits.length; i < n; i++) {
128
- if (gaps.includes(i)) {
129
- out += ' ';
130
- }
131
-
132
- out += digits[i];
133
- }
134
-
135
- return out;
136
- }
137
-
138
- function luhn(digits: string) {
139
- let sum = 0;
140
-
141
- for (let i = 0, n = digits.length; i < n; i++) {
142
- let d = Number(digits[n - 1 - i]);
143
-
144
- if (i % 2) {
145
- d *= 2;
146
-
147
- if (d > 9) {
148
- d -= 9;
149
- }
150
- }
151
-
152
- sum += d;
153
- }
154
-
155
- return sum % 10 === 0;
156
- }
157
-
158
- // Monochrome marks in currentColor, so they take the theme instead of fighting it.
159
- function mark(brand: () => Brand, size: 'large' | 'small') {
160
- return html`
161
- <span aria-hidden='true' class='cc-brand cc-brand--${size}'>
162
- ${(Object.keys(BRANDS) as Brand[]).map((b) => html`
163
- <span class='cc-brand-mark ${() => brand() === b && '--active'}'>
164
- ${icon({ class: 'cc-brand-icon' }, BRANDS[b].icon)}
165
- </span>
166
- `)}
167
- </span>
168
- `;
169
- }
170
-
171
- // Reformats in place and puts the caret back after the same number of digits it was after, so editing mid-number
172
- // never throws it to the end.
173
- function reformat(element: HTMLInputElement, max: number, format: (digits: string) => string, pad?: (digits: string) => string) {
174
- let at = element.selectionStart ?? element.value.length,
175
- before = digitsOf(element.value.slice(0, at)).length,
176
- digits = digitsOf(element.value).slice(0, max);
177
-
178
- if (pad) {
179
- let padded = pad(digits);
180
-
181
- before += padded.length - digits.length;
182
- digits = padded;
183
- }
184
-
185
- let value = format(digits);
186
-
187
- element.value = value;
188
-
189
- if (document.activeElement === element) {
190
- let position = caret(value, Math.min(before, digits.length));
191
-
192
- element.setSelectionRange(position, position);
193
- }
194
-
195
- return value;
196
- }
197
-
198
- // Backspace right after a space or slash would delete the separator, which reformatting puts straight back, leaving
199
- // the caret stuck. Step over it so the digit before goes instead.
200
- function skip(e: KeyboardEvent) {
201
- let element = e.currentTarget as HTMLInputElement,
202
- at = element.selectionStart;
203
-
204
- if (at === null || at !== element.selectionEnd) {
205
- return;
206
- }
207
-
208
- if (e.key === 'Backspace' && at > 0 && NON_DIGIT.test(element.value[at - 1])) {
209
- element.setSelectionRange(at - 1, at - 1);
210
- }
211
-
212
- if (e.key === 'Delete' && at < element.value.length && NON_DIGIT.test(element.value[at])) {
213
- element.setSelectionRange(at + 1, at + 1);
214
- }
215
- }
216
-
217
- function validate(field: Field, values: State, final: boolean) {
218
- let spec = BRANDS[detect(values.number)],
219
- value = values[field],
220
- digits = digitsOf(value);
221
-
222
- // Tabbing past an empty field isn't a mistake; only a full check flags it.
223
- if (!value.trim()) {
224
- return final ? 'Required' : '';
225
- }
226
-
227
- if (field === 'number') {
228
- if (!spec.lengths.includes(digits.length)) {
229
- return 'Too short';
230
- }
231
-
232
- if (!luhn(digits)) {
233
- return 'Not a valid number';
234
- }
235
- }
236
-
237
- if (field === 'expiry') {
238
- if (digits.length < 4) {
239
- return 'Use MM/YY';
240
- }
241
-
242
- let month = Number(digits.slice(0, 2)),
243
- now = new Date(),
244
- year = 2000 + Number(digits.slice(2));
245
-
246
- if (month < 1 || month > 12) {
247
- return 'Invalid month';
248
- }
249
-
250
- // Cards stay valid through the last day of their expiry month.
251
- if (year < now.getFullYear() || (year === now.getFullYear() && month < now.getMonth() + 1)) {
252
- return 'Card expired';
253
- }
254
- }
255
-
256
- if (field === 'cvc' && digits.length < spec.cvc) {
257
- return 'Too short';
258
- }
259
-
260
- return '';
261
- }
262
-
263
-
264
- export default component(
265
- function(
266
- this: { attributes?: D } | void,
267
- {
268
- note = '',
269
- onvalid,
270
- state = reactive({ cvc: '', expiry: '', name: '', number: '' }),
271
- submit = 'Check details',
272
- ...attributes
273
- }: A
274
- ) {
275
- // Every brand binding reads this, so typing digits only reaches them when the brand itself changes.
276
- let detected = computed(() => detect(state.number)),
277
- fields: Record<Field, { active: boolean; error: string }> = {
278
- cvc: reactive({ active: false, error: '' }),
279
- expiry: reactive({ active: false, error: '' }),
280
- name: reactive({ active: false, error: '' }),
281
- number: reactive({ active: false, error: '' })
282
- },
283
- id = `cc-${++uid}`,
284
- local = reactive({ confirmed: false, ring: false }),
285
- // The ring's box, kept where it last framed a field while it fades out.
286
- outline = reactive({
287
- height: undefined as string | undefined,
288
- left: undefined as string | undefined,
289
- top: undefined as string | undefined,
290
- width: undefined as string | undefined
291
- }),
292
- parts = { ...this?.attributes?.[CC_FIELD], ...attributes[CC_FIELD] },
293
- regions: Partial<Record<Field, HTMLElement>> = {},
294
- slots = reactive([] as Slot[]),
295
- timer: ReturnType<typeof setTimeout> | undefined;
296
-
297
- // Only appearing and clearing rebuild an error; a new message just swaps its text, so it doesn't replay the
298
- // entrance.
299
- let errors = Object.fromEntries(
300
- FIELDS.map((field) => [field, computed(() => !!fields[field].error)])
301
- ) as Record<Field, ReturnType<typeof computed<boolean>>>;
302
-
303
- function brand() {
304
- return read(detected);
305
- }
306
-
307
- function check(e: SubmitEvent) {
308
- e.preventDefault();
309
-
310
- let bad: Field | undefined;
311
-
312
- for (let i = 0, n = FIELDS.length; i < n; i++) {
313
- let error = validate(FIELDS[i], state, true);
314
-
315
- fields[FIELDS[i]].error = error;
316
-
317
- if (error && !bad) {
318
- bad = FIELDS[i];
319
- }
320
- }
321
-
322
- if (bad) {
323
- ((e.currentTarget as HTMLFormElement).elements.namedItem(bad) as HTMLInputElement).focus();
324
- return;
325
- }
326
-
327
- local.confirmed = true;
328
- onvalid?.({ brand: brand(), expiry: state.expiry, last4: digitsOf(state.number).slice(-4), name: state.name.trim() });
329
-
330
- clearTimeout(timer);
331
- timer = setTimeout(() => {
332
- local.confirmed = false;
333
- }, CONFIRM_FOR);
334
- }
335
-
336
- function control(field: Field, own: FieldAttributes) {
337
- return input.call({ attributes: parts }, {
338
- ...own,
339
- 'aria-describedby': () => fields[field].error && `${id}-${field}-error`,
340
- 'aria-invalid': () => fields[field].error ? 'true' : 'false',
341
- class: `cc-field cc-field--${field}`,
342
- id: `${id}-${field}`,
343
- name: field,
344
- onblur: () => {
345
- fields[field].error = validate(field, state, false);
346
- },
347
- state: fields[field],
348
- value: () => state[field]
349
- });
350
- }
351
-
352
- function focused() {
353
- return FIELDS.find((field) => fields[field].active) ?? '';
354
- }
355
-
356
- // The ring is measured with offset* values, which ignore the flip's transform.
357
- function frame(field: Field | '') {
358
- let region = field && field !== 'cvc' ? regions[field] : undefined;
359
-
360
- if (!region) {
361
- local.ring = false;
362
- return;
363
- }
364
-
365
- outline.height = `${region.offsetHeight + 12}px`;
366
- outline.left = `${region.offsetLeft - 8}px`;
367
- outline.top = `${region.offsetTop - 6}px`;
368
- outline.width = `${region.offsetWidth + 16}px`;
369
- local.ring = true;
370
- }
371
-
372
- function set(field: Field, value: string) {
373
- state[field] = value;
374
- // Typing is the fix, so the error goes at once rather than fading.
375
- fields[field].error = '';
376
- local.confirmed = false;
377
- }
378
-
379
- function shell(field: Field, label: string, content: Renderable<unknown>) {
380
- return html`
381
- <div class='cc-shell cc-shell--${field}'>
382
- <div class='cc-shell-header'>
383
- <label class='cc-label' for='${id}-${field}'>${label}</label>
384
- ${() => read(errors[field]) && html`
385
- <span class='cc-error' id='${id}-${field}-error'>${() => fields[field].error}</span>
386
- `}
387
- </div>
388
- ${content}
389
- </div>
390
- `;
391
- }
392
-
393
- effect(() => digitsOf(state.number), (digits) => {
394
- let initial = slots.length === 0,
395
- spec = BRANDS[detect(digits)],
396
- length = Math.max(spec.lengths[0], digits.length);
397
-
398
- for (let i = 0; i < length; i++) {
399
- let char = digits[i] ?? '•',
400
- gap = spec.gaps.includes(i),
401
- slot = slots[i];
402
-
403
- if (!slot) {
404
- slots.push(reactive({ char, gap, roll: initial ? 0 : 1 }));
405
- continue;
406
- }
407
-
408
- slot.gap = gap;
409
-
410
- // Alternating the roll parity swaps between identical keyframes, replaying the arrival for each new digit.
411
- if (slot.char !== char) {
412
- slot.char = char;
413
- slot.roll = slot.roll === 1 ? 2 : 1;
414
- }
415
- }
416
-
417
- if (slots.length > length) {
418
- slots.splice(length);
419
- }
420
- });
421
-
422
- effect(focused, frame);
423
-
424
- onCleanup(() => clearTimeout(timer));
425
-
426
- return html`
427
- <form
428
- aria-label='Card details'
429
- class='cc'
430
- novalidate
431
- ${this?.attributes}
432
- ${attributes}
433
- ${{ onsubmit: check }}
434
- >
435
- <div aria-hidden='true' class='cc-preview'>
436
- <div class='cc-card ${() => focused() === 'cvc' && 'cc-card--flipped'}'>
437
- <div class='cc-face cc-face--front'>
438
- <span
439
- class='cc-ring ${() => local.ring && '--active'}'
440
- ${{
441
- style: () => ({
442
- height: outline.height,
443
- left: outline.left,
444
- top: outline.top,
445
- width: outline.width
446
- })
447
- }}
448
- ></span>
449
- <div class='cc-face-top'>
450
- ${icon({ class: 'cc-chip' }, chip)}
451
- ${mark(brand, 'large')}
452
- </div>
453
- <div class='cc-number' ${{ onconnect: (element: HTMLElement) => { regions.number = element; } }}>
454
- ${html.reactive(slots, (slot) => html`
455
- <span
456
- class='cc-digit ${() => slot.gap && 'cc-digit--gap'} ${() => slot.char === '•' && 'cc-digit--placeholder'} ${() => slot.roll && `cc-digit--roll-${slot.roll}`}'
457
- >${() => slot.char}</span>
458
- `)}
459
- </div>
460
- <div class='cc-face-bottom'>
461
- <div class='cc-holder' ${{ onconnect: (element: HTMLElement) => { regions.name = element; } }}>
462
- <span class='cc-caption'>Card holder</span>
463
- <span class='cc-holder-value'>${() => state.name.trim() || 'Your name'}</span>
464
- </div>
465
- <div class='cc-expires' ${{ onconnect: (element: HTMLElement) => { regions.expiry = element; } }}>
466
- <span class='cc-caption'>Expires</span>
467
- <span class='cc-expires-value'>${() => state.expiry || 'MM/YY'}</span>
468
- </div>
469
- </div>
470
- </div>
471
- <div class='cc-face cc-face--back'>
472
- <div class='cc-stripe'></div>
473
- <div class='cc-signature'>
474
- <div class='cc-signature-value'>${() => state.cvc || (brand() === 'amex' ? '••••' : '•••')}</div>
475
- <span class='cc-caption'>CVC</span>
476
- </div>
477
- <p class='cc-disclaimer'>Not a real card. Nothing you type leaves this page.</p>
478
- </div>
479
- </div>
480
- </div>
481
-
482
- <div class='cc-fields'>
483
- ${shell('number', 'Card number', html`
484
- <div class='cc-control'>
485
- ${control('number', {
486
- autocomplete: 'cc-number',
487
- inputmode: 'numeric',
488
- oninput: (e: Event) => {
489
- let element = e.currentTarget as HTMLInputElement,
490
- spec = BRANDS[detect(element.value)];
491
-
492
- set('number', reformat(element, Math.max(...spec.lengths), (d) => group(d, spec.gaps)));
493
-
494
- // A shorter code is required once the brand changes away from Amex.
495
- if (state.cvc.length > spec.cvc) {
496
- state.cvc = state.cvc.slice(0, spec.cvc);
497
- }
498
- },
499
- onkeydown: skip,
500
- placeholder: '1234 5678 9012 3456'
501
- })}
502
- <span class='cc-control-brand ${() => brand() !== 'unknown' && 'cc-control-brand--known'}'>${mark(brand, 'small')}</span>
503
- </div>
504
- `)}
505
- <div class='cc-row'>
506
- ${shell('expiry', 'Expiry', control('expiry', {
507
- autocomplete: 'cc-exp',
508
- inputmode: 'numeric',
509
- oninput: (e: Event) => {
510
- // A first digit of 2 to 9 can only be a single digit month.
511
- set('expiry', reformat(e.currentTarget as HTMLInputElement, 4, expiry, (d) => INVALID_MONTH_START.test(d) ? `0${d}`.slice(0, 4) : d));
512
- },
513
- onkeydown: skip,
514
- placeholder: 'MM/YY'
515
- }))}
516
- ${shell('cvc', 'CVC', control('cvc', {
517
- autocomplete: 'cc-csc',
518
- inputmode: 'numeric',
519
- oninput: (e: Event) => {
520
- set('cvc', reformat(e.currentTarget as HTMLInputElement, BRANDS[brand()].cvc, (d) => d));
521
- },
522
- placeholder: () => brand() === 'amex' ? '1234' : '123'
523
- }))}
524
- </div>
525
- ${shell('name', 'Name on card', control('name', {
526
- autocapitalize: 'words',
527
- autocomplete: 'cc-name',
528
- maxlength: 40,
529
- oninput: (e: Event) => {
530
- set('name', (e.currentTarget as HTMLInputElement).value);
531
- },
532
- placeholder: 'Ada Lovelace',
533
- spellcheck: false
534
- }))}
535
- </div>
536
-
537
- <div class='cc-actions'>
538
- <button
539
- class='button button--feedback cc-submit'
540
- type='submit'
541
- ${this?.attributes?.[CC_SUBMIT]}
542
- ${attributes[CC_SUBMIT]}
543
- >
544
- ${faces(() => local.confirmed ? 'valid' : 'idle', [
545
- { content: submit, key: 'idle' },
546
- { content: html`${icon({ 'aria-hidden': 'true', class: 'button-icon button-icon--draw' }, checkSvg)}Details look valid`, key: 'valid' }
547
- ])}
548
- </button>
549
- ${!!note && html`
550
- <p class='cc-note'>
551
- ${icon({ 'aria-hidden': 'true', class: 'cc-note-icon' }, lock)}
552
- ${note}
553
- </p>
554
- `}
555
- <span aria-live='polite' class='button-status' role='status'>${() => local.confirmed && 'Card details look valid'}</span>
556
- <span aria-live='polite' class='cc-live'>${() => brand() !== 'unknown' && `${BRANDS[brand()].name} card`}</span>
557
- </div>
558
- </form>
559
- `;
560
- },
561
- { field: CC_FIELD, submit: CC_SUBMIT }
562
- );