@nswds/ui 4.0.0 → 4.1.1
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/README.md +1 -1
- package/dist/components/aspect-ratio.js.map +1 -1
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/badge.js +11 -29
- package/dist/components/badge.js.map +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/card.js +3 -14
- package/dist/components/card.js.map +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/drawer.js +5 -16
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/field.js +9 -45
- package/dist/components/field.js.map +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input.js +1 -6
- package/dist/components/input.js.map +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/labeled-separator.js.map +1 -1
- package/dist/components/link.js.map +1 -1
- package/dist/components/logo.js.map +1 -1
- package/dist/components/masthead.d.ts +34 -0
- package/dist/components/masthead.js +79 -0
- package/dist/components/masthead.js.map +1 -0
- package/dist/components/popover.js +1 -4
- package/dist/components/popover.js.map +1 -1
- package/dist/components/resizable.js +2 -8
- package/dist/components/resizable.js.map +1 -1
- package/dist/components/scroll-area.js +1 -5
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sheet.js +1 -4
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/skip-link.d.ts +51 -0
- package/dist/components/skip-link.js +110 -0
- package/dist/components/skip-link.js.map +1 -0
- package/dist/components/sonner.js.map +1 -1
- package/dist/components/spinner.js +32 -41
- package/dist/components/spinner.js.map +1 -1
- package/dist/components/tooltip.js +2 -12
- package/dist/components/tooltip.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/components/field.js
CHANGED
|
@@ -8,11 +8,7 @@ import { Separator } from '../components/separator.js';
|
|
|
8
8
|
import { cn } from '../lib/utils.js';
|
|
9
9
|
|
|
10
10
|
const InsideFieldContext = React.createContext(false);
|
|
11
|
-
function FieldSet({
|
|
12
|
-
className,
|
|
13
|
-
ref,
|
|
14
|
-
...props
|
|
15
|
-
}) {
|
|
11
|
+
function FieldSet({ className, ref, ...props }) {
|
|
16
12
|
return /* @__PURE__ */ jsx(
|
|
17
13
|
"fieldset",
|
|
18
14
|
{
|
|
@@ -102,20 +98,13 @@ function Field({
|
|
|
102
98
|
}
|
|
103
99
|
);
|
|
104
100
|
}
|
|
105
|
-
function FieldContent({
|
|
106
|
-
className,
|
|
107
|
-
ref,
|
|
108
|
-
...props
|
|
109
|
-
}) {
|
|
101
|
+
function FieldContent({ className, ref, ...props }) {
|
|
110
102
|
return /* @__PURE__ */ jsx(
|
|
111
103
|
"div",
|
|
112
104
|
{
|
|
113
105
|
ref,
|
|
114
106
|
"data-slot": "field-content",
|
|
115
|
-
className: cn(
|
|
116
|
-
"group/field-content flex flex-1 flex-col gap-0.5 leading-snug",
|
|
117
|
-
className
|
|
118
|
-
),
|
|
107
|
+
className: cn("group/field-content flex flex-1 flex-col gap-0.5 leading-snug", className),
|
|
119
108
|
...props
|
|
120
109
|
}
|
|
121
110
|
);
|
|
@@ -124,11 +113,7 @@ const fieldLabelClassName = cn(
|
|
|
124
113
|
"group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-disabled/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10",
|
|
125
114
|
"has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col"
|
|
126
115
|
);
|
|
127
|
-
function FieldLabel({
|
|
128
|
-
className,
|
|
129
|
-
ref,
|
|
130
|
-
...props
|
|
131
|
-
}) {
|
|
116
|
+
function FieldLabel({ className, ref, ...props }) {
|
|
132
117
|
const insideField = React.useContext(InsideFieldContext);
|
|
133
118
|
if (!insideField) {
|
|
134
119
|
return /* @__PURE__ */ jsx(
|
|
@@ -173,11 +158,7 @@ const fieldDescriptionClassName = cn(
|
|
|
173
158
|
"last:mt-0 nth-last-2:-mt-1",
|
|
174
159
|
"[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary"
|
|
175
160
|
);
|
|
176
|
-
function FieldDescription({
|
|
177
|
-
className,
|
|
178
|
-
ref,
|
|
179
|
-
...props
|
|
180
|
-
}) {
|
|
161
|
+
function FieldDescription({ className, ref, ...props }) {
|
|
181
162
|
const insideField = React.useContext(InsideFieldContext);
|
|
182
163
|
if (!insideField) {
|
|
183
164
|
return /* @__PURE__ */ jsx(
|
|
@@ -246,35 +227,18 @@ function FieldError({
|
|
|
246
227
|
if (!errors?.length) {
|
|
247
228
|
return null;
|
|
248
229
|
}
|
|
249
|
-
const uniqueErrors = [
|
|
250
|
-
...new Map(errors.map((error) => [error?.message, error])).values()
|
|
251
|
-
];
|
|
230
|
+
const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()];
|
|
252
231
|
if (uniqueErrors?.length === 1) {
|
|
253
232
|
return uniqueErrors[0]?.message;
|
|
254
233
|
}
|
|
255
|
-
return /* @__PURE__ */ jsx("ul", { className: "ms-4 flex list-disc flex-col gap-1", children: uniqueErrors.map(
|
|
256
|
-
(error, index) => error?.message && /* @__PURE__ */ jsx("li", { children: error.message }, index)
|
|
257
|
-
) });
|
|
234
|
+
return /* @__PURE__ */ jsx("ul", { className: "ms-4 flex list-disc flex-col gap-1", children: uniqueErrors.map((error, index) => error?.message && /* @__PURE__ */ jsx("li", { children: error.message }, index)) });
|
|
258
235
|
}, [children, errors]);
|
|
259
236
|
if (!content) {
|
|
260
237
|
return null;
|
|
261
238
|
}
|
|
262
|
-
const errorClassName = cn(
|
|
263
|
-
"text-sm/relaxed font-normal text-destructive",
|
|
264
|
-
className
|
|
265
|
-
);
|
|
239
|
+
const errorClassName = cn("text-sm/relaxed font-normal text-destructive", className);
|
|
266
240
|
if (!insideField) {
|
|
267
|
-
return /* @__PURE__ */ jsx(
|
|
268
|
-
"div",
|
|
269
|
-
{
|
|
270
|
-
ref,
|
|
271
|
-
role: "alert",
|
|
272
|
-
"data-slot": "field-error",
|
|
273
|
-
className: errorClassName,
|
|
274
|
-
...props,
|
|
275
|
-
children: content
|
|
276
|
-
}
|
|
277
|
-
);
|
|
241
|
+
return /* @__PURE__ */ jsx("div", { ref, role: "alert", "data-slot": "field-error", className: errorClassName, ...props, children: content });
|
|
278
242
|
}
|
|
279
243
|
return /* @__PURE__ */ jsx(
|
|
280
244
|
Field$1.Error,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/field.tsx"],"names":["FieldPrimitive"],"mappings":";;;;;;;;AAuDA,MAAM,kBAAA,GAAqB,KAAA,CAAM,aAAA,CAAc,KAAK,CAAA;AAEpD,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAqC;AACnC,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,WAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,kGAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAA,CAAY;AAAA,EACnB,SAAA;AAAA,EACA,OAAA,GAAU,QAAA;AAAA,EACV,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAsE;AACpE,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,WAAA,EAAU,cAAA;AAAA,MACV,cAAA,EAAc,OAAA;AAAA,MACd,SAAA,EAAW,EAAA;AAAA,QACT,qFAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAW,EAAE,SAAA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A,GACF;AAIA,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,uBACE,GAAA;AAAA,MAAC,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,IAAA,EAAK,OAAA;AAAA,QACL,WAAA,EAAU,aAAA;AAAA,QACV,SAAA,EAAW,cAAA;AAAA,QACV,GAAG,KAAA;AAAA,QAEH,QAAA,EAAA;AAAA;AAAA,KACH;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAACA,OAAA,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,GAAA;AAAA,MAKA,KAAA,EAAK,IAAA;AAAA,MACL,IAAA,EAAK,OAAA;AAAA,MACL,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,cAAA;AAAA,MACV,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"field.js","sourcesContent":["'use client'\n\nimport { Field as FieldPrimitive } from '@base-ui/react/field'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Label } from '../components/label.js'\nimport { Separator } from '../components/separator.js'\nimport { cn } from '../lib/utils.js'\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Base UI Field\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// `Field`, `FieldLabel`, `FieldDescription`, and `FieldError` wrap Base UI's\n// Field primitive (@base-ui/react/field). Base UI owns the accessible wiring:\n// the label is associated with the control, and any description/error ids are\n// added to the control's `aria-describedby` automatically — no manual\n// `htmlFor` / `aria-describedby` / `aria-invalid` plumbing required. Set\n// `invalid` on `Field` (e.g. from react-hook-form) and the control receives\n// `aria-invalid` and the wrapper gets `data-invalid` for free.\n//\n// Base UI's Field parts must live inside a `Field.Root`. To keep the previous\n// behaviour where a label/description/error could also be used standalone\n// (e.g. a group-level FieldDescription directly inside a FieldSet), FieldLabel/\n// FieldDescription/FieldError opt into the Base UI part only when they detect a\n// surrounding `Field` (via `InsideFieldContext`) and otherwise render the plain\n// element they did before. Inside a Field they gain the automatic association;\n// outside one they are unchanged.\n//\n// `FieldSet` / `FieldLegend` stay native `<fieldset>` / `<legend>` (already\n// accessible for grouping); `FieldGroup` / `FieldContent` / `FieldSeparator` /\n// `FieldTitle` remain layout-only primitives.\n//\n// ─────────────────────────────────────────────────────────────────────────────\n// Typography hierarchy (deliberate, do not collapse to a single size)\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// FieldLabel inherits its font-size from the Label primitive (`text-base/\n// relaxed` = 16px) — the primary form text users read when scanning a form,\n// kept at the 16px ideal for body copy.\n// Every supporting element in this file uses `text-sm/relaxed` (14px). That\n// is below the 16px body-copy ideal but comfortably above the 12px floor\n// older versions used, so it still reads clearly as secondary information.\n// The 16/14 gap is intentional: it preserves a scannable visual hierarchy\n// (label > description / error / metadata) without shrinking supporting text\n// back down to the previous 12px.\n//\n// If you find yourself wanting to bump these to text-base, do it in\n// `label.tsx` so FieldLabel moves with the family. If you want to drop\n// them to text-xs, please raise that as a design decision — 12px is below\n// the NSW Government digital service standards minimum body-text size.\n// ─────────────────────────────────────────────────────────────────────────────\n\n// True for descendants of our <Field> (which renders Base UI's Field.Root).\nconst InsideFieldContext = React.createContext(false)\n\nfunction FieldSet({\n className,\n ref,\n ...props\n}: React.ComponentProps<'fieldset'>) {\n return (\n <fieldset\n ref={ref}\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ref,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n return (\n <legend\n ref={ref}\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn(\n 'mb-2 font-medium data-[variant=label]:text-sm/relaxed data-[variant=legend]:text-sm',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot=\"field-group\"\n className={cn(\n // `has-[>[data-slot=…]]:gap-3` matches when FieldGroup CONTAINS a\n // checkbox/radio group child. The original `data-[slot=checkbox-group]:gap-3`\n // was self-referential (this element's slot is `field-group`) and\n // could never apply. Mirrors the rule on FieldSet above.\n 'group/field-group @container/field-group flex w-full flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 *:data-[slot=field-group]:gap-4',\n className\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n // `data-invalid:` (presence) matches the `data-invalid` attribute Base UI's\n // Field.Root sets when the field is invalid (via the `invalid` prop or native\n // validation) — replacing the old hand-set `data-[invalid=true]`.\n 'group/field flex w-full gap-2 data-invalid:text-destructive',\n {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n }\n)\n\nfunction Field({\n className,\n orientation = 'vertical',\n ref,\n children,\n ...props\n}: React.ComponentProps<typeof FieldPrimitive.Root> &\n VariantProps<typeof fieldVariants>) {\n return (\n <FieldPrimitive.Root\n ref={ref}\n // Preserve the explicit group role + data-orientation the layout and the\n // accessibility tests rely on; Base UI's Root renders a bare <div>.\n role=\"group\"\n data-slot=\"field\"\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n >\n <InsideFieldContext.Provider value={true}>\n {children}\n </InsideFieldContext.Provider>\n </FieldPrimitive.Root>\n )\n}\n\nfunction FieldContent({\n className,\n ref,\n ...props\n}: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot=\"field-content\"\n className={cn(\n 'group/field-content flex flex-1 flex-col gap-0.5 leading-snug',\n className\n )}\n {...props}\n />\n )\n}\n\nconst fieldLabelClassName = cn(\n 'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-disabled/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col'\n)\n\nfunction FieldLabel({\n className,\n ref,\n ...props\n}: React.ComponentProps<typeof Label>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (no surrounding Field): render the styled Label directly, as\n // before. Base UI's Field.Label would throw without a Field.Root ancestor.\n if (!insideField) {\n return (\n <Label\n ref={ref}\n data-slot=\"field-label\"\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Label\n // Base UI's Field.Label types its ref as HTMLElement (it can render a\n // non-label); here it always renders our <Label>, so the ref is an\n // HTMLLabelElement at runtime.\n ref={ref as React.Ref<HTMLElement>}\n // Render through our styled Label so FieldLabel keeps the Label\n // primitive's typography + data-slot, while Base UI supplies the\n // automatic `htmlFor` association with the field control.\n render={<Label />}\n data-slot=\"field-label\"\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldTitle({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot=\"field-label\"\n className={cn(\n 'flex w-fit items-center gap-2 text-sm/relaxed font-medium group-data-disabled/field:opacity-50',\n className\n )}\n {...props}\n />\n )\n}\n\nconst fieldDescriptionClassName = cn(\n // `group-data-[orientation=horizontal]/field:` matches the\n // `data-orientation=\"horizontal\"` attribute Field emits.\n 'text-start text-sm/relaxed leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary'\n)\n\nfunction FieldDescription({\n className,\n ref,\n ...props\n}: React.ComponentProps<'p'>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (e.g. a group-level description inside a FieldSet): a plain\n // <p>, as before. Inside a Field, Base UI links it to the control via\n // aria-describedby.\n if (!insideField) {\n return (\n <p\n ref={ref}\n data-slot=\"field-description\"\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Description\n ref={ref}\n data-slot=\"field-description\"\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({\n children,\n className,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n children?: React.ReactNode\n}) {\n return (\n <div\n ref={ref}\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn(\n 'relative -my-2 h-5 text-sm/relaxed group-data-[variant=outline]/field-group:-mb-2',\n className\n )}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"relative mx-auto block w-fit bg-background px-2 text-muted-foreground\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const insideField = React.useContext(InsideFieldContext)\n\n const content = React.useMemo(() => {\n if (children) {\n return children\n }\n\n if (!errors?.length) {\n return null\n }\n\n const uniqueErrors = [\n ...new Map(errors.map((error) => [error?.message, error])).values(),\n ]\n\n if (uniqueErrors?.length === 1) {\n return uniqueErrors[0]?.message\n }\n\n return (\n <ul className=\"ms-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map(\n (error, index) =>\n error?.message && <li key={index}>{error.message}</li>\n )}\n </ul>\n )\n }, [children, errors])\n\n if (!content) {\n return null\n }\n\n const errorClassName = cn(\n 'text-sm/relaxed font-normal text-destructive',\n className\n )\n\n // Standalone: a plain alert region, as before. Inside a Field, Base UI links\n // it to the control via aria-describedby.\n if (!insideField) {\n return (\n <div\n ref={ref}\n role=\"alert\"\n data-slot=\"field-error\"\n className={errorClassName}\n {...props}\n >\n {content}\n </div>\n )\n }\n\n return (\n <FieldPrimitive.Error\n ref={ref}\n // `match` lets the `errors` array / external library drive visibility\n // instead of the control's native ValidityState. We only render this when\n // there IS content, so force it visible; Base UI then adds its id to the\n // control's `aria-describedby`.\n match\n role=\"alert\"\n data-slot=\"field-error\"\n className={errorClassName}\n {...props}\n >\n {content}\n </FieldPrimitive.Error>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n}\n\n// Derived prop types — exact component props for consumers wrapping these.\nexport type FieldProps = React.ComponentProps<typeof Field>\nexport type FieldSetProps = React.ComponentProps<typeof FieldSet>\nexport type FieldLegendProps = React.ComponentProps<typeof FieldLegend>\nexport type FieldGroupProps = React.ComponentProps<typeof FieldGroup>\nexport type FieldContentProps = React.ComponentProps<typeof FieldContent>\nexport type FieldLabelProps = React.ComponentProps<typeof FieldLabel>\nexport type FieldTitleProps = React.ComponentProps<typeof FieldTitle>\nexport type FieldDescriptionProps = React.ComponentProps<\n typeof FieldDescription\n>\nexport type FieldSeparatorProps = React.ComponentProps<typeof FieldSeparator>\nexport type FieldErrorProps = React.ComponentProps<typeof FieldError>\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/field.tsx"],"names":["FieldPrimitive"],"mappings":";;;;;;;;AAuDA,MAAM,kBAAA,GAAqB,KAAA,CAAM,aAAA,CAAc,KAAK,CAAA;AAEpD,SAAS,SAAS,EAAE,SAAA,EAAW,GAAA,EAAK,G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OAAO,YAAA,CAAa,CAAC,CAAA,EAAG,OAAA;AAAA,IAC1B;AAEA,IAAA,2BACG,IAAA,EAAA,EAAG,SAAA,EAAU,oCAAA,EACX,QAAA,EAAA,YAAA,CAAa,IAAI,CAAC,KAAA,EAAO,KAAA,KAAU,KAAA,EAAO,2BAAW,GAAA,CAAC,IAAA,EAAA,EAAgB,gBAAM,OAAA,EAAA,EAAd,KAAsB,CAAK,CAAA,EAC5F,CAAA;AAAA,EAEJ,CAAA,EAAG,CAAC,QAAA,EAAU,MAAM,CAAC,CAAA;AAErB,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,cAAA,GAAiB,EAAA,CAAG,8CAAA,EAAgD,SAAS,CAAA;AAInF,EAAA,IAAI,CAAC,WAAA,EAAa;AAChB,IAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,GAAA,EAAU,IAAA,EAAK,OAAA,EAAQ,WAAA,EAAU,aAAA,EAAc,SAAA,EAAW,cAAA,EAAiB,GAAG,KAAA,EAChF,QAAA,EAAA,OAAA,EACH,CAAA;AAAA,EAEJ;AAEA,EAAA,uBACE,GAAA;AAAA,IAACA,OAAA,CAAe,KAAA;AAAA,IAAf;AAAA,MACC,GAAA;AAAA,MAKA,KAAA,EAAK,IAAA;AAAA,MACL,IAAA,EAAK,OAAA;AAAA,MACL,WAAA,EAAU,aAAA;AAAA,MACV,SAAA,EAAW,cAAA;AAAA,MACV,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"field.js","sourcesContent":["'use client'\n\nimport { Field as FieldPrimitive } from '@base-ui/react/field'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { Label } from '../components/label.js'\nimport { Separator } from '../components/separator.js'\nimport { cn } from '../lib/utils.js'\n\n// ─────────────────────────────────────────────────────────────────────────────\n// Base UI Field\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// `Field`, `FieldLabel`, `FieldDescription`, and `FieldError` wrap Base UI's\n// Field primitive (@base-ui/react/field). Base UI owns the accessible wiring:\n// the label is associated with the control, and any description/error ids are\n// added to the control's `aria-describedby` automatically — no manual\n// `htmlFor` / `aria-describedby` / `aria-invalid` plumbing required. Set\n// `invalid` on `Field` (e.g. from react-hook-form) and the control receives\n// `aria-invalid` and the wrapper gets `data-invalid` for free.\n//\n// Base UI's Field parts must live inside a `Field.Root`. To keep the previous\n// behaviour where a label/description/error could also be used standalone\n// (e.g. a group-level FieldDescription directly inside a FieldSet), FieldLabel/\n// FieldDescription/FieldError opt into the Base UI part only when they detect a\n// surrounding `Field` (via `InsideFieldContext`) and otherwise render the plain\n// element they did before. Inside a Field they gain the automatic association;\n// outside one they are unchanged.\n//\n// `FieldSet` / `FieldLegend` stay native `<fieldset>` / `<legend>` (already\n// accessible for grouping); `FieldGroup` / `FieldContent` / `FieldSeparator` /\n// `FieldTitle` remain layout-only primitives.\n//\n// ─────────────────────────────────────────────────────────────────────────────\n// Typography hierarchy (deliberate, do not collapse to a single size)\n// ─────────────────────────────────────────────────────────────────────────────\n//\n// FieldLabel inherits its font-size from the Label primitive (`text-base/\n// relaxed` = 16px) — the primary form text users read when scanning a form,\n// kept at the 16px ideal for body copy.\n// Every supporting element in this file uses `text-sm/relaxed` (14px). That\n// is below the 16px body-copy ideal but comfortably above the 12px floor\n// older versions used, so it still reads clearly as secondary information.\n// The 16/14 gap is intentional: it preserves a scannable visual hierarchy\n// (label > description / error / metadata) without shrinking supporting text\n// back down to the previous 12px.\n//\n// If you find yourself wanting to bump these to text-base, do it in\n// `label.tsx` so FieldLabel moves with the family. If you want to drop\n// them to text-xs, please raise that as a design decision — 12px is below\n// the NSW Government digital service standards minimum body-text size.\n// ─────────────────────────────────────────────────────────────────────────────\n\n// True for descendants of our <Field> (which renders Base UI's Field.Root).\nconst InsideFieldContext = React.createContext(false)\n\nfunction FieldSet({ className, ref, ...props }: React.ComponentProps<'fieldset'>) {\n return (\n <fieldset\n ref={ref}\n data-slot='field-set'\n className={cn(\n 'flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({\n className,\n variant = 'legend',\n ref,\n ...props\n}: React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }) {\n return (\n <legend\n ref={ref}\n data-slot='field-legend'\n data-variant={variant}\n className={cn(\n 'mb-2 font-medium data-[variant=label]:text-sm/relaxed data-[variant=legend]:text-sm',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-group'\n className={cn(\n // `has-[>[data-slot=…]]:gap-3` matches when FieldGroup CONTAINS a\n // checkbox/radio group child. The original `data-[slot=checkbox-group]:gap-3`\n // was self-referential (this element's slot is `field-group`) and\n // could never apply. Mirrors the rule on FieldSet above.\n 'group/field-group @container/field-group flex w-full flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 *:data-[slot=field-group]:gap-4',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva(\n // `data-invalid:` (presence) matches the `data-invalid` attribute Base UI's\n // Field.Root sets when the field is invalid (via the `invalid` prop or native\n // validation) — replacing the old hand-set `data-[invalid=true]`.\n 'group/field flex w-full gap-2 data-invalid:text-destructive',\n {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n },\n },\n defaultVariants: {\n orientation: 'vertical',\n },\n },\n)\n\nfunction Field({\n className,\n orientation = 'vertical',\n ref,\n children,\n ...props\n}: React.ComponentProps<typeof FieldPrimitive.Root> & VariantProps<typeof fieldVariants>) {\n return (\n <FieldPrimitive.Root\n ref={ref}\n // Preserve the explicit group role + data-orientation the layout and the\n // accessibility tests rely on; Base UI's Root renders a bare <div>.\n role='group'\n data-slot='field'\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n >\n <InsideFieldContext.Provider value={true}>{children}</InsideFieldContext.Provider>\n </FieldPrimitive.Root>\n )\n}\n\nfunction FieldContent({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-content'\n className={cn('group/field-content flex flex-1 flex-col gap-0.5 leading-snug', className)}\n {...props}\n />\n )\n}\n\nconst fieldLabelClassName = cn(\n 'group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-disabled/field:opacity-50 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-2 dark:has-data-checked:bg-primary/10',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',\n)\n\nfunction FieldLabel({ className, ref, ...props }: React.ComponentProps<typeof Label>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (no surrounding Field): render the styled Label directly, as\n // before. Base UI's Field.Label would throw without a Field.Root ancestor.\n if (!insideField) {\n return (\n <Label\n ref={ref}\n data-slot='field-label'\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Label\n // Base UI's Field.Label types its ref as HTMLElement (it can render a\n // non-label); here it always renders our <Label>, so the ref is an\n // HTMLLabelElement at runtime.\n ref={ref as React.Ref<HTMLElement>}\n // Render through our styled Label so FieldLabel keeps the Label\n // primitive's typography + data-slot, while Base UI supplies the\n // automatic `htmlFor` association with the field control.\n render={<Label />}\n data-slot='field-label'\n className={cn(fieldLabelClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldTitle({ className, ref, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n ref={ref}\n data-slot='field-label'\n className={cn(\n 'flex w-fit items-center gap-2 text-sm/relaxed font-medium group-data-disabled/field:opacity-50',\n className,\n )}\n {...props}\n />\n )\n}\n\nconst fieldDescriptionClassName = cn(\n // `group-data-[orientation=horizontal]/field:` matches the\n // `data-orientation=\"horizontal\"` attribute Field emits.\n 'text-start text-sm/relaxed leading-normal font-normal text-muted-foreground group-data-[orientation=horizontal]/field:text-balance [[data-variant=legend]+&]:-mt-1.5',\n 'last:mt-0 nth-last-2:-mt-1',\n '[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',\n)\n\nfunction FieldDescription({ className, ref, ...props }: React.ComponentProps<'p'>) {\n const insideField = React.useContext(InsideFieldContext)\n\n // Standalone (e.g. a group-level description inside a FieldSet): a plain\n // <p>, as before. Inside a Field, Base UI links it to the control via\n // aria-describedby.\n if (!insideField) {\n return (\n <p\n ref={ref}\n data-slot='field-description'\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n }\n\n return (\n <FieldPrimitive.Description\n ref={ref}\n data-slot='field-description'\n className={cn(fieldDescriptionClassName, className)}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({\n children,\n className,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n children?: React.ReactNode\n}) {\n return (\n <div\n ref={ref}\n data-slot='field-separator'\n data-content={!!children}\n className={cn(\n 'relative -my-2 h-5 text-sm/relaxed group-data-[variant=outline]/field-group:-mb-2',\n className,\n )}\n {...props}\n >\n <Separator className='absolute inset-0 top-1/2' />\n {children && (\n <span\n className='relative mx-auto block w-fit bg-background px-2 text-muted-foreground'\n data-slot='field-separator-content'\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({\n className,\n children,\n errors,\n ref,\n ...props\n}: React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}) {\n const insideField = React.useContext(InsideFieldContext)\n\n const content = React.useMemo(() => {\n if (children) {\n return children\n }\n\n if (!errors?.length) {\n return null\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]\n\n if (uniqueErrors?.length === 1) {\n return uniqueErrors[0]?.message\n }\n\n return (\n <ul className='ms-4 flex list-disc flex-col gap-1'>\n {uniqueErrors.map((error, index) => error?.message && <li key={index}>{error.message}</li>)}\n </ul>\n )\n }, [children, errors])\n\n if (!content) {\n return null\n }\n\n const errorClassName = cn('text-sm/relaxed font-normal text-destructive', className)\n\n // Standalone: a plain alert region, as before. Inside a Field, Base UI links\n // it to the control via aria-describedby.\n if (!insideField) {\n return (\n <div ref={ref} role='alert' data-slot='field-error' className={errorClassName} {...props}>\n {content}\n </div>\n )\n }\n\n return (\n <FieldPrimitive.Error\n ref={ref}\n // `match` lets the `errors` array / external library drive visibility\n // instead of the control's native ValidityState. We only render this when\n // there IS content, so force it visible; Base UI then adds its id to the\n // control's `aria-describedby`.\n match\n role='alert'\n data-slot='field-error'\n className={errorClassName}\n {...props}\n >\n {content}\n </FieldPrimitive.Error>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n}\n\n// Derived prop types — exact component props for consumers wrapping these.\nexport type FieldProps = React.ComponentProps<typeof Field>\nexport type FieldSetProps = React.ComponentProps<typeof FieldSet>\nexport type FieldLegendProps = React.ComponentProps<typeof FieldLegend>\nexport type FieldGroupProps = React.ComponentProps<typeof FieldGroup>\nexport type FieldContentProps = React.ComponentProps<typeof FieldContent>\nexport type FieldLabelProps = React.ComponentProps<typeof FieldLabel>\nexport type FieldTitleProps = React.ComponentProps<typeof FieldTitle>\nexport type FieldDescriptionProps = React.ComponentProps<typeof FieldDescription>\nexport type FieldSeparatorProps = React.ComponentProps<typeof FieldSeparator>\nexport type FieldErrorProps = React.ComponentProps<typeof FieldError>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/hover-card.tsx"],"names":["PreviewCardPrimitive"],"mappings":";;;;AAMA,SAAS,SAAA,CAAU,EAAE,GAAG,KAAA,EAAM,EAAoC;AAChE,EAAA,2BAAQA,WAAA,CAAqB,IAAA,EAArB,EAA0B,WAAA,EAAU,YAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SAAS,gBAAA,CAAiB,EAAE,GAAG,KAAA,EAAM,EAAuC;AAC1E,EAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/hover-card.tsx"],"names":["PreviewCardPrimitive"],"mappings":";;;;AAMA,SAAS,SAAA,CAAU,EAAE,GAAG,KAAA,EAAM,EAAoC;AAChE,EAAA,2BAAQA,WAAA,CAAqB,IAAA,EAArB,EAA0B,WAAA,EAAU,YAAA,EAAc,GAAG,KAAA,EAAO,CAAA;AACtE;AAEA,SAAS,gBAAA,CAAiB,EAAE,GAAG,KAAA,EAAM,EAAuC;AAC1E,EAAA,2BAAQA,WAAA,CAAqB,OAAA,EAArB,EAA6B,WAAA,EAAU,oBAAA,EAAsB,GAAG,KAAA,EAAO,CAAA;AACjF;AAEA,SAAS,gBAAA,CAAiB;AAAA,EACxB,SAAA;AAAA,EACA,IAAA,GAAO,QAAA;AAAA,EACP,UAAA,GAAa,CAAA;AAAA,EACb,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc,CAAA;AAAA,EACd,GAAG;AACL,CAAA,EACgG;AAC9F,EAAA,uBACE,GAAA,CAACA,WAAA,CAAqB,MAAA,EAArB,EAA4B,aAAU,mBAAA,EACrC,QAAA,kBAAA,GAAA;AAAA,IAACA,WAAA,CAAqB,UAAA;AAAA,IAArB;AAAA,MACC,KAAA;AAAA,MACA,WAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAA;AAAA,MACA,SAAA,EAAU,cAAA;AAAA,MAEV,QAAA,kBAAA,GAAA;AAAA,QAACA,WAAA,CAAqB,KAAA;AAAA,QAArB;AAAA,UACC,WAAA,EAAU,oBAAA;AAAA,UACV,SAAA,EAAW,EAAA;AAAA,YACT,siBAAA;AAAA,YACA;AAAA,WACF;AAAA,UACC,GAAG;AAAA;AAAA;AACN;AAAA,GACF,EACF,CAAA;AAEJ","file":"hover-card.js","sourcesContent":["'use client'\n\nimport { PreviewCard as PreviewCardPrimitive } from '@base-ui/react/preview-card'\n\nimport { cn } from '../lib/utils.js'\n\nfunction HoverCard({ ...props }: PreviewCardPrimitive.Root.Props) {\n return <PreviewCardPrimitive.Root data-slot='hover-card' {...props} />\n}\n\nfunction HoverCardTrigger({ ...props }: PreviewCardPrimitive.Trigger.Props) {\n return <PreviewCardPrimitive.Trigger data-slot='hover-card-trigger' {...props} />\n}\n\nfunction HoverCardContent({\n className,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 4,\n ...props\n}: PreviewCardPrimitive.Popup.Props &\n Pick<PreviewCardPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {\n return (\n <PreviewCardPrimitive.Portal data-slot='hover-card-portal'>\n <PreviewCardPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className='isolate z-50'\n >\n <PreviewCardPrimitive.Popup\n data-slot='hover-card-content'\n className={cn(\n 'z-50 w-72 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-xs/relaxed text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n />\n </PreviewCardPrimitive.Positioner>\n </PreviewCardPrimitive.Portal>\n )\n}\n\nexport { HoverCard, HoverCardContent, HoverCardTrigger }\n"]}
|
package/dist/components/input.js
CHANGED
|
@@ -3,12 +3,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { Input as Input$1 } from '@base-ui/react/input';
|
|
4
4
|
import { cn } from '../lib/utils.js';
|
|
5
5
|
|
|
6
|
-
function Input({
|
|
7
|
-
className,
|
|
8
|
-
type,
|
|
9
|
-
ref,
|
|
10
|
-
...props
|
|
11
|
-
}) {
|
|
6
|
+
function Input({ className, type, ref, ...props }) {
|
|
12
7
|
return /* @__PURE__ */ jsx(
|
|
13
8
|
Input$1,
|
|
14
9
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/input.tsx"],"names":["InputPrimitive"],"mappings":";;;;AAOA,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../src/components/input.tsx"],"names":["InputPrimitive"],"mappings":";;;;AAOA,SAAS,MAAM,EAAE,SAAA,EAAW,MAAM,GAAA,EAAK,GAAG,OAAM,EAAkC;AAChF,EAAA,uBACE,GAAA;AAAA,IAACA,OAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,IAAA;AAAA,MACA,WAAA,EAAU,OAAA;AAAA,MACV,WAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA,QAIT,oGAAA;AAAA;AAAA;AAAA;AAAA,QAIA,+EAAA;AAAA;AAAA,QAEA,kCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QAKA,mHAAA;AAAA;AAAA,QAEA,0HAAA;AAAA;AAAA,QAEA,wCAAA;AAAA;AAAA,QAEA,8EAAA;AAAA;AAAA,QAEA,oLAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"input.js","sourcesContent":["'use client'\n\nimport { Input as InputPrimitive } from '@base-ui/react/input'\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Input({ className, type, ref, ...props }: React.ComponentProps<'input'>) {\n return (\n <InputPrimitive\n ref={ref}\n type={type}\n data-slot='input'\n data-type={type}\n className={cn(\n // No `outline-none` here: it sets `--tw-outline-style: none` globally\n // on the element, which then suppresses the focus outline below\n // (which reads `outline-style: var(--tw-outline-style)`).\n 'h-12 w-full min-w-0 rounded-sm px-4 py-2 text-base transition-colors motion-reduce:transition-none',\n // Every colour routes through the --input-* semantic tokens (layer 3,\n // theme.css / the registry theme item). Dark mode and brand themes\n // restyle the input by remapping tokens — no dark: variants here.\n 'border border-(--input-border) bg-(--input-surface) text-(--input-foreground)',\n // Hover\n 'hover:bg-(--input-surface-hover)',\n // Focus — `focus-visible:` per the design-system policy (matches\n // Button/Link). For text fields this is behaviour-preserving:\n // browsers flag keyboard-editable controls as :focus-visible even\n // when focused by pointer, so the ring still shows on click.\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring)',\n // File input slot\n 'file:inline-flex file:h-8 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-(--input-foreground)',\n // Placeholder styles\n 'placeholder:text-(--input-placeholder)',\n // Disabled\n 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',\n // Invalid — 2px danger border, danger hover surface (Figma error variants)\n 'aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus-visible:outline-(--input-invalid-ring)',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport { Input }\n\nexport type InputProps = React.ComponentProps<typeof Input>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/label.tsx"],"names":[],"mappings":";;;AAMA,SAAS,MAAM,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAkC;AAC1E,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,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, ref, ...props }: React.ComponentProps<'label'>) {\n return (\n <label\n ref={ref}\n data-slot
|
|
1
|
+
{"version":3,"sources":["../../src/components/label.tsx"],"names":[],"mappings":";;;AAMA,SAAS,MAAM,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAkC;AAC1E,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,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, ref, ...props }: React.ComponentProps<'label'>) {\n return (\n <label\n ref={ref}\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\nexport type LabelProps = React.ComponentProps<typeof Label>\n"]}
|
|
@@ -1 +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,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,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 ref,\n ...props\n}: React.ComponentProps<'div'> & { children?: React.ReactNode }) {\n return (\n <div\n ref={ref}\n data-slot
|
|
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,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,IAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,GAAA;AAAA,MACA,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 ref,\n ...props\n}: React.ComponentProps<'div'> & { children?: React.ReactNode }) {\n return (\n <div\n ref={ref}\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\nexport type LabeledSeparatorProps = React.ComponentProps<typeof LabeledSeparator>\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["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AC,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","file":"link.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React, { createContext, 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 motion-reduce:transition-none',\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\n/**\n * Object form of a link target, mirroring the `UrlObject` accepted by framework\n * link components such as next/link. Used for `Link`'s `href` when a custom\n * element/component is supplied via `as` / `LinkProvider`; a plain anchor still\n * takes a string.\n *\n * Fields are optional, matching next/link. Typing the *shape* — rather than the\n * previous bare `object` — rejects unrelated values like arrays and functions\n * (both carry a numeric `length`, which is incompatible with `length?: never`).\n */\ntype LinkUrlObject = {\n pathname?: string | null\n query?: string | Record<string, unknown> | null\n hash?: string | null\n search?: string | null\n host?: string | null\n hostname?: string | null\n port?: string | number | null\n protocol?: string | null\n /** Brand that excludes arrays/functions (which have a numeric `length`). */\n length?: never\n}\n\ntype LinkProps = Omit<React.ComponentPropsWithoutRef<'a'>, 'href'> &\n VariantProps<typeof linkVariants> & {\n as?: LinkComponent\n href: React.ComponentPropsWithoutRef<'a'>['href'] | LinkUrlObject\n ref?: React.Ref<HTMLAnchorElement>\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] as const\n\nfunction Link({ as, variant, className, ref, ...props }: LinkProps) {\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 */\nfunction ExternalLink({\n children,\n icon,\n newTabLabel = '(opens in a new tab)',\n target = '_blank',\n rel = 'noopener noreferrer',\n ref,\n ...props\n}: ExternalLinkProps) {\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, LinkUrlObject }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/link.tsx"],"names":[],"mappings":";;;;;AASA,MAAM,UAAA,GAAa;AAAA;AAAA,EAEjB,6GAAA;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;AAkCD,MAAM,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AAAA,MAEJ,QAAA,kBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,qZAAA,EAAsZ;AAAA;AAAA,GACha;AAEJ;AAwBA,SAAS,YAAA,CAAa;AAAA,EACpB,QAAA;AAAA,EACA,IAAA;AAAA,EACA,WAAA,GAAc,sBAAA;AAAA,EACd,MAAA,GAAS,QAAA;AAAA,EACT,GAAA,GAAM,qBAAA;AAAA,EACN,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAsB;AACpB,EAAA,MAAM,YAAA,GAAe,SAAS,IAAA,GAAO,IAAA,GAAQ,wBAAQ,GAAA,CAAC,aAAA,EAAA,EAAc,WAAU,QAAA,EAAS,CAAA;AAEvF,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","file":"link.js","sourcesContent":["'use client'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport React, { createContext, 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 motion-reduce:transition-none',\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\n/**\n * Object form of a link target, mirroring the `UrlObject` accepted by framework\n * link components such as next/link. Used for `Link`'s `href` when a custom\n * element/component is supplied via `as` / `LinkProvider`; a plain anchor still\n * takes a string.\n *\n * Fields are optional, matching next/link. Typing the *shape* — rather than the\n * previous bare `object` — rejects unrelated values like arrays and functions\n * (both carry a numeric `length`, which is incompatible with `length?: never`).\n */\ntype LinkUrlObject = {\n pathname?: string | null\n query?: string | Record<string, unknown> | null\n hash?: string | null\n search?: string | null\n host?: string | null\n hostname?: string | null\n port?: string | number | null\n protocol?: string | null\n /** Brand that excludes arrays/functions (which have a numeric `length`). */\n length?: never\n}\n\ntype LinkProps = Omit<React.ComponentPropsWithoutRef<'a'>, 'href'> &\n VariantProps<typeof linkVariants> & {\n as?: LinkComponent\n href: React.ComponentPropsWithoutRef<'a'>['href'] | LinkUrlObject\n ref?: React.Ref<HTMLAnchorElement>\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 <LinkComponentContext.Provider value={component}>{children}</LinkComponentContext.Provider>\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] as const\n\nfunction Link({ as, variant, className, ref, ...props }: LinkProps) {\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 = 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 */\nfunction ExternalLink({\n children,\n icon,\n newTabLabel = '(opens in a new tab)',\n target = '_blank',\n rel = 'noopener noreferrer',\n ref,\n ...props\n}: ExternalLinkProps) {\n const trailingIcon = 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, LinkUrlObject }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/logo.tsx"],"names":[],"mappings":";;;AAQO,SAAS,KAAK,EAAE,QAAA,GAAW,WAAW,GAAA,EAAK,GAAG,OAAM,EAAc;AACvE,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA,gBAAA,EAAc,CAAA;AAAA,oBACxC,IAAA,CAAC,SAAI,GAAA,EAAU,OAAA,EAAQ,eAAc,aAAA,EAAY,MAAA,EAAQ,GAAG,KAAA,EAC1D,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,QAAA,EAAS,SAAA;AAAA,UACT,QAAA,EAAS,SAAA;AAAA,UACT,CAAA,EAAE,8tFAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YACT,aAAa,SAAA,IAAa,mCAAA;AAAA,YAAA,CACzB,QAAA,KAAa,UAAA,IAAc,QAAA,KAAa,YAAA,KACvC,YAAA;AAAA,YACF,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA,OACF;AAAA,sBAEA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,QAAA,EAAS,SAAA;AAAA,UACT,QAAA,EAAS,SAAA;AAAA,UACT,CAAA,EAAE,gmDAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YACT,aAAa,SAAA,IAAa,mCAAA;AAAA,YAAA,CACzB,QAAA,KAAa,UAAA,IAAc,QAAA,KAAa,YAAA,KACvC,YAAA;AAAA,YACF,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA,OACF;AAAA,sBAEA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,CAAA,EAAE,4iFAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YAAA,CACR,QAAA,KAAa,SAAA,IAAa,QAAA,KAAa,UAAA,KACtC,kCAAA;AAAA,YACF,aAAa,YAAA,IAAgB,YAAA;AAAA,YAC7B,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA,OACF;AAAA,sBAEA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,CAAA,EAAE,ueAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YAAA,CACR,QAAA,KAAa,SAAA,IAAa,QAAA,KAAa,UAAA,KACtC,kCAAA;AAAA,YACF,aAAa,YAAA,IAAgB,YAAA;AAAA,YAC7B,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA;AACF,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"logo.js","sourcesContent":["import clsx from 'clsx'\nimport type { ComponentPropsWithoutRef, Ref } from 'react'\n\ntype LogoProps = ComponentPropsWithoutRef<'svg'> & {\n logoType?: 'default' | 'reversed' | 'mono-white' | 'mono-black'\n ref?: Ref<SVGSVGElement>\n}\n\nexport function Logo({ logoType = 'default', ref, ...props }: LogoProps) {\n return (\n <>\n <span className=\"sr-only\">NSW Government</span>\n <svg ref={ref} viewBox=\"0 0 259 280\" aria-hidden=\"true\" {...props}>\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M24.208 270.207h-5.045v-4.277l11.15.054v13.676H26.08v-2.491c-.266.278-.553.556-.86.833-.673.585-1.49 1.07-2.433 1.434-.96.373-2.143.564-3.513.564-2.33 0-4.385-.539-6.109-1.6-1.727-1.065-3.073-2.594-4.007-4.538-.926-1.927-1.395-4.231-1.395-6.85 0-2.657.494-4.994 1.47-6.946.971-1.96 2.363-3.498 4.132-4.571 1.768-1.065 3.849-1.604 6.183-1.604 1.515 0 2.915.245 4.156.725 1.255.485 2.36 1.157 3.273 1.985a9.61 9.61 0 0 1 2.192 2.852 8.196 8.196 0 0 1 .872 3.319l.021.435h-6.038l-.062-.339a5.22 5.22 0 0 0-.814-1.981 4.562 4.562 0 0 0-1.537-1.43c-.614-.352-1.345-.531-2.175-.531-1.005 0-1.931.261-2.741.775-.806.51-1.458 1.351-1.935 2.495-.486 1.169-.731 2.74-.731 4.679 0 1.579.162 2.897.482 3.925.311 1.011.739 1.819 1.266 2.403.523.581 1.117.991 1.773 1.219a6.036 6.036 0 0 0 2.089.369c.669 0 1.27-.112 1.79-.328.523-.224.98-.514 1.354-.866.377-.356.676-.746.884-1.152.216-.41.349-.816.399-1.21l.14-1.028Zm20.878-16.312c2.354 0 4.435.534 6.179 1.587 1.752 1.061 3.13 2.59 4.086 4.546.947 1.935 1.428 4.281 1.428 6.967 0 2.648-.473 4.969-1.412 6.9-.946 1.948-2.317 3.469-4.073 4.521-1.744 1.053-3.837 1.583-6.212 1.583-2.396 0-4.502-.534-6.254-1.583-1.753-1.044-3.135-2.557-4.099-4.505-.947-1.927-1.428-4.252-1.428-6.912 0-2.673.486-5.015 1.449-6.954.968-1.956 2.355-3.486 4.12-4.551 1.764-1.061 3.853-1.599 6.216-1.599Zm0 21.185c1.117 0 2.093-.265 2.898-.787.802-.523 1.433-1.372 1.881-2.516.453-1.185.686-2.772.686-4.712 0-1.993-.237-3.618-.698-4.832-.444-1.181-1.08-2.056-1.885-2.603-.814-.543-1.782-.82-2.878-.82-1.1 0-2.072.277-2.886.82-.81.543-1.453 1.422-1.906 2.611-.47 1.223-.706 2.843-.706 4.82 0 1.944.237 3.531.702 4.712.452 1.148 1.092 1.997 1.902 2.515.81.527 1.781.792 2.89.792Zm23.764-2.93-6.162-17.829H57.09l8.654 25.251h6.195l8.73-25.251h-5.607L68.85 272.15Zm30.312-2.827H88.863v5.206l12.043.016v5.027H83.103v-25.251h17.632l-.016 4.99H88.892v5.089h10.27v4.923Zm22.482-1.529c.685-.613 1.246-1.401 1.678-2.341.419-.933.635-2.081.635-3.419 0-1.497-.311-2.835-.93-3.983-.619-1.169-1.599-2.093-2.919-2.756-1.3-.647-2.973-.974-4.975-.974h-10.738v25.243h5.759v-9.404h4.24l3.991 9.404h6.046l-4.651-10.456c.673-.357 1.3-.8 1.864-1.314Zm-3.513-5.64c0 .999-.336 1.79-1.025 2.428-.69.63-1.649.949-2.857.949h-4.095v-6.606h4.456c1.038 0 1.873.286 2.545.875.657.576.976 1.347.976 2.354Zm15.159-7.833 10.527 15.23v-15.23h5.776v25.251h-5.086l-10.98-15.86v15.86h-5.759v-25.251h5.522Zm33.949 16.461-5.29-16.461h-7.894v25.251h5.809v-16.266l5.124 16.266h4.485l5.162-16.357v16.357h5.826v-25.251h-7.878l-5.344 16.461Zm33.727-1.459h-10.298v5.206l12.046.016v5.027h-17.806v-25.251h17.636l-.021 4.99h-11.818v5.089h10.261v4.923Zm21.494.228-10.523-15.23h-5.527v25.251h5.756v-15.86l10.979 15.86h5.087v-25.251h-5.772v15.23Zm15.586-10.004h-7.388v-5.226h20.402v5.226h-7.217v20.025h-5.797v-20.025Z\"\n className={clsx(\n logoType === 'default' && 'fill-nsw-blue-800 dark:fill-white',\n (logoType === 'reversed' || logoType === 'mono-white') &&\n 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white'\n )}\n />\n\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M146.699 209.236c-1.482-2.395-3.717-4.571-6.64-6.465-2.919-1.894-6.897-3.34-11.81-4.297l-13.678-2.814c-4.132-.891-6.981-2.043-8.468-3.419-1.449-1.343-2.184-3.129-2.184-5.309 0-1.388.316-2.652.943-3.759.623-1.111 1.528-2.093 2.687-2.922 1.166-.828 2.616-1.483 4.306-1.943 1.711-.469 3.633-.705 5.714-.705 2.74 0 5.211.361 7.346 1.078 2.109.713 3.857 1.881 5.194 3.481 1.338 1.6 2.16 3.775 2.442 6.465l.038.373h16.971l-.008-.427c-.075-4.575-1.371-8.773-3.85-12.474-2.483-3.705-6.141-6.681-10.879-8.852-4.726-2.164-10.623-3.262-17.528-3.262-5.801 0-11.117 1.011-15.805 3.009-4.7 2.002-8.475 4.89-11.212 8.587-2.749 3.717-4.12 8.164-4.078 13.224.112 6.175 1.99 11.186 5.577 14.903 3.576 3.697 8.476 6.158 14.567 7.306l13.795 2.81c2.529.502 4.825 1.16 6.823 1.96 1.96.784 3.525 1.803 4.651 3.03 1.1 1.197 1.657 2.772 1.657 4.67 0 2.114-.694 3.9-2.06 5.301-1.4 1.434-3.301 2.515-5.643 3.224-2.388.721-5.058 1.086-7.936 1.086-2.807 0-5.394-.435-7.686-1.297-2.28-.85-4.194-2.093-5.689-3.693-1.491-1.591-2.513-3.585-3.04-5.918l-.075-.327H83.846l.045.46c.407 4.045 1.666 7.629 3.738 10.659 2.068 3.009 4.717 5.545 7.873 7.551 3.148 1.993 6.677 3.514 10.494 4.513a46.33 46.33 0 0 0 11.693 1.5c6.466 0 12.2-1.019 17.046-3.034 4.867-2.022 8.717-4.807 11.449-8.276 2.753-3.493 4.148-7.476 4.148-11.848 0-2.064-.232-4.36-.697-6.822-.478-2.482-1.466-4.948-2.936-7.327ZM25.937 191.763l36.916 53.312H77.87v-79.724H61.072v51.282L25.754 165.53l-.125-.179H9.19v79.724h16.748v-53.312Zm196.637 24.577 14.388-50.987h16.457l-23.587 79.724h-13.367l-14.554-50.469-14.659 50.469h-13.147l-23.533-79.724h16.511l14.384 50.979 14.389-50.979h12.167l14.551 50.987Z\"\n className={clsx(\n logoType === 'default' && 'fill-nsw-blue-800 dark:fill-white',\n (logoType === 'reversed' || logoType === 'mono-white') &&\n 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white'\n )}\n />\n\n <path\n d=\"M122.291 145.572c-19.75-2.424-38.934 3.904-72.69-5.263-3.447-.937-4.718 2.694-2.854 5.736 9.07 14.803 54.881 3.203 75.635 1.065.906-.095.814-1.426-.091-1.538ZM208.735 140.309c-33.756 9.167-52.941 2.839-72.691 5.263-.905.112-1 1.447-.091 1.538 20.759 2.138 66.566 13.738 75.635-1.065 1.864-3.042.594-6.673-2.853-5.736ZM59.882 119.132c-6.864-10.058-12.474-21.31-16.818-33.69-13.101 3.826-26.51 9.346-40.16 16.57a5.388 5.388 0 0 0-2.902 4.67 5.38 5.38 0 0 0 2.653 4.812c26.431 15.802 52.273 24.841 76.93 26.933-7.34-4.475-14.072-11.044-19.703-19.295ZM23.059 85.513a201.529 201.529 0 0 1 17.976-6.233c-2.126-6.896-3.87-14.12-5.249-21.658-6.827-.85-13.89-1.4-21.199-1.641-.062 0-.128-.004-.19-.004a5.391 5.391 0 0 0-4.647 2.602 5.383 5.383 0 0 0-.12 5.483c4.243 7.659 8.724 14.808 13.429 21.45ZM88.005 135.572c4.099 1.807 8.293 2.818 12.358 3.029-9.953-7.12-17.773-19.192-22.278-34.58-5.805-19.81-7.745-41.666-5.83-65.247-7.832-4.936-16.32-9.557-25.46-13.85a5.428 5.428 0 0 0-5.402.43 5.396 5.396 0 0 0-2.388 4.841c2.126 34.215 10.95 62.915 26.223 85.298 6.404 9.391 14.281 16.332 22.777 20.079ZM107.488 23.577A253.323 253.323 0 0 0 92.235 6.735c-1.063-1.078-2.433-1.65-3.85-1.65-.506 0-1.017.075-1.523.224-1.923.568-3.314 2.106-3.733 4.115-1.072 5.164-3.11 15.69-4.012 26.101 7.014 4.613 13.492 9.49 19.426 14.621 2.3-8.757 5.29-17.63 8.945-26.569ZM255.42 102.007c-13.65-7.223-27.058-12.744-40.16-16.569-4.343 12.38-9.953 23.631-16.818 33.689-5.63 8.255-12.362 14.82-19.708 19.296 24.658-2.093 50.5-11.132 76.931-26.934 1.715-1.024 2.707-2.822 2.653-4.811-.045-1.99-1.133-3.734-2.898-4.671ZM235.273 85.513c4.705-6.643 9.186-13.796 13.43-21.455.963-1.74.922-3.788-.121-5.483a5.4 5.4 0 0 0-4.837-2.598c-7.309.24-14.377.796-21.199 1.641-1.375 7.539-3.123 14.762-5.249 21.658a203.803 203.803 0 0 1 17.976 6.237ZM180.247 104.025c-4.505 15.384-12.329 27.46-22.278 34.58 4.065-.211 8.263-1.227 12.358-3.034 8.496-3.746 16.373-10.688 22.777-20.075 15.273-22.383 24.097-51.082 26.223-85.297a5.394 5.394 0 0 0-2.388-4.84 5.428 5.428 0 0 0-5.402-.432c-9.14 4.29-17.628 8.91-25.46 13.85 1.915 23.582-.029 45.434-5.83 65.248ZM179.214 35.52c-.901-10.406-2.94-20.932-4.011-26.1-.416-2.01-1.811-3.547-3.733-4.115a5.39 5.39 0 0 0-1.524-.224c-1.416 0-2.787.572-3.85 1.65-5.485 5.549-10.568 11.164-15.252 16.842 3.654 8.939 6.644 17.812 8.949 26.565 5.934-5.127 12.407-10.005 19.421-14.617ZM129.144 87.229c6.64-13.092 17.246-24.829 25.21-32.243-4.372-17.779-11.104-34.55-20.397-52.097C132.998 1.078 131.195 0 129.148 0s-3.845 1.082-4.808 2.889c-9.389 17.604-16.237 35.122-20.377 52.093 8.313 7.688 19.28 20.224 25.181 32.247Z\"\n className={clsx(\n (logoType === 'default' || logoType === 'reversed') &&\n 'fill-nsw-red-600 dark:fill-white',\n logoType === 'mono-white' && 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white'\n )}\n />\n\n <path\n d=\"M153.541 133.686c6.885-4.833 13.77-13.254 18.139-24.97 8.458-22.681 9.334-47.945 8.122-65.823-15.331 10.215-39.665 31.55-47.975 54.36-3.911 10.734-5.734 25.355-2.72 33.511 1.259 3.411 3.401 5.997 6.345 7.227 4.46 1.865 11.312.456 18.089-4.305ZM125.713 95.261c-2.027-4.724-4.261-9.18-7.728-14.186-9.809-14.16-23.026-26.933-39.475-38.185-.17 2.652-2.57 31.297 5.851 59.304 6.408 21.302 17.354 29.98 23.354 33.333 6.038 3.369 11.561 4.165 18.039 2.557-6.565-8.935-5.747-27.27-.041-42.823Z\"\n className={clsx(\n (logoType === 'default' || logoType === 'reversed') &&\n 'fill-nsw-red-600 dark:fill-white',\n logoType === 'mono-white' && 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white'\n )}\n />\n </svg>\n </>\n )\n}\n\nexport type { LogoProps }\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/logo.tsx"],"names":[],"mappings":";;;AAQO,SAAS,KAAK,EAAE,QAAA,GAAW,WAAW,GAAA,EAAK,GAAG,OAAM,EAAc;AACvE,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,SAAA,EAAU,QAAA,EAAA,gBAAA,EAAc,CAAA;AAAA,oBACxC,IAAA,CAAC,SAAI,GAAA,EAAU,OAAA,EAAQ,eAAc,aAAA,EAAY,MAAA,EAAQ,GAAG,KAAA,EAC1D,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,QAAA,EAAS,SAAA;AAAA,UACT,QAAA,EAAS,SAAA;AAAA,UACT,CAAA,EAAE,8tFAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YACT,aAAa,SAAA,IAAa,mCAAA;AAAA,YAAA,CACzB,QAAA,KAAa,UAAA,IAAc,QAAA,KAAa,YAAA,KAAiB,YAAA;AAAA,YAC1D,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA,OACF;AAAA,sBAEA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,QAAA,EAAS,SAAA;AAAA,UACT,QAAA,EAAS,SAAA;AAAA,UACT,CAAA,EAAE,gmDAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YACT,aAAa,SAAA,IAAa,mCAAA;AAAA,YAAA,CACzB,QAAA,KAAa,UAAA,IAAc,QAAA,KAAa,YAAA,KAAiB,YAAA;AAAA,YAC1D,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA,OACF;AAAA,sBAEA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,CAAA,EAAE,4iFAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YAAA,CACR,QAAA,KAAa,SAAA,IAAa,QAAA,KAAa,UAAA,KACtC,kCAAA;AAAA,YACF,aAAa,YAAA,IAAgB,YAAA;AAAA,YAC7B,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA,OACF;AAAA,sBAEA,GAAA;AAAA,QAAC,MAAA;AAAA,QAAA;AAAA,UACC,CAAA,EAAE,ueAAA;AAAA,UACF,SAAA,EAAW,IAAA;AAAA,YAAA,CACR,QAAA,KAAa,SAAA,IAAa,QAAA,KAAa,UAAA,KACtC,kCAAA;AAAA,YACF,aAAa,YAAA,IAAgB,YAAA;AAAA,YAC7B,aAAa,YAAA,IAAgB;AAAA;AAC/B;AAAA;AACF,KAAA,EACF;AAAA,GAAA,EACF,CAAA;AAEJ","file":"logo.js","sourcesContent":["import clsx from 'clsx'\nimport type { ComponentPropsWithoutRef, Ref } from 'react'\n\ntype LogoProps = ComponentPropsWithoutRef<'svg'> & {\n logoType?: 'default' | 'reversed' | 'mono-white' | 'mono-black'\n ref?: Ref<SVGSVGElement>\n}\n\nexport function Logo({ logoType = 'default', ref, ...props }: LogoProps) {\n return (\n <>\n <span className='sr-only'>NSW Government</span>\n <svg ref={ref} viewBox='0 0 259 280' aria-hidden='true' {...props}>\n <path\n fillRule='evenodd'\n clipRule='evenodd'\n d='M24.208 270.207h-5.045v-4.277l11.15.054v13.676H26.08v-2.491c-.266.278-.553.556-.86.833-.673.585-1.49 1.07-2.433 1.434-.96.373-2.143.564-3.513.564-2.33 0-4.385-.539-6.109-1.6-1.727-1.065-3.073-2.594-4.007-4.538-.926-1.927-1.395-4.231-1.395-6.85 0-2.657.494-4.994 1.47-6.946.971-1.96 2.363-3.498 4.132-4.571 1.768-1.065 3.849-1.604 6.183-1.604 1.515 0 2.915.245 4.156.725 1.255.485 2.36 1.157 3.273 1.985a9.61 9.61 0 0 1 2.192 2.852 8.196 8.196 0 0 1 .872 3.319l.021.435h-6.038l-.062-.339a5.22 5.22 0 0 0-.814-1.981 4.562 4.562 0 0 0-1.537-1.43c-.614-.352-1.345-.531-2.175-.531-1.005 0-1.931.261-2.741.775-.806.51-1.458 1.351-1.935 2.495-.486 1.169-.731 2.74-.731 4.679 0 1.579.162 2.897.482 3.925.311 1.011.739 1.819 1.266 2.403.523.581 1.117.991 1.773 1.219a6.036 6.036 0 0 0 2.089.369c.669 0 1.27-.112 1.79-.328.523-.224.98-.514 1.354-.866.377-.356.676-.746.884-1.152.216-.41.349-.816.399-1.21l.14-1.028Zm20.878-16.312c2.354 0 4.435.534 6.179 1.587 1.752 1.061 3.13 2.59 4.086 4.546.947 1.935 1.428 4.281 1.428 6.967 0 2.648-.473 4.969-1.412 6.9-.946 1.948-2.317 3.469-4.073 4.521-1.744 1.053-3.837 1.583-6.212 1.583-2.396 0-4.502-.534-6.254-1.583-1.753-1.044-3.135-2.557-4.099-4.505-.947-1.927-1.428-4.252-1.428-6.912 0-2.673.486-5.015 1.449-6.954.968-1.956 2.355-3.486 4.12-4.551 1.764-1.061 3.853-1.599 6.216-1.599Zm0 21.185c1.117 0 2.093-.265 2.898-.787.802-.523 1.433-1.372 1.881-2.516.453-1.185.686-2.772.686-4.712 0-1.993-.237-3.618-.698-4.832-.444-1.181-1.08-2.056-1.885-2.603-.814-.543-1.782-.82-2.878-.82-1.1 0-2.072.277-2.886.82-.81.543-1.453 1.422-1.906 2.611-.47 1.223-.706 2.843-.706 4.82 0 1.944.237 3.531.702 4.712.452 1.148 1.092 1.997 1.902 2.515.81.527 1.781.792 2.89.792Zm23.764-2.93-6.162-17.829H57.09l8.654 25.251h6.195l8.73-25.251h-5.607L68.85 272.15Zm30.312-2.827H88.863v5.206l12.043.016v5.027H83.103v-25.251h17.632l-.016 4.99H88.892v5.089h10.27v4.923Zm22.482-1.529c.685-.613 1.246-1.401 1.678-2.341.419-.933.635-2.081.635-3.419 0-1.497-.311-2.835-.93-3.983-.619-1.169-1.599-2.093-2.919-2.756-1.3-.647-2.973-.974-4.975-.974h-10.738v25.243h5.759v-9.404h4.24l3.991 9.404h6.046l-4.651-10.456c.673-.357 1.3-.8 1.864-1.314Zm-3.513-5.64c0 .999-.336 1.79-1.025 2.428-.69.63-1.649.949-2.857.949h-4.095v-6.606h4.456c1.038 0 1.873.286 2.545.875.657.576.976 1.347.976 2.354Zm15.159-7.833 10.527 15.23v-15.23h5.776v25.251h-5.086l-10.98-15.86v15.86h-5.759v-25.251h5.522Zm33.949 16.461-5.29-16.461h-7.894v25.251h5.809v-16.266l5.124 16.266h4.485l5.162-16.357v16.357h5.826v-25.251h-7.878l-5.344 16.461Zm33.727-1.459h-10.298v5.206l12.046.016v5.027h-17.806v-25.251h17.636l-.021 4.99h-11.818v5.089h10.261v4.923Zm21.494.228-10.523-15.23h-5.527v25.251h5.756v-15.86l10.979 15.86h5.087v-25.251h-5.772v15.23Zm15.586-10.004h-7.388v-5.226h20.402v5.226h-7.217v20.025h-5.797v-20.025Z'\n className={clsx(\n logoType === 'default' && 'fill-nsw-blue-800 dark:fill-white',\n (logoType === 'reversed' || logoType === 'mono-white') && 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white',\n )}\n />\n\n <path\n fillRule='evenodd'\n clipRule='evenodd'\n d='M146.699 209.236c-1.482-2.395-3.717-4.571-6.64-6.465-2.919-1.894-6.897-3.34-11.81-4.297l-13.678-2.814c-4.132-.891-6.981-2.043-8.468-3.419-1.449-1.343-2.184-3.129-2.184-5.309 0-1.388.316-2.652.943-3.759.623-1.111 1.528-2.093 2.687-2.922 1.166-.828 2.616-1.483 4.306-1.943 1.711-.469 3.633-.705 5.714-.705 2.74 0 5.211.361 7.346 1.078 2.109.713 3.857 1.881 5.194 3.481 1.338 1.6 2.16 3.775 2.442 6.465l.038.373h16.971l-.008-.427c-.075-4.575-1.371-8.773-3.85-12.474-2.483-3.705-6.141-6.681-10.879-8.852-4.726-2.164-10.623-3.262-17.528-3.262-5.801 0-11.117 1.011-15.805 3.009-4.7 2.002-8.475 4.89-11.212 8.587-2.749 3.717-4.12 8.164-4.078 13.224.112 6.175 1.99 11.186 5.577 14.903 3.576 3.697 8.476 6.158 14.567 7.306l13.795 2.81c2.529.502 4.825 1.16 6.823 1.96 1.96.784 3.525 1.803 4.651 3.03 1.1 1.197 1.657 2.772 1.657 4.67 0 2.114-.694 3.9-2.06 5.301-1.4 1.434-3.301 2.515-5.643 3.224-2.388.721-5.058 1.086-7.936 1.086-2.807 0-5.394-.435-7.686-1.297-2.28-.85-4.194-2.093-5.689-3.693-1.491-1.591-2.513-3.585-3.04-5.918l-.075-.327H83.846l.045.46c.407 4.045 1.666 7.629 3.738 10.659 2.068 3.009 4.717 5.545 7.873 7.551 3.148 1.993 6.677 3.514 10.494 4.513a46.33 46.33 0 0 0 11.693 1.5c6.466 0 12.2-1.019 17.046-3.034 4.867-2.022 8.717-4.807 11.449-8.276 2.753-3.493 4.148-7.476 4.148-11.848 0-2.064-.232-4.36-.697-6.822-.478-2.482-1.466-4.948-2.936-7.327ZM25.937 191.763l36.916 53.312H77.87v-79.724H61.072v51.282L25.754 165.53l-.125-.179H9.19v79.724h16.748v-53.312Zm196.637 24.577 14.388-50.987h16.457l-23.587 79.724h-13.367l-14.554-50.469-14.659 50.469h-13.147l-23.533-79.724h16.511l14.384 50.979 14.389-50.979h12.167l14.551 50.987Z'\n className={clsx(\n logoType === 'default' && 'fill-nsw-blue-800 dark:fill-white',\n (logoType === 'reversed' || logoType === 'mono-white') && 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white',\n )}\n />\n\n <path\n d='M122.291 145.572c-19.75-2.424-38.934 3.904-72.69-5.263-3.447-.937-4.718 2.694-2.854 5.736 9.07 14.803 54.881 3.203 75.635 1.065.906-.095.814-1.426-.091-1.538ZM208.735 140.309c-33.756 9.167-52.941 2.839-72.691 5.263-.905.112-1 1.447-.091 1.538 20.759 2.138 66.566 13.738 75.635-1.065 1.864-3.042.594-6.673-2.853-5.736ZM59.882 119.132c-6.864-10.058-12.474-21.31-16.818-33.69-13.101 3.826-26.51 9.346-40.16 16.57a5.388 5.388 0 0 0-2.902 4.67 5.38 5.38 0 0 0 2.653 4.812c26.431 15.802 52.273 24.841 76.93 26.933-7.34-4.475-14.072-11.044-19.703-19.295ZM23.059 85.513a201.529 201.529 0 0 1 17.976-6.233c-2.126-6.896-3.87-14.12-5.249-21.658-6.827-.85-13.89-1.4-21.199-1.641-.062 0-.128-.004-.19-.004a5.391 5.391 0 0 0-4.647 2.602 5.383 5.383 0 0 0-.12 5.483c4.243 7.659 8.724 14.808 13.429 21.45ZM88.005 135.572c4.099 1.807 8.293 2.818 12.358 3.029-9.953-7.12-17.773-19.192-22.278-34.58-5.805-19.81-7.745-41.666-5.83-65.247-7.832-4.936-16.32-9.557-25.46-13.85a5.428 5.428 0 0 0-5.402.43 5.396 5.396 0 0 0-2.388 4.841c2.126 34.215 10.95 62.915 26.223 85.298 6.404 9.391 14.281 16.332 22.777 20.079ZM107.488 23.577A253.323 253.323 0 0 0 92.235 6.735c-1.063-1.078-2.433-1.65-3.85-1.65-.506 0-1.017.075-1.523.224-1.923.568-3.314 2.106-3.733 4.115-1.072 5.164-3.11 15.69-4.012 26.101 7.014 4.613 13.492 9.49 19.426 14.621 2.3-8.757 5.29-17.63 8.945-26.569ZM255.42 102.007c-13.65-7.223-27.058-12.744-40.16-16.569-4.343 12.38-9.953 23.631-16.818 33.689-5.63 8.255-12.362 14.82-19.708 19.296 24.658-2.093 50.5-11.132 76.931-26.934 1.715-1.024 2.707-2.822 2.653-4.811-.045-1.99-1.133-3.734-2.898-4.671ZM235.273 85.513c4.705-6.643 9.186-13.796 13.43-21.455.963-1.74.922-3.788-.121-5.483a5.4 5.4 0 0 0-4.837-2.598c-7.309.24-14.377.796-21.199 1.641-1.375 7.539-3.123 14.762-5.249 21.658a203.803 203.803 0 0 1 17.976 6.237ZM180.247 104.025c-4.505 15.384-12.329 27.46-22.278 34.58 4.065-.211 8.263-1.227 12.358-3.034 8.496-3.746 16.373-10.688 22.777-20.075 15.273-22.383 24.097-51.082 26.223-85.297a5.394 5.394 0 0 0-2.388-4.84 5.428 5.428 0 0 0-5.402-.432c-9.14 4.29-17.628 8.91-25.46 13.85 1.915 23.582-.029 45.434-5.83 65.248ZM179.214 35.52c-.901-10.406-2.94-20.932-4.011-26.1-.416-2.01-1.811-3.547-3.733-4.115a5.39 5.39 0 0 0-1.524-.224c-1.416 0-2.787.572-3.85 1.65-5.485 5.549-10.568 11.164-15.252 16.842 3.654 8.939 6.644 17.812 8.949 26.565 5.934-5.127 12.407-10.005 19.421-14.617ZM129.144 87.229c6.64-13.092 17.246-24.829 25.21-32.243-4.372-17.779-11.104-34.55-20.397-52.097C132.998 1.078 131.195 0 129.148 0s-3.845 1.082-4.808 2.889c-9.389 17.604-16.237 35.122-20.377 52.093 8.313 7.688 19.28 20.224 25.181 32.247Z'\n className={clsx(\n (logoType === 'default' || logoType === 'reversed') &&\n 'fill-nsw-red-600 dark:fill-white',\n logoType === 'mono-white' && 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white',\n )}\n />\n\n <path\n d='M153.541 133.686c6.885-4.833 13.77-13.254 18.139-24.97 8.458-22.681 9.334-47.945 8.122-65.823-15.331 10.215-39.665 31.55-47.975 54.36-3.911 10.734-5.734 25.355-2.72 33.511 1.259 3.411 3.401 5.997 6.345 7.227 4.46 1.865 11.312.456 18.089-4.305ZM125.713 95.261c-2.027-4.724-4.261-9.18-7.728-14.186-9.809-14.16-23.026-26.933-39.475-38.185-.17 2.652-2.57 31.297 5.851 59.304 6.408 21.302 17.354 29.98 23.354 33.333 6.038 3.369 11.561 4.165 18.039 2.557-6.565-8.935-5.747-27.27-.041-42.823Z'\n className={clsx(\n (logoType === 'default' || logoType === 'reversed') &&\n 'fill-nsw-red-600 dark:fill-white',\n logoType === 'mono-white' && 'fill-white',\n logoType === 'mono-black' && 'fill-black dark:fill-white',\n )}\n />\n </svg>\n </>\n )\n}\n\nexport type { LogoProps }\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
|
+
import { VariantProps } from 'class-variance-authority';
|
|
3
|
+
import React__default from 'react';
|
|
4
|
+
|
|
5
|
+
declare const mastheadVariants: (props?: ({
|
|
6
|
+
color?: "white" | "grey" | "light" | "dark" | null | undefined;
|
|
7
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
8
|
+
declare const mastheadContainerVariants: (props?: ({
|
|
9
|
+
container?: "fluid" | "contained" | null | undefined;
|
|
10
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
11
|
+
type MastheadProps = React__default.ComponentPropsWithoutRef<'div'> & VariantProps<typeof mastheadVariants> & VariantProps<typeof mastheadContainerVariants> & {
|
|
12
|
+
/** Classes applied to the inner width-constraining wrapper. */
|
|
13
|
+
containerClassName?: string;
|
|
14
|
+
ref?: React__default.Ref<HTMLDivElement>;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* The "A NSW Government website" strip shown above the site header on every
|
|
18
|
+
* NSW Government page. Successor to the legacy `.nsw-masthead`.
|
|
19
|
+
*
|
|
20
|
+
* - `color` selects a WCAG 2.2 AAA text/background pair (`dark` matches the
|
|
21
|
+
* legacy default, `light` matches the legacy `--light` theme).
|
|
22
|
+
* - `container` selects the inner wrapper layout: `fluid` (full-bleed,
|
|
23
|
+
* nswds-app parity) or `contained` (centred 1200px column, legacy
|
|
24
|
+
* `nsw-container` parity). Fine-tune either with the `--masthead-max-width`
|
|
25
|
+
* and `--masthead-padding-x` custom properties.
|
|
26
|
+
* - Children replace the default message; pass a `SkipLinks` sibling before
|
|
27
|
+
* the Masthead for bypass-blocks support.
|
|
28
|
+
*
|
|
29
|
+
* The default `id="nsw-masthead"` is kept for compatibility with existing
|
|
30
|
+
* shells that target it (override via the `id` prop).
|
|
31
|
+
*/
|
|
32
|
+
declare function Masthead({ className, color, container, containerClassName, children, ref, ...props }: MastheadProps): React__default.JSX.Element;
|
|
33
|
+
|
|
34
|
+
export { Masthead, type MastheadProps, mastheadContainerVariants, mastheadVariants };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { cn } from '../lib/utils.js';
|
|
4
|
+
|
|
5
|
+
const mastheadColors = {
|
|
6
|
+
// Legacy .nsw-masthead (brand dark). Deepens in dark mode, matching the
|
|
7
|
+
// original nswds-app implementation.
|
|
8
|
+
dark: "bg-primary-800 text-white dark:bg-primary-950",
|
|
9
|
+
// Legacy .nsw-masthead--light (off-white). grey-100 is the same value as
|
|
10
|
+
// the legacy --nsw-off-white (#f2f2f2).
|
|
11
|
+
light: "bg-grey-100 text-grey-900",
|
|
12
|
+
white: "bg-white text-grey-900",
|
|
13
|
+
grey: "bg-grey-800 text-white"
|
|
14
|
+
};
|
|
15
|
+
const mastheadVariants = cva("w-full text-xs", {
|
|
16
|
+
variants: {
|
|
17
|
+
color: mastheadColors
|
|
18
|
+
},
|
|
19
|
+
defaultVariants: {
|
|
20
|
+
color: "dark"
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const mastheadContainerVariants = cva(
|
|
24
|
+
[
|
|
25
|
+
"mx-auto flex w-full items-center justify-between gap-x-4 py-2",
|
|
26
|
+
// Lateral padding funnels through --masthead-padding-x so an app can
|
|
27
|
+
// retune it once (via the `style` prop or a utility class) without a new
|
|
28
|
+
// variant. Defaults reproduce the nswds-app rhythm: 16px → 24px → 48px.
|
|
29
|
+
"px-(--masthead-padding-x)",
|
|
30
|
+
"[--masthead-padding-x:--spacing(4)] sm:[--masthead-padding-x:--spacing(6)] lg:[--masthead-padding-x:--spacing(12)]"
|
|
31
|
+
],
|
|
32
|
+
{
|
|
33
|
+
variants: {
|
|
34
|
+
container: {
|
|
35
|
+
// Full-bleed (nswds-app style). --masthead-max-width is still read so
|
|
36
|
+
// a shell app can constrain the inner wrapper without switching
|
|
37
|
+
// variants (the archive/practice `#nsw-masthead > div` override).
|
|
38
|
+
fluid: "max-w-[var(--masthead-max-width,none)]",
|
|
39
|
+
// Centred content column, legacy nsw-container parity (1200px).
|
|
40
|
+
contained: "max-w-[var(--masthead-max-width,75rem)]"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
container: "fluid"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
function Masthead({
|
|
49
|
+
className,
|
|
50
|
+
color,
|
|
51
|
+
container,
|
|
52
|
+
containerClassName,
|
|
53
|
+
children,
|
|
54
|
+
ref,
|
|
55
|
+
...props
|
|
56
|
+
}) {
|
|
57
|
+
return /* @__PURE__ */ jsx(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
id: "nsw-masthead",
|
|
61
|
+
"data-slot": "masthead",
|
|
62
|
+
...props,
|
|
63
|
+
className: cn(mastheadVariants({ color }), className),
|
|
64
|
+
ref,
|
|
65
|
+
children: /* @__PURE__ */ jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
"data-slot": "masthead-container",
|
|
69
|
+
className: cn(mastheadContainerVariants({ container }), containerClassName),
|
|
70
|
+
children: children ?? "A NSW Government website"
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { Masthead, mastheadContainerVariants, mastheadVariants };
|
|
78
|
+
//# sourceMappingURL=masthead.js.map
|
|
79
|
+
//# sourceMappingURL=masthead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/masthead.tsx"],"names":[],"mappings":";;;;AAUA,MAAM,cAAA,GAAiB;AAAA;AAAA;AAAA,EAGrB,IAAA,EAAM,+CAAA;AAAA;AAAA;AAAA,EAGN,KAAA,EAAO,2BAAA;AAAA,EACP,KAAA,EAAO,wBAAA;AAAA,EACP,IAAA,EAAM;AACR,CAAA;AAEA,MAAM,gBAAA,GAAmB,IAAI,gBAAA,EAAkB;AAAA,EAC7C,QAAA,EAAU;AAAA,IACR,KAAA,EAAO;AAAA,GACT;AAAA,EACA,eAAA,EAAiB;AAAA,IACf,KAAA,EAAO;AAAA;AAEX,CAAC;AAED,MAAM,yBAAA,GAA4B,GAAA;AAAA,EAChC;AAAA,IACE,+DAAA;AAAA;AAAA;AAAA;AAAA,IAIA,2BAAA;AAAA,IACA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,SAAA,EAAW;AAAA;AAAA;AAAA;AAAA,QAIT,KAAA,EAAO,wCAAA;AAAA;AAAA,QAEP,SAAA,EAAW;AAAA;AACb,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,SAAA,EAAW;AAAA;AACb;AAEJ;AA0BA,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,KAAA;AAAA,EACA,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,QAAA;AAAA,EACA,GAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAkB;AAChB,EAAA,uBACE,GAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,EAAA,EAAG,cAAA;AAAA,MACH,WAAA,EAAU,UAAA;AAAA,MACT,GAAG,KAAA;AAAA,MACJ,WAAW,EAAA,CAAG,gBAAA,CAAiB,EAAE,KAAA,EAAO,GAAG,SAAS,CAAA;AAAA,MACpD,GAAA;AAAA,MAEA,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,WAAA,EAAU,oBAAA;AAAA,UACV,WAAW,EAAA,CAAG,yBAAA,CAA0B,EAAE,SAAA,EAAW,GAAG,kBAAkB,CAAA;AAAA,UAEzE,QAAA,EAAA,QAAA,IAAY;AAAA;AAAA;AACf;AAAA,GACF;AAEJ","file":"masthead.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\n// Colour pairs are curated for WCAG 2.2 AAA (1.4.6 Contrast Enhanced): every\n// text/background combination below resolves to at least 7:1. This is why the\n// Masthead does not accept the full Button colour palette — accent/danger/\n// warning backgrounds with white text sit under 7:1 and would silently break\n// the AAA guarantee. Add new colours only with a verified pair.\nconst mastheadColors = {\n // Legacy .nsw-masthead (brand dark). Deepens in dark mode, matching the\n // original nswds-app implementation.\n dark: 'bg-primary-800 text-white dark:bg-primary-950',\n // Legacy .nsw-masthead--light (off-white). grey-100 is the same value as\n // the legacy --nsw-off-white (#f2f2f2).\n light: 'bg-grey-100 text-grey-900',\n white: 'bg-white text-grey-900',\n grey: 'bg-grey-800 text-white',\n}\n\nconst mastheadVariants = cva('w-full text-xs', {\n variants: {\n color: mastheadColors,\n },\n defaultVariants: {\n color: 'dark',\n },\n})\n\nconst mastheadContainerVariants = cva(\n [\n 'mx-auto flex w-full items-center justify-between gap-x-4 py-2',\n // Lateral padding funnels through --masthead-padding-x so an app can\n // retune it once (via the `style` prop or a utility class) without a new\n // variant. Defaults reproduce the nswds-app rhythm: 16px → 24px → 48px.\n 'px-(--masthead-padding-x)',\n '[--masthead-padding-x:--spacing(4)] sm:[--masthead-padding-x:--spacing(6)] lg:[--masthead-padding-x:--spacing(12)]',\n ],\n {\n variants: {\n container: {\n // Full-bleed (nswds-app style). --masthead-max-width is still read so\n // a shell app can constrain the inner wrapper without switching\n // variants (the archive/practice `#nsw-masthead > div` override).\n fluid: 'max-w-[var(--masthead-max-width,none)]',\n // Centred content column, legacy nsw-container parity (1200px).\n contained: 'max-w-[var(--masthead-max-width,75rem)]',\n },\n },\n defaultVariants: {\n container: 'fluid',\n },\n },\n)\n\ntype MastheadProps = React.ComponentPropsWithoutRef<'div'> &\n VariantProps<typeof mastheadVariants> &\n VariantProps<typeof mastheadContainerVariants> & {\n /** Classes applied to the inner width-constraining wrapper. */\n containerClassName?: string\n ref?: React.Ref<HTMLDivElement>\n }\n\n/**\n * The \"A NSW Government website\" strip shown above the site header on every\n * NSW Government page. Successor to the legacy `.nsw-masthead`.\n *\n * - `color` selects a WCAG 2.2 AAA text/background pair (`dark` matches the\n * legacy default, `light` matches the legacy `--light` theme).\n * - `container` selects the inner wrapper layout: `fluid` (full-bleed,\n * nswds-app parity) or `contained` (centred 1200px column, legacy\n * `nsw-container` parity). Fine-tune either with the `--masthead-max-width`\n * and `--masthead-padding-x` custom properties.\n * - Children replace the default message; pass a `SkipLinks` sibling before\n * the Masthead for bypass-blocks support.\n *\n * The default `id=\"nsw-masthead\"` is kept for compatibility with existing\n * shells that target it (override via the `id` prop).\n */\nfunction Masthead({\n className,\n color,\n container,\n containerClassName,\n children,\n ref,\n ...props\n}: MastheadProps) {\n return (\n <div\n id='nsw-masthead'\n data-slot='masthead'\n {...props}\n className={cn(mastheadVariants({ color }), className)}\n ref={ref}\n >\n <div\n data-slot='masthead-container'\n className={cn(mastheadContainerVariants({ container }), containerClassName)}\n >\n {children ?? 'A NSW Government website'}\n </div>\n </div>\n )\n}\n\nexport { Masthead, mastheadContainerVariants, mastheadVariants }\nexport type { MastheadProps }\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/popover.tsx"],"names":["PopoverPrimitive"],"mappings":";;;;AAOA,SAAS,OAAA,CAAQ,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC1D,EAAA,2BAAQA,SAAA,CAAiB,IAAA,EAAjB,EAAsB,WAAA,EAAU,SAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AAC/D;AAEA,SAAS,cAAA,CAAe,EAAE,GAAG,KAAA,EAAM,EAAmC;AACpE,EAAA,2BAAQA,SAAA,CAAiB,OAAA,EAAjB,EAAyB,WAAA,EAAU,iBAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAC1E;AAEA,SAAS,cAAA,CAAe;AAAA,EACtB,SAAA;AAAA,EACA,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc,CAAA;AAAA,EACd,IAAA,GAAO,QAAA;AAAA,EACP,UAAA,GAAa,CAAA;AAAA,EACb,GAAG;AACL,CAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/components/popover.tsx"],"names":["PopoverPrimitive"],"mappings":";;;;AAOA,SAAS,OAAA,CAAQ,EAAE,GAAG,KAAA,EAAM,EAAgC;AAC1D,EAAA,2BAAQA,SAAA,CAAiB,IAAA,EAAjB,EAAsB,WAAA,EAAU,SAAA,EAAW,GAAG,KAAA,EAAO,CAAA;AAC/D;AAEA,SAAS,cAAA,CAAe,EAAE,GAAG,KAAA,EAAM,EAAmC;AACpE,EAAA,2BAAQA,SAAA,CAAiB,OAAA,EAAjB,EAAyB,WAAA,EAAU,iBAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAC1E;AAEA,SAAS,cAAA,CAAe;AAAA,EACtB,SAAA;AAAA,EACA,KAAA,GAAQ,QAAA;AAAA,EACR,WAAA,GAAc,CAAA;AAAA,EACd,IAAA,GAAO,QAAA;AAAA,EACP,UAAA,GAAa,CAAA;AAA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AAA,MAC/C,GAAG;AAAA;AAAA,GACN;AAEJ","file":"popover.js","sourcesContent":["'use client'\n\nimport { Popover as PopoverPrimitive } from '@base-ui/react/popover'\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Popover({ ...props }: PopoverPrimitive.Root.Props) {\n return <PopoverPrimitive.Root data-slot='popover' {...props} />\n}\n\nfunction PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {\n return <PopoverPrimitive.Trigger data-slot='popover-trigger' {...props} />\n}\n\nfunction PopoverContent({\n className,\n align = 'center',\n alignOffset = 0,\n side = 'bottom',\n sideOffset = 4,\n ...props\n}: PopoverPrimitive.Popup.Props &\n Pick<PopoverPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {\n return (\n <PopoverPrimitive.Portal>\n <PopoverPrimitive.Positioner\n align={align}\n alignOffset={alignOffset}\n side={side}\n sideOffset={sideOffset}\n className='isolate z-50'\n >\n <PopoverPrimitive.Popup\n data-slot='popover-content'\n className={cn(\n 'z-50 flex w-72 origin-(--transform-origin) flex-col gap-4 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-start-2 data-[side=inline-start]:slide-in-from-end-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n className,\n )}\n {...props}\n />\n </PopoverPrimitive.Positioner>\n </PopoverPrimitive.Portal>\n )\n}\n\nfunction PopoverHeader({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='popover-header'\n className={cn('flex flex-col gap-1 text-xs', className)}\n {...props}\n />\n )\n}\n\nfunction PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {\n return (\n <PopoverPrimitive.Title\n data-slot='popover-title'\n className={cn('text-sm font-medium', className)}\n {...props}\n />\n )\n}\n\nfunction PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props) {\n return (\n <PopoverPrimitive.Description\n data-slot='popover-description'\n className={cn('text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nexport { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger }\n"]}
|
|
@@ -3,18 +3,12 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import * as ResizablePrimitive from 'react-resizable-panels';
|
|
4
4
|
import { cn } from '../lib/utils.js';
|
|
5
5
|
|
|
6
|
-
function ResizablePanelGroup({
|
|
7
|
-
className,
|
|
8
|
-
...props
|
|
9
|
-
}) {
|
|
6
|
+
function ResizablePanelGroup({ className, ...props }) {
|
|
10
7
|
return /* @__PURE__ */ jsx(
|
|
11
8
|
ResizablePrimitive.Group,
|
|
12
9
|
{
|
|
13
10
|
"data-slot": "resizable-panel-group",
|
|
14
|
-
className: cn(
|
|
15
|
-
"flex h-full w-full aria-[orientation=vertical]:flex-col",
|
|
16
|
-
className
|
|
17
|
-
),
|
|
11
|
+
className: cn("flex h-full w-full aria-[orientation=vertical]:flex-col", className),
|
|
18
12
|
...props
|
|
19
13
|
}
|
|
20
14
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/resizable.tsx"],"names":[],"mappings":";;;;AAMA,SAAS,mBAAA,CAAoB
|
|
1
|
+
{"version":3,"sources":["../../src/components/resizable.tsx"],"names":[],"mappings":";;;;AAMA,SAAS,mBAAA,CAAoB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AACnF,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA,CAAmB,KAAA;AAAA,IAAnB;AAAA,MACC,WAAA,EAAU,uBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,yDAAA,EAA2D,SAAS,CAAA;AAAA,MACjF,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,cAAA,CAAe,EAAE,GAAG,KAAA,EAAM,EAAkC;AACnE,EAAA,2BAAQ,kBAAA,CAAmB,KAAA,EAAnB,EAAyB,WAAA,EAAU,iBAAA,EAAmB,GAAG,KAAA,EAAO,CAAA;AAC1E;AAEA,SAAS,eAAA,CAAgB;AAAA,EACvB,UAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAEG;AACD,EAAA,uBACE,GAAA;AAAA,IAAC,kBAAA,CAAmB,SAAA;AAAA,IAAnB;AAAA,MACC,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,ypBAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEH,QAAA,EAAA,UAAA,oBAAc,GAAA,CAAC,KAAA,EAAA,EAAI,SAAA,EAAU,iDAAA,EAAkD;AAAA;AAAA,GAClF;AAEJ","file":"resizable.js","sourcesContent":["'use client'\n\nimport * as ResizablePrimitive from 'react-resizable-panels'\n\nimport { cn } from '../lib/utils.js'\n\nfunction ResizablePanelGroup({ className, ...props }: ResizablePrimitive.GroupProps) {\n return (\n <ResizablePrimitive.Group\n data-slot='resizable-panel-group'\n className={cn('flex h-full w-full aria-[orientation=vertical]:flex-col', className)}\n {...props}\n />\n )\n}\n\nfunction ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {\n return <ResizablePrimitive.Panel data-slot='resizable-panel' {...props} />\n}\n\nfunction ResizableHandle({\n withHandle,\n className,\n ...props\n}: ResizablePrimitive.SeparatorProps & {\n withHandle?: boolean\n}) {\n return (\n <ResizablePrimitive.Separator\n data-slot='resizable-handle'\n className={cn(\n 'relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:start-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:start-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 rtl:after:translate-x-1/2 rtl:aria-[orientation=horizontal]:after:-translate-x-0 [&[aria-orientation=horizontal]>div]:rotate-90',\n className,\n )}\n {...props}\n >\n {withHandle && <div className='z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border' />}\n </ResizablePrimitive.Separator>\n )\n}\n\nexport { ResizableHandle, ResizablePanel, ResizablePanelGroup }\n"]}
|