UNPKG

dgz-ui-shared

Version:

Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library

12 lines (11 loc) 5.56 kB
"use strict";const _=require("./createLucideIcon-B950nf2d-DrrWmvZU.cjs"),b=require("react"),t=require("./index-BL59b1Bz-COeLljOH.cjs");function H(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const c in e)if(c!=="default"){const n=Object.getOwnPropertyDescriptor(e,c);Object.defineProperty(r,c,n.get?n:{enumerable:!0,get:()=>e[c]})}}return r.default=e,Object.freeze(r)}const s=H(b);function O(e){const r=e+"CollectionProvider",[c,n]=t.j(r),[F,y]=c(r,{collectionRef:{current:null},itemMap:new Map}),v=d=>{const{scope:o,children:u}=d,a=b.useRef(null),l=b.useRef(new Map).current;return t.ae.jsx(F,{scope:o,itemMap:l,collectionRef:a,children:u})};v.displayName=r;const g=e+"CollectionSlot",I=t.S(g),m=b.forwardRef((d,o)=>{const{scope:u,children:a}=d,l=y(g,u),p=t.i(o,l.collectionRef);return t.ae.jsx(I,{ref:p,children:a})});m.displayName=g;const i=e+"CollectionItemSlot",w="data-radix-collection-item",S=t.S(i),h=b.forwardRef((d,o)=>{const{scope:u,children:a,...l}=d,p=b.useRef(null),C=t.i(o,p),A=y(i,u);return b.useEffect(()=>(A.itemMap.set(p,{ref:p,...l}),()=>void A.itemMap.delete(p))),t.ae.jsx(S,{[w]:"",ref:C,children:a})});h.displayName=i;function x(d){const o=y(e+"CollectionConsumer",d);return b.useCallback(()=>{const u=o.collectionRef.current;if(!u)return[];const a=Array.from(u.querySelectorAll(`[${w}]`));return Array.from(o.itemMap.values()).sort((l,p)=>a.indexOf(l.ref.current)-a.indexOf(p.ref.current))},[o.collectionRef,o.itemMap])}return[{Provider:v,Slot:m,ItemSlot:h},x,n]}var X=s.createContext(void 0);function P(e){const r=s.useContext(X);return e||r||"ltr"}/** * @license lucide-react v0.511.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const Y=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Z=_.k("check",Y);/** * @license lucide-react v0.511.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const J=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Q=_.k("circle",J);var D="rovingFocusGroup.onEntryFocus",V={bubbles:!1,cancelable:!0},T="RovingFocusGroup",[E,$,W]=O(T),[ee,te]=t.j(T,[W]),[oe,re]=ee(T),L=s.forwardRef((e,r)=>t.ae.jsx(E.Provider,{scope:e.__scopeRovingFocusGroup,children:t.ae.jsx(E.Slot,{scope:e.__scopeRovingFocusGroup,children:t.ae.jsx(ne,{...e,ref:r})})}));L.displayName=T;var ne=s.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:c,orientation:n,loop:F=!1,dir:y,currentTabStopId:v,defaultCurrentTabStopId:g,onCurrentTabStopIdChange:I,onEntryFocus:m,preventScrollOnEntryFocus:i=!1,...w}=e,S=s.useRef(null),h=t.i(r,S),x=P(y),[d,o]=t.y({prop:v,defaultProp:g??null,onChange:I,caller:T}),[u,a]=s.useState(!1),l=t.n(m),p=$(c),C=s.useRef(!1),[A,M]=s.useState(0);return s.useEffect(()=>{const f=S.current;if(f)return f.addEventListener(D,l),()=>f.removeEventListener(D,l)},[l]),t.ae.jsx(oe,{scope:c,orientation:n,dir:x,loop:F,currentTabStopId:d,onItemFocus:s.useCallback(f=>o(f),[o]),onItemShiftTab:s.useCallback(()=>a(!0),[]),onFocusableItemAdd:s.useCallback(()=>M(f=>f+1),[]),onFocusableItemRemove:s.useCallback(()=>M(f=>f-1),[]),children:t.ae.jsx(t.h.div,{tabIndex:u||A===0?-1:0,"data-orientation":n,...w,ref:h,style:{outline:"none",...e.style},onMouseDown:t.y$1(e.onMouseDown,()=>{C.current=!0}),onFocus:t.y$1(e.onFocus,f=>{const G=!C.current;if(f.target===f.currentTarget&&G&&!u){const k=new CustomEvent(D,V);if(f.currentTarget.dispatchEvent(k),!k.defaultPrevented){const j=p().filter(R=>R.focusable),q=j.find(R=>R.active),U=j.find(R=>R.id===d),z=[q,U,...j].filter(Boolean).map(R=>R.ref.current);B(z,i)}}C.current=!1}),onBlur:t.y$1(e.onBlur,()=>a(!1))})})}),K="RovingFocusGroupItem",N=s.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:c,focusable:n=!0,active:F=!1,tabStopId:y,children:v,...g}=e,I=t.g(),m=y||I,i=re(K,c),w=i.currentTabStopId===m,S=$(c),{onFocusableItemAdd:h,onFocusableItemRemove:x,currentTabStopId:d}=i;return s.useEffect(()=>{if(n)return h(),()=>x()},[n,h,x]),t.ae.jsx(E.ItemSlot,{scope:c,id:m,focusable:n,active:F,children:t.ae.jsx(t.h.span,{tabIndex:w?0:-1,"data-orientation":i.orientation,...g,ref:r,onMouseDown:t.y$1(e.onMouseDown,o=>{n?i.onItemFocus(m):o.preventDefault()}),onFocus:t.y$1(e.onFocus,()=>i.onItemFocus(m)),onKeyDown:t.y$1(e.onKeyDown,o=>{if(o.key==="Tab"&&o.shiftKey){i.onItemShiftTab();return}if(o.target!==o.currentTarget)return;const u=le(o,i.orientation,i.dir);if(u!==void 0){if(o.metaKey||o.ctrlKey||o.altKey||o.shiftKey)return;o.preventDefault();let a=S().filter(l=>l.focusable).map(l=>l.ref.current);if(u==="last")a.reverse();else if(u==="prev"||u==="next"){u==="prev"&&a.reverse();const l=a.indexOf(o.currentTarget);a=i.loop?ue(a,l+1):a.slice(l+1)}setTimeout(()=>B(a))}}),children:typeof v=="function"?v({isCurrentTabStop:w,hasTabStop:d!=null}):v})})});N.displayName=K;var ce={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function ae(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function le(e,r,c){const n=ae(e.key,c);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return ce[n]}function B(e,r=!1){const c=document.activeElement;for(const n of e)if(n===c||(n.focus({preventScroll:r}),document.activeElement!==c))return}function ue(e,r){return e.map((c,n)=>e[(r+n)%e.length])}var ie=L,se=N;exports.D=O;exports.Fe=ie;exports.a=Q;exports.be=te;exports.ge=se;exports.n=P;exports.t=Z;