@nswds/ui 9.6.1 → 9.6.3
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.
|
@@ -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,IAAnB;AAAA,MACC,WAAA,EAAU,WAAA;AAAA,MACV,cAAA,EAAc,OAAA;AAAA,MACd,SAAA,EAAW,EAAA,CAAG,sCAAA,EAAwC,SAAS,CAAA;AAAA,MAC9D,GAAG;AAAA;AAAA,GACN;AAEJ;AAEA,SAAS,aAAA,CAAc,EAAE,SAAA,EAAW,GAAG,OAAM,EAAkC;AAC7E,EAAA,uBACE,GAAA;AAAA,IAACA,WAAA,CA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A;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"]}
|
|
@@ -10,7 +10,7 @@ function Slider({
|
|
|
10
10
|
max = 100,
|
|
11
11
|
...props
|
|
12
12
|
}) {
|
|
13
|
-
const
|
|
13
|
+
const thumbCount = thumbCountOf(value ?? defaultValue);
|
|
14
14
|
return /* @__PURE__ */ jsx(
|
|
15
15
|
Slider$1.Root,
|
|
16
16
|
{
|
|
@@ -37,11 +37,18 @@ function Slider({
|
|
|
37
37
|
)
|
|
38
38
|
}
|
|
39
39
|
),
|
|
40
|
-
Array.from({ length:
|
|
40
|
+
Array.from({ length: thumbCount }, (_, index) => /* @__PURE__ */ jsx(
|
|
41
41
|
Slider$1.Thumb,
|
|
42
42
|
{
|
|
43
43
|
"data-slot": "slider-thumb",
|
|
44
|
-
className:
|
|
44
|
+
className: cn(
|
|
45
|
+
"relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/30 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-2 active:ring-2 disabled:pointer-events-none disabled:opacity-50",
|
|
46
|
+
// Keyboard focus lands on the range input Base UI renders inside
|
|
47
|
+
// the thumb, never on the thumb itself, so a `focus-visible:`
|
|
48
|
+
// ring here could not draw (#250). Key the house 2px ring off the
|
|
49
|
+
// focused input instead.
|
|
50
|
+
"has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring has-focus-visible:outline-solid"
|
|
51
|
+
)
|
|
45
52
|
},
|
|
46
53
|
index
|
|
47
54
|
))
|
|
@@ -49,6 +56,10 @@ function Slider({
|
|
|
49
56
|
}
|
|
50
57
|
);
|
|
51
58
|
}
|
|
59
|
+
function thumbCountOf(value) {
|
|
60
|
+
if (typeof value === "number") return 1;
|
|
61
|
+
return value?.length ?? 1;
|
|
62
|
+
}
|
|
52
63
|
|
|
53
64
|
export { Slider };
|
|
54
65
|
//# sourceMappingURL=slider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/slider.tsx"],"names":["SliderPrimitive"],"mappings":";;;;AAIA,SAAS,MAAA,CAAO;AAAA,EACd,SAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA,GAAM,CAAA;AAAA,EACN,GAAA,GAAM,GAAA;AAAA,EACN,GAAG;AACL,CAAA,EAA+B;
|
|
1
|
+
{"version":3,"sources":["../../src/components/slider.tsx"],"names":["SliderPrimitive"],"mappings":";;;;AAIA,SAAS,MAAA,CAAO;AAAA,EACd,SAAA;AAAA,EACA,YAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAA,GAAM,CAAA;AAAA,EACN,GAAA,GAAM,GAAA;AAAA,EACN,GAAG;AACL,CAAA,EAA+B;AAK7B,EAAA,MAAM,UAAA,GAAa,YAAA,CAAa,KAAA,IAAS,YAAY,CAAA;AAErD,EAAA,uBACE,GAAA;AAAA,IAACA,QAAA,CAAgB,IAAA;AAAA,IAAhB;AAAA,MACC,SAAA,EAAW,EAAA,CAAG,6CAAA,EAA+C,SAAS,CAAA;AAAA,MACtE,WAAA,EAAU,QAAA;AAAA,MACV,YAAA;AAAA,MACA,KAAA;AAAA,MACA,GAAA;AAAA,MACA,GAAA;AAAA,MACA,cAAA,EAAe,MAAA;AAAA,MACd,GAAG,KAAA;AAAA,MAEJ,QAAA,kBAAA,IAAA,CAACA,QAAA,CAAgB,OAAA,EAAhB,EAAwB,WAAU,2KAAA,EACjC,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAACA,QAAA,CAAgB,KAAA;AAAA,UAAhB;AAAA,YACC,WAAA,EAAU,cAAA;AAAA,YACV,SAAA,EAAU,mJAAA;AAAA,YAEV,QAAA,kBAAA,GAAA;AAAA,cAACA,QAAA,CAAgB,SAAA;AAAA,cAAhB;AAAA,gBACC,WAAA,EAAU,cAAA;AAAA,gBACV,SAAA,EAAU;AAAA;AAAA;AACZ;AAAA,SACF;AAAA,QACC,KAAA,CAAM,KAAK,EAAE,MAAA,EAAQ,YAAW,EAAG,CAAC,GAAG,KAAA,qBACtC,GAAA;AAAA,UAACA,QAAA,CAAgB,KAAA;AAAA,UAAhB;AAAA,YACC,WAAA,EAAU,cAAA;AAAA,YAEV,SAAA,EAAW,EAAA;AAAA,cACT,0OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAKA;AAAA;AACF,WAAA;AAAA,UARK;AAAA,SAUR;AAAA,OAAA,EACH;AAAA;AAAA,GACF;AAEJ;AAEA,SAAS,aAAa,KAAA,EAAoD;AACxE,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,CAAA;AACtC,EAAA,OAAO,OAAO,MAAA,IAAU,CAAA;AAC1B","file":"slider.js","sourcesContent":["import { Slider as SliderPrimitive } from '@base-ui/react/slider'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Slider({\n className,\n defaultValue,\n value,\n min = 0,\n max = 100,\n ...props\n}: SliderPrimitive.Root.Props) {\n // One thumb per value. Base UI accepts a plain number as well as an array,\n // so a number is one thumb — it used to fall through to `[min, max]` and\n // render two (#250). With no value at all Base UI holds a single number,\n // `min`, so that is one thumb too; a second would have no value behind it.\n const thumbCount = thumbCountOf(value ?? defaultValue)\n\n return (\n <SliderPrimitive.Root\n className={cn('data-horizontal:w-full data-vertical:h-full', className)}\n data-slot='slider'\n defaultValue={defaultValue}\n value={value}\n min={min}\n max={max}\n thumbAlignment='edge'\n {...props}\n >\n <SliderPrimitive.Control className='relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col'>\n <SliderPrimitive.Track\n data-slot='slider-track'\n className='relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1'\n >\n <SliderPrimitive.Indicator\n data-slot='slider-range'\n className='bg-primary select-none data-horizontal:h-full data-vertical:w-full'\n />\n </SliderPrimitive.Track>\n {Array.from({ length: thumbCount }, (_, index) => (\n <SliderPrimitive.Thumb\n data-slot='slider-thumb'\n key={index}\n className={cn(\n 'relative block size-3 shrink-0 rounded-full border border-ring bg-white ring-ring/30 transition-[color,box-shadow] select-none after:absolute after:-inset-2 hover:ring-2 active:ring-2 disabled:pointer-events-none disabled:opacity-50',\n // Keyboard focus lands on the range input Base UI renders inside\n // the thumb, never on the thumb itself, so a `focus-visible:`\n // ring here could not draw (#250). Key the house 2px ring off the\n // focused input instead.\n 'has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-ring has-focus-visible:outline-solid',\n )}\n />\n ))}\n </SliderPrimitive.Control>\n </SliderPrimitive.Root>\n )\n}\n\nfunction thumbCountOf(value: SliderPrimitive.Root.Props['value']): number {\n if (typeof value === 'number') return 1\n return value?.length ?? 1\n}\n\nexport { Slider }\n"]}
|