@nswds/ui 8.4.1 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/button.d.ts +3 -3
- package/dist/components/callout.d.ts +2 -2
- package/dist/components/header.d.ts +1 -1
- package/dist/components/input-group.d.ts +1 -1
- package/dist/components/masthead.d.ts +1 -1
- package/dist/components/skip-link.d.ts +1 -1
- package/dist/components/switch.js +28 -2
- package/dist/components/switch.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { Link } from './link.js';
|
|
|
6
6
|
|
|
7
7
|
declare const badgeVariants: (props?: ({
|
|
8
8
|
variant?: "solid" | "soft" | "surface" | "outline" | null | undefined;
|
|
9
|
-
color?: "
|
|
9
|
+
color?: "tertiary" | "accent" | "white" | "grey" | "primary" | "secondary" | "primary/grey" | "light" | "primary/white" | null | undefined;
|
|
10
10
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
11
11
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
12
12
|
type BadgeProps = VariantProps<typeof badgeVariants> & React__default.ComponentPropsWithoutRef<'span'> & {
|
|
@@ -5,8 +5,8 @@ import React__default from 'react';
|
|
|
5
5
|
import { Link } from './link.js';
|
|
6
6
|
|
|
7
7
|
declare const buttonCva: (props?: ({
|
|
8
|
-
variant?: "
|
|
9
|
-
color?: "
|
|
8
|
+
variant?: "link" | "solid" | "soft" | "surface" | "outline" | "ghost" | null | undefined;
|
|
9
|
+
color?: "danger" | "tertiary" | "accent" | "success" | "warning" | "white" | "grey" | "primary" | "secondary" | null | undefined;
|
|
10
10
|
size?: "default" | "sm" | "lg" | "icon" | null | undefined;
|
|
11
11
|
iconOnly?: boolean | null | undefined;
|
|
12
12
|
onTint?: boolean | null | undefined;
|
|
@@ -27,7 +27,7 @@ type ButtonVariantProps = NonNullable<Parameters<typeof buttonCva>[0]>;
|
|
|
27
27
|
*/
|
|
28
28
|
declare function buttonVariants({ onTint, ...props }?: ButtonVariantProps): string;
|
|
29
29
|
declare const buttonColorCva: (props?: ({
|
|
30
|
-
color?: "
|
|
30
|
+
color?: "danger" | "tertiary" | "accent" | "success" | "warning" | "white" | "grey" | "primary" | "secondary" | null | undefined;
|
|
31
31
|
onTint?: boolean | null | undefined;
|
|
32
32
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
33
33
|
/**
|
|
@@ -25,7 +25,7 @@ type CalloutStatus = 'info' | 'success' | 'warning' | 'danger';
|
|
|
25
25
|
* drift out of step with the token library.
|
|
26
26
|
*/
|
|
27
27
|
declare const calloutVariants: (props?: ({
|
|
28
|
-
status?: "
|
|
28
|
+
status?: "danger" | "success" | "warning" | "info" | null | undefined;
|
|
29
29
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
30
30
|
type CalloutProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'title'> & VariantProps<typeof calloutVariants> & {
|
|
31
31
|
/** Optional bold lead line above the body copy. */
|
|
@@ -66,7 +66,7 @@ declare function Callout({ className, status, title, icon, children, ref, ...pro
|
|
|
66
66
|
*/
|
|
67
67
|
declare const Alert: typeof Callout;
|
|
68
68
|
declare const alertVariants: (props?: ({
|
|
69
|
-
status?: "
|
|
69
|
+
status?: "danger" | "success" | "warning" | "info" | null | undefined;
|
|
70
70
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
71
71
|
type AlertProps = CalloutProps;
|
|
72
72
|
type AlertStatus = CalloutStatus;
|
|
@@ -30,7 +30,7 @@ declare const headerColors: {
|
|
|
30
30
|
};
|
|
31
31
|
type HeaderColor = keyof typeof headerColors;
|
|
32
32
|
declare const headerVariants: (props?: ({
|
|
33
|
-
color?: "
|
|
33
|
+
color?: "white" | "grey" | "light" | "dark" | null | undefined;
|
|
34
34
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
35
35
|
declare const headerContainerVariants: (props?: ({
|
|
36
36
|
container?: "fluid" | "contained" | null | undefined;
|
|
@@ -35,7 +35,7 @@ declare function InputGroupButton({ className, type, variant, size, ...props }:
|
|
|
35
35
|
type?: 'button' | 'submit' | 'reset';
|
|
36
36
|
}): React.JSX.Element;
|
|
37
37
|
declare const inputGroupActionVariants: (props?: ({
|
|
38
|
-
variant?: "
|
|
38
|
+
variant?: "open" | "solid" | "subtle" | null | undefined;
|
|
39
39
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
40
40
|
declare function InputGroupAction({ className, type, variant, ...props }: Omit<React.ComponentProps<typeof Button>, 'size' | 'type' | 'variant'> & VariantProps<typeof inputGroupActionVariants> & {
|
|
41
41
|
type?: 'button' | 'submit' | 'reset';
|
|
@@ -10,7 +10,7 @@ declare const mastheadColors: {
|
|
|
10
10
|
};
|
|
11
11
|
type MastheadColor = keyof typeof mastheadColors;
|
|
12
12
|
declare const mastheadVariants: (props?: ({
|
|
13
|
-
color?: "
|
|
13
|
+
color?: "white" | "grey" | "light" | "dark" | null | undefined;
|
|
14
14
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
15
15
|
declare const mastheadContainerVariants: (props?: ({
|
|
16
16
|
container?: "fluid" | "contained" | null | undefined;
|
|
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
|
|
|
3
3
|
import React__default from 'react';
|
|
4
4
|
|
|
5
5
|
declare const skipLinkVariants: (props?: ({
|
|
6
|
-
color?: "
|
|
6
|
+
color?: "white" | "grey" | "light" | "dark" | null | undefined;
|
|
7
7
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
8
8
|
type SkipLinkProps = React__default.ComponentPropsWithoutRef<'a'> & VariantProps<typeof skipLinkVariants> & {
|
|
9
9
|
/** Same-page fragment target, e.g. `"#content"`. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Switch as Switch$1 } from '@base-ui/react/switch';
|
|
4
|
+
import { IconCheck } from '../icons/check.js';
|
|
4
5
|
import { cn } from '../lib/utils.js';
|
|
5
6
|
|
|
6
7
|
function Switch({
|
|
@@ -14,7 +15,25 @@ function Switch({
|
|
|
14
15
|
"data-slot": "switch",
|
|
15
16
|
"data-size": size,
|
|
16
17
|
className: cn(
|
|
17
|
-
"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-
|
|
18
|
+
"peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-(--text-default) bg-(--input-surface) motion-safe:transition-colors",
|
|
19
|
+
// Checkbox's theme bridge, so brand overrides reach both modes. The
|
|
20
|
+
// thumb reads these too: ink for the fill and tick, mark for the thumb
|
|
21
|
+
// on a selected track, off for the ring on an unselected one.
|
|
22
|
+
"[--switch-ink:var(--color-primary-800)] [--switch-mark:var(--surface-default)] [--switch-off:var(--text-default)] dark:not-data-disabled:not-aria-invalid:[--switch-ink:var(--color-primary-200)]",
|
|
23
|
+
// The padding puts the thumb 5px (sm: 4px) inside the outer edge,
|
|
24
|
+
// Checkbox's inset, and fixes its travel at the track minus both insets.
|
|
25
|
+
"data-[size=default]:h-8 data-[size=default]:w-14 data-[size=default]:px-1 data-[size=sm]:h-6 data-[size=sm]:w-10 data-[size=sm]:px-0.75",
|
|
26
|
+
// A 44px hit area without making the visible control larger. The
|
|
27
|
+
// pseudo-element sizes from the padding box, so add the border back.
|
|
28
|
+
"after:absolute after:top-1/2 after:left-1/2 after:h-11 after:w-[calc(100%+2px)] after:min-w-11 after:-translate-1/2",
|
|
29
|
+
"data-checked:border-(--switch-ink) data-checked:bg-(--switch-ink)",
|
|
30
|
+
"not-data-disabled:data-checked:hover:bg-[color-mix(in_srgb,var(--switch-ink)_88%,var(--input-surface))] not-data-disabled:data-unchecked:hover:bg-[color-mix(in_srgb,var(--switch-ink)_10%,var(--input-surface))]",
|
|
31
|
+
"focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-3 focus-visible:outline-(--switch-ink)",
|
|
32
|
+
// Input's invalid roles. The second pixel of the off border is an inset
|
|
33
|
+
// ring rather than border-2, so the thumb does not shift by a pixel.
|
|
34
|
+
"aria-invalid:not-data-disabled:[--switch-ink:var(--danger-solid)] aria-invalid:not-data-disabled:[--switch-mark:var(--white)] aria-invalid:focus-visible:outline-offset-2 aria-invalid:focus-visible:outline-(--input-invalid-ring) aria-invalid:not-data-disabled:data-unchecked:border-(--input-invalid-border) aria-invalid:not-data-disabled:data-unchecked:inset-ring aria-invalid:not-data-disabled:data-unchecked:inset-ring-(--input-invalid-border) aria-invalid:not-data-disabled:data-unchecked:hover:bg-(--input-invalid-surface-hover)",
|
|
35
|
+
// Base UI renders a span: data-disabled covers both the prop and Field.
|
|
36
|
+
"data-disabled:cursor-not-allowed data-disabled:border-(--text-subtle) data-disabled:[--switch-ink:var(--text-subtle)] data-disabled:[--switch-off:var(--text-subtle)]",
|
|
18
37
|
className
|
|
19
38
|
),
|
|
20
39
|
...props,
|
|
@@ -22,7 +41,14 @@ function Switch({
|
|
|
22
41
|
Switch$1.Thumb,
|
|
23
42
|
{
|
|
24
43
|
"data-slot": "switch-thumb",
|
|
25
|
-
className:
|
|
44
|
+
className: cn(
|
|
45
|
+
"pointer-events-none grid shrink-0 place-items-center rounded-full bg-(--input-surface) text-(--switch-ink) inset-ring-2 inset-ring-(--switch-off) motion-safe:transition-[translate,background-color,box-shadow]",
|
|
46
|
+
"group-data-[size=default]/switch:size-5.5 group-data-[size=sm]/switch:size-4 group-data-[size=default]/switch:[&>svg]:size-4.5 group-data-[size=sm]/switch:[&>svg]:size-3",
|
|
47
|
+
"not-data-disabled:data-unchecked:group-hover/switch:bg-[color-mix(in_srgb,var(--switch-ink)_10%,var(--input-surface))] group-aria-invalid/switch:not-data-disabled:data-unchecked:group-hover/switch:bg-(--input-invalid-surface-hover)",
|
|
48
|
+
"data-checked:bg-(--switch-mark) data-checked:inset-ring-0",
|
|
49
|
+
"group-data-[size=default]/switch:data-checked:translate-x-6 group-data-[size=sm]/switch:data-checked:translate-x-4 rtl:group-data-[size=default]/switch:data-checked:-translate-x-6 rtl:group-data-[size=sm]/switch:data-checked:-translate-x-4"
|
|
50
|
+
),
|
|
51
|
+
render: (thumbProps, state) => /* @__PURE__ */ jsx("span", { ...thumbProps, children: state.checked ? /* @__PURE__ */ jsx(IconCheck, { "aria-hidden": true }) : null })
|
|
26
52
|
}
|
|
27
53
|
)
|
|
28
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/switch.tsx"],"names":["SwitchPrimitive"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/switch.tsx"],"names":["SwitchPrimitive"],"mappings":";;;;;AAOA,SAAS,MAAA,CAAO;AAAA,EACd,SAAA;AAAA,EACA,IAAA,GAAO,SAAA;AAAA,EACP,GAAG;AACL,CAAA,EAEG;AACD,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,IAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,QAAA;AAAA,MACV,WAAA,EAAW,IAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,QACT,6JAAA;AAAA;AAAA;AAAA;AAAA,QAIA,mMAAA;AAAA;AAAA;AAAA,QAGA,yIAAA;AAAA;AAAA;AAAA,QAGA,qHAAA;AAAA,QACA,mEAAA;AAAA,QACA,mNAAA;AAAA,QACA,mHAAA;AAAA;AAAA;AAAA,QAGA,qhBAAA;AAAA;AAAA,QAEA,uKAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAIJ,QAAA,kBAAA,GAAA;AAAA,QAACA,QAAA,CAAgB,KAAA;AAAA,QAAhB;AAAA,UACC,WAAA,EAAU,cAAA;AAAA,UACV,SAAA,EAAW,EAAA;AAAA,YACT,kNAAA;AAAA,YACA,2KAAA;AAAA,YACA,yOAAA;AAAA,YACA,2DAAA;AAAA,YACA;AAAA,WACF;AAAA,UACA,MAAA,EAAQ,CAAC,UAAA,EAAY,KAAA,yBAClB,MAAA,EAAA,EAAM,GAAG,UAAA,EAAa,QAAA,EAAA,KAAA,CAAM,0BAAU,GAAA,CAAC,SAAA,EAAA,EAAU,aAAA,EAAW,IAAA,EAAC,IAAK,IAAA,EAAK;AAAA;AAAA;AAE5E;AAAA,GACF;AAEJ","file":"switch.js","sourcesContent":["'use client'\n\nimport { Switch as SwitchPrimitive } from '@base-ui/react/switch'\n\nimport { IconCheck } from '../icons/check.js'\nimport { cn } from '../lib/utils.js'\n\nfunction Switch({\n className,\n size = 'default',\n ...props\n}: SwitchPrimitive.Root.Props & {\n size?: 'sm' | 'default'\n}) {\n return (\n <SwitchPrimitive.Root\n data-slot='switch'\n data-size={size}\n className={cn(\n 'peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-(--text-default) bg-(--input-surface) motion-safe:transition-colors',\n // Checkbox's theme bridge, so brand overrides reach both modes. The\n // thumb reads these too: ink for the fill and tick, mark for the thumb\n // on a selected track, off for the ring on an unselected one.\n '[--switch-ink:var(--color-primary-800)] [--switch-mark:var(--surface-default)] [--switch-off:var(--text-default)] dark:not-data-disabled:not-aria-invalid:[--switch-ink:var(--color-primary-200)]',\n // The padding puts the thumb 5px (sm: 4px) inside the outer edge,\n // Checkbox's inset, and fixes its travel at the track minus both insets.\n 'data-[size=default]:h-8 data-[size=default]:w-14 data-[size=default]:px-1 data-[size=sm]:h-6 data-[size=sm]:w-10 data-[size=sm]:px-0.75',\n // A 44px hit area without making the visible control larger. The\n // pseudo-element sizes from the padding box, so add the border back.\n 'after:absolute after:top-1/2 after:left-1/2 after:h-11 after:w-[calc(100%+2px)] after:min-w-11 after:-translate-1/2',\n 'data-checked:border-(--switch-ink) data-checked:bg-(--switch-ink)',\n 'not-data-disabled:data-checked:hover:bg-[color-mix(in_srgb,var(--switch-ink)_88%,var(--input-surface))] not-data-disabled:data-unchecked:hover:bg-[color-mix(in_srgb,var(--switch-ink)_10%,var(--input-surface))]',\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-3 focus-visible:outline-(--switch-ink)',\n // Input's invalid roles. The second pixel of the off border is an inset\n // ring rather than border-2, so the thumb does not shift by a pixel.\n 'aria-invalid:not-data-disabled:[--switch-ink:var(--danger-solid)] aria-invalid:not-data-disabled:[--switch-mark:var(--white)] aria-invalid:focus-visible:outline-offset-2 aria-invalid:focus-visible:outline-(--input-invalid-ring) aria-invalid:not-data-disabled:data-unchecked:border-(--input-invalid-border) aria-invalid:not-data-disabled:data-unchecked:inset-ring aria-invalid:not-data-disabled:data-unchecked:inset-ring-(--input-invalid-border) aria-invalid:not-data-disabled:data-unchecked:hover:bg-(--input-invalid-surface-hover)',\n // Base UI renders a span: data-disabled covers both the prop and Field.\n 'data-disabled:cursor-not-allowed data-disabled:border-(--text-subtle) data-disabled:[--switch-ink:var(--text-subtle)] data-disabled:[--switch-off:var(--text-subtle)]',\n className,\n )}\n {...props}\n >\n {/* Off is a hollow ring, on is a solid thumb with a tick, so the state\n reads by shape as well as by colour and side. */}\n <SwitchPrimitive.Thumb\n data-slot='switch-thumb'\n className={cn(\n 'pointer-events-none grid shrink-0 place-items-center rounded-full bg-(--input-surface) text-(--switch-ink) inset-ring-2 inset-ring-(--switch-off) motion-safe:transition-[translate,background-color,box-shadow]',\n 'group-data-[size=default]/switch:size-5.5 group-data-[size=sm]/switch:size-4 group-data-[size=default]/switch:[&>svg]:size-4.5 group-data-[size=sm]/switch:[&>svg]:size-3',\n 'not-data-disabled:data-unchecked:group-hover/switch:bg-[color-mix(in_srgb,var(--switch-ink)_10%,var(--input-surface))] group-aria-invalid/switch:not-data-disabled:data-unchecked:group-hover/switch:bg-(--input-invalid-surface-hover)',\n 'data-checked:bg-(--switch-mark) data-checked:inset-ring-0',\n 'group-data-[size=default]/switch:data-checked:translate-x-6 group-data-[size=sm]/switch:data-checked:translate-x-4 rtl:group-data-[size=default]/switch:data-checked:-translate-x-6 rtl:group-data-[size=sm]/switch:data-checked:-translate-x-4',\n )}\n render={(thumbProps, state) => (\n <span {...thumbProps}>{state.checked ? <IconCheck aria-hidden /> : null}</span>\n )}\n />\n </SwitchPrimitive.Root>\n )\n}\n\nexport { Switch }\n"]}
|