@nucleux/md3-slider 0.3.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nucleux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @nucleux/md3-slider
2
+
3
+ Material 3 slider — Nucleux agentic UI for React.
4
+
5
+ Part of **[Nucleux](https://github.com/intelligaia-open-labs/nucleux)** — agentic UI components for React. Install a single component, or the full kit via [`@nucleux/react`](https://www.npmjs.com/package/@nucleux/react).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ pnpm add @nucleux/md3-slider @nucleux/tokens
11
+ ```
12
+
13
+ `react` / `react-dom` are peer dependencies.
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import { Md3Slider } from "@nucleux/md3-slider";
19
+ ```
20
+
21
+ Requires the theme once in your app: `import "@nucleux/tokens/styles.css";`
22
+ and the Tailwind preset from `@nucleux/tokens/preset`.
23
+
24
+ ## License
25
+
26
+ MIT © Nucleux
package/dist/index.cjs ADDED
@@ -0,0 +1,113 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var utils = require('@nucleux/utils');
6
+ var jsxRuntime = require('react/jsx-runtime');
7
+
8
+ function _interopNamespace(e) {
9
+ if (e && e.__esModule) return e;
10
+ var n = Object.create(null);
11
+ if (e) {
12
+ Object.keys(e).forEach(function (k) {
13
+ if (k !== 'default') {
14
+ var d = Object.getOwnPropertyDescriptor(e, k);
15
+ Object.defineProperty(n, k, d.get ? d : {
16
+ enumerable: true,
17
+ get: function () { return e[k]; }
18
+ });
19
+ }
20
+ });
21
+ }
22
+ n.default = e;
23
+ return Object.freeze(n);
24
+ }
25
+
26
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
27
+
28
+ // src/index.tsx
29
+ var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
30
+ var roundToStep = (n, min, step) => min + Math.round((n - min) / step) * step;
31
+ var Md3Slider = React__namespace.forwardRef(
32
+ ({ value, defaultValue = 0, min = 0, max = 100, step = 1, disabled = false, onValueChange, className, "aria-label": ariaLabel, ...props }, ref) => {
33
+ const trackRef = React__namespace.useRef(null);
34
+ const isControlled = value !== void 0;
35
+ const [internal, setInternal] = React__namespace.useState(clamp(defaultValue, min, max));
36
+ const current = clamp(isControlled ? value : internal, min, max);
37
+ const pct = (current - min) / (max - min) * 100;
38
+ const commit = (next) => {
39
+ const v = clamp(roundToStep(next, min, step), min, max);
40
+ if (v === current) return;
41
+ if (!isControlled) setInternal(v);
42
+ onValueChange?.(v);
43
+ };
44
+ const valueFromClientX = (clientX) => {
45
+ const track = trackRef.current;
46
+ if (!track) return current;
47
+ const rect = track.getBoundingClientRect();
48
+ return min + clamp((clientX - rect.left) / rect.width, 0, 1) * (max - min);
49
+ };
50
+ const onKeyDown = (e) => {
51
+ if (disabled) return;
52
+ const map = {
53
+ ArrowRight: current + step,
54
+ ArrowUp: current + step,
55
+ ArrowLeft: current - step,
56
+ ArrowDown: current - step,
57
+ Home: min,
58
+ End: max
59
+ };
60
+ if (!(e.key in map)) return;
61
+ e.preventDefault();
62
+ commit(map[e.key]);
63
+ };
64
+ return /* @__PURE__ */ jsxRuntime.jsx(
65
+ "div",
66
+ {
67
+ ref,
68
+ className: utils.cn("relative flex w-full touch-none select-none items-center py-2", disabled && "pointer-events-none opacity-[0.38]", className),
69
+ ...props,
70
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
71
+ "div",
72
+ {
73
+ ref: trackRef,
74
+ onPointerDown: (e) => {
75
+ e.preventDefault();
76
+ e.target.setPointerCapture?.(e.pointerId);
77
+ commit(valueFromClientX(e.clientX));
78
+ },
79
+ onPointerMove: (e) => {
80
+ if (e.buttons === 0) return;
81
+ commit(valueFromClientX(e.clientX));
82
+ },
83
+ className: "relative h-1 w-full grow cursor-pointer rounded-full bg-md-surface-variant",
84
+ children: [
85
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute h-full rounded-full bg-md-primary", style: { width: `${pct}%` } }),
86
+ /* @__PURE__ */ jsxRuntime.jsx(
87
+ "div",
88
+ {
89
+ role: "slider",
90
+ tabIndex: disabled ? -1 : 0,
91
+ "aria-label": ariaLabel,
92
+ "aria-valuemin": min,
93
+ "aria-valuemax": max,
94
+ "aria-valuenow": current,
95
+ "aria-disabled": disabled || void 0,
96
+ "aria-orientation": "horizontal",
97
+ onKeyDown,
98
+ className: "absolute top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-md-primary shadow-md-1 outline-none focus-visible:ring-2 focus-visible:ring-md-primary focus-visible:ring-offset-2 focus-visible:ring-offset-md-surface",
99
+ style: { left: `${pct}%` }
100
+ }
101
+ )
102
+ ]
103
+ }
104
+ )
105
+ }
106
+ );
107
+ }
108
+ );
109
+ Md3Slider.displayName = "Md3Slider";
110
+
111
+ exports.Md3Slider = Md3Slider;
112
+ //# sourceMappingURL=index.cjs.map
113
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":["React","jsx","cn","jsxs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAW,GAAA,EAAa,GAAA,KAAgB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,CAAC,CAAC,CAAA;AACrF,IAAM,WAAA,GAAc,CAAC,CAAA,EAAW,GAAA,EAAa,IAAA,KAAiB,GAAA,GAAM,IAAA,CAAK,KAAA,CAAA,CAAO,CAAA,GAAI,GAAA,IAAO,IAAI,CAAA,GAAI,IAAA;AAG5F,IAAM,SAAA,GAAkBA,gBAAA,CAAA,UAAA;AAAA,EAC7B,CACE,EAAE,KAAA,EAAO,YAAA,GAAe,GAAG,GAAA,GAAM,CAAA,EAAG,MAAM,GAAA,EAAK,IAAA,GAAO,GAAG,QAAA,GAAW,KAAA,EAAO,eAAe,SAAA,EAAW,YAAA,EAAc,WAAW,GAAG,KAAA,IACjI,GAAA,KACG;AACH,IAAA,MAAM,QAAA,GAAiBA,wBAAuB,IAAI,CAAA;AAClD,IAAA,MAAM,eAAe,KAAA,KAAU,MAAA;AAC/B,IAAA,MAAM,CAAC,UAAU,WAAW,CAAA,GAAUA,0BAAS,KAAA,CAAM,YAAA,EAAc,GAAA,EAAK,GAAG,CAAC,CAAA;AAC5E,IAAA,MAAM,UAAU,KAAA,CAAM,YAAA,GAAe,KAAA,GAAQ,QAAA,EAAU,KAAK,GAAG,CAAA;AAC/D,IAAA,MAAM,GAAA,GAAA,CAAQ,OAAA,GAAU,GAAA,KAAQ,GAAA,GAAM,GAAA,CAAA,GAAQ,GAAA;AAE9C,IAAA,MAAM,MAAA,GAAS,CAAC,IAAA,KAAiB;AAC/B,MA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I;AAAA;AAC3B;AAAA;AAAA;AACF;AAAA,KACF;AAAA,EAEJ;AACF;AACA,SAAA,CAAU,WAAA,GAAc,WAAA","file":"index.cjs","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface Md3SliderProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\"> {\n value?: number;\n defaultValue?: number;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n onValueChange?: (value: number) => void;\n \"aria-label\"?: string;\n}\n\nconst clamp = (n: number, min: number, max: number) => Math.min(max, Math.max(min, n));\nconst roundToStep = (n: number, min: number, step: number) => min + Math.round((n - min) / step) * step;\n\n/** A Material Design 3 slider (single value) with pointer + keyboard control. */\nexport const Md3Slider = React.forwardRef<HTMLDivElement, Md3SliderProps>(\n (\n { value, defaultValue = 0, min = 0, max = 100, step = 1, disabled = false, onValueChange, className, \"aria-label\": ariaLabel, ...props },\n ref,\n ) => {\n const trackRef = React.useRef<HTMLDivElement>(null);\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState(clamp(defaultValue, min, max));\n const current = clamp(isControlled ? value : internal, min, max);\n const pct = ((current - min) / (max - min)) * 100;\n\n const commit = (next: number) => {\n const v = clamp(roundToStep(next, min, step), min, max);\n if (v === current) return;\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n };\n\n const valueFromClientX = (clientX: number) => {\n const track = trackRef.current;\n if (!track) return current;\n const rect = track.getBoundingClientRect();\n return min + clamp((clientX - rect.left) / rect.width, 0, 1) * (max - min);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const map: Record<string, number> = {\n ArrowRight: current + step,\n ArrowUp: current + step,\n ArrowLeft: current - step,\n ArrowDown: current - step,\n Home: min,\n End: max,\n };\n if (!(e.key in map)) return;\n e.preventDefault();\n commit(map[e.key]!);\n };\n\n return (\n <div\n ref={ref}\n className={cn(\"relative flex w-full touch-none select-none items-center py-2\", disabled && \"pointer-events-none opacity-[0.38]\", className)}\n {...props}\n >\n <div\n ref={trackRef}\n onPointerDown={(e) => {\n e.preventDefault();\n (e.target as HTMLElement).setPointerCapture?.(e.pointerId);\n commit(valueFromClientX(e.clientX));\n }}\n onPointerMove={(e) => {\n if (e.buttons === 0) return;\n commit(valueFromClientX(e.clientX));\n }}\n className=\"relative h-1 w-full grow cursor-pointer rounded-full bg-md-surface-variant\"\n >\n <div className=\"absolute h-full rounded-full bg-md-primary\" style={{ width: `${pct}%` }} />\n <div\n role=\"slider\"\n tabIndex={disabled ? -1 : 0}\n aria-label={ariaLabel}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={current}\n aria-disabled={disabled || undefined}\n aria-orientation=\"horizontal\"\n onKeyDown={onKeyDown}\n className=\"absolute top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-md-primary shadow-md-1 outline-none focus-visible:ring-2 focus-visible:ring-md-primary focus-visible:ring-offset-2 focus-visible:ring-offset-md-surface\"\n style={{ left: `${pct}%` }}\n />\n </div>\n </div>\n );\n },\n);\nMd3Slider.displayName = \"Md3Slider\";\n"]}
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+
3
+ interface Md3SliderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
4
+ value?: number;
5
+ defaultValue?: number;
6
+ min?: number;
7
+ max?: number;
8
+ step?: number;
9
+ disabled?: boolean;
10
+ onValueChange?: (value: number) => void;
11
+ "aria-label"?: string;
12
+ }
13
+ /** A Material Design 3 slider (single value) with pointer + keyboard control. */
14
+ declare const Md3Slider: React.ForwardRefExoticComponent<Md3SliderProps & React.RefAttributes<HTMLDivElement>>;
15
+
16
+ export { Md3Slider, type Md3SliderProps };
@@ -0,0 +1,16 @@
1
+ import * as React from 'react';
2
+
3
+ interface Md3SliderProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
4
+ value?: number;
5
+ defaultValue?: number;
6
+ min?: number;
7
+ max?: number;
8
+ step?: number;
9
+ disabled?: boolean;
10
+ onValueChange?: (value: number) => void;
11
+ "aria-label"?: string;
12
+ }
13
+ /** A Material Design 3 slider (single value) with pointer + keyboard control. */
14
+ declare const Md3Slider: React.ForwardRefExoticComponent<Md3SliderProps & React.RefAttributes<HTMLDivElement>>;
15
+
16
+ export { Md3Slider, type Md3SliderProps };
package/dist/index.js ADDED
@@ -0,0 +1,91 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { cn } from '@nucleux/utils';
4
+ import { jsx, jsxs } from 'react/jsx-runtime';
5
+
6
+ // src/index.tsx
7
+ var clamp = (n, min, max) => Math.min(max, Math.max(min, n));
8
+ var roundToStep = (n, min, step) => min + Math.round((n - min) / step) * step;
9
+ var Md3Slider = React.forwardRef(
10
+ ({ value, defaultValue = 0, min = 0, max = 100, step = 1, disabled = false, onValueChange, className, "aria-label": ariaLabel, ...props }, ref) => {
11
+ const trackRef = React.useRef(null);
12
+ const isControlled = value !== void 0;
13
+ const [internal, setInternal] = React.useState(clamp(defaultValue, min, max));
14
+ const current = clamp(isControlled ? value : internal, min, max);
15
+ const pct = (current - min) / (max - min) * 100;
16
+ const commit = (next) => {
17
+ const v = clamp(roundToStep(next, min, step), min, max);
18
+ if (v === current) return;
19
+ if (!isControlled) setInternal(v);
20
+ onValueChange?.(v);
21
+ };
22
+ const valueFromClientX = (clientX) => {
23
+ const track = trackRef.current;
24
+ if (!track) return current;
25
+ const rect = track.getBoundingClientRect();
26
+ return min + clamp((clientX - rect.left) / rect.width, 0, 1) * (max - min);
27
+ };
28
+ const onKeyDown = (e) => {
29
+ if (disabled) return;
30
+ const map = {
31
+ ArrowRight: current + step,
32
+ ArrowUp: current + step,
33
+ ArrowLeft: current - step,
34
+ ArrowDown: current - step,
35
+ Home: min,
36
+ End: max
37
+ };
38
+ if (!(e.key in map)) return;
39
+ e.preventDefault();
40
+ commit(map[e.key]);
41
+ };
42
+ return /* @__PURE__ */ jsx(
43
+ "div",
44
+ {
45
+ ref,
46
+ className: cn("relative flex w-full touch-none select-none items-center py-2", disabled && "pointer-events-none opacity-[0.38]", className),
47
+ ...props,
48
+ children: /* @__PURE__ */ jsxs(
49
+ "div",
50
+ {
51
+ ref: trackRef,
52
+ onPointerDown: (e) => {
53
+ e.preventDefault();
54
+ e.target.setPointerCapture?.(e.pointerId);
55
+ commit(valueFromClientX(e.clientX));
56
+ },
57
+ onPointerMove: (e) => {
58
+ if (e.buttons === 0) return;
59
+ commit(valueFromClientX(e.clientX));
60
+ },
61
+ className: "relative h-1 w-full grow cursor-pointer rounded-full bg-md-surface-variant",
62
+ children: [
63
+ /* @__PURE__ */ jsx("div", { className: "absolute h-full rounded-full bg-md-primary", style: { width: `${pct}%` } }),
64
+ /* @__PURE__ */ jsx(
65
+ "div",
66
+ {
67
+ role: "slider",
68
+ tabIndex: disabled ? -1 : 0,
69
+ "aria-label": ariaLabel,
70
+ "aria-valuemin": min,
71
+ "aria-valuemax": max,
72
+ "aria-valuenow": current,
73
+ "aria-disabled": disabled || void 0,
74
+ "aria-orientation": "horizontal",
75
+ onKeyDown,
76
+ className: "absolute top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-md-primary shadow-md-1 outline-none focus-visible:ring-2 focus-visible:ring-md-primary focus-visible:ring-offset-2 focus-visible:ring-offset-md-surface",
77
+ style: { left: `${pct}%` }
78
+ }
79
+ )
80
+ ]
81
+ }
82
+ )
83
+ }
84
+ );
85
+ }
86
+ );
87
+ Md3Slider.displayName = "Md3Slider";
88
+
89
+ export { Md3Slider };
90
+ //# sourceMappingURL=index.js.map
91
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx"],"names":[],"mappings":";;;;;AAeA,IAAM,KAAA,GAAQ,CAAC,CAAA,EAAW,GAAA,EAAa,GAAA,KAAgB,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,GAAA,C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AiB,CAAA,CAAE,OAAO,CAAC,CAAA;AAAA,YACpC,CAAA;AAAA,YACA,aAAA,EAAe,CAAC,CAAA,KAAM;AACpB,cAAA,IAAI,CAAA,CAAE,YAAY,CAAA,EAAG;AACrB,cAAA,MAAA,CAAO,gBAAA,CAAiB,CAAA,CAAE,OAAO,CAAC,CAAA;AAAA,YACpC,CAAA;AAAA,YACA,SAAA,EAAU,4EAAA;AAAA,YAEV,QAAA,EAAA;AAAA,8BAAA,GAAA,CAAC,KAAA,EAAA,EAAI,WAAU,4CAAA,EAA6C,KAAA,EAAO,EAAE,KAAA,EAAO,CAAA,EAAG,GAAG,CAAA,CAAA,CAAA,EAAI,EAAG,CAAA;AAAA,8BACzF,GAAA;AAAA,gBAAC,KAAA;AAAA,gBAAA;AAAA,kBACC,IAAA,EAAK,QAAA;AAAA,kBACL,QAAA,EAAU,WAAW,EAAA,GAAK,CAAA;AAAA,kBAC1B,YAAA,EAAY,SAAA;AAAA,kBACZ,eAAA,EAAe,GAAA;AAAA,kBACf,eAAA,EAAe,GAAA;AAAA,kBACf,eAAA,EAAe,OAAA;AAAA,kBACf,iBAAe,QAAA,IAAY,MAAA;AAAA,kBAC3B,kBAAA,EAAiB,YAAA;AAAA,kBACjB,SAAA;AAAA,kBACA,SAAA,EAAU,oOAAA;AAAA,kBACV,KAAA,EAAO,EAAE,IAAA,EAAM,CAAA,EAAG,GAAG,CAAA,CAAA,CAAA;AAAI;AAAA;AAC3B;AAAA;AAAA;AACF;AAAA,KACF;AAAA,EAEJ;AACF;AACA,SAAA,CAAU,WAAA,GAAc,WAAA","file":"index.js","sourcesContent":["import * as React from \"react\";\nimport { cn } from \"@nucleux/utils\";\n\nexport interface Md3SliderProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, \"defaultValue\" | \"onChange\"> {\n value?: number;\n defaultValue?: number;\n min?: number;\n max?: number;\n step?: number;\n disabled?: boolean;\n onValueChange?: (value: number) => void;\n \"aria-label\"?: string;\n}\n\nconst clamp = (n: number, min: number, max: number) => Math.min(max, Math.max(min, n));\nconst roundToStep = (n: number, min: number, step: number) => min + Math.round((n - min) / step) * step;\n\n/** A Material Design 3 slider (single value) with pointer + keyboard control. */\nexport const Md3Slider = React.forwardRef<HTMLDivElement, Md3SliderProps>(\n (\n { value, defaultValue = 0, min = 0, max = 100, step = 1, disabled = false, onValueChange, className, \"aria-label\": ariaLabel, ...props },\n ref,\n ) => {\n const trackRef = React.useRef<HTMLDivElement>(null);\n const isControlled = value !== undefined;\n const [internal, setInternal] = React.useState(clamp(defaultValue, min, max));\n const current = clamp(isControlled ? value : internal, min, max);\n const pct = ((current - min) / (max - min)) * 100;\n\n const commit = (next: number) => {\n const v = clamp(roundToStep(next, min, step), min, max);\n if (v === current) return;\n if (!isControlled) setInternal(v);\n onValueChange?.(v);\n };\n\n const valueFromClientX = (clientX: number) => {\n const track = trackRef.current;\n if (!track) return current;\n const rect = track.getBoundingClientRect();\n return min + clamp((clientX - rect.left) / rect.width, 0, 1) * (max - min);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (disabled) return;\n const map: Record<string, number> = {\n ArrowRight: current + step,\n ArrowUp: current + step,\n ArrowLeft: current - step,\n ArrowDown: current - step,\n Home: min,\n End: max,\n };\n if (!(e.key in map)) return;\n e.preventDefault();\n commit(map[e.key]!);\n };\n\n return (\n <div\n ref={ref}\n className={cn(\"relative flex w-full touch-none select-none items-center py-2\", disabled && \"pointer-events-none opacity-[0.38]\", className)}\n {...props}\n >\n <div\n ref={trackRef}\n onPointerDown={(e) => {\n e.preventDefault();\n (e.target as HTMLElement).setPointerCapture?.(e.pointerId);\n commit(valueFromClientX(e.clientX));\n }}\n onPointerMove={(e) => {\n if (e.buttons === 0) return;\n commit(valueFromClientX(e.clientX));\n }}\n className=\"relative h-1 w-full grow cursor-pointer rounded-full bg-md-surface-variant\"\n >\n <div className=\"absolute h-full rounded-full bg-md-primary\" style={{ width: `${pct}%` }} />\n <div\n role=\"slider\"\n tabIndex={disabled ? -1 : 0}\n aria-label={ariaLabel}\n aria-valuemin={min}\n aria-valuemax={max}\n aria-valuenow={current}\n aria-disabled={disabled || undefined}\n aria-orientation=\"horizontal\"\n onKeyDown={onKeyDown}\n className=\"absolute top-1/2 h-5 w-5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-md-primary shadow-md-1 outline-none focus-visible:ring-2 focus-visible:ring-md-primary focus-visible:ring-offset-2 focus-visible:ring-offset-md-surface\"\n style={{ left: `${pct}%` }}\n />\n </div>\n </div>\n );\n },\n);\nMd3Slider.displayName = \"Md3Slider\";\n"]}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nucleux/md3-slider",
3
+ "version": "0.3.0",
4
+ "type": "module",
5
+ "sideEffects": false,
6
+ "description": "Material 3 slider — Nucleux agentic UI for React.",
7
+ "keywords": [
8
+ "nucleux",
9
+ "react",
10
+ "ui",
11
+ "components",
12
+ "agentic",
13
+ "ai",
14
+ "tailwind",
15
+ "md3-slider"
16
+ ],
17
+ "main": "./dist/index.cjs",
18
+ "module": "./dist/index.js",
19
+ "types": "./dist/index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/index.d.ts",
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs"
25
+ }
26
+ },
27
+ "files": [
28
+ "dist",
29
+ "README.md"
30
+ ],
31
+ "peerDependencies": {
32
+ "react": ">=18",
33
+ "react-dom": ">=18"
34
+ },
35
+ "dependencies": {
36
+ "@nucleux/utils": "0.3.0"
37
+ },
38
+ "devDependencies": {
39
+ "tsup": "^8.3.5",
40
+ "typescript": "^5.7.2",
41
+ "@types/react": "^18.3.18",
42
+ "react": "^18.3.1",
43
+ "lucide-react": "^0.469.0"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ },
48
+ "license": "MIT",
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "git+https://github.com/intelligaia-open-labs/nucleux.git",
52
+ "directory": "packages/md3-slider"
53
+ },
54
+ "homepage": "https://github.com/intelligaia-open-labs/nucleux#readme",
55
+ "scripts": {
56
+ "build": "tsup"
57
+ }
58
+ }