@nswds/ui 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/badge.d.ts +3 -1
- package/dist/components/badge.js +1 -0
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.d.ts +3 -1
- package/dist/components/button.js +1 -0
- package/dist/components/button.js.map +1 -1
- package/dist/components/card.d.ts +8 -8
- package/dist/components/card.js +6 -6
- package/dist/components/card.js.map +1 -1
- package/dist/components/field.d.ts +12 -12
- package/dist/components/field.js +7 -7
- package/dist/components/field.js.map +1 -1
- package/dist/components/forgot-password-form.d.ts +18 -0
- package/dist/components/forgot-password-form.js +44 -0
- package/dist/components/forgot-password-form.js.map +1 -0
- package/dist/components/label.d.ts +1 -1
- package/dist/components/label.js +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/labeled-separator.d.ts +19 -0
- package/dist/components/labeled-separator.js +34 -0
- package/dist/components/labeled-separator.js.map +1 -0
- package/dist/components/link.d.ts +45 -10
- package/dist/components/link.js +120 -4
- package/dist/components/link.js.map +1 -1
- package/dist/components/login-form.d.ts +1 -1
- package/dist/components/login-form.js +31 -22
- package/dist/components/login-form.js.map +1 -1
- package/dist/components/separator.d.ts +11 -2
- package/dist/components/separator.js +21 -9
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sign-up-form.d.ts +25 -0
- package/dist/components/sign-up-form.js +110 -0
- package/dist/components/sign-up-form.js.map +1 -0
- package/dist/components/spinner.d.ts +7 -1
- package/dist/components/spinner.js +13 -2
- package/dist/components/spinner.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { Button } from '../components/button.js';
|
|
4
|
+
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '../components/card.js';
|
|
5
|
+
import { FieldGroup, Field, FieldLabel, FieldDescription } from '../components/field.js';
|
|
6
|
+
import { Input } from '../components/input.js';
|
|
7
|
+
import { Link } from '../components/link.js';
|
|
8
|
+
import { cn } from '../lib/utils.js';
|
|
9
|
+
|
|
10
|
+
function ForgotPasswordForm({
|
|
11
|
+
className,
|
|
12
|
+
...props
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-6", className), ...props, children: /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
15
|
+
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
16
|
+
/* @__PURE__ */ jsx(CardTitle, { children: "Forgot your password?" }),
|
|
17
|
+
/* @__PURE__ */ jsx(CardDescription, { children: "Enter the email address for your account and we'll send you a link to reset your password." })
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("form", { children: /* @__PURE__ */ jsxs(FieldGroup, { children: [
|
|
20
|
+
/* @__PURE__ */ jsxs(Field, { children: [
|
|
21
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: "email", children: "Email" }),
|
|
22
|
+
/* @__PURE__ */ jsx(
|
|
23
|
+
Input,
|
|
24
|
+
{
|
|
25
|
+
id: "email",
|
|
26
|
+
type: "email",
|
|
27
|
+
autoComplete: "email",
|
|
28
|
+
placeholder: "m@example.com",
|
|
29
|
+
required: true
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsx(Button, { type: "submit", children: "Send reset link" }) }),
|
|
34
|
+
/* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsxs(FieldDescription, { className: "text-center", children: [
|
|
35
|
+
"Remembered your password? ",
|
|
36
|
+
/* @__PURE__ */ jsx(Link, { href: "#", children: "Back to login" })
|
|
37
|
+
] }) })
|
|
38
|
+
] }) }) })
|
|
39
|
+
] }) });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { ForgotPasswordForm };
|
|
43
|
+
//# sourceMappingURL=forgot-password-form.js.map
|
|
44
|
+
//# sourceMappingURL=forgot-password-form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/forgot-password-form.tsx"],"names":[],"mappings":";;;;;;;;AAkCO,SAAS,kBAAA,CAAmB;AAAA,EACjC,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAgC;AAC9B,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAW,EAAA,CAAG,qBAAA,EAAuB,SAAS,CAAA,EAAI,GAAG,KAAA,EACxD,QAAA,kBAAA,IAAA,CAAC,IAAA,EAAA,EAAK,SAAA,EAAU,QAAA,EACd,QAAA,EAAA;AAAA,oBAAA,IAAA,CAAC,UAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,GAAA,CAAC,aAAU,QAAA,EAAA,uBAAA,EAAqB,CAAA;AAAA,sBAChC,GAAA,CAAC,mBAAgB,QAAA,EAAA,4FAAA,EAGjB;AAAA,KAAA,EACF,CAAA;AAAA,oBACA,GAAA,CAAC,WAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EACC,+BAAC,UAAA,EAAA,EACC,QAAA,EAAA;AAAA,sBAAA,IAAA,CAAC,KAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,UAAA,EAAA,EAAW,OAAA,EAAQ,OAAA,EAAQ,QAAA,EAAA,OAAA,EAAK,CAAA;AAAA,wBACjC,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,EAAA,EAAG,OAAA;AAAA,YACH,IAAA,EAAK,OAAA;AAAA,YACL,YAAA,EAAa,OAAA;AAAA,YACb,WAAA,EAAY,eAAA;AAAA,YACZ,QAAA,EAAQ;AAAA;AAAA;AACV,OAAA,EACF,CAAA;AAAA,0BACC,KAAA,EAAA,EACC,QAAA,kBAAA,GAAA,CAAC,UAAO,IAAA,EAAK,QAAA,EAAS,6BAAe,CAAA,EACvC,CAAA;AAAA,sBACA,GAAA,CAAC,KAAA,EAAA,EACC,QAAA,kBAAA,IAAA,CAAC,gBAAA,EAAA,EAAiB,WAAU,aAAA,EAAc,QAAA,EAAA;AAAA,QAAA,4BAAA;AAAA,wBACd,GAAA,CAAC,IAAA,EAAA,EAAK,IAAA,EAAK,GAAA,EAAI,QAAA,EAAA,eAAA,EAAa;AAAA,OAAA,EACxD,CAAA,EACF;AAAA,KAAA,EACF,GACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ","file":"forgot-password-form.js","sourcesContent":["'use client'\n\nimport type * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '../components/card.js'\nimport {\n Field,\n FieldDescription,\n FieldGroup,\n FieldLabel,\n} from '../components/field.js'\nimport { Input } from '../components/input.js'\nimport { Link } from '../components/link.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * ForgotPasswordForm — the password-reset request step that pairs with the\n * \"Forgot your password?\" link in LoginForm.\n *\n * A composed pattern (Card + Field + Input + Button), published as a worked\n * example: copy the source and wire the single email field to your own reset\n * handler rather than configuring it through props.\n *\n * Single-field by design. The flow is intentionally minimal — collect the\n * email, send the reset link, and (for account-enumeration safety) show the\n * same confirmation whether or not the address is registered.\n */\nexport function ForgotPasswordForm({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div className={cn('flex flex-col gap-6', className)} {...props}>\n <Card className=\"w-full\">\n <CardHeader>\n <CardTitle>Forgot your password?</CardTitle>\n <CardDescription>\n Enter the email address for your account and we'll send you a\n link to reset your password.\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form>\n <FieldGroup>\n <Field>\n <FieldLabel htmlFor=\"email\">Email</FieldLabel>\n <Input\n id=\"email\"\n type=\"email\"\n autoComplete=\"email\"\n placeholder=\"m@example.com\"\n required\n />\n </Field>\n <Field>\n <Button type=\"submit\">Send reset link</Button>\n </Field>\n <Field>\n <FieldDescription className=\"text-center\">\n Remembered your password? <Link href=\"#\">Back to login</Link>\n </FieldDescription>\n </Field>\n </FieldGroup>\n </form>\n </CardContent>\n </Card>\n </div>\n )\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
declare function Label({ className, ...props }: React.ComponentProps<
|
|
4
|
+
declare function Label({ className, ...props }: React.ComponentProps<'label'>): react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
|
6
6
|
export { Label };
|
package/dist/components/label.js
CHANGED
|
@@ -8,7 +8,7 @@ function Label({ className, ...props }) {
|
|
|
8
8
|
{
|
|
9
9
|
"data-slot": "label",
|
|
10
10
|
className: cn(
|
|
11
|
-
"flex items-center gap-2 text-
|
|
11
|
+
"flex items-center gap-2 text-base/relaxed font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
12
12
|
className
|
|
13
13
|
),
|
|
14
14
|
...props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/label.tsx"],"names":[],"mappings":";;;AAMA,SAAS,KAAA,CAAM,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AACrE,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,OAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,
|
|
1
|
+
{"version":3,"sources":["../../src/components/label.tsx"],"names":[],"mappings":";;;AAMA,SAAS,KAAA,CAAM,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AACrE,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,OAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,kNAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"label.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Label({ className, ...props }: React.ComponentProps<'label'>) {\n return (\n <label\n data-slot=\"label\"\n className={cn(\n 'flex items-center gap-2 text-base/relaxed font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50',\n className\n )}\n {...props}\n />\n )\n}\n\nexport { Label }\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A horizontal divider broken by a centred label — e.g. the "or" rule that
|
|
6
|
+
* separates one sign-in method from another in a login form.
|
|
7
|
+
*
|
|
8
|
+
* Always renders a label (defaulting to "or"); it is not a plain horizontal
|
|
9
|
+
* rule. For an unbroken divider, use the `Separator` component instead.
|
|
10
|
+
*
|
|
11
|
+
* The two flanking rules are rendered `decorative` (role="none") because the
|
|
12
|
+
* visible label already conveys the boundary to assistive tech; exposing two
|
|
13
|
+
* `role="separator"` elements either side of it would be redundant noise.
|
|
14
|
+
*/
|
|
15
|
+
declare function LabeledSeparator({ className, children, ...props }: React.ComponentProps<'div'> & {
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
}): react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { LabeledSeparator };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Separator } from '../components/separator.js';
|
|
3
|
+
import { cn } from '../lib/utils.js';
|
|
4
|
+
|
|
5
|
+
function LabeledSeparator({
|
|
6
|
+
className,
|
|
7
|
+
children = "or",
|
|
8
|
+
...props
|
|
9
|
+
}) {
|
|
10
|
+
return /* @__PURE__ */ jsxs(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
"data-slot": "labeled-separator",
|
|
14
|
+
className: cn("flex items-center gap-3", className),
|
|
15
|
+
...props,
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ jsx(Separator, { decorative: true, className: "flex-1" }),
|
|
18
|
+
/* @__PURE__ */ jsx(
|
|
19
|
+
"span",
|
|
20
|
+
{
|
|
21
|
+
"data-slot": "labeled-separator-content",
|
|
22
|
+
className: "shrink-0 text-sm text-muted-foreground",
|
|
23
|
+
children
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ jsx(Separator, { decorative: true, className: "flex-1" })
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { LabeledSeparator };
|
|
33
|
+
//# sourceMappingURL=labeled-separator.js.map
|
|
34
|
+
//# sourceMappingURL=labeled-separator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/labeled-separator.tsx"],"names":[],"mappings":";;;;AAgBA,SAAS,gBAAA,CAAiB;AAAA,EACxB,SAAA;AAAA,EACA,QAAA,GAAW,IAAA;AAAA,EACX,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,mBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yBAAA,EAA2B,SAAS,CAAA;AAAA,MACjD,GAAG,KAAA;AAAA,MAEJ,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,SAAA,EAAA,EAAU,UAAA,EAAU,IAAA,EAAC,SAAA,EAAU,QAAA,EAAS,CAAA;AAAA,wBACzC,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,WAAA,EAAU,2BAAA;AAAA,YACV,SAAA,EAAU,wCAAA;AAAA,YAET;AAAA;AAAA,SACH;AAAA,wBACA,GAAA,CAAC,SAAA,EAAA,EAAU,UAAA,EAAU,IAAA,EAAC,WAAU,QAAA,EAAS;AAAA;AAAA;AAAA,GAC3C;AAEJ","file":"labeled-separator.js","sourcesContent":["import type * as React from 'react'\n\nimport { Separator } from '../components/separator.js'\nimport { cn } from '../lib/utils.js'\n\n/**\n * A horizontal divider broken by a centred label — e.g. the \"or\" rule that\n * separates one sign-in method from another in a login form.\n *\n * Always renders a label (defaulting to \"or\"); it is not a plain horizontal\n * rule. For an unbroken divider, use the `Separator` component instead.\n *\n * The two flanking rules are rendered `decorative` (role=\"none\") because the\n * visible label already conveys the boundary to assistive tech; exposing two\n * `role=\"separator\"` elements either side of it would be redundant noise.\n */\nfunction LabeledSeparator({\n className,\n children = 'or',\n ...props\n}: React.ComponentProps<'div'> & { children?: React.ReactNode }) {\n return (\n <div\n data-slot=\"labeled-separator\"\n className={cn('flex items-center gap-3', className)}\n {...props}\n >\n <Separator decorative className=\"flex-1\" />\n <span\n data-slot=\"labeled-separator-content\"\n className=\"shrink-0 text-sm text-muted-foreground\"\n >\n {children}\n </span>\n <Separator decorative className=\"flex-1\" />\n </div>\n )\n}\n\nexport { LabeledSeparator }\n"]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
3
|
+
import { VariantProps } from 'class-variance-authority';
|
|
2
4
|
import React__default from 'react';
|
|
3
5
|
|
|
6
|
+
declare const linkVariants: (props?: ({
|
|
7
|
+
variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
|
|
8
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
4
9
|
type LinkComponent = React__default.ElementType;
|
|
5
|
-
type LinkProps = Omit<React__default.ComponentPropsWithoutRef<'a'>, 'href'> & {
|
|
10
|
+
type LinkProps = Omit<React__default.ComponentPropsWithoutRef<'a'>, 'href'> & VariantProps<typeof linkVariants> & {
|
|
6
11
|
as?: LinkComponent;
|
|
7
12
|
href: React__default.ComponentPropsWithoutRef<'a'>['href'] | object;
|
|
8
13
|
};
|
|
@@ -10,19 +15,49 @@ declare function LinkProvider({ children, component, }: {
|
|
|
10
15
|
children: React__default.ReactNode;
|
|
11
16
|
component: LinkComponent;
|
|
12
17
|
}): react_jsx_runtime.JSX.Element;
|
|
18
|
+
declare const Link: React__default.ForwardRefExoticComponent<Omit<Omit<React__default.DetailedHTMLProps<React__default.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref">, "href"> & VariantProps<(props?: ({
|
|
19
|
+
variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
|
|
20
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
21
|
+
as?: LinkComponent;
|
|
22
|
+
href: React__default.ComponentPropsWithoutRef<"a">["href"] | object;
|
|
23
|
+
} & React__default.RefAttributes<HTMLAnchorElement>>;
|
|
24
|
+
type ExternalLinkProps = LinkProps & {
|
|
25
|
+
/**
|
|
26
|
+
* Screen-reader suffix announced after the link text. Defaults to
|
|
27
|
+
* `"(opens in a new tab)"`. Pass an empty string to suppress.
|
|
28
|
+
*/
|
|
29
|
+
newTabLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Custom trailing icon. Pass `null` to hide the icon entirely. If omitted,
|
|
32
|
+
* the default open-in-new glyph is rendered.
|
|
33
|
+
*/
|
|
34
|
+
icon?: React__default.ReactNode | null;
|
|
35
|
+
};
|
|
13
36
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
37
|
+
* Anchor preconfigured for cross-origin / new-tab navigation. Sets
|
|
38
|
+
* `target="_blank"` and `rel="noopener noreferrer"` by default, renders a
|
|
39
|
+
* trailing open-in-new icon, and appends a visually-hidden suffix so screen
|
|
40
|
+
* readers announce that the link opens a new tab.
|
|
17
41
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* `group-…` variants) — Tailwind v4 maps them to real CSS, no JS state
|
|
21
|
-
* tracking required.
|
|
42
|
+
* All `Link` props are forwarded — `variant`, `as`, `className`, etc. —
|
|
43
|
+
* and any of `target`, `rel`, `icon`, or `newTabLabel` can be overridden.
|
|
22
44
|
*/
|
|
23
|
-
declare const
|
|
45
|
+
declare const ExternalLink: React__default.ForwardRefExoticComponent<Omit<Omit<React__default.DetailedHTMLProps<React__default.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref">, "href"> & VariantProps<(props?: ({
|
|
46
|
+
variant?: "white" | "primary" | "secondary" | "unstyled" | null | undefined;
|
|
47
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string> & {
|
|
24
48
|
as?: LinkComponent;
|
|
25
49
|
href: React__default.ComponentPropsWithoutRef<"a">["href"] | object;
|
|
50
|
+
} & {
|
|
51
|
+
/**
|
|
52
|
+
* Screen-reader suffix announced after the link text. Defaults to
|
|
53
|
+
* `"(opens in a new tab)"`. Pass an empty string to suppress.
|
|
54
|
+
*/
|
|
55
|
+
newTabLabel?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Custom trailing icon. Pass `null` to hide the icon entirely. If omitted,
|
|
58
|
+
* the default open-in-new glyph is rendered.
|
|
59
|
+
*/
|
|
60
|
+
icon?: React__default.ReactNode | null;
|
|
26
61
|
} & React__default.RefAttributes<HTMLAnchorElement>>;
|
|
27
62
|
|
|
28
|
-
export { Link, type LinkComponent, type LinkProps, LinkProvider };
|
|
63
|
+
export { ExternalLink, type ExternalLinkProps, Link, type LinkComponent, type LinkProps, LinkProvider, linkVariants };
|
package/dist/components/link.js
CHANGED
|
@@ -1,7 +1,71 @@
|
|
|
1
1
|
"use client"
|
|
2
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
3
4
|
import React, { createContext, forwardRef, useContext } from 'react';
|
|
5
|
+
import { cn } from '../lib/utils.js';
|
|
4
6
|
|
|
7
|
+
const styledBase = [
|
|
8
|
+
// Typography + transition
|
|
9
|
+
"font-medium underline decoration-current underline-offset-4 transition-colors",
|
|
10
|
+
// Text colour derives from --link-color; --link-halo and --link-halo-active
|
|
11
|
+
// derive from --link-color via color-mix so each variant only sets the one
|
|
12
|
+
// token and the hover/active halos follow automatically.
|
|
13
|
+
"text-(--link-color)",
|
|
14
|
+
"[--link-halo:color-mix(in_oklch,var(--link-color)_10%,transparent)]",
|
|
15
|
+
"[--link-halo-active:color-mix(in_oklch,var(--link-color)_18%,transparent)]",
|
|
16
|
+
// Hover / active halos use box-shadow + background-color rather than
|
|
17
|
+
// padding, so inline links sit flush against surrounding text. The
|
|
18
|
+
// shadows extend the halo 2px above and 4px below the line box, matching
|
|
19
|
+
// the GOV.UK Design System focus pattern.
|
|
20
|
+
"hover:bg-(--link-halo) hover:decoration-2",
|
|
21
|
+
"hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]",
|
|
22
|
+
// Wrapped lines each get their own halo
|
|
23
|
+
"[box-decoration-break:clone] [-webkit-box-decoration-break:clone]",
|
|
24
|
+
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--link-color)",
|
|
25
|
+
// Default sizing for icon children — without this, an unsized SVG inside
|
|
26
|
+
// a Link collapses to 0×0 in flex layouts. `vertical-align: -0.15em`
|
|
27
|
+
// aligns the icon's box to the text's x-height for inline-flow usage;
|
|
28
|
+
// flex contexts ignore vertical-align and should set `items-baseline` (or
|
|
29
|
+
// similar) on the Link itself. Consumers can override per-icon by passing
|
|
30
|
+
// a `size-*` or `align-*` class on the icon itself.
|
|
31
|
+
"*:data-[slot=icon]:inline-block *:data-[slot=icon]:size-[1em] *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:align-[-0.15em]"
|
|
32
|
+
];
|
|
33
|
+
const linkVariants = cva("", {
|
|
34
|
+
variants: {
|
|
35
|
+
variant: {
|
|
36
|
+
primary: [
|
|
37
|
+
...styledBase,
|
|
38
|
+
// Link
|
|
39
|
+
"[--link-color:var(--color-primary-800)] dark:[--link-color:var(--color-primary-200)]",
|
|
40
|
+
// Visited — set the text colour directly. `:visited` is restricted by
|
|
41
|
+
// browsers to a small set of paint-only properties (color, *-color,
|
|
42
|
+
// fill, stroke) and ignores custom properties, so we can't shift
|
|
43
|
+
// --link-color here. Setting `text-*` works, and the underline follows
|
|
44
|
+
// because the base uses `decoration-current` (currentColor).
|
|
45
|
+
"visited:text-primary-600 dark:visited:text-primary-300",
|
|
46
|
+
// Active — deeper halo via --link-halo-active
|
|
47
|
+
"active:bg-(--link-halo-active) active:decoration-2",
|
|
48
|
+
"active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]"
|
|
49
|
+
],
|
|
50
|
+
secondary: [
|
|
51
|
+
...styledBase,
|
|
52
|
+
"[--link-color:var(--color-primary-200)] dark:[--link-color:var(--color-primary-800)]"
|
|
53
|
+
],
|
|
54
|
+
white: [
|
|
55
|
+
...styledBase,
|
|
56
|
+
"[--link-color:var(--color-white)] dark:[--link-color:var(--color-grey-800)]"
|
|
57
|
+
],
|
|
58
|
+
// Zero classes — the consumer (typically Button / BadgeButton) is
|
|
59
|
+
// supplying its own complete visual treatment and doesn't want any
|
|
60
|
+
// Link styling to compose on top. Intentionally omits the icon defaults
|
|
61
|
+
// too, so the wrapping component has full control of icon sizing.
|
|
62
|
+
unstyled: []
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
defaultVariants: {
|
|
66
|
+
variant: "primary"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
5
69
|
const LinkComponentContext = createContext(null);
|
|
6
70
|
function LinkProvider({
|
|
7
71
|
children,
|
|
@@ -9,12 +73,64 @@ function LinkProvider({
|
|
|
9
73
|
}) {
|
|
10
74
|
return /* @__PURE__ */ jsx(LinkComponentContext.Provider, { value: component, children });
|
|
11
75
|
}
|
|
12
|
-
const
|
|
76
|
+
const ANCHOR_ONLY_PROPS = [
|
|
77
|
+
"href",
|
|
78
|
+
"target",
|
|
79
|
+
"rel",
|
|
80
|
+
"download",
|
|
81
|
+
"ping",
|
|
82
|
+
"referrerPolicy",
|
|
83
|
+
"hrefLang",
|
|
84
|
+
"type"
|
|
85
|
+
];
|
|
86
|
+
const Link = forwardRef(function Link2({ as, variant, className, ...props }, ref) {
|
|
13
87
|
const ContextLink = useContext(LinkComponentContext);
|
|
14
88
|
const component = as ?? ContextLink ?? "a";
|
|
15
|
-
|
|
89
|
+
const isNonAnchorIntrinsic = typeof component === "string" && component !== "a";
|
|
90
|
+
const elementProps = { ...props };
|
|
91
|
+
if (isNonAnchorIntrinsic) {
|
|
92
|
+
for (const prop of ANCHOR_ONLY_PROPS) {
|
|
93
|
+
delete elementProps[prop];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return React.createElement(component, {
|
|
97
|
+
...elementProps,
|
|
98
|
+
className: cn(linkVariants({ variant }), className),
|
|
99
|
+
ref
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
function OpenInNewIcon(props) {
|
|
103
|
+
return /* @__PURE__ */ jsx(
|
|
104
|
+
"svg",
|
|
105
|
+
{
|
|
106
|
+
"data-slot": "icon",
|
|
107
|
+
fill: "currentColor",
|
|
108
|
+
viewBox: "0 -960 960 960",
|
|
109
|
+
"aria-hidden": "true",
|
|
110
|
+
...props,
|
|
111
|
+
children: /* @__PURE__ */ jsx("path", { d: "M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h240q17 0 28.5 11.5T480-800q0 17-11.5 28.5T440-760H200v560h560v-240q0-17 11.5-28.5T800-480q17 0 28.5 11.5T840-440v240q0 33-23.5 56.5T760-120H200Zm560-584L416-360q-11 11-28 11t-28-11q-11-11-11-28t11-28l344-344H600q-17 0-28.5-11.5T560-800q0-17 11.5-28.5T600-840h200q17 0 28.5 11.5T840-800v200q0 17-11.5 28.5T800-560q-17 0-28.5-11.5T760-600v-104Z" })
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const ExternalLink = forwardRef(function ExternalLink2({
|
|
116
|
+
children,
|
|
117
|
+
icon,
|
|
118
|
+
newTabLabel = "(opens in a new tab)",
|
|
119
|
+
target = "_blank",
|
|
120
|
+
rel = "noopener noreferrer",
|
|
121
|
+
...props
|
|
122
|
+
}, ref) {
|
|
123
|
+
const trailingIcon = icon === null ? null : icon ?? /* @__PURE__ */ jsx(OpenInNewIcon, { className: "ml-0.5" });
|
|
124
|
+
return /* @__PURE__ */ jsxs(Link, { ...props, target, rel, ref, children: [
|
|
125
|
+
children,
|
|
126
|
+
trailingIcon,
|
|
127
|
+
newTabLabel ? /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
|
|
128
|
+
" ",
|
|
129
|
+
newTabLabel
|
|
130
|
+
] }) : null
|
|
131
|
+
] });
|
|
16
132
|
});
|
|
17
133
|
|
|
18
|
-
export { Link, LinkProvider };
|
|
134
|
+
export { ExternalLink, Link, LinkProvider, linkVariants };
|
|
19
135
|
//# sourceMappingURL=link.js.map
|
|
20
136
|
//# sourceMappingURL=link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/link.tsx"],"names":["Link"],"mappings":";;;AAWA,MAAM,oBAAA,GAAuB,cAAoC,IAAI,CAAA;AAErE,SAAS,YAAA,CAAa;AAAA,EACpB,QAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,2BACG,oBAAA,CAAqB,QAAA,EAArB,EAA8B,KAAA,EAAO,WACnC,QAAA,EACH,CAAA;AAEJ;AAYA,MAAM,IAAA,GAAO,WAAW,SAASA,KAAAA,CAC/B,EAAE,EAAA,EAAI,GAAG,KAAA,EAAM,EACf,GAAA,EACA;AACA,EAAA,MAAM,WAAA,GAAc,WAAW,oBAAoB,CAAA;AACnD,EAAA,MAAM,SAAA,GAAY,MAAM,WAAA,IAAe,GAAA;AAEvC,EAAA,OAAO,MAAM,aAAA,CAAc,SAAA,EAAW,EAAE,GAAG,KAAA,EAAO,KAAK,CAAA;AACzD,CAAC","file":"link.js","sourcesContent":["'use client'\n\nimport React, { createContext, forwardRef, useContext } from 'react'\n\ntype LinkComponent = React.ElementType\n\ntype LinkProps = Omit<React.ComponentPropsWithoutRef<'a'>, 'href'> & {\n as?: LinkComponent\n href: React.ComponentPropsWithoutRef<'a'>['href'] | object\n}\n\nconst LinkComponentContext = createContext<LinkComponent | null>(null)\n\nfunction LinkProvider({\n children,\n component,\n}: {\n children: React.ReactNode\n component: LinkComponent\n}) {\n return (\n <LinkComponentContext.Provider value={component}>\n {children}\n </LinkComponentContext.Provider>\n )\n}\n\n/**\n * Polymorphic anchor wrapper. Renders an `<a>` by default, or any element\n * provided via the `as` prop, or via a `<LinkProvider component={…}>` context\n * (use the context to inject a framework Link like Next.js `next/link`).\n *\n * Hover / active / focus styling on consumers should use the native CSS\n * pseudo-class utilities (`hover:`, `active:`, `focus-visible:`, and their\n * `group-…` variants) — Tailwind v4 maps them to real CSS, no JS state\n * tracking required.\n */\nconst Link = forwardRef(function Link(\n { as, ...props }: LinkProps,\n ref: React.ForwardedRef<HTMLAnchorElement>\n) {\n const ContextLink = useContext(LinkComponentContext)\n const component = as ?? ContextLink ?? 'a'\n\n return React.createElement(component, { ...props, ref })\n})\n\nexport { Link, LinkProvider }\nexport type { LinkComponent, LinkProps }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/link.tsx"],"names":["Link","ExternalLink"],"mappings":"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","file":"link.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React, { createContext, forwardRef, useContext } from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n// Shared visual base for all *styled* variants. Pulled out so the `unstyled`\n// variant can omit it entirely (otherwise it wouldn't actually be unstyled).\nconst styledBase = [\n // Typography + transition\n 'font-medium underline decoration-current underline-offset-4 transition-colors',\n // Text colour derives from --link-color; --link-halo and --link-halo-active\n // derive from --link-color via color-mix so each variant only sets the one\n // token and the hover/active halos follow automatically.\n 'text-(--link-color)',\n '[--link-halo:color-mix(in_oklch,var(--link-color)_10%,transparent)]',\n '[--link-halo-active:color-mix(in_oklch,var(--link-color)_18%,transparent)]',\n // Hover / active halos use box-shadow + background-color rather than\n // padding, so inline links sit flush against surrounding text. The\n // shadows extend the halo 2px above and 4px below the line box, matching\n // the GOV.UK Design System focus pattern.\n 'hover:bg-(--link-halo) hover:decoration-2',\n 'hover:shadow-[0_-2px_0_var(--link-halo),0_4px_0_var(--link-halo)]',\n // Wrapped lines each get their own halo\n '[box-decoration-break:clone] [-webkit-box-decoration-break:clone]',\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--link-color)',\n // Default sizing for icon children — without this, an unsized SVG inside\n // a Link collapses to 0×0 in flex layouts. `vertical-align: -0.15em`\n // aligns the icon's box to the text's x-height for inline-flow usage;\n // flex contexts ignore vertical-align and should set `items-baseline` (or\n // similar) on the Link itself. Consumers can override per-icon by passing\n // a `size-*` or `align-*` class on the icon itself.\n '*:data-[slot=icon]:inline-block *:data-[slot=icon]:size-[1em] *:data-[slot=icon]:shrink-0 *:data-[slot=icon]:align-[-0.15em]',\n]\n\nconst linkVariants = cva('', {\n variants: {\n variant: {\n primary: [\n ...styledBase,\n // Link\n '[--link-color:var(--color-primary-800)] dark:[--link-color:var(--color-primary-200)]',\n // Visited — set the text colour directly. `:visited` is restricted by\n // browsers to a small set of paint-only properties (color, *-color,\n // fill, stroke) and ignores custom properties, so we can't shift\n // --link-color here. Setting `text-*` works, and the underline follows\n // because the base uses `decoration-current` (currentColor).\n 'visited:text-primary-600 dark:visited:text-primary-300',\n // Active — deeper halo via --link-halo-active\n 'active:bg-(--link-halo-active) active:decoration-2',\n 'active:shadow-[0_-2px_0_var(--link-halo-active),0_4px_0_var(--link-halo-active)]',\n ],\n secondary: [\n ...styledBase,\n '[--link-color:var(--color-primary-200)] dark:[--link-color:var(--color-primary-800)]',\n ],\n white: [\n ...styledBase,\n '[--link-color:var(--color-white)] dark:[--link-color:var(--color-grey-800)]',\n ],\n // Zero classes — the consumer (typically Button / BadgeButton) is\n // supplying its own complete visual treatment and doesn't want any\n // Link styling to compose on top. Intentionally omits the icon defaults\n // too, so the wrapping component has full control of icon sizing.\n unstyled: [],\n },\n },\n defaultVariants: {\n variant: 'primary',\n },\n})\n\ntype LinkComponent = React.ElementType\n\ntype LinkProps = Omit<React.ComponentPropsWithoutRef<'a'>, 'href'> &\n VariantProps<typeof linkVariants> & {\n as?: LinkComponent\n href: React.ComponentPropsWithoutRef<'a'>['href'] | object\n }\n\nconst LinkComponentContext = createContext<LinkComponent | null>(null)\n\nfunction LinkProvider({\n children,\n component,\n}: {\n children: React.ReactNode\n component: LinkComponent\n}) {\n return (\n <LinkComponentContext.Provider value={component}>\n {children}\n </LinkComponentContext.Provider>\n )\n}\n\n/**\n * Polymorphic anchor wrapper. Renders an `<a>` by default, or any element\n * provided via the `as` prop, or via a `<LinkProvider component={…}>` context\n * (use the context to inject a framework Link like Next.js `next/link`).\n *\n * Hover / active / focus styling on consumers should use the native CSS\n * pseudo-class utilities (`hover:`, `active:`, `focus-visible:`, and their\n * `group-…` variants) — Tailwind v4 maps them to real CSS, no JS state\n * tracking required.\n */\n/**\n * Anchor-only HTML attributes. When `Link` is rendered as a non-anchor\n * intrinsic element (e.g. `as=\"button\"`), forwarding these produces invalid\n * markup like `<button href=\"…\">` and React DOM warnings, so they are\n * stripped. Custom components passed via `as` / `LinkProvider` are assumed to\n * be anchor-like (e.g. `next/link`) and receive the full prop set.\n */\nconst ANCHOR_ONLY_PROPS = [\n 'href',\n 'target',\n 'rel',\n 'download',\n 'ping',\n 'referrerPolicy',\n 'hrefLang',\n 'type',\n] as const\n\nconst Link = forwardRef(function Link(\n { as, variant, className, ...props }: LinkProps,\n ref: React.ForwardedRef<HTMLAnchorElement>\n) {\n const ContextLink = useContext(LinkComponentContext)\n const component = as ?? ContextLink ?? 'a'\n\n // Drop anchor-only props when the resolved element is a non-anchor\n // intrinsic tag (e.g. `as=\"button\"`). String components other than 'a'\n // are real DOM tags that can't accept `href`/`target`/etc; non-string\n // components (framework links) keep the full set.\n const isNonAnchorIntrinsic =\n typeof component === 'string' && component !== 'a'\n\n const elementProps = { ...props } as Record<string, unknown>\n if (isNonAnchorIntrinsic) {\n for (const prop of ANCHOR_ONLY_PROPS) {\n delete elementProps[prop]\n }\n }\n\n return React.createElement(component, {\n ...elementProps,\n className: cn(linkVariants({ variant }), className),\n ref,\n })\n})\n\n/**\n * Open-in-new-tab glyph used by `ExternalLink`. Defined inline (rather than\n * imported from `Icons`) so that consumers of `Link` / `ExternalLink` don't\n * tree-pull the full icon set. Sized and aligned through the `[data-slot=icon]`\n * rules in `linkVariants`.\n */\nfunction OpenInNewIcon(props: React.SVGProps<SVGSVGElement>) {\n return (\n <svg\n data-slot=\"icon\"\n fill=\"currentColor\"\n viewBox=\"0 -960 960 960\"\n aria-hidden=\"true\"\n {...props}\n >\n <path d=\"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h240q17 0 28.5 11.5T480-800q0 17-11.5 28.5T440-760H200v560h560v-240q0-17 11.5-28.5T800-480q17 0 28.5 11.5T840-440v240q0 33-23.5 56.5T760-120H200Zm560-584L416-360q-11 11-28 11t-28-11q-11-11-11-28t11-28l344-344H600q-17 0-28.5-11.5T560-800q0-17 11.5-28.5T600-840h200q17 0 28.5 11.5T840-800v200q0 17-11.5 28.5T800-560q-17 0-28.5-11.5T760-600v-104Z\" />\n </svg>\n )\n}\n\ntype ExternalLinkProps = LinkProps & {\n /**\n * Screen-reader suffix announced after the link text. Defaults to\n * `\"(opens in a new tab)\"`. Pass an empty string to suppress.\n */\n newTabLabel?: string\n /**\n * Custom trailing icon. Pass `null` to hide the icon entirely. If omitted,\n * the default open-in-new glyph is rendered.\n */\n icon?: React.ReactNode | null\n}\n\n/**\n * Anchor preconfigured for cross-origin / new-tab navigation. Sets\n * `target=\"_blank\"` and `rel=\"noopener noreferrer\"` by default, renders a\n * trailing open-in-new icon, and appends a visually-hidden suffix so screen\n * readers announce that the link opens a new tab.\n *\n * All `Link` props are forwarded — `variant`, `as`, `className`, etc. —\n * and any of `target`, `rel`, `icon`, or `newTabLabel` can be overridden.\n */\nconst ExternalLink = forwardRef(function ExternalLink(\n {\n children,\n icon,\n newTabLabel = '(opens in a new tab)',\n target = '_blank',\n rel = 'noopener noreferrer',\n ...props\n }: ExternalLinkProps,\n ref: React.ForwardedRef<HTMLAnchorElement>\n) {\n const trailingIcon =\n icon === null ? null : (icon ?? <OpenInNewIcon className=\"ml-0.5\" />)\n\n return (\n <Link {...props} target={target} rel={rel} ref={ref}>\n {children}\n {trailingIcon}\n {newTabLabel ? <span className=\"sr-only\"> {newTabLabel}</span> : null}\n </Link>\n )\n})\n\nexport { ExternalLink, Link, LinkProvider, linkVariants }\nexport type { ExternalLinkProps, LinkComponent, LinkProps }\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
|
-
declare function LoginForm({ className, ...props }: React.ComponentProps<
|
|
4
|
+
declare function LoginForm({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
|
|
5
5
|
|
|
6
6
|
export { LoginForm };
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
-
import { cn } from '../lib/utils.js';
|
|
4
3
|
import { Button } from '../components/button.js';
|
|
5
4
|
import { Card, CardHeader, CardTitle, CardDescription, CardContent } from '../components/card.js';
|
|
6
5
|
import { FieldGroup, Field, FieldLabel, FieldDescription } from '../components/field.js';
|
|
6
|
+
import { Icons } from '../components/icons.js';
|
|
7
7
|
import { Input } from '../components/input.js';
|
|
8
|
+
import { LabeledSeparator } from '../components/labeled-separator.js';
|
|
9
|
+
import { Link } from '../components/link.js';
|
|
10
|
+
import { Separator } from '../components/separator.js';
|
|
11
|
+
import { cn } from '../lib/utils.js';
|
|
8
12
|
|
|
9
13
|
function LoginForm({
|
|
10
14
|
className,
|
|
11
15
|
...props
|
|
12
16
|
}) {
|
|
13
|
-
return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-6", className), ...props, children: /* @__PURE__ */ jsxs(Card, { children: [
|
|
17
|
+
return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-6", className), ...props, children: /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
|
|
14
18
|
/* @__PURE__ */ jsxs(CardHeader, { children: [
|
|
15
19
|
/* @__PURE__ */ jsx(CardTitle, { children: "Login to your account" }),
|
|
16
|
-
/* @__PURE__ */ jsx(CardDescription, { children: "
|
|
20
|
+
/* @__PURE__ */ jsx(CardDescription, { children: "Choose how you'd like to sign in" })
|
|
17
21
|
] }),
|
|
18
22
|
/* @__PURE__ */ jsx(CardContent, { children: /* @__PURE__ */ jsx("form", { children: /* @__PURE__ */ jsxs(FieldGroup, { children: [
|
|
23
|
+
/* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsxs(Button, { type: "button", children: [
|
|
24
|
+
/* @__PURE__ */ jsx(Icons.login, {}),
|
|
25
|
+
"Continue with single sign-on"
|
|
26
|
+
] }) }),
|
|
27
|
+
/* @__PURE__ */ jsx(LabeledSeparator, { children: "or sign in with email" }),
|
|
19
28
|
/* @__PURE__ */ jsxs(Field, { children: [
|
|
20
29
|
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: "email", children: "Email" }),
|
|
21
30
|
/* @__PURE__ */ jsx(
|
|
@@ -28,28 +37,28 @@ function LoginForm({
|
|
|
28
37
|
}
|
|
29
38
|
)
|
|
30
39
|
] }),
|
|
40
|
+
/* @__PURE__ */ jsxs(Field, { className: "relative [&>a]:w-auto", children: [
|
|
41
|
+
/* @__PURE__ */ jsx(FieldLabel, { htmlFor: "password", children: "Password" }),
|
|
42
|
+
/* @__PURE__ */ jsx(Input, { id: "password", type: "password", required: true }),
|
|
43
|
+
/* @__PURE__ */ jsx(Link, { href: "#", className: "absolute top-0 right-0 text-sm", children: "Forgot your password?" })
|
|
44
|
+
] }),
|
|
45
|
+
/* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsxs(Button, { type: "submit", variant: "outline", color: "primary", children: [
|
|
46
|
+
/* @__PURE__ */ jsx(Icons.key, {}),
|
|
47
|
+
"Login"
|
|
48
|
+
] }) }),
|
|
49
|
+
/* @__PURE__ */ jsx(LabeledSeparator, { children: "or" }),
|
|
31
50
|
/* @__PURE__ */ jsxs(Field, { children: [
|
|
32
|
-
/* @__PURE__ */ jsxs(
|
|
33
|
-
/* @__PURE__ */ jsx(
|
|
34
|
-
|
|
35
|
-
"a",
|
|
36
|
-
{
|
|
37
|
-
href: "#",
|
|
38
|
-
className: "ms-auto inline-block text-sm underline-offset-4 hover:underline",
|
|
39
|
-
children: "Forgot your password?"
|
|
40
|
-
}
|
|
41
|
-
)
|
|
51
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", color: "grey", children: [
|
|
52
|
+
/* @__PURE__ */ jsx(Icons.mail, {}),
|
|
53
|
+
"Email me a magic link instead"
|
|
42
54
|
] }),
|
|
43
|
-
/* @__PURE__ */ jsx(
|
|
55
|
+
/* @__PURE__ */ jsx(FieldDescription, { children: "We'll send a password-free sign-in link to the email above." })
|
|
44
56
|
] }),
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
50
|
-
/* @__PURE__ */ jsx("a", { href: "#", children: "Sign up" })
|
|
51
|
-
] })
|
|
52
|
-
] })
|
|
57
|
+
/* @__PURE__ */ jsx(Separator, { className: "bg-grey-200" }),
|
|
58
|
+
/* @__PURE__ */ jsx(Field, { children: /* @__PURE__ */ jsxs(FieldDescription, { className: "text-center", children: [
|
|
59
|
+
"Don't have an account? ",
|
|
60
|
+
/* @__PURE__ */ jsx(Link, { href: "#", children: "Sign up" })
|
|
61
|
+
] }) })
|
|
53
62
|
] }) }) })
|
|
54
63
|
] }) });
|
|
55
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/login-form.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/login-form.tsx"],"names":[],"mappings":"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","file":"login-form.js","sourcesContent":["'use client'\n\nimport type * as React from 'react'\n\nimport { Button } from '../components/button.js'\nimport {\n Card,\n CardContent,\n CardDescription,\n CardHeader,\n CardTitle,\n} from '../components/card.js'\nimport {\n Field,\n FieldDescription,\n FieldGroup,\n FieldLabel,\n} from '../components/field.js'\nimport { Icons } from '../components/icons.js'\nimport { Input } from '../components/input.js'\nimport { LabeledSeparator } from '../components/labeled-separator.js'\nimport { Link } from '../components/link.js'\nimport { Separator } from '../components/separator.js'\nimport { cn } from '../lib/utils.js'\n\nexport function LoginForm({\n className,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div className={cn('flex flex-col gap-6', className)} {...props}>\n <Card className=\"w-full\">\n <CardHeader>\n <CardTitle>Login to your account</CardTitle>\n <CardDescription>\n Choose how you'd like to sign in\n </CardDescription>\n </CardHeader>\n <CardContent>\n <form>\n <FieldGroup>\n {/*\n * Best-practice sign-in order, most-recommended first:\n * 1. Single sign-on (SSO) — the preferred path\n * 2. Email + password — the traditional fallback\n * 3. Magic link — passwordless, reuses the email\n * Each method is divided by a LabeledSeparator so it reads as a\n * distinct alternative. Only SSO carries primary (solid)\n * emphasis — one primary action per view — with password Login\n * and the magic link stepped down to outline treatments.\n */}\n {/* 1 — Single sign-on: the recommended first option */}\n <Field>\n <Button type=\"button\">\n <Icons.login />\n Continue with single sign-on\n </Button>\n </Field>\n <LabeledSeparator>or sign in with email</LabeledSeparator>\n {/* 2 — Email + password */}\n <Field>\n <FieldLabel htmlFor=\"email\">Email</FieldLabel>\n <Input\n id=\"email\"\n type=\"email\"\n placeholder=\"m@example.com\"\n required\n />\n </Field>\n <Field className=\"relative [&>a]:w-auto\">\n <FieldLabel htmlFor=\"password\">Password</FieldLabel>\n <Input id=\"password\" type=\"password\" required />\n {/*\n * Placed AFTER the input in DOM (rather than next to the\n * label) so keyboard tab order is email → password → forgot,\n * not email → forgot → password. Visually positioned at the\n * top-right via absolute positioning to preserve the\n * \"Forgot your password?\" alongside-label layout. See WCAG\n * 2.4.3 Focus Order test in\n * login-form.accessibility.stories.tsx.\n */}\n <Link href=\"#\" className=\"absolute top-0 right-0 text-sm\">\n Forgot your password?\n </Link>\n </Field>\n <Field>\n <Button type=\"submit\" variant=\"outline\" color=\"primary\">\n <Icons.key />\n Login\n </Button>\n </Field>\n {/* 3 — Magic link: passwordless, sent to the email entered above */}\n <LabeledSeparator>or</LabeledSeparator>\n <Field>\n <Button type=\"button\" variant=\"outline\" color=\"grey\">\n <Icons.mail />\n Email me a magic link instead\n </Button>\n <FieldDescription>\n We'll send a password-free sign-in link to the email\n above.\n </FieldDescription>\n </Field>\n <Separator className=\"bg-grey-200\" />\n <Field>\n <FieldDescription className=\"text-center\">\n Don't have an account? <Link href=\"#\">Sign up</Link>\n </FieldDescription>\n </Field>\n </FieldGroup>\n </form>\n </CardContent>\n </Card>\n </div>\n )\n}\n"]}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Separator as Separator$1 } from '@base-ui/react/separator';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type SeparatorProps = Separator$1.Props & {
|
|
5
|
+
/**
|
|
6
|
+
* When true, the separator is purely presentational and is hidden from
|
|
7
|
+
* assistive tech by setting `role="none"`. Defaults to `false`, in which
|
|
8
|
+
* case Base UI's default `role="separator"` is left intact so AT users
|
|
9
|
+
* hear it as a region boundary.
|
|
10
|
+
*/
|
|
11
|
+
decorative?: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare function Separator({ className, orientation, decorative, role, ...props }: SeparatorProps): react_jsx_runtime.JSX.Element;
|
|
5
14
|
|
|
6
|
-
export { Separator };
|
|
15
|
+
export { Separator, type SeparatorProps };
|
|
@@ -6,22 +6,34 @@ import { cn } from '../lib/utils.js';
|
|
|
6
6
|
function Separator({
|
|
7
7
|
className,
|
|
8
8
|
orientation = "horizontal",
|
|
9
|
+
decorative = false,
|
|
10
|
+
role,
|
|
9
11
|
...props
|
|
10
12
|
}) {
|
|
13
|
+
const sharedClassName = cn(
|
|
14
|
+
"shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
|
|
15
|
+
className
|
|
16
|
+
);
|
|
17
|
+
const isPresentational = decorative || role === "none" || role === "presentation";
|
|
18
|
+
if (isPresentational) {
|
|
19
|
+
return /* @__PURE__ */ jsx(
|
|
20
|
+
"div",
|
|
21
|
+
{
|
|
22
|
+
"data-slot": "separator",
|
|
23
|
+
"data-orientation": orientation,
|
|
24
|
+
role: "none",
|
|
25
|
+
className: sharedClassName,
|
|
26
|
+
...props
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
}
|
|
11
30
|
return /* @__PURE__ */ jsx(
|
|
12
31
|
Separator$1,
|
|
13
32
|
{
|
|
14
33
|
"data-slot": "separator",
|
|
15
34
|
orientation,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// only (see @base-ui/react SeparatorDataAttributes). The previous
|
|
19
|
-
// `data-horizontal:` / `data-vertical:` selectors targeted
|
|
20
|
-
// non-existent boolean attributes and never matched, leaving the
|
|
21
|
-
// separator with no explicit axis sizing.
|
|
22
|
-
"shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch",
|
|
23
|
-
className
|
|
24
|
-
),
|
|
35
|
+
role: role ?? "separator",
|
|
36
|
+
className: sharedClassName,
|
|
25
37
|
...props
|
|
26
38
|
}
|
|
27
39
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/separator.tsx"],"names":["SeparatorPrimitive"],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../../src/components/separator.tsx"],"names":["SeparatorPrimitive"],"mappings":";;;;AAkBA,SAAS,SAAA,CAAU;AAAA,EACjB,SAAA;AAAA,EACA,WAAA,GAAc,YAAA;AAAA,EACd,UAAA,GAAa,KAAA;AAAA,EACb,IAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAmB;AAMjB,EAAA,MAAM,eAAA,GAAkB,EAAA;AAAA,IACtB,sKAAA;AAAA,IACA;AAAA,GACF;AAOA,EAAA,MAAM,gBAAA,GACJ,UAAA,IAAc,IAAA,KAAS,MAAA,IAAU,IAAA,KAAS,cAAA;AAE5C,EAAA,IAAI,gBAAA,EAAkB;AAIpB,IAAA,uBACE,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,WAAA,EAAU,WAAA;AAAA,QACV,kBAAA,EAAkB,WAAA;AAAA,QAClB,IAAA,EAAK,MAAA;AAAA,QACL,SAAA,EAAW,eAAA;AAAA,QACV,GAAI;AAAA;AAAA,KACP;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAACA,WAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,WAAA;AAAA,MACV,WAAA;AAAA,MACA,MAAM,IAAA,IAAQ,WAAA;AAAA,MACd,SAAA,EAAW,eAAA;AAAA,MACV,GAAG;AAAA;AAAA,GACN;AAEJ","file":"separator.js","sourcesContent":["'use client'\n\nimport type * as React from 'react'\n\nimport { Separator as SeparatorPrimitive } from '@base-ui/react/separator'\n\nimport { cn } from '../lib/utils.js'\n\ntype SeparatorProps = SeparatorPrimitive.Props & {\n /**\n * When true, the separator is purely presentational and is hidden from\n * assistive tech by setting `role=\"none\"`. Defaults to `false`, in which\n * case Base UI's default `role=\"separator\"` is left intact so AT users\n * hear it as a region boundary.\n */\n decorative?: boolean\n}\n\nfunction Separator({\n className,\n orientation = 'horizontal',\n decorative = false,\n role,\n ...props\n}: SeparatorProps) {\n // Base UI's Separator emits `data-orientation=\"horizontal|vertical\"` for\n // CSS targeting AND `aria-orientation` for assistive tech. The previous\n // `data-horizontal:` / `data-vertical:` selectors targeted non-existent\n // boolean attributes and never matched, leaving the separator with no\n // explicit axis sizing.\n const sharedClassName = cn(\n 'shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:w-px data-[orientation=vertical]:self-stretch',\n className\n )\n\n // A consumer passing `role=\"none\"` / `\"presentation\"` is asking for a\n // presentational separator just as `decorative` does — treat them the same.\n // Otherwise Base UI would still emit `aria-orientation` (which it sets from\n // the orientation prop regardless of role), recreating the axe\n // `aria-allowed-attr` violation that `decorative` exists to avoid.\n const isPresentational =\n decorative || role === 'none' || role === 'presentation'\n\n if (isPresentational) {\n // Render a plain <div> for presentational separators. Bypass the\n // primitive so the rendered element carries no ARIA semantics at all\n // (no `aria-orientation`).\n return (\n <div\n data-slot=\"separator\"\n data-orientation={orientation}\n role=\"none\"\n className={sharedClassName}\n {...(props as React.HTMLAttributes<HTMLDivElement>)}\n />\n )\n }\n\n return (\n <SeparatorPrimitive\n data-slot=\"separator\"\n orientation={orientation}\n role={role ?? 'separator'}\n className={sharedClassName}\n {...props}\n />\n )\n}\n\nexport { Separator }\nexport type { SeparatorProps }\n"]}
|