@nswds/ui 1.4.0 → 1.5.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 +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,6NAAA;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-xs/relaxed leading-none 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"]}
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"]}
@@ -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
- * Polymorphic anchor wrapper. Renders an `<a>` by default, or any element
15
- * provided via the `as` prop, or via a `<LinkProvider component={…}>` context
16
- * (use the context to inject a framework Link like Next.js `next/link`).
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
- * Hover / active / focus styling on consumers should use the native CSS
19
- * pseudo-class utilities (`hover:`, `active:`, `focus-visible:`, and their
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 Link: React__default.ForwardRefExoticComponent<Omit<Omit<React__default.DetailedHTMLProps<React__default.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>, "ref">, "href"> & {
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 };
@@ -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 Link = forwardRef(function Link2({ as, ...props }, ref) {
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
- return React.createElement(component, { ...props, ref });
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":";;;;;AASA,MAAM,UAAA,GAAa;AAAA;AAAA,EAEjB,+EAAA;AAAA;AAAA;AAAA;AAAA,EAIA,qBAAA;AAAA,EACA,qEAAA;AAAA,EACA,4EAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,2CAAA;AAAA,EACA,mEAAA;AAAA;AAAA,EAEA,mEAAA;AAAA,EACA,mHAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA;AACF,CAAA;AAEA,MAAM,YAAA,GAAe,IAAI,EAAA,EAAI;AAAA,EAC3B,QAAA,EAAU;AAAA,IACR,OAAA,EAAS;AAAA,MACP,OAAA,EAAS;AAAA,QACP,GAAG,UAAA;AAAA;AAAA,QAEH,sFAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMA,wDAAA;AAAA;AAAA,QAEA,oDAAA;AAAA,QACA;AAAA,OACF;AAAA,MACA,SAAA,EAAW;AAAA,QACT,GAAG,UAAA;AAAA,QACH;AAAA,OACF;AAAA,MACA,KAAA,EAAO;AAAA,QACL,GAAG,UAAA;AAAA,QACH;AAAA,OACF;AAAA;AAAA;AAAA;AAAA;AAAA,MAKA,UAAU;AAAC;AACb,GACF;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,OAAA,EAAS;AAAA;AAEb,CAAC;AAUD,MAAM,oBAAA,GAAuB,cAAoC,IAAI,CAAA;AAErE,SAAS,YAAA,CAAa;AAAA,EACpB,QAAA;AAAA,EACA;AACF,CAAA,EAGG;AACD,EAAA,2BACG,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AA,EAAE,qZAAA,EAAsZ;AAAA;AAAA,GACha;AAEJ;AAwBA,MAAM,YAAA,GAAe,UAAA,CAAW,SAASC,aAAAA,CACvC;AAAA,EACE,QAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA,GAAc,sBAAA;AAAA,EACd,MAAA,GAAS,QAAA;AAAA,EACT,GAAA,GAAM,qBAAA;AAAA,EACN,GAAG;AACL,CAAA,EACA,GAAA,EACA;AACA,EAAA,MAAM,YAAA,GACJ,SAAS,IAAA,GAAO,IAAA,GAAQ,wBAAQ,GAAA,CAAC,aAAA,EAAA,EAAc,WAAU,QAAA,EAAS,CAAA;AAEpE,EAAA,4BACG,IAAA,EAAA,EAAM,GAAG,KAAA,EAAO,MAAA,EAAgB,KAAU,GAAA,EACxC,QAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA,mBAAc,IAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA;AAAA,MAAA,GAAA;AAAA,MAAE;AAAA,KAAA,EAAY,CAAA,GAAU;AAAA,GAAA,EACnE,CAAA;AAEJ,CAAC","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<"div">): react_jsx_runtime.JSX.Element;
4
+ declare function LoginForm({ className, ...props }: React.ComponentProps<'div'>): react_jsx_runtime.JSX.Element;
5
5
 
6
6
  export { LoginForm };
@@ -1,16 +1,16 @@
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';
7
6
  import { Input } from '../components/input.js';
7
+ import { cn } from '../lib/utils.js';
8
8
 
9
9
  function LoginForm({
10
10
  className,
11
11
  ...props
12
12
  }) {
13
- return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-6", className), ...props, children: /* @__PURE__ */ jsxs(Card, { children: [
13
+ return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col gap-6", className), ...props, children: /* @__PURE__ */ jsxs(Card, { className: "w-full", children: [
14
14
  /* @__PURE__ */ jsxs(CardHeader, { children: [
15
15
  /* @__PURE__ */ jsx(CardTitle, { children: "Login to your account" }),
16
16
  /* @__PURE__ */ jsx(CardDescription, { children: "Enter your email below to login to your account" })
@@ -28,19 +28,17 @@ function LoginForm({
28
28
  }
29
29
  )
30
30
  ] }),
31
- /* @__PURE__ */ jsxs(Field, { children: [
32
- /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
33
- /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "password", children: "Password" }),
34
- /* @__PURE__ */ jsx(
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
- )
42
- ] }),
43
- /* @__PURE__ */ jsx(Input, { id: "password", type: "password", required: true })
31
+ /* @__PURE__ */ jsxs(Field, { className: "relative", children: [
32
+ /* @__PURE__ */ jsx(FieldLabel, { htmlFor: "password", children: "Password" }),
33
+ /* @__PURE__ */ jsx(Input, { id: "password", type: "password", required: true }),
34
+ /* @__PURE__ */ jsx(
35
+ "a",
36
+ {
37
+ href: "#",
38
+ className: "absolute top-0 right-0 text-sm underline-offset-4 hover:underline",
39
+ children: "Forgot your password?"
40
+ }
41
+ )
44
42
  ] }),
45
43
  /* @__PURE__ */ jsxs(Field, { children: [
46
44
  /* @__PURE__ */ jsx(Button, { type: "submit", children: "Login" }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/login-form.tsx"],"names":[],"mappings":";;;;;;;AAqBO,SAAS,SAAA,CAAU;AAAA,EACxB,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,EACC,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,iDAAA,EAEjB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AAAA,wBACA,IAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,aAAA,EAAc,QAAA,EAAA;AAAA,UAAA,yBAAA;AAAA,0BACZ,GAAA,CAAC,GAAA,EAAA,EAAE,IAAA,EAAK,GAAA,EAAI,QAAA,EAAA,SAAA,EAAO;AAAA,SAAA,EACjD;AAAA,OAAA,EACF;AAAA,KAAA,EACF,GACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ","file":"login-form.js","sourcesContent":["'use client'\n\nimport type * as React from \"react\"\n\nimport { cn } from \"../lib/utils.js\"\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\"\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>\n <CardHeader>\n <CardTitle>Login to your account</CardTitle>\n <CardDescription>\n Enter your email below to login to your account\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 placeholder=\"m@example.com\"\n required\n />\n </Field>\n <Field>\n <div className=\"flex items-center\">\n <FieldLabel htmlFor=\"password\">Password</FieldLabel>\n <a\n href=\"#\"\n className=\"ms-auto inline-block text-sm underline-offset-4 hover:underline\"\n >\n Forgot your password?\n </a>\n </div>\n <Input id=\"password\" type=\"password\" required />\n </Field>\n <Field>\n <Button type=\"submit\">Login</Button>\n <Button variant=\"outline\" type=\"button\">\n Login with Google\n </Button>\n <FieldDescription className=\"text-center\">\n Don&apos;t have an account? <a href=\"#\">Sign up</a>\n </FieldDescription>\n </Field>\n </FieldGroup>\n </form>\n </CardContent>\n </Card>\n </div>\n )\n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G,YAAW,IAAA,EAAK,UAAA,EAAW,UAAQ,IAAA,EAAC,CAAA;AAAA,wBAU9C,GAAA;AAAA,UAAC,GAAA;AAAA,UAAA;AAAA,YACC,IAAA,EAAK,GAAA;AAAA,YACL,SAAA,EAAU,mEAAA;AAAA,YACX,QAAA,EAAA;AAAA;AAAA;AAED,OAAA,EACF,CAAA;AAAA,2BACC,KAAA,EAAA,EACC,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,MAAA,EAAA,EAAO,IAAA,EAAK,QAAA,EAAS,QAAA,EAAA,OAAA,EAAK,CAAA;AAAA,4BAC1B,MAAA,EAAA,EAAO,OAAA,EAAQ,SAAA,EAAU,IAAA,EAAK,UAAS,QAAA,EAAA,mBAAA,EAExC,CAAA;AAAA,wBACA,IAAA,CAAC,gBAAA,EAAA,EAAiB,SAAA,EAAU,aAAA,EAAc,QAAA,EAAA;AAAA,UAAA,yBAAA;AAAA,0BACZ,GAAA,CAAC,GAAA,EAAA,EAAE,IAAA,EAAK,GAAA,EAAI,QAAA,EAAA,SAAA,EAAO;AAAA,SAAA,EACjD;AAAA,OAAA,EACF;AAAA,KAAA,EACF,GACF,CAAA,EACF;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ","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 { Input } from '../components/input.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 Enter your email below to login to your account\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 placeholder=\"m@example.com\"\n required\n />\n </Field>\n <Field className=\"relative\">\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 <a\n href=\"#\"\n className=\"absolute top-0 right-0 text-sm underline-offset-4 hover:underline\"\n >\n Forgot your password?\n </a>\n </Field>\n <Field>\n <Button type=\"submit\">Login</Button>\n <Button variant=\"outline\" type=\"button\">\n Login with Google\n </Button>\n <FieldDescription className=\"text-center\">\n Don&apos;t have an account? <a href=\"#\">Sign up</a>\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
- declare function Separator({ className, orientation, ...props }: Separator$1.Props): react_jsx_runtime.JSX.Element;
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
- className: cn(
17
- // Base UI's Separator emits `data-orientation="horizontal|vertical"`
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":";;;;AAMA,SAAS,SAAA,CAAU;AAAA,EACjB,SAAA;AAAA,EACA,WAAA,GAAc,YAAA;AAAA,EACd,GAAG;AACL,CAAA,EAA6B;AAC3B,EAAA,uBACE,GAAA;AAAA,IAACA,WAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,WAAA;AAAA,MACV,WAAA;AAAA,MACA,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAMT,sKAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"separator.js","sourcesContent":["\"use client\"\n\nimport { Separator as SeparatorPrimitive } from \"@base-ui/react/separator\"\n\nimport { cn } from \"../lib/utils.js\"\n\nfunction Separator({\n className,\n orientation = \"horizontal\",\n ...props\n}: SeparatorPrimitive.Props) {\n return (\n <SeparatorPrimitive\n data-slot=\"separator\"\n orientation={orientation}\n className={cn(\n // Base UI's Separator emits `data-orientation=\"horizontal|vertical\"`\n // only (see @base-ui/react SeparatorDataAttributes). The previous\n // `data-horizontal:` / `data-vertical:` selectors targeted\n // non-existent boolean attributes and never matched, leaving the\n // separator with no explicit axis sizing.\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 {...props}\n />\n )\n}\n\nexport { Separator }\n"]}
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"]}
@@ -9,11 +9,17 @@ declare const theme: {
9
9
  lg: string;
10
10
  xl: string;
11
11
  };
12
+ color: {
13
+ primary: string;
14
+ accent: string;
15
+ white: string;
16
+ };
12
17
  };
13
18
  type SpinnerProps = {
14
19
  className?: string;
15
20
  size?: keyof typeof theme.size;
21
+ color?: keyof typeof theme.color;
16
22
  } & React.HTMLAttributes<HTMLSpanElement>;
17
- declare function Spinner({ className, size, ...props }: SpinnerProps): react_jsx_runtime.JSX.Element;
23
+ declare function Spinner({ className, size, color, ...props }: SpinnerProps): react_jsx_runtime.JSX.Element;
18
24
 
19
25
  export { Spinner };
@@ -9,16 +9,27 @@ const theme = {
9
9
  md: "h-6 w-6",
10
10
  lg: "h-8 w-8",
11
11
  xl: "h-10 w-10"
12
+ },
13
+ color: {
14
+ primary: "fill-primary-800 text-grey-400",
15
+ accent: "fill-accent-600 text-grey-400",
16
+ white: "fill-white text-white/30"
12
17
  }
13
18
  };
14
- function Spinner({ className, size = "md", ...props }) {
19
+ function Spinner({
20
+ className,
21
+ size = "md",
22
+ color = "primary",
23
+ ...props
24
+ }) {
15
25
  return /* @__PURE__ */ jsx("span", { role: "status", ...props, children: /* @__PURE__ */ jsxs(
16
26
  "svg",
17
27
  {
18
28
  fill: "none",
19
29
  viewBox: "0 0 100 101",
20
30
  className: cn(
21
- "inline animate-spin fill-primary text-muted-foreground/30",
31
+ "inline animate-spin",
32
+ theme.color[color],
22
33
  theme.size[size],
23
34
  className
24
35
  ),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/spinner.tsx"],"names":[],"mappings":";;;AAKA,MAAM,KAAA,GAAQ;AAAA,EACZ,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI;AAAA;AAER,CAAA;AAOA,SAAS,QAAQ,EAAE,SAAA,EAAW,OAAO,IAAA,EAAM,GAAG,OAAM,EAAiB;AACnE,EAAA,uBACE,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAU,GAAG,KAAA,EACtB,QAAA,kBAAA,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,MAAA;AAAA,MACL,OAAA,EAAQ,aAAA;AAAA,MACR,SAAA,EAAW,EAAA;AAAA,QACT,2DAAA;AAAA,QACA,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,QACf;AAAA,OACF;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,CAAA,EAAE,8WAAA;AAAA,YACF,IAAA,EAAK;AAAA;AAAA,SACP;AAAA,wBACA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,CAAA,EAAE,+kBAAA;AAAA,YACF,IAAA,EAAK;AAAA;AAAA;AACP;AAAA;AAAA,GACF,EACF,CAAA;AAEJ","file":"spinner.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../lib/utils.js'\n\nconst theme = {\n size: {\n xs: 'h-3 w-3',\n sm: 'h-4 w-4',\n md: 'h-6 w-6',\n lg: 'h-8 w-8',\n xl: 'h-10 w-10',\n },\n}\n\ntype SpinnerProps = {\n className?: string\n size?: keyof typeof theme.size\n} & React.HTMLAttributes<HTMLSpanElement>\n\nfunction Spinner({ className, size = 'md', ...props }: SpinnerProps) {\n return (\n <span role=\"status\" {...props}>\n <svg\n fill=\"none\"\n viewBox=\"0 0 100 101\"\n className={cn(\n 'inline animate-spin fill-primary text-muted-foreground/30',\n theme.size[size],\n className\n )}\n >\n <path\n d=\"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z\"\n fill=\"currentColor\"\n />\n <path\n d=\"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z\"\n fill=\"currentFill\"\n />\n </svg>\n </span>\n )\n}\n\nexport { Spinner }\n"]}
1
+ {"version":3,"sources":["../../src/components/spinner.tsx"],"names":[],"mappings":";;;AAKA,MAAM,KAAA,GAAQ;AAAA,EACZ,IAAA,EAAM;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI,SAAA;AAAA,IACJ,EAAA,EAAI;AAAA,GACN;AAAA,EACA,KAAA,EAAO;AAAA,IACL,OAAA,EAAS,gCAAA;AAAA,IACT,MAAA,EAAQ,+BAAA;AAAA,IACR,KAAA,EAAO;AAAA;AAEX,CAAA;AAQA,SAAS,OAAA,CAAQ;AAAA,EACf,SAAA;AAAA,EACA,IAAA,GAAO,IAAA;AAAA,EACP,KAAA,GAAQ,SAAA;AAAA,EACR,GAAG;AACL,CAAA,EAAiB;AACf,EAAA,uBACE,GAAA,CAAC,MAAA,EAAA,EAAK,IAAA,EAAK,QAAA,EAAU,GAAG,KAAA,EACtB,QAAA,kBAAA,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,MAAA;AAAA,MACL,OAAA,EAAQ,aAAA;AAAA,MACR,SAAA,EAAW,EAAA;AAAA,QACT,qBAAA;AAAA,QACA,KAAA,CAAM,MAAM,KAAK,CAAA;AAAA,QACjB,KAAA,CAAM,KAAK,IAAI,CAAA;AAAA,QACf;AAAA,OACF;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,CAAA,EAAE,8WAAA;AAAA,YACF,IAAA,EAAK;AAAA;AAAA,SACP;AAAA,wBACA,GAAA;AAAA,UAAC,MAAA;AAAA,UAAA;AAAA,YACC,CAAA,EAAE,+kBAAA;AAAA,YACF,IAAA,EAAK;AAAA;AAAA;AACP;AAAA;AAAA,GACF,EACF,CAAA;AAEJ","file":"spinner.js","sourcesContent":["'use client'\n\nimport * as React from 'react'\nimport { cn } from '../lib/utils.js'\n\nconst theme = {\n size: {\n xs: 'h-3 w-3',\n sm: 'h-4 w-4',\n md: 'h-6 w-6',\n lg: 'h-8 w-8',\n xl: 'h-10 w-10',\n },\n color: {\n primary: 'fill-primary-800 text-grey-400',\n accent: 'fill-accent-600 text-grey-400',\n white: 'fill-white text-white/30',\n },\n}\n\ntype SpinnerProps = {\n className?: string\n size?: keyof typeof theme.size\n color?: keyof typeof theme.color\n} & React.HTMLAttributes<HTMLSpanElement>\n\nfunction Spinner({\n className,\n size = 'md',\n color = 'primary',\n ...props\n}: SpinnerProps) {\n return (\n <span role=\"status\" {...props}>\n <svg\n fill=\"none\"\n viewBox=\"0 0 100 101\"\n className={cn(\n 'inline animate-spin',\n theme.color[color],\n theme.size[size],\n className\n )}\n >\n <path\n d=\"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z\"\n fill=\"currentColor\"\n />\n <path\n d=\"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z\"\n fill=\"currentFill\"\n />\n </svg>\n </span>\n )\n}\n\nexport { Spinner }\n"]}
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { Badge, BadgeButton, badgeVariants } from './components/badge.js';
2
2
  export { Button, TouchTarget, buttonVariants } from './components/button.js';
3
3
  export { DescriptionDetails, DescriptionList, DescriptionTerm } from './components/description-list.js';
4
4
  export { IconName, Icons } from './components/icons.js';
5
- export { Link, LinkComponent, LinkProps, LinkProvider } from './components/link.js';
5
+ export { ExternalLink, ExternalLinkProps, Link, LinkComponent, LinkProps, LinkProvider, linkVariants } from './components/link.js';
6
6
  export { Logo } from './components/logo.js';
7
7
  export { Spinner } from './components/spinner.js';
8
8
  export { aboriginal, allPalettes, brand, colorThemes, colors, diverging, semantic, sequential } from './lib/color-palette.js';