@nswds/ui 9.6.2 → 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.
|
@@ -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"]}
|