UNPKG

@vela-ui/react

Version:

Vela UI React components

3 lines (2 loc) 3.75 kB
"use client" "use strict";"use client";var y=Object.create;var p=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var R=(t,e)=>{for(var o in e)p(t,o,{get:e[o],enumerable:!0})},f=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of k(e))!T.call(t,r)&&r!==o&&p(t,r,{get:()=>e[r],enumerable:!(n=P(e,r))||n.enumerable});return t};var g=(t,e,o)=>(o=t!=null?y(v(t)):{},f(e||!t||!t.__esModule?p(o,"default",{value:t,enumerable:!0}):o,t)),w=t=>f(p({},"__esModule",{value:!0}),t);var G={};R(G,{Slider:()=>E,SliderOutput:()=>D,SliderRange:()=>q,SliderThumb:()=>B,SliderTrack:()=>F});module.exports=w(G);var S=g(require("react")),a=require("react-aria-components"),b=require("tailwind-variants");var m=g(require("react"));function x(t={}){let{strict:e=!0,errorMessage:o="useContext: `context` is undefined. Seems you forgot to wrap component within the Provider",name:n}=t,r=m.createContext(void 0);r.displayName=n;function i(){var d;let s=m.useContext(r);if(!s&&e){let c=new Error(o);throw c.name="ContextError",(d=Error.captureStackTrace)==null||d.call(Error,c,i),c}return s}return[r.Provider,i,r]}var l=require("react/jsx-runtime"),z=(0,b.tv)({slots:{root:"group relative isolate flex touch-none flex-col gap-2",track:"bg-muted relative grow cursor-pointer rounded-full",range:"bg-primary absolute rounded-full",thumb:"border-primary bg-background ring-ring/50 top-[50%] left-[50%] block shrink-0 rounded-full border shadow-sm transition-[color,box-shadow] hover:ring-4",output:"text-muted-foreground text-sm"},variants:{orientation:{horizontal:{root:"",track:"w-full",range:"h-full"},vertical:{root:"",track:"h-full",range:"w-full"}},size:{sm:{track:"data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:w-1.5",thumb:"size-4"},md:{track:"data-[orientation=horizontal]:h-2 data-[orientation=vertical]:w-2",thumb:"size-5"},lg:{track:"data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5",thumb:"size-6"}},isDisabled:{true:{track:"cursor-default",range:"bg-primary/15",thumb:"pointer-events-none opacity-50"}},isFocusable:{true:{thumb:"ring-4 outline-hidden"}}},defaultVariants:{size:"md"}}),{root:A,track:V,range:N,thumb:O,output:$}=z(),[M,C]=x({name:"SliderContext"});function E({className:t,size:e,children:o,...n}){return(0,l.jsx)(a.Slider,{"data-slot":"slider",className:(0,a.composeRenderProps)(t,(r,i)=>A({...i,className:r})),...n,children:(0,a.composeRenderProps)(o,(r,{orientation:i})=>(0,l.jsx)(M,{value:{orientation:i,size:e},children:r}))})}function D({className:t,...e}){return(0,l.jsx)(a.SliderOutput,{"data-slot":"slider-output",className:(0,a.composeRenderProps)(t,(o,n)=>$({...n,className:o})),...e})}function F({className:t,...e}){let{orientation:o,size:n}=C();return(0,l.jsx)(a.SliderTrack,{"data-slot":"slider-track",className:(0,a.composeRenderProps)(t,(r,i)=>V({...i,className:r,orientation:o,size:n})),...e})}function q({className:t,style:e,...o}){let n=S.default.useContext(a.SliderStateContext),{orientation:r,isDisabled:i,getThumbPercent:s,values:d}=n||{};return(0,l.jsx)("div",{"data-slot":"slider-range",style:{...(()=>{let u=s?s(0)*100:0,h=s?s(1)*100:0;return(d==null?void 0:d.length)===1?r==="horizontal"?{width:`${u}%`}:{height:`${u}%`}:r==="horizontal"?{left:`${u}%`,width:`${Math.abs(u-h)}%`}:{bottom:`${u}%`,height:`${Math.abs(u-h)}%`}})(),...e},className:N({orientation:r,isDisabled:i,className:t}),...o})}function B({className:t,...e}){let{size:o}=C();return(0,l.jsx)(a.SliderThumb,{"data-slot":"slider-thumb",className:(0,a.composeRenderProps)(t,(n,r)=>O({...r,className:n,size:o})),...e})}0&&(module.exports={Slider,SliderOutput,SliderRange,SliderThumb,SliderTrack});