@radui/ui 1.0.0 → 1.1.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/dist/components/Accordion.cjs +1 -0
- package/dist/components/Accordion.js +1 -1
- package/dist/components/AlertDialog.cjs +1 -0
- package/dist/components/AlertDialog.d.ts +61 -24
- package/dist/components/AlertDialog.js +1 -1
- package/dist/components/AspectRatio.cjs +1 -0
- package/dist/components/Avatar.cjs +1 -0
- package/dist/components/Avatar.d.ts +36 -6
- package/dist/components/Avatar.js +1 -1
- package/dist/components/AvatarGroup.cjs +1 -0
- package/dist/components/AvatarGroup.d.ts +39 -18
- package/dist/components/AvatarGroup.js +1 -1
- package/dist/components/AvatarPrimitiveFallback-BpUU1vNV.cjs +1 -0
- package/dist/components/{AvatarPrimitiveFallback-C1siRii4.js → AvatarPrimitiveFallback-DIXB9Tnm.js} +1 -1
- package/dist/components/Badge.cjs +1 -0
- package/dist/components/Badge.js +1 -1
- package/dist/components/BlockQuote.cjs +1 -0
- package/dist/components/Breadcrumb.cjs +1 -0
- package/dist/components/Breadcrumb.js +1 -1
- package/dist/components/Button.cjs +1 -0
- package/dist/components/Button.js +1 -1
- package/dist/components/Callout.cjs +1 -0
- package/dist/components/Callout.d.ts +32 -18
- package/dist/components/Callout.js +1 -1
- package/dist/components/Card.cjs +1 -0
- package/dist/components/Card.d.ts +31 -16
- package/dist/components/Card.js +1 -1
- package/dist/components/Checkbox.cjs +8 -0
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/CheckboxCards.cjs +1 -0
- package/dist/components/CheckboxCards.js +1 -1
- package/dist/components/CheckboxGroup.cjs +1 -0
- package/dist/components/CheckboxGroup.d.ts +6 -2
- package/dist/components/CheckboxGroup.js +1 -1
- package/dist/components/{CheckboxGroupPrimitive-DfHQYkep.js → CheckboxGroupPrimitive-BRCGIztp.js} +1 -1
- package/dist/components/CheckboxGroupPrimitive-C21WO4L3.cjs +1 -0
- package/dist/components/Code.cjs +1 -0
- package/dist/components/Collapsible.cjs +1 -0
- package/dist/components/Collapsible.d.ts +34 -4
- package/dist/components/Collapsible.js +1 -1
- package/dist/components/Combobox.cjs +1 -0
- package/dist/components/Combobox.d.ts +57 -45
- package/dist/components/Combobox.js +1 -1
- package/dist/components/ComboboxPrimitive-BdX2jgpQ.js +1 -0
- package/dist/components/ComboboxPrimitive-CyO6ZH5T.cjs +1 -0
- package/dist/components/Command.cjs +1 -0
- package/dist/components/Command.d.ts +36 -8
- package/dist/components/Command.js +1 -1
- package/dist/components/ContextMenu.cjs +1 -0
- package/dist/components/ContextMenu.d.ts +25 -11
- package/dist/components/ContextMenu.js +1 -1
- package/dist/components/DataList.cjs +1 -0
- package/dist/components/Dialog.cjs +1 -0
- package/dist/components/Dialog.d.ts +29 -4
- package/dist/components/Dialog.js +1 -1
- package/dist/components/Disclosure.cjs +1 -0
- package/dist/components/Disclosure.js +1 -1
- package/dist/components/Drawer.cjs +1 -0
- package/dist/components/Drawer.d.ts +31 -3
- package/dist/components/Drawer.js +1 -1
- package/dist/components/DropdownMenu.cjs +1 -0
- package/dist/components/DropdownMenu.d.ts +25 -11
- package/dist/components/DropdownMenu.js +1 -1
- package/dist/components/Em.cjs +1 -0
- package/dist/components/Fieldset.cjs +1 -0
- package/dist/components/Heading.cjs +1 -0
- package/dist/components/HoverCard.cjs +1 -0
- package/dist/components/HoverCard.d.ts +15 -1
- package/dist/components/HoverCard.js +1 -1
- package/dist/components/Kbd.cjs +1 -0
- package/dist/components/Label.cjs +1 -0
- package/dist/components/Label.d.ts +18 -0
- package/dist/components/Label.js +1 -0
- package/dist/components/Link.cjs +1 -0
- package/dist/components/Link.js +1 -1
- package/dist/components/LiveRegion.cjs +1 -0
- package/dist/components/LiveRegion.d.ts +2 -5
- package/dist/components/LiveRegion.js +1 -1
- package/dist/components/MenuPrimitive-Ctqo21Vd.cjs +1 -0
- package/dist/components/MenuPrimitive-Cy_MJfjG.js +1 -0
- package/dist/components/Menubar.cjs +1 -0
- package/dist/components/Menubar.d.ts +45 -16
- package/dist/components/Menubar.js +1 -1
- package/dist/components/Meter.cjs +1 -0
- package/dist/components/Meter.d.ts +44 -0
- package/dist/components/Meter.js +1 -0
- package/dist/components/Minimap.cjs +1 -0
- package/dist/components/Minimap.js +1 -1
- package/dist/components/NavigationMenu.cjs +1 -0
- package/dist/components/NavigationMenu.d.ts +2 -0
- package/dist/components/NavigationMenu.js +1 -1
- package/dist/components/NumberField.cjs +1 -0
- package/dist/components/Popover.cjs +1 -0
- package/dist/components/Popover.d.ts +64 -5
- package/dist/components/Popover.js +1 -1
- package/dist/components/Progress.cjs +1 -0
- package/dist/components/Progress.d.ts +14 -2
- package/dist/components/Progress.js +1 -1
- package/dist/components/Quote.cjs +1 -0
- package/dist/components/Radio.cjs +1 -0
- package/dist/components/Radio.js +1 -1
- package/dist/components/RadioCards.cjs +1 -0
- package/dist/components/RadioCards.d.ts +22 -1
- package/dist/components/RadioCards.js +1 -1
- package/dist/components/RadioGroup.cjs +1 -0
- package/dist/components/RadioGroup.d.ts +27 -7
- package/dist/components/RadioGroup.js +1 -1
- package/dist/components/RadioGroupPrimitive-B0CrM2bi.cjs +1 -0
- package/dist/components/RadioGroupPrimitive-CnPy0zgW.js +1 -0
- package/dist/components/ScrollArea.cjs +1 -0
- package/dist/components/ScrollArea.d.ts +24 -13
- package/dist/components/ScrollArea.js +1 -1
- package/dist/components/Select.cjs +1 -0
- package/dist/components/Select.d.ts +52 -44
- package/dist/components/Select.js +1 -1
- package/dist/components/Separator.cjs +1 -0
- package/dist/components/Separator.d.ts +8 -1
- package/dist/components/Separator.js +1 -1
- package/dist/components/Skeleton.cjs +1 -0
- package/dist/components/Slider.cjs +1 -0
- package/dist/components/Slider.js +1 -1
- package/dist/components/Spinner.cjs +1 -0
- package/dist/components/Splitter.cjs +1 -0
- package/dist/components/Steps.cjs +1 -0
- package/dist/components/Steps.d.ts +33 -16
- package/dist/components/Steps.js +1 -1
- package/dist/components/Strong.cjs +1 -0
- package/dist/components/Switch.cjs +1 -0
- package/dist/components/Switch.d.ts +14 -2
- package/dist/components/Switch.js +1 -1
- package/dist/components/TabNav.cjs +1 -0
- package/dist/components/TabNav.d.ts +5 -0
- package/dist/components/TabNav.js +1 -1
- package/dist/components/Table.cjs +1 -0
- package/dist/components/Table.d.ts +23 -12
- package/dist/components/Table.js +1 -1
- package/dist/components/Tabs.cjs +1 -0
- package/dist/components/Tabs.js +1 -1
- package/dist/components/Text.cjs +1 -0
- package/dist/components/TextArea.cjs +1 -0
- package/dist/components/TextField.cjs +1 -0
- package/dist/components/Theme.cjs +1 -0
- package/dist/components/Theme.d.ts +2 -0
- package/dist/components/Theme.js +1 -1
- package/dist/components/ThemeContext-t7IX-w6i.cjs +1 -0
- package/dist/components/Toast.cjs +1 -0
- package/dist/components/Toast.js +1 -1
- package/dist/components/Toggle.cjs +1 -0
- package/dist/components/Toggle.js +1 -1
- package/dist/components/ToggleGroup.cjs +1 -0
- package/dist/components/ToggleGroup.js +1 -1
- package/dist/components/Toolbar.cjs +1 -0
- package/dist/components/Toolbar.d.ts +8 -1
- package/dist/components/Toolbar.js +1 -1
- package/dist/components/Tooltip.cjs +1 -0
- package/dist/components/Tooltip.d.ts +7 -1
- package/dist/components/Tooltip.js +1 -1
- package/dist/components/Tree.cjs +1 -0
- package/dist/components/Tree.d.ts +8 -1
- package/dist/components/Tree.js +1 -1
- package/dist/components/VisuallyHidden.cjs +1 -0
- package/dist/components/VisuallyHidden.d.ts +6 -1
- package/dist/components/VisuallyHidden.js +1 -1
- package/dist/components/check-BazcmpuG.cjs +44 -0
- package/dist/components/documentOverlayOpen-BbC6uByx.cjs +1 -0
- package/dist/components/{floating-ui.react-2kiGB4sW.js → floating-ui.react-CZf-mCiA.js} +1 -1
- package/dist/components/floating-ui.react-Kw0_L48Q.cjs +5 -0
- package/dist/components/index-7Bjw6jmo.cjs +1 -0
- package/dist/components/index-BZO29jsF.cjs +1 -0
- package/dist/components/index-B_OPdW20.js +1 -0
- package/dist/components/index-BbvJO-A-.cjs +1 -0
- package/dist/components/index-Bg-UeWCo.cjs +1 -0
- package/dist/components/index-BidxkqdT.js +1 -0
- package/dist/components/index-BudP4FIn.cjs +1 -0
- package/dist/components/index-BwNOI8cB.cjs +1 -0
- package/dist/components/{index-DMX7gpdp.js → index-CAD0hWja.js} +1 -1
- package/dist/components/{index-xlB--dex.js → index-CXv1Y-O3.js} +1 -1
- package/dist/components/index-C_Yiql9j.cjs +1 -0
- package/dist/components/index-CbdoW3TC.cjs +1 -0
- package/dist/components/{index-nYRBURkR.js → index-Cp5L_alO.js} +1 -1
- package/dist/components/{index-C7dBo_Ry.js → index-D8QLtYJh.js} +1 -1
- package/dist/components/{index-FITGoHty.js → index-DH-14XDv.js} +1 -1
- package/dist/components/index-DrMwbB8q.cjs +1 -0
- package/dist/components/index-K0sE1H4u.cjs +1 -0
- package/dist/components/index-c6NFMS_0.cjs +1 -0
- package/dist/components/index-rUSzFrhJ.cjs +1 -0
- package/dist/components/keyboard-BBlFllyi.cjs +1 -0
- package/dist/components/mergeProps-DW5qFqqJ.cjs +1 -0
- package/dist/components/mergeRefs-BUn-enYe.cjs +1 -0
- package/dist/components/useComponentClass-B0DF90tm.cjs +1 -0
- package/dist/index.cjs +70 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.js +69 -0
- package/dist/styles/clarity/Accordion/accordion.clarity.scss +147 -0
- package/dist/styles/clarity/AlertDialog/alert-dialog.clarity.scss +199 -0
- package/dist/styles/clarity/Avatar/_avatar-base.clarity.scss +87 -0
- package/dist/styles/clarity/Avatar/avatar.clarity.scss +1 -0
- package/dist/styles/clarity/AvatarGroup/avatar-group.clarity.scss +122 -0
- package/dist/styles/clarity/Badge/badge.clarity.scss +118 -0
- package/dist/styles/clarity/BlockQuote/blockquote.clarity.scss +123 -0
- package/dist/styles/clarity/Breadcrumb/breadcrumb.clarity.scss +50 -0
- package/dist/styles/clarity/Button/button.clarity.scss +132 -0
- package/dist/styles/clarity/Callout/callout.clarity.scss +183 -0
- package/dist/styles/clarity/Card/card.clarity.scss +121 -0
- package/dist/styles/clarity/Checkbox/checkbox.clarity.scss +75 -0
- package/dist/styles/clarity/CheckboxCards/checkbox-cards.clarity.scss +143 -0
- package/dist/styles/clarity/CheckboxGroup/checkbox-group.clarity.scss +92 -0
- package/dist/styles/clarity/Code/code.clarity.scss +42 -0
- package/dist/styles/clarity/Collapsible/collapsible.clarity.scss +84 -0
- package/dist/styles/clarity/Combobox/combobox.clarity.scss +157 -0
- package/dist/styles/clarity/Command/command.clarity.scss +231 -0
- package/dist/styles/clarity/ContextMenu/context-menu.clarity.scss +272 -0
- package/dist/styles/clarity/DataList/data-list.clarity.scss +60 -0
- package/dist/styles/clarity/Dialog/dialog.clarity.scss +205 -0
- package/dist/styles/clarity/Disclosure/disclosure.clarity.scss +56 -0
- package/dist/styles/clarity/Drawer/drawer.clarity.scss +331 -0
- package/dist/styles/clarity/DropdownMenu/dropdown-menu.clarity.scss +187 -0
- package/dist/styles/clarity/Em/em.clarity.scss +3 -0
- package/dist/styles/clarity/Fieldset/fieldset.clarity.scss +49 -0
- package/dist/styles/clarity/Heading/heading.clarity.scss +46 -0
- package/dist/styles/clarity/HoverCard/hover-card.clarity.scss +43 -0
- package/dist/styles/clarity/Kbd/kbd.clarity.scss +55 -0
- package/dist/styles/clarity/Label/label.clarity.scss +11 -0
- package/dist/styles/clarity/Link/link.clarity.scss +41 -0
- package/dist/styles/clarity/Menubar/menubar.clarity.scss +149 -0
- package/dist/styles/clarity/Meter/meter.clarity.scss +39 -0
- package/dist/styles/clarity/Minimap/minimap.clarity.scss +92 -0
- package/dist/styles/clarity/NavigationMenu/navigation-menu.clarity.scss +128 -0
- package/dist/styles/clarity/NumberField/number-field.clarity.scss +135 -0
- package/dist/styles/clarity/Popover/popover.clarity.scss +106 -0
- package/dist/styles/clarity/Progress/progress.clarity.scss +38 -0
- package/dist/styles/clarity/Quote/quote.clarity.scss +26 -0
- package/dist/styles/clarity/Radio/radio.clarity.scss +76 -0
- package/dist/styles/clarity/RadioCards/radiocards.clarity.scss +134 -0
- package/dist/styles/clarity/RadioGroup/radio-group.clarity.scss +99 -0
- package/dist/styles/clarity/ScrollArea/scroll-area.clarity.scss +112 -0
- package/dist/styles/clarity/Select/select.clarity.scss +228 -0
- package/dist/styles/clarity/Separator/separator.clarity.scss +23 -0
- package/dist/styles/clarity/Skeleton/skeleton.clarity.scss +33 -0
- package/dist/styles/clarity/Slider/slider.clarity.scss +203 -0
- package/dist/styles/clarity/Spinner/spinner.clarity.scss +52 -0
- package/dist/styles/clarity/Splitter/splitter.clarity.scss +151 -0
- package/dist/styles/clarity/Steps/steps.clarity.scss +143 -0
- package/dist/styles/clarity/Strong/strong.clarity.scss +6 -0
- package/dist/styles/clarity/Switch/switch.clarity.scss +89 -0
- package/dist/styles/clarity/TabNav/tab-nav.clarity.scss +69 -0
- package/dist/styles/clarity/Table/table.clarity.scss +128 -0
- package/dist/styles/clarity/Tabs/tabs.clarity.scss +91 -0
- package/dist/styles/clarity/Text/text.clarity.scss +5 -0
- package/dist/styles/clarity/TextArea/textarea.clarity.scss +146 -0
- package/dist/styles/clarity/TextField/text-field.clarity.scss +120 -0
- package/dist/styles/clarity/Toast/toast.clarity.scss +203 -0
- package/dist/styles/clarity/Toggle/toggle.clarity.scss +51 -0
- package/dist/styles/clarity/ToggleGroup/toggle-group.clarity.scss +103 -0
- package/dist/styles/clarity/Toolbar/toolbar.clarity.scss +140 -0
- package/dist/styles/clarity/Tooltip/tooltip.clarity.scss +37 -0
- package/dist/styles/clarity/Tree/tree.clarity.scss +103 -0
- package/dist/themes/baremetal.css +1 -1
- package/dist/themes/default.css +1 -1
- package/package.json +21 -2
- package/dist/components/ComboboxPrimitive-DQcJ8pzQ.js +0 -1
- package/dist/components/MenuPrimitive-D9VMz2TZ.js +0 -1
- package/dist/components/RadioGroupPrimitive-D1PP4y2M.js +0 -1
- package/dist/components/index-D8I-rMwz.js +0 -1
- package/dist/components/index-XF8itt-H.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import r,{createContext as n,forwardRef as o,useRef as i,useCallback as l}from"react";import{u as s,c as u}from"./useComponentClass-C0isGl1z.js";import{u as c}from"./index-wRElCyvx.js";import{P as m}from"./index-XF8itt-H.js";import{K as d}from"./keyboard-BKF7hXqL.js";import{m as p}from"./mergeRefs-B8eZ_q-T.js";import"./ThemeContext-Sm-iNANd.js";import"./mergeProps-0RucjqeH.js";const h=n({rootClass:"",value:0,setValue:()=>{},commitValue:()=>{},minValue:0,maxValue:100,step:1,name:void 0,isDragging:!1,setDragging:()=>{},disabled:!1,orientation:"horizontal",pageStepMultiplier:10,showStepMarks:!1,formatValue:void 0,rootRef:{current:null},thumbRefs:void 0,registerThumbRef:void 0}),f=e=>{if(!Number.isFinite(e))return 0;const t=String(e),a=/e-(\d+)$/i.exec(t);if(a){return(t.split(/e/i)[0].split(".")[1]||"").length+Number(a[1])}return(t.split(".")[1]||"").length},v=(e,t,a)=>{const r=Math.min(Math.max(f(t),f(a)),15);return Number(e.toFixed(r))},b=(e,t,a)=>{if(!(t>0))return e;const r=Math.round((e-a)/t)*t+a;return v(r,t,a)},g=(e,t,a)=>Math.min(a,Math.max(t,e)),y=(e,t,a,r)=>({lower:t>0?e[t-1]:a,upper:t<e.length-1?e[t+1]:r}),x="Slider",w=o((({children:t,className:a="",customRootClass:n="",defaultValue:o,value:m,onValueChange:d,onValueCommit:p,min:f=0,max:v=100,step:w=1,disabled:R=!1,name:$,orientation:k="horizontal",pageStepMultiplier:M=10,showStepMarks:N=!1,formatValue:A,onPointerDown:V,...D},S)=>{const P=s(n,x),[C,T]=c(m,o??(Array.isArray(m)?m:0),d),[E,L]=r.useState(!1),O=r.useRef(null),X=r.useRef(null),W=i([]),_=r.useMemo((()=>e=>{X.current=e,"function"==typeof S?S(e):S&&(S.current=e)}),[S]),B=r.useRef(C);B.current=C;const F=l((e=>{B.current=e,T(e)}),[T]),j=l((e=>{p?.(void 0===e?B.current:e)}),[p]),I=l(((e,t)=>{W.current[e]=t}),[]),U=e=>{const t=X.current;if(!t)return null;const a=t.getBoundingClientRect(),r="vertical"===k?a.height:a.width;if(!r)return null;const n="vertical"===k?(a.bottom-e.clientY)/r:(e.clientX-a.left)/r,o=f+g(n,0,1)*(v-f);return i=b(o,w,f),g(i,f,v);var i},K=e=>{const t=U(e);if(null===t)return;const a=B.current;if(Array.isArray(a)){if(0===a.length)return;let e=O.current;if(null===e){let r=0,n=1/0;if(a.forEach(((e,a)=>{const o=Math.abs(e-t);(o<n||o===n&&t>e)&&(r=a,n=o)})),0===n&&a.filter((e=>e===t)).length>1)return;e=r,O.current=e,W.current[e]?.current?.focus()}const{lower:r,upper:n}=y(a,e,f,v),o=g(t,r,n);if(o===a[e])return;const i=[...a];i[e]=o,F(i)}else t!==a&&F(t)},z={rootClass:P,value:C,setValue:F,commitValue:j,minValue:f,maxValue:v,step:w,name:$,isDragging:E,setDragging:L,disabled:R,orientation:k,pageStepMultiplier:M,showStepMarks:N,formatValue:A,rootRef:X,thumbRefs:W.current,registerThumbRef:I};return e(h.Provider,{value:z,children:e("div",{ref:_,className:u(P,a),"data-slider-root":P,"data-disabled":R,"data-orientation":k,...D,onPointerDown:e=>{if(V?.(e),R||e.defaultPrevented||e.button>0)return;e.stopPropagation();const t=e.target,a=W.current.findIndex((e=>{const a=e?.current;return!!a&&(a===t||a.contains(t))})),r=B.current,n=-1!==a&&Array.isArray(r)&&r.some(((e,t)=>t!==a&&e===r[a]));-1!==a&&Array.isArray(r)&&!n?(O.current=a,W.current[a]?.current?.focus()):(O.current=null,Array.isArray(r)||W.current[0]?.current?.focus()),L(!0),K(e);const o=e=>{e.preventDefault(),K(e)},i=()=>{L(!1),O.current=null,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),j()};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)},children:t})})}));w.displayName=x;const R=o((({children:t,className:a,style:n,...o},i)=>{const{rootClass:l,orientation:s}=r.useContext(h),c="vertical"===s?{rotate:"180deg",position:"relative"}:{position:"relative"},m=u(l?`${l}-track`:void 0,a)||void 0;return e("div",{ref:i,className:m,style:{...n,...c},...o,children:t})}));R.displayName="SliderTrack";const $=r.memo(o((({children:n,asChild:o=!1,index:i=0,"aria-label":l,"aria-labelledby":s,className:c,style:f,onKeyDown:b,onPointerDown:x,onPointerUp:w,onFocus:R,onBlur:$,...k},M)=>{const{rootClass:N,value:A,minValue:V,maxValue:D,step:S,setValue:P,commitValue:C,name:T,isDragging:E,setDragging:L,disabled:O,orientation:X,pageStepMultiplier:W,formatValue:_,registerThumbRef:B}=r.useContext(h),F=r.useRef(null);r.useEffect((()=>{B&&F.current&&B(i,F)}),[i,B]);const j=Array.isArray(A)&&i>=0&&i<A.length?A[i]:"number"==typeof A?A:V,I=Number.isFinite(j)?j:V,U=Math.min(D,Math.max(V,I)),K=D===V?0:(U-V)/(D-V)*100,[z,G]=r.useState(!1),H=E?"dragging":z?"active":"inactive",Y=e(m.div,{ref:p(F,M),asChild:o,className:u(N?`${N}-thumb`:void 0,c)||void 0,role:"slider",tabIndex:O?-1:0,"aria-valuemin":V,"aria-valuemax":D,"aria-valuenow":U,"aria-valuetext":_?_(U):void 0,"aria-orientation":X,"aria-label":l,"aria-labelledby":s,"aria-disabled":O||void 0,"data-state":H,"data-disabled":O,"data-index":i,onKeyDown:e=>{if(b?.(e),O||e.defaultPrevented)return;let t=U;const a=Boolean(e.currentTarget.closest('[dir="rtl"]'));switch(e.key){case d.ARROW_RIGHT:t=a?U-S:U+S;break;case d.ARROW_LEFT:t=a?U+S:U-S;break;case d.ARROW_UP:t=U+S;break;case d.ARROW_DOWN:t=U-S;break;case d.HOME:t=V;break;case d.END:t=D;break;case d.PAGE_UP:t=U+S*W;break;case d.PAGE_DOWN:t=U-S*W;break;default:return}e.preventDefault();const r=Array.isArray(A)?y(A,i,V,D):{lower:V,upper:D},n=g(v(t,S,V),r.lower,r.upper);if(n===U)return;let o;if(Array.isArray(A)){const e=[...A];e[i]=n,o=e}else o=n;P(o),C(o)},onPointerDown:e=>{x?.(e),O||e.defaultPrevented||(e.currentTarget.focus(),L(!0))},onPointerUp:e=>{w?.(e),L(!1)},onFocus:e=>{R?.(e),G(!0)},onBlur:e=>{$?.(e),G(!1)},style:{...f,..."vertical"===X?{top:`calc(${K}% - 10px)`}:{left:`calc(${K}% - 10px)`}},...k,children:n});return t(a,{children:[Y,void 0!==T&&e("input",{type:"hidden",value:U,name:Array.isArray(A)?`${T}[${i}]`:T,disabled:O})]})})));$.displayName="SliderThumb";const k=o((({children:t,className:a,style:n,...o},i)=>{const{rootClass:l,value:s,minValue:c,maxValue:m,orientation:d}=r.useContext(h);let p=0,f=0;if(Array.isArray(s))if(0===s.length)p=0,f=0;else{const e=[...s].sort(((e,t)=>e-t)),t=e[0],a=e[e.length-1];p=m===c?0:(t-c)/(m-c)*100,f=m===c?0:(a-c)/(m-c)*100,1===s.length&&(p=0)}else p=0,f=m===c?0:(s-c)/(m-c)*100;const v=f-p,b=u(l?`${l}-range`:void 0,a)||void 0;return e("div",{ref:i,className:b,style:{...n,..."vertical"===d?{height:`${v}%`,marginTop:100-f+"%"}:{marginLeft:`${p}%`,width:`${v}%`}},...o,children:t})}));k.displayName="SliderRange";const M=o((({children:a,customMarks:n,...o},i)=>{const{rootClass:l,minValue:s,maxValue:u,step:c,orientation:m,showStepMarks:d}=r.useContext(h);if(!d&&!n)return null;const p=[];if(n)n.forEach((({value:a,label:r})=>{const n=u===s?0:(a-s)/(u-s)*100;p.push(t("div",{className:l?`${l}-mark ${l}-mark-custom`:void 0,"data-testid":`mark-${a}`,style:"vertical"===m?{bottom:`${n}%`,left:"50%",transform:"translateX(-50%)"}:{left:`${n}%`,top:0,transform:"translateX(-50%)"},"data-value":a,children:[e("div",{className:l?`${l}-mark-line`:void 0,style:"vertical"===m?{width:"2px",height:"12px",position:"absolute",bottom:"-6px",left:"50%",transform:"translateX(-50%)"}:{width:"1px",height:"6px",position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)"}}),r&&e("span",{className:l?`${l}-mark-label`:void 0,style:"vertical"===m?{right:"16px",top:"50%",transform:"translateY(-50%)",whiteSpace:"nowrap"}:{top:"8px",left:"50%",transform:"translateX(-50%)",whiteSpace:"nowrap"},children:r})]},a))}));else for(let t=s;t<=u;t+=c){const a=u===s?0:(t-s)/(u-s)*100;p.push(e("div",{className:l?`${l}-mark`:void 0,"data-testid":`mark-${t}`,style:"vertical"===m?{bottom:`${a}%`,left:"50%",transform:"translateX(-50%)"}:{left:`${a}%`,top:0,transform:"translateX(-50%)"},"data-value":t,children:e("div",{className:l?`${l}-mark-line`:void 0,style:"vertical"===m?{width:"2px",height:"8px",position:"absolute",bottom:"-4px",left:"50%",transform:"translateX(-50%)"}:{width:"1px",height:"4px",position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)"}})},t))}return t("div",{ref:i,className:l?`${l}-marks`:void 0,style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:1},...o,children:[p,a]})}));M.displayName="SliderMarks";const N=o((({children:a,"aria-label":n,"aria-labelledby":o,defaultValue:i=[25,75],value:l,onValueChange:s,...u},c)=>{const{rootClass:p,minValue:f,maxValue:v,step:g,disabled:y,orientation:x,rootRef:w}=r.useContext(h),[R,$]=r.useState(l||i),k=l??R,[M,N]=r.useState(null),[A,V]=r.useState(null),D=r.useRef(0),S=e=>Math.min(v,Math.max(f,e)),P=e=>{$(e),s?.(e)},C=v===f?0:(k[0]-f)/(v-f)*100,T=v===f?0:(k[1]-f)/(v-f)*100,E=(e,t)=>{const a=e.currentTarget.getBoundingClientRect();let r;r="vertical"===x?(a.bottom-e.clientY)/a.height:(e.clientX-a.left)/a.width;const n=b(f+r*(v-f),g,f),o=S(n),i=[...k];i["lower"===t?0:1]=o,"lower"===t?i[0]=Math.min(i[0],k[1]):i[1]=Math.max(i[1],k[0]),P(i)},L=(e,t)=>{if(y)return;e.stopPropagation(),N(t),E(e,t);const a=e=>{e.preventDefault();const a=w.current;if(!a)return;const r=a.getBoundingClientRect();let n;n="vertical"===x?(r.bottom-e.clientY)/r.height:(e.clientX-r.left)/r.width;const o=b(f+n*(v-f),g,f),i=S(o),l=[...k];l["lower"===t?0:1]=i,"lower"===t?l[0]=Math.min(l[0],k[1]):l[1]=Math.max(l[1],k[0]);const s=performance.now();s-D.current>16&&(P(l),D.current=s)},r=()=>{N(null),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",r)};document.addEventListener("pointermove",a),document.addEventListener("pointerup",r)},O=(e,t)=>{M&&M===t&&(e.preventDefault(),E(e,t))},X=()=>{N(null)},W=(e,t)=>{if(y)return;const a=[...k],r=Boolean(e.currentTarget.closest('[dir="rtl"]'));switch(e.key){case d.ARROW_RIGHT:a["lower"===t?0:1]=r?k["lower"===t?0:1]-g:k["lower"===t?0:1]+g;break;case d.ARROW_LEFT:a["lower"===t?0:1]=r?k["lower"===t?0:1]+g:k["lower"===t?0:1]-g;break;case d.ARROW_UP:a["lower"===t?0:1]=k["lower"===t?0:1]+g;break;case d.ARROW_DOWN:a["lower"===t?0:1]=k["lower"===t?0:1]-g;break;case d.HOME:a["lower"===t?0:1]=f;break;case d.END:a["lower"===t?0:1]=v;break;default:return}e.preventDefault(),"lower"===t?a[0]=Math.min(a[0],k[1]):a[1]=Math.max(a[1],k[0]),a[0]=S(a[0]),a[1]=S(a[1]),P(a)};return t("div",{ref:c,className:p?`${p}-range-slider`:void 0,...u,children:[e(m.div,{className:p?`${p}-thumb ${p}-thumb-lower`:void 0,role:"slider",tabIndex:y?-1:0,"aria-valuemin":f,"aria-valuemax":v,"aria-valuenow":k[0],"aria-orientation":x,"aria-label":n?`${n} minimum`:"Minimum value","aria-labelledby":o,"data-state":"lower"===M?"dragging":"lower"===A?"active":"inactive","data-disabled":y,onKeyDown:e=>W(e,"lower"),onFocus:()=>V("lower"),onBlur:()=>V(null),onPointerDown:e=>L(e,"lower"),onPointerMove:e=>O(e,"lower"),onPointerUp:X,style:"vertical"===x?{bottom:`calc(${C}% - 8px)`}:{left:`calc(${C}% - 8px)`}}),e(m.div,{className:p?`${p}-thumb ${p}-thumb-upper`:void 0,role:"slider",tabIndex:y?-1:0,"aria-valuemin":f,"aria-valuemax":v,"aria-valuenow":k[1],"aria-orientation":x,"aria-label":n?`${n} maximum`:"Maximum value","aria-labelledby":o,"data-state":"upper"===M?"dragging":"upper"===A?"active":"inactive","data-disabled":y,onKeyDown:e=>W(e,"upper"),onFocus:()=>V("upper"),onBlur:()=>V(null),onPointerDown:e=>L(e,"upper"),onPointerMove:e=>O(e,"upper"),onPointerUp:X,style:"vertical"===x?{bottom:`calc(${T}% - 8px)`}:{left:`calc(${T}% - 8px)`}}),e("div",{className:p?`${p}-range-fill`:void 0,style:"vertical"===x?{bottom:`${Math.min(C,T)}%`,height:`${Math.abs(T-C)}%`,left:0,right:0}:{left:`${Math.min(C,T)}%`,width:`${Math.abs(T-C)}%`,top:0,bottom:0}}),a]})}));N.displayName="SliderRangeSlider";const A=(e,t)=>2===t?0===e?"minimum":"maximum":`${e+1} of ${t}`,V=o(((r,n)=>{const{defaultValue:o,min:i=0,max:l=100,step:s=1,orientation:u="horizontal",formatValue:c,"aria-label":m,"aria-labelledby":d,...p}=r,h=r.value??o,f=Array.isArray(h)?Math.max(h.length,1):1;return e(V.Root,{ref:n,defaultValue:o,min:i,max:l,step:s,orientation:u,formatValue:c,...p,children:f>1?t(a,{children:[e(V.Track,{children:e(V.Range,{})}),Array.from({length:f},((t,a)=>e(V.Thumb,{index:a,"aria-label":m?`${m} ${A(a,f)}`:void 0,"aria-labelledby":d},a)))]}):e(V.Track,{children:e(V.Range,{children:e(V.Thumb,{"aria-label":m,"aria-labelledby":d})})})})}));V.displayName="Slider",V.Root=w,V.Track=R,V.Range=k,V.Thumb=$,V.Marks=M,V.RangeSlider=N;export{M as Marks,k as Range,N as RangeSlider,w as Root,$ as Thumb,R as Track,V as default};
|
|
1
|
+
'use client';import{jsx as e,jsxs as t,Fragment as a}from"react/jsx-runtime";import r,{createContext as n,forwardRef as o,useRef as i,useCallback as l}from"react";import{u as s,c as u}from"./useComponentClass-C0isGl1z.js";import{u as c}from"./index-wRElCyvx.js";import{P as m}from"./index-BidxkqdT.js";import{K as d}from"./keyboard-BKF7hXqL.js";import{m as p}from"./mergeRefs-B8eZ_q-T.js";import"./ThemeContext-Sm-iNANd.js";import"./mergeProps-0RucjqeH.js";const h=n({rootClass:"",value:0,setValue:()=>{},commitValue:()=>{},minValue:0,maxValue:100,step:1,name:void 0,isDragging:!1,setDragging:()=>{},disabled:!1,orientation:"horizontal",pageStepMultiplier:10,showStepMarks:!1,formatValue:void 0,rootRef:{current:null},thumbRefs:void 0,registerThumbRef:void 0}),f=e=>{if(!Number.isFinite(e))return 0;const t=String(e),a=/e-(\d+)$/i.exec(t);if(a){return(t.split(/e/i)[0].split(".")[1]||"").length+Number(a[1])}return(t.split(".")[1]||"").length},v=(e,t,a)=>{const r=Math.min(Math.max(f(t),f(a)),15);return Number(e.toFixed(r))},b=(e,t,a)=>{if(!(t>0))return e;const r=Math.round((e-a)/t)*t+a;return v(r,t,a)},g=(e,t,a)=>Math.min(a,Math.max(t,e)),y=(e,t,a,r)=>({lower:t>0?e[t-1]:a,upper:t<e.length-1?e[t+1]:r}),x="Slider",w=o((({children:t,className:a="",customRootClass:n="",defaultValue:o,value:m,onValueChange:d,onValueCommit:p,min:f=0,max:v=100,step:w=1,disabled:R=!1,name:$,orientation:k="horizontal",pageStepMultiplier:M=10,showStepMarks:N=!1,formatValue:A,onPointerDown:V,...D},S)=>{const P=s(n,x),[C,T]=c(m,o??(Array.isArray(m)?m:0),d),[E,L]=r.useState(!1),O=r.useRef(null),X=r.useRef(null),W=i([]),_=r.useMemo((()=>e=>{X.current=e,"function"==typeof S?S(e):S&&(S.current=e)}),[S]),B=r.useRef(C);B.current=C;const F=l((e=>{B.current=e,T(e)}),[T]),j=l((e=>{p?.(void 0===e?B.current:e)}),[p]),I=l(((e,t)=>{W.current[e]=t}),[]),U=e=>{const t=X.current;if(!t)return null;const a=t.getBoundingClientRect(),r="vertical"===k?a.height:a.width;if(!r)return null;const n="vertical"===k?(a.bottom-e.clientY)/r:(e.clientX-a.left)/r,o=f+g(n,0,1)*(v-f);return i=b(o,w,f),g(i,f,v);var i},K=e=>{const t=U(e);if(null===t)return;const a=B.current;if(Array.isArray(a)){if(0===a.length)return;let e=O.current;if(null===e){let r=0,n=1/0;if(a.forEach(((e,a)=>{const o=Math.abs(e-t);(o<n||o===n&&t>e)&&(r=a,n=o)})),0===n&&a.filter((e=>e===t)).length>1)return;e=r,O.current=e,W.current[e]?.current?.focus()}const{lower:r,upper:n}=y(a,e,f,v),o=g(t,r,n);if(o===a[e])return;const i=[...a];i[e]=o,F(i)}else t!==a&&F(t)},z={rootClass:P,value:C,setValue:F,commitValue:j,minValue:f,maxValue:v,step:w,name:$,isDragging:E,setDragging:L,disabled:R,orientation:k,pageStepMultiplier:M,showStepMarks:N,formatValue:A,rootRef:X,thumbRefs:W.current,registerThumbRef:I};return e(h.Provider,{value:z,children:e("div",{ref:_,className:u(P,a),"data-slider-root":P,"data-disabled":R,"data-orientation":k,...D,onPointerDown:e=>{if(V?.(e),R||e.defaultPrevented||e.button>0)return;e.stopPropagation();const t=e.target,a=W.current.findIndex((e=>{const a=e?.current;return!!a&&(a===t||a.contains(t))})),r=B.current,n=-1!==a&&Array.isArray(r)&&r.some(((e,t)=>t!==a&&e===r[a]));-1!==a&&Array.isArray(r)&&!n?(O.current=a,W.current[a]?.current?.focus()):(O.current=null,Array.isArray(r)||W.current[0]?.current?.focus()),L(!0),K(e);const o=e=>{e.preventDefault(),K(e)},i=()=>{L(!1),O.current=null,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),document.removeEventListener("pointercancel",i),j()};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i),document.addEventListener("pointercancel",i)},children:t})})}));w.displayName=x;const R=o((({children:t,className:a,style:n,...o},i)=>{const{rootClass:l,orientation:s}=r.useContext(h),c="vertical"===s?{rotate:"180deg",position:"relative"}:{position:"relative"},m=u(l?`${l}-track`:void 0,a)||void 0;return e("div",{ref:i,className:m,style:{...n,...c},...o,children:t})}));R.displayName="SliderTrack";const $=r.memo(o((({children:n,asChild:o=!1,index:i=0,"aria-label":l,"aria-labelledby":s,className:c,style:f,onKeyDown:b,onPointerDown:x,onPointerUp:w,onFocus:R,onBlur:$,...k},M)=>{const{rootClass:N,value:A,minValue:V,maxValue:D,step:S,setValue:P,commitValue:C,name:T,isDragging:E,setDragging:L,disabled:O,orientation:X,pageStepMultiplier:W,formatValue:_,registerThumbRef:B}=r.useContext(h),F=r.useRef(null);r.useEffect((()=>{B&&F.current&&B(i,F)}),[i,B]);const j=Array.isArray(A)&&i>=0&&i<A.length?A[i]:"number"==typeof A?A:V,I=Number.isFinite(j)?j:V,U=Math.min(D,Math.max(V,I)),K=D===V?0:(U-V)/(D-V)*100,[z,G]=r.useState(!1),H=E?"dragging":z?"active":"inactive",Y=e(m.div,{ref:p(F,M),asChild:o,className:u(N?`${N}-thumb`:void 0,c)||void 0,role:"slider",tabIndex:O?-1:0,"aria-valuemin":V,"aria-valuemax":D,"aria-valuenow":U,"aria-valuetext":_?_(U):void 0,"aria-orientation":X,"aria-label":l,"aria-labelledby":s,"aria-disabled":O||void 0,"data-state":H,"data-disabled":O,"data-index":i,onKeyDown:e=>{if(b?.(e),O||e.defaultPrevented)return;let t=U;const a=Boolean(e.currentTarget.closest('[dir="rtl"]'));switch(e.key){case d.ARROW_RIGHT:t=a?U-S:U+S;break;case d.ARROW_LEFT:t=a?U+S:U-S;break;case d.ARROW_UP:t=U+S;break;case d.ARROW_DOWN:t=U-S;break;case d.HOME:t=V;break;case d.END:t=D;break;case d.PAGE_UP:t=U+S*W;break;case d.PAGE_DOWN:t=U-S*W;break;default:return}e.preventDefault();const r=Array.isArray(A)?y(A,i,V,D):{lower:V,upper:D},n=g(v(t,S,V),r.lower,r.upper);if(n===U)return;let o;if(Array.isArray(A)){const e=[...A];e[i]=n,o=e}else o=n;P(o),C(o)},onPointerDown:e=>{x?.(e),O||e.defaultPrevented||(e.currentTarget.focus(),L(!0))},onPointerUp:e=>{w?.(e),L(!1)},onFocus:e=>{R?.(e),G(!0)},onBlur:e=>{$?.(e),G(!1)},style:{...f,..."vertical"===X?{top:`calc(${K}% - 10px)`}:{left:`calc(${K}% - 10px)`}},...k,children:n});return t(a,{children:[Y,void 0!==T&&e("input",{type:"hidden",value:U,name:Array.isArray(A)?`${T}[${i}]`:T,disabled:O})]})})));$.displayName="SliderThumb";const k=o((({children:t,className:a,style:n,...o},i)=>{const{rootClass:l,value:s,minValue:c,maxValue:m,orientation:d}=r.useContext(h);let p=0,f=0;if(Array.isArray(s))if(0===s.length)p=0,f=0;else{const e=[...s].sort(((e,t)=>e-t)),t=e[0],a=e[e.length-1];p=m===c?0:(t-c)/(m-c)*100,f=m===c?0:(a-c)/(m-c)*100,1===s.length&&(p=0)}else p=0,f=m===c?0:(s-c)/(m-c)*100;const v=f-p,b=u(l?`${l}-range`:void 0,a)||void 0;return e("div",{ref:i,className:b,style:{...n,..."vertical"===d?{height:`${v}%`,marginTop:100-f+"%"}:{marginLeft:`${p}%`,width:`${v}%`}},...o,children:t})}));k.displayName="SliderRange";const M=o((({children:a,customMarks:n,...o},i)=>{const{rootClass:l,minValue:s,maxValue:u,step:c,orientation:m,showStepMarks:d}=r.useContext(h);if(!d&&!n)return null;const p=[];if(n)n.forEach((({value:a,label:r})=>{const n=u===s?0:(a-s)/(u-s)*100;p.push(t("div",{className:l?`${l}-mark ${l}-mark-custom`:void 0,"data-testid":`mark-${a}`,style:"vertical"===m?{bottom:`${n}%`,left:"50%",transform:"translateX(-50%)"}:{left:`${n}%`,top:0,transform:"translateX(-50%)"},"data-value":a,children:[e("div",{className:l?`${l}-mark-line`:void 0,style:"vertical"===m?{width:"2px",height:"12px",position:"absolute",bottom:"-6px",left:"50%",transform:"translateX(-50%)"}:{width:"1px",height:"6px",position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)"}}),r&&e("span",{className:l?`${l}-mark-label`:void 0,style:"vertical"===m?{right:"16px",top:"50%",transform:"translateY(-50%)",whiteSpace:"nowrap"}:{top:"8px",left:"50%",transform:"translateX(-50%)",whiteSpace:"nowrap"},children:r})]},a))}));else for(let t=s;t<=u;t+=c){const a=u===s?0:(t-s)/(u-s)*100;p.push(e("div",{className:l?`${l}-mark`:void 0,"data-testid":`mark-${t}`,style:"vertical"===m?{bottom:`${a}%`,left:"50%",transform:"translateX(-50%)"}:{left:`${a}%`,top:0,transform:"translateX(-50%)"},"data-value":t,children:e("div",{className:l?`${l}-mark-line`:void 0,style:"vertical"===m?{width:"2px",height:"8px",position:"absolute",bottom:"-4px",left:"50%",transform:"translateX(-50%)"}:{width:"1px",height:"4px",position:"absolute",top:"100%",left:"50%",transform:"translateX(-50%)"}})},t))}return t("div",{ref:i,className:l?`${l}-marks`:void 0,style:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",zIndex:1},...o,children:[p,a]})}));M.displayName="SliderMarks";const N=o((({children:a,"aria-label":n,"aria-labelledby":o,defaultValue:i=[25,75],value:l,onValueChange:s,...u},c)=>{const{rootClass:p,minValue:f,maxValue:v,step:g,disabled:y,orientation:x,rootRef:w}=r.useContext(h),[R,$]=r.useState(l||i),k=l??R,[M,N]=r.useState(null),[A,V]=r.useState(null),D=r.useRef(0),S=e=>Math.min(v,Math.max(f,e)),P=e=>{$(e),s?.(e)},C=v===f?0:(k[0]-f)/(v-f)*100,T=v===f?0:(k[1]-f)/(v-f)*100,E=(e,t)=>{const a=e.currentTarget.getBoundingClientRect();let r;r="vertical"===x?(a.bottom-e.clientY)/a.height:(e.clientX-a.left)/a.width;const n=b(f+r*(v-f),g,f),o=S(n),i=[...k];i["lower"===t?0:1]=o,"lower"===t?i[0]=Math.min(i[0],k[1]):i[1]=Math.max(i[1],k[0]),P(i)},L=(e,t)=>{if(y)return;e.stopPropagation(),N(t),E(e,t);const a=e=>{e.preventDefault();const a=w.current;if(!a)return;const r=a.getBoundingClientRect();let n;n="vertical"===x?(r.bottom-e.clientY)/r.height:(e.clientX-r.left)/r.width;const o=b(f+n*(v-f),g,f),i=S(o),l=[...k];l["lower"===t?0:1]=i,"lower"===t?l[0]=Math.min(l[0],k[1]):l[1]=Math.max(l[1],k[0]);const s=performance.now();s-D.current>16&&(P(l),D.current=s)},r=()=>{N(null),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",r)};document.addEventListener("pointermove",a),document.addEventListener("pointerup",r)},O=(e,t)=>{M&&M===t&&(e.preventDefault(),E(e,t))},X=()=>{N(null)},W=(e,t)=>{if(y)return;const a=[...k],r=Boolean(e.currentTarget.closest('[dir="rtl"]'));switch(e.key){case d.ARROW_RIGHT:a["lower"===t?0:1]=r?k["lower"===t?0:1]-g:k["lower"===t?0:1]+g;break;case d.ARROW_LEFT:a["lower"===t?0:1]=r?k["lower"===t?0:1]+g:k["lower"===t?0:1]-g;break;case d.ARROW_UP:a["lower"===t?0:1]=k["lower"===t?0:1]+g;break;case d.ARROW_DOWN:a["lower"===t?0:1]=k["lower"===t?0:1]-g;break;case d.HOME:a["lower"===t?0:1]=f;break;case d.END:a["lower"===t?0:1]=v;break;default:return}e.preventDefault(),"lower"===t?a[0]=Math.min(a[0],k[1]):a[1]=Math.max(a[1],k[0]),a[0]=S(a[0]),a[1]=S(a[1]),P(a)};return t("div",{ref:c,className:p?`${p}-range-slider`:void 0,...u,children:[e(m.div,{className:p?`${p}-thumb ${p}-thumb-lower`:void 0,role:"slider",tabIndex:y?-1:0,"aria-valuemin":f,"aria-valuemax":v,"aria-valuenow":k[0],"aria-orientation":x,"aria-label":n?`${n} minimum`:"Minimum value","aria-labelledby":o,"data-state":"lower"===M?"dragging":"lower"===A?"active":"inactive","data-disabled":y,onKeyDown:e=>W(e,"lower"),onFocus:()=>V("lower"),onBlur:()=>V(null),onPointerDown:e=>L(e,"lower"),onPointerMove:e=>O(e,"lower"),onPointerUp:X,style:"vertical"===x?{bottom:`calc(${C}% - 8px)`}:{left:`calc(${C}% - 8px)`}}),e(m.div,{className:p?`${p}-thumb ${p}-thumb-upper`:void 0,role:"slider",tabIndex:y?-1:0,"aria-valuemin":f,"aria-valuemax":v,"aria-valuenow":k[1],"aria-orientation":x,"aria-label":n?`${n} maximum`:"Maximum value","aria-labelledby":o,"data-state":"upper"===M?"dragging":"upper"===A?"active":"inactive","data-disabled":y,onKeyDown:e=>W(e,"upper"),onFocus:()=>V("upper"),onBlur:()=>V(null),onPointerDown:e=>L(e,"upper"),onPointerMove:e=>O(e,"upper"),onPointerUp:X,style:"vertical"===x?{bottom:`calc(${T}% - 8px)`}:{left:`calc(${T}% - 8px)`}}),e("div",{className:p?`${p}-range-fill`:void 0,style:"vertical"===x?{bottom:`${Math.min(C,T)}%`,height:`${Math.abs(T-C)}%`,left:0,right:0}:{left:`${Math.min(C,T)}%`,width:`${Math.abs(T-C)}%`,top:0,bottom:0}}),a]})}));N.displayName="SliderRangeSlider";const A=(e,t)=>2===t?0===e?"minimum":"maximum":`${e+1} of ${t}`,V=o(((r,n)=>{const{defaultValue:o,min:i=0,max:l=100,step:s=1,orientation:u="horizontal",formatValue:c,"aria-label":m,"aria-labelledby":d,...p}=r,h=r.value??o,f=Array.isArray(h)?Math.max(h.length,1):1;return e(V.Root,{ref:n,defaultValue:o,min:i,max:l,step:s,orientation:u,formatValue:c,...p,children:f>1?t(a,{children:[e(V.Track,{children:e(V.Range,{})}),Array.from({length:f},((t,a)=>e(V.Thumb,{index:a,"aria-label":m?`${m} ${A(a,f)}`:void 0,"aria-labelledby":d},a)))]}):e(V.Track,{children:e(V.Range,{children:e(V.Thumb,{"aria-label":m,"aria-labelledby":d})})})})}));V.displayName="Slider",V.Root=w,V.Track=R,V.Range=k,V.Thumb=$,V.Marks=M,V.RangeSlider=N;export{M as Marks,k as Range,N as RangeSlider,w as Root,$ as Thumb,R as Track,V as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),r=require("./useComponentClass-B0DF90tm.cjs"),s=require("./index-c6NFMS_0.cjs");require("./ThemeContext-t7IX-w6i.cjs");const i="Spinner",t=a.forwardRef((({className:a,customRootClass:t="",size:l="",role:n,"aria-label":o,"aria-labelledby":c,"aria-hidden":u,...d},p)=>{const m=r.useComponentClass(t,i),b=s.createDataAttributes("spinner",{size:l}),x=r.clsx(m,a)||void 0;var j;const C=!0===(j=u)||"true"===j?{"aria-hidden":!0,role:n}:{role:n??"status","aria-label":c?o:o??"Loading","aria-labelledby":c};return e.jsx("span",{className:m?`${m}-container`:void 0,children:e.jsx("span",{ref:p,className:x,...C,...d,...b})})}));t.displayName=i,exports.default=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),n=require("./useComponentClass-B0DF90tm.cjs"),r=require("./keyboard-BBlFllyi.cjs");require("./ThemeContext-t7IX-w6i.cjs");const a=t.createContext(null),o=()=>{const e=t.useContext(a);if(!e)throw new Error("Splitter components must be used within a Splitter.Root");return e},i=e=>Math.round(10*e)/10,s=t.forwardRef((({orientation:o="horizontal",children:s,className:l,customRootClass:u="",defaultSizes:c=[50,50],minSizes:d=[0,0],maxSizes:m=[100,100],onSizesChange:f,disabled:v=!1,dir:h,style:x,...S},p)=>{const E=t.useId(),g=n.useComponentClass(u,"Splitter"),R=t.useRef(null),[b,y]=t.useState(c),[C,z]=t.useState(!1),[w,D]=t.useState(null),[P,k]=t.useState({}),[K,A]=t.useState({}),O=t.useRef(null),Y=t.useCallback((e=>{R.current=e,"function"==typeof p?p(e):p&&(p.current=e)}),[p]),I=t.useMemo((()=>{const e=[...d||[]],t=[...m||[]];return Object.entries(P).forEach((([n,r])=>{const a=Number(n);void 0!==r.minSize&&(e[a]=Math.max(e[a]??0,r.minSize)),void 0!==r.maxSize&&(t[a]=Math.min(t[a]??100,r.maxSize))})),{minSizes:e,maxSizes:t}}),[d,m,P]),M=t.useCallback((e=>K[e]??`${E}-panel-${e}`),[K,E]),j=t.useCallback(((e,t)=>(A((n=>n[e]===t?n:{...n,[e]:t})),()=>{A((n=>{if(n[e]!==t)return n;const r={...n};return delete r[e],r}))})),[]),H=t.useCallback(((e,t,n)=>(k((r=>{const a=r[e];if(a?.minSize===t&&a?.maxSize===n)return r;const o={...r};return void 0===t&&void 0===n?delete o[e]:o[e]={minSize:t,maxSize:n},o})),()=>{k((t=>{if(!(e in t))return t;const n={...t};return delete n[e],n}))})),[]),N=t.useRef(null);t.useEffect((()=>()=>{O.current?.(),N.current&&(clearTimeout(N.current),N.current=null)}),[]);const _=t.useRef(b),L=t.useRef(I);_.current=b,L.current=I;const T="horizontal"===o,B=t.useCallback((()=>{if(h)return"rtl"===h;const e=R.current;return!(!e||"undefined"==typeof window||"function"!=typeof window.getComputedStyle)&&"rtl"===window.getComputedStyle(e).direction}),[h]),W=t.useCallback(((e,t=_.current)=>{const n=e,r=e+1,{minSizes:a,maxSizes:o}=L.current,i=(t[n]||0)+(t[r]||0),s=a[n]??0,l=o[n]??100,u=a[r]??0,c=o[r]??100;return{leftPanelIndex:n,rightPanelIndex:r,min:Math.max(s,i-c),max:Math.min(l,i-u),totalAdjacentSize:i}}),[]),q=t.useCallback(((e,t,n=_.current)=>{const r=[...n],{leftPanelIndex:a,rightPanelIndex:o,min:i,max:s,totalAdjacentSize:l}=W(e,r),u=((e,t,n)=>Math.max(t,Math.min(n,e)))(t,i,s);return r[a]=u,r[o]=l-u,r}),[W]),$=t.useCallback((e=>{const t=_.current,{leftPanelIndex:n,min:r,max:a}=W(e,t);return{"aria-valuemin":i(r),"aria-valuemax":i(a),"aria-valuenow":i(t[n]||0)}}),[W]),F=t.useCallback(((e,t=!1)=>{y(e),N.current&&clearTimeout(N.current),f&&(t?f(e):N.current=setTimeout((()=>{f(e)}),16))}),[f]),G=t.useCallback(((e,t)=>{if(v)return;if("button"in t&&0!==t.button)return;t.preventDefault();const n=t.currentTarget;n&&"function"==typeof n.focus&&document.activeElement!==n&&n.focus({preventScroll:!0}),O.current?.();const r=e=>{if("touches"in e){const t=e.touches[0]??e.changedTouches?.[0];return t?T?t.clientX:t.clientY:null}return T?e.clientX:e.clientY},a=r(t);if(null===a)return;const o=[..._.current],i=o.length,s=T&&B()?-1:1,l=n?T?n.offsetWidth:n.offsetHeight:0;z(!0),D(e);let u=null,c=a,d=o;const m=()=>{u=null;const t=(t=>{const n=R.current;if(!n)return d;const r=(T?n.clientWidth:n.clientHeight)-l*Math.max(0,i-1);return r<=0?d:q(e,(o[e]||0)+(t-a)*s/r*100,o)})(c);t.some(((e,t)=>e!==d[t]))&&(d=t,_.current=t,y(t))},h=e=>{const t=r(e);null!==t&&(e.cancelable&&"touches"in e&&e.preventDefault(),c=t,null===u&&(u=requestAnimationFrame(m)))},x=()=>{null!==u&&(cancelAnimationFrame(u),u=null),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",S),document.removeEventListener("touchmove",h),document.removeEventListener("touchend",S),document.removeEventListener("touchcancel",S),O.current=null};function S(){const e=null!==u;x(),e&&m(),z(!1),D(null);d.some(((e,t)=>e!==o[t]))&&f&&(N.current&&(clearTimeout(N.current),N.current=null),f(d))}O.current=x,document.addEventListener("mousemove",h),document.addEventListener("mouseup",S),document.addEventListener("touchmove",h,{passive:!1}),document.addEventListener("touchend",S),document.addEventListener("touchcancel",S)}),[v,T,B,f,q]),V=t.useCallback(((e,t)=>{if(v)return;const n=t.shiftKey?10:1,a=_.current;let o=0;if(T){const e=B()?-n:n;t.key===r.KEYBOARD_KEYS.ARROW_LEFT&&(o=-e),t.key===r.KEYBOARD_KEYS.ARROW_RIGHT&&(o=e)}else t.key===r.KEYBOARD_KEYS.ARROW_UP&&(o=-n),t.key===r.KEYBOARD_KEYS.ARROW_DOWN&&(o=n);if(0===o){if(t.key===r.KEYBOARD_KEYS.HOME||t.key===r.KEYBOARD_KEYS.END){t.preventDefault();const{min:n,max:o}=W(e,a);F(q(e,t.key===r.KEYBOARD_KEYS.HOME?n:o),!0)}}else{t.preventDefault();const n=a[e]||0;F(q(e,n+o),!0)}}),[v,W,T,B,q,F]),X={orientation:o,sizes:b,setSizes:F,getHandleValueAttributes:$,startDrag:G,handleKeyDown:V,isDragging:C,activeHandleIndex:w,rootClass:g,registerPanelConstraints:H,registerPanelId:j,getPanelId:M,disabled:v};return e.jsx(a.Provider,{value:X,children:e.jsx("div",{...S,ref:Y,className:n.clsx(g,l),dir:h,"data-orientation":o,"data-disabled":v?"":void 0,style:{display:"flex",flexDirection:T?"row":"column",width:"100%",height:"100%",...x},children:s})})}));s.displayName="SplitterRoot";const l=t.forwardRef((({index:r,children:a,className:i,style:s,minSize:l,maxSize:u,customRootClass:c,id:d,...m},f)=>{const{sizes:v,orientation:h,rootClass:x,registerPanelConstraints:S,registerPanelId:p,getPanelId:E}=o(),g=d??E?.(r);t.useEffect((()=>{if(d&&p)return p(r,d)}),[d,r,p]),t.useEffect((()=>{if(S&&(void 0!==l||void 0!==u))return S(r,l,u)}),[r,l,u,S]);const R={flexBasis:`${v[r]??0}%`,flexGrow:0,flexShrink:1,overflow:"auto",minWidth:"horizontal"===h?0:void 0,minHeight:"vertical"===h?0:void 0,...s};return e.jsx("div",{...m,ref:f,id:g,className:n.clsx(x&&`${x}-panel`,i),"data-orientation":h,style:R,children:a})}));l.displayName="SplitterPanel";const u=t.forwardRef((({index:t,className:r,"aria-label":a,style:i,customRootClass:s,disabled:l,onMouseDown:u,onTouchStart:c,onKeyDown:d,...m},f)=>{const{startDrag:v,orientation:h,isDragging:x,activeHandleIndex:S,handleKeyDown:p,getHandleValueAttributes:E,rootClass:g,getPanelId:R,disabled:b}=o(),y=Boolean(l||b),C=x&&S===t,z=E(t);return e.jsx("div",{...m,ref:f,className:n.clsx(g&&`${g}-handle`,{active:C},r),role:"separator","aria-orientation":h,"aria-label":a||`${h} resize handle`,...z,"data-orientation":h,"data-dragging":C?"":void 0,"data-disabled":y?"":void 0,"aria-disabled":!!y||void 0,"aria-controls":R?.(t),tabIndex:y?-1:0,onMouseDown:e=>{u?.(e),e.defaultPrevented||y||v(t,e)},onTouchStart:e=>{c?.(e),e.defaultPrevented||y||v(t,e)},onKeyDown:e=>{d?.(e),e.defaultPrevented||y||p(t,e)},style:i})}));u.displayName="SplitterHandle";const c=t.forwardRef(((t,n)=>(console.warn("Direct usage of Splitter is not supported. Please use Splitter.Root, Splitter.Panel, etc. instead."),e.jsx("div",{ref:n,...t}))));c.displayName="Splitter",c.Root=s,c.Panel=l,c.Handle=u,exports.Handle=u,exports.Panel=l,exports.Root=s,exports.default=c;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./useComponentClass-B0DF90tm.cjs"),r=require("./index-Bg-UeWCo.cjs"),i=require("./index-BwNOI8cB.cjs");require("./ThemeContext-t7IX-w6i.cjs"),require("./mergeProps-DW5qFqqJ.cjs");const n=t.createContext(null),o=()=>{const e=t.useContext(n);if(!e)throw new Error("useStepsContext must be used within a StepsContext.Provider");return e},a=t.forwardRef((({children:o,className:a,customRootClass:l,orientation:c="vertical",value:u,defaultValue:d,onValueChange:m,...p},f)=>{const[x,N]=i.useControllableState(u,d??0,m),v=s.useComponentClass(l,"Steps"),[C,S]=t.useState([]),h=t.useCallback((e=>(S((t=>t.includes(e)?t:[...t,e].sort(((e,t)=>{const s=e.compareDocumentPosition(t);return s&Node.DOCUMENT_POSITION_FOLLOWING?-1:s&Node.DOCUMENT_POSITION_PRECEDING?1:0})))),()=>{S((t=>t.includes(e)?t.filter((t=>t!==e)):t))})),[]),b=t.useMemo((()=>({currentStep:x,setCurrentStep:N,rootClass:v,orientation:c,registerItem:h,itemElements:C})),[x,N,v,c,h,C]);return e.jsx(n.Provider,{value:b,children:e.jsx(r.Primitive.div,{ref:f,className:s.clsx(v,a,v&&`${v}-${c}`),"data-orientation":c,...p,children:o})})}));a.displayName="Steps.Root";const l="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,c=t.forwardRef((({children:i,value:n,className:a="",...c},u)=>{const{rootClass:d,currentStep:m,registerItem:p,itemElements:f}=o(),[x,N]=t.useState(null),v=t.useCallback((e=>{N(e),"function"==typeof u?u(e):u&&(u.current=e)}),[u]);l((()=>{if(x&&p)return p(x)}),[x,p]);const C=x&&f?f.indexOf(x):-1,S=null!=n,h=S?(e=>{if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null})(n):C>=0?C:null,b=null!==h&&m===h,j=null!==h&&m>h?"completed":b?"active":"inactive";return e.jsx(r.Primitive.div,{ref:v,className:s.clsx(d&&`${d}-item`,a),"data-state":j,"data-value":S?n:h??void 0,"aria-current":b?"step":void 0,...c,children:i})}));c.displayName="Steps.Item";const u=t.forwardRef((({children:t,className:i="",...n},a)=>{const{rootClass:l}=o();return e.jsx(r.Primitive.div,{ref:a,className:s.clsx(l&&`${l}-track`,i),...n,children:t})}));u.displayName="Steps.Track";const d=t.forwardRef((({children:t,className:i="",...n},a)=>{const{rootClass:l}=o();return e.jsx(r.Primitive.div,{ref:a,className:s.clsx(l&&`${l}-bubble`,i),...n,children:t})}));d.displayName="Steps.Bubble";const m=t.forwardRef((({children:t,className:i="",...n},a)=>{const{rootClass:l}=o();return e.jsx(r.Primitive.div,{ref:a,className:s.clsx(l&&`${l}-line`,i),...n,children:t})}));m.displayName="Steps.Line";const p=t.forwardRef((({children:t,className:i="",...n},a)=>{const{rootClass:l}=o();return e.jsx(r.Primitive.div,{ref:a,className:s.clsx(l&&`${l}-content`,i),...n,children:t})}));p.displayName="Steps.Content";const f=t.forwardRef((({children:t,className:i="",...n},a)=>{const{rootClass:l}=o();return e.jsx(r.Primitive.div,{ref:a,className:s.clsx(l&&`${l}-title`,i),...n,children:t})}));f.displayName="Steps.Title";const x=t.forwardRef((({children:t,className:i="",...n},a)=>{const{rootClass:l}=o();return e.jsx(r.Primitive.div,{ref:a,className:s.clsx(l&&`${l}-description`,i),...n,children:t})}));x.displayName="Steps.Description";const N=Object.assign((()=>(console.warn("Direct usage of Steps is not supported. Please use Steps.Root, Steps.Item, etc. instead."),null)),{Root:a,Item:c,Track:u,Bubble:d,Line:m,Content:p,Title:f,Description:x});exports.Bubble=d,exports.Content=p,exports.Description=x,exports.Item=c,exports.Line=m,exports.Root=a,exports.Title=f,exports.Track=u,exports.default=N;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import Primitive from '~/core/primitives/Primitive';
|
|
2
3
|
|
|
3
|
-
type StepsRootProps = React.
|
|
4
|
+
type StepsRootProps = React.ComponentPropsWithoutRef<typeof Primitive.div> & {
|
|
4
5
|
customRootClass?: string;
|
|
5
6
|
/**
|
|
6
7
|
* Layout direction. Defaults to `vertical`, which is how Steps has always rendered;
|
|
@@ -11,7 +12,9 @@ type StepsRootProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
11
12
|
defaultValue?: number;
|
|
12
13
|
onValueChange?: (value: number) => void;
|
|
13
14
|
};
|
|
14
|
-
declare const StepsRoot: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
15
|
+
declare const StepsRoot: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
16
|
+
asChild?: boolean;
|
|
17
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & {
|
|
15
18
|
customRootClass?: string;
|
|
16
19
|
/**
|
|
17
20
|
* Layout direction. Defaults to `vertical`, which is how Steps has always rendered;
|
|
@@ -23,30 +26,44 @@ declare const StepsRoot: React.ForwardRefExoticComponent<React.HTMLAttributes<HT
|
|
|
23
26
|
onValueChange?: (value: number) => void;
|
|
24
27
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
25
28
|
|
|
26
|
-
type StepItemProps = React.
|
|
29
|
+
type StepItemProps = React.ComponentPropsWithoutRef<typeof Primitive.div> & {
|
|
27
30
|
value?: string | number | null;
|
|
28
31
|
};
|
|
29
|
-
declare const StepItem: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
32
|
+
declare const StepItem: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
33
|
+
asChild?: boolean;
|
|
34
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & {
|
|
30
35
|
value?: string | number | null;
|
|
31
36
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
32
37
|
|
|
33
|
-
type StepTrackProps = React.
|
|
34
|
-
declare const StepTrack: React.ForwardRefExoticComponent<
|
|
38
|
+
type StepTrackProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
39
|
+
declare const StepTrack: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
35
42
|
|
|
36
|
-
type StepBubbleProps = React.
|
|
37
|
-
declare const StepBubble: React.ForwardRefExoticComponent<
|
|
43
|
+
type StepBubbleProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
44
|
+
declare const StepBubble: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
45
|
+
asChild?: boolean;
|
|
46
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
38
47
|
|
|
39
|
-
type StepLineProps = React.
|
|
40
|
-
declare const StepLine: React.ForwardRefExoticComponent<
|
|
48
|
+
type StepLineProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
49
|
+
declare const StepLine: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
50
|
+
asChild?: boolean;
|
|
51
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
41
52
|
|
|
42
|
-
type StepContentProps = React.
|
|
43
|
-
declare const StepContent: React.ForwardRefExoticComponent<
|
|
53
|
+
type StepContentProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
54
|
+
declare const StepContent: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
55
|
+
asChild?: boolean;
|
|
56
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
44
57
|
|
|
45
|
-
type StepTitleProps = React.
|
|
46
|
-
declare const StepTitle: React.ForwardRefExoticComponent<
|
|
58
|
+
type StepTitleProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
59
|
+
declare const StepTitle: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
60
|
+
asChild?: boolean;
|
|
61
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
47
62
|
|
|
48
|
-
type StepDescriptionProps = React.
|
|
49
|
-
declare const StepDescription: React.ForwardRefExoticComponent<
|
|
63
|
+
type StepDescriptionProps = React.ComponentPropsWithoutRef<typeof Primitive.div>;
|
|
64
|
+
declare const StepDescription: React.ForwardRefExoticComponent<Omit<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
65
|
+
asChild?: boolean;
|
|
66
|
+
} & React.RefAttributes<HTMLElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
50
67
|
|
|
51
68
|
declare const StepsComponent: () => null;
|
|
52
69
|
type StepsComponentType = typeof StepsComponent & {
|
package/dist/components/Steps.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e}from"react/jsx-runtime";import t,{createContext as s,useContext as r}from"react";import{u as a,c as n}from"./useComponentClass-C0isGl1z.js";import{P as o}from"./index-
|
|
1
|
+
'use client';import{jsx as e}from"react/jsx-runtime";import t,{createContext as s,useContext as r}from"react";import{u as a,c as n}from"./useComponentClass-C0isGl1z.js";import{P as o}from"./index-BidxkqdT.js";import{u as i}from"./index-wRElCyvx.js";import"./ThemeContext-Sm-iNANd.js";import"./mergeProps-0RucjqeH.js";const l=s(null),c=()=>{const e=r(l);if(!e)throw new Error("useStepsContext must be used within a StepsContext.Provider");return e},u=t.forwardRef((({children:s,className:r,customRootClass:c,orientation:u="vertical",value:d,defaultValue:m,onValueChange:f,...p},N)=>{const[C,h]=i(d,m??0,f),S=a(c,"Steps"),[v,b]=t.useState([]),w=t.useCallback((e=>(b((t=>t.includes(e)?t:[...t,e].sort(((e,t)=>{const s=e.compareDocumentPosition(t);return s&Node.DOCUMENT_POSITION_FOLLOWING?-1:s&Node.DOCUMENT_POSITION_PRECEDING?1:0})))),()=>{b((t=>t.includes(e)?t.filter((t=>t!==e)):t))})),[]),R=t.useMemo((()=>({currentStep:C,setCurrentStep:h,rootClass:S,orientation:u,registerItem:w,itemElements:v})),[C,h,S,u,w,v]);return e(l.Provider,{value:R,children:e(o.div,{ref:N,className:n(S,r,S&&`${S}-${u}`),"data-orientation":u,...p,children:s})})}));u.displayName="Steps.Root";const d="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,m=t.forwardRef((({children:s,value:r,className:a="",...i},l)=>{const{rootClass:u,currentStep:m,registerItem:f,itemElements:p}=c(),[N,C]=t.useState(null),h=t.useCallback((e=>{C(e),"function"==typeof l?l(e):l&&(l.current=e)}),[l]);d((()=>{if(N&&f)return f(N)}),[N,f]);const S=N&&p?p.indexOf(N):-1,v=null!=r,b=v?(e=>{if("number"==typeof e)return Number.isFinite(e)?e:null;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:null}return null})(r):S>=0?S:null,w=null!==b&&m===b,R=null!==b&&m>b?"completed":w?"active":"inactive";return e(o.div,{ref:h,className:n(u&&`${u}-item`,a),"data-state":R,"data-value":v?r:b??void 0,"aria-current":w?"step":void 0,...i,children:s})}));m.displayName="Steps.Item";const f=t.forwardRef((({children:t,className:s="",...r},a)=>{const{rootClass:i}=c();return e(o.div,{ref:a,className:n(i&&`${i}-track`,s),...r,children:t})}));f.displayName="Steps.Track";const p=t.forwardRef((({children:t,className:s="",...r},a)=>{const{rootClass:i}=c();return e(o.div,{ref:a,className:n(i&&`${i}-bubble`,s),...r,children:t})}));p.displayName="Steps.Bubble";const N=t.forwardRef((({children:t,className:s="",...r},a)=>{const{rootClass:i}=c();return e(o.div,{ref:a,className:n(i&&`${i}-line`,s),...r,children:t})}));N.displayName="Steps.Line";const C=t.forwardRef((({children:t,className:s="",...r},a)=>{const{rootClass:i}=c();return e(o.div,{ref:a,className:n(i&&`${i}-content`,s),...r,children:t})}));C.displayName="Steps.Content";const h=t.forwardRef((({children:t,className:s="",...r},a)=>{const{rootClass:i}=c();return e(o.div,{ref:a,className:n(i&&`${i}-title`,s),...r,children:t})}));h.displayName="Steps.Title";const S=t.forwardRef((({children:t,className:s="",...r},a)=>{const{rootClass:i}=c();return e(o.div,{ref:a,className:n(i&&`${i}-description`,s),...r,children:t})}));S.displayName="Steps.Description";const v=Object.assign((()=>(console.warn("Direct usage of Steps is not supported. Please use Steps.Root, Steps.Item, etc. instead."),null)),{Root:u,Item:m,Track:f,Bubble:p,Line:N,Content:C,Title:h,Description:S});export{p as Bubble,C as Content,S as Description,m as Item,N as Line,u as Root,h as Title,f as Track,v as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),r=require("./useComponentClass-B0DF90tm.cjs");require("./ThemeContext-t7IX-w6i.cjs");const t="Strong",o=s.forwardRef((({children:s,className:o,customRootClass:a,...c},n)=>{const u=r.useComponentClass(a,t);return e.jsx("strong",{ref:n,className:r.clsx(u,o),...c,children:s})}));o.displayName=t,exports.default=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./index-BZO29jsF.cjs"),r=require("./useComponentClass-B0DF90tm.cjs"),a=require("./index-c6NFMS_0.cjs"),i=require("./index-BwNOI8cB.cjs"),c=require("./index-DrMwbB8q.cjs"),o=require("./mergeRefs-BUn-enYe.cjs"),n=require("./index-Bg-UeWCo.cjs");require("./ThemeContext-t7IX-w6i.cjs"),require("./mergeProps-DW5qFqqJ.cjs");const d=t.createContext({checked:!1,setChecked:()=>{},rootClass:"",disabled:!1}),l="Switch",u=t.forwardRef((({children:n,customRootClass:u,color:h="",variant:m,size:C,defaultChecked:b=!1,checked:x,onCheckedChange:p,disabled:f=!1,required:k=!1,name:v,value:j,asChild:q=!1,className:w,onClick:R,...g},y)=>{const[N,P]=i.useControllableState(x,b,p),S=r.useComponentClass(u,l),E=a.createDataAttributes("switch",{variant:m,size:C}),T=a.createDataAccentColorAttribute(h),A=a.composeAttributes(E,T),B=t.useRef(null),D=t.useRef(b),z=Boolean(v)||k;t.useEffect((()=>{const e=B.current?.closest("form");if(!e||!z)return;const t=()=>P(Boolean(D.current));return e.addEventListener("reset",t),()=>e.removeEventListener("reset",t)}),[z,P]);const L={checked:N,setChecked:P,rootClass:S,disabled:f},_={...A,"data-slot":"switch-root","data-state":N?"checked":"unchecked","data-disabled":f?"":void 0,role:"switch","aria-checked":N,"aria-required":k,disabled:f,...g};return v&&(_.name=v),j&&(_.value=j),e.jsxs(d.Provider,{value:L,children:[e.jsx(s.ButtonPrimitive,{ref:o.mergeRefs(y,B),asChild:q,..._,className:r.clsx(S,w),onClick:c.composeEventHandlers(R,(()=>{f||P(!N)})),children:n}),z&&e.jsx("input",{type:"checkbox","aria-hidden":"true",tabIndex:-1,name:v,value:j??"on",checked:N,required:k,disabled:f,onChange:()=>{},style:{position:"absolute",width:1,height:1,margin:0,opacity:0,pointerEvents:"none"}})]})}));u.displayName=l;const h=t.forwardRef((({asChild:s=!1,className:a,children:i,...c},o)=>{const{checked:l,rootClass:u,disabled:h}=t.useContext(d),m={"data-slot":"switch-thumb"};return m["data-state"]=l?"checked":"unchecked",h&&(m["data-disabled"]=""),e.jsx(n.Primitive.span,{ref:o,className:r.clsx(u&&`${u}-indicator`,a),asChild:s,...m,...c,children:i})}));h.displayName="SwitchThumb";const m=()=>(console.warn("Direct usage of Switch is not supported. Please use Switch.Root, Switch.Thumb, etc. instead."),null);m.Root=u,m.Thumb=h,exports.Root=u,exports.Thumb=h,exports.default=m;
|
|
@@ -45,7 +45,13 @@ type SwitchThumbProps = ComponentPropsWithoutRef<typeof Primitive.span> & {
|
|
|
45
45
|
className?: string;
|
|
46
46
|
children?: React__default.ReactNode;
|
|
47
47
|
};
|
|
48
|
-
declare const SwitchThumb: React__default.ForwardRefExoticComponent<
|
|
48
|
+
declare const SwitchThumb: React__default.ForwardRefExoticComponent<Omit<Omit<React__default.DetailedHTMLProps<React__default.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
49
|
+
asChild?: boolean;
|
|
50
|
+
} & React__default.RefAttributes<HTMLElement>, "ref"> & {
|
|
51
|
+
asChild?: boolean;
|
|
52
|
+
className?: string;
|
|
53
|
+
children?: React__default.ReactNode;
|
|
54
|
+
} & React__default.RefAttributes<HTMLElement>>;
|
|
49
55
|
|
|
50
56
|
declare const Switch: {
|
|
51
57
|
(): null;
|
|
@@ -70,7 +76,13 @@ declare const Switch: {
|
|
|
70
76
|
value?: string;
|
|
71
77
|
asChild?: boolean;
|
|
72
78
|
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
73
|
-
Thumb: React$1.ForwardRefExoticComponent<
|
|
79
|
+
Thumb: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "ref"> & {
|
|
80
|
+
asChild?: boolean;
|
|
81
|
+
} & React$1.RefAttributes<HTMLElement>, "ref"> & {
|
|
82
|
+
asChild?: boolean;
|
|
83
|
+
className?: string;
|
|
84
|
+
children?: React.ReactNode;
|
|
85
|
+
} & React$1.RefAttributes<HTMLElement>>;
|
|
74
86
|
};
|
|
75
87
|
declare namespace SwitchProps {
|
|
76
88
|
type Root = SwitchRootProps;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsxs as e,jsx as s}from"react/jsx-runtime";import t,{createContext as a,forwardRef as o,useContext as r}from"react";import{B as i}from"./index-
|
|
1
|
+
'use client';import{jsxs as e,jsx as s}from"react/jsx-runtime";import t,{createContext as a,forwardRef as o,useContext as r}from"react";import{B as i}from"./index-DH-14XDv.js";import{u as c,c as d}from"./useComponentClass-C0isGl1z.js";import{c as n,a as l,b as h}from"./index-eAZUMNef.js";import{u as m}from"./index-wRElCyvx.js";import{c as u}from"./index-CXzybYmm.js";import{m as p}from"./mergeRefs-B8eZ_q-T.js";import{P as f}from"./index-BidxkqdT.js";import"./ThemeContext-Sm-iNANd.js";import"./mergeProps-0RucjqeH.js";const C=a({checked:!1,setChecked:()=>{},rootClass:"",disabled:!1}),b="Switch",k=o((({children:a,customRootClass:o,color:r="",variant:f,size:k,defaultChecked:v=!1,checked:j,onCheckedChange:w,disabled:x=!1,required:g=!1,name:R,value:N,asChild:y=!1,className:S,onClick:T,...E},P)=>{const[q,B]=m(j,v,w),z=c(o,b),L=n("switch",{variant:f,size:k}),D=h(r),I=l(L,D),$=t.useRef(null),A=t.useRef(v),F=Boolean(R)||g;t.useEffect((()=>{const e=$.current?.closest("form");if(!e||!F)return;const s=()=>B(Boolean(A.current));return e.addEventListener("reset",s),()=>e.removeEventListener("reset",s)}),[F,B]);const G={checked:q,setChecked:B,rootClass:z,disabled:x},H={...I,"data-slot":"switch-root","data-state":q?"checked":"unchecked","data-disabled":x?"":void 0,role:"switch","aria-checked":q,"aria-required":g,disabled:x,...E};return R&&(H.name=R),N&&(H.value=N),e(C.Provider,{value:G,children:[s(i,{ref:p(P,$),asChild:y,...H,className:d(z,S),onClick:u(T,(()=>{x||B(!q)})),children:a}),F&&s("input",{type:"checkbox","aria-hidden":"true",tabIndex:-1,name:R,value:N??"on",checked:q,required:g,disabled:x,onChange:()=>{},style:{position:"absolute",width:1,height:1,margin:0,opacity:0,pointerEvents:"none"}})]})}));k.displayName=b;const v=o((({asChild:e=!1,className:t,children:a,...o},i)=>{const{checked:c,rootClass:n,disabled:l}=r(C),h={"data-slot":"switch-thumb"};return h["data-state"]=c?"checked":"unchecked",l&&(h["data-disabled"]=""),s(f.span,{ref:i,className:d(n&&`${n}-indicator`,t),asChild:e,...h,...o,children:a})}));v.displayName="SwitchThumb";const j=()=>(console.warn("Direct usage of Switch is not supported. Please use Switch.Root, Switch.Thumb, etc. instead."),null);j.Root=k,j.Thumb=v;export{k as Root,v as Thumb,j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),o=require("./useComponentClass-B0DF90tm.cjs"),t=require("./index-rUSzFrhJ.cjs"),r=require("./index-Bg-UeWCo.cjs"),s=require("./index-BwNOI8cB.cjs");require("./ThemeContext-t7IX-w6i.cjs"),require("./index-BZO29jsF.cjs"),require("./keyboard-BBlFllyi.cjs"),require("./mergeRefs-BUn-enYe.cjs"),require("./mergeProps-DW5qFqqJ.cjs");const i=a.createContext({rootClass:"",tabValue:"",handleTabChange:()=>{}}),n=a.forwardRef((({value:s,className:n="",href:l="#",children:d,disabled:u,asChild:c,active:v,id:C,onClick:b,...h},x)=>{const{rootClass:p,tabValue:f,handleTabChange:j}=a.useContext(i),{setFocusedItemId:m}=a.useContext(t.RovingFocusGroupContext);c&&(u=!1);const R=a.useId(),g=C??R,N=v??(void 0!==s&&s===f);a.useEffect((()=>{N&&!u&&m(g)}),[N,u,g]);return e.jsx(t.RovingFocusGroupUtility.Item,{domId:g,children:e.jsx(r.Primitive.a,{ref:x,id:g,className:o.clsx(p&&`${p}-link`,n),asChild:c,onClick:e=>{u?e.preventDefault():(b?.(e),e.defaultPrevented||void 0===s||j(s))},"aria-disabled":u,"aria-current":N?"page":void 0,"data-state":N?"active":"inactive","data-disabled":u?"":void 0,"data-slot":"tab-nav-link",disabled:u,...u?{}:{href:l},...h,children:d})})}));n.displayName="TabNavLink";const l=a.forwardRef((({className:r,loop:n=!0,orientation:l="horizontal",dir:d,children:u,color:c,customRootClass:v="",defaultValue:C="",onValueChange:b=()=>{},value:h,...x},p)=>{const f=o.useComponentClass(v,"TabNav"),[j,m]=s.useControllableState(h,C||"",b),R=e=>{e!==j&&m(e)},g=a.useRef(!0);a.useEffect((()=>{g.current?g.current=!1:void 0===h&&C&&R(C)}),[C,h]);const N={rootClass:f,tabValue:j,handleTabChange:R};return e.jsx(i.Provider,{value:N,children:e.jsx(t.RovingFocusGroupUtility.Root,{loop:n,orientation:l,dir:d,children:e.jsx(t.RovingFocusGroupUtility.Group,{asChild:!0,children:e.jsx("nav",{ref:p,className:o.clsx(f,r),dir:d,"data-orientation":l,"data-slot":"tab-nav-root",role:void 0,...x,children:u})})})})}));l.displayName="TabNavRoot";const d=()=>(console.warn("Direct usage of TabNav is not supported. Please use TabNav.Root, TabNav.Link instead."),null);d.Root=l,d.Link=n,exports.Link=n,exports.Root=l,exports.default=d;
|
|
@@ -25,6 +25,8 @@ declare const TabNavLink: React__default.ForwardRefExoticComponent<Omit<React__d
|
|
|
25
25
|
type TabNavRootProps = React__default.ComponentPropsWithoutRef<'nav'> & {
|
|
26
26
|
loop?: boolean;
|
|
27
27
|
orientation?: 'horizontal' | 'vertical';
|
|
28
|
+
/** Reading direction. In `rtl`, ArrowLeft moves to the next link. */
|
|
29
|
+
dir?: 'ltr' | 'rtl';
|
|
28
30
|
customRootClass?: string;
|
|
29
31
|
color?: string;
|
|
30
32
|
value?: string;
|
|
@@ -34,6 +36,8 @@ type TabNavRootProps = React__default.ComponentPropsWithoutRef<'nav'> & {
|
|
|
34
36
|
declare const TabNavRoot: React__default.ForwardRefExoticComponent<Omit<React__default.DetailedHTMLProps<React__default.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
35
37
|
loop?: boolean;
|
|
36
38
|
orientation?: "horizontal" | "vertical";
|
|
39
|
+
/** Reading direction. In `rtl`, ArrowLeft moves to the next link. */
|
|
40
|
+
dir?: "ltr" | "rtl";
|
|
37
41
|
customRootClass?: string;
|
|
38
42
|
color?: string;
|
|
39
43
|
value?: string;
|
|
@@ -46,6 +50,7 @@ declare const TabNav: {
|
|
|
46
50
|
Root: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>, "ref"> & {
|
|
47
51
|
loop?: boolean;
|
|
48
52
|
orientation?: "horizontal" | "vertical";
|
|
53
|
+
dir?: "ltr" | "rtl";
|
|
49
54
|
customRootClass?: string;
|
|
50
55
|
color?: string;
|
|
51
56
|
value?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as a}from"react/jsx-runtime";import{createContext as e,forwardRef as o,useContext as t,useId as
|
|
1
|
+
'use client';import{jsx as a}from"react/jsx-runtime";import{createContext as e,forwardRef as o,useContext as t,useId as r,useEffect as i,useRef as s}from"react";import{c as n,u as d}from"./useComponentClass-C0isGl1z.js";import{a as l,R as c}from"./index-D8QLtYJh.js";import{P as m}from"./index-BidxkqdT.js";import{u}from"./index-wRElCyvx.js";import"./ThemeContext-Sm-iNANd.js";import"./index-DH-14XDv.js";import"./keyboard-BKF7hXqL.js";import"./mergeRefs-B8eZ_q-T.js";import"./mergeProps-0RucjqeH.js";const v=e({rootClass:"",tabValue:"",handleTabChange:()=>{}}),p=o((({value:e,className:o="",href:s="#",children:d,disabled:u,asChild:p,active:h,id:b,onClick:f,...C},N)=>{const{rootClass:j,tabValue:T,handleTabChange:k}=t(v),{setFocusedItemId:g}=t(l);p&&(u=!1);const R=r(),x=b??R,P=h??(void 0!==e&&e===T);i((()=>{P&&!u&&g(x)}),[P,u,x]);return a(c.Item,{domId:x,children:a(m.a,{ref:N,id:x,className:n(j&&`${j}-link`,o),asChild:p,onClick:a=>{u?a.preventDefault():(f?.(a),a.defaultPrevented||void 0===e||k(e))},"aria-disabled":u,"aria-current":P?"page":void 0,"data-state":P?"active":"inactive","data-disabled":u?"":void 0,"data-slot":"tab-nav-link",disabled:u,...u?{}:{href:s},...C,children:d})})}));p.displayName="TabNavLink";const h=o((({className:e,loop:o=!0,orientation:t="horizontal",dir:r,children:l,color:m,customRootClass:p="",defaultValue:h="",onValueChange:b=()=>{},value:f,...C},N)=>{const j=d(p,"TabNav"),[T,k]=u(f,h||"",b),g=a=>{a!==T&&k(a)},R=s(!0);i((()=>{R.current?R.current=!1:void 0===f&&h&&g(h)}),[h,f]);const x={rootClass:j,tabValue:T,handleTabChange:g};return a(v.Provider,{value:x,children:a(c.Root,{loop:o,orientation:t,dir:r,children:a(c.Group,{asChild:!0,children:a("nav",{ref:N,className:n(j,e),dir:r,"data-orientation":t,"data-slot":"tab-nav-root",role:void 0,...C,children:l})})})})}));h.displayName="TabNavRoot";const b=()=>(console.warn("Direct usage of TabNav is not supported. Please use TabNav.Root, TabNav.Link instead."),null);b.Root=h,b.Link=p;export{p as Link,h as Root,b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react/jsx-runtime"),n=require("./useComponentClass-B0DF90tm.cjs"),r=require("./keyboard-BBlFllyi.cjs"),s=require("./index-Bg-UeWCo.cjs");require("./ThemeContext-t7IX-w6i.cjs"),require("./mergeProps-DW5qFqqJ.cjs");const l=e.createContext(null),o="Table",a=()=>{const t=e.useContext(l);if(!t)throw new Error("Table components must be used within a Table.Root");return t};function i(e){return e?Array.isArray(e)?Object.fromEntries(e.map(((e,t)=>[t,e]))):e:{}}const u=e.forwardRef((({children:s,className:a="",customRootClass:u="",resizable:c=!1,defaultColumnWidths:d,columnWidths:m,onColumnWidthsChange:h,minColumnWidth:f=48,resizeHandleVisibility:v="hover",...b},C)=>{const x=n.useComponentClass(u,o),y=e.useRef(null),[R,p]=e.useState((()=>i(d))),[z,w]=e.useState(0),[E,j]=e.useState(!1),[N,T]=e.useState(null),g=e.useRef({}),H=e.useRef(0),M=e.useRef(!1),k=e.useRef(null),L=e.useCallback((()=>{const e=k.current;e&&(document.removeEventListener("mousemove",e.handleMove),document.removeEventListener("mouseup",e.handleEnd),document.removeEventListener("touchmove",e.handleMove),document.removeEventListener("touchend",e.handleEnd),document.removeEventListener("touchcancel",e.handleEnd),k.current=null)}),[]);e.useEffect((()=>()=>{L()}),[L]);const W=void 0!==m,I=W?i(m):R;g.current=I,H.current=z;const P=e.useCallback((e=>{W||p(e),h?.(e)}),[W,h]),S=e.useCallback((e=>{w((t=>Math.max(t,e+1)))}),[]),A=e.useCallback((e=>{if(!c)return;const t=I[e];return void 0!==t?{width:t}:void 0}),[I,c]);e.useLayoutEffect((()=>{if(!c||W||!y.current||0===z||M.current)return;const e=y.current.offsetWidth;if(e<=0)return;const t=Object.keys(g.current).length>0?function(e,t,n){const r=Array.from({length:t},((t,n)=>e[n]??0)),s=r.reduce(((e,t)=>e+t),0);if(s<=0||n<=0)return e;const l=n/s;return Object.fromEntries(r.map(((e,t)=>[t,Math.max(1,Math.round(e*l))])))}(g.current,z,e):function(e,t){const n=Math.max(1,Math.floor(t/e));return Object.fromEntries(Array.from({length:e},((e,t)=>[t,n])))}(z,e);M.current=!0,P(t)}),[z,W,c,P]);const D=e.useCallback(((e,t)=>{let n=e;for(let e=0;e<Math.abs(t);e+=1)if(n=t<0?n.previousElementSibling:n.nextElementSibling,!n)return null;return n}),[]),O=e.useCallback(((e,t)=>g.current[e]??t?.offsetWidth??f),[f]),K=e.useCallback(((e,t,n,r)=>{const s=e+1;if(s>=H.current)return;const l=r-f,o=n-f,a=Math.max(-o,Math.min(l,t)),i=n+a,u=r-a;P({...g.current,[e]:i,[s]:u})}),[f,P]),$=e.useCallback(((e,t,n)=>{if(!c||e>=H.current-1)return;n.preventDefault();const r="clientX"in n?n.clientX:n.touches[0].clientX,s=D(t,1),l=O(e,t),o=O(e+1,s);j(!0),T(e),L();const a=t=>{const n="clientX"in t?t.clientX:t.touches[0].clientX;K(e,n-r,l,o)},i=()=>{j(!1),T(null),L()};k.current={handleMove:a,handleEnd:i},document.addEventListener("mousemove",a),document.addEventListener("mouseup",i),document.addEventListener("touchmove",a),document.addEventListener("touchend",i),document.addEventListener("touchcancel",i)}),[K,L,O,D,c]),q=e.useCallback(((e,t,n)=>{if(!c||e>=H.current-1)return;const s=n.shiftKey?20:5;let l=0;if(n.key===r.KEYBOARD_KEYS.ARROW_LEFT?l=-s:n.key===r.KEYBOARD_KEYS.ARROW_RIGHT&&(l=s),0===l)return;n.preventDefault();const o=D(t,1);K(e,l,O(e,t),O(e+1,o))}),[K,O,D,c]),X=e.useMemo((()=>({rootClass:x,resizable:c,resizeHandleVisibility:v,columnCount:z,minColumnWidth:f,registerColumnIndex:S,columnWidths:I,getColumnStyle:A,startColumnResize:$,handleColumnResizeKeyDown:q,isResizing:E,activeColumnIndex:N})),[N,z,I,A,q,E,f,S,v,c,x,$]);return t.jsx(l.Provider,{value:X,children:t.jsx("div",{ref:C,className:n.clsx(x&&`${x}-wrapper`,a),"data-resizable":c?"":void 0,"data-resizing":c&&E?"":void 0,"data-resize-handle-visibility":c?v:void 0,...b,children:t.jsxs("table",{ref:y,className:n.clsx(x),"data-resizable":c?"":void 0,style:c?{tableLayout:"fixed",width:"100%"}:void 0,children:[c&&z>0&&t.jsx("colgroup",{children:Array.from({length:z},((e,n)=>t.jsx("col",{style:A(n)},n)))}),s]})})})}));u.displayName=o;const c=e.forwardRef((({children:r,className:o="header",...a},i)=>{const u=e.useContext(l)?.rootClass;return t.jsx(s.Primitive.thead,{ref:i,className:n.clsx(u&&`${u}-head`,o),...a,children:r})}));c.displayName="TableHead";const d=e.forwardRef((({children:r,className:o="",...a},i)=>{const u=e.useContext(l)?.rootClass;return t.jsx(s.Primitive.tbody,{ref:i,className:n.clsx(u&&`${u}-body`,o),...a,children:r})}));d.displayName="TableBody";const m=e.forwardRef((({children:r,className:o="row",...a},i)=>{const u=e.useContext(l)?.rootClass;return t.jsx(s.Primitive.tr,{ref:i,className:n.clsx(u&&`${u}-row`,o),...a,children:r})}));m.displayName="TableRow";const h=e.createContext(null),f=e.forwardRef((({children:r,className:l="cell-header",columnIndex:o,style:i,...u},c)=>{const{resizable:d,registerColumnIndex:m,rootClass:f}=a(),v=d&&void 0!==o;e.useLayoutEffect((()=>{void 0!==o&&m(o)}),[o,m]);const b=t.jsx(s.Primitive.th,{ref:c,className:n.clsx(f&&`${f}-cell-header`,l,v&&"resizable"),"data-resizable":v?"":void 0,style:i,...u,children:r});return void 0===o?b:t.jsx(h.Provider,{value:{columnIndex:o},children:b})}));f.displayName="TableColumnCellHeader";const v=e.forwardRef((({className:r,"aria-label":s,...l},o)=>{const{rootClass:i,resizable:u,resizeHandleVisibility:c,columnCount:d,minColumnWidth:m,columnWidths:f,startColumnResize:v,handleColumnResizeKeyDown:b,isResizing:C,activeColumnIndex:x}=a(),{columnIndex:y}=(()=>{const t=e.useContext(h);if(!t)throw new Error("Table.ColumnResizeHandle must be used within a Table.ColumnCellHeader with columnIndex");return t})(),R=e.useRef(null),p=C&&x===y,z=d>0&&y>=d-1,w=e.useCallback((e=>{R.current=e?.closest("th")??null,"function"==typeof o?o(e):o&&(o.current=e)}),[o]);if(!u||z)return null;const E=Math.round(f[y]??R.current?.offsetWidth??m);return t.jsx("div",{...l,ref:w,"data-slot":"table-column-resize-handle","data-resize-handle-visibility":c,"data-state":p?"active":void 0,className:n.clsx(i&&`${i}-column-resize-handle`,{active:p},r),role:"separator","aria-orientation":"vertical","aria-label":s||`Resize column ${y+1}`,"aria-valuemin":m,"aria-valuenow":E,tabIndex:0,onMouseDown:e=>{R.current&&v(y,R.current,e)},onTouchStart:e=>{R.current&&v(y,R.current,e)},onKeyDown:e=>{R.current&&b(y,R.current,e)}})}));v.displayName="TableColumnResizeHandle";const b=e.forwardRef((({children:e,className:r="cell",columnIndex:l,style:o,...i},u)=>{const{resizable:c,rootClass:d}=a(),m=c&&void 0!==l;return t.jsx(s.Primitive.td,{ref:u,className:n.clsx(d&&`${d}-cell`,r,m&&"resizable"),"data-resizable":m?"":void 0,style:o,...i,children:e})}));b.displayName="TableCell";const C=e.forwardRef((function(e,t){return console.warn("Direct usage of Table is not supported. Please use Table.Root, Table.Head, etc. instead."),null}));C.displayName="Table",C.Root=u,C.Body=d,C.Head=c,C.Row=m,C.Cell=b,C.ColumnCellHeader=f,C.ColumnResizeHandle=v,exports.Body=d,exports.Cell=b,exports.ColumnCellHeader=f,exports.ColumnResizeHandle=v,exports.Head=c,exports.Root=u,exports.Row=m,exports.default=C,exports.useTable=a;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React$1, { CSSProperties } from 'react';
|
|
2
|
+
import Primitive from '~/core/primitives/Primitive';
|
|
2
3
|
|
|
3
4
|
type ColumnWidths = Record<number, number>;
|
|
4
5
|
type TableResizeHandleVisibility = 'hover' | 'always';
|
|
@@ -38,21 +39,29 @@ declare const TableRoot: React$1.ForwardRefExoticComponent<Omit<React$1.Detailed
|
|
|
38
39
|
resizeHandleVisibility?: TableResizeHandleVisibility;
|
|
39
40
|
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
40
41
|
|
|
41
|
-
type TableHeadProps = React$1.ComponentPropsWithoutRef<
|
|
42
|
-
declare const TableHead: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> &
|
|
42
|
+
type TableHeadProps = React$1.ComponentPropsWithoutRef<typeof Primitive.thead>;
|
|
43
|
+
declare const TableHead: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & {
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
} & React$1.RefAttributes<HTMLElement>, "ref"> & React$1.RefAttributes<HTMLElement>>;
|
|
43
46
|
|
|
44
|
-
type TableBodyProps = React$1.ComponentPropsWithoutRef<
|
|
45
|
-
declare const TableBody: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> &
|
|
47
|
+
type TableBodyProps = React$1.ComponentPropsWithoutRef<typeof Primitive.tbody>;
|
|
48
|
+
declare const TableBody: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>, "ref"> & {
|
|
49
|
+
asChild?: boolean;
|
|
50
|
+
} & React$1.RefAttributes<HTMLElement>, "ref"> & React$1.RefAttributes<HTMLElement>>;
|
|
46
51
|
|
|
47
|
-
type TableRowProps = React$1.ComponentPropsWithoutRef<
|
|
48
|
-
declare const TableRow: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, "ref"> &
|
|
52
|
+
type TableRowProps = React$1.ComponentPropsWithoutRef<typeof Primitive.tr>;
|
|
53
|
+
declare const TableRow: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, "ref"> & {
|
|
54
|
+
asChild?: boolean;
|
|
55
|
+
} & React$1.RefAttributes<HTMLElement>, "ref"> & React$1.RefAttributes<HTMLElement>>;
|
|
49
56
|
|
|
50
|
-
type TableColumnCellHeaderProps = React$1.ComponentPropsWithoutRef<
|
|
57
|
+
type TableColumnCellHeaderProps = React$1.ComponentPropsWithoutRef<typeof Primitive.th> & {
|
|
51
58
|
columnIndex?: number;
|
|
52
59
|
};
|
|
53
|
-
declare const TableColumnCellHeader: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, "ref"> & {
|
|
60
|
+
declare const TableColumnCellHeader: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, "ref"> & {
|
|
61
|
+
asChild?: boolean;
|
|
62
|
+
} & React$1.RefAttributes<HTMLElement>, "ref"> & {
|
|
54
63
|
columnIndex?: number;
|
|
55
|
-
} & React$1.RefAttributes<
|
|
64
|
+
} & React$1.RefAttributes<HTMLElement>>;
|
|
56
65
|
|
|
57
66
|
type TableColumnResizeHandleProps = React$1.ComponentPropsWithoutRef<'div'> & {
|
|
58
67
|
'aria-label'?: string;
|
|
@@ -61,12 +70,14 @@ declare const TableColumnResizeHandle: React$1.ForwardRefExoticComponent<Omit<Re
|
|
|
61
70
|
'aria-label'?: string;
|
|
62
71
|
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
63
72
|
|
|
64
|
-
type TableCellProps = React$1.ComponentPropsWithoutRef<
|
|
73
|
+
type TableCellProps = React$1.ComponentPropsWithoutRef<typeof Primitive.td> & {
|
|
65
74
|
columnIndex?: number;
|
|
66
75
|
};
|
|
67
|
-
declare const TableCell: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref"> & {
|
|
76
|
+
declare const TableCell: React$1.ForwardRefExoticComponent<Omit<Omit<React$1.DetailedHTMLProps<React$1.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, "ref"> & {
|
|
77
|
+
asChild?: boolean;
|
|
78
|
+
} & React$1.RefAttributes<HTMLElement>, "ref"> & {
|
|
68
79
|
columnIndex?: number;
|
|
69
|
-
} & React$1.RefAttributes<
|
|
80
|
+
} & React$1.RefAttributes<HTMLElement>>;
|
|
70
81
|
|
|
71
82
|
type TableProps = React$1.HTMLAttributes<HTMLTableElement> & {
|
|
72
83
|
children?: React$1.ReactNode;
|
package/dist/components/Table.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import e,{createContext as n,useRef as t,useState as r,useCallback as o,useEffect as
|
|
1
|
+
'use client';import e,{createContext as n,useRef as t,useState as r,useCallback as o,useEffect as a,useLayoutEffect as l,useMemo as s}from"react";import{jsx as i,jsxs as c}from"react/jsx-runtime";import{u,c as d}from"./useComponentClass-C0isGl1z.js";import{K as m}from"./keyboard-BKF7hXqL.js";import{P as h}from"./index-BidxkqdT.js";import"./ThemeContext-Sm-iNANd.js";import"./mergeProps-0RucjqeH.js";const f=n(null),v="Table",b=()=>{const n=e.useContext(f);if(!n)throw new Error("Table components must be used within a Table.Root");return n};function C(e){return e?Array.isArray(e)?Object.fromEntries(e.map(((e,n)=>[n,e]))):e:{}}const y=e.forwardRef((({children:e,className:n="",customRootClass:h="",resizable:b=!1,defaultColumnWidths:y,columnWidths:p,onColumnWidthsChange:R,minColumnWidth:z=48,resizeHandleVisibility:w="hover",...x},E)=>{const N=u(h,v),T=t(null),[g,H]=r((()=>C(y))),[L,M]=r(0),[W,I]=r(!1),[j,$]=r(null),A=t({}),D=t(0),O=t(!1),X=t(null),k=o((()=>{const e=X.current;e&&(document.removeEventListener("mousemove",e.handleMove),document.removeEventListener("mouseup",e.handleEnd),document.removeEventListener("touchmove",e.handleMove),document.removeEventListener("touchend",e.handleEnd),document.removeEventListener("touchcancel",e.handleEnd),X.current=null)}),[]);a((()=>()=>{k()}),[k]);const K=void 0!==p,P=K?C(p):g;A.current=P,D.current=L;const S=o((e=>{K||H(e),R?.(e)}),[K,R]),B=o((e=>{M((n=>Math.max(n,e+1)))}),[]),V=o((e=>{if(!b)return;const n=P[e];return void 0!==n?{width:n}:void 0}),[P,b]);l((()=>{if(!b||K||!T.current||0===L||O.current)return;const e=T.current.offsetWidth;if(e<=0)return;const n=Object.keys(A.current).length>0?function(e,n,t){const r=Array.from({length:n},((n,t)=>e[t]??0)),o=r.reduce(((e,n)=>e+n),0);if(o<=0||t<=0)return e;const a=t/o;return Object.fromEntries(r.map(((e,n)=>[n,Math.max(1,Math.round(e*a))])))}(A.current,L,e):function(e,n){const t=Math.max(1,Math.floor(n/e));return Object.fromEntries(Array.from({length:e},((e,n)=>[n,t])))}(L,e);O.current=!0,S(n)}),[L,K,b,S]);const _=o(((e,n)=>{let t=e;for(let e=0;e<Math.abs(n);e+=1)if(t=n<0?t.previousElementSibling:t.nextElementSibling,!t)return null;return t}),[]),F=o(((e,n)=>A.current[e]??n?.offsetWidth??z),[z]),G=o(((e,n,t,r)=>{const o=e+1;if(o>=D.current)return;const a=r-z,l=t-z,s=Math.max(-l,Math.min(a,n)),i=t+s,c=r-s;S({...A.current,[e]:i,[o]:c})}),[z,S]),q=o(((e,n,t)=>{if(!b||e>=D.current-1)return;t.preventDefault();const r="clientX"in t?t.clientX:t.touches[0].clientX,o=_(n,1),a=F(e,n),l=F(e+1,o);I(!0),$(e),k();const s=n=>{const t="clientX"in n?n.clientX:n.touches[0].clientX;G(e,t-r,a,l)},i=()=>{I(!1),$(null),k()};X.current={handleMove:s,handleEnd:i},document.addEventListener("mousemove",s),document.addEventListener("mouseup",i),document.addEventListener("touchmove",s),document.addEventListener("touchend",i),document.addEventListener("touchcancel",i)}),[G,k,F,_,b]),J=o(((e,n,t)=>{if(!b||e>=D.current-1)return;const r=t.shiftKey?20:5;let o=0;if(t.key===m.ARROW_LEFT?o=-r:t.key===m.ARROW_RIGHT&&(o=r),0===o)return;t.preventDefault();const a=_(n,1);G(e,o,F(e,n),F(e+1,a))}),[G,F,_,b]),Q=s((()=>({rootClass:N,resizable:b,resizeHandleVisibility:w,columnCount:L,minColumnWidth:z,registerColumnIndex:B,columnWidths:P,getColumnStyle:V,startColumnResize:q,handleColumnResizeKeyDown:J,isResizing:W,activeColumnIndex:j})),[j,L,P,V,J,W,z,B,w,b,N,q]);return i(f.Provider,{value:Q,children:i("div",{ref:E,className:d(N&&`${N}-wrapper`,n),"data-resizable":b?"":void 0,"data-resizing":b&&W?"":void 0,"data-resize-handle-visibility":b?w:void 0,...x,children:c("table",{ref:T,className:d(N),"data-resizable":b?"":void 0,style:b?{tableLayout:"fixed",width:"100%"}:void 0,children:[b&&L>0&&i("colgroup",{children:Array.from({length:L},((e,n)=>i("col",{style:V(n)},n)))}),e]})})})}));y.displayName=v;const p=e.forwardRef((({children:n,className:t="header",...r},o)=>{const a=e.useContext(f)?.rootClass;return i(h.thead,{ref:o,className:d(a&&`${a}-head`,t),...r,children:n})}));p.displayName="TableHead";const R=e.forwardRef((({children:n,className:t="",...r},o)=>{const a=e.useContext(f)?.rootClass;return i(h.tbody,{ref:o,className:d(a&&`${a}-body`,t),...r,children:n})}));R.displayName="TableBody";const z=e.forwardRef((({children:n,className:t="row",...r},o)=>{const a=e.useContext(f)?.rootClass;return i(h.tr,{ref:o,className:d(a&&`${a}-row`,t),...r,children:n})}));z.displayName="TableRow";const w=n(null),x=e.forwardRef((({children:n,className:t="cell-header",columnIndex:r,style:o,...a},l)=>{const{resizable:s,registerColumnIndex:c,rootClass:u}=b(),m=s&&void 0!==r;e.useLayoutEffect((()=>{void 0!==r&&c(r)}),[r,c]);const f=i(h.th,{ref:l,className:d(u&&`${u}-cell-header`,t,m&&"resizable"),"data-resizable":m?"":void 0,style:o,...a,children:n});return void 0===r?f:i(w.Provider,{value:{columnIndex:r},children:f})}));x.displayName="TableColumnCellHeader";const E=e.forwardRef((({className:n,"aria-label":t,...r},o)=>{const{rootClass:a,resizable:l,resizeHandleVisibility:s,columnCount:c,minColumnWidth:u,columnWidths:m,startColumnResize:h,handleColumnResizeKeyDown:f,isResizing:v,activeColumnIndex:C}=b(),{columnIndex:y}=(()=>{const n=e.useContext(w);if(!n)throw new Error("Table.ColumnResizeHandle must be used within a Table.ColumnCellHeader with columnIndex");return n})(),p=e.useRef(null),R=v&&C===y,z=c>0&&y>=c-1,x=e.useCallback((e=>{p.current=e?.closest("th")??null,"function"==typeof o?o(e):o&&(o.current=e)}),[o]);if(!l||z)return null;const E=Math.round(m[y]??p.current?.offsetWidth??u);return i("div",{...r,ref:x,"data-slot":"table-column-resize-handle","data-resize-handle-visibility":s,"data-state":R?"active":void 0,className:d(a&&`${a}-column-resize-handle`,{active:R},n),role:"separator","aria-orientation":"vertical","aria-label":t||`Resize column ${y+1}`,"aria-valuemin":u,"aria-valuenow":E,tabIndex:0,onMouseDown:e=>{p.current&&h(y,p.current,e)},onTouchStart:e=>{p.current&&h(y,p.current,e)},onKeyDown:e=>{p.current&&f(y,p.current,e)}})}));E.displayName="TableColumnResizeHandle";const N=e.forwardRef((({children:e,className:n="cell",columnIndex:t,style:r,...o},a)=>{const{resizable:l,rootClass:s}=b(),c=l&&void 0!==t;return i(h.td,{ref:a,className:d(s&&`${s}-cell`,n,c&&"resizable"),"data-resizable":c?"":void 0,style:r,...o,children:e})}));N.displayName="TableCell";const T=e.forwardRef((function(e,n){return console.warn("Direct usage of Table is not supported. Please use Table.Root, Table.Head, etc. instead."),null}));T.displayName="Table",T.Root=y,T.Body=R,T.Head=p,T.Row=z,T.Cell=N,T.ColumnCellHeader=x,T.ColumnResizeHandle=E;export{R as Body,N as Cell,x as ColumnCellHeader,E as ColumnResizeHandle,p as Head,y as Root,z as Row,T as default,b as useTable};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react/jsx-runtime"),o=require("./useComponentClass-B0DF90tm.cjs"),a=require("./index-rUSzFrhJ.cjs"),i=require("./index-Bg-UeWCo.cjs"),r=require("./index-BwNOI8cB.cjs");require("./ThemeContext-t7IX-w6i.cjs"),require("./index-BZO29jsF.cjs"),require("./keyboard-BBlFllyi.cjs"),require("./mergeRefs-BUn-enYe.cjs"),require("./mergeProps-DW5qFqqJ.cjs");const s=e=>e.replace(/\s+/g,"-"),n=(e,t)=>`${e}-trigger-${s(t)}`,d=(e,t)=>`${e}-content-${s(t)}`,l=e.createContext(null),c=e.forwardRef((({className:r="",children:s,asChild:n=!1,...d},c)=>{const u=e.useContext(l);if(!u)throw new Error("TabList must be used within a TabRoot");const{rootClass:b,orientation:v}=u;return t.jsx(a.RovingFocusGroupUtility.Group,{children:t.jsx(i.Primitive.div,{ref:c,role:"tablist","aria-orientation":v,className:o.clsx(b&&`${b}-list`,r),"data-slot":"tabs-list",asChild:n,...d,children:s})})}));c.displayName="TabList";const u=e.forwardRef((({value:r,children:s,className:c="",disabled:u,asChild:b=!1,id:v,onClick:h,onFocus:C,...m},f)=>{const g=e.useContext(l);if(!g)throw new Error("TabTrigger must be used within a TabRoot");const{tabValue:x,handleTabChange:p,rootClass:T,orientation:R,activationMode:j,baseId:w,registerTriggerId:I}=g,{setFocusedItemId:N}=e.useContext(a.RovingFocusGroupContext),y=void 0!==r&&r===x,q=v??(void 0!==r?n(w,r):void 0),P=void 0!==r?d(w,r):void 0;e.useEffect((()=>{if(void 0!==r&&void 0!==v&&I)return I(r,v),()=>I(r,void 0)}),[r,v,I]),e.useEffect((()=>{y&&!u&&q&&N(q)}),[y,u,q]);const F={};return F["data-state"]=y?"active":"inactive",F["data-orientation"]=R||"horizontal",u&&(F["data-disabled"]=""),t.jsx(a.RovingFocusGroupUtility.Item,{domId:q,children:t.jsx(i.Primitive.button,{ref:f,id:q,onClick:e=>{h?.(e),e.defaultPrevented||u||void 0===r||p(r)},onFocus:e=>{C?.(e),e.defaultPrevented||u||void 0===r||"manual"!==j&&p(r)},className:o.clsx(T&&`${T}-trigger`,y?"active":"",u?"disabled":"",c),role:"tab",type:"button","aria-selected":y,"aria-controls":y?P:void 0,"aria-disabled":u,disabled:u,"data-slot":"tabs-trigger",asChild:b,...F,...m,children:s})})}));u.displayName="TabTrigger";const b="TabContent",v=e.forwardRef((({className:a="",value:r,children:s,customRootClass:c,asChild:u=!1,forceMount:v=!1,...h},C)=>{const m=o.useComponentClass(c,b),f=e.useContext(l);if(!f)throw new Error("TabContent must be used within a TabRoot");const{tabValue:g,orientation:x,baseId:p,customTriggerIds:T}=f,R=void 0!==r&&g===r;if(!(v||R))return null;const j={};return j["data-state"]=R?"active":"inactive",j["data-orientation"]=x||"horizontal",t.jsx(i.Primitive.div,{ref:C,className:o.clsx(m,a),id:void 0!==r?d(p,r):void 0,role:"tabpanel","aria-labelledby":void 0!==r?T?.[r]??n(p,r):void 0,tabIndex:R?0:void 0,hidden:!R,"aria-hidden":!R,"data-slot":"tabs-content",asChild:u,...j,...h,children:s})}));v.displayName=b;const h="Tabs",C=e.forwardRef((({children:s,defaultValue:n="",onValueChange:d=()=>{},customRootClass:c="",value:u,className:b,color:v,orientation:C="horizontal",dir:m="ltr",loop:f=!0,activationMode:g="automatic",asChild:x=!1,...p},T)=>{const R=o.useComponentClass(c,h),[j,w]=r.useControllableState(u,n||"",d),I=e.useId(),[N,y]=e.useState({}),q=e.useCallback(((e,t)=>{y((o=>{if(o[e]===t)return o;const a={...o};return void 0===t?delete a[e]:a[e]=t,a}))}),[]),P=e=>{e!==j&&w(e)},F=e.useRef(!0);e.useEffect((()=>{F.current?F.current=!1:void 0===u&&n&&P(n)}),[n,u]);const E={rootClass:R,baseId:I,tabValue:j,handleTabChange:P,orientation:C,activationMode:g,customTriggerIds:N,registerTriggerId:q},$={};return $["data-orientation"]=C,t.jsx(l.Provider,{value:E,children:t.jsx(a.RovingFocusGroupUtility.Root,{orientation:C,loop:f,dir:m,asChild:!0,children:t.jsx(i.Primitive.div,{ref:T,className:o.clsx(R,b),"data-color":v,"data-slot":"tabs-root",dir:m,asChild:x,...$,...p,children:s})})})}));C.displayName=h;const m=e.forwardRef(((e,t)=>(console.warn("Direct usage of Tabs is not supported. Please use Tabs.Root, Tabs.List, etc. instead."),null)));m.displayName="Tabs",m.List=c,m.Content=v,m.Root=C,m.Trigger=u,exports.Content=v,exports.List=c,exports.Root=C,exports.Trigger=u,exports.default=m;
|
package/dist/components/Tabs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import a,{createContext as t,useContext as e,useEffect as o,useId as i,useState as r,useCallback as s,useRef as d}from"react";import{jsx as n}from"react/jsx-runtime";import{c as l,u as c}from"./useComponentClass-C0isGl1z.js";import{R as u,a as m}from"./index-
|
|
1
|
+
'use client';import a,{createContext as t,useContext as e,useEffect as o,useId as i,useState as r,useCallback as s,useRef as d}from"react";import{jsx as n}from"react/jsx-runtime";import{c as l,u as c}from"./useComponentClass-C0isGl1z.js";import{R as u,a as m}from"./index-D8QLtYJh.js";import{P as b}from"./index-BidxkqdT.js";import{u as h}from"./index-wRElCyvx.js";import"./ThemeContext-Sm-iNANd.js";import"./index-DH-14XDv.js";import"./keyboard-BKF7hXqL.js";import"./mergeRefs-B8eZ_q-T.js";import"./mergeProps-0RucjqeH.js";const v=a=>a.replace(/\s+/g,"-"),f=(a,t)=>`${a}-trigger-${v(t)}`,g=(a,t)=>`${a}-content-${v(t)}`,p=t(null),C=a.forwardRef((({className:a="",children:t,asChild:o=!1,...i},r)=>{const s=e(p);if(!s)throw new Error("TabList must be used within a TabRoot");const{rootClass:d,orientation:c}=s;return n(u.Group,{children:n(b.div,{ref:r,role:"tablist","aria-orientation":c,className:l(d&&`${d}-list`,a),"data-slot":"tabs-list",asChild:o,...i,children:t})})}));C.displayName="TabList";const T=a.forwardRef((({value:a,children:t,className:i="",disabled:r,asChild:s=!1,id:d,onClick:c,onFocus:h,...v},C)=>{const T=e(p);if(!T)throw new Error("TabTrigger must be used within a TabRoot");const{tabValue:R,handleTabChange:w,rootClass:N,orientation:I,activationMode:j,baseId:x,registerTriggerId:y}=T,{setFocusedItemId:P}=e(m),$=void 0!==a&&a===R,L=d??(void 0!==a?f(x,a):void 0),V=void 0!==a?g(x,a):void 0;o((()=>{if(void 0!==a&&void 0!==d&&y)return y(a,d),()=>y(a,void 0)}),[a,d,y]),o((()=>{$&&!r&&L&&P(L)}),[$,r,L]);const M={};return M["data-state"]=$?"active":"inactive",M["data-orientation"]=I||"horizontal",r&&(M["data-disabled"]=""),n(u.Item,{domId:L,children:n(b.button,{ref:C,id:L,onClick:t=>{c?.(t),t.defaultPrevented||r||void 0===a||w(a)},onFocus:t=>{h?.(t),t.defaultPrevented||r||void 0===a||"manual"!==j&&w(a)},className:l(N&&`${N}-trigger`,$?"active":"",r?"disabled":"",i),role:"tab",type:"button","aria-selected":$,"aria-controls":$?V:void 0,"aria-disabled":r,disabled:r,"data-slot":"tabs-trigger",asChild:s,...M,...v,children:t})})}));T.displayName="TabTrigger";const R="TabContent",w=a.forwardRef((({className:a="",value:t,children:o,customRootClass:i,asChild:r=!1,forceMount:s=!1,...d},u)=>{const m=c(i,R),h=e(p);if(!h)throw new Error("TabContent must be used within a TabRoot");const{tabValue:v,orientation:C,baseId:T,customTriggerIds:w}=h,N=void 0!==t&&v===t;if(!(s||N))return null;const I={};return I["data-state"]=N?"active":"inactive",I["data-orientation"]=C||"horizontal",n(b.div,{ref:u,className:l(m,a),id:void 0!==t?g(T,t):void 0,role:"tabpanel","aria-labelledby":void 0!==t?w?.[t]??f(T,t):void 0,tabIndex:N?0:void 0,hidden:!N,"aria-hidden":!N,"data-slot":"tabs-content",asChild:r,...I,...d,children:o})}));w.displayName=R;const N="Tabs",I=a.forwardRef((({children:a,defaultValue:t="",onValueChange:e=()=>{},customRootClass:m="",value:v,className:f,color:g,orientation:C="horizontal",dir:T="ltr",loop:R=!0,activationMode:w="automatic",asChild:I=!1,...j},x)=>{const y=c(m,N),[P,$]=h(v,t||"",e),L=i(),[V,M]=r({}),k=s(((a,t)=>{M((e=>{if(e[a]===t)return e;const o={...e};return void 0===t?delete o[a]:o[a]=t,o}))}),[]),z=a=>{a!==P&&$(a)},E=d(!0);o((()=>{E.current?E.current=!1:void 0===v&&t&&z(t)}),[t,v]);const F={rootClass:y,baseId:L,tabValue:P,handleTabChange:z,orientation:C,activationMode:w,customTriggerIds:V,registerTriggerId:k},D={};return D["data-orientation"]=C,n(p.Provider,{value:F,children:n(u.Root,{orientation:C,loop:R,dir:T,asChild:!0,children:n(b.div,{ref:x,className:l(y,f),"data-color":g,"data-slot":"tabs-root",dir:T,asChild:I,...D,...j,children:a})})})}));I.displayName=N;const j=a.forwardRef(((a,t)=>(console.warn("Direct usage of Tabs is not supported. Please use Tabs.Root, Tabs.List, etc. instead."),null)));j.displayName="Tabs",j.List=C,j.Content=w,j.Root=I,j.Trigger=T;export{w as Content,C as List,I as Root,T as Trigger,j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),s=require("./useComponentClass-B0DF90tm.cjs");require("./ThemeContext-t7IX-w6i.cjs");const r="Text",t=["div","span","p","label"],a=e.forwardRef((({children:a,customRootClass:l="",className:o="",as:c="p",...n},u)=>{const p=s.useComponentClass(l,r);return t.includes(c)||(c="p"),e.createElement(c,{ref:u,className:s.clsx(p,o),...n},a)}));a.displayName=r,exports.default=a;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),a=require("./useComponentClass-B0DF90tm.cjs"),t=require("./index-c6NFMS_0.cjs");require("./ThemeContext-t7IX-w6i.cjs");const s="TextArea",o=r.forwardRef((({children:r,customRootClass:o="",className:i="",variant:l="",size:c="",resize:d="both",color:n="",radius:u="",...p},x)=>{const f=a.useComponentClass(o,s),m=t.createDataAttributes("textarea",{variant:l,size:c,resize:d,radius:u}),h=t.createDataAccentColorAttribute(n),v=t.composeAttributes(m,h);return e.jsx("div",{ref:x,className:a.clsx(f,i),...p,...v,children:r})}));o.displayName=s;const i=r.forwardRef((({children:r,placeholder:a="",value:t,defaultValue:s,...o},i)=>{const l=void 0===t&&void 0===s&&"string"==typeof r?r:void 0;return e.jsx("textarea",{ref:i,placeholder:a,value:t,defaultValue:s??l,...o})}));i.displayName="TextAreaInput";const l=r.forwardRef((({customRootClass:r="",className:t="",style:s,variant:l,size:c,resize:d,color:n,radius:u,readonly:p=!1,readOnly:x,disabled:f=!1,placeholder:m="",children:h,...v},j)=>{const y={},b={};return Object.entries(v).forEach((([e,r])=>{e.startsWith("data-")?y[e]=r:b[e]=r})),e.jsx(o,{ref:j,customRootClass:r,className:a.clsx(t),style:s,variant:l,size:c,resize:d,color:n,radius:u,"data-disabled":f?"":void 0,...y,children:e.jsx(i,{placeholder:m,disabled:f,readOnly:x??p,...b,children:h})})}));l.displayName="TextArea",l.Input=i,l.Root=o,exports.Input=i,exports.Root=o,exports.default=l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./useComponentClass-B0DF90tm.cjs"),l=require("./mergeProps-DW5qFqqJ.cjs");require("./ThemeContext-t7IX-w6i.cjs");const a=t.createContext({rootClass:"",inputRef:{current:null},clearInput:()=>{},hasValue:!1,setHasValue:()=>!1,isLocked:!1,setIsLocked:()=>!1}),o="TextField",r=t.forwardRef((({className:l="",customRootClass:r="",children:n,...u},c)=>{const d=s.useComponentClass(r,o),i=t.useRef(null),[p,f]=t.useState(!1),[x,m]=t.useState(!1),C=t.useCallback((()=>{const e=i.current;if(!e)return;const t=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"value")?.set;t?.call(e,""),e.dispatchEvent(new Event("input",{bubbles:!0})),f(!1),e.focus()}),[]);return e.jsx(a.Provider,{value:{rootClass:d,inputRef:i,clearInput:C,hasValue:p,setHasValue:f,isLocked:x,setIsLocked:m},children:e.jsx("div",{ref:c,className:s.clsx(d,l),"data-slot":"text-field-root",...u,children:n})})}));r.displayName=o;const n=t.forwardRef((({className:o="",type:r="text",onChange:n,onInput:u,value:c,defaultValue:d,...i},p)=>{const{rootClass:f,inputRef:x,setHasValue:m,setIsLocked:C}=t.useContext(a),h=Boolean(i.disabled||i.readOnly);t.useEffect((()=>{C(h)}),[h,C]),t.useEffect((()=>{void 0===c?void 0!==d&&m(String(d).length>0):m(String(c).length>0)}),[d,m,c]);return e.jsx("input",{ref:l.composeRefs(p,x),type:r,className:s.clsx(f&&`${f}-input`,o),"data-slot":"text-field-input",value:c,defaultValue:d,onInput:e=>{m(e.currentTarget.value.length>0),u?.(e)},onChange:e=>{m(e.currentTarget.value.length>0),n?.(e)},...i})}));n.displayName="TextFieldInput";const u=t.forwardRef((({children:l,className:o="",side:r,...n},u)=>{const{rootClass:c,inputRef:d}=t.useContext(a);return e.jsx("div",{ref:u,role:"presentation",className:s.clsx(c&&`${c}-slot`,o),"data-slot":"text-field-slot","data-text-field-slot":r,...n,onMouseDown:e=>{n.onMouseDown?.(e),e.defaultPrevented||(e.preventDefault(),d.current?.focus())},children:l})}));u.displayName="TextFieldSlot";const c=t.forwardRef((({className:l="",type:o="button",onClick:r,children:n,...u},c)=>{const{rootClass:d,clearInput:i,inputRef:p,hasValue:f,isLocked:x}=t.useContext(a);return!f||x?null:e.jsx("button",{ref:c,type:o,className:s.clsx(d&&`${d}-reset`,l),"data-slot":"text-field-reset",onClick:e=>{r?.(e),e.defaultPrevented||p.current?.disabled||p.current?.readOnly||i()},...u,children:n})}));c.displayName="TextFieldReset";const d=t.forwardRef((({className:t="",customRootClass:l="",inputClassName:a="",startSlot:o,endSlot:c,type:d="text",...i},p)=>e.jsxs(r,{customRootClass:l,className:s.clsx(t),children:[o?e.jsx(u,{side:"start",children:o}):null,e.jsx(n,{ref:p,type:d,className:s.clsx(a),...i}),c?e.jsx(u,{side:"end",children:c}):null]})));d.displayName="TextField",d.Root=r,d.Input=n,d.Slot=u,d.Reset=c,exports.Input=n,exports.Reset=c,exports.Root=r,exports.Slot=u,exports.default=d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("./ThemeContext-t7IX-w6i.cjs");const r=t.forwardRef((function({appearance:r="dark",id:s="rad-ui-theme-container",accentColor:c="",radius:u="",scaling:n="",classNamespace:i,children:d,...o},f){const l=t.useRef(null),h=t.useRef(null),[m,p]=t.useState(r),[v,x]=t.useState(c),[E,R]=t.useState(u),[g,j]=t.useState(n),k=t.useRef(f);t.useEffect((()=>{k.current=f}),[f]);const y=t.useCallback((e=>{l.current=e,((e,t)=>{"function"!=typeof e?e&&(e.current=t):e(t)})(k.current,e)}),[]);return t.useEffect((()=>{const e=window.matchMedia("(prefers-color-scheme: dark)"),t=e=>{"system"===r&&p(e.matches?"dark":"light")};return"system"===r?(p(e.matches?"dark":"light"),e.addEventListener("change",t)):p(r),()=>e.removeEventListener("change",t)}),[r]),t.useEffect((()=>{c&&x(c)}),[c]),t.useEffect((()=>{u&&R(u)}),[u]),t.useEffect((()=>{n&&j(n)}),[n]),e.jsx(a.ThemeContext.Provider,{value:{containerRef:l,portalRootRef:h,classNamespace:i},children:e.jsxs("div",{ref:y,id:s,"data-rad-ui-theme":m,"data-rad-ui-accent-color":v,"data-rad-ui-radius":E,"data-rad-ui-scaling":g,...o,children:[d,e.jsx("div",{ref:h,"data-rad-ui-portal-root":""})]})})}));r.displayName="Theme",exports.default=r;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ComponentPropsWithoutRef } from 'react';
|
|
2
2
|
|
|
3
3
|
type ThemeProps = ComponentPropsWithoutRef<'div'> & {
|
|
4
|
+
/** Color scheme. Defaults to `'dark'`; pass `'system'` to follow the OS preference. */
|
|
4
5
|
appearance?: 'light' | 'dark' | 'system';
|
|
5
6
|
accentColor?: string;
|
|
6
7
|
radius?: string;
|
|
@@ -8,6 +9,7 @@ type ThemeProps = ComponentPropsWithoutRef<'div'> & {
|
|
|
8
9
|
classNamespace?: string;
|
|
9
10
|
};
|
|
10
11
|
declare const Theme: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
|
|
12
|
+
/** Color scheme. Defaults to `'dark'`; pass `'system'` to follow the OS preference. */
|
|
11
13
|
appearance?: "light" | "dark" | "system";
|
|
12
14
|
accentColor?: string;
|
|
13
15
|
radius?: string;
|
package/dist/components/Theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use client';import{jsx as e,jsxs as a}from"react/jsx-runtime";import{forwardRef as r,useRef as t,useState as n,useEffect as c,useCallback as i}from"react";import{T as o}from"./ThemeContext-Sm-iNANd.js";const
|
|
1
|
+
'use client';import{jsx as e,jsxs as a}from"react/jsx-runtime";import{forwardRef as r,useRef as t,useState as n,useEffect as c,useCallback as i}from"react";import{T as o}from"./ThemeContext-Sm-iNANd.js";const d=r((function({appearance:r="dark",id:d="rad-ui-theme-container",accentColor:s="",radius:l="",scaling:m="",classNamespace:u,children:h,...p},f){const v=t(null),g=t(null),[k,y]=n(r),[x,N]=n(s),[R,T]=n(l),[j,w]=n(m),C=t(f);c((()=>{C.current=f}),[f]);const E=i((e=>{v.current=e,((e,a)=>{"function"!=typeof e?e&&(e.current=a):e(a)})(C.current,e)}),[]);return c((()=>{const e=window.matchMedia("(prefers-color-scheme: dark)"),a=e=>{"system"===r&&y(e.matches?"dark":"light")};return"system"===r?(y(e.matches?"dark":"light"),e.addEventListener("change",a)):y(r),()=>e.removeEventListener("change",a)}),[r]),c((()=>{s&&N(s)}),[s]),c((()=>{l&&T(l)}),[l]),c((()=>{m&&w(m)}),[m]),e(o.Provider,{value:{containerRef:v,portalRootRef:g,classNamespace:u},children:a("div",{ref:E,id:d,"data-rad-ui-theme":k,"data-rad-ui-accent-color":x,"data-rad-ui-radius":R,"data-rad-ui-scaling":j,...p,children:[h,e("div",{ref:g,"data-rad-ui-portal-root":""})]})})}));d.displayName="Theme";export{d as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use client';"use strict";const e=require("react").createContext(null);exports.ThemeContext=e;
|