{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-sso-sign-in",
  "type": "registry:block",
  "title": "Single sign-on",
  "description": "Signing in through an identity provider in the sign-in card: Google, Microsoft and a work e-mail for SAML.",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/divider.json",
    "https://wideset.co/r/form-field.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/sso-sign-in/app-icon.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/sso-sign-in/app-icon.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\nimport { useId } from 'react';\n\n/** Figma's W, in its own box (24.97 × 13.87). */\nconst W =\n  'M21.377 0C21.377 0 18.14 9.233 18.017 9.574C17.95 9.402 14.331 0 14.331 0H11.069C11.069 0 7.462 9.574 7.41 9.703C7.353 9.57 3.508 0 3.508 0H0L5.853 13.871H9.059L12.716 4.054H12.773C12.81 4.149 16.51 13.871 16.51 13.871H19.827C19.827 13.871 24.932 0.114 24.967 0H21.377Z';\n\n/** Figma's tile, 46.24 × 46.89 with a 16.18 radius, at its place in the 47.25 × 48 icon. */\nconst TILE = { x: 0.69, y: 0.81, width: 46.24, height: 46.89, rx: 16.18 };\n\n// Light-palette primitives: the icon looks the same in dark mode.\nconst INDIGO_300 = '[stop-color:var(--ws-colors-light-indigo-300)]';\nconst INDIGO_400 = '[stop-color:var(--ws-colors-light-indigo-400)]';\nconst INDIGO_500 = '[stop-color:var(--ws-colors-light-indigo-500)]';\nconst INDIGO_600 = '[stop-color:var(--ws-colors-light-indigo-600)]';\nconst INDIGO_700 = '[stop-color:var(--ws-colors-light-indigo-700)]';\nconst PURPLE_200 = '[stop-color:var(--ws-colors-light-purple-200)]';\nconst PURPLE_400 = '[stop-color:var(--ws-colors-light-purple-400)]';\nconst WHITE = '[stop-color:var(--ws-colors-light-neutral-0)]';\n\n/**\n * The app icon at the top of a sign-in card: Figma's glass tile, a W lit from below. It is not the\n * flat brand mark of an app's sidebar, and it keeps its colours in dark mode, so it draws with the\n * light palette's primitives. Figma lights the tile with blurred, blended shapes; here that light is\n * two gradients in the nearest tokens. Decorative: the title beside it names the product.\n */\nexport function AppIcon({ className }: { className?: string }) {\n  const id = useId();\n  const url = (name: string) => `url(#${id}${name})`;\n\n  return (\n    <svg\n      viewBox=\"0 0 47.25 48\"\n      preserveAspectRatio=\"none\"\n      aria-hidden=\"true\"\n      className={cn('size-ws-18 shrink-0', className)}\n    >\n      <defs>\n        <clipPath id={`${id}tile`}>\n          <rect {...TILE} />\n        </clipPath>\n        {/* The light rising from the bottom edge. */}\n        <linearGradient id={`${id}glow`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopOpacity={0.06} className={INDIGO_600} />\n          <stop offset=\"0.4\" stopOpacity={0.1} className={INDIGO_600} />\n          <stop offset=\"0.6\" stopOpacity={0.38} className={INDIGO_600} />\n          <stop offset=\"0.75\" stopOpacity={0.62} className={INDIGO_600} />\n          <stop offset=\"0.86\" stopOpacity={0.85} className={INDIGO_600} />\n          <stop offset=\"0.93\" stopOpacity={0.9} className={INDIGO_500} />\n          <stop offset=\"0.97\" className={INDIGO_400} />\n          <stop offset=\"1\" className={INDIGO_300} />\n        </linearGradient>\n        {/* Figma's radial fill: centred above the tile, so its rim lights the lower corners. */}\n        <radialGradient\n          id={`${id}bowl`}\n          cx=\"0.5\"\n          cy=\"-0.111\"\n          r=\"1\"\n          gradientTransform=\"matrix(0.8005 0 0 1.4758 0.0998 0.0528)\"\n        >\n          <stop offset=\"0.55\" stopOpacity={0} className={INDIGO_600} />\n          <stop offset=\"0.79\" className={INDIGO_600} />\n          <stop offset=\"0.86\" className={INDIGO_400} />\n        </radialGradient>\n        <linearGradient id={`${id}w`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" className={PURPLE_200} />\n          <stop offset=\"0.5\" stopOpacity={0.56} className={INDIGO_500} />\n          <stop offset=\"1\" stopOpacity={0.15} className={INDIGO_700} />\n        </linearGradient>\n        {/* Figma's two glass highlights: a lilac line along the top, a white one along the bottom. */}\n        <linearGradient id={`${id}rim`} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n          <stop offset=\"0\" stopOpacity={0.3} className={PURPLE_400} />\n          <stop offset=\"0.15\" stopOpacity={0} className={PURPLE_400} />\n          <stop offset=\"0.92\" stopOpacity={0} className={WHITE} />\n          <stop offset=\"1\" stopOpacity={0.2} className={WHITE} />\n        </linearGradient>\n      </defs>\n      <g clipPath={url('tile')}>\n        <rect {...TILE} className=\"fill-(--ws-colors-light-brand-1100)\" />\n        <rect {...TILE} fill={url('bowl')} />\n        <rect {...TILE} fill={url('glow')} />\n      </g>\n      <rect\n        x=\"0.23\"\n        y=\"0.23\"\n        width=\"46.79\"\n        height=\"47.54\"\n        rx=\"16.18\"\n        fill=\"none\"\n        stroke={url('rim')}\n        strokeWidth=\"0.46\"\n      />\n      <path transform=\"translate(11.32 18.61)\" d={W} fill={url('w')} />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/sso-sign-in/auth-card.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/sso-sign-in/auth-card.tsx",
      "content": "'use client';\n\nimport {\n  type RemixiconComponentType,\n  RiArrowDownSLine,\n  RiArrowLeftLine,\n  RiArrowUpSLine,\n} from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\nimport { type AnchorHTMLAttributes, type ReactNode, useEffect, useRef } from 'react';\n\nimport { AppIcon } from './app-icon';\n\n/*\n  The card a sign-in or sign-up screen sits in. Every starting point that uses it (the sign-in,\n  sign-up and account-access screens) carries a byte-identical copy of this file and of app-icon.tsx;\n  src/__tests__/blocks.test.tsx keeps them the same.\n*/\n\ntype AuthCardProps = {\n  /** The other screen (sign in, or create an account), in the footer; ↑ and ↓ open it too. */\n  other: { href: string; label: string };\n  children: ReactNode;\n  className?: string;\n};\n\nconst FOOTER_CONTROL =\n  'typography-body-md text-ws-static-subtle hover:text-ws-static-base gap-ws-5 rounded-ws-control-md focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default flex cursor-pointer items-center';\n\n/**\n * Figma's sign-in card: the app icon and the form on white, a grey footer that says how to leave by\n * keyboard. Esc, or ← outside a text field, goes back; ↑ or ↓ outside a text field opens the other\n * screen. In a field the arrows stay with the field: they move the caret and open autofill.\n * 740px tall as in Figma, or the window less the page's padding when that is shorter, and never\n * shorter than its content.\n */\nexport function AuthCard({ other, children, className }: AuthCardProps) {\n  const back = useRef<HTMLButtonElement>(null);\n  const next = useRef<HTMLAnchorElement>(null);\n\n  useEffect(() => {\n    const onKeyDown = (event: KeyboardEvent) => {\n      if (event.defaultPrevented || event.isComposing) return;\n      if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n      const typing =\n        event.target instanceof Element &&\n        event.target.closest('input, textarea, select, [contenteditable]') !== null;\n      if (event.key === 'Escape' || (event.key === 'ArrowLeft' && !typing)) {\n        back.current?.click();\n      } else if ((event.key === 'ArrowUp' || event.key === 'ArrowDown') && !typing) {\n        event.preventDefault();\n        next.current?.click();\n      }\n    };\n    document.addEventListener('keydown', onKeyDown);\n    return () => document.removeEventListener('keydown', onKeyDown);\n  }, []);\n\n  return (\n    <div\n      className={cn(\n        'bg-ws-static-foreground rounded-ws-container-xl shadow-ws-low flex h-[min(46.25rem,calc(100dvh-3rem))] min-h-fit flex-col justify-between overflow-hidden',\n        className,\n      )}\n    >\n      <div className=\"gap-ws-14 p-ws-12 sm:p-ws-18 flex flex-col items-start\">\n        <AppIcon />\n        {children}\n      </div>\n      <footer className=\"bg-ws-static-alpha-subtle px-ws-12 py-ws-9 flex items-center justify-between\">\n        <button\n          ref={back}\n          type=\"button\"\n          aria-keyshortcuts=\"Escape ArrowLeft\"\n          onClick={() => window.history.back()}\n          className={FOOTER_CONTROL}\n        >\n          <Key icon={RiArrowLeftLine} />\n          Back\n        </button>\n        <a\n          ref={next}\n          href={other.href}\n          aria-keyshortcuts=\"ArrowUp ArrowDown\"\n          className={FOOTER_CONTROL}\n        >\n          <span className=\"gap-ws-3 flex\">\n            <Key icon={RiArrowUpSLine} />\n            <Key icon={RiArrowDownSLine} />\n          </span>\n          {other.label}\n        </a>\n      </footer>\n    </div>\n  );\n}\n\n/**\n * A key, drawn as Figma draws it here: the box of Button `xs` Border, as a `kbd`. The control it\n * sits in names the shortcut (`aria-keyshortcuts`), so screen readers skip the key itself.\n */\nfunction Key({ icon: Icon }: { icon: RemixiconComponentType }) {\n  return (\n    <kbd\n      aria-hidden=\"true\"\n      className=\"border-ws-dynamic-secondary-default bg-ws-static-highlight-subtle shadow-ws-controls-control rounded-ws-control-md size-ws-12 text-ws-dynamic-secondary-default flex shrink-0 items-center justify-center border\"\n    >\n      <Icon className=\"size-ws-8\" />\n    </kbd>\n  );\n}\n\n/** A link inside a sentence, as Figma draws the help line's: body text in the primary colour, underlined. */\nexport function TextLink({\n  className,\n  children,\n  ...props\n}: AnchorHTMLAttributes<HTMLAnchorElement>) {\n  return (\n    <a\n      className={cn(\n        'text-ws-dynamic-primary-default hover:text-ws-dynamic-primary-hover active:text-ws-dynamic-primary-pressed rounded-ws-control-sm focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default underline decoration-from-font',\n        className,\n      )}\n      {...props}\n    >\n      {children}\n    </a>\n  );\n}\n"
    },
    {
      "path": "src/blocks/sso-sign-in/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/sso-sign-in/data.ts",
      "content": "/** Where the screen leads: replace with your routes. */\nexport const ROUTES = {\n  /** Sign in with an e-mail and a password. */\n  signIn: '#sign-in',\n  signUp: '#sign-up',\n  google: '#sign-in/google',\n  microsoft: '#sign-in/microsoft',\n};\n\nexport type SsoConnection = {\n  workspace: string;\n  provider: string;\n  /** Where single sign-on starts: your server's SAML endpoint for the connection. */\n  href: string;\n};\n\n/** E-mail domains with single sign-on set up. Your server answers this lookup. */\nexport const SSO_DOMAINS: Record<string, SsoConnection> = {\n  'lumenstudio.co': { workspace: 'Lumen Studio', provider: 'Okta', href: '#sso/lumen-studio' },\n};\n"
    },
    {
      "path": "src/blocks/sso-sign-in/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/sso-sign-in/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { AuthCard } from './auth-card';\nimport { ROUTES } from './data';\nimport { SsoForm } from './sso-form';\n\n/**\n * Single sign-on, Inset direction with no navigation: the sign-in card with Google, Microsoft and a\n * work e-mail for SAML.\n */\nexport default function SsoSignIn() {\n  return (\n    <main className=\"ws-block-utility bg-ws-static-background p-ws-12 flex min-h-dvh items-center justify-center\">\n      <AuthCard\n        other={{ href: ROUTES.signUp, label: 'Create account' }}\n        className=\"w-full max-w-[38.75rem]\"\n      >\n        <SsoForm />\n      </AuthCard>\n    </main>\n  );\n}\n"
    },
    {
      "path": "src/blocks/sso-sign-in/sso-form.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/sso-sign-in/sso-form.tsx",
      "content": "'use client';\n\nimport { RiGoogleFill, RiMicrosoftFill } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Divider } from '@/components/ui/wideset/divider/Divider';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { type FormEvent, useId, useState } from 'react';\n\nimport { TextLink } from './auth-card';\nimport { ROUTES, SSO_DOMAINS } from './data';\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\n/**\n * Signing in through an identity provider. Google and Microsoft are one click each, drawn as\n * secondary buttons; the work e-mail is the one form, and its button is the only filled one. As\n * soon as the address is complete the domain is looked up: a known one names the workspace and its\n * provider under the field and on the button. An unknown domain is an error only on submit.\n */\nexport function SsoForm() {\n  const id = useId();\n  const [email, setEmail] = useState('');\n  const [error, setError] = useState<string>();\n  const value = email.trim();\n  const domain = value.split('@')[1]?.toLowerCase() ?? '';\n  const connection = EMAIL.test(value) ? SSO_DOMAINS[domain] : undefined;\n\n  const submit = (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault();\n    const next = !value\n      ? 'Enter your work e-mail.'\n      : !EMAIL.test(value)\n        ? 'Enter an e-mail like name@company.com.'\n        : connection\n          ? undefined\n          : `No single sign-on is set up for ${domain}. Use Google, Microsoft or a password.`;\n    setError(next);\n    if (next || !connection) {\n      document.getElementById(`${id}-email`)?.focus();\n      return;\n    }\n    window.location.assign(connection.href);\n  };\n\n  return (\n    <div className=\"gap-ws-12 flex w-full flex-col\">\n      <h1 className=\"typography-title-md text-ws-static-strong mb-ws-5\">Sign in to Orbit</h1>\n      <div className=\"gap-ws-5 flex flex-col\">\n        <Button\n          size=\"lg\"\n          variant=\"secondary\"\n          preset=\"border\"\n          className=\"w-full\"\n          onClick={() => window.location.assign(ROUTES.google)}\n        >\n          <Button.Icon icon={RiGoogleFill} />\n          Continue with Google\n        </Button>\n        <Button\n          size=\"lg\"\n          variant=\"secondary\"\n          preset=\"border\"\n          className=\"w-full\"\n          onClick={() => window.location.assign(ROUTES.microsoft)}\n        >\n          <Button.Icon icon={RiMicrosoftFill} />\n          Continue with Microsoft\n        </Button>\n      </div>\n      <Divider text=\"or\" />\n      <form\n        noValidate\n        onSubmit={submit}\n        aria-label=\"Single sign-on\"\n        className=\"gap-ws-12 flex flex-col\"\n      >\n        <FormField\n          label=\"Work e-mail\"\n          htmlFor={`${id}-email`}\n          helperText={\n            connection\n              ? `${connection.workspace} uses ${connection.provider}: continue to sign in.`\n              : 'We’ll find your company’s sign-in page.'\n          }\n          errorText={error}\n        >\n          <TextInput\n            id={`${id}-email`}\n            name=\"email\"\n            type=\"email\"\n            autoComplete=\"email\"\n            autoCapitalize=\"none\"\n            spellCheck={false}\n            placeholder=\"e.g. maya@lumenstudio.co\"\n            required\n            value={email}\n            variant={error ? 'danger' : 'primary'}\n            onChange={(event) => {\n              setEmail(event.target.value);\n              setError(undefined);\n            }}\n          />\n        </FormField>\n        <Button type=\"submit\" size=\"lg\" className=\"w-full\">\n          {connection ? `Continue with ${connection.provider}` : 'Continue with SSO'}\n        </Button>\n      </form>\n      <p className=\"typography-body-md text-ws-static-subtle\">\n        Not using single sign-on? <TextLink href={ROUTES.signIn}>Sign in with a password</TextLink>\n      </p>\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
