UNPKG

@snowball-tech/fractal

Version:

Fractal's (Snowball's design system) React component library based on RadixUI and PandaCSS

3 lines 1.79 kB
'use client'; import{a as i}from"./chunk-T734KD6C.js";import{b as t}from"./chunk-CMFNILWJ.js";import{a,b as R}from"./chunk-XYM7TA65.js";import*as r from"@radix-ui/react-slider";import{useId as F}from"react";import $ from"lodash/fp/isFunction";import n from"lodash/fp/isNumber";import O from"lodash/fp/omit";import U from"lodash/fp/range";import{jsx as d,jsxs as j}from"react/jsx-runtime";var _=({defaultValue:o,disabled:f=!1,id:y,inverted:N=!1,label:u,max:w=100,min:k=0,minStepsBetweenThumbs:T=0,name:I,onValueChange:c,onValueCommit:b,orientation:m="horizontal",step:P=1,value:e,...p})=>{let h=F(),g=(y??h)||h,x=e||o,s=n(x)?1:x?.length??1,z=U(0)(s),C=l=>{$(c)&&c(s===1?l[0]:l)},E=l=>{$(b)&&b(s===1?l[0]:l)};return j(r.Root,{id:g,"aria-label":u,className:R(`${t}-${i}`,"relative box-border flex rounded-full border-1 border-normal",m==="vertical"?"h-full max-h-full w-1 flex-col justify-center":"h-1 w-full max-w-full items-center",p.className),defaultValue:n(o)?[o]:o,disabled:f,inverted:N,max:w,min:k,minStepsBetweenThumbs:T,name:I||g,orientation:m,step:P,value:n(e)?[e]:e,onValueChange:C,onValueCommit:E,...O(["className","dir"],p),children:[d(r.Track,{className:a(`${t}-${i}__track`,"relative h-full w-full flex-1 rounded-full",f?"bg-disabled":"bg-highlight",m==="vertical"?"w-1":""),children:d(r.Range,{className:a(`${t}-${i}__range`,"absolute rounded-full bg-secondary transition-transform delay-100 duration-600 [transition-property:cubic-bezier(0.65,0,0.35,1)]",m==="vertical"?"w-full":"h-full")})}),z.map((l,S)=>d(r.Thumb,{"aria-label":u,className:a(`${t}-${i}__thumb`,`${t}-${i}__thumb--${S}`,"block size-2 rounded-full bg-secondary"),title:n(e)?String(e):void 0},`thumbs-${S}`))]})};_.displayName="Slider";var D=_;export{_ as a,D as b}; //# sourceMappingURL=chunk-WKDKJOVD.js.map