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