@nswds/ui 9.6.0 → 9.6.2
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/accordion.js +13 -3
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/input-otp.js +4 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/native-select.js +10 -2
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/select.js +10 -2
- package/dist/components/select.js.map +1 -1
- package/dist/components/toggle.js +12 -2
- package/dist/components/toggle.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
2
2
|
import { Accordion as Accordion$1 } from '@base-ui/react/accordion';
|
|
3
3
|
import { IconExpandLess } from '../icons/expand-less.js';
|
|
4
4
|
import { IconExpandMore } from '../icons/expand-more.js';
|
|
5
|
+
import { overlayInk } from '../lib/overlay.js';
|
|
5
6
|
import { cn } from '../lib/utils.js';
|
|
6
7
|
|
|
7
8
|
function Accordion({
|
|
@@ -42,7 +43,16 @@ function AccordionTrigger({ className, children, ...props }) {
|
|
|
42
43
|
{
|
|
43
44
|
"data-slot": "accordion-trigger",
|
|
44
45
|
className: cn(
|
|
45
|
-
|
|
46
|
+
// The text, chevrons and ring are the interactive ink: primary-800
|
|
47
|
+
// in light, primary-200 in dark (DESIGN.md, The Role-Flip Rule).
|
|
48
|
+
// `text-primary` is the FILL, which brightens to blue-500 in dark —
|
|
49
|
+
// 4.34:1 on the band variant's open grey (#249). In light the two
|
|
50
|
+
// are the same colour.
|
|
51
|
+
overlayInk,
|
|
52
|
+
// `outline-hidden` + `focus-visible:outline-solid`, not
|
|
53
|
+
// `outline-none`: that sets `--tw-outline-style: none`, which
|
|
54
|
+
// `outline-2` reads, so the ring never drew (#249).
|
|
55
|
+
"group/accordion-trigger relative flex min-h-14 flex-1 items-center justify-between gap-6 px-2 py-4 text-start text-lg/snug font-semibold text-(--overlay-ink) outline-hidden transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:underline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--overlay-ink) focus-visible:outline-solid aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ms-auto **:data-[slot=accordion-trigger-icon]:size-6",
|
|
46
56
|
// Band variant: every header sits on a grey band (a Grey 01 tint, so it
|
|
47
57
|
// inverts correctly in dark mode) that deepens when hovered, focused or open.
|
|
48
58
|
// All interactive states share one shade so nothing depends on cascade order.
|
|
@@ -56,14 +66,14 @@ function AccordionTrigger({ className, children, ...props }) {
|
|
|
56
66
|
IconExpandMore,
|
|
57
67
|
{
|
|
58
68
|
"data-slot": "accordion-trigger-icon",
|
|
59
|
-
className: "pointer-events-none shrink-0 text-
|
|
69
|
+
className: "pointer-events-none shrink-0 text-(--overlay-ink) group-aria-expanded/accordion-trigger:hidden"
|
|
60
70
|
}
|
|
61
71
|
),
|
|
62
72
|
/* @__PURE__ */ jsx(
|
|
63
73
|
IconExpandLess,
|
|
64
74
|
{
|
|
65
75
|
"data-slot": "accordion-trigger-icon",
|
|
66
|
-
className: "pointer-events-none hidden shrink-0 text-
|
|
76
|
+
className: "pointer-events-none hidden shrink-0 text-(--overlay-ink) group-aria-expanded/accordion-trigger:inline group-data-[variant=accent]/accordion:text-accent-600"
|
|
67
77
|
}
|
|
68
78
|
)
|
|
69
79
|
]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/accordion.tsx"],"names":["AccordionPrimitive"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/components/accordion.tsx"],"names":["AccordionPrimitive"],"mappings":";;;;;;;AASA,SAAS,SAAA,CAAU;AAAA,EACjB,SAAA;AAAA,EACA,OAAA,GAAU,SAAA;AAAA,EACV,GAAG;AACL,CAAA,EAAmE;AACjE,EAAA,uBACE,GAAA;AAAA,IAACA,WAAA,CAAmB,IAAA;AAAA,IAAn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;AAEA,SAAS,iBAAiB,EAAE,SAAA,EAAW,QAAA,EAAU,GAAG,OAAM,EAAmC;AAC3F,EAAA,uBACE,GAAA;AAAA,IAACA,WAAA,CAAmB,KAAA;AAAA,IAAnB;AAAA,MACC,WAAA,EAAU,mBAAA;AAAA,MACV,SAAA,EAAU,0GAAA;AAAA,MACT,GAAG,KAAA;AAAA,MAEJ,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACC,SAAA,EAAW,EAAA;AAAA,YACT,uNAAA;AAAA,YACA;AAAA,WACF;AAAA,UAEC;AAAA;AAAA;AACH;AAAA,GACF;AAEJ","file":"accordion.js","sourcesContent":["import { Accordion as AccordionPrimitive } from '@base-ui/react/accordion'\n\nimport { IconExpandLess } from '../icons/expand-less.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { overlayInk } from '../lib/overlay.js'\nimport { cn } from '../lib/utils.js'\n\ntype AccordionVariant = 'default' | 'accent' | 'band'\n\nfunction Accordion({\n className,\n variant = 'default',\n ...props\n}: AccordionPrimitive.Root.Props & { variant?: AccordionVariant }) {\n return (\n <AccordionPrimitive.Root\n data-slot='accordion'\n data-variant={variant}\n className={cn('group/accordion flex w-full flex-col', className)}\n {...props}\n />\n )\n}\n\nfunction AccordionItem({ className, ...props }: AccordionPrimitive.Item.Props) {\n return (\n <AccordionPrimitive.Item\n data-slot='accordion-item'\n className={cn(\n 'border-t last:border-b',\n // Accent variant: a fine Red 02 (waratah) rule slides in on the inline-start\n // edge when the item is open. A transparent 2px border is always reserved so\n // expanding never shifts the heading.\n 'group-data-[variant=accent]/accordion:border-s-2 group-data-[variant=accent]/accordion:border-s-transparent group-data-[variant=accent]/accordion:transition-colors group-data-[variant=accent]/accordion:data-open:border-s-accent-600',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction AccordionTrigger({ className, children, ...props }: AccordionPrimitive.Trigger.Props) {\n return (\n <AccordionPrimitive.Header className='flex'>\n <AccordionPrimitive.Trigger\n data-slot='accordion-trigger'\n className={cn(\n // The text, chevrons and ring are the interactive ink: primary-800\n // in light, primary-200 in dark (DESIGN.md, The Role-Flip Rule).\n // `text-primary` is the FILL, which brightens to blue-500 in dark —\n // 4.34:1 on the band variant's open grey (#249). In light the two\n // are the same colour.\n overlayInk,\n // `outline-hidden` + `focus-visible:outline-solid`, not\n // `outline-none`: that sets `--tw-outline-style: none`, which\n // `outline-2` reads, so the ring never drew (#249).\n 'group/accordion-trigger relative flex min-h-14 flex-1 items-center justify-between gap-6 px-2 py-4 text-start text-lg/snug font-semibold text-(--overlay-ink) outline-hidden transition-colors hover:bg-muted focus-visible:bg-muted focus-visible:underline focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-(--overlay-ink) focus-visible:outline-solid aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ms-auto **:data-[slot=accordion-trigger-icon]:size-6',\n // Band variant: every header sits on a grey band (a Grey 01 tint, so it\n // inverts correctly in dark mode) that deepens when hovered, focused or open.\n // All interactive states share one shade so nothing depends on cascade order.\n 'group-data-[variant=band]/accordion:bg-foreground/10 group-data-[variant=band]/accordion:hover:bg-foreground/20 group-data-[variant=band]/accordion:focus-visible:bg-foreground/20 group-data-[variant=band]/accordion:aria-expanded:bg-foreground/20',\n className,\n )}\n {...props}\n >\n {children}\n {/* Down chevron (collapsed state) — always the trigger's ink. */}\n <IconExpandMore\n data-slot='accordion-trigger-icon'\n className='pointer-events-none shrink-0 text-(--overlay-ink) group-aria-expanded/accordion-trigger:hidden'\n />\n {/* Up chevron (expanded state) — the trigger's ink by default; turns Red 02\n in the accent variant, so the open item's icon matches its accent rule. */}\n <IconExpandLess\n data-slot='accordion-trigger-icon'\n className='pointer-events-none hidden shrink-0 text-(--overlay-ink) group-aria-expanded/accordion-trigger:inline group-data-[variant=accent]/accordion:text-accent-600'\n />\n </AccordionPrimitive.Trigger>\n </AccordionPrimitive.Header>\n )\n}\n\nfunction AccordionContent({ className, children, ...props }: AccordionPrimitive.Panel.Props) {\n return (\n <AccordionPrimitive.Panel\n data-slot='accordion-content'\n className='overflow-hidden px-2 text-base/relaxed data-open:animate-accordion-down data-closed:animate-accordion-up'\n {...props}\n >\n <div\n className={cn(\n 'h-(--accordion-panel-height) pt-3 pb-6 text-foreground data-ending-style:h-0 data-starting-style:h-0 [&_a]:text-primary [&_a]:underline [&_a]:underline-offset-4 [&_a]:hover:decoration-2 [&_p:not(:last-child)]:mb-4',\n className,\n )}\n >\n {children}\n </div>\n </AccordionPrimitive.Panel>\n )\n}\n\nexport { Accordion, AccordionContent, AccordionItem, AccordionTrigger }\nexport type { AccordionVariant }\n"]}
|
|
@@ -50,7 +50,10 @@ function InputOTPSlot({
|
|
|
50
50
|
"data-slot": "input-otp-slot",
|
|
51
51
|
"data-active": isActive,
|
|
52
52
|
className: cn(
|
|
53
|
-
|
|
53
|
+
// The slot borders are the field's only edge, so they use Input's
|
|
54
|
+
// border and surface tokens, which clear 3:1 in both modes;
|
|
55
|
+
// `border-input` was 1.34:1 light / 1.67:1 dark (#255, WCAG 1.4.11).
|
|
56
|
+
"relative flex size-7 items-center justify-center border-y border-e border-(--input-border) bg-(--input-surface) text-xs/relaxed transition-all outline-none first:rounded-s-sm first:border-s last:rounded-e-sm aria-invalid:border-destructive data-[active=true]:z-10 data-[active=true]:border-ring data-[active=true]:ring-2 data-[active=true]:ring-ring/30 data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40",
|
|
54
57
|
className
|
|
55
58
|
),
|
|
56
59
|
...props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/input-otp.tsx"],"names":[],"mappings":";;;;;;AAQA,SAAS,QAAA,CAAS;AAAA,EAChB,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,GAAG;AACL,CAAA,EAEG;AACD,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAA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,SAAA,EAAU,wDAAA;AAAA,MACV,IAAA,EAAK,WAAA;AAAA,MACJ,GAAG,KAAA;AAAA,MAEJ,8BAAC,UAAA,EAAA,EAAW;AAAA;AAAA,GACd;AAEJ","file":"input-otp.js","sourcesContent":["'use client'\n\nimport { OTPInput, OTPInputContext } from 'input-otp'\nimport * as React from 'react'\n\nimport { IconRemove } from '../icons/remove.js'\nimport { cn } from '../lib/utils.js'\n\nfunction InputOTP({\n className,\n containerClassName,\n ...props\n}: React.ComponentProps<typeof OTPInput> & {\n containerClassName?: string\n}) {\n return (\n <OTPInput\n data-slot='input-otp'\n containerClassName={cn(\n 'cn-input-otp flex items-center has-disabled:opacity-50',\n containerClassName,\n )}\n spellCheck={false}\n className={cn('disabled:cursor-not-allowed', className)}\n {...props}\n />\n )\n}\n\nfunction InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='input-otp-group'\n className={cn(\n 'flex items-center rounded-sm has-aria-invalid:border-destructive has-aria-invalid:ring-2 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nfunction InputOTPSlot({\n index,\n className,\n ...props\n}: React.ComponentProps<'div'> & {\n index: number\n}) {\n const inputOTPContext = React.useContext(OTPInputContext)\n const { char, hasFakeCaret, isActive } = inputOTPContext?.slots[index] ?? {}\n\n return (\n <div\n data-slot='input-otp-slot'\n data-active={isActive}\n className={cn(\n // The slot borders are the field's only edge, so they use Input's\n // border and surface tokens, which clear 3:1 in both modes;\n // `border-input` was 1.34:1 light / 1.67:1 dark (#255, WCAG 1.4.11).\n 'relative flex size-7 items-center justify-center border-y border-e border-(--input-border) bg-(--input-surface) text-xs/relaxed transition-all outline-none first:rounded-s-sm first:border-s last:rounded-e-sm aria-invalid:border-destructive data-[active=true]:z-10 data-[active=true]:border-ring data-[active=true]:ring-2 data-[active=true]:ring-ring/30 data-[active=true]:aria-invalid:border-destructive data-[active=true]:aria-invalid:ring-destructive/20 dark:data-[active=true]:aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n >\n {char}\n {hasFakeCaret && (\n <div className='pointer-events-none absolute inset-0 flex items-center justify-center'>\n <div className='h-4 w-px animate-caret-blink bg-foreground duration-1000' />\n </div>\n )}\n </div>\n )\n}\n\nfunction InputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {\n return (\n <div\n data-slot='input-otp-separator'\n className=\"flex items-center [&_svg:not([class*='size-'])]:size-4\"\n role='separator'\n {...props}\n >\n <IconRemove />\n </div>\n )\n}\n\nexport { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot }\n"]}
|
|
@@ -16,8 +16,16 @@ const nativeSelectVariants = cva(
|
|
|
16
16
|
variant: {
|
|
17
17
|
// Crisp field — bordered white box; matches Input and Select's default.
|
|
18
18
|
default: "border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)",
|
|
19
|
-
// Filled band —
|
|
20
|
-
|
|
19
|
+
// Filled band — a tinted surface with an underline, revealing the full
|
|
20
|
+
// border on hover. The tint is barely distinguishable from the page
|
|
21
|
+
// (1.09:1), so the underline, in the field border colour, is what
|
|
22
|
+
// identifies the control at 3:1 (#255, WCAG 1.4.11).
|
|
23
|
+
//
|
|
24
|
+
// Each side's colour is set on its own, never the `border-transparent`
|
|
25
|
+
// shorthand beside the `border-b-` longhand: the two tie on
|
|
26
|
+
// specificity, so a consumer's own Tailwind build re-emitting
|
|
27
|
+
// `border-transparent` after ours would win and erase the underline.
|
|
28
|
+
filled: "border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)"
|
|
21
29
|
},
|
|
22
30
|
size: {
|
|
23
31
|
default: "h-12 ps-4 pe-10",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/native-select.tsx"],"names":[],"mappings":";;;;;;AAOA,MAAM,oBAAA,GAAuB,GAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAM3B,8gBAA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AW,GAAG,oBAAA,CAAqB,EAAE,SAAS,UAAA,EAAY,IAAA,EAAM,OAAA,EAAS,CAAC;AAAA;AAAA,SAC5E;AAAA,wBACA,GAAA;AAAA,UAAC,cAAA;AAAA,UAAA;AAAA,YACC,SAAA,EAAU,6FAAA;AAAA,YACV,aAAA,EAAY,MAAA;AAAA,YACZ,WAAA,EAAU;AAAA;AAAA;AACZ;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,kBAAA,CAAmB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAmC;AACnF,EAAA,uBACE,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,sBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,oBAAA,CAAqB,EAAE,SAAA,EAAW,GAAG,OAAM,EAAqC;AACvF,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,wBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,+BAAA,EAAiC,SAAS,CAAA;AAAA,MACvD,GAAG;AAAA;AAAA,GACN;AAEJ","file":"native-select.js","sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst nativeSelectVariants = cva(\n // Field foundation shared with Input (input.tsx) and the Select trigger: the\n // same --input-* semantic tokens, 16px text, and an outline-based focus ring.\n // appearance-none hides the native arrow so our chevron shows; no outline-none\n // (it would suppress the focus-visible outline). Dark mode and brand themes\n // restyle via tokens, so there are no dark: variants.\n 'w-full min-w-0 appearance-none rounded-sm text-base text-(--input-foreground) select-none selection:bg-primary selection:text-primary-foreground focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed 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) motion-safe:transition-colors',\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; matches Input and Select's default.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — a tinted surface with an underline, revealing the full\n // border on hover. The tint is barely distinguishable from the page\n // (1.09:1), so the underline, in the field border colour, is what\n // identifies the control at 3:1 (#255, WCAG 1.4.11).\n //\n // Each side's colour is set on its own, never the `border-transparent`\n // shorthand beside the `border-b-` longhand: the two tie on\n // specificity, so a consumer's own Tailwind build re-emitting\n // `border-transparent` after ours would win and erase the underline.\n filled:\n 'border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 ps-4 pe-10',\n sm: 'h-10 ps-3 pe-9',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\ntype NativeSelectProps = Omit<React.ComponentProps<'select'>, 'size'> &\n VariantProps<typeof nativeSelectVariants>\n\nfunction NativeSelect({ className, variant, size, ...props }: NativeSelectProps) {\n // Resolved once (see `resolveVariant`), so cva and the four data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <div\n className={cn(\n 'group/native-select relative w-fit has-[select:disabled]:opacity-50',\n className,\n )}\n data-slot='native-select-wrapper'\n data-size={sizeway}\n data-variant={variantway}\n >\n <select\n data-slot='native-select'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attributes from the classes both derive from the resolved values.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(nativeSelectVariants({ variant: variantway, size: sizeway }))}\n />\n <IconExpandMore\n className='pointer-events-none absolute end-3 top-1/2 size-5 -translate-y-1/2 text-primary select-none'\n aria-hidden='true'\n data-slot='native-select-icon'\n />\n </div>\n )\n}\n\nfunction NativeSelectOption({ className, ...props }: React.ComponentProps<'option'>) {\n return (\n <option\n data-slot='native-select-option'\n className={cn('bg-[Canvas] text-[CanvasText]', className)}\n {...props}\n />\n )\n}\n\nfunction NativeSelectOptGroup({ className, ...props }: React.ComponentProps<'optgroup'>) {\n return (\n <optgroup\n data-slot='native-select-optgroup'\n className={cn('bg-[Canvas] text-[CanvasText]', className)}\n {...props}\n />\n )\n}\n\nexport { NativeSelect, NativeSelectOptGroup, NativeSelectOption, nativeSelectVariants }\n"]}
|
|
@@ -51,8 +51,16 @@ const selectTriggerVariants = cva(
|
|
|
51
51
|
variant: {
|
|
52
52
|
// Crisp field — bordered white box; the default, matches Input exactly.
|
|
53
53
|
default: "border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)",
|
|
54
|
-
// Filled band —
|
|
55
|
-
|
|
54
|
+
// Filled band — a tinted surface with an underline, revealing the full
|
|
55
|
+
// border on hover. The tint is barely distinguishable from the page
|
|
56
|
+
// (1.09:1), so the underline, in the field border colour, is what
|
|
57
|
+
// identifies the control at 3:1 (#255, WCAG 1.4.11).
|
|
58
|
+
//
|
|
59
|
+
// Each side's colour is set on its own, never the `border-transparent`
|
|
60
|
+
// shorthand beside the `border-b-` longhand: the two tie on
|
|
61
|
+
// specificity, so a consumer's own Tailwind build re-emitting
|
|
62
|
+
// `border-transparent` after ours would win and erase the underline.
|
|
63
|
+
filled: "border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)"
|
|
56
64
|
},
|
|
57
65
|
size: {
|
|
58
66
|
default: "h-12 px-4 py-2",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/select.tsx"],"names":["SelectPrimitive"],"mappings":";;;;;;;;;;AAaA,MAAM,SAASA,QAAA,CAAgB;AAE/B,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,u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,CAAgB,SAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,kBAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,kDAAA,EAAoD,SAAS,CAAA;AAAA,MAC1E,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,oBAAA,CAAqB;AAAA,EAC5B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAA+D;AAC7D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,aAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ;AAEA,SAAS,sBAAA,CAAuB;AAAA,EAC9B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,eAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,2BAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,6HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ","file":"select.js","sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconExpandLess } from '../icons/expand-less.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {\n return (\n <SelectPrimitive.Group\n data-slot='select-group'\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {\n return (\n <SelectPrimitive.Value\n data-slot='select-value'\n className={cn('flex flex-1 text-start', className)}\n {...props}\n />\n )\n}\n\nconst selectTriggerVariants = cva(\n // Field foundation shared with Input (input.tsx): the same --input-* semantic\n // tokens, 16px text, and an outline-based focus ring. No `outline-none` here —\n // it sets --tw-outline-style:none on the element and would suppress the focus\n // outline below. Dark mode and brand themes restyle via tokens, so there are\n // no dark: variants.\n //\n // Focus is `focus:`, not the `focus-visible:` Input uses — like Button, and\n // for the same reason (see button.tsx). This trigger is a <button>, and a\n // button focused by MOUSE does not match :focus-visible, so on a pointer click\n // the ring never painted. A native <select> DOES match :focus-visible on click\n // (the browser's form-control heuristic), which is why NativeSelect keeps\n // focus-visible; this custom trigger cannot, so `focus:` rings on click too and\n // the control reads as focused like the rest of the field family. Do not\n // \"unify\" it back to focus-visible.\n \"flex w-fit items-center justify-between gap-2 rounded-sm text-base whitespace-nowrap text-(--input-foreground) focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus:outline-(--input-invalid-ring) data-placeholder:text-(--input-placeholder) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 motion-safe:transition-colors [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; the default, matches Input exactly.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — borderless tinted surface that reveals its border on hover.\n filled: 'border border-transparent bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 px-4 py-2',\n sm: 'h-10 px-3 py-1.5',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\nfunction SelectTrigger({\n className,\n variant,\n size,\n children,\n ...props\n}: SelectPrimitive.Trigger.Props & VariantProps<typeof selectTriggerVariants>) {\n // Resolved once (see `resolveVariant`), so cva and the data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <SelectPrimitive.Trigger\n data-slot='select-trigger'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(selectTriggerVariants({ variant: variantway, size: sizeway, className }))}\n >\n {children}\n <SelectPrimitive.Icon\n render={<IconExpandMore className='pointer-events-none size-5 text-primary' />}\n />\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 0,\n alignItemWithTrigger = true,\n ...props\n}: SelectPrimitive.Popup.Props &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n >) {\n return (\n <SelectPrimitive.Portal>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <SelectPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n alignItemWithTrigger={alignItemWithTrigger}\n className='isolate z-50'\n >\n <SelectPrimitive.Popup\n data-slot='select-content'\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n 'relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none 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 <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalBoundary>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot='select-label'\n className={cn('px-4 py-2 text-base font-semibold text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props) {\n return (\n <SelectPrimitive.Item\n data-slot='select-item'\n className={cn(\n \"relative flex min-h-11 w-full cursor-default items-center gap-2 rounded-sm py-2 ps-4 pe-9 text-base outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText className='flex flex-1 shrink-0 gap-2 whitespace-nowrap'>\n {children}\n </SelectPrimitive.ItemText>\n <SelectPrimitive.ItemIndicator\n render={\n <span className='pointer-events-none absolute end-2 flex items-center justify-center' />\n }\n >\n <IconCheck className='pointer-events-none' />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props) {\n return (\n <SelectPrimitive.Separator\n data-slot='select-separator'\n className={cn('pointer-events-none -mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot='select-scroll-up-button'\n className={cn(\n \"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandLess />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot='select-scroll-down-button'\n className={cn(\n \"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandMore />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n selectTriggerVariants,\n SelectValue,\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/select.tsx"],"names":["SelectPrimitive"],"mappings":";;;;;;;;;;AAaA,MAAM,SAASA,QAAA,CAAgB;AAE/B,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EAAA,CAAG,iBAAA,EAAmB,SAAS,CAAA;AAAA,MACzC,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,WAAA,CAAY,EAAE,SAAA,EAAW,GAAG,OAAM,EAAgC;AACzE,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,KAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,cAAA;AAAA,MACV,SAAA,EAAW,EA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AAA,EAAU,yBAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,0HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ;AAEA,SAAS,sBAAA,CAAuB;AAAA,EAC9B,SAAA;AAAA,EACA,GAAG;AACL,CAAA,EAAiE;AAC/D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,eAAA;AAAA,IAAhB;AAAA,MACC,WAAA,EAAU,2BAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,6HAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG,KAAA;AAAA,MAEJ,8BAAC,cAAA,EAAA,EAAe;AAAA;AAAA,GAClB;AAEJ","file":"select.js","sourcesContent":["'use client'\n\nimport { Select as SelectPrimitive } from '@base-ui/react/select'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport * as React from 'react'\n\nimport { IconCheck } from '../icons/check.js'\nimport { IconExpandLess } from '../icons/expand-less.js'\nimport { IconExpandMore } from '../icons/expand-more.js'\nimport { PortalBoundary } from '../lib/portal-boundary.js'\nimport { resolveVariant } from '../lib/resolve-variant.js'\nimport { cn } from '../lib/utils.js'\n\nconst Select = SelectPrimitive.Root\n\nfunction SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {\n return (\n <SelectPrimitive.Group\n data-slot='select-group'\n className={cn('scroll-my-1 p-1', className)}\n {...props}\n />\n )\n}\n\nfunction SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {\n return (\n <SelectPrimitive.Value\n data-slot='select-value'\n className={cn('flex flex-1 text-start', className)}\n {...props}\n />\n )\n}\n\nconst selectTriggerVariants = cva(\n // Field foundation shared with Input (input.tsx): the same --input-* semantic\n // tokens, 16px text, and an outline-based focus ring. No `outline-none` here —\n // it sets --tw-outline-style:none on the element and would suppress the focus\n // outline below. Dark mode and brand themes restyle via tokens, so there are\n // no dark: variants.\n //\n // Focus is `focus:`, not the `focus-visible:` Input uses — like Button, and\n // for the same reason (see button.tsx). This trigger is a <button>, and a\n // button focused by MOUSE does not match :focus-visible, so on a pointer click\n // the ring never painted. A native <select> DOES match :focus-visible on click\n // (the browser's form-control heuristic), which is why NativeSelect keeps\n // focus-visible; this custom trigger cannot, so `focus:` rings on click too and\n // the control reads as focused like the rest of the field family. Do not\n // \"unify\" it back to focus-visible.\n \"flex w-fit items-center justify-between gap-2 rounded-sm text-base whitespace-nowrap text-(--input-foreground) focus:outline focus:outline-2 focus:outline-offset-2 focus:outline-(--input-ring) disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus:outline-(--input-invalid-ring) data-placeholder:text-(--input-placeholder) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 motion-safe:transition-colors [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n {\n variants: {\n variant: {\n // Crisp field — bordered white box; the default, matches Input exactly.\n default:\n 'border border-(--input-border) bg-(--input-surface) hover:bg-(--input-surface-hover)',\n // Filled band — a tinted surface with an underline, revealing the full\n // border on hover. The tint is barely distinguishable from the page\n // (1.09:1), so the underline, in the field border colour, is what\n // identifies the control at 3:1 (#255, WCAG 1.4.11).\n //\n // Each side's colour is set on its own, never the `border-transparent`\n // shorthand beside the `border-b-` longhand: the two tie on\n // specificity, so a consumer's own Tailwind build re-emitting\n // `border-transparent` after ours would win and erase the underline.\n filled:\n 'border border-x-transparent border-t-transparent border-b-(--input-border) bg-secondary hover:border-(--input-border)',\n },\n size: {\n default: 'h-12 px-4 py-2',\n sm: 'h-10 px-3 py-1.5',\n },\n },\n defaultVariants: { variant: 'default', size: 'default' },\n },\n)\n\nfunction SelectTrigger({\n className,\n variant,\n size,\n children,\n ...props\n}: SelectPrimitive.Trigger.Props & VariantProps<typeof selectTriggerVariants>) {\n // Resolved once (see `resolveVariant`), so cva and the data attributes\n // agree for `null` and `''` as well as the default spelling.\n const variantway = resolveVariant(variant, 'default')\n const sizeway = resolveVariant(size, 'default')\n return (\n <SelectPrimitive.Trigger\n data-slot='select-trigger'\n {...props}\n // After the spread, so a consumer's own `data-*` cannot desync the\n // attribute from the classes both derive from the resolved value.\n data-size={sizeway}\n data-variant={variantway}\n className={cn(selectTriggerVariants({ variant: variantway, size: sizeway, className }))}\n >\n {children}\n <SelectPrimitive.Icon\n render={<IconExpandMore className='pointer-events-none size-5 text-primary' />}\n />\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectContent({\n className,\n children,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 0,\n alignItemWithTrigger = true,\n ...props\n}: SelectPrimitive.Popup.Props &\n Pick<\n SelectPrimitive.Positioner.Props,\n 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'alignItemWithTrigger'\n >) {\n return (\n <SelectPrimitive.Portal>\n {/* Resets a ButtonGroup's context and applies any portal scope — see PortalBoundary. */}\n <PortalBoundary>\n <SelectPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n alignItemWithTrigger={alignItemWithTrigger}\n className='isolate z-50'\n >\n <SelectPrimitive.Popup\n data-slot='select-content'\n data-align-trigger={alignItemWithTrigger}\n className={cn(\n 'relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-md bg-popover text-popover-foreground ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none 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 <SelectScrollUpButton />\n <SelectPrimitive.List>{children}</SelectPrimitive.List>\n <SelectScrollDownButton />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </PortalBoundary>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props) {\n return (\n <SelectPrimitive.GroupLabel\n data-slot='select-label'\n className={cn('px-4 py-2 text-base font-semibold text-muted-foreground', className)}\n {...props}\n />\n )\n}\n\nfunction SelectItem({ className, children, ...props }: SelectPrimitive.Item.Props) {\n return (\n <SelectPrimitive.Item\n data-slot='select-item'\n className={cn(\n \"relative flex min-h-11 w-full cursor-default items-center gap-2 rounded-sm py-2 ps-4 pe-9 text-base outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2\",\n className,\n )}\n {...props}\n >\n <SelectPrimitive.ItemText className='flex flex-1 shrink-0 gap-2 whitespace-nowrap'>\n {children}\n </SelectPrimitive.ItemText>\n <SelectPrimitive.ItemIndicator\n render={\n <span className='pointer-events-none absolute end-2 flex items-center justify-center' />\n }\n >\n <IconCheck className='pointer-events-none' />\n </SelectPrimitive.ItemIndicator>\n </SelectPrimitive.Item>\n )\n}\n\nfunction SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props) {\n return (\n <SelectPrimitive.Separator\n data-slot='select-separator'\n className={cn('pointer-events-none -mx-1 my-1 h-px bg-border/50', className)}\n {...props}\n />\n )\n}\n\nfunction SelectScrollUpButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {\n return (\n <SelectPrimitive.ScrollUpArrow\n data-slot='select-scroll-up-button'\n className={cn(\n \"top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandLess />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({\n className,\n ...props\n}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {\n return (\n <SelectPrimitive.ScrollDownArrow\n data-slot='select-scroll-down-button'\n className={cn(\n \"bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-3.5\",\n className,\n )}\n {...props}\n >\n <IconExpandMore />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nexport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectLabel,\n SelectScrollDownButton,\n SelectScrollUpButton,\n SelectSeparator,\n SelectTrigger,\n selectTriggerVariants,\n SelectValue,\n}\n"]}
|
|
@@ -5,12 +5,22 @@ import { cva } from 'class-variance-authority';
|
|
|
5
5
|
import { cn } from '../lib/utils.js';
|
|
6
6
|
|
|
7
7
|
const toggleVariants = cva(
|
|
8
|
-
|
|
8
|
+
[
|
|
9
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-sm text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
10
|
+
// Pressed is the interactive fill with its foreground, as a selected
|
|
11
|
+
// segment. It was a `bg-muted` tint, 1.09:1 against the page in light and
|
|
12
|
+
// 1.00:1 in dark — pressed and not pressed looked the same (#255,
|
|
13
|
+
// WCAG 1.4.11). Base UI marks the state with aria-pressed (and
|
|
14
|
+
// data-pressed); the old `data-[state=on]` was Radix's and never matched.
|
|
15
|
+
"aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-primary-foreground aria-pressed:hover:bg-primary/90 aria-pressed:hover:text-primary-foreground"
|
|
16
|
+
],
|
|
9
17
|
{
|
|
10
18
|
variants: {
|
|
11
19
|
variant: {
|
|
12
20
|
default: "bg-transparent",
|
|
13
|
-
|
|
21
|
+
// The field family's border token (Input, Select), which clears 3:1
|
|
22
|
+
// against the page in both modes; `border-input` was 1.34:1 / 1.67:1.
|
|
23
|
+
outline: "border border-(--input-border) bg-transparent hover:bg-muted"
|
|
14
24
|
},
|
|
15
25
|
size: {
|
|
16
26
|
default: "h-7 min-w-7 px-2 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/toggle.tsx"],"names":["TogglePrimitive"],"mappings":";;;;;AAOA,MAAM,cAAA,GAAiB,GAAA;AAAA,EACrB,
|
|
1
|
+
{"version":3,"sources":["../../src/components/toggle.tsx"],"names":["TogglePrimitive"],"mappings":";;;;;AAOA,MAAM,cAAA,GAAiB,GAAA;AAAA,EACrB;AAAA,IACE,seAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA;AAAA,GACF;AAAA,EACA;AAAA,IACE,QAAA,EAAU;AAAA,MACR,OAAA,EAAS;AAAA,QACP,OAAA,EAAS,gBAAA;AAAA;AAAA;AAAA,QAGT,OAAA,EAAS;AAAA,OACX;AAAA,MACA,IAAA,EAAM;AAAA,QACJ,OAAA,EACE,wFAAA;AAAA,QACF,EAAA,EAAI,wJAAA;AAAA,QACJ,EAAA,EAAI;AAAA;AACN,KACF;AAAA,IACA,eAAA,EAAiB;AAAA,MACf,OAAA,EAAS,SAAA;AAAA,MACT,IAAA,EAAM;AAAA;AACR;AAEJ;AAEA,SAAS,MAAA,CAAO;AAAA,EACd,SAAA;AAAA,EACA,OAAA,GAAU,SAAA;AAAA,EACV,IAAA,GAAO,SAAA;AAAA,EACP,GAAG;AACL,CAAA,EAAgE;AAC9D,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,QAAA;AAAA,MACV,SAAA,EAAW,GAAG,cAAA,CAAe,EAAE,SAAS,IAAA,EAAM,SAAA,EAAW,CAAC,CAAA;AAAA,MACzD,GAAG;AAAA;AAAA,GACN;AAEJ","file":"toggle.js","sourcesContent":["'use client'\n\nimport { Toggle as TogglePrimitive } from '@base-ui/react/toggle'\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils.js'\n\nconst toggleVariants = cva(\n [\n \"group/toggle inline-flex items-center justify-center gap-1 rounded-sm text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4\",\n // Pressed is the interactive fill with its foreground, as a selected\n // segment. It was a `bg-muted` tint, 1.09:1 against the page in light and\n // 1.00:1 in dark — pressed and not pressed looked the same (#255,\n // WCAG 1.4.11). Base UI marks the state with aria-pressed (and\n // data-pressed); the old `data-[state=on]` was Radix's and never matched.\n 'aria-pressed:border-primary aria-pressed:bg-primary aria-pressed:text-primary-foreground aria-pressed:hover:bg-primary/90 aria-pressed:hover:text-primary-foreground',\n ],\n {\n variants: {\n variant: {\n default: 'bg-transparent',\n // The field family's border token (Input, Select), which clears 3:1\n // against the page in both modes; `border-input` was 1.34:1 / 1.67:1.\n outline: 'border border-(--input-border) bg-transparent hover:bg-muted',\n },\n size: {\n default:\n 'h-7 min-w-7 px-2 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5',\n sm: \"h-6 min-w-6 rounded-sm px-2 text-[0.625rem] has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3\",\n lg: 'h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pe-2 has-data-[icon=inline-start]:ps-2',\n },\n },\n defaultVariants: {\n variant: 'default',\n size: 'default',\n },\n },\n)\n\nfunction Toggle({\n className,\n variant = 'default',\n size = 'default',\n ...props\n}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {\n return (\n <TogglePrimitive\n data-slot='toggle'\n className={cn(toggleVariants({ variant, size, className }))}\n {...props}\n />\n )\n}\n\nexport { Toggle, toggleVariants }\n"]}
|