{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "app-auth-signin",
  "type": "registry:block",
  "title": "App, sign in",
  "description": "Sign in with email and password, or email and a code (signInWith code, with optional Continue with Google and Continue with Microsoft buttons, each in its provider colour mark): labelled fields with the right autocomplete, a button that shows or hides the password, a forgot link, and idle, sending and error states. Never submits unless the host gives it an action.",
  "categories": [
    "app"
  ],
  "dependencies": [
    "zod@^4.6.5"
  ],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/banner.json",
    "https://ui.klarhimmel.com/r/block-kit.json",
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/input.json",
    "https://ui.klarhimmel.com/r/kit-app.json",
    "https://ui.klarhimmel.com/r/kit-auth.json",
    "https://ui.klarhimmel.com/r/kit-form.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/app-auth-signin/spec.ts",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-auth-signin/spec.ts",
      "content": "import { z } from 'zod';\nimport { defineSpec, formFields, link, req, t } from '../_shared/schema';\n\nconst schema = z.object({\n  /** signInWith password: email and password. code: email only, then a code by email (app-auth-code takes it from there), as Klarhimmel's\n   *  own sign-in does; no password field and no forgot link. */\n  signInWith: z.enum(['password', 'code']).optional(),\n  /** \"Continue with Google\" above the form, then the or line. The host points href at its Google start. */\n  google: link.optional(),\n  /** \"Continue with Microsoft\" under Google (or alone), with Microsoft's four-square mark. The host points href at its Microsoft start. */\n  microsoft: link.optional(),\n  orLabel: t(20).optional(),\n  eyebrow: t(60).optional(),\n  title: t(120),\n  description: t(300).optional(),\n  emailLabel: req(40),\n  passwordLabel: req(40),\n  showLabel: t(30),\n  hideLabel: t(30),\n  forgot: link,\n  submit: t(30),\n  sending: t(30),\n  /** The line under the form: a question and the link that answers it (\"No account yet?\" \"Create one\"). */\n  alternative: z.object({ text: t(80), link }),\n  /** idle, sending (the button waits), error (a banner says what went wrong; the fields are described by it). */\n  state: z.enum(['idle', 'sending', 'error']),\n  messages: z.object({ error: t(160) }),\n  ...formFields,\n});\n\nexport const spec = defineSpec({\n  type: 'app-auth-signin',\n  aliases: ['app/auth-signin'],\n  name: 'App, sign in',\n  category: 'app',\n  role: 'body',\n  description: 'Sign in with email and password, or email and a code (signInWith code, with optional Continue with Google and Continue with Microsoft buttons, each in its provider colour mark): labelled fields with the right autocomplete, a button that shows or hides the password, a forgot link, and idle, sending and error states. Never submits unless the host gives it an action.',\n  schema,\n  defaults: {\n    \"eyebrow\": \"Name the section\",\n    \"google\": {\n      \"label\": \"Continue with a provider\",\n      \"href\": \"#google\"\n    },\n    \"microsoft\": {\n      \"label\": \"Continue with another\",\n      \"href\": \"#microsoft\"\n    },\n    \"orLabel\": \"or\",\n    \"title\": \"Sign in\",\n    \"description\": \"Say which details to use to get in.\",\n    \"emailLabel\": \"Email address\",\n    \"passwordLabel\": \"Password\",\n    \"showLabel\": \"Show password\",\n    \"hideLabel\": \"Hide password\",\n    \"forgot\": {\n      \"label\": \"Forgot your password?\",\n      \"href\": \"#reset\"\n    },\n    \"submit\": \"Sign in\",\n    \"sending\": \"Signing in…\",\n    \"alternative\": {\n      \"text\": \"No account yet?\",\n      \"link\": {\n        \"label\": \"Create one\",\n        \"href\": \"#sign-up\"\n      }\n    },\n    \"state\": \"idle\",\n    \"messages\": {\n      \"error\": \"Say that the details do not match and to check them.\"\n    }\n  },\n});\n"
    },
    {
      "path": "src/blocks/app-auth-signin/index.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/blocks/app-auth-signin/index.tsx",
      "content": "import { useId } from 'react';\nimport { cn } from '../../lib/utils';\nimport { Text, withHeadingLevel } from '../../editing';\nimport { Banner } from '../../ui/banner';\nimport { Button, buttonClass } from '../../ui/button';\nimport { Input } from '../../ui/input';\nimport { Container, Section, SectionHeader } from '../_shared/kit';\nimport { AppPanel, StateSlot, Swap } from '../_shared/app-kit';\nimport { FieldRow, LabelLink, PasswordInput, describedBy } from '../_shared/auth-kit';\nimport { FormExtras, useFormProps } from '../_shared/form-kit';\nimport { spec } from './spec';\nimport type { BlockProps } from '../types';\nimport type { z } from 'zod';\n\nexport { spec };\ntype Props = z.infer<typeof spec.schema>;\n\n// The providers' own marks in full colour, as their brand guidelines ask (Felix 10-25 14:1x: \"login pages should use the microsoft and\n// google logotypes in color to increase brand awareness and trust\"): Google's G at 18 px, Microsoft's four squares at 21 px, the same\n// in light and dark, never recoloured, with 12 px of clear space before the label. Their colours live in theme CSS, never in a block.\nconst GoogleMark = () => (\n  <svg aria-hidden viewBox=\"0 0 48 48\" className=\"kh-google-g size-[18px] shrink-0\">\n    <path d=\"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z\" />\n    <path d=\"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z\" />\n    <path d=\"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z\" />\n    <path d=\"M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z\" />\n  </svg>\n);\nconst MicrosoftMark = () => (\n  <svg aria-hidden viewBox=\"0 0 21 21\" className=\"kh-microsoft-mark size-[21px] shrink-0\">\n    <rect x=\"1\" y=\"1\" width=\"9\" height=\"9\" />\n    <rect x=\"11\" y=\"1\" width=\"9\" height=\"9\" />\n    <rect x=\"1\" y=\"11\" width=\"9\" height=\"9\" />\n    <rect x=\"11\" y=\"11\" width=\"9\" height=\"9\" />\n  </svg>\n);\n/** One provider button: the mark, then the label, 12 px apart. */\nfunction Provider({ link, path, mark }: { link: { label: string; href: string }; path: string; mark: React.ReactNode }) {\n  return (\n    <a href={link.href} className={cn(buttonClass('secondary', 'lg', true), 'gap-3')}>\n      {mark}\n      <Text path={[path, 'label']} value={link.label} as=\"span\" />\n    </a>\n  );\n}\n\nfunction AppAuthSignin({ props }: BlockProps<Props>) {\n  const id = useId();\n  const form = useFormProps(props);\n  const { state } = props;\n  const code = props.signInWith === 'code';\n  const failed = state === 'error';\n  const by = failed ? `${id}-alert` : undefined;\n  const google = !!(props.google?.href && props.google.label.trim());\n  const microsoft = !!(props.microsoft?.href && props.microsoft.label.trim());\n  return (\n    <Section labelledBy={id}>\n      <Container width=\"narrow\" className=\"max-w-md\">\n        <SectionHeader id={id} eyebrow={props.eyebrow} title={props.title} description={props.description} />\n        <AppPanel className=\"mt-8\">\n          {(google || microsoft) && (\n            <div className=\"flex flex-col gap-3 px-6 pt-6 @xl:px-8 @xl:pt-8\">\n              {google && <Provider link={props.google!} path=\"google\" mark={<GoogleMark />} />}\n              {microsoft && <Provider link={props.microsoft!} path=\"microsoft\" mark={<MicrosoftMark />} />}\n              {(props.orLabel ?? 'or').trim() ? <p className=\"mt-2 text-center text-kh-small text-kh-muted\"><Text path={['orLabel']} value={props.orLabel ?? 'or'} as=\"span\" /></p> : <div className=\"mt-2\" />}\n            </div>\n          )}\n          <form {...form} aria-busy={state === 'sending' || undefined} className=\"p-6 @xl:p-8\">\n            <fieldset disabled={state === 'sending'} className=\"m-0 flex min-w-0 flex-col gap-5 border-0 p-0\">\n            <StateSlot show={failed}>\n              <div id={by}>\n                <Banner tone=\"error\">\n                  <Text path={['messages', 'error']} value={props.messages.error} as=\"span\" />\n                </Banner>\n              </div>\n            </StateSlot>\n            <FieldRow id={`${id}-m`} label={<Text path={['emailLabel']} value={props.emailLabel} as=\"span\" />}>\n              <Input id={`${id}-m`} name=\"email\" type=\"email\" inputMode=\"email\" autoComplete={code ? 'email' : 'username'} autoCapitalize=\"none\" spellCheck={false} required aria-invalid={failed || undefined} aria-describedby={by} />\n            </FieldRow>\n            {!code && (\n              <>\n                <FieldRow id={`${id}-p`} label={<Text path={['passwordLabel']} value={props.passwordLabel} as=\"span\" />}>\n                  <PasswordInput id={`${id}-p`} name=\"password\" autoComplete=\"current-password\" showLabel={props.showLabel} hideLabel={props.hideLabel} showPath={['showLabel']} hidePath={['hideLabel']} invalid={failed} describedby={describedBy(`${id}-p`, false, false) ?? by} required />\n                </FieldRow>\n                <p className=\"text-kh-small\">\n                  <LabelLink path={['forgot']} link={props.forgot} />\n                </p>\n              </>\n            )}\n            <FormExtras {...props} />\n            <Button type=\"submit\" full disabled={state === 'sending'}>\n              <Swap show={state !== 'sending'}>\n                <Text path={['submit']} value={props.submit} as=\"span\" />\n              </Swap>\n              <Swap show={state === 'sending'}>\n                <Text path={['sending']} value={props.sending} as=\"span\" />\n              </Swap>\n            </Button>\n            </fieldset>\n          </form>\n        </AppPanel>\n        <p className=\"mt-6 text-center text-kh-small text-kh-muted\">\n          <Text path={['alternative', 'text']} value={props.alternative.text} as=\"span\" />{' '}\n          <LabelLink path={['alternative', 'link']} link={props.alternative.link} />\n        </p>\n      </Container>\n    </Section>\n  );\n}\n\nexport default withHeadingLevel(AppAuthSignin);\n"
    }
  ]
}
