@jamsrui/slider 0.0.15 → 0.0.17
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/index.d.mts +36 -3
- package/dist/index.mjs +1 -1
- package/dist/slider-config.d.mts +6 -4
- package/dist/slider-config.mjs +1 -1
- package/dist/slider-context.d.mts +20 -0
- package/dist/slider-context.mjs +1 -0
- package/dist/slider-control.d.mts +10 -0
- package/dist/slider-control.mjs +1 -0
- package/dist/slider-indicator.d.mts +10 -0
- package/dist/slider-indicator.mjs +1 -0
- package/dist/slider-thumb.d.mts +11 -0
- package/dist/slider-thumb.mjs +1 -0
- package/dist/slider-track.d.mts +10 -0
- package/dist/slider-track.mjs +1 -0
- package/dist/slider-value.d.mts +11 -0
- package/dist/slider-value.mjs +1 -0
- package/dist/slider.d.mts +6 -3
- package/dist/slider.mjs +1 -1
- package/dist/styles.d.mts +82 -1
- package/dist/styles.mjs +1 -0
- package/dist/use-slider.d.mts +28 -5
- package/dist/use-slider.mjs +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
+
import { Slider as Slider$1 } from './slider.mjs';
|
|
4
|
+
import { SliderControl } from './slider-control.mjs';
|
|
5
|
+
import { SliderTrack } from './slider-track.mjs';
|
|
6
|
+
import { SliderIndicator } from './slider-indicator.mjs';
|
|
7
|
+
import { SliderThumb } from './slider-thumb.mjs';
|
|
8
|
+
import { SliderValue } from './slider-value.mjs';
|
|
9
|
+
export { SliderSlots, SliderVariants, slider } from './styles.mjs';
|
|
10
|
+
export { useSliderContext } from './slider-context.mjs';
|
|
2
11
|
export { SliderConfig, useSliderConfig } from './slider-config.mjs';
|
|
3
|
-
import 'react';
|
|
4
12
|
import '@jamsrui/utils';
|
|
5
|
-
import '
|
|
13
|
+
import './use-slider.mjs';
|
|
6
14
|
import '@jamsrui/core';
|
|
15
|
+
|
|
16
|
+
declare const Slider: ((props: Slider$1.Props) => react_jsx_runtime.JSX.Element) & {
|
|
17
|
+
Root: (props: Slider$1.Props) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
Control: (props: SliderControl.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
19
|
+
Track: (props: SliderTrack.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
20
|
+
Indicator: (props: SliderIndicator.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
21
|
+
Thumb: (props: SliderThumb.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
22
|
+
Value: (props: SliderValue.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
23
|
+
};
|
|
24
|
+
declare namespace Slider {
|
|
25
|
+
interface Props extends Slider$1.Props {
|
|
26
|
+
}
|
|
27
|
+
interface ControlProps extends SliderControl.Props {
|
|
28
|
+
}
|
|
29
|
+
interface TrackProps extends SliderTrack.Props {
|
|
30
|
+
}
|
|
31
|
+
interface IndicatorProps extends SliderIndicator.Props {
|
|
32
|
+
}
|
|
33
|
+
interface ThumbProps extends SliderThumb.Props {
|
|
34
|
+
}
|
|
35
|
+
interface ValueProps extends SliderValue.Props {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { Slider, SliderControl, SliderIndicator, SliderThumb, SliderTrack, SliderValue };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"
|
|
1
|
+
import{Slider as r}from"./slider.mjs";import{SliderControl as e}from"./slider-control.mjs";import{SliderTrack as o}from"./slider-track.mjs";import{SliderIndicator as t}from"./slider-indicator.mjs";import{SliderThumb as i}from"./slider-thumb.mjs";import{SliderValue as p}from"./slider-value.mjs";import{slider as d}from"./styles.mjs";import{useSliderContext as l}from"./slider-context.mjs";import{SliderConfig as s,useSliderConfig as n}from"./slider-config.mjs";const C=Object.assign(r,{Root:r,Control:e,Track:o,Indicator:t,Thumb:i,Value:p});export{C as Slider,s as SliderConfig,e as SliderControl,t as SliderIndicator,i as SliderThumb,o as SliderTrack,p as SliderValue,d as slider,n as useSliderConfig,l as useSliderContext};
|
package/dist/slider-config.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Slider } from './slider.mjs';
|
|
2
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
4
|
-
import '
|
|
2
|
+
import { WithGlobalConfig } from '@jamsrui/core';
|
|
3
|
+
import { Slider } from './slider.mjs';
|
|
5
4
|
import '@jamsrui/utils';
|
|
5
|
+
import './use-slider.mjs';
|
|
6
|
+
import 'react';
|
|
7
|
+
import './styles.mjs';
|
|
6
8
|
|
|
7
9
|
declare const useSliderConfig: () => Record<string, any>;
|
|
8
10
|
declare const SliderConfig: (props: Omit<Partial<Record<string, any>>, "children"> & {
|
|
@@ -10,7 +12,7 @@ declare const SliderConfig: (props: Omit<Partial<Record<string, any>>, "children
|
|
|
10
12
|
children: React.ReactNode;
|
|
11
13
|
}) => react_jsx_runtime.JSX.Element;
|
|
12
14
|
declare namespace SliderConfig {
|
|
13
|
-
interface Props extends
|
|
15
|
+
interface Props extends WithGlobalConfig<Slider.Props> {
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
package/dist/slider-config.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createConfigContext as
|
|
1
|
+
"use client";import{createConfigContext as e}from"@jamsrui/utils";const[o,r]=e({displayName:"SliderConfig"});export{o as SliderConfig,r as useSliderConfig};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
|
|
3
|
+
type SliderContextValue = {
|
|
4
|
+
values: number[];
|
|
5
|
+
min: number;
|
|
6
|
+
max: number;
|
|
7
|
+
step: number;
|
|
8
|
+
orientation: "horizontal" | "vertical";
|
|
9
|
+
isDisabled: boolean;
|
|
10
|
+
minStepsBetweenThumbs: number;
|
|
11
|
+
registerThumb: (index: number, ref: React.RefObject<HTMLDivElement>) => void;
|
|
12
|
+
handleThumbPointerDown: (index: number, event: React.PointerEvent) => void;
|
|
13
|
+
getPercentageForValue: (value: number) => number;
|
|
14
|
+
onTrackPointerDown: (event: React.PointerEvent) => void;
|
|
15
|
+
trackRef: React.RefObject<HTMLDivElement | null>;
|
|
16
|
+
};
|
|
17
|
+
declare const SliderContext: react.Context<SliderContextValue | null>;
|
|
18
|
+
declare const useSliderContext: () => SliderContextValue;
|
|
19
|
+
|
|
20
|
+
export { SliderContext, type SliderContextValue, useSliderContext };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as t,useContext as n}from"react";const r=t(null),i=()=>{const e=n(r);if(!e)throw new Error("useSliderContext must be used within a Slider");return e};export{r as SliderContext,i as useSliderContext};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
|
|
4
|
+
declare const SliderControl: (props: SliderControl.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SliderControl {
|
|
6
|
+
interface Props extends UIProps<"div"> {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SliderControl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useRenderElement as d}from"@jamsrui/hooks";import{useSliderContext as m}from"./slider-context.mjs";import{slider as c}from"./styles.mjs";const C=e=>{const{render:r,children:o,className:t,...s}=e,{orientation:n,isDisabled:i}=m(),{control:l}=c({orientation:n,isDisabled:i}),p=l({className:t});return d("div",{props:{...s,children:o,className:p,render:r}})};export{C as SliderControl};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
|
|
4
|
+
declare const SliderIndicator: (props: SliderIndicator.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SliderIndicator {
|
|
6
|
+
interface Props extends UIProps<"div"> {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SliderIndicator };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useRenderElement as $}from"@jamsrui/hooks";import{useSliderContext as b}from"./slider-context.mjs";import{slider as v}from"./styles.mjs";const U=h=>{const{render:f,children:g,className:x,...l}=h,{orientation:o,isDisabled:u,values:e,getPercentageForValue:n,min:a,max:P}=b(),{indicator:y}=v({orientation:o,isDisabled:u}),I=y({className:x});let c=0,s=0,d=0,i=0;if(e.length===1){const t=n(e[0]??a);o==="horizontal"?s=t:i=t}else if(e.length>1){const t=n(e[0]??a),m=n(e[e.length-1]??P),r=Math.min(t,m),p=Math.max(t,m);o==="horizontal"?(c=r,s=p-r):(d=r,i=p-r)}const S=o==="horizontal"?{left:`${c}%`,width:`${s}%`}:{bottom:`${d}%`,height:`${i}%`};return $("div",{props:{...l,children:g,className:I,style:{...l.style,...S},render:f}})};export{U as SliderIndicator};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UIProps } from '@jamsrui/utils';
|
|
2
|
+
import react__default from 'react';
|
|
3
|
+
|
|
4
|
+
declare const SliderThumb: (props: SliderThumb.Props) => react__default.ReactElement<unknown, string | react__default.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SliderThumb {
|
|
6
|
+
interface Props extends UIProps<"div"> {
|
|
7
|
+
index?: number;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { SliderThumb };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useRenderElement as v}from"@jamsrui/hooks";import{useRef as y,useLayoutEffect as S}from"react";import{useSliderContext as T}from"./slider-context.mjs";import{slider as E}from"./styles.mjs";const N=l=>{const{render:m,children:d,className:u,index:e=0,...o}=l,{orientation:t,isDisabled:r,values:c,getPercentageForValue:p,registerThumb:n,handleThumbPointerDown:f}=T(),{thumb:b}=E({orientation:t,isDisabled:r}),h=b({className:u}),s=y(null);S(()=>{n(e,s)},[e,n]);const i=c[e]??0,a=p(i),P=t==="horizontal"?{left:`${a}%`,transform:"translateX(-50%)",position:"absolute"}:{bottom:`${a}%`,transform:"translateY(50%)",position:"absolute"};return v("div",{props:{...o,children:d,className:h,ref:s,style:{...o.style,...P},onPointerDown:x=>f(e,x),tabIndex:r?void 0:0,role:"slider","aria-valuenow":i,"aria-disabled":r,"aria-orientation":t,render:m}})};export{N as SliderThumb};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
|
|
4
|
+
declare const SliderTrack: (props: SliderTrack.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SliderTrack {
|
|
6
|
+
interface Props extends UIProps<"div"> {
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SliderTrack };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useRenderElement as l}from"@jamsrui/hooks";import{useSliderContext as m}from"./slider-context.mjs";import{slider as f}from"./styles.mjs";const T=e=>{const{render:r,children:o,className:t,...n}=e,{orientation:s,isDisabled:i,onTrackPointerDown:c,trackRef:p}=m(),{track:a}=f({orientation:s,isDisabled:i}),d=a({className:t});return l("div",{props:{...n,children:o,className:d,onPointerDown:c,ref:p,render:r}})};export{T as SliderTrack};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
|
|
4
|
+
declare const SliderValue: (props: SliderValue.Props) => react.ReactElement<unknown, string | react.JSXElementConstructor<any>>;
|
|
5
|
+
declare namespace SliderValue {
|
|
6
|
+
interface Props extends Omit<UIProps<"div">, "children"> {
|
|
7
|
+
children?: React.ReactNode | ((values: number[]) => React.ReactNode);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { SliderValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{useRenderElement as p}from"@jamsrui/hooks";import{useSliderContext as m}from"./slider-context.mjs";import{slider as u}from"./styles.mjs";const P=o=>{const{render:n,children:e,className:s,...i}=o,{values:t,orientation:l,isDisabled:a}=m(),{value:c}=u({orientation:l,isDisabled:a}),d=c({className:s});let r;return typeof e=="function"?r=e(t):e?r=e:r=t.join(" - "),p("div",{props:{...i,children:r,className:d,render:n}})};export{P as SliderValue};
|
package/dist/slider.d.mts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { UIProps } from '@jamsrui/utils';
|
|
3
|
+
import { UseSliderProps } from './use-slider.mjs';
|
|
4
|
+
import { SliderVariants } from './styles.mjs';
|
|
5
|
+
import 'react';
|
|
3
6
|
|
|
4
|
-
declare const Slider: (props: Slider.Props) =>
|
|
7
|
+
declare const Slider: (props: Slider.Props) => react_jsx_runtime.JSX.Element;
|
|
5
8
|
declare namespace Slider {
|
|
6
|
-
interface Props extends UIProps<"div"
|
|
9
|
+
interface Props extends Omit<UIProps<"div">, "onChange" | "defaultValue">, SliderVariants, UseSliderProps {
|
|
7
10
|
}
|
|
8
11
|
}
|
|
9
12
|
|
package/dist/slider.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRenderElement as
|
|
1
|
+
"use client";import{jsx as R}from"react/jsx-runtime";import{useRenderElement as b}from"@jamsrui/hooks";import{SliderContext as h}from"./slider-context.mjs";import{useSlider as C}from"./use-slider.mjs";import{slider as U}from"./styles.mjs";const V=o=>{const{render:i,children:s,className:n,defaultValue:a,value:d,onChange:l,min:m,max:p,step:c,orientation:r,isDisabled:t,minStepsBetweenThumbs:u,name:S,...f}=o,e=C({defaultValue:a,value:d,onChange:l,min:m,max:p,step:c,orientation:r,isDisabled:t,minStepsBetweenThumbs:u,name:S}),{root:P}=U({orientation:r,isDisabled:t}),x=P({className:n}),v=b("div",{props:{...f,children:s,className:x,"data-orientation":e.orientation,"data-disabled":e.isDisabled?"":void 0,render:i}});return R(h.Provider,{value:e,children:v})},T=V;export{T as Slider};
|
package/dist/styles.d.mts
CHANGED
|
@@ -1,2 +1,83 @@
|
|
|
1
|
+
import * as _jamsrui_utils from '@jamsrui/utils';
|
|
2
|
+
import { VariantProps } from '@jamsrui/utils';
|
|
1
3
|
|
|
2
|
-
|
|
4
|
+
declare const slider: _jamsrui_utils.TVReturnType<{
|
|
5
|
+
orientation: {
|
|
6
|
+
horizontal: {
|
|
7
|
+
root: string;
|
|
8
|
+
control: string;
|
|
9
|
+
};
|
|
10
|
+
vertical: {
|
|
11
|
+
control: string;
|
|
12
|
+
root: string;
|
|
13
|
+
track: string;
|
|
14
|
+
indicator: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
isDisabled: {
|
|
18
|
+
true: {
|
|
19
|
+
root: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
root: string;
|
|
24
|
+
control: string;
|
|
25
|
+
track: string;
|
|
26
|
+
indicator: string;
|
|
27
|
+
thumb: string;
|
|
28
|
+
value: string;
|
|
29
|
+
}, undefined, {
|
|
30
|
+
orientation: {
|
|
31
|
+
horizontal: {
|
|
32
|
+
root: string;
|
|
33
|
+
control: string;
|
|
34
|
+
};
|
|
35
|
+
vertical: {
|
|
36
|
+
control: string;
|
|
37
|
+
root: string;
|
|
38
|
+
track: string;
|
|
39
|
+
indicator: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
isDisabled: {
|
|
43
|
+
true: {
|
|
44
|
+
root: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}, {
|
|
48
|
+
root: string;
|
|
49
|
+
control: string;
|
|
50
|
+
track: string;
|
|
51
|
+
indicator: string;
|
|
52
|
+
thumb: string;
|
|
53
|
+
value: string;
|
|
54
|
+
}, _jamsrui_utils.TVReturnType<{
|
|
55
|
+
orientation: {
|
|
56
|
+
horizontal: {
|
|
57
|
+
root: string;
|
|
58
|
+
control: string;
|
|
59
|
+
};
|
|
60
|
+
vertical: {
|
|
61
|
+
control: string;
|
|
62
|
+
root: string;
|
|
63
|
+
track: string;
|
|
64
|
+
indicator: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
isDisabled: {
|
|
68
|
+
true: {
|
|
69
|
+
root: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
root: string;
|
|
74
|
+
control: string;
|
|
75
|
+
track: string;
|
|
76
|
+
indicator: string;
|
|
77
|
+
thumb: string;
|
|
78
|
+
value: string;
|
|
79
|
+
}, undefined, unknown, unknown, undefined>>;
|
|
80
|
+
type SliderVariants = VariantProps<typeof slider>;
|
|
81
|
+
type SliderSlots = keyof ReturnType<typeof slider>;
|
|
82
|
+
|
|
83
|
+
export { type SliderSlots, type SliderVariants, slider };
|
package/dist/styles.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{tv as o}from"@jamsrui/utils";const e=o({slots:{root:"relative flex touch-none select-none items-center",control:"flex items-center",track:"relative h-5 w-full grow overflow-hidden rounded-full bg-neutral-200 dark:bg-neutral-800",indicator:"absolute h-full bg-primary",thumb:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",value:"text-sm"},variants:{orientation:{horizontal:{root:"w-full",control:"w-full"},vertical:{control:"h-full",root:"h-full flex-col",track:"h-full w-5",indicator:"w-full bottom-0"}},isDisabled:{true:{root:"opacity-50 cursor-not-allowed"}}},defaultVariants:{orientation:"horizontal"}});export{e as slider};
|
package/dist/use-slider.d.mts
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import react__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface UseSliderProps {
|
|
4
|
+
value?: number | number[];
|
|
5
|
+
defaultValue?: number | number[];
|
|
6
|
+
onChange?: (value: number | number[]) => void;
|
|
7
|
+
min?: number;
|
|
8
|
+
max?: number;
|
|
9
|
+
step?: number;
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
minStepsBetweenThumbs?: number;
|
|
13
|
+
name?: string;
|
|
5
14
|
}
|
|
15
|
+
declare const useSlider: (props: UseSliderProps) => {
|
|
16
|
+
values: number[];
|
|
17
|
+
min: number;
|
|
18
|
+
max: number;
|
|
19
|
+
step: number;
|
|
20
|
+
orientation: "horizontal" | "vertical";
|
|
21
|
+
isDisabled: boolean;
|
|
22
|
+
minStepsBetweenThumbs: number;
|
|
23
|
+
trackRef: react__default.RefObject<HTMLDivElement | null>;
|
|
24
|
+
registerThumb: (index: number, ref: react__default.RefObject<HTMLDivElement>) => void;
|
|
25
|
+
handleThumbPointerDown: (index: number, event: react__default.PointerEvent) => void;
|
|
26
|
+
onTrackPointerDown: (event: react__default.PointerEvent) => void;
|
|
27
|
+
getPercentageForValue: (val: number) => number;
|
|
28
|
+
};
|
|
6
29
|
|
|
7
|
-
export { useSlider };
|
|
30
|
+
export { type UseSliderProps, useSlider };
|
package/dist/use-slider.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const r=e=>{};
|
|
1
|
+
"use client";import{useControlledState as A}from"@jamsrui/hooks";import{useCallback as d,useRef as D,useState as U}from"react";const C=(w,c,l)=>Math.min(Math.max(w,c),l),O=w=>{const{value:c,defaultValue:l,onChange:R,min:o=0,max:m=100,step:f=1,orientation:E="horizontal",isDisabled:p=!1,minStepsBetweenThumbs:S=0}=w,[g,L]=A({prop:c===void 0?void 0:Array.isArray(c)?c:[c],defaultProp:l===void 0?[o]:Array.isArray(l)?l:[l],onChange:n=>{R&&R(n)}}),M=D(null),T=D([]),V=d((n,r)=>{T.current[n]=r},[]),v=d(n=>{const r=M.current;if(!r)return o;const e=r.getBoundingClientRect(),t=E==="vertical",a=t?e.height:e.width,i=t?n.clientY:n.clientX,u=t?e.top:e.left;let s=(i-u)/a;t&&(s=1-s),s=C(s,0,1);const P=o+s*(m-o),y=Math.round((P-o)/f)*f+o;return C(y,o,m)},[o,m,f,E]),b=d((n,r)=>{L(e=>{if(!e)return[n];const t=[...e];return t[r]=n,t.sort((a,i)=>a-i),t})},[L]),[B,h]=U(null),x=d((n,r)=>{if(p)return;r.preventDefault(),r.stopPropagation();const e=T.current[n]?.current;e&&(e.setPointerCapture(r.pointerId),e.focus()),h(n);const t=i=>{const u=v(i);b(u,n)},a=i=>{e&&e.releasePointerCapture(i.pointerId),h(null),window.removeEventListener("pointermove",t),window.removeEventListener("pointerup",a)};window.addEventListener("pointermove",t),window.addEventListener("pointerup",a)},[p,v,b]),k=d(n=>{if(p)return;const r=v(n);let e=0,t=1/0;g.forEach((u,s)=>{const P=Math.abs(u-r);P<t&&(t=P,e=s)}),b(r,e),h(e);const a=u=>{const s=v(u);b(s,e)},i=()=>{h(null),window.removeEventListener("pointermove",a),window.removeEventListener("pointerup",i)};window.addEventListener("pointermove",a),window.addEventListener("pointerup",i)},[p,v,g,b]),I=d(n=>(n-o)/(m-o)*100,[o,m]);return{values:g,min:o,max:m,step:f,orientation:E,isDisabled:p,minStepsBetweenThumbs:S,trackRef:M,registerThumb:V,handleThumbPointerDown:x,onTrackPointerDown:k,getPercentageForValue:I}};export{O as useSlider};
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jamsrui/slider",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"react": ">=19"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jamsrui/hooks": "^0.0.
|
|
9
|
-
"@jamsrui/
|
|
10
|
-
"@jamsrui/
|
|
8
|
+
"@jamsrui/hooks": "^0.0.17",
|
|
9
|
+
"@jamsrui/core": "^0.0.14",
|
|
10
|
+
"@jamsrui/utils": "^0.0.17"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|